@gemx-dev/heatmap-react 3.5.42 → 3.5.43
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/components/VizLive/VizLiveHeatmap.d.ts.map +1 -1
- package/dist/esm/helpers/viewport-fixer.d.ts +5 -3
- package/dist/esm/helpers/viewport-fixer.d.ts.map +1 -1
- package/dist/esm/helpers/viewport-replacer.d.ts +12 -12
- package/dist/esm/helpers/viewport-replacer.d.ts.map +1 -1
- package/dist/esm/index.js +132 -133
- package/dist/esm/index.mjs +132 -133
- package/dist/esm/types/viewport-fixer.d.ts +9 -8
- package/dist/esm/types/viewport-fixer.d.ts.map +1 -1
- package/dist/umd/components/VizLive/VizLiveHeatmap.d.ts.map +1 -1
- package/dist/umd/helpers/viewport-fixer.d.ts +5 -3
- package/dist/umd/helpers/viewport-fixer.d.ts.map +1 -1
- package/dist/umd/helpers/viewport-replacer.d.ts +12 -12
- package/dist/umd/helpers/viewport-replacer.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/types/viewport-fixer.d.ts +9 -8
- package/dist/umd/types/viewport-fixer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VizLiveHeatmap.d.ts","sourceRoot":"","sources":["../../../src/components/VizLive/VizLiveHeatmap.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VizLiveHeatmap.d.ts","sourceRoot":"","sources":["../../../src/components/VizLive/VizLiveHeatmap.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAqBlC,CAAC"}
|
|
@@ -2,11 +2,13 @@ import { DebugInfo, ViewportConfig } from '../types';
|
|
|
2
2
|
export declare class ViewportUnitsFixer {
|
|
3
3
|
private iframe;
|
|
4
4
|
private config;
|
|
5
|
+
private replacer;
|
|
5
6
|
constructor(config: ViewportConfig);
|
|
6
7
|
private init;
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private process;
|
|
9
|
+
recalculate(): Promise<void>;
|
|
10
|
+
updateConfig(config: Partial<ViewportConfig>): void;
|
|
11
|
+
destroy(): void;
|
|
10
12
|
}
|
|
11
13
|
export declare function initViewportFixer(config: ViewportConfig): ViewportUnitsFixer;
|
|
12
14
|
export declare function debugViewportUnits(): DebugInfo | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport-fixer.d.ts","sourceRoot":"","sources":["../../src/helpers/viewport-fixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"viewport-fixer.d.ts","sourceRoot":"","sources":["../../src/helpers/viewport-fixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,cAAc,EAAE,MAAM,UAAU,CAAC;AAGvE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAsC;gBAE1C,MAAM,EAAE,cAAc;YAMpB,IAAI;YAcJ,OAAO;IAiCR,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAOnD,OAAO,IAAI,IAAI;CAIvB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,CAS5E;AAED,wBAAgB,kBAAkB,IAAI,SAAS,GAAG,IAAI,CA+BrD"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { ViewportConfig } from '../types';
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
regex(): RegExp;
|
|
9
|
-
config(): ViewportConfig;
|
|
2
|
+
export declare class ViewportUnitsReplacer {
|
|
3
|
+
private doc;
|
|
4
|
+
private win;
|
|
5
|
+
private config;
|
|
6
|
+
private regex;
|
|
7
|
+
constructor(iframe: HTMLIFrameElement, config: ViewportConfig);
|
|
10
8
|
private px;
|
|
11
9
|
private convert;
|
|
12
10
|
private replaceInText;
|
|
@@ -16,10 +14,12 @@ declare class ViewportUnitsReplacer {
|
|
|
16
14
|
private processStylesheets;
|
|
17
15
|
private processLinkedStylesheets;
|
|
18
16
|
private getFinalHeight;
|
|
19
|
-
private
|
|
17
|
+
private getFinalWidth;
|
|
20
18
|
private waitForResources;
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
run(): Promise<{
|
|
20
|
+
height: number;
|
|
21
|
+
width: number;
|
|
22
|
+
}>;
|
|
23
|
+
updateConfig(config: Partial<ViewportConfig>): void;
|
|
23
24
|
}
|
|
24
|
-
export default ViewportUnitsReplacer;
|
|
25
25
|
//# sourceMappingURL=viewport-replacer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport-replacer.d.ts","sourceRoot":"","sources":["../../src/helpers/viewport-replacer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewport-replacer.d.ts","sourceRoot":"","sources":["../../src/helpers/viewport-replacer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,qBAAqB;IAChC,OAAO,CAAC,GAAG,CAAW;IACtB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,KAAK,CAAgD;gBAEjD,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc;IAU7D,OAAO,CAAC,EAAE;IAIV,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,kBAAkB;YAwBZ,wBAAwB;IAmCtC,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,aAAa;YAUP,gBAAgB;IAkBjB,GAAG,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IA6BvD,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAG3D"}
|
package/dist/esm/index.js
CHANGED
|
@@ -511,85 +511,18 @@ function isElementInViewport(elementRect, visualRef, scale) {
|
|
|
511
511
|
return elementBottom > viewportTop && elementTop < viewportBottom;
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const classCode = ActualClass.toString();
|
|
518
|
-
const classInstantiateCode = ActualClass.name;
|
|
519
|
-
const scriptCode = `
|
|
520
|
-
(function() {
|
|
521
|
-
'use strict';
|
|
522
|
-
${classCode}
|
|
523
|
-
const replacer = new ${classInstantiateCode}();
|
|
524
|
-
replacer.init();
|
|
525
|
-
})();
|
|
526
|
-
`;
|
|
527
|
-
return scriptCode;
|
|
528
|
-
};
|
|
529
|
-
class ViewportUnitsFixer {
|
|
530
|
-
iframe = null;
|
|
514
|
+
class ViewportUnitsReplacer {
|
|
515
|
+
doc;
|
|
516
|
+
win;
|
|
531
517
|
config;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
async init() {
|
|
538
|
-
if (!this.iframe) {
|
|
539
|
-
console.error('[Parent] Required elements not found');
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
// this.injectScriptContent = await generateIframeInjectScript();
|
|
543
|
-
window.addEventListener('message', this.handleMessage.bind(this));
|
|
544
|
-
if (this.iframe.contentDocument?.readyState === 'complete') {
|
|
545
|
-
await this.injectScript();
|
|
546
|
-
}
|
|
547
|
-
else {
|
|
548
|
-
this.iframe.addEventListener('load', () => this.injectScript());
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
async injectScript() {
|
|
552
|
-
if (!this.iframe?.contentWindow || !this.iframe.contentDocument)
|
|
553
|
-
return;
|
|
554
|
-
const doc = this.iframe.contentDocument;
|
|
555
|
-
const win = this.iframe.contentWindow;
|
|
556
|
-
try {
|
|
557
|
-
win.__viewportConfig = this.config;
|
|
558
|
-
const script = doc.createElement('script');
|
|
559
|
-
const scriptCode = await getScriptInjectCode();
|
|
560
|
-
script.textContent = scriptCode;
|
|
561
|
-
doc.head.appendChild(script);
|
|
518
|
+
regex = /([-.\d]+)(vh|svh|lvh|dvh|vw|svw|lvw|dvw)/gi;
|
|
519
|
+
constructor(iframe, config) {
|
|
520
|
+
if (!iframe.contentDocument || !iframe.contentWindow) {
|
|
521
|
+
throw new Error('Iframe document or window not accessible');
|
|
562
522
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
handleMessage(event) {
|
|
568
|
-
const data = event.data;
|
|
569
|
-
if (!data || data.type !== 'IFRAME_HEIGHT_CALCULATED')
|
|
570
|
-
return;
|
|
571
|
-
this.config.onSuccess?.(data);
|
|
572
|
-
}
|
|
573
|
-
recalculate() {
|
|
574
|
-
this.injectScript();
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
function initViewportFixer(config) {
|
|
578
|
-
const fixer = new ViewportUnitsFixer(config);
|
|
579
|
-
window.viewportFixer = fixer;
|
|
580
|
-
window.addEventListener('iframe-dimensions-applied', ((e) => {
|
|
581
|
-
const ev = e;
|
|
582
|
-
console.log('Iframe dimensions finalized:', ev.detail);
|
|
583
|
-
}));
|
|
584
|
-
return fixer;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
class ViewportUnitsReplacer {
|
|
588
|
-
regex() {
|
|
589
|
-
return /([-.\d]+)(vh|svh|lvh|dvh|vw|svw|lvw|dvw)/gi;
|
|
590
|
-
}
|
|
591
|
-
config() {
|
|
592
|
-
return window.__viewportConfig;
|
|
523
|
+
this.doc = iframe.contentDocument;
|
|
524
|
+
this.win = iframe.contentWindow;
|
|
525
|
+
this.config = config;
|
|
593
526
|
}
|
|
594
527
|
px(value) {
|
|
595
528
|
return `${value.toFixed(2)}px`;
|
|
@@ -599,42 +532,44 @@ class ViewportUnitsReplacer {
|
|
|
599
532
|
if (isNaN(num))
|
|
600
533
|
return value;
|
|
601
534
|
const map = {
|
|
602
|
-
vh: this.config
|
|
603
|
-
svh: this.config
|
|
604
|
-
lvh: this.config
|
|
605
|
-
dvh: this.config
|
|
606
|
-
vw: this.config
|
|
607
|
-
svw: this.config
|
|
608
|
-
lvw: this.config
|
|
609
|
-
dvw: this.config
|
|
535
|
+
vh: this.config.targetHeight,
|
|
536
|
+
svh: this.config.targetHeight,
|
|
537
|
+
lvh: this.config.targetHeight,
|
|
538
|
+
dvh: this.config.targetHeight,
|
|
539
|
+
vw: this.config.targetWidth,
|
|
540
|
+
svw: this.config.targetWidth,
|
|
541
|
+
lvw: this.config.targetWidth,
|
|
542
|
+
dvw: this.config.targetWidth,
|
|
610
543
|
};
|
|
611
544
|
return this.px((num / 100) * (map[unit.toLowerCase()] || 0));
|
|
612
545
|
}
|
|
613
546
|
replaceInText(cssText) {
|
|
614
|
-
return cssText.replace(this.regex
|
|
547
|
+
return cssText.replace(this.regex, (_, value, unit) => this.convert(value, unit));
|
|
615
548
|
}
|
|
616
549
|
processInlineStyles() {
|
|
617
550
|
let count = 0;
|
|
618
|
-
|
|
551
|
+
this.doc.querySelectorAll('[style]').forEach((el) => {
|
|
619
552
|
const style = el.getAttribute('style');
|
|
620
|
-
if (style && this.regex
|
|
553
|
+
if (style && this.regex.test(style)) {
|
|
554
|
+
this.regex.lastIndex = 0;
|
|
621
555
|
el.setAttribute('style', this.replaceInText(style));
|
|
622
556
|
count++;
|
|
623
557
|
}
|
|
624
558
|
});
|
|
625
|
-
console.log(`[
|
|
559
|
+
console.log(`[ViewportReplacer] Replaced ${count} inline style elements`);
|
|
626
560
|
return count;
|
|
627
561
|
}
|
|
628
562
|
processStyleTags() {
|
|
629
563
|
let count = 0;
|
|
630
|
-
|
|
564
|
+
this.doc.querySelectorAll('style').forEach((tag) => {
|
|
631
565
|
const css = tag.textContent || '';
|
|
632
|
-
if (this.regex
|
|
566
|
+
if (this.regex.test(css)) {
|
|
567
|
+
this.regex.lastIndex = 0;
|
|
633
568
|
tag.textContent = this.replaceInText(css);
|
|
634
569
|
count++;
|
|
635
570
|
}
|
|
636
571
|
});
|
|
637
|
-
console.log(`[
|
|
572
|
+
console.log(`[ViewportReplacer] Replaced ${count} <style> tags`);
|
|
638
573
|
return count;
|
|
639
574
|
}
|
|
640
575
|
processRule(rule) {
|
|
@@ -644,7 +579,8 @@ class ViewportUnitsReplacer {
|
|
|
644
579
|
for (let i = 0; i < style.length; i++) {
|
|
645
580
|
const prop = style[i];
|
|
646
581
|
const value = style.getPropertyValue(prop);
|
|
647
|
-
if (value && this.regex
|
|
582
|
+
if (value && this.regex.test(value)) {
|
|
583
|
+
this.regex.lastIndex = 0;
|
|
648
584
|
style.setProperty(prop, this.replaceInText(value), style.getPropertyPriority(prop));
|
|
649
585
|
count++;
|
|
650
586
|
}
|
|
@@ -660,11 +596,11 @@ class ViewportUnitsReplacer {
|
|
|
660
596
|
}
|
|
661
597
|
processStylesheets() {
|
|
662
598
|
let total = 0;
|
|
663
|
-
Array.from(
|
|
599
|
+
Array.from(this.doc.styleSheets).forEach((sheet) => {
|
|
664
600
|
try {
|
|
665
601
|
// Bỏ qua external CSS (cross-origin)
|
|
666
|
-
if (sheet.href && !sheet.href.startsWith(location.origin)) {
|
|
667
|
-
console.log('[
|
|
602
|
+
if (sheet.href && !sheet.href.startsWith(this.win.location.origin)) {
|
|
603
|
+
console.log('[ViewportReplacer] Skipping external CSS:', sheet.href);
|
|
668
604
|
return;
|
|
669
605
|
}
|
|
670
606
|
const rules = sheet.cssRules || sheet.rules;
|
|
@@ -675,26 +611,27 @@ class ViewportUnitsReplacer {
|
|
|
675
611
|
}
|
|
676
612
|
}
|
|
677
613
|
catch (e) {
|
|
678
|
-
console.warn('[
|
|
614
|
+
console.warn('[ViewportReplacer] Cannot read stylesheet (CORS?):', e.message);
|
|
679
615
|
}
|
|
680
616
|
});
|
|
681
|
-
console.log(`[
|
|
617
|
+
console.log(`[ViewportReplacer] Replaced ${total} rules in stylesheets`);
|
|
682
618
|
return total;
|
|
683
619
|
}
|
|
684
620
|
async processLinkedStylesheets() {
|
|
685
|
-
const links =
|
|
621
|
+
const links = this.doc.querySelectorAll('link[rel="stylesheet"]');
|
|
686
622
|
let count = 0;
|
|
687
623
|
for (const link of Array.from(links)) {
|
|
688
|
-
if (!link.href.startsWith(location.origin)) {
|
|
689
|
-
console.log('[
|
|
624
|
+
if (!link.href.startsWith(this.win.location.origin)) {
|
|
625
|
+
console.log('[ViewportReplacer] Skipping external CSS:', link.href);
|
|
690
626
|
continue;
|
|
691
627
|
}
|
|
692
628
|
try {
|
|
693
629
|
const res = await fetch(link.href);
|
|
694
630
|
let css = await res.text();
|
|
695
|
-
if (this.regex
|
|
631
|
+
if (this.regex.test(css)) {
|
|
632
|
+
this.regex.lastIndex = 0;
|
|
696
633
|
css = this.replaceInText(css);
|
|
697
|
-
const style =
|
|
634
|
+
const style = this.doc.createElement('style');
|
|
698
635
|
style.textContent = css;
|
|
699
636
|
style.dataset.originalHref = link.href;
|
|
700
637
|
link.parentNode?.insertBefore(style, link);
|
|
@@ -703,30 +640,25 @@ class ViewportUnitsReplacer {
|
|
|
703
640
|
}
|
|
704
641
|
}
|
|
705
642
|
catch (e) {
|
|
706
|
-
console.warn('[
|
|
643
|
+
console.warn('[ViewportReplacer] Cannot load CSS:', link.href, e);
|
|
707
644
|
}
|
|
708
645
|
}
|
|
709
|
-
console.log(`[
|
|
646
|
+
console.log(`[ViewportReplacer] Replaced ${count} linked CSS files`);
|
|
710
647
|
return count;
|
|
711
648
|
}
|
|
712
649
|
getFinalHeight() {
|
|
713
650
|
// Trigger reflow
|
|
714
|
-
void
|
|
715
|
-
return Math.max(
|
|
651
|
+
void this.doc.body.offsetHeight;
|
|
652
|
+
return Math.max(this.doc.body.scrollHeight, this.doc.body.offsetHeight, this.doc.documentElement.scrollHeight, this.doc.documentElement.offsetHeight, this.doc.documentElement.clientHeight);
|
|
716
653
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
type: 'IFRAME_HEIGHT_CALCULATED',
|
|
720
|
-
height,
|
|
721
|
-
width: document.body.scrollWidth,
|
|
722
|
-
}, '*');
|
|
723
|
-
console.log('[Iframe] Sent height to parent:', height);
|
|
654
|
+
getFinalWidth() {
|
|
655
|
+
return Math.max(this.doc.body.scrollWidth, this.doc.body.offsetWidth, this.doc.documentElement.scrollWidth, this.doc.documentElement.offsetWidth, this.doc.documentElement.clientWidth);
|
|
724
656
|
}
|
|
725
657
|
async waitForResources() {
|
|
726
|
-
if ('fonts' in
|
|
727
|
-
await
|
|
658
|
+
if ('fonts' in this.doc) {
|
|
659
|
+
await this.doc.fonts.ready;
|
|
728
660
|
}
|
|
729
|
-
const images = Array.from(
|
|
661
|
+
const images = Array.from(this.doc.images).filter((img) => !img.complete);
|
|
730
662
|
if (images.length > 0) {
|
|
731
663
|
await Promise.all(images.map((img) => new Promise((resolve) => {
|
|
732
664
|
img.onload = img.onerror = resolve;
|
|
@@ -735,37 +667,104 @@ class ViewportUnitsReplacer {
|
|
|
735
667
|
}
|
|
736
668
|
async run() {
|
|
737
669
|
try {
|
|
670
|
+
console.log('[ViewportReplacer] Starting viewport units replacement...');
|
|
738
671
|
this.processInlineStyles();
|
|
739
672
|
this.processStyleTags();
|
|
740
673
|
this.processStylesheets();
|
|
741
674
|
await this.processLinkedStylesheets();
|
|
742
675
|
// await this.waitForResources();
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
676
|
+
return await new Promise((resolve) => {
|
|
677
|
+
requestAnimationFrame(() => {
|
|
678
|
+
const height = this.getFinalHeight();
|
|
679
|
+
const width = this.getFinalWidth();
|
|
680
|
+
console.log('[ViewportReplacer] Calculated dimensions:', { height, width });
|
|
681
|
+
resolve({ height, width });
|
|
682
|
+
});
|
|
746
683
|
});
|
|
747
684
|
}
|
|
748
685
|
catch (err) {
|
|
749
|
-
console.error('[
|
|
750
|
-
|
|
686
|
+
console.error('[ViewportReplacer] Critical error:', err);
|
|
687
|
+
return {
|
|
688
|
+
height: this.doc.body.scrollHeight || 1000,
|
|
689
|
+
width: this.doc.body.scrollWidth || 1000,
|
|
690
|
+
};
|
|
751
691
|
}
|
|
752
692
|
}
|
|
753
|
-
|
|
754
|
-
|
|
693
|
+
updateConfig(config) {
|
|
694
|
+
this.config = { ...this.config, ...config };
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
class ViewportUnitsFixer {
|
|
699
|
+
iframe;
|
|
700
|
+
config;
|
|
701
|
+
replacer = null;
|
|
702
|
+
constructor(config) {
|
|
703
|
+
this.config = config;
|
|
704
|
+
this.iframe = config.iframe;
|
|
705
|
+
this.init();
|
|
706
|
+
}
|
|
707
|
+
async init() {
|
|
708
|
+
if (!this.iframe) {
|
|
709
|
+
console.error('[ViewportFixer] iframe not found');
|
|
710
|
+
this.config.onError?.(new Error('iframe not found'));
|
|
755
711
|
return;
|
|
756
|
-
|
|
757
|
-
|
|
712
|
+
}
|
|
713
|
+
if (this.iframe.contentDocument?.readyState === 'complete') {
|
|
714
|
+
await this.process();
|
|
758
715
|
}
|
|
759
716
|
else {
|
|
760
|
-
this.
|
|
717
|
+
this.iframe.addEventListener('load', () => this.process());
|
|
761
718
|
}
|
|
762
719
|
}
|
|
720
|
+
async process() {
|
|
721
|
+
if (!this.iframe.contentDocument || !this.iframe.contentWindow) {
|
|
722
|
+
console.error('[ViewportFixer] Cannot access iframe document');
|
|
723
|
+
this.config.onError?.(new Error('Cannot access iframe document'));
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
try {
|
|
727
|
+
console.log('[ViewportFixer] Processing viewport units...');
|
|
728
|
+
// Tạo replacer instance với iframe và config
|
|
729
|
+
this.replacer = new ViewportUnitsReplacer(this.iframe, this.config);
|
|
730
|
+
// Chạy replacement
|
|
731
|
+
const result = await this.replacer.run();
|
|
732
|
+
console.log('[ViewportFixer] Process completed:', result);
|
|
733
|
+
// Trigger success callback
|
|
734
|
+
this.config.onSuccess?.(result);
|
|
735
|
+
// Dispatch custom event
|
|
736
|
+
window.dispatchEvent(new CustomEvent('iframe-dimensions-applied', {
|
|
737
|
+
detail: result,
|
|
738
|
+
}));
|
|
739
|
+
}
|
|
740
|
+
catch (error) {
|
|
741
|
+
console.error('[ViewportFixer] Failed to process:', error);
|
|
742
|
+
this.config.onError?.(error);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
async recalculate() {
|
|
746
|
+
console.log('[ViewportFixer] Recalculating...');
|
|
747
|
+
await this.process();
|
|
748
|
+
}
|
|
749
|
+
updateConfig(config) {
|
|
750
|
+
this.config = { ...this.config, ...config };
|
|
751
|
+
if (this.replacer) {
|
|
752
|
+
this.replacer.updateConfig(config);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
destroy() {
|
|
756
|
+
this.replacer = null;
|
|
757
|
+
console.log('[ViewportFixer] Destroyed');
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function initViewportFixer(config) {
|
|
761
|
+
const fixer = new ViewportUnitsFixer(config);
|
|
762
|
+
window.addEventListener('iframe-dimensions-applied', ((e) => {
|
|
763
|
+
const ev = e;
|
|
764
|
+
console.log('[ViewportFixer] Iframe dimensions finalized:', ev.detail);
|
|
765
|
+
}));
|
|
766
|
+
return fixer;
|
|
763
767
|
}
|
|
764
|
-
|
|
765
|
-
var viewportReplacer = /*#__PURE__*/Object.freeze({
|
|
766
|
-
__proto__: null,
|
|
767
|
-
default: ViewportUnitsReplacer
|
|
768
|
-
});
|
|
769
768
|
|
|
770
769
|
const scrollToElementIfNeeded = (visualRef, rect, scale) => {
|
|
771
770
|
if (!visualRef.current)
|
|
@@ -2367,7 +2366,7 @@ const VizLiveRenderer = () => {
|
|
|
2367
2366
|
const VizLiveHeatmap = () => {
|
|
2368
2367
|
const controls = useHeatmapControlStore((state) => state.controls);
|
|
2369
2368
|
const isRendering = useHeatmapDataStore((state) => state.isRendering);
|
|
2370
|
-
const iframeHeight =
|
|
2369
|
+
const iframeHeight = useHeatmapLiveStore((state) => state.iframeHeight);
|
|
2371
2370
|
const wrapperHeight = useHeatmapLiveStore((state) => state.wrapperHeight);
|
|
2372
2371
|
const setWrapperHeight = useHeatmapLiveStore((state) => state.setWrapperHeight);
|
|
2373
2372
|
const reset = useHeatmapLiveStore((state) => state.reset);
|