@stream-mdx/react 0.5.0 → 1.0.0

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/README.md +79 -4
  3. package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
  4. package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
  5. package/dist/components/bottom-stick-scroll-area.cjs +117 -193
  6. package/dist/components/bottom-stick-scroll-area.mjs +112 -183
  7. package/dist/components/diff-renderer.cjs +86 -0
  8. package/dist/components/diff-renderer.d.cts +11 -0
  9. package/dist/components/diff-renderer.d.ts +11 -0
  10. package/dist/components/diff-renderer.mjs +66 -0
  11. package/dist/components/index.cjs +2761 -1508
  12. package/dist/components/index.d.cts +7 -2
  13. package/dist/components/index.d.ts +7 -2
  14. package/dist/components/index.mjs +2730 -1493
  15. package/dist/components/katex-math.cjs +220 -0
  16. package/dist/components/katex-math.d.cts +10 -0
  17. package/dist/components/katex-math.d.ts +10 -0
  18. package/dist/components/katex-math.mjs +188 -0
  19. package/dist/contexts/math-tracker.cjs +240 -521
  20. package/dist/contexts/math-tracker.mjs +235 -513
  21. package/dist/index-Cmne1yUK.d.cts +723 -0
  22. package/dist/index-D7dyyu3q.d.ts +723 -0
  23. package/dist/index.cjs +13029 -6475
  24. package/dist/index.d.cts +69 -39
  25. package/dist/index.d.ts +69 -39
  26. package/dist/index.mjs +13007 -6442
  27. package/dist/math/display-wrapper.cjs +7 -15
  28. package/dist/math/display-wrapper.d.cts +2 -2
  29. package/dist/math/display-wrapper.d.ts +2 -2
  30. package/dist/math/display-wrapper.mjs +2 -6
  31. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  32. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  33. package/dist/renderer/hooks.cjs +35 -20
  34. package/dist/renderer/hooks.d.cts +22 -1
  35. package/dist/renderer/hooks.d.ts +22 -1
  36. package/dist/renderer/hooks.mjs +27 -12
  37. package/dist/renderer/patch-batching.cjs +5 -8
  38. package/dist/renderer/patch-coalescing.cjs +5 -8
  39. package/dist/renderer/patch-commit-scheduler.cjs +138 -356
  40. package/dist/renderer/patch-commit-scheduler.d.cts +13 -1
  41. package/dist/renderer/patch-commit-scheduler.d.ts +13 -1
  42. package/dist/renderer/patch-commit-scheduler.mjs +133 -348
  43. package/dist/renderer/store.cjs +3775 -1373
  44. package/dist/renderer/store.d.cts +108 -3
  45. package/dist/renderer/store.d.ts +108 -3
  46. package/dist/renderer/store.mjs +3778 -1362
  47. package/dist/renderer/virtualized-code.cjs +415 -71
  48. package/dist/renderer/virtualized-code.d.cts +24 -23
  49. package/dist/renderer/virtualized-code.d.ts +24 -23
  50. package/dist/renderer/virtualized-code.mjs +409 -62
  51. package/dist/renderer.cjs +10655 -4334
  52. package/dist/renderer.d.cts +98 -29
  53. package/dist/renderer.d.ts +98 -29
  54. package/dist/renderer.mjs +10582 -4212
  55. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  56. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  57. package/dist/server.cjs +10195 -3872
  58. package/dist/server.d.cts +17 -252
  59. package/dist/server.d.ts +17 -252
  60. package/dist/server.mjs +9997 -3649
  61. package/dist/{streaming-markdown-CEI9eDZm.d.ts → streaming-markdown-yELbJxyH.d.ts} +49 -55
  62. package/dist/{streaming-markdown-DRisClXb.d.cts → streaming-markdown-zVwFuaJG.d.cts} +49 -55
  63. package/dist/streaming-markdown.cjs +11660 -5378
  64. package/dist/streaming-markdown.d.cts +7 -2
  65. package/dist/streaming-markdown.d.ts +7 -2
  66. package/dist/streaming-markdown.mjs +11679 -5347
  67. package/dist/trusted-mdx/index.cjs +833 -0
  68. package/dist/trusted-mdx/index.d.cts +11 -0
  69. package/dist/trusted-mdx/index.d.ts +11 -0
  70. package/dist/trusted-mdx/index.mjs +807 -0
  71. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  72. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  73. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  74. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  75. package/dist/trusted-mdx/server.cjs +752 -0
  76. package/dist/trusted-mdx/server.d.cts +24 -0
  77. package/dist/trusted-mdx/server.d.ts +24 -0
  78. package/dist/trusted-mdx/server.mjs +724 -0
  79. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  80. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  81. package/dist/utils/inline-html.cjs +246 -147
  82. package/dist/utils/inline-html.d.cts +37 -6
  83. package/dist/utils/inline-html.d.ts +37 -6
  84. package/dist/utils/inline-html.mjs +237 -134
  85. package/package.json +41 -18
  86. package/dist/index-BVhp_pcF.d.ts +0 -251
  87. package/dist/index-EaeouYp2.d.cts +0 -251
  88. package/dist/mdx-client.cjs +0 -408
  89. package/dist/mdx-client.d.cts +0 -113
  90. package/dist/mdx-client.d.ts +0 -113
  91. package/dist/mdx-client.mjs +0 -369
  92. package/dist/mdx-coordinator.cjs +0 -584
  93. package/dist/mdx-coordinator.d.cts +0 -21
  94. package/dist/mdx-coordinator.d.ts +0 -21
  95. package/dist/mdx-coordinator.mjs +0 -550
  96. package/dist/renderer/node-views.cjs +0 -1887
  97. package/dist/renderer/node-views.d.cts +0 -14
  98. package/dist/renderer/node-views.d.ts +0 -14
  99. package/dist/renderer/node-views.mjs +0 -1861
@@ -6,17 +6,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
8
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
13
12
  for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  return to;
18
15
  };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
20
17
 
21
18
  // src/renderer/patch-commit-scheduler.ts
22
19
  var patch_commit_scheduler_exports = {};
@@ -30,36 +27,56 @@ var import_patch_batching = require("@stream-mdx/core/perf/patch-batching");
30
27
  var import_core = require("@stream-mdx/core");
31
28
 
32
29
  // src/renderer/patch-commit-scheduler.ts
33
- var DEFAULT_TIMEOUT_MS = 16;
34
- var COALESCING_DURATION_SAMPLE_LIMIT = 60;
35
- var COALESCING_DURATION_ACTIVATE_MS = 6;
36
- var COALESCING_DURATION_DEACTIVATE_MS = 4;
37
- var RETAIN_TOUCHED_IN_HISTORY = typeof process !== "undefined" && process.env ? process.env.NODE_ENV !== "production" : true;
38
- var EMPTY_TOUCHED_SET = /* @__PURE__ */ new Set();
30
+ var DEFAULT_TIMEOUT_MS = 16, COALESCING_DURATION_SAMPLE_LIMIT = 60, COALESCING_DURATION_ACTIVATE_MS = 6, COALESCING_DURATION_DEACTIVATE_MS = 4, RETAIN_TOUCHED_IN_HISTORY = typeof process < "u" && process.env ? process.env.NODE_ENV !== "production" : !0, EMPTY_TOUCHED_SET = /* @__PURE__ */ new Set();
31
+ function semanticEnvelopeKeyForPatch(patch) {
32
+ if ((0, import_patch_batching.getPatchKind)(patch) !== "semantic") return;
33
+ let meta = patch.op === "setHTML" ? patch.patchMeta : patch.meta, streamSeq = meta?.streamSeq, parseEpoch = meta?.parseEpoch, tx = meta?.tx;
34
+ if (!(typeof streamSeq != "number" || !Number.isFinite(streamSeq) || streamSeq < 0 || typeof parseEpoch != "number" || !Number.isFinite(parseEpoch) || parseEpoch < 0 || typeof tx != "number" || !Number.isFinite(tx) || tx < 0))
35
+ return `${streamSeq}/${parseEpoch}/${tx}`;
36
+ }
39
37
  function shouldSkipCoalescing(patches) {
40
- return patches.length <= 1;
38
+ if (patches.length <= 1) return !0;
39
+ let firstEnvelopeKey, hasEnvelopeKey = !1, hasMultipleEnvelopes = !1, hasUnsequencedSemantic = !1, hasEnrichment = !1, observePatch = (patch) => {
40
+ if ((0, import_patch_batching.getPatchKind)(patch) === "enrichment") {
41
+ hasEnrichment = !0;
42
+ return;
43
+ }
44
+ let key = semanticEnvelopeKeyForPatch(patch);
45
+ if (key === void 0) {
46
+ hasUnsequencedSemantic = !0;
47
+ return;
48
+ }
49
+ hasEnvelopeKey && firstEnvelopeKey !== key && (hasMultipleEnvelopes = !0), hasEnvelopeKey || (firstEnvelopeKey = key, hasEnvelopeKey = !0);
50
+ };
51
+ for (let patch of patches)
52
+ if (patch.op === "setPropsBatch")
53
+ for (let entry of patch.entries ?? [])
54
+ !entry || !entry.at || observePatch({
55
+ op: "setProps",
56
+ at: entry.at,
57
+ props: entry.props,
58
+ meta: { ...patch.meta ?? {}, ...entry.meta ?? {} }
59
+ });
60
+ else
61
+ observePatch(patch);
62
+ return hasEnvelopeKey && (hasMultipleEnvelopes || hasUnsequencedSemantic || hasEnrichment);
41
63
  }
42
64
  function getDefaultNow() {
43
- if (typeof performance !== "undefined" && typeof performance.now === "function") {
44
- return () => performance.now();
45
- }
46
- return () => Date.now();
65
+ return typeof performance < "u" && typeof performance.now == "function" ? () => performance.now() : () => Date.now();
47
66
  }
48
67
  function getDefaultRaf() {
49
- if (typeof globalThis !== "undefined") {
50
- const candidate = globalThis.requestAnimationFrame;
51
- if (typeof candidate === "function") {
68
+ if (typeof globalThis < "u") {
69
+ let candidate = globalThis.requestAnimationFrame;
70
+ if (typeof candidate == "function")
52
71
  return candidate.bind(globalThis);
53
- }
54
72
  }
55
73
  return null;
56
74
  }
57
75
  function getDefaultCancelRaf() {
58
- if (typeof globalThis !== "undefined") {
59
- const candidate = globalThis.cancelAnimationFrame;
60
- if (typeof candidate === "function") {
76
+ if (typeof globalThis < "u") {
77
+ let candidate = globalThis.cancelAnimationFrame;
78
+ if (typeof candidate == "function")
61
79
  return candidate.bind(globalThis);
62
- }
63
80
  }
64
81
  return null;
65
82
  }
@@ -68,97 +85,52 @@ var PatchCommitScheduler = class {
68
85
  this.semanticQueue = [];
69
86
  this.enrichmentHighQueue = [];
70
87
  this.enrichmentLowQueue = [];
71
- this.scheduled = false;
72
- this.flushing = false;
88
+ this.scheduled = !1;
89
+ this.flushing = !1;
73
90
  this.scheduledHandle = null;
74
- this.scheduledViaRaf = false;
91
+ this.scheduledViaRaf = !1;
75
92
  this.sequence = 0;
76
93
  this.idleResolvers = [];
77
- this.paused = false;
94
+ this.paused = !1;
78
95
  this.history = [];
79
96
  this.scheduleToken = 0;
80
97
  this.coalescingDurationSamples = [];
81
- this.adaptiveBudgetActive = false;
98
+ this.adaptiveBudgetActive = !1;
82
99
  this.flushCount = 0;
83
- this.store = params.store;
84
- this.onFlush = params.onFlush;
85
- this.frameBudgetMs = Math.max(1, params.options?.frameBudgetMs ?? 10);
86
- this.maxBatchesPerFlush = params.options?.maxBatchesPerFlush ?? 12;
87
- this.now = params.options?.now ?? getDefaultNow();
88
- this.raf = params.options?.raf ?? getDefaultRaf();
89
- this.cancelRaf = params.options?.cancelRaf ?? getDefaultCancelRaf();
90
- this.timeoutMs = Math.max(1, params.options?.timeoutMs ?? DEFAULT_TIMEOUT_MS);
91
- this.lowPriorityFrameBudgetMs = Math.max(
100
+ this.store = params.store, this.onFlush = params.onFlush, this.isGenerationCurrent = params.isGenerationCurrent, this.frameBudgetMs = Math.max(1, params.options?.frameBudgetMs ?? 4), this.maxBatchesPerFlush = params.options?.maxBatchesPerFlush ?? 12, this.now = params.options?.now ?? getDefaultNow(), this.raf = params.options?.raf ?? getDefaultRaf(), this.cancelRaf = params.options?.cancelRaf ?? getDefaultCancelRaf(), this.timeoutMs = Math.max(1, params.options?.timeoutMs ?? DEFAULT_TIMEOUT_MS), this.lowPriorityFrameBudgetMs = Math.max(
92
101
  1,
93
102
  params.options?.lowPriorityFrameBudgetMs ?? Math.max(2, Math.floor(this.frameBudgetMs * 0.6))
94
- );
95
- this.maxLowPriorityBatchesPerFlush = params.options?.maxLowPriorityBatchesPerFlush ?? 2;
96
- this.urgentQueueThreshold = Math.max(1, params.options?.urgentQueueThreshold ?? 4);
97
- this.historyLimit = Math.max(1, params.options?.historyLimit ?? 200);
98
- this.startupMicrotaskFlushes = Math.max(0, Math.floor(params.options?.startupMicrotaskFlushes ?? 0));
99
- this.adaptiveBudgeting = params.options?.adaptiveBudgeting ?? true;
100
- const requestedBatch = params.options?.batch;
101
- if (requestedBatch === "microtask") {
102
- this.batchStrategy = "microtask";
103
- } else if (requestedBatch === "timeout") {
104
- this.batchStrategy = "timeout";
105
- } else if (requestedBatch === "rAF") {
106
- this.batchStrategy = this.raf ? "rAF" : "timeout";
107
- } else {
108
- this.batchStrategy = "microtask";
109
- }
110
- if (this.batchStrategy === "microtask" && typeof queueMicrotask !== "function") {
111
- this.batchStrategy = this.raf ? "rAF" : "timeout";
112
- }
103
+ ), this.maxLowPriorityBatchesPerFlush = params.options?.maxLowPriorityBatchesPerFlush ?? 2, this.urgentQueueThreshold = Math.max(1, params.options?.urgentQueueThreshold ?? 4), this.historyLimit = Math.max(1, params.options?.historyLimit ?? 200), this.startupMicrotaskFlushes = Math.max(0, Math.floor(params.options?.startupMicrotaskFlushes ?? 0)), this.adaptiveBudgeting = params.options?.adaptiveBudgeting ?? !0;
104
+ let requestedBatch = params.options?.batch;
105
+ requestedBatch === "microtask" ? this.batchStrategy = "microtask" : requestedBatch === "timeout" ? this.batchStrategy = "timeout" : requestedBatch === "rAF" ? this.batchStrategy = this.raf ? "rAF" : "timeout" : this.batchStrategy = this.raf ? "rAF" : "timeout", this.batchStrategy === "microtask" && typeof queueMicrotask != "function" && (this.batchStrategy = this.raf ? "rAF" : "timeout");
113
106
  }
114
107
  enqueue(input) {
115
- if (!input || !input.patches || input.patches.length === 0) {
108
+ if (!input || !input.patches || input.patches.length === 0)
116
109
  return;
117
- }
118
- if (!this.paused && !this.flushing && this.getPendingCount() >= this.urgentQueueThreshold) {
119
- this.runFlush(this.frameBudgetMs, false);
120
- }
121
- const batch = {
110
+ this.batchStrategy !== "rAF" && !this.paused && !this.flushing && this.getPendingCount() >= this.urgentQueueThreshold && this.runFlush(this.frameBudgetMs, !1);
111
+ let explicitKind = input.meta?.kind, hasExplicitKind = explicitKind === "semantic" || explicitKind === "enrichment", hasSemanticPatch = !1, hasNonInputSourcePatch = !1;
112
+ for (let patch of input.patches)
113
+ patch.op !== "appendInputSource" && (hasNonInputSourcePatch = !0), !hasExplicitKind && !hasSemanticPatch && (0, import_patch_batching.getPatchKind)(patch) === "semantic" && (hasSemanticPatch = !0);
114
+ let batch = {
122
115
  seq: ++this.sequence,
123
116
  patches: input.patches,
124
117
  meta: input.meta ?? {},
125
118
  receivedAt: input.meta?.receivedAt ?? this.now(),
126
- kind: input.meta?.kind === "semantic" || input.meta?.kind === "enrichment" ? input.meta.kind : input.patches.some((patch) => (0, import_patch_batching.getPatchKind)(patch) === "semantic") ? "semantic" : "enrichment",
119
+ kind: explicitKind === "semantic" || explicitKind === "enrichment" ? explicitKind : hasSemanticPatch ? "semantic" : "enrichment",
120
+ hasNonInputSourcePatch,
127
121
  priority: input.meta?.priority === "low" ? "low" : "high"
128
122
  };
129
- if (batch.kind === "semantic") {
130
- batch.priority = "high";
131
- this.semanticQueue.push(batch);
132
- } else if (batch.priority === "low") {
133
- this.enrichmentLowQueue.push(batch);
134
- } else {
135
- this.enrichmentHighQueue.push(batch);
136
- }
137
- if (!this.paused) {
138
- this.schedule();
139
- }
123
+ batch.kind === "semantic" ? (batch.priority = "high", this.semanticQueue.push(batch)) : batch.priority === "low" ? this.enrichmentLowQueue.push(batch) : this.enrichmentHighQueue.push(batch), this.paused || this.schedule();
140
124
  }
141
125
  flushAll() {
142
- if (this.semanticQueue.length === 0 && this.enrichmentHighQueue.length === 0 && this.enrichmentLowQueue.length === 0 && !this.flushing) {
126
+ if (this.semanticQueue.length === 0 && this.enrichmentHighQueue.length === 0 && this.enrichmentLowQueue.length === 0 && !this.flushing)
143
127
  return null;
144
- }
145
128
  this.cancelScheduled();
146
- const result = this.runFlush(Number.POSITIVE_INFINITY, true);
147
- this.maybeResolveIdle();
148
- return result;
129
+ let result = this.runFlush(Number.POSITIVE_INFINITY, !0);
130
+ return this.maybeResolveIdle(), result;
149
131
  }
150
132
  clear() {
151
- this.cancelScheduled();
152
- this.semanticQueue = [];
153
- this.enrichmentHighQueue = [];
154
- this.enrichmentLowQueue = [];
155
- this.flushing = false;
156
- this.flushCount = 0;
157
- this.coalescingDurationSamples = [];
158
- this.adaptiveBudgetActive = false;
159
- this.adaptiveHighBatchCap = void 0;
160
- this.adaptiveLowBatchCap = void 0;
161
- this.maybeResolveIdle();
133
+ this.cancelScheduled(), this.semanticQueue = [], this.enrichmentHighQueue = [], this.enrichmentLowQueue = [], this.flushing = !1, this.flushCount = 0, this.coalescingDurationSamples = [], this.adaptiveBudgetActive = !1, this.adaptiveHighBatchCap = void 0, this.adaptiveLowBatchCap = void 0, this.maybeResolveIdle();
162
134
  }
163
135
  getPendingCount() {
164
136
  return this.semanticQueue.length + this.enrichmentHighQueue.length + this.enrichmentLowQueue.length;
@@ -167,114 +139,54 @@ var PatchCommitScheduler = class {
167
139
  return !this.flushing && !this.scheduled && this.semanticQueue.length === 0 && this.enrichmentHighQueue.length === 0 && this.enrichmentLowQueue.length === 0;
168
140
  }
169
141
  awaitIdle() {
170
- if (this.isIdle()) {
171
- return Promise.resolve();
172
- }
173
- return new Promise((resolve) => {
142
+ return this.isIdle() ? Promise.resolve() : new Promise((resolve) => {
174
143
  this.idleResolvers.push(resolve);
175
144
  });
176
145
  }
177
146
  schedule() {
178
- if (this.paused) {
147
+ if (this.paused || this.scheduled || this.flushing)
179
148
  return;
180
- }
181
- if (this.scheduled || this.flushing) {
182
- return;
183
- }
184
- const token = ++this.scheduleToken;
185
- this.scheduled = true;
186
- const execute = () => {
149
+ let token = ++this.scheduleToken;
150
+ this.scheduled = !0;
151
+ let execute = () => {
187
152
  if (token !== this.scheduleToken) {
188
- this.scheduled = false;
189
- this.scheduledHandle = null;
190
- this.scheduledViaRaf = false;
191
- this.maybeResolveIdle();
153
+ this.scheduled = !1, this.scheduledHandle = null, this.scheduledViaRaf = !1, this.maybeResolveIdle();
192
154
  return;
193
155
  }
194
156
  if (this.paused) {
195
- this.scheduled = false;
196
- this.scheduledHandle = null;
197
- this.scheduledViaRaf = false;
198
- this.maybeResolveIdle();
157
+ this.scheduled = !1, this.scheduledHandle = null, this.scheduledViaRaf = !1, this.maybeResolveIdle();
199
158
  return;
200
159
  }
201
- this.scheduled = false;
202
- this.scheduledHandle = null;
203
- this.scheduledViaRaf = false;
204
- this.runFlush(this.frameBudgetMs, false);
205
- this.maybeResolveIdle();
206
- };
207
- const useStartupMicrotask = this.batchStrategy !== "microtask" && this.startupMicrotaskFlushes > 0 && this.flushCount < this.startupMicrotaskFlushes && typeof queueMicrotask === "function";
208
- if ((this.batchStrategy === "microtask" || useStartupMicrotask) && typeof queueMicrotask === "function") {
209
- this.scheduledViaRaf = false;
210
- this.scheduledHandle = token;
211
- queueMicrotask(execute);
212
- } else if (this.batchStrategy === "rAF" && this.raf) {
213
- this.scheduledViaRaf = true;
214
- this.scheduledHandle = this.raf(() => execute());
215
- } else {
216
- this.scheduledViaRaf = false;
217
- this.scheduledHandle = setTimeout(() => execute(), this.timeoutMs);
218
- }
160
+ this.scheduled = !1, this.scheduledHandle = null, this.scheduledViaRaf = !1, this.runFlush(this.frameBudgetMs, !1), this.maybeResolveIdle();
161
+ }, useStartupMicrotask = this.batchStrategy !== "microtask" && this.startupMicrotaskFlushes > 0 && this.flushCount < this.startupMicrotaskFlushes && typeof queueMicrotask == "function";
162
+ (this.batchStrategy === "microtask" || useStartupMicrotask) && typeof queueMicrotask == "function" ? (this.scheduledViaRaf = !1, this.scheduledHandle = token, queueMicrotask(execute)) : this.batchStrategy === "rAF" && this.raf ? (this.scheduledViaRaf = !0, this.scheduledHandle = this.raf(() => execute())) : (this.scheduledViaRaf = !1, this.scheduledHandle = setTimeout(() => execute(), this.timeoutMs));
219
163
  }
220
164
  cancelScheduled() {
221
- if (!this.scheduled) return;
222
- this.scheduleToken++;
223
- if (this.scheduledHandle !== null) {
224
- if (this.scheduledViaRaf && this.cancelRaf) {
225
- this.cancelRaf(this.scheduledHandle);
226
- } else {
227
- clearTimeout(this.scheduledHandle);
228
- }
229
- }
230
- this.scheduled = false;
231
- this.scheduledHandle = null;
232
- this.scheduledViaRaf = false;
165
+ this.scheduled && (this.scheduleToken++, this.scheduledHandle !== null && (this.scheduledViaRaf && this.cancelRaf ? this.cancelRaf(this.scheduledHandle) : clearTimeout(this.scheduledHandle)), this.scheduled = !1, this.scheduledHandle = null, this.scheduledViaRaf = !1);
233
166
  }
234
167
  runFlush(budgetMs, manual) {
235
- if (this.paused && !manual) {
168
+ if (this.paused && !manual || this.semanticQueue.length === 0 && this.enrichmentHighQueue.length === 0 && this.enrichmentLowQueue.length === 0)
236
169
  return null;
237
- }
238
- if (this.semanticQueue.length === 0 && this.enrichmentHighQueue.length === 0 && this.enrichmentLowQueue.length === 0) {
239
- return null;
240
- }
241
- this.flushing = true;
242
- const startedAt = this.now();
243
- const initialSemanticQueueSize = this.semanticQueue.length;
244
- const initialEnrichmentQueueSize = this.enrichmentHighQueue.length + this.enrichmentLowQueue.length;
245
- const initialQueueSize = initialSemanticQueueSize + initialEnrichmentQueueSize;
246
- const batches = [];
247
- let totalInputPatches = 0;
248
- let totalAppliedPatches = 0;
249
- let elapsed = 0;
250
- const processQueue = (queue, maxBatches, budgetLimit) => {
251
- const effectiveBudget = manual ? Number.POSITIVE_INFINITY : Math.max(0, budgetLimit ?? budgetMs);
252
- const startingBatchCount = batches.length;
253
- let consumed = 0;
254
- while (consumed < queue.length) {
255
- const next = queue[consumed];
170
+ this.flushing = !0;
171
+ let startedAt = this.now(), elapsed = 0, initialSemanticQueueSize = this.semanticQueue.length, initialEnrichmentQueueSize = this.enrichmentHighQueue.length + this.enrichmentLowQueue.length, initialQueueSize = initialSemanticQueueSize + initialEnrichmentQueueSize, batches = [], totalInputPatches = 0, totalAppliedPatches = 0, hasNonInputSourcePatch = !1, processQueue = (queue, maxBatches, budgetLimit) => {
172
+ let effectiveBudget = manual ? Number.POSITIVE_INFINITY : Math.max(0, budgetLimit ?? budgetMs), startingBatchCount = batches.length, consumed = 0;
173
+ for (; consumed < queue.length; ) {
174
+ let next = queue[consumed];
256
175
  if (!next) break;
257
- consumed += 1;
258
- const applyStart = this.now();
259
- const queueDelayMs = Math.max(0, applyStart - next.receivedAt);
260
- let coalesced;
261
- let coalescingMetrics;
262
- if (shouldSkipCoalescing(next.patches)) {
176
+ if (consumed += 1, next.meta.generation !== void 0 && this.isGenerationCurrent && !this.isGenerationCurrent(next.meta.generation)) continue;
177
+ hasNonInputSourcePatch || (hasNonInputSourcePatch = next.hasNonInputSourcePatch);
178
+ let applyStart = this.now(), queueDelayMs = Math.max(0, applyStart - next.receivedAt), coalesced, coalescingMetrics;
179
+ if (shouldSkipCoalescing(next.patches))
263
180
  coalesced = next.patches;
264
- } else {
265
- const result = (0, import_core.coalescePatchesWithMetrics)(next.patches, import_core.DEFAULT_COALESCE_CONFIG);
266
- coalesced = result.patches;
267
- coalescingMetrics = result.metrics;
181
+ else {
182
+ let result = (0, import_core.coalescePatchesWithMetrics)(next.patches, import_core.DEFAULT_COALESCE_CONFIG);
183
+ coalesced = result.patches, coalescingMetrics = result.metrics;
268
184
  }
269
- const touched = this.store.applyPatches(coalesced, {
270
- coalesced: true,
185
+ let touched = this.store.applyPatches(coalesced, {
186
+ coalesced: !0,
271
187
  metrics: coalescingMetrics
272
- });
273
- const durationMs = this.now() - applyStart;
274
- this.recordCoalescingDuration(coalescingMetrics?.durationMs);
275
- totalInputPatches += next.patches.length;
276
- totalAppliedPatches += coalesced.length;
277
- batches.push({
188
+ }), durationMs = this.now() - applyStart;
189
+ if (this.recordCoalescingDuration(coalescingMetrics?.durationMs), totalInputPatches += next.patches.length, totalAppliedPatches += coalesced.length, batches.push({
278
190
  tx: next.meta.tx,
279
191
  metrics: next.meta.metrics,
280
192
  patchCount: next.patches.length,
@@ -287,45 +199,26 @@ var PatchCommitScheduler = class {
287
199
  priority: next.priority,
288
200
  kind: next.kind,
289
201
  coalescing: coalescingMetrics
290
- });
291
- if (maxBatches && batches.length - startingBatchCount >= maxBatches) {
202
+ }), maxBatches && batches.length - startingBatchCount >= maxBatches || !manual && (elapsed = this.now() - startedAt, elapsed >= effectiveBudget))
292
203
  break;
293
- }
294
- if (!manual) {
295
- elapsed = this.now() - startedAt;
296
- if (elapsed >= effectiveBudget) {
297
- break;
298
- }
299
- }
300
- }
301
- if (consumed > 0) {
302
- queue.splice(0, consumed);
303
204
  }
205
+ consumed > 0 && queue.splice(0, consumed);
304
206
  };
305
- processQueue(this.semanticQueue, void 0, Number.POSITIVE_INFINITY);
306
- const initialHighQueueSize = this.enrichmentHighQueue.length;
307
- const configuredHighLimit = manual || !this.maxBatchesPerFlush ? void 0 : initialHighQueueSize > this.maxBatchesPerFlush ? void 0 : this.maxBatchesPerFlush;
308
- const highBatchLimit = this.adaptiveBudgeting ? this.adaptiveHighBatchCap ?? configuredHighLimit : configuredHighLimit;
309
- processQueue(this.enrichmentHighQueue, highBatchLimit, budgetMs);
310
- if (manual) {
311
- processQueue(this.enrichmentLowQueue, void 0, Number.POSITIVE_INFINITY);
312
- } else if (this.enrichmentLowQueue.length > 0) {
313
- elapsed = this.now() - startedAt;
314
- const budgetForLow = Math.max(0, this.lowPriorityFrameBudgetMs - elapsed);
315
- const processedHigherPriorityWork = batches.length > 0;
316
- if (budgetForLow > 0 || !processedHigherPriorityWork) {
317
- const initialLowQueueSize = this.enrichmentLowQueue.length;
318
- const configuredLowLimit = manual || !this.maxLowPriorityBatchesPerFlush ? void 0 : initialLowQueueSize > this.maxLowPriorityBatchesPerFlush ? void 0 : this.maxLowPriorityBatchesPerFlush;
319
- const lowBatchLimit = this.adaptiveBudgeting ? this.adaptiveLowBatchCap ?? configuredLowLimit : configuredLowLimit;
320
- processQueue(this.enrichmentLowQueue, lowBatchLimit, budgetForLow);
207
+ if (processQueue(this.semanticQueue, void 0, budgetMs), this.semanticQueue.length === 0) {
208
+ let initialHighQueueSize = this.enrichmentHighQueue.length, configuredHighLimit = manual || !this.maxBatchesPerFlush || initialHighQueueSize > this.maxBatchesPerFlush ? void 0 : this.maxBatchesPerFlush, highBatchLimit = this.adaptiveBudgeting ? this.adaptiveHighBatchCap ?? configuredHighLimit : configuredHighLimit;
209
+ if (processQueue(this.enrichmentHighQueue, highBatchLimit, budgetMs), manual)
210
+ processQueue(this.enrichmentLowQueue, void 0, Number.POSITIVE_INFINITY);
211
+ else if (this.enrichmentLowQueue.length > 0) {
212
+ elapsed = this.now() - startedAt;
213
+ let budgetForLow = Math.max(0, this.lowPriorityFrameBudgetMs - elapsed), processedHigherPriorityWork = batches.length > 0;
214
+ if (budgetForLow > 0 || !processedHigherPriorityWork) {
215
+ let initialLowQueueSize = this.enrichmentLowQueue.length, configuredLowLimit = this.maxLowPriorityBatchesPerFlush ? initialLowQueueSize > this.maxLowPriorityBatchesPerFlush ? void 0 : this.maxLowPriorityBatchesPerFlush : void 0, lowBatchLimit = this.adaptiveBudgeting ? this.adaptiveLowBatchCap ?? configuredLowLimit : configuredLowLimit;
216
+ processQueue(this.enrichmentLowQueue, lowBatchLimit, budgetForLow);
217
+ }
321
218
  }
322
219
  }
323
- this.flushing = false;
324
- const completedAt = this.now();
325
- const totalDurationMs = completedAt - startedAt;
326
- const remainingSemantic = this.semanticQueue.length;
327
- const remainingEnrichment = this.enrichmentHighQueue.length + this.enrichmentLowQueue.length;
328
- const remaining = remainingSemantic + remainingEnrichment;
220
+ this.flushing = !1;
221
+ let completedAt = this.now(), totalDurationMs = completedAt - startedAt, remainingSemantic = this.semanticQueue.length, remainingEnrichment = this.enrichmentHighQueue.length + this.enrichmentLowQueue.length, remaining = remainingSemantic + remainingEnrichment;
329
222
  if (batches.length > 0) {
330
223
  this.flushCount += 1;
331
224
  try {
@@ -342,20 +235,15 @@ var PatchCommitScheduler = class {
342
235
  enrichmentQueueDepthBefore: initialEnrichmentQueueSize,
343
236
  flushStartedAt: startedAt,
344
237
  flushCompletedAt: completedAt
345
- });
238
+ }, hasNonInputSourcePatch);
346
239
  } catch (error) {
347
240
  console.error("[patch-scheduler] onFlush callback failed", error);
348
241
  }
349
242
  }
350
- if (remaining > 0 && !this.paused) {
351
- this.schedule();
352
- }
353
- const coalescingStats = this.adaptiveBudgeting ? this.computeCoalescingDurationStats() : { sampleCount: this.coalescingDurationSamples.length, p95: null };
354
- if (this.adaptiveBudgeting) {
355
- this.updateAdaptiveBudget(coalescingStats.p95);
356
- }
357
- const adaptiveState = this.adaptiveBudgeting ? this.snapshotAdaptiveBudget(coalescingStats.p95 ?? null) : void 0;
358
- const flushResult = batches.length > 0 ? {
243
+ remaining > 0 && !this.paused && this.schedule();
244
+ let coalescingStats = this.adaptiveBudgeting ? this.computeCoalescingDurationStats() : { sampleCount: this.coalescingDurationSamples.length, p95: null };
245
+ this.adaptiveBudgeting && this.updateAdaptiveBudget(coalescingStats.p95);
246
+ let adaptiveState = this.adaptiveBudgeting ? this.snapshotAdaptiveBudget(coalescingStats.p95 ?? null) : void 0, flushResult = batches.length > 0 ? {
359
247
  batches,
360
248
  totalPatches: totalInputPatches,
361
249
  totalAppliedPatches,
@@ -373,26 +261,15 @@ var PatchCommitScheduler = class {
373
261
  adaptiveBudgetActive: adaptiveState?.active,
374
262
  adaptiveBudgetState: adaptiveState
375
263
  } : null;
376
- if (flushResult) {
377
- this.recordHistory(flushResult);
378
- }
379
- return flushResult;
264
+ return flushResult && this.recordHistory(flushResult), flushResult;
380
265
  }
381
266
  recordCoalescingDuration(value) {
382
- if (typeof value !== "number" || !Number.isFinite(value)) {
383
- return;
384
- }
385
- this.coalescingDurationSamples.push(value);
386
- if (this.coalescingDurationSamples.length > COALESCING_DURATION_SAMPLE_LIMIT) {
387
- this.coalescingDurationSamples.splice(0, this.coalescingDurationSamples.length - COALESCING_DURATION_SAMPLE_LIMIT);
388
- }
267
+ typeof value != "number" || !Number.isFinite(value) || (this.coalescingDurationSamples.push(value), this.coalescingDurationSamples.length > COALESCING_DURATION_SAMPLE_LIMIT && this.coalescingDurationSamples.splice(0, this.coalescingDurationSamples.length - COALESCING_DURATION_SAMPLE_LIMIT));
389
268
  }
390
269
  computeCoalescingDurationStats() {
391
- if (this.coalescingDurationSamples.length === 0) {
270
+ if (this.coalescingDurationSamples.length === 0)
392
271
  return { sampleCount: 0, p95: null };
393
- }
394
- const sorted = [...this.coalescingDurationSamples].sort((a, b) => a - b);
395
- const index = Math.min(sorted.length - 1, Math.max(0, Math.floor(0.95 * (sorted.length - 1))));
272
+ let sorted = [...this.coalescingDurationSamples].sort((a, b) => a - b), index = Math.min(sorted.length - 1, Math.max(0, Math.floor(0.95 * (sorted.length - 1))));
396
273
  return { sampleCount: this.coalescingDurationSamples.length, p95: sorted[index] ?? null };
397
274
  }
398
275
  snapshotAdaptiveBudget(latestP95) {
@@ -402,53 +279,32 @@ var PatchCommitScheduler = class {
402
279
  lowBatchCap: this.adaptiveLowBatchCap,
403
280
  activateThresholdMs: COALESCING_DURATION_ACTIVATE_MS,
404
281
  deactivateThresholdMs: COALESCING_DURATION_DEACTIVATE_MS,
405
- lastObservedP95: typeof latestP95 === "number" ? latestP95 : null
282
+ lastObservedP95: typeof latestP95 == "number" ? latestP95 : null
406
283
  };
407
284
  }
408
285
  updateAdaptiveBudget(p95) {
409
- if (!this.adaptiveBudgeting) {
410
- return;
411
- }
412
- if (p95 !== null && p95 > COALESCING_DURATION_ACTIVATE_MS) {
413
- if (!this.adaptiveBudgetActive) {
414
- this.adaptiveBudgetActive = true;
415
- this.adaptiveHighBatchCap = this.computeAdaptiveCap(this.maxBatchesPerFlush, 2);
416
- this.adaptiveLowBatchCap = this.computeAdaptiveCap(this.maxLowPriorityBatchesPerFlush, 1);
417
- }
418
- } else if (this.adaptiveBudgetActive && (p95 === null || p95 < COALESCING_DURATION_DEACTIVATE_MS)) {
419
- this.adaptiveBudgetActive = false;
420
- this.adaptiveHighBatchCap = void 0;
421
- this.adaptiveLowBatchCap = void 0;
422
- }
286
+ this.adaptiveBudgeting && (p95 !== null && p95 > COALESCING_DURATION_ACTIVATE_MS ? this.adaptiveBudgetActive || (this.adaptiveBudgetActive = !0, this.adaptiveHighBatchCap = this.computeAdaptiveCap(this.maxBatchesPerFlush, 2), this.adaptiveLowBatchCap = this.computeAdaptiveCap(this.maxLowPriorityBatchesPerFlush, 1)) : this.adaptiveBudgetActive && (p95 === null || p95 < COALESCING_DURATION_DEACTIVATE_MS) && (this.adaptiveBudgetActive = !1, this.adaptiveHighBatchCap = void 0, this.adaptiveLowBatchCap = void 0));
423
287
  }
424
288
  computeAdaptiveCap(configured, fallback = 1) {
425
- if (configured === void 0 || configured <= 0) {
426
- return Math.max(1, fallback);
427
- }
428
- return Math.max(1, Math.floor(configured / 2));
289
+ return configured === void 0 || configured <= 0 ? Math.max(1, fallback) : Math.max(1, Math.floor(configured / 2));
429
290
  }
430
291
  maybeResolveIdle() {
431
- if (!this.isIdle()) {
292
+ if (!this.isIdle() || this.idleResolvers.length === 0)
432
293
  return;
433
- }
434
- if (this.idleResolvers.length === 0) {
435
- return;
436
- }
437
- const pending = this.idleResolvers.slice();
294
+ let pending = this.idleResolvers.slice();
438
295
  this.idleResolvers = [];
439
- for (const resolve of pending) {
296
+ for (let resolve of pending)
440
297
  try {
441
298
  resolve();
442
299
  } catch (error) {
443
300
  console.error("[patch-scheduler] idle resolver failed", error);
444
301
  }
445
- }
446
302
  }
447
303
  recordHistory(result) {
448
- if (RETAIN_TOUCHED_IN_HISTORY) {
304
+ if (RETAIN_TOUCHED_IN_HISTORY)
449
305
  this.history.push(result);
450
- } else {
451
- const trimmed = {
306
+ else {
307
+ let trimmed = {
452
308
  ...result,
453
309
  batches: result.batches.map((batch) => ({
454
310
  ...batch,
@@ -457,108 +313,34 @@ var PatchCommitScheduler = class {
457
313
  };
458
314
  this.history.push(trimmed);
459
315
  }
460
- if (this.history.length > this.historyLimit) {
461
- this.history.splice(0, this.history.length - this.historyLimit);
462
- }
316
+ this.history.length > this.historyLimit && this.history.splice(0, this.history.length - this.historyLimit);
463
317
  }
464
318
  pause() {
465
- if (this.paused) {
466
- return;
467
- }
468
- this.paused = true;
469
- this.cancelScheduled();
319
+ this.paused || (this.paused = !0, this.cancelScheduled());
470
320
  }
471
321
  resume() {
472
- if (!this.paused) {
473
- return;
474
- }
475
- this.paused = false;
476
- if (this.getPendingCount() > 0) {
477
- this.schedule();
478
- }
322
+ this.paused && (this.paused = !1, this.getPendingCount() > 0 && this.schedule());
479
323
  }
480
324
  isPaused() {
481
325
  return this.paused;
482
326
  }
483
327
  restart() {
484
- this.cancelScheduled();
485
- this.semanticQueue = [];
486
- this.enrichmentHighQueue = [];
487
- this.enrichmentLowQueue = [];
488
- this.flushing = false;
489
- this.sequence = 0;
490
- this.history = [];
491
- this.flushCount = 0;
492
- this.scheduleToken++;
493
- this.paused = false;
494
- this.coalescingDurationSamples = [];
495
- this.adaptiveBudgetActive = false;
496
- this.adaptiveHighBatchCap = void 0;
497
- this.adaptiveLowBatchCap = void 0;
498
- this.maybeResolveIdle();
328
+ this.cancelScheduled(), this.semanticQueue = [], this.enrichmentHighQueue = [], this.enrichmentLowQueue = [], this.flushing = !1, this.sequence = 0, this.history = [], this.flushCount = 0, this.scheduleToken++, this.paused = !1, this.coalescingDurationSamples = [], this.adaptiveBudgetActive = !1, this.adaptiveHighBatchCap = void 0, this.adaptiveLowBatchCap = void 0, this.maybeResolveIdle();
499
329
  }
500
330
  getHistory(limit) {
501
- if (limit === void 0 || limit >= this.history.length) {
502
- return [...this.history];
503
- }
504
- return this.history.slice(this.history.length - limit);
331
+ return limit === void 0 || limit >= this.history.length ? [...this.history] : this.history.slice(this.history.length - limit);
505
332
  }
506
333
  setHistoryLimit(limit) {
507
- this.historyLimit = Math.max(1, limit);
508
- if (this.history.length > this.historyLimit) {
509
- this.history.splice(0, this.history.length - this.historyLimit);
510
- }
334
+ this.historyLimit = Math.max(1, limit), this.history.length > this.historyLimit && this.history.splice(0, this.history.length - this.historyLimit);
511
335
  }
512
336
  updateOptions(options) {
513
337
  if (!options) return;
514
- let shouldReschedule = false;
515
- if (typeof options.frameBudgetMs !== "undefined") {
516
- this.frameBudgetMs = Math.max(1, options.frameBudgetMs);
517
- shouldReschedule = true;
518
- }
519
- if (typeof options.maxBatchesPerFlush !== "undefined") {
520
- this.maxBatchesPerFlush = options.maxBatchesPerFlush;
521
- shouldReschedule = true;
522
- }
523
- if (typeof options.lowPriorityFrameBudgetMs !== "undefined") {
524
- this.lowPriorityFrameBudgetMs = Math.max(1, options.lowPriorityFrameBudgetMs);
525
- shouldReschedule = true;
526
- }
527
- if (typeof options.maxLowPriorityBatchesPerFlush !== "undefined") {
528
- this.maxLowPriorityBatchesPerFlush = options.maxLowPriorityBatchesPerFlush;
529
- shouldReschedule = true;
530
- }
531
- if (typeof options.urgentQueueThreshold !== "undefined") {
532
- this.urgentQueueThreshold = Math.max(1, options.urgentQueueThreshold);
533
- shouldReschedule = true;
534
- }
535
- if (typeof options.historyLimit !== "undefined") {
536
- this.setHistoryLimit(options.historyLimit);
537
- }
538
- if (typeof options.startupMicrotaskFlushes !== "undefined") {
539
- this.startupMicrotaskFlushes = Math.max(0, Math.floor(options.startupMicrotaskFlushes));
540
- }
541
- if (typeof options.adaptiveBudgeting !== "undefined") {
542
- this.adaptiveBudgeting = options.adaptiveBudgeting;
543
- }
544
- if (typeof options.batch !== "undefined") {
545
- const requestedBatch = options.batch;
546
- if (requestedBatch === "microtask") {
547
- this.batchStrategy = "microtask";
548
- } else if (requestedBatch === "timeout") {
549
- this.batchStrategy = "timeout";
550
- } else if (requestedBatch === "rAF") {
551
- this.batchStrategy = this.raf ? "rAF" : "timeout";
552
- }
553
- if (this.batchStrategy === "microtask" && typeof queueMicrotask !== "function") {
554
- this.batchStrategy = this.raf ? "rAF" : "timeout";
555
- }
556
- shouldReschedule = true;
557
- }
558
- if (shouldReschedule && !this.paused && !this.flushing && this.getPendingCount() > 0) {
559
- this.cancelScheduled();
560
- this.schedule();
338
+ let shouldReschedule = !1;
339
+ if (typeof options.frameBudgetMs < "u" && (this.frameBudgetMs = Math.max(1, options.frameBudgetMs), shouldReschedule = !0), typeof options.maxBatchesPerFlush < "u" && (this.maxBatchesPerFlush = options.maxBatchesPerFlush, shouldReschedule = !0), typeof options.lowPriorityFrameBudgetMs < "u" && (this.lowPriorityFrameBudgetMs = Math.max(1, options.lowPriorityFrameBudgetMs), shouldReschedule = !0), typeof options.maxLowPriorityBatchesPerFlush < "u" && (this.maxLowPriorityBatchesPerFlush = options.maxLowPriorityBatchesPerFlush, shouldReschedule = !0), typeof options.urgentQueueThreshold < "u" && (this.urgentQueueThreshold = Math.max(1, options.urgentQueueThreshold), shouldReschedule = !0), typeof options.historyLimit < "u" && this.setHistoryLimit(options.historyLimit), typeof options.startupMicrotaskFlushes < "u" && (this.startupMicrotaskFlushes = Math.max(0, Math.floor(options.startupMicrotaskFlushes))), typeof options.adaptiveBudgeting < "u" && (this.adaptiveBudgeting = options.adaptiveBudgeting), typeof options.batch < "u") {
340
+ let requestedBatch = options.batch;
341
+ requestedBatch === "microtask" ? this.batchStrategy = "microtask" : requestedBatch === "timeout" ? this.batchStrategy = "timeout" : requestedBatch === "rAF" && (this.batchStrategy = this.raf ? "rAF" : "timeout"), this.batchStrategy === "microtask" && typeof queueMicrotask != "function" && (this.batchStrategy = this.raf ? "rAF" : "timeout"), shouldReschedule = !0;
561
342
  }
343
+ shouldReschedule && !this.paused && !this.flushing && this.getPendingCount() > 0 && (this.cancelScheduled(), this.schedule());
562
344
  }
563
345
  clearHistory() {
564
346
  this.history = [];