@uniweb/core 0.10.2 → 0.11.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 (2) hide show
  1. package/package.json +3 -3
  2. package/src/tracker.js +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,8 +40,8 @@
40
40
  "vitest": "^4.1.7"
41
41
  },
42
42
  "dependencies": {
43
- "@uniweb/theming": "^0.1.15",
44
- "@uniweb/semantic-parser": "^1.2.3"
43
+ "@uniweb/semantic-parser": "^1.2.3",
44
+ "@uniweb/theming": "^0.1.15"
45
45
  },
46
46
  "scripts": {
47
47
  "test": "vitest run"
package/src/tracker.js CHANGED
@@ -171,13 +171,28 @@ export default class Tracker {
171
171
  * @param {Object} options
172
172
  * @param {string} [options.endpoint] - destination; **required to enable**
173
173
  * @param {boolean} [options.consentRequired=false] - hold everything until granted
174
- * @param {number} [options.flushInterval=5000]
174
+ * @param {number} [options.flushIntervalMs=5000] - batch window, MILLISECONDS
175
175
  * @param {number} [options.maxQueueSize=10]
176
176
  * @param {boolean} [options.debug=false]
177
177
  */
178
178
  constructor(options = {}) {
179
179
  this.endpoint = options.endpoint || null
180
- this.flushInterval = options.flushInterval || 5000
180
+ // **`Ms` is in the name because the unit cannot be inferred from the
181
+ // value, and the failure is silent and inverted.** A bare `flushInterval:
182
+ // 30` meaning *thirty seconds* reads here as 30 **milliseconds** — flushing
183
+ // ~33x a second, the opposite of the intent, indistinguishable from working
184
+ // config, and paid for by the host rather than by whoever typed it. The wire
185
+ // field the host emits is `flushIntervalMs` for the same reason; this option
186
+ // is spelled to match so nothing has to translate between them.
187
+ //
188
+ // ⛔ **No floor is imposed, deliberately.** A minimum here would be a second
189
+ // copy of a policy the host already owns, able only to disagree with theirs —
190
+ // the same reason this framework never co-owns a serve location. What is
191
+ // rejected is not a *small* value but an *invalid* one: anything non-finite
192
+ // or <= 0 would arm a spinning or never-firing timer, so it falls back to the
193
+ // default rather than being honoured.
194
+ const interval = options.flushIntervalMs
195
+ this.flushIntervalMs = Number.isFinite(interval) && interval > 0 ? interval : 5000
181
196
  this.maxQueueSize = options.maxQueueSize || 10
182
197
  this.debug = options.debug || false
183
198
 
@@ -472,7 +487,7 @@ export default class Tracker {
472
487
  * @private
473
488
  */
474
489
  armFlushInterval() {
475
- setInterval(() => this.flush(), this.flushInterval)
490
+ setInterval(() => this.flush(), this.flushIntervalMs)
476
491
  }
477
492
 
478
493
  /** @private */