@gemx-dev/clarity-visualize 0.8.69 → 0.8.71
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/build/clarity.visualize.js +29 -0
- package/build/clarity.visualize.min.js +1 -1
- package/build/clarity.visualize.module.js +29 -0
- package/package.json +2 -2
- package/src/layout.ts +24 -0
- package/src/visualizer.ts +2 -2
- package/types/index.d.ts +2 -3
- package/types/visualize.d.ts +8 -0
|
@@ -1670,6 +1670,35 @@ class LayoutHelper {
|
|
|
1670
1670
|
// Reset dialog render state for new render cycle
|
|
1671
1671
|
resetDialogRenderState();
|
|
1672
1672
|
};
|
|
1673
|
+
/** Rebuild internal node/hash maps from a pre-rendered document (used for HTML cache restore). */
|
|
1674
|
+
this.hydrate = (doc) => {
|
|
1675
|
+
this.nodes = {};
|
|
1676
|
+
this.hashMapAlpha = {};
|
|
1677
|
+
this.hashMapBeta = {};
|
|
1678
|
+
// querySelectorAll does not include documentElement itself
|
|
1679
|
+
const htmlEl = doc.documentElement;
|
|
1680
|
+
if (htmlEl === null || htmlEl === void 0 ? void 0 : htmlEl.hasAttribute("data-clarity-id" /* Constant.Id */)) {
|
|
1681
|
+
const id = parseInt(htmlEl.getAttribute("data-clarity-id" /* Constant.Id */), 10);
|
|
1682
|
+
if (!isNaN(id) && id > 0) {
|
|
1683
|
+
this.nodes[id] = htmlEl;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
const elements = doc.querySelectorAll(`[${"data-clarity-id" /* Constant.Id */}]`);
|
|
1687
|
+
for (const el of Array.from(elements)) {
|
|
1688
|
+
const id = parseInt(el.getAttribute("data-clarity-id" /* Constant.Id */), 10);
|
|
1689
|
+
if (!isNaN(id) && id > 0) {
|
|
1690
|
+
this.nodes[id] = el;
|
|
1691
|
+
const ha = el.getAttribute("data-clarity-hashalpha" /* Constant.HashAlpha */);
|
|
1692
|
+
const hb = el.getAttribute("data-clarity-hashbeta" /* Constant.HashBeta */);
|
|
1693
|
+
if (ha) {
|
|
1694
|
+
this.hashMapAlpha[ha] = el;
|
|
1695
|
+
}
|
|
1696
|
+
if (hb) {
|
|
1697
|
+
this.hashMapBeta[hb] = el;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1673
1702
|
this.get = (hash) => {
|
|
1674
1703
|
if (hash in this.hashMapBeta && this.hashMapBeta[hash].isConnected) {
|
|
1675
1704
|
return this.hashMapBeta[hash];
|