nodebb-plugin-ezoic-infinite 1.8.11 → 1.8.12

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 +1 -1
  2. package/public/client.js +36 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.8.11",
3
+ "version": "1.8.12",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * NodeBB Ezoic Infinite Ads — client.js v52
2
+ * NodeBB Ezoic Infinite Ads — client.js v52.1
3
3
  *
4
4
  * Historique des corrections majeures
5
5
  * ────────────────────────────────────
@@ -154,6 +154,7 @@
154
154
  ioViewportMode: isMobile() ? 'm' : 'd',
155
155
  domRev: 0,
156
156
  domCache: new Map(),
157
+ cacheFrameArmed: false,
157
158
  };
158
159
 
159
160
  let blockedUntil = 0;
@@ -175,25 +176,45 @@
175
176
 
176
177
  const Arch = {
177
178
  cache: {
179
+ // v53: frame-only micro-cache (safe for NodeBB progressive renders).
180
+ // We only cache DOM query results until the next animation frame, and any mutation invalidates immediately.
181
+ _armFrameClear() {
182
+ if (S.cacheFrameArmed) return;
183
+ S.cacheFrameArmed = true;
184
+ requestAnimationFrame(() => {
185
+ S.cacheFrameArmed = false;
186
+ try { S.domCache.clear(); } catch (_) {}
187
+ dbg('dom-cache.clear', 'raf');
188
+ });
189
+ },
178
190
  invalidate(reason) {
179
- S.domRev++;
180
- S.domCache.clear();
191
+ try { S.domRev++; S.domCache.clear(); } catch (_) {}
181
192
  dbg('dom-cache.invalidate', reason || '');
182
193
  },
183
- queryAll(key, selector, mapFn) {
184
- const cacheKey = `${S.domRev}:${key}`;
185
- if (S.domCache.has(cacheKey)) return S.domCache.get(cacheKey);
194
+ queryAll(key, selector, filterFn) {
195
+ const k = `q:${S.domRev}:${key}:${selector}`;
196
+ try {
197
+ if (S.domCache.has(k)) return S.domCache.get(k);
198
+ } catch (_) {}
186
199
  const arr = Array.from(document.querySelectorAll(selector));
187
- const out = typeof mapFn === 'function' ? arr.filter(Boolean).filter(mapFn) : arr;
188
- S.domCache.set(cacheKey, out);
200
+ const out = typeof filterFn === 'function' ? arr.filter(Boolean).filter(filterFn) : arr;
201
+ try {
202
+ this._armFrameClear();
203
+ S.domCache.set(k, out);
204
+ } catch (_) {}
189
205
  return out;
190
206
  },
191
207
  get(key, buildFn) {
192
- const cacheKey = `${S.domRev}:${key}`;
193
- if (S.domCache.has(cacheKey)) return S.domCache.get(cacheKey);
194
- const v = buildFn();
195
- S.domCache.set(cacheKey, v);
196
- return v;
208
+ const k = `g:${S.domRev}:${key}`;
209
+ try {
210
+ if (S.domCache.has(k)) return S.domCache.get(k);
211
+ } catch (_) {}
212
+ const out = buildFn();
213
+ try {
214
+ this._armFrameClear();
215
+ S.domCache.set(k, out);
216
+ } catch (_) {}
217
+ return out;
197
218
  },
198
219
  },
199
220
  ezoic: {
@@ -213,7 +234,7 @@
213
234
  },
214
235
  },
215
236
  page: {
216
- kind() { return getKind(); },
237
+ kind() { return Arch.cache.get('kind', getKind); },
217
238
  key() { return pageKey(); },
218
239
  },
219
240
  };
@@ -378,7 +399,6 @@ function prepareIdsForShow(ids) {
378
399
  }
379
400
 
380
401
  function getKind() {
381
- return Arch.cache.get('kind', () => {
382
402
  const p = location.pathname;
383
403
  if (/^\/topic\//.test(p)) return 'topic';
384
404
  if (/^\/category\//.test(p)) return 'categoryTopics';
@@ -387,7 +407,6 @@ function prepareIdsForShow(ids) {
387
407
  if (document.querySelector(SEL.post)) return 'topic';
388
408
  if (document.querySelector(SEL.topic)) return 'categoryTopics';
389
409
  return 'other';
390
- });
391
410
  }
392
411
 
393
412
  // ── Items DOM ──────────────────────────────────────────────────────────────
@@ -1004,6 +1023,7 @@ function startShowBatch(ids) {
1004
1023
  S.runQueued = false;
1005
1024
  S.sweepQueued = false;
1006
1025
  S.scrollSpeed = 0;
1026
+ S.cacheFrameArmed = false;
1007
1027
  S.lastScrollY = 0;
1008
1028
  S.lastScrollTs = 0;
1009
1029
  Arch.cache.invalidate('cleanup');