@gemx-dev/heatmap-react 3.5.92-dev.24 → 3.5.92-dev.26
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/dist/esm/hooks/viz-canvas/useAreaClickmap.d.ts.map +1 -1
- package/dist/esm/hooks/viz-canvas/useClickmap.d.ts.map +1 -1
- package/dist/esm/hooks/viz-render/useHeatmapIframeProcessor.d.ts.map +1 -1
- package/dist/esm/index.js +226 -163
- package/dist/esm/index.mjs +226 -163
- package/dist/esm/libs/iframe-processor/lifecycle.d.ts +1 -0
- package/dist/esm/libs/iframe-processor/lifecycle.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/orchestrator.d.ts +1 -0
- package/dist/esm/libs/iframe-processor/orchestrator.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/processors/height-observer/index.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/processors/height-observer/types.d.ts +4 -0
- package/dist/esm/libs/iframe-processor/processors/height-observer/types.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/processors/viewport/dimensions.d.ts +1 -1
- package/dist/esm/libs/iframe-processor/processors/viewport/dimensions.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/processors/viewport/pipeline.d.ts.map +1 -1
- package/dist/esm/libs/iframe-processor/shared/iframe-types.d.ts +2 -0
- package/dist/esm/libs/iframe-processor/shared/iframe-types.d.ts.map +1 -1
- package/dist/umd/hooks/viz-canvas/useAreaClickmap.d.ts.map +1 -1
- package/dist/umd/hooks/viz-canvas/useClickmap.d.ts.map +1 -1
- package/dist/umd/hooks/viz-render/useHeatmapIframeProcessor.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/libs/iframe-processor/lifecycle.d.ts +1 -0
- package/dist/umd/libs/iframe-processor/lifecycle.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/orchestrator.d.ts +1 -0
- package/dist/umd/libs/iframe-processor/orchestrator.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/processors/height-observer/index.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/processors/height-observer/types.d.ts +4 -0
- package/dist/umd/libs/iframe-processor/processors/height-observer/types.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/processors/viewport/dimensions.d.ts +1 -1
- package/dist/umd/libs/iframe-processor/processors/viewport/dimensions.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/processors/viewport/pipeline.d.ts.map +1 -1
- package/dist/umd/libs/iframe-processor/shared/iframe-types.d.ts +2 -0
- package/dist/umd/libs/iframe-processor/shared/iframe-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAreaClickmap.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-canvas/useAreaClickmap.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe;;
|
|
1
|
+
{"version":3,"file":"useAreaClickmap.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-canvas/useAreaClickmap.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe;;CAmB3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickmap.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-canvas/useClickmap.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;
|
|
1
|
+
{"version":3,"file":"useClickmap.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-canvas/useClickmap.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;CAmBvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHeatmapIframeProcessor.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-render/useHeatmapIframeProcessor.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7E,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,yBAAyB,QAAO,
|
|
1
|
+
{"version":3,"file":"useHeatmapIframeProcessor.d.ts","sourceRoot":"","sources":["../../../src/hooks/viz-render/useHeatmapIframeProcessor.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC7E,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,eAAO,MAAM,yBAAyB,QAAO,6BAyE5C,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -3492,16 +3492,21 @@ const useAreaTopAutoDetect = (props) => {
|
|
|
3492
3492
|
const useAreaClickmap = () => {
|
|
3493
3493
|
const vizRef = useHeatmapVizRectContext((s) => s.vizRef);
|
|
3494
3494
|
const clickmap = useHeatmapDataContext((s) => s.clickmap);
|
|
3495
|
+
const isDomLoaded = useHeatmapVizContext((s) => s.isDomLoaded);
|
|
3495
3496
|
const start = useCallback(() => {
|
|
3496
|
-
if (!vizRef || !clickmap ||
|
|
3497
|
+
if (!vizRef || !clickmap || !isDomLoaded)
|
|
3497
3498
|
return;
|
|
3498
3499
|
try {
|
|
3499
3500
|
vizRef?.clearmap?.();
|
|
3501
|
+
if (clickmap.length === 0)
|
|
3502
|
+
return;
|
|
3503
|
+
// implement area clickmap
|
|
3504
|
+
// requestIdleCallback(() => vizRef?.areaClickmap?.(clickmap), { timeout: 300 });
|
|
3500
3505
|
}
|
|
3501
3506
|
catch (error) {
|
|
3502
|
-
console.error(
|
|
3507
|
+
console.error(`useAreaClickmap ~ error:`, error);
|
|
3503
3508
|
}
|
|
3504
|
-
}, [vizRef, clickmap]);
|
|
3509
|
+
}, [vizRef, clickmap, isDomLoaded]);
|
|
3505
3510
|
return { start };
|
|
3506
3511
|
};
|
|
3507
3512
|
|
|
@@ -3510,14 +3515,16 @@ const useClickmap = () => {
|
|
|
3510
3515
|
const clickmap = useHeatmapDataContext((s) => s.clickmap);
|
|
3511
3516
|
const isDomLoaded = useHeatmapVizContext((s) => s.isDomLoaded);
|
|
3512
3517
|
const start = useCallback(() => {
|
|
3513
|
-
if (!vizRef || !clickmap ||
|
|
3518
|
+
if (!vizRef || !clickmap || !isDomLoaded)
|
|
3514
3519
|
return;
|
|
3515
3520
|
try {
|
|
3516
3521
|
vizRef?.clearmap?.();
|
|
3522
|
+
if (clickmap.length === 0)
|
|
3523
|
+
return;
|
|
3517
3524
|
requestIdleCallback(() => vizRef?.clickmap?.(clickmap), { timeout: 300 });
|
|
3518
3525
|
}
|
|
3519
3526
|
catch (error) {
|
|
3520
|
-
console.error(
|
|
3527
|
+
console.error(`useClickmap ~ error:`, error);
|
|
3521
3528
|
}
|
|
3522
3529
|
}, [vizRef, clickmap, isDomLoaded]);
|
|
3523
3530
|
return { start };
|
|
@@ -4224,6 +4231,28 @@ function createPerfTimer(config) {
|
|
|
4224
4231
|
};
|
|
4225
4232
|
}
|
|
4226
4233
|
|
|
4234
|
+
/**
|
|
4235
|
+
* Default iframe dimension calculation.
|
|
4236
|
+
* Used as fallback when no fix overrides getDimensions().
|
|
4237
|
+
*/
|
|
4238
|
+
function getFinalHeight(doc, onlyClientHeight = true) {
|
|
4239
|
+
void doc.body.offsetHeight; // trigger reflow
|
|
4240
|
+
// const bodyMinHeight = parseFloat(win.getComputedStyle(doc.body).minHeight) || 0;
|
|
4241
|
+
// const htmlMinHeight = parseFloat(win.getComputedStyle(doc.documentElement).minHeight) || 0;
|
|
4242
|
+
if (onlyClientHeight) {
|
|
4243
|
+
return Math.max(doc.body?.clientHeight || 0, doc.documentElement?.clientHeight || 0);
|
|
4244
|
+
}
|
|
4245
|
+
return Math.max(doc.body?.scrollHeight || 0, doc.body?.offsetHeight || 0, doc.documentElement?.scrollHeight || 0, doc.documentElement?.offsetHeight || 0, doc.documentElement?.clientHeight || 0);
|
|
4246
|
+
}
|
|
4247
|
+
function getFinalWidth(doc) {
|
|
4248
|
+
return Math.max(
|
|
4249
|
+
// doc.body?.scrollWidth || 0,
|
|
4250
|
+
// doc.body?.offsetWidth || 0,
|
|
4251
|
+
// doc.documentElement?.scrollWidth || 0,
|
|
4252
|
+
// doc.documentElement?.offsetWidth || 0,
|
|
4253
|
+
doc.documentElement?.clientWidth || 0);
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4227
4256
|
/**
|
|
4228
4257
|
* DOM observation setup — ResizeObserver + MutationObserver.
|
|
4229
4258
|
* Returns a cleanup function that disconnects both observers.
|
|
@@ -4248,36 +4277,74 @@ function setup(doc, onChange) {
|
|
|
4248
4277
|
};
|
|
4249
4278
|
}
|
|
4250
4279
|
|
|
4280
|
+
// cspell:ignore cooldown
|
|
4251
4281
|
/**
|
|
4252
4282
|
* Height Observer Processor
|
|
4253
4283
|
* Background observer — watches for iframe content height changes.
|
|
4254
4284
|
*/
|
|
4255
|
-
// ──
|
|
4256
|
-
function
|
|
4257
|
-
if (s.
|
|
4258
|
-
|
|
4259
|
-
|
|
4285
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
4286
|
+
function readCurrentHeight(s) {
|
|
4287
|
+
if (!s.iframe?.contentDocument || !s.iframe?.contentWindow)
|
|
4288
|
+
return 0;
|
|
4289
|
+
const height = getFinalHeight(s.iframe.contentDocument, s.iframe.contentWindow);
|
|
4290
|
+
s.logger.log('Height:', height);
|
|
4291
|
+
return height;
|
|
4292
|
+
}
|
|
4293
|
+
function isBlocked(s) {
|
|
4294
|
+
return s.isProcessing || s.isCoolingDown || s.throttleTimeout !== null;
|
|
4295
|
+
}
|
|
4296
|
+
function hasHeightChanged(s, height) {
|
|
4297
|
+
return height !== s.lastHeight;
|
|
4298
|
+
}
|
|
4299
|
+
// ── Cooldown ──────────────────────────────────────────────────────────────────
|
|
4300
|
+
function startCooldown(s) {
|
|
4301
|
+
s.isCoolingDown = true;
|
|
4302
|
+
s.cooldownTimeout = setTimeout(() => {
|
|
4303
|
+
s.cooldownTimeout = null;
|
|
4304
|
+
s.isCoolingDown = false;
|
|
4305
|
+
}, s.cooldownMs);
|
|
4306
|
+
}
|
|
4307
|
+
function stopCooldown(s) {
|
|
4308
|
+
if (s.cooldownTimeout) {
|
|
4309
|
+
clearTimeout(s.cooldownTimeout);
|
|
4310
|
+
s.cooldownTimeout = null;
|
|
4260
4311
|
}
|
|
4312
|
+
s.isCoolingDown = false;
|
|
4313
|
+
}
|
|
4314
|
+
// ── Debounce ──────────────────────────────────────────────────────────────────
|
|
4315
|
+
function cancelPendingDebounce(s) {
|
|
4261
4316
|
if (s.debounceTimeout) {
|
|
4262
4317
|
clearTimeout(s.debounceTimeout);
|
|
4263
4318
|
s.debounceTimeout = null;
|
|
4264
4319
|
}
|
|
4265
4320
|
}
|
|
4266
|
-
function
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
const maxHeight = Math.max(...heights.filter((h) => h > 0));
|
|
4272
|
-
s.logger.log('Height sources:', {
|
|
4273
|
-
'documentElement.scrollHeight': docEl.scrollHeight,
|
|
4274
|
-
'documentElement.offsetHeight': docEl.offsetHeight,
|
|
4275
|
-
'body.scrollHeight': body.scrollHeight,
|
|
4276
|
-
'body.offsetHeight': body.offsetHeight,
|
|
4277
|
-
maxHeight,
|
|
4278
|
-
});
|
|
4279
|
-
return maxHeight;
|
|
4321
|
+
function processCurrentHeightIfChanged(s) {
|
|
4322
|
+
const height = readCurrentHeight(s);
|
|
4323
|
+
if (hasHeightChanged(s, height)) {
|
|
4324
|
+
processHeightChange(s, height);
|
|
4325
|
+
}
|
|
4280
4326
|
}
|
|
4327
|
+
function scheduleDebounce(s) {
|
|
4328
|
+
cancelPendingDebounce(s);
|
|
4329
|
+
s.debounceTimeout = setTimeout(() => {
|
|
4330
|
+
s.debounceTimeout = null;
|
|
4331
|
+
processCurrentHeightIfChanged(s);
|
|
4332
|
+
}, s.debounceMs);
|
|
4333
|
+
}
|
|
4334
|
+
// ── Throttle ──────────────────────────────────────────────────────────────────
|
|
4335
|
+
function scheduleThrottledCheck(s) {
|
|
4336
|
+
s.throttleTimeout = setTimeout(() => {
|
|
4337
|
+
s.throttleTimeout = null;
|
|
4338
|
+
const height = readCurrentHeight(s);
|
|
4339
|
+
if (!hasHeightChanged(s, height)) {
|
|
4340
|
+
cancelPendingDebounce(s);
|
|
4341
|
+
return;
|
|
4342
|
+
}
|
|
4343
|
+
s.logger.log(`Height changed: ${s.lastHeight}px -> ${height}px`);
|
|
4344
|
+
scheduleDebounce(s);
|
|
4345
|
+
}, s.throttleMs);
|
|
4346
|
+
}
|
|
4347
|
+
// ── Core ──────────────────────────────────────────────────────────────────────
|
|
4281
4348
|
async function processHeightChange(s, newHeight) {
|
|
4282
4349
|
if (!s.iframe || !s.config)
|
|
4283
4350
|
return;
|
|
@@ -4289,7 +4356,6 @@ async function processHeightChange(s, newHeight) {
|
|
|
4289
4356
|
width: s.iframe.contentWindow?.innerWidth ?? 0,
|
|
4290
4357
|
};
|
|
4291
4358
|
s.lastHeight = newHeight;
|
|
4292
|
-
s.logger.log('Height change processed:', result);
|
|
4293
4359
|
s.config.onHeightChange?.(result);
|
|
4294
4360
|
window.dispatchEvent(new CustomEvent('iframe-dimensions-applied', { detail: result }));
|
|
4295
4361
|
}
|
|
@@ -4299,46 +4365,59 @@ async function processHeightChange(s, newHeight) {
|
|
|
4299
4365
|
}
|
|
4300
4366
|
finally {
|
|
4301
4367
|
s.isProcessing = false;
|
|
4368
|
+
if (s.cooldownMs > 0)
|
|
4369
|
+
startCooldown(s);
|
|
4302
4370
|
}
|
|
4303
4371
|
}
|
|
4304
4372
|
function handleHeightChange(s) {
|
|
4305
|
-
if (s
|
|
4373
|
+
if (isBlocked(s))
|
|
4306
4374
|
return;
|
|
4307
|
-
s
|
|
4308
|
-
s.throttleTimeout = null;
|
|
4309
|
-
const currentHeight = getActualHeight(s);
|
|
4310
|
-
if (currentHeight === s.lastHeight) {
|
|
4311
|
-
// Height returned to known state — cancel any stale pending debounce
|
|
4312
|
-
// to prevent it from firing with an outdated height and corrupting lastHeight.
|
|
4313
|
-
if (s.debounceTimeout) {
|
|
4314
|
-
clearTimeout(s.debounceTimeout);
|
|
4315
|
-
s.debounceTimeout = null;
|
|
4316
|
-
}
|
|
4317
|
-
return;
|
|
4318
|
-
}
|
|
4319
|
-
s.logger.log(`Height changed: ${s.lastHeight}px -> ${currentHeight}px`);
|
|
4320
|
-
if (s.debounceTimeout)
|
|
4321
|
-
clearTimeout(s.debounceTimeout);
|
|
4322
|
-
s.debounceTimeout = setTimeout(() => {
|
|
4323
|
-
s.debounceTimeout = null;
|
|
4324
|
-
// Re-read height at dispatch time to avoid using a stale closure value.
|
|
4325
|
-
const finalHeight = getActualHeight(s);
|
|
4326
|
-
if (finalHeight !== s.lastHeight) {
|
|
4327
|
-
processHeightChange(s, finalHeight);
|
|
4328
|
-
}
|
|
4329
|
-
}, s.debounceMs);
|
|
4330
|
-
}, s.throttleMs);
|
|
4375
|
+
scheduleThrottledCheck(s);
|
|
4331
4376
|
}
|
|
4332
|
-
function
|
|
4377
|
+
function attachObserver(s) {
|
|
4333
4378
|
if (!s.iframe?.contentDocument?.body) {
|
|
4334
4379
|
s.logger.warn('Cannot observe height changes: iframe body not found');
|
|
4335
4380
|
return;
|
|
4336
4381
|
}
|
|
4337
4382
|
s.observerCleanup?.();
|
|
4338
|
-
s.lastHeight =
|
|
4383
|
+
s.lastHeight = readCurrentHeight(s);
|
|
4339
4384
|
s.logger.log('Initial height:', s.lastHeight);
|
|
4340
4385
|
s.observerCleanup = setup(s.iframe.contentDocument, () => handleHeightChange(s));
|
|
4341
4386
|
}
|
|
4387
|
+
function detachObserver(s) {
|
|
4388
|
+
s.observerCleanup?.();
|
|
4389
|
+
s.observerCleanup = null;
|
|
4390
|
+
}
|
|
4391
|
+
function clearAllTimers(s) {
|
|
4392
|
+
if (s.throttleTimeout) {
|
|
4393
|
+
clearTimeout(s.throttleTimeout);
|
|
4394
|
+
s.throttleTimeout = null;
|
|
4395
|
+
}
|
|
4396
|
+
if (s.debounceTimeout) {
|
|
4397
|
+
clearTimeout(s.debounceTimeout);
|
|
4398
|
+
s.debounceTimeout = null;
|
|
4399
|
+
}
|
|
4400
|
+
if (s.startDelayTimeout) {
|
|
4401
|
+
clearTimeout(s.startDelayTimeout);
|
|
4402
|
+
s.startDelayTimeout = null;
|
|
4403
|
+
}
|
|
4404
|
+
stopCooldown(s);
|
|
4405
|
+
}
|
|
4406
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────────
|
|
4407
|
+
function observeImmediately(s) {
|
|
4408
|
+
attachObserver(s);
|
|
4409
|
+
s.logger.log('Height observer started');
|
|
4410
|
+
}
|
|
4411
|
+
function observeAfterDelay(s, delayMs) {
|
|
4412
|
+
s.logger.log(`Height observer will start in ${delayMs}ms`);
|
|
4413
|
+
s.startDelayTimeout = setTimeout(() => {
|
|
4414
|
+
s.startDelayTimeout = null;
|
|
4415
|
+
if (!s.running)
|
|
4416
|
+
return;
|
|
4417
|
+
attachObserver(s);
|
|
4418
|
+
s.logger.log('Height observer started (after delay)');
|
|
4419
|
+
}, delayMs);
|
|
4420
|
+
}
|
|
4342
4421
|
function start$5(s, iframe, cfg) {
|
|
4343
4422
|
if (s.running) {
|
|
4344
4423
|
s.logger.warn('Observer is already running. Call stop() first.');
|
|
@@ -4348,27 +4427,32 @@ function start$5(s, iframe, cfg) {
|
|
|
4348
4427
|
s.config = cfg;
|
|
4349
4428
|
s.throttleMs = cfg.throttleMs ?? 25;
|
|
4350
4429
|
s.debounceMs = cfg.debounceMs ?? 500;
|
|
4430
|
+
s.cooldownMs = cfg.cooldownMs ?? 0;
|
|
4351
4431
|
s.running = true;
|
|
4352
|
-
|
|
4353
|
-
|
|
4432
|
+
const startDelayMs = cfg.startDelayMs ?? 0;
|
|
4433
|
+
if (startDelayMs > 0) {
|
|
4434
|
+
observeAfterDelay(s, startDelayMs);
|
|
4435
|
+
}
|
|
4436
|
+
else {
|
|
4437
|
+
observeImmediately(s);
|
|
4438
|
+
}
|
|
4354
4439
|
}
|
|
4355
4440
|
function stop$5(s) {
|
|
4356
4441
|
if (!s.running)
|
|
4357
4442
|
return;
|
|
4358
|
-
s
|
|
4359
|
-
s
|
|
4360
|
-
clearTimers(s);
|
|
4443
|
+
detachObserver(s);
|
|
4444
|
+
clearAllTimers(s);
|
|
4361
4445
|
s.iframe = null;
|
|
4362
4446
|
s.config = null;
|
|
4363
4447
|
s.lastHeight = 0;
|
|
4364
4448
|
s.isProcessing = false;
|
|
4449
|
+
s.isCoolingDown = false;
|
|
4365
4450
|
s.running = false;
|
|
4366
4451
|
s.logger.log('Height observer stopped');
|
|
4367
4452
|
}
|
|
4368
4453
|
function clear(s) {
|
|
4369
|
-
s
|
|
4370
|
-
s
|
|
4371
|
-
clearTimers(s);
|
|
4454
|
+
detachObserver(s);
|
|
4455
|
+
clearAllTimers(s);
|
|
4372
4456
|
s.lastHeight = 0;
|
|
4373
4457
|
s.isProcessing = false;
|
|
4374
4458
|
}
|
|
@@ -4382,6 +4466,8 @@ function updateConfig$3(s, cfg) {
|
|
|
4382
4466
|
s.throttleMs = cfg.throttleMs;
|
|
4383
4467
|
if (cfg.debounceMs !== undefined)
|
|
4384
4468
|
s.debounceMs = cfg.debounceMs;
|
|
4469
|
+
if (cfg.cooldownMs !== undefined)
|
|
4470
|
+
s.cooldownMs = cfg.cooldownMs;
|
|
4385
4471
|
s.logger.configure({ enabled: !!s.config.debug });
|
|
4386
4472
|
s.logger.log('Config updated');
|
|
4387
4473
|
}
|
|
@@ -4395,15 +4481,19 @@ function createHeightObserver() {
|
|
|
4395
4481
|
lastHeight: 0,
|
|
4396
4482
|
throttleTimeout: null,
|
|
4397
4483
|
debounceTimeout: null,
|
|
4484
|
+
startDelayTimeout: null,
|
|
4485
|
+
cooldownTimeout: null,
|
|
4398
4486
|
isProcessing: false,
|
|
4487
|
+
isCoolingDown: false,
|
|
4399
4488
|
throttleMs: 25,
|
|
4400
4489
|
debounceMs: 500,
|
|
4490
|
+
cooldownMs: 0,
|
|
4401
4491
|
running: false,
|
|
4402
4492
|
};
|
|
4403
4493
|
return {
|
|
4404
4494
|
start: (iframe, cfg) => start$5(s, iframe, cfg),
|
|
4405
4495
|
stop: () => stop$5(s),
|
|
4406
|
-
observe: () =>
|
|
4496
|
+
observe: () => attachObserver(s),
|
|
4407
4497
|
clear: () => clear(s),
|
|
4408
4498
|
updateConfig: (cfg) => updateConfig$3(s, cfg),
|
|
4409
4499
|
getCurrentHeight: () => s.lastHeight,
|
|
@@ -5150,20 +5240,6 @@ register$1({
|
|
|
5150
5240
|
afterProcess,
|
|
5151
5241
|
});
|
|
5152
5242
|
|
|
5153
|
-
/**
|
|
5154
|
-
* Default iframe dimension calculation.
|
|
5155
|
-
* Used as fallback when no fix overrides getDimensions().
|
|
5156
|
-
*/
|
|
5157
|
-
function getFinalHeight(doc, win) {
|
|
5158
|
-
void doc.body.offsetHeight; // trigger reflow
|
|
5159
|
-
const bodyMinHeight = parseFloat(win.getComputedStyle(doc.body).minHeight) || 0;
|
|
5160
|
-
const htmlMinHeight = parseFloat(win.getComputedStyle(doc.documentElement).minHeight) || 0;
|
|
5161
|
-
return Math.max(doc.body?.scrollHeight || 0, doc.body?.offsetHeight || 0, doc.documentElement?.scrollHeight || 0, doc.documentElement?.offsetHeight || 0, doc.documentElement?.clientHeight || 0, bodyMinHeight, htmlMinHeight);
|
|
5162
|
-
}
|
|
5163
|
-
function getFinalWidth(doc) {
|
|
5164
|
-
return Math.max(doc.body?.scrollWidth || 0, doc.body?.offsetWidth || 0, doc.documentElement?.scrollWidth || 0, doc.documentElement?.offsetWidth || 0, doc.documentElement?.clientWidth || 0);
|
|
5165
|
-
}
|
|
5166
|
-
|
|
5167
5243
|
/**
|
|
5168
5244
|
* Viewport fix pipeline runner.
|
|
5169
5245
|
*
|
|
@@ -5177,82 +5253,58 @@ const logger = createLogger({ enabled: false, prefix: 'ViewportReplacer' });
|
|
|
5177
5253
|
function configure(debug) {
|
|
5178
5254
|
logger.configure({ enabled: debug });
|
|
5179
5255
|
}
|
|
5256
|
+
async function runTracked(label, fn) {
|
|
5257
|
+
const t = perf$3.mark(label);
|
|
5258
|
+
await fn();
|
|
5259
|
+
perf$3.measure(label, t);
|
|
5260
|
+
}
|
|
5261
|
+
async function runPhase(phaseKey, methodName, entries, ctx) {
|
|
5262
|
+
await runTracked(`${phaseKey}.${methodName}`, async () => {
|
|
5263
|
+
for (const { name, fn } of entries) {
|
|
5264
|
+
logger.log(`[${methodName}] ${name}`);
|
|
5265
|
+
await runTracked(`${phaseKey}.${name}.${methodName}`, () => fn(ctx));
|
|
5266
|
+
}
|
|
5267
|
+
});
|
|
5268
|
+
}
|
|
5269
|
+
function collectGlobalEntries(fixes, method) {
|
|
5270
|
+
return fixes
|
|
5271
|
+
.filter((fix) => fix[method] != null)
|
|
5272
|
+
.map((fix) => ({ name: fix.name, fn: fix[method] }));
|
|
5273
|
+
}
|
|
5274
|
+
function shopEntry(shopFix, method) {
|
|
5275
|
+
if (!shopFix?.[method])
|
|
5276
|
+
return [];
|
|
5277
|
+
return [{ name: 'shop', fn: shopFix[method] }];
|
|
5278
|
+
}
|
|
5279
|
+
function waitForAnimationFrame() {
|
|
5280
|
+
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
5281
|
+
}
|
|
5282
|
+
function resolveFirstDimensions(ctx, candidates) {
|
|
5283
|
+
for (const { name, getDimensions } of candidates) {
|
|
5284
|
+
if (!getDimensions)
|
|
5285
|
+
continue;
|
|
5286
|
+
const dims = getDimensions(ctx);
|
|
5287
|
+
if (dims) {
|
|
5288
|
+
logger.log(`Dimensions from ${name}:`, dims);
|
|
5289
|
+
return dims;
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
return null;
|
|
5293
|
+
}
|
|
5294
|
+
// ── Pipeline ──────────────────────────────────────────────────────────────────
|
|
5180
5295
|
async function run$1(ctx, activeGlobal, shopFix) {
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
if (fix.beforeProcess) {
|
|
5185
|
-
logger.log(`[beforeProcess] ${fix.name}`);
|
|
5186
|
-
const t = perf$3.mark(`phase1.${fix.name}.beforeProcess`);
|
|
5187
|
-
await fix.beforeProcess(ctx);
|
|
5188
|
-
perf$3.measure(`phase1.${fix.name}.beforeProcess`, t);
|
|
5189
|
-
}
|
|
5190
|
-
}
|
|
5191
|
-
if (shopFix?.beforeProcess) {
|
|
5192
|
-
logger.log('[beforeProcess] shop');
|
|
5193
|
-
const t = perf$3.mark('phase1.shop.beforeProcess');
|
|
5194
|
-
await shopFix.beforeProcess(ctx);
|
|
5195
|
-
perf$3.measure('phase1.shop.beforeProcess', t);
|
|
5196
|
-
}
|
|
5197
|
-
perf$3.measure('phase1.beforeProcess', t1);
|
|
5198
|
-
// ── Phase 2: process ──────────────────────────────────────────────────────
|
|
5199
|
-
const t2 = perf$3.mark('phase2.process');
|
|
5200
|
-
for (const fix of activeGlobal) {
|
|
5201
|
-
if (fix.process) {
|
|
5202
|
-
logger.log(`[process] ${fix.name}`);
|
|
5203
|
-
const t = perf$3.mark(`phase2.${fix.name}.process`);
|
|
5204
|
-
await fix.process(ctx);
|
|
5205
|
-
perf$3.measure(`phase2.${fix.name}.process`, t);
|
|
5206
|
-
}
|
|
5207
|
-
}
|
|
5208
|
-
perf$3.measure('phase2.process', t2);
|
|
5209
|
-
// ── Phase 3: afterProcess ─────────────────────────────────────────────────
|
|
5210
|
-
const t3 = perf$3.mark('phase3.afterProcess');
|
|
5211
|
-
if (shopFix?.afterProcess) {
|
|
5212
|
-
logger.log('[afterProcess] shop');
|
|
5213
|
-
const t = perf$3.mark('phase3.shop.afterProcess');
|
|
5214
|
-
await shopFix.afterProcess(ctx);
|
|
5215
|
-
perf$3.measure('phase3.shop.afterProcess', t);
|
|
5216
|
-
}
|
|
5217
|
-
for (const fix of activeGlobal) {
|
|
5218
|
-
if (fix.afterProcess) {
|
|
5219
|
-
logger.log(`[afterProcess] ${fix.name}`);
|
|
5220
|
-
const t = perf$3.mark(`phase3.${fix.name}.afterProcess`);
|
|
5221
|
-
await fix.afterProcess(ctx);
|
|
5222
|
-
perf$3.measure(`phase3.${fix.name}.afterProcess`, t);
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5225
|
-
perf$3.measure('phase3.afterProcess', t3);
|
|
5226
|
-
// ── Phase 4: getDimensions ────────────────────────────────────────────────
|
|
5296
|
+
await runPhase('phase1', 'beforeProcess', [...collectGlobalEntries(activeGlobal, 'beforeProcess'), ...shopEntry(shopFix, 'beforeProcess')], ctx);
|
|
5297
|
+
await runPhase('phase2', 'process', collectGlobalEntries(activeGlobal, 'process'), ctx);
|
|
5298
|
+
await runPhase('phase3', 'afterProcess', [...shopEntry(shopFix, 'afterProcess'), ...collectGlobalEntries(activeGlobal, 'afterProcess')], ctx);
|
|
5227
5299
|
const t4 = perf$3.mark('phase4.getDimensions');
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
}
|
|
5237
|
-
if (!dimensions) {
|
|
5238
|
-
for (const fix of activeGlobal) {
|
|
5239
|
-
if (fix.getDimensions) {
|
|
5240
|
-
dimensions = fix.getDimensions(ctx);
|
|
5241
|
-
if (dimensions) {
|
|
5242
|
-
logger.log(`Dimensions from global fix [${fix.name}]:`, dimensions);
|
|
5243
|
-
break;
|
|
5244
|
-
}
|
|
5245
|
-
}
|
|
5246
|
-
}
|
|
5247
|
-
}
|
|
5248
|
-
if (!dimensions) {
|
|
5249
|
-
dimensions = { height: getFinalHeight(ctx.doc, ctx.win), width: getFinalWidth(ctx.doc) };
|
|
5250
|
-
}
|
|
5251
|
-
logger.log('Final dimensions:', dimensions);
|
|
5252
|
-
perf$3.measure('phase4.getDimensions', t4);
|
|
5253
|
-
resolve(dimensions);
|
|
5254
|
-
});
|
|
5255
|
-
});
|
|
5300
|
+
await waitForAnimationFrame();
|
|
5301
|
+
const dimensions = resolveFirstDimensions(ctx, [
|
|
5302
|
+
...(shopFix ? [{ name: 'shop fix', ...shopFix }] : []),
|
|
5303
|
+
...activeGlobal,
|
|
5304
|
+
]) ?? { height: getFinalHeight(ctx.doc, false), width: getFinalWidth(ctx.doc) };
|
|
5305
|
+
logger.log('Final dimensions:', dimensions);
|
|
5306
|
+
perf$3.measure('phase4.getDimensions', t4);
|
|
5307
|
+
return dimensions;
|
|
5256
5308
|
}
|
|
5257
5309
|
|
|
5258
5310
|
const registry = new Map();
|
|
@@ -5445,20 +5497,6 @@ async function process(s) {
|
|
|
5445
5497
|
perf$3.endSession();
|
|
5446
5498
|
s.logger.groupEnd();
|
|
5447
5499
|
s.logger.log('Process completed:', result);
|
|
5448
|
-
s.heightObserver.stop();
|
|
5449
|
-
s.heightObserver.start(s.iframe, {
|
|
5450
|
-
iframe: s.iframe,
|
|
5451
|
-
debug: s.config.debug,
|
|
5452
|
-
throttleMs: 25,
|
|
5453
|
-
debounceMs: 500,
|
|
5454
|
-
onHeightChange: (result) => {
|
|
5455
|
-
s.config?.onSuccess?.(result);
|
|
5456
|
-
dispatchDimensionsEvent(result);
|
|
5457
|
-
},
|
|
5458
|
-
onError: (error) => {
|
|
5459
|
-
s.config?.onError?.(error);
|
|
5460
|
-
},
|
|
5461
|
-
});
|
|
5462
5500
|
s.config.onSuccess?.(result);
|
|
5463
5501
|
dispatchDimensionsEvent(result);
|
|
5464
5502
|
}
|
|
@@ -5510,6 +5548,26 @@ function stop$1(s) {
|
|
|
5510
5548
|
s.running = false;
|
|
5511
5549
|
s.logger.log('Stopped');
|
|
5512
5550
|
}
|
|
5551
|
+
function startHeightObserver(s) {
|
|
5552
|
+
if (!s.iframe || !s.config)
|
|
5553
|
+
return;
|
|
5554
|
+
s.heightObserver.stop();
|
|
5555
|
+
s.heightObserver.start(s.iframe, {
|
|
5556
|
+
iframe: s.iframe,
|
|
5557
|
+
debug: s.config.debug,
|
|
5558
|
+
throttleMs: 25,
|
|
5559
|
+
debounceMs: 500,
|
|
5560
|
+
cooldownMs: 1000,
|
|
5561
|
+
startDelayMs: s.config.heightObserverStartDelayMs,
|
|
5562
|
+
onHeightChange: (result) => {
|
|
5563
|
+
s.config?.onSuccess?.(result);
|
|
5564
|
+
dispatchDimensionsEvent(result);
|
|
5565
|
+
},
|
|
5566
|
+
onError: (error) => {
|
|
5567
|
+
s.config?.onError?.(error);
|
|
5568
|
+
},
|
|
5569
|
+
});
|
|
5570
|
+
}
|
|
5513
5571
|
async function recalculate$1(s) {
|
|
5514
5572
|
if (!s.running) {
|
|
5515
5573
|
s.logger.warn('Fixer is not running.');
|
|
@@ -5548,6 +5606,7 @@ function createOrchestrator() {
|
|
|
5548
5606
|
enableNavigationBlockingMessage: () => s.navigationBlocker.enableMessage(),
|
|
5549
5607
|
disableNavigationBlocking: () => s.navigationBlocker.disable(),
|
|
5550
5608
|
disableNavigationBlockingMessage: () => s.navigationBlocker.disableMessage(),
|
|
5609
|
+
startHeightObserver: () => startHeightObserver(s),
|
|
5551
5610
|
isRunning: () => s.running,
|
|
5552
5611
|
getStateInfo: () => ({
|
|
5553
5612
|
isRunning: s.running,
|
|
@@ -5606,6 +5665,7 @@ function createIframeHelper() {
|
|
|
5606
5665
|
stop: () => stop(s),
|
|
5607
5666
|
recalculate: () => recalculate(s),
|
|
5608
5667
|
enableNavigationBlocking: () => enableNavigationBlocking(s),
|
|
5668
|
+
startHeightObserver: () => s.fixer.startHeightObserver(),
|
|
5609
5669
|
isRunning: () => s.running,
|
|
5610
5670
|
};
|
|
5611
5671
|
}
|
|
@@ -6637,6 +6697,7 @@ const useHeatmapIframeProcessor = () => {
|
|
|
6637
6697
|
if (height)
|
|
6638
6698
|
setIframeHeight(height);
|
|
6639
6699
|
setIsDomLoaded(true);
|
|
6700
|
+
helperRef.current?.startHeightObserver();
|
|
6640
6701
|
},
|
|
6641
6702
|
});
|
|
6642
6703
|
}, [deviceType]);
|
|
@@ -6663,6 +6724,7 @@ const useHeatmapIframeProcessor = () => {
|
|
|
6663
6724
|
if (height)
|
|
6664
6725
|
setIframeHeight(height);
|
|
6665
6726
|
setIsDomLoaded(true);
|
|
6727
|
+
helperRef.current?.startHeightObserver();
|
|
6666
6728
|
},
|
|
6667
6729
|
});
|
|
6668
6730
|
}, [viewport]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -6691,6 +6753,7 @@ function startIframe({ helperRef, iframe, shopId, deviceType = EDeviceType.Deskt
|
|
|
6691
6753
|
iframe,
|
|
6692
6754
|
debug: true,
|
|
6693
6755
|
shopId,
|
|
6756
|
+
heightObserverStartDelayMs: 1000,
|
|
6694
6757
|
onSuccess: (data) => {
|
|
6695
6758
|
perf$1.measure('IframeHelper processing', tHelper);
|
|
6696
6759
|
perf$1.measure('Total render', t0);
|