Skip to content

Commit 5425cac

Browse files
committed
formatted with prettier
1 parent 3b65464 commit 5425cac

53 files changed

Lines changed: 2415 additions & 3513 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.prettierignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
published
2+
build
3+
node_modules
4+
.git
5+
.gitignore
6+
.prettierignore
7+
.prettierrc.json
8+
.prettierrc.js
9+
.prettierrc.yaml
10+
.prettierrc.yml
11+
.prettierrc.toml
12+
.prettierrc.toml

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"printWidth": 125,
7+
"endOfLine": "lf"
8+
}

src/ChecklistNetworkManager.js

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { GleapSession, GleapTranslationManager } from "./Gleap"; // Adjust path if needed
1+
import { GleapSession, GleapTranslationManager } from './Gleap'; // Adjust path if needed
22

33
// Enum for request states
44
const RequestStatus = {
5-
PENDING: "pending",
6-
SUCCESS: "success",
7-
ERROR: "error",
5+
PENDING: 'pending',
6+
SUCCESS: 'success',
7+
ERROR: 'error',
88
};
99

1010
class ChecklistNetworkManager {
@@ -54,11 +54,8 @@ class ChecklistNetworkManager {
5454
_getQueryParams() {
5555
const gleapSessionInstance = GleapSession.getInstance();
5656
const session = gleapSessionInstance?.session;
57-
const lang =
58-
GleapTranslationManager.getInstance().getActiveLanguage() || "en";
59-
return `gleapId=${session?.gleapId || ""}&gleapHash=${
60-
session?.gleapHash || ""
61-
}&lang=${lang}`;
57+
const lang = GleapTranslationManager.getInstance().getActiveLanguage() || 'en';
58+
return `gleapId=${session?.gleapId || ''}&gleapHash=${session?.gleapHash || ''}&lang=${lang}`;
6259
}
6360

6461
/**
@@ -88,22 +85,20 @@ class ChecklistNetworkManager {
8885
gleapSessionInstance?.injectSession(xhr); // Inject session headers
8986

9087
if (data) {
91-
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
88+
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
9289
}
9390

9491
xhr.onreadystatechange = () => {
9592
if (xhr.readyState === 4) {
9693
if (xhr.status >= 200 && xhr.status < 300) {
9794
try {
9895
// Handle potential empty success responses (e.g., 204)
99-
const responseData = xhr.responseText
100-
? JSON.parse(xhr.responseText)
101-
: null;
96+
const responseData = xhr.responseText ? JSON.parse(xhr.responseText) : null;
10297
resolve(responseData);
10398
} catch (err) {
10499
reject({
105100
status: xhr.status,
106-
statusText: "JSON Parse Error",
101+
statusText: 'JSON Parse Error',
107102
responseText: xhr.responseText,
108103
error: err,
109104
});
@@ -119,7 +114,7 @@ class ChecklistNetworkManager {
119114
};
120115

121116
xhr.onerror = () => {
122-
reject({ status: 0, statusText: "Network Error", responseText: null });
117+
reject({ status: 0, statusText: 'Network Error', responseText: null });
123118
};
124119

125120
xhr.send(data ? JSON.stringify(data) : null);
@@ -165,9 +160,7 @@ class ChecklistNetworkManager {
165160
// 3. Start a new request
166161
const apiUrl = this._getApiUrl();
167162
if (!apiUrl) {
168-
const error = new Error(
169-
"ChecklistNetworkManager: Gleap API URL not configured."
170-
);
163+
const error = new Error('ChecklistNetworkManager: Gleap API URL not configured.');
171164
this.validationCache.set(cacheKey, {
172165
status: RequestStatus.ERROR,
173166
error,
@@ -176,7 +169,7 @@ class ChecklistNetworkManager {
176169
}
177170

178171
const url = `${apiUrl}/outbound/checklists?${this._getQueryParams()}`;
179-
const requestPromise = this._makeRequest("POST", url, {
172+
const requestPromise = this._makeRequest('POST', url, {
180173
outboundId,
181174
sharedKey,
182175
})
@@ -188,7 +181,7 @@ class ChecklistNetworkManager {
188181
});
189182
return responseData.id;
190183
} else {
191-
const error = new Error("Validation response missing checklist ID.");
184+
const error = new Error('Validation response missing checklist ID.');
192185
this.validationCache.set(cacheKey, {
193186
status: RequestStatus.ERROR,
194187
error: responseData || error,
@@ -235,23 +228,19 @@ class ChecklistNetworkManager {
235228
// 2. Check for an ongoing request
236229
if (this.fetchRequests.has(internalId)) {
237230
// Return a promise that resolves with a deep copy
238-
return this.fetchRequests
239-
.get(internalId)
240-
.then((data) => JSON.parse(JSON.stringify(data)));
231+
return this.fetchRequests.get(internalId).then((data) => JSON.parse(JSON.stringify(data)));
241232
}
242233

243234
// 3. Start a new request
244235
const apiUrl = this._getApiUrl();
245236
if (!apiUrl) {
246-
const error = new Error(
247-
"ChecklistNetworkManager: Gleap API URL not configured."
248-
);
237+
const error = new Error('ChecklistNetworkManager: Gleap API URL not configured.');
249238
this.fetchCache.set(internalId, { status: RequestStatus.ERROR, error });
250239
return Promise.reject(error);
251240
}
252241

253242
const url = `${apiUrl}/outbound/checklists/${internalId}?convertTipTap=true&${this._getQueryParams()}`;
254-
const requestPromise = this._makeRequest("GET", url, null)
243+
const requestPromise = this._makeRequest('GET', url, null)
255244
.then((responseData) => {
256245
if (responseData) {
257246
// Cache the successful data
@@ -263,9 +252,7 @@ class ChecklistNetworkManager {
263252
return JSON.parse(JSON.stringify(responseData));
264253
} else {
265254
// Should not happen with successful GET usually, but handle defensively
266-
const error = new Error(
267-
"Empty response received for checklist fetch."
268-
);
255+
const error = new Error('Empty response received for checklist fetch.');
269256
this.fetchCache.set(internalId, {
270257
status: RequestStatus.ERROR,
271258
error: responseData || error,

src/ElementPicker.js

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,29 @@ class ElementOverlay {
2525
*/
2626
constructor(options) {
2727
// Create and style the overlay element.
28-
this.overlay = document.createElement("div");
29-
this.overlay.className = options.className || "_ext-element-overlay";
30-
this.overlay.style.background =
31-
(options.style && options.style.background) || "rgba(250, 240, 202, 0.2)";
32-
this.overlay.style.borderColor =
33-
(options.style && options.style.borderColor) || "#F95738";
34-
this.overlay.style.borderStyle =
35-
(options.style && options.style.borderStyle) || "solid";
36-
this.overlay.style.borderRadius =
37-
(options.style && options.style.borderRadius) || "1px";
38-
this.overlay.style.borderWidth =
39-
(options.style && options.style.borderWidth) || "1px";
40-
this.overlay.style.boxSizing =
41-
(options.style && options.style.boxSizing) || "border-box";
42-
this.overlay.style.cursor =
43-
(options.style && options.style.cursor) || "crosshair";
44-
this.overlay.style.position =
45-
(options.style && options.style.position) || "absolute";
46-
this.overlay.style.zIndex =
47-
(options.style && options.style.zIndex) || "2147483647";
48-
this.overlay.style.margin =
49-
(options.style && options.style.margin) || "0px";
50-
this.overlay.style.padding =
51-
(options.style && options.style.padding) || "0px";
28+
this.overlay = document.createElement('div');
29+
this.overlay.className = options.className || '_ext-element-overlay';
30+
this.overlay.style.background = (options.style && options.style.background) || 'rgba(250, 240, 202, 0.2)';
31+
this.overlay.style.borderColor = (options.style && options.style.borderColor) || '#F95738';
32+
this.overlay.style.borderStyle = (options.style && options.style.borderStyle) || 'solid';
33+
this.overlay.style.borderRadius = (options.style && options.style.borderRadius) || '1px';
34+
this.overlay.style.borderWidth = (options.style && options.style.borderWidth) || '1px';
35+
this.overlay.style.boxSizing = (options.style && options.style.boxSizing) || 'border-box';
36+
this.overlay.style.cursor = (options.style && options.style.cursor) || 'crosshair';
37+
this.overlay.style.position = (options.style && options.style.position) || 'absolute';
38+
this.overlay.style.zIndex = (options.style && options.style.zIndex) || '2147483647';
39+
this.overlay.style.margin = (options.style && options.style.margin) || '0px';
40+
this.overlay.style.padding = (options.style && options.style.padding) || '0px';
5241

5342
// Create a container that will host a Shadow DOM.
54-
this.shadowContainer = document.createElement("div");
55-
this.shadowContainer.className = "_ext-element-overlay-container";
56-
this.shadowContainer.style.position = "absolute";
57-
this.shadowContainer.style.top = "0px";
58-
this.shadowContainer.style.left = "0px";
59-
this.shadowContainer.style.margin = "0px";
60-
this.shadowContainer.style.padding = "0px";
61-
this.shadowRoot = this.shadowContainer.attachShadow({ mode: "open" });
43+
this.shadowContainer = document.createElement('div');
44+
this.shadowContainer.className = '_ext-element-overlay-container';
45+
this.shadowContainer.style.position = 'absolute';
46+
this.shadowContainer.style.top = '0px';
47+
this.shadowContainer.style.left = '0px';
48+
this.shadowContainer.style.margin = '0px';
49+
this.shadowContainer.style.padding = '0px';
50+
this.shadowRoot = this.shadowContainer.attachShadow({ mode: 'open' });
6251
}
6352

6453
/**
@@ -99,14 +88,14 @@ class ElementOverlay {
9988
* Enables pointer events on the overlay.
10089
*/
10190
captureCursor() {
102-
this.overlay.style.pointerEvents = "auto";
91+
this.overlay.style.pointerEvents = 'auto';
10392
}
10493

10594
/**
10695
* Disables pointer events on the overlay.
10796
*/
10897
ignoreCursor() {
109-
this.overlay.style.pointerEvents = "none";
98+
this.overlay.style.pointerEvents = 'none';
11099
}
111100

112101
/**
@@ -119,10 +108,10 @@ class ElementOverlay {
119108
*/
120109
setBounds(bounds) {
121110
const { x, y, width, height } = bounds;
122-
this.overlay.style.left = x + "px";
123-
this.overlay.style.top = y + "px";
124-
this.overlay.style.width = width + "px";
125-
this.overlay.style.height = height + "px";
111+
this.overlay.style.left = x + 'px';
112+
this.overlay.style.top = y + 'px';
113+
this.overlay.style.width = width + 'px';
114+
this.overlay.style.height = height + 'px';
126115
}
127116
}
128117

@@ -159,12 +148,11 @@ class ElementPicker {
159148
this.active = true;
160149
this.options = options;
161150

162-
document.addEventListener("mousemove", this.handleMouseMove, true);
163-
document.addEventListener("click", this.handleClick, true);
151+
document.addEventListener('mousemove', this.handleMouseMove, true);
152+
document.addEventListener('click', this.handleClick, true);
164153

165154
const parentElement = options.parentElement || document.body;
166-
const useShadowDOM =
167-
options.useShadowDOM !== undefined ? options.useShadowDOM : true;
155+
const useShadowDOM = options.useShadowDOM !== undefined ? options.useShadowDOM : true;
168156
this.overlay.addToDOM(parentElement, useShadowDOM);
169157
this.tick();
170158

@@ -178,8 +166,8 @@ class ElementPicker {
178166
this.active = false;
179167
this.options = undefined;
180168

181-
document.removeEventListener("mousemove", this.handleMouseMove, true);
182-
document.removeEventListener("click", this.handleClick, true);
169+
document.removeEventListener('mousemove', this.handleMouseMove, true);
170+
document.removeEventListener('click', this.handleClick, true);
183171

184172
this.overlay.removeFromDOM();
185173
this.target = undefined;
@@ -206,12 +194,7 @@ class ElementPicker {
206194
*/
207195
handleClick(event) {
208196
const clickedEl = document.elementFromPoint(event.clientX, event.clientY);
209-
if (
210-
this.options &&
211-
this.options.elementFilter &&
212-
clickedEl &&
213-
!this.options.elementFilter(clickedEl)
214-
) {
197+
if (this.options && this.options.elementFilter && clickedEl && !this.options.elementFilter(clickedEl)) {
215198
return;
216199
}
217200

0 commit comments

Comments
 (0)