@naturalcycles/internal-web-lib 1.5.0 → 1.6.1
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/bundle/analyticsClient.js +50 -63
- package/bundle/analyticsClient.js.map +1 -1
- package/bundle/conversionClient.js +22 -45
- package/bundle/conversionClient.js.map +1 -1
- package/bundle/cookieMonster.js +185 -159
- package/bundle/cookieMonster.js.map +1 -1
- package/dist/analytics/analyticsClient.d.ts +12 -0
- package/dist/analytics/analyticsClient.js +36 -12
- package/dist/conversion/conversion.util.js +1 -2
- package/dist/conversion/conversionClient.js +1 -2
- package/dist/cookie-monster/components/setting-dropdown/setting-dropdown.component.js +1 -2
- package/dist/cookie-monster/components/setting-dropdown/setting-dropdown2.component.js +1 -2
- package/dist/cookie-monster/components/themed-button/themed-button.component.js +1 -2
- package/dist/cookie-monster/components/themed-button/themed-button2.component.js +1 -2
- package/dist/cookie-monster/consent/consent.service.js +2 -3
- package/dist/cookie-monster/consent/consentLogStorage.service.js +1 -2
- package/dist/cookie-monster/const/cookieMonster.const.js +0 -1
- package/dist/cookie-monster/cookie-monster-element.js +2 -3
- package/dist/cookie-monster/cookieMonsterService.js +5 -6
- package/dist/cookie-monster/css/fonts.js +1 -2
- package/dist/cookie-monster/css/general.js +1 -2
- package/dist/cookie-monster/css/shared-sheets.js +2 -3
- package/dist/cookie-monster/icons/back.js +1 -2
- package/dist/cookie-monster/icons/chevron.js +1 -2
- package/dist/cookie-monster/index.js +1 -1
- package/dist/cookie-monster/lang/da-DK.js +1 -2
- package/dist/cookie-monster/lang/de-DE.js +1 -2
- package/dist/cookie-monster/lang/en-GB.js +1 -2
- package/dist/cookie-monster/lang/en-US.js +1 -2
- package/dist/cookie-monster/lang/es-US.js +1 -2
- package/dist/cookie-monster/lang/fi-FI.js +1 -2
- package/dist/cookie-monster/lang/fr-FR.js +1 -2
- package/dist/cookie-monster/lang/it-IT.js +1 -2
- package/dist/cookie-monster/lang/no-NO.js +1 -2
- package/dist/cookie-monster/lang/pt-BR.js +1 -2
- package/dist/cookie-monster/lang/sv-SE.js +1 -2
- package/dist/cookie-monster/types/CookieMonster.types.js +1 -2
- package/dist/cookie-monster/utils/createButton.js +1 -2
- package/dist/cookie-monster/utils/getCookieMonsterEvent.js +1 -2
- package/dist/cookie-monster/utils/handleRootClick.js +1 -2
- package/dist/cookie-monster/utils/linkify.js +1 -2
- package/dist/cookie-monster/utils/translationsService.d.ts +2 -2
- package/dist/cookie-monster/utils/translationsService.js +6 -7
- package/dist/cookie-monster/views/main.view.js +3 -4
- package/dist/cookie-monster/views/settings.view.js +3 -4
- package/dist/cookie-monster/views/views.js +1 -2
- package/dist/{node_modules/.pnpm/@naturalcycles_ncuikit@1.15.0_react@19.3.0_undici@8.11.2/node_modules/@naturalcycles/ncuikit → ncuikit}/dist/styles/_palette.js +1 -2
- package/package.json +4 -3
|
@@ -34,6 +34,7 @@ export declare class AnalyticsClient implements AnalyticsClientApi {
|
|
|
34
34
|
*/
|
|
35
35
|
private retryAfter;
|
|
36
36
|
private hasUpdatedAcquisitionProps;
|
|
37
|
+
private isQueuePersistScheduled;
|
|
37
38
|
private readonly eventListeners;
|
|
38
39
|
private handlePageHide;
|
|
39
40
|
private handleVisibilityChange;
|
|
@@ -123,6 +124,12 @@ export declare class AnalyticsClient implements AnalyticsClientApi {
|
|
|
123
124
|
private scheduleFlush;
|
|
124
125
|
private clearFlushTimer;
|
|
125
126
|
private removeFromQueue;
|
|
127
|
+
/**
|
|
128
|
+
* Coalesces the snapshot writes of a synchronous burst of events into one: each write
|
|
129
|
+
* serializes the whole queue, so a write per event would cost O(n^2).
|
|
130
|
+
*/
|
|
131
|
+
private schedulePersistQueue;
|
|
132
|
+
private persistScheduledQueue;
|
|
126
133
|
private persistQueue;
|
|
127
134
|
private get queueKey();
|
|
128
135
|
}
|
|
@@ -150,6 +157,11 @@ export declare class AnalyticsIdentity {
|
|
|
150
157
|
* if storage becomes unreadable later.
|
|
151
158
|
*/
|
|
152
159
|
private memoryEntry;
|
|
160
|
+
/**
|
|
161
|
+
* The stored string memoryEntry was parsed from. An unchanged string skips the JSON.parse,
|
|
162
|
+
* a changed one (e.g written by another tab or app) is adopted.
|
|
163
|
+
*/
|
|
164
|
+
private memoryEntryRaw?;
|
|
153
165
|
private hasRefreshedExpiry;
|
|
154
166
|
getDistinctId(): AnalyticsDistinctId;
|
|
155
167
|
/**
|
|
@@ -8,7 +8,7 @@ import { nanoidBrowser, nanoidBrowserCustomAlphabet } from "@naturalcycles/js-li
|
|
|
8
8
|
import { _filterNullishValues, _filterObject } from "@naturalcycles/js-lib/object";
|
|
9
9
|
import { _safeJsonStringify } from "@naturalcycles/js-lib/string";
|
|
10
10
|
import { _noop } from "@naturalcycles/js-lib/types";
|
|
11
|
-
|
|
11
|
+
// src/analytics/analyticsClient.ts
|
|
12
12
|
/**
|
|
13
13
|
* Browsers drop a cookie over 4096 bytes, and the identity goes with it. The 3800 budget also
|
|
14
14
|
* has to cover the `; expires=`, `; path=`, `; domain=` and `; secure` attributes that setCookie
|
|
@@ -89,6 +89,7 @@ var AnalyticsClient = class {
|
|
|
89
89
|
*/
|
|
90
90
|
retryAfter = 0;
|
|
91
91
|
hasUpdatedAcquisitionProps = false;
|
|
92
|
+
isQueuePersistScheduled = false;
|
|
92
93
|
eventListeners = /* @__PURE__ */ new Set();
|
|
93
94
|
handlePageHide = () => {
|
|
94
95
|
this.flushNow();
|
|
@@ -185,7 +186,7 @@ var AnalyticsClient = class {
|
|
|
185
186
|
this.queue.shift();
|
|
186
187
|
this.cfg.logger.warn("[analytics] queue overflow, dropped the oldest event");
|
|
187
188
|
}
|
|
188
|
-
this.
|
|
189
|
+
this.schedulePersistQueue();
|
|
189
190
|
if (this.queue.length >= this.cfg.maxBatchSize && !this.consecutiveFailures) this.flush();
|
|
190
191
|
else this.scheduleFlush();
|
|
191
192
|
return event;
|
|
@@ -237,6 +238,7 @@ var AnalyticsClient = class {
|
|
|
237
238
|
*/
|
|
238
239
|
flushNow() {
|
|
239
240
|
if (!this.queue.length) return;
|
|
241
|
+
this.persistScheduledQueue();
|
|
240
242
|
this.clearFlushTimer();
|
|
241
243
|
for (const batch of this.prepareBatches()) this.postBatch(batch, true).catch((err) => {
|
|
242
244
|
this.cfg.logger.warn("[analytics] lifecycle batch failed to send; retained for retry", { err });
|
|
@@ -248,6 +250,7 @@ var AnalyticsClient = class {
|
|
|
248
250
|
* (e.g in tests or HMR) - the app-wide singleton never needs it.
|
|
249
251
|
*/
|
|
250
252
|
destroy() {
|
|
253
|
+
this.persistScheduledQueue();
|
|
251
254
|
this.clearFlushTimer();
|
|
252
255
|
if (isServerSide()) return;
|
|
253
256
|
globalThis.removeEventListener("pagehide", this.handlePageHide);
|
|
@@ -364,15 +367,15 @@ var AnalyticsClient = class {
|
|
|
364
367
|
batches.push(this.finalizeBatch(current));
|
|
365
368
|
current = void 0;
|
|
366
369
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
current
|
|
370
|
+
if (current) {
|
|
371
|
+
current.events.push(event);
|
|
372
|
+
current.bodyBytes += separatorBytes + eventBytes;
|
|
373
|
+
} else current = this.createPendingBatch(userId, event, eventBytes);
|
|
371
374
|
}
|
|
372
|
-
if (current
|
|
375
|
+
if (current) batches.push(this.finalizeBatch(current));
|
|
373
376
|
return batches;
|
|
374
377
|
}
|
|
375
|
-
createPendingBatch(userId) {
|
|
378
|
+
createPendingBatch(userId, firstEvent, firstEventBytes) {
|
|
376
379
|
const sentAt = Date.now();
|
|
377
380
|
const emptyBody = {
|
|
378
381
|
sentAt,
|
|
@@ -383,8 +386,8 @@ var AnalyticsClient = class {
|
|
|
383
386
|
return {
|
|
384
387
|
sentAt,
|
|
385
388
|
userId,
|
|
386
|
-
events: [],
|
|
387
|
-
bodyBytes: getUtf8ByteLength(JSON.stringify(emptyBody))
|
|
389
|
+
events: [firstEvent],
|
|
390
|
+
bodyBytes: getUtf8ByteLength(JSON.stringify(emptyBody)) + firstEventBytes
|
|
388
391
|
};
|
|
389
392
|
}
|
|
390
393
|
finalizeBatch(batch) {
|
|
@@ -451,8 +454,21 @@ var AnalyticsClient = class {
|
|
|
451
454
|
this.queue = this.queue.filter((event) => !ids.has(event.id));
|
|
452
455
|
this.persistQueue();
|
|
453
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Coalesces the snapshot writes of a synchronous burst of events into one: each write
|
|
459
|
+
* serializes the whole queue, so a write per event would cost O(n^2).
|
|
460
|
+
*/
|
|
461
|
+
schedulePersistQueue() {
|
|
462
|
+
if (!this.cfg.persistQueue || this.isQueuePersistScheduled) return;
|
|
463
|
+
this.isQueuePersistScheduled = true;
|
|
464
|
+
queueMicrotask(() => this.persistScheduledQueue());
|
|
465
|
+
}
|
|
466
|
+
persistScheduledQueue() {
|
|
467
|
+
if (this.isQueuePersistScheduled) this.persistQueue();
|
|
468
|
+
}
|
|
454
469
|
persistQueue() {
|
|
455
470
|
if (!this.cfg.persistQueue) return;
|
|
471
|
+
this.isQueuePersistScheduled = false;
|
|
456
472
|
try {
|
|
457
473
|
if (this.queue.length) localStorage.setItem(this.queueKey, _safeJsonStringify(this.queue));
|
|
458
474
|
else localStorage.removeItem(this.queueKey);
|
|
@@ -495,6 +511,11 @@ var AnalyticsIdentity = class {
|
|
|
495
511
|
* if storage becomes unreadable later.
|
|
496
512
|
*/
|
|
497
513
|
memoryEntry = {};
|
|
514
|
+
/**
|
|
515
|
+
* The stored string memoryEntry was parsed from. An unchanged string skips the JSON.parse,
|
|
516
|
+
* a changed one (e.g written by another tab or app) is adopted.
|
|
517
|
+
*/
|
|
518
|
+
memoryEntryRaw;
|
|
498
519
|
hasRefreshedExpiry = false;
|
|
499
520
|
getDistinctId() {
|
|
500
521
|
return this.ensureIdentity().distinct_id;
|
|
@@ -588,12 +609,16 @@ var AnalyticsIdentity = class {
|
|
|
588
609
|
loadEntry() {
|
|
589
610
|
try {
|
|
590
611
|
const raw = this.cfg.persistence === "cookie" ? getCookie(this.cfg.persistenceKey) : localStorage.getItem(this.cfg.persistenceKey);
|
|
591
|
-
if (raw
|
|
612
|
+
if (raw && raw !== this.memoryEntryRaw) {
|
|
613
|
+
this.memoryEntry = JSON.parse(raw);
|
|
614
|
+
this.memoryEntryRaw = raw;
|
|
615
|
+
}
|
|
592
616
|
} catch {}
|
|
593
617
|
return this.memoryEntry;
|
|
594
618
|
}
|
|
595
619
|
saveEntry(entry) {
|
|
596
620
|
this.memoryEntry = entry;
|
|
621
|
+
this.memoryEntryRaw = void 0;
|
|
597
622
|
this.hasRefreshedExpiry = true;
|
|
598
623
|
let bytes = 0;
|
|
599
624
|
try {
|
|
@@ -695,5 +720,4 @@ var AnalyticsClientError = class extends AppError {
|
|
|
695
720
|
super(message, data, { name: "AnalyticsClientError" });
|
|
696
721
|
}
|
|
697
722
|
};
|
|
698
|
-
//#endregion
|
|
699
723
|
export { AnalyticsClient, AnalyticsClientError, AnalyticsIdentity, getCookie, setCookie };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { nanoidBrowser } from "@naturalcycles/js-lib/nanoid";
|
|
2
|
-
|
|
2
|
+
// src/conversion/conversion.util.ts
|
|
3
3
|
function generateConversionEventId() {
|
|
4
4
|
return nanoidBrowser();
|
|
5
5
|
}
|
|
6
|
-
//#endregion
|
|
7
6
|
export { generateConversionEventId };
|
|
@@ -4,7 +4,7 @@ import { getFetcher } from "@naturalcycles/js-lib/http";
|
|
|
4
4
|
import { _filterEmptyValues } from "@naturalcycles/js-lib/object";
|
|
5
5
|
import { _noop } from "@naturalcycles/js-lib/types";
|
|
6
6
|
import { WebSignupQueryParam, clickIdParameters, conversionService, cookieService, formatMetaClickId, sanitizeFbclid } from "@naturalcycles/shared";
|
|
7
|
-
|
|
7
|
+
// src/conversion/conversionClient.ts
|
|
8
8
|
var CLICK_ID_COOKIE_DAYS = 30;
|
|
9
9
|
var MAX_CLICK_ID_LENGTH = 200;
|
|
10
10
|
var MIN_FBCLID_LENGTH = 20;
|
|
@@ -121,5 +121,4 @@ var ConversionClient = class {
|
|
|
121
121
|
return formatMetaClickId(fbclid);
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
//#endregion
|
|
125
124
|
export { ConversionClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/components/setting-dropdown/setting-dropdown.component.css?inline
|
|
2
2
|
var setting_dropdown_component_default = ".CookieMonster__dropdown {\n padding: 16px 0;\n display: grid;\n grid-template-columns: max-content 1fr;\n align-items: center;\n border-bottom: 1px solid var(--color-ink-300);\n}\n\n:host(:last-of-type) .CookieMonster__dropdown {\n border-bottom: none;\n}\n\n.CookieMonster__icon {\n width: 24px;\n height: 24px;\n margin-right: 4px;\n}\n\n.CookieMonster__icon___expanded {\n transform: rotate(180deg);\n}\n\n.CookieMonster__dropdownHeading {\n color: var(--color-ink-1000);\n font-size: 16px;\n font-weight: 800;\n align-self: center;\n}\n\n.CookieMonster__dropdownContent {\n font-size: 14px;\n padding-top: 16px;\n grid-column: 1 / span 2;\n color: var(--color-ink-600);\n overflow-y: auto;\n}\n\n.CookieMonster__dropdownButton {\n background-color: transparent;\n border: none;\n display: flex;\n\n cursor: pointer;\n}\n\n.CookieMonster__dropdownLabel {\n font-size: 14px;\n color: var(--color-ink-600);\n justify-self: end;\n}\n\ninput[type='checkbox'] {\n appearance: none;\n -webkit-appearance: none;\n position: relative;\n width: 18px;\n height: 18px;\n justify-self: end;\n border: 2px solid var(--color-purple-500);\n border-radius: 2px;\n cursor: pointer;\n}\n\ninput[type='checkbox']:checked::after {\n content: '✓';\n position: absolute;\n color: white;\n font-size: 14px;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n\ninput[type='checkbox']:checked:not(:disabled) {\n background-color: var(--color-purple-500);\n border-color: var(--color-purple-500);\n}\n\ninput[type='checkbox']:checked:disabled {\n background-color: var(--color-ink-400);\n border-color: var(--color-ink-400);\n}\n\n.CookieMonster__alwaysOnGroup {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n}\n\n::slotted(a) {\n color: var(--color-neue-blue-500);\n}\n";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { setting_dropdown_component_default as default };
|
|
@@ -3,7 +3,7 @@ import chevron_default from "../../icons/chevron.js";
|
|
|
3
3
|
import { CookieMonsterDropdownDetail } from "../../types/CookieMonster.types.js";
|
|
4
4
|
import { tr } from "../../utils/translationsService.js";
|
|
5
5
|
import setting_dropdown_component_default from "./setting-dropdown.component.js";
|
|
6
|
-
|
|
6
|
+
// src/cookie-monster/components/setting-dropdown/setting-dropdown.component.ts
|
|
7
7
|
var dropdownStyleSheet = createStyles(setting_dropdown_component_default);
|
|
8
8
|
var SettingDropdown = class extends HTMLElement {
|
|
9
9
|
root;
|
|
@@ -125,5 +125,4 @@ var SettingDropdown = class extends HTMLElement {
|
|
|
125
125
|
return this.checkbox.checked;
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
//#endregion
|
|
129
128
|
export { SettingDropdown };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/components/themed-button/themed-button.component.css?inline
|
|
2
2
|
var themed_button_component_default = ".CookieMonster__button {\n font-size: 14px;\n font-style: normal;\n line-height: 100%;\n background-color: transparent;\n border: none;\n border-radius: 28px;\n padding: 8px 16px;\n text-align: center;\n white-space: nowrap;\n cursor: pointer;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n}\n\n.CookieMonster__button___primary {\n border: 1px solid var(--color-purple-500);\n background-color: var(--color-purple-500);\n color: var(--color-white-1000);\n}\n\n.CookieMonster__button___secondary {\n border: 1px solid var(--color-purple-500);\n color: var(--color-purple-500);\n}\n";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { themed_button_component_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createStyles, fontSheet, generalSheet, paletteSheet } from "../../css/shared-sheets.js";
|
|
2
2
|
import themed_button_component_default from "./themed-button.component.js";
|
|
3
|
-
|
|
3
|
+
// src/cookie-monster/components/themed-button/themed-button.component.ts
|
|
4
4
|
var buttonStyleSheet = createStyles(themed_button_component_default);
|
|
5
5
|
var ThemedButton = class extends HTMLElement {
|
|
6
6
|
root;
|
|
@@ -26,5 +26,4 @@ var ThemedButton = class extends HTMLElement {
|
|
|
26
26
|
if (name === "theme") this.button.classList.add(`CookieMonster__button___${newValue}`);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { ThemedButton };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CookieMonsterEvent } from "../types/CookieMonster.types.js";
|
|
2
1
|
import { DEFAULT_OPT_OUT_CONSENT } from "../const/cookieMonster.const.js";
|
|
3
2
|
import { CookieMonsterElement } from "../cookie-monster-element.js";
|
|
3
|
+
import { CookieMonsterEvent } from "../types/CookieMonster.types.js";
|
|
4
4
|
import { consentLogStorageService } from "./consentLogStorage.service.js";
|
|
5
5
|
import { isServerSide } from "@naturalcycles/js-lib";
|
|
6
|
-
|
|
6
|
+
// src/cookie-monster/consent/consent.service.ts
|
|
7
7
|
var ConsentService = class {
|
|
8
8
|
initialized = false;
|
|
9
9
|
domain;
|
|
@@ -64,5 +64,4 @@ var ConsentService = class {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
var consentService = new ConsentService();
|
|
67
|
-
//#endregion
|
|
68
67
|
export { consentService };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cookieService } from "@naturalcycles/shared";
|
|
2
|
-
|
|
2
|
+
// src/cookie-monster/consent/consentLogStorage.service.ts
|
|
3
3
|
var COOKIE_NAME = "CookieConsent";
|
|
4
4
|
var COOKIE_EXPIRATION_DAYS = 365;
|
|
5
5
|
var LOG_STORAGE_KEY = "CookieMonsterConsentLog";
|
|
@@ -34,5 +34,4 @@ var ConsentLogStorageService = class {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
var consentLogStorageService = new ConsentLogStorageService();
|
|
37
|
-
//#endregion
|
|
38
37
|
export { consentLogStorageService };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createStyles, generalSheet, paletteSheet } from "./css/shared-sheets.js";
|
|
2
2
|
import { CookieMonsterEvent, CookieMonsterView } from "./types/CookieMonster.types.js";
|
|
3
|
-
import { setLanguage } from "./utils/translationsService.js";
|
|
4
3
|
import { getCookieMonsterEvent } from "./utils/getCookieMonsterEvent.js";
|
|
4
|
+
import { setLanguage } from "./utils/translationsService.js";
|
|
5
5
|
import views_default from "./views/views.js";
|
|
6
6
|
import { isServerSide } from "@naturalcycles/js-lib";
|
|
7
7
|
import { langService } from "@naturalcycles/shared";
|
|
8
|
-
|
|
8
|
+
// src/cookie-monster/cookie-monster-element.ts
|
|
9
9
|
var viewsStyleSheet = createStyles(views_default);
|
|
10
10
|
var CookieMonsterElement = class CookieMonsterElement extends HTMLElement {
|
|
11
11
|
root;
|
|
@@ -121,5 +121,4 @@ var CookieMonsterElement = class CookieMonsterElement extends HTMLElement {
|
|
|
121
121
|
this.mainView = newMainView;
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
//#endregion
|
|
125
124
|
export { CookieMonsterElement };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CookieMonsterView } from "./types/CookieMonster.types.js";
|
|
2
1
|
import { SettingDropdown } from "./components/setting-dropdown/setting-dropdown2.component.js";
|
|
3
2
|
import { ThemedButton } from "./components/themed-button/themed-button2.component.js";
|
|
4
|
-
import { SettingsViewElement } from "./views/settings.view.js";
|
|
5
|
-
import { MainViewElement } from "./views/main.view.js";
|
|
6
|
-
import { CookieMonsterElement } from "./cookie-monster-element.js";
|
|
7
3
|
import { consentService } from "./consent/consent.service.js";
|
|
8
|
-
|
|
4
|
+
import { CookieMonsterElement } from "./cookie-monster-element.js";
|
|
5
|
+
import { CookieMonsterView } from "./types/CookieMonster.types.js";
|
|
6
|
+
import { MainViewElement } from "./views/main.view.js";
|
|
7
|
+
import { SettingsViewElement } from "./views/settings.view.js";
|
|
8
|
+
// src/cookie-monster/cookieMonsterService.ts
|
|
9
9
|
var CookieMonsterService = class {
|
|
10
10
|
register(options) {
|
|
11
11
|
defineElementOnce("cookie-monster", CookieMonsterElement);
|
|
@@ -55,5 +55,4 @@ function defineElementOnce(name, element) {
|
|
|
55
55
|
if (!globalThis.customElements.get(name)) globalThis.customElements.define(name, element);
|
|
56
56
|
}
|
|
57
57
|
var cookieMonsterService = new CookieMonsterService();
|
|
58
|
-
//#endregion
|
|
59
58
|
export { cookieMonsterService };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/css/fonts.css?inline
|
|
2
2
|
var fonts_default = "@font-face {\n /* \n * The font family name is explicitly different compared to the same font family in other projects.\n * Having the same font family name as NCWeb/WebSignup caused rendering issues (font size being off).\n */\n font-family: 'Open Sauce One';\n font-display: swap;\n src: url('/fonts/opensauce/one/OpenSauceOne-Regular.woff2') format('woff2');\n font-weight: 400;\n font-style: normal;\n}\n\n@font-face {\n font-family: 'Open Sauce One';\n font-display: swap;\n src: url('/fonts/opensauce/one/OpenSauceOne-Medium.woff2') format('woff2');\n font-weight: 500;\n font-style: normal;\n}\n\n@font-face {\n font-family: 'Open Sauce One';\n font-display: swap;\n src: url('/fonts/opensauce/one/OpenSauceOne-Bold.woff2') format('woff2');\n font-weight: 600;\n font-style: normal;\n}\n\n@font-face {\n font-family: 'Open Sauce One';\n font-display: swap;\n src: url('/fonts/opensauce/one/OpenSauceOne-ExtraBold.woff2') format('woff2');\n font-weight: 800;\n font-style: normal;\n}\n";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { fonts_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/css/general.css?inline
|
|
2
2
|
var general_default = "* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sauce One', sans-serif;\n line-height: 150%;\n}\n";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { general_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _palette_default from "../../
|
|
1
|
+
import _palette_default from "../../ncuikit/dist/styles/_palette.js";
|
|
2
2
|
import fonts_default from "./fonts.js";
|
|
3
3
|
import general_default from "./general.js";
|
|
4
|
-
|
|
4
|
+
// src/cookie-monster/css/shared-sheets.ts
|
|
5
5
|
function createStyles(css) {
|
|
6
6
|
const sheet = new CSSStyleSheet();
|
|
7
7
|
sheet.replaceSync(css);
|
|
@@ -10,5 +10,4 @@ function createStyles(css) {
|
|
|
10
10
|
var paletteSheet = createStyles(_palette_default.replaceAll(":root", ":host"));
|
|
11
11
|
var generalSheet = createStyles(general_default);
|
|
12
12
|
var fontSheet = createStyles(fonts_default);
|
|
13
|
-
//#endregion
|
|
14
13
|
export { createStyles, fontSheet, generalSheet, paletteSheet };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/icons/back.svg
|
|
2
2
|
var back_default = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M1.38381%208.25519C1.41634%208.33382%201.46457%208.40749%201.52849%208.4714L6.19515%2013.1381C6.4555%2013.3984%206.87761%2013.3984%207.13796%2013.1381C7.39831%2012.8777%207.39831%2012.4556%207.13796%2012.1953L3.60937%208.66666L13.9999%208.66667C14.3681%208.66667%2014.6666%208.36819%2014.6666%208C14.6666%207.63181%2014.3681%207.33333%2013.9999%207.33333L3.60937%207.33333L7.13796%203.80473C7.39831%203.54439%207.39831%203.12228%207.13796%202.86193C6.87761%202.60158%206.4555%202.60158%206.19515%202.86193L1.52849%207.52859C1.39988%207.6572%201.3348%207.82529%201.33325%207.99384'%20fill='%2372035D'/%3e%3cpath%20d='M1.38381%208.25519C1.35195%208.17837%201.33405%208.0943%201.33325%208.00615L1.38381%208.25519Z'%20fill='%2372035D'/%3e%3c/svg%3e";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { back_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/icons/chevron.svg
|
|
2
2
|
var chevron_default = "data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.2929%2015.7071C11.6834%2016.0976%2012.3166%2016.0976%2012.7071%2015.7071L17.7071%2010.7071C18.0976%2010.3166%2018.0976%209.68342%2017.7071%209.29289C17.3166%208.90237%2016.6834%208.90237%2016.2929%209.29289L12%2013.5858L7.70711%209.29289C7.31658%208.90237%206.68342%208.90237%206.29289%209.29289C5.90237%209.68342%205.90237%2010.3166%206.29289%2010.7071L11.2929%2015.7071Z'%20fill='%231A1A1A'/%3e%3c/svg%3e";
|
|
3
|
-
//#endregion
|
|
4
3
|
export { chevron_default as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConsentSource, CookieMonsterDropdownDetail, CookieMonsterEvent, CookieMonsterEventReason, CookieMonsterView } from "./types/CookieMonster.types.js";
|
|
2
1
|
import { cookieMonsterService } from "./cookieMonsterService.js";
|
|
2
|
+
import { ConsentSource, CookieMonsterDropdownDetail, CookieMonsterEvent, CookieMonsterEventReason, CookieMonsterView } from "./types/CookieMonster.types.js";
|
|
3
3
|
export { ConsentSource, CookieMonsterDropdownDetail, CookieMonsterEvent, CookieMonsterEventReason, CookieMonsterView, cookieMonsterService };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/da-DK.json
|
|
2
2
|
var da_DK_default = {
|
|
3
3
|
"button-back": "Tilbage",
|
|
4
4
|
"button-cookie-policy": "Cookiepolitik",
|
|
@@ -18,5 +18,4 @@ var da_DK_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Administrér cookieindstillinger:",
|
|
19
19
|
"text-cookies-usage": "Vi bruger cookies til at analysere trafik og tilpasse indhold og annoncer, men du har selv kontrollen og kan ændre dine indstillinger nedenfor eller når som helst i vores {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { da_DK_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/de-DE.json
|
|
2
2
|
var de_DE_default = {
|
|
3
3
|
"button-back": "Zurück",
|
|
4
4
|
"button-cookie-policy": "Cookie-Richtlinie",
|
|
@@ -18,5 +18,4 @@ var de_DE_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Cookie-Einstellungen verwalten:",
|
|
19
19
|
"text-cookies-usage": "Wir verwenden Cookies, um den Datenverkehr zu analysieren sowie Inhalte und Anzeigen zu personalisieren. Du hast die Kontrolle und kannst die Einstellungen unten oder jederzeit in unserer {{ cookiePolicyLink }} verwalten."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { de_DE_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/en-GB.json
|
|
2
2
|
var en_GB_default = {
|
|
3
3
|
"button-back": "Back",
|
|
4
4
|
"button-cookie-policy": "Cookie Policy",
|
|
@@ -18,5 +18,4 @@ var en_GB_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Manage cookie settings:",
|
|
19
19
|
"text-cookies-usage": "While we use cookies to analyze traffic and personalize content and ads, you are in control and can manage settings below or anytime in our {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { en_GB_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/en-US.json
|
|
2
2
|
var en_US_default = {
|
|
3
3
|
"button-back": "Back",
|
|
4
4
|
"button-cookie-policy": "Cookie Policy",
|
|
@@ -18,5 +18,4 @@ var en_US_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Manage cookie settings:",
|
|
19
19
|
"text-cookies-usage": "While we use cookies to analyze traffic and personalize content and ads, you are in control and can manage settings below or anytime in our {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { en_US_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/es-US.json
|
|
2
2
|
var es_US_default = {
|
|
3
3
|
"button-back": "Atrás",
|
|
4
4
|
"button-cookie-policy": "Política de cookies",
|
|
@@ -18,5 +18,4 @@ var es_US_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Administrar configuración de cookies:",
|
|
19
19
|
"text-cookies-usage": "Aunque usamos cookies para analizar el tráfico y personalizar el contenido y los anuncios, tú tienes el control y puedes gestionar la configuración abajo o en cualquier momento en nuestra {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { es_US_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/fi-FI.json
|
|
2
2
|
var fi_FI_default = {
|
|
3
3
|
"button-back": "Takaisin",
|
|
4
4
|
"button-cookie-policy": "Evästekäytäntö",
|
|
@@ -18,5 +18,4 @@ var fi_FI_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Evästeasetusten hallinta:",
|
|
19
19
|
"text-cookies-usage": "Käytämme evästeitä liikenteen analysointiin sekä sisällön ja mainosten personointiin. Voit hallita asetuksia alla tai milloin tahansa {{ cookiePolicyLink }}-sivullamme."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { fi_FI_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/fr-FR.json
|
|
2
2
|
var fr_FR_default = {
|
|
3
3
|
"button-back": "Retour",
|
|
4
4
|
"button-cookie-policy": "Politique en matière de cookies",
|
|
@@ -18,5 +18,4 @@ var fr_FR_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Gérer les paramètres des cookies:",
|
|
19
19
|
"text-cookies-usage": "Nous utilisons des cookies pour analyser le trafic, personnaliser le contenu et les publicités, mais vous gardez le contrôle et pouvez gérer vos préférences ci-dessous ou à tout moment dans notre {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { fr_FR_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/it-IT.json
|
|
2
2
|
var it_IT_default = {
|
|
3
3
|
"button-back": "Indietro",
|
|
4
4
|
"button-cookie-policy": "Cookie Policy",
|
|
@@ -18,5 +18,4 @@ var it_IT_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Gestisci le impostazioni dei cookie:",
|
|
19
19
|
"text-cookies-usage": "Anche se usiamo i cookie per analizzare il traffico e personalizzare contenuti e annunci, il controllo è nelle tue mani e puoi gestire le impostazioni qui sotto o in qualsiasi momento nella nostra {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { it_IT_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/no-NO.json
|
|
2
2
|
var no_NO_default = {
|
|
3
3
|
"button-back": "Tilbake",
|
|
4
4
|
"button-cookie-policy": "Retningslinjer for informasjonskapsler",
|
|
@@ -18,5 +18,4 @@ var no_NO_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Administrer informasjonskapselinnstillinger:",
|
|
19
19
|
"text-cookies-usage": "Vi bruker informasjonskapsler for å analysere trafikk og tilpasse innhold og annonser. Du har full kontroll og kan administrere innstillingene nedenfor eller når som helst i våre {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { no_NO_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/pt-BR.json
|
|
2
2
|
var pt_BR_default = {
|
|
3
3
|
"button-back": "Voltar",
|
|
4
4
|
"button-cookie-policy": "Política de cookies",
|
|
@@ -18,5 +18,4 @@ var pt_BR_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Gerenciar configurações de cookies:",
|
|
19
19
|
"text-cookies-usage": "Embora utilizemos cookies para analisar o tráfego e personalizar conteúdo e anúncios, você tem controle e pode gerenciar as configurações abaixo ou a qualquer momento em nossa {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { pt_BR_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/lang/sv-SE.json
|
|
2
2
|
var sv_SE_default = {
|
|
3
3
|
"button-back": "Tillbaka",
|
|
4
4
|
"button-cookie-policy": "Cookiepolicy",
|
|
@@ -18,5 +18,4 @@ var sv_SE_default = {
|
|
|
18
18
|
"heading-manage-cookie-settings": "Hantera cookie-inställningar:",
|
|
19
19
|
"text-cookies-usage": "Vi använder cookies för att analysera trafik och anpassa innehåll och annonser, men det är du som bestämmer och du kan hantera inställningarna nedan eller när som helst i vår {{ cookiePolicyLink }}."
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { sv_SE_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/types/CookieMonster.types.ts
|
|
2
2
|
var CookieMonsterView = /* @__PURE__ */ function(CookieMonsterView) {
|
|
3
3
|
CookieMonsterView["banner"] = "banner";
|
|
4
4
|
CookieMonsterView["settings"] = "settings";
|
|
@@ -30,5 +30,4 @@ var ConsentSource = /* @__PURE__ */ function(ConsentSource) {
|
|
|
30
30
|
ConsentSource["gpc"] = "gpc";
|
|
31
31
|
return ConsentSource;
|
|
32
32
|
}({});
|
|
33
|
-
//#endregion
|
|
34
33
|
export { ConsentSource, CookieMonsterDropdownDetail, CookieMonsterEvent, CookieMonsterEventReason, CookieMonsterView };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/utils/createButton.ts
|
|
2
2
|
function createButton(uid, action, theme, label) {
|
|
3
3
|
const button = document.createElement("themed-button");
|
|
4
4
|
button.setAttribute("uid", uid);
|
|
@@ -7,5 +7,4 @@ function createButton(uid, action, theme, label) {
|
|
|
7
7
|
button.textContent = label;
|
|
8
8
|
return button;
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { createButton };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/utils/getCookieMonsterEvent.ts
|
|
2
2
|
function getCookieMonsterEvent(type, detail) {
|
|
3
3
|
return new CustomEvent(type, {
|
|
4
4
|
detail,
|
|
@@ -6,5 +6,4 @@ function getCookieMonsterEvent(type, detail) {
|
|
|
6
6
|
composed: true
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { getCookieMonsterEvent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/utils/handleRootClick.ts
|
|
2
2
|
function createRootClickHandler(actionHandlers) {
|
|
3
3
|
return function handleRootClick(event) {
|
|
4
4
|
const clickedElement = event.target;
|
|
@@ -12,5 +12,4 @@ function createRootClickHandler(actionHandlers) {
|
|
|
12
12
|
handler();
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { createRootClickHandler };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/cookie-monster/utils/linkify.ts
|
|
2
2
|
function linkify(text) {
|
|
3
3
|
const div = document.createElement("div");
|
|
4
4
|
div.textContent = text;
|
|
5
5
|
div.innerHTML = div.innerHTML.replaceAll(/\bhttps?:\/\/[^\s<]+[^\s<.)\]]/g, (url) => `<a href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
|
|
6
6
|
return div.innerHTML;
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { linkify };
|
|
@@ -2,6 +2,6 @@ import type { StringMap } from '@naturalcycles/js-lib/types';
|
|
|
2
2
|
import { LANG } from '@naturalcycles/shared';
|
|
3
3
|
export interface Translations extends StringMap {
|
|
4
4
|
}
|
|
5
|
-
export declare const SUPPORTED_LANGUAGES: LANG[];
|
|
6
|
-
export declare function setLanguage(rawLang?:
|
|
5
|
+
export declare const SUPPORTED_LANGUAGES: (LANG.en_US | LANG.en_GB | LANG.es_US | LANG.pt_BR | LANG.sv_SE | LANG.de_DE | LANG.fr_FR | LANG.it_IT | LANG.da_DK | LANG.no_NO | LANG.fi_FI)[];
|
|
6
|
+
export declare function setLanguage(rawLang?: string): void;
|
|
7
7
|
export declare function tr(key: string, params?: Record<string, string>): string;
|
|
@@ -11,7 +11,7 @@ import pt_BR_default from "../lang/pt-BR.js";
|
|
|
11
11
|
import sv_SE_default from "../lang/sv-SE.js";
|
|
12
12
|
import { _objectKeys } from "@naturalcycles/js-lib/types";
|
|
13
13
|
import { LANG, langService } from "@naturalcycles/shared";
|
|
14
|
-
|
|
14
|
+
// src/cookie-monster/utils/translationsService.ts
|
|
15
15
|
var translationsByLang = {
|
|
16
16
|
[LANG.en_US]: en_US_default,
|
|
17
17
|
[LANG.en_GB]: en_GB_default,
|
|
@@ -26,16 +26,16 @@ var translationsByLang = {
|
|
|
26
26
|
[LANG.no_NO]: no_NO_default
|
|
27
27
|
};
|
|
28
28
|
_objectKeys(translationsByLang);
|
|
29
|
-
var EN_US_FALLBACK_LANGS = /* @__PURE__ */ new Set([LANG.en_GB, LANG.en_CA]);
|
|
30
29
|
var TranslationsService = class {
|
|
31
30
|
copy = translationsByLang[langService.LANG_DEFAULT];
|
|
32
31
|
setLanguage(rawLang) {
|
|
33
|
-
const lang = langService.
|
|
34
|
-
const translations = translationsByLang[lang]
|
|
35
|
-
|
|
32
|
+
const lang = langService.toCookieMonsterLangOrUndefined(rawLang) ?? langService.LANG_DEFAULT;
|
|
33
|
+
const translations = translationsByLang[lang];
|
|
34
|
+
if (lang !== langService.LANG_DEFAULT && langService.isEnglish(lang)) this.copy = {
|
|
36
35
|
...translationsByLang[langService.LANG_DEFAULT],
|
|
37
36
|
...translations
|
|
38
|
-
}
|
|
37
|
+
};
|
|
38
|
+
else this.copy = translations;
|
|
39
39
|
}
|
|
40
40
|
tr(key, params) {
|
|
41
41
|
const translation = this.copy[key];
|
|
@@ -52,5 +52,4 @@ function setLanguage(rawLang) {
|
|
|
52
52
|
function tr(key, params) {
|
|
53
53
|
return translationService.tr(key, params);
|
|
54
54
|
}
|
|
55
|
-
//#endregion
|
|
56
55
|
export { setLanguage, tr };
|