@gemx-dev/clarity-visualize 0.8.67 → 0.8.69
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 +912 -1019
- package/build/clarity.visualize.min.js +1 -1
- package/build/clarity.visualize.module.js +912 -1019
- package/package.json +2 -2
- package/src/clarity-app.js +235808 -0
- package/src/layout.ts +12 -3
- package/src/visualizer.ts +35 -3
- package/tsconfig.json +1 -0
package/src/layout.ts
CHANGED
|
@@ -107,7 +107,7 @@ const imageMaskedSvg = {
|
|
|
107
107
|
/* END imageMaskedSvgs */
|
|
108
108
|
|
|
109
109
|
export class LayoutHelper {
|
|
110
|
-
static TIMEOUT =
|
|
110
|
+
static TIMEOUT = 7000;
|
|
111
111
|
|
|
112
112
|
primaryHtmlNodeId: number | null = null;
|
|
113
113
|
isMobile: boolean;
|
|
@@ -249,8 +249,17 @@ export class LayoutHelper {
|
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
public customElement = (event: DecodedLayout.CustomElementEvent): void => {
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
const tagName = event.data.name;
|
|
253
|
+
if (!this.state.window.customElements.get(tagName)) {
|
|
254
|
+
try {
|
|
255
|
+
// Use eval to create class in target window context (avoids ES5 transpilation issues)
|
|
256
|
+
const EmptyElement = (this.state.window as any).eval(
|
|
257
|
+
'(class extends HTMLElement { constructor() { super(); } })'
|
|
258
|
+
);
|
|
259
|
+
this.state.window.customElements.define(tagName, EmptyElement);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
console.error(`Failed to define custom element ${tagName}:`, e);
|
|
262
|
+
}
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
|
package/src/visualizer.ts
CHANGED
|
@@ -64,11 +64,11 @@ export class Visualizer implements VisualizerType {
|
|
|
64
64
|
if (decoded && decoded.length > 0 && target) {
|
|
65
65
|
try {
|
|
66
66
|
// Flatten the payload and parse all events out of them, sorted by time
|
|
67
|
-
let merged = this.
|
|
67
|
+
let merged = this.mergeForHtml(decoded);
|
|
68
68
|
await this.setup(target, { version: decoded[0].envelope.version, dom: merged.dom, useproxy, portalCanvasId });
|
|
69
69
|
// Render all mutations on top of the initial markup
|
|
70
|
-
|
|
71
|
-
let entry = merged.events
|
|
70
|
+
for (let i = 0; i < merged.events.length; i++) {
|
|
71
|
+
let entry = merged.events[i];
|
|
72
72
|
switch (entry.event) {
|
|
73
73
|
case Data.Event.StyleSheetAdoption:
|
|
74
74
|
case Data.Event.StyleSheetUpdate:
|
|
@@ -154,6 +154,38 @@ export class Visualizer implements VisualizerType {
|
|
|
154
154
|
return merged;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
private mergeForHtml = (decoded: DecodedData.DecodedPayload[]): MergedPayload => {
|
|
158
|
+
let merged: MergedPayload = { timestamp: null, envelope: null, dom: null, events: [] };
|
|
159
|
+
|
|
160
|
+
decoded = decoded.sort(this.sortPayloads);
|
|
161
|
+
this.enrich = this.enrich || new EnrichHelper();
|
|
162
|
+
helper.selector.config(this._excludeClassNames);
|
|
163
|
+
this.enrich.reset();
|
|
164
|
+
|
|
165
|
+
for (let payload of decoded) {
|
|
166
|
+
merged.timestamp = merged.timestamp ? merged.timestamp : payload.timestamp;
|
|
167
|
+
merged.envelope = payload.envelope;
|
|
168
|
+
const domEntries = payload[Constant.Dom];
|
|
169
|
+
if (Array.isArray(domEntries)) {
|
|
170
|
+
for (let entry of domEntries) {
|
|
171
|
+
let enriched = this.enrich.selectors(entry);
|
|
172
|
+
if (entry.event === Data.Event.Discover) {
|
|
173
|
+
merged.dom = enriched;
|
|
174
|
+
} else if (
|
|
175
|
+
entry.event === Data.Event.Mutation ||
|
|
176
|
+
entry.event === Data.Event.StyleSheetAdoption ||
|
|
177
|
+
entry.event === Data.Event.StyleSheetUpdate ||
|
|
178
|
+
entry.event === Data.Event.CustomElement
|
|
179
|
+
) {
|
|
180
|
+
merged.events.push(entry);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
merged.events = merged.events.sort(this.sortEvents);
|
|
186
|
+
return merged;
|
|
187
|
+
}
|
|
188
|
+
|
|
157
189
|
public setup = async (target: Window, options: Options): Promise<Visualizer> => {
|
|
158
190
|
this.reset();
|
|
159
191
|
if (options.excludeClassNames) {
|