@epigraph/epigraph-std-lib 4.0.1-alpha → 4.1.0
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/Epigraph/epigraph.cjs +1 -0
- package/dist/Epigraph/epigraph.d.ts +2 -3
- package/dist/Epigraph/epigraph.js +18 -21
- package/dist/Epigraph/epigraphBaseSolutions.cjs +1 -0
- package/dist/Epigraph/{epigraphBaseSolution.d.ts → epigraphBaseSolutions.d.ts} +1 -1
- package/dist/{lib/Epigraph/epigraphBaseSolution.js → Epigraph/epigraphBaseSolutions.js} +1 -1
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs +16 -0
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +354 -27
- package/dist/EpigraphLibs/EpigraphAnalytics/generics/queue.d.ts +3 -2
- package/dist/EpigraphLibs/EpigraphLogger/epigraphLogger.cjs +1 -0
- package/dist/EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.cjs +1 -0
- package/dist/EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.cjs +29 -0
- package/dist/EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.js +359 -19
- package/dist/EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.cjs +1 -0
- package/dist/EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.cjs +1 -0
- package/dist/EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.js +51 -30
- package/dist/EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs +1 -0
- package/dist/epigraph-std-lib.cjs +1 -0
- package/dist/epigraph-std-lib.d.ts +9 -1
- package/dist/epigraph-std-lib.js +40 -1
- package/package.json +4 -35
- package/dist/EpigraphLibs/EpigraphAnalytics/types/index.d.ts +0 -7
- package/dist/lib/Epigraph/constants/enums.js +0 -4
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/consent-plugins/consent-plugin-names.js +0 -4
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/consent-plugins/one-trust-consent-plugin.js +0 -29
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/node.js +0 -22
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/queue.js +0 -23
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/single-linked-list.js +0 -30
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/ga3-analytics-plugin.js +0 -87
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.js +0 -124
- package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/nexus-analytics-plugin.js +0 -45
- package/dist/lib/EpigraphLibs/EpigraphUnitsConverter/conversions.js +0 -26
- package/dist/lib/EpigraphLibs/EpigraphUnitsConverter/enums.js +0 -5
- package/dist/node_modules/lit-html/async-directive.js +0 -67
- package/dist/node_modules/lit-html/directive-helpers.js +0 -10
- package/dist/node_modules/lit-html/directive.js +0 -27
- package/dist/node_modules/lit-html/directives/ref.js +0 -40
- package/dist/node_modules/lit-html/lit-html.js +0 -225
- package/dist/vite-env.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../EpigraphLibs/EpigraphLogger/epigraphLogger.cjs"),p=require("../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs");var r=(n=>(n.DEVELOPMENT="development",n.STAGING="staging",n.PRODUCTION="production",n))(r||{});class g{constructor(e){if(this._loggerContext="EPIGRAPH",this._isReady=!1,this._logger=new s.EpigraphLogger("EPIGRAPH LOGGER"),this._environment=r.DEVELOPMENT,this._activeComponentsInSession=new Map,this._staleComponentsInSession=new Map,window.epigraph)return window.epigraph.registerActiveComponent(e),window.epigraph;window.epigraph=this,window.epigraph.registerActiveComponent(e),this.logBranding(),this._initializer=e,this._environment=this._initializer.environment;const t=this.getLoggerModeNameFromEnvironment();this._logger.setCurrentMode(t),this._urlProcessor=new p.EpigraphUrlProcessor,this.id=g.safeGenerateUuid();const i=this._urlProcessor.getParameterInUrl(p.QUERY_PARAMETER_NAMES.epigraphSessionId);this._epigraphSessionId=i??g.safeGenerateUuid(),this._logger.info({title:"Epigraph Object Ready!!",details:this,contextOverride:this._loggerContext}),this._isReady=!0}get isReady(){return this._isReady}get logger(){return this._logger}get urlProcessor(){return this._urlProcessor}get epigraphSessionId(){return this._epigraphSessionId}get environment(){return this._environment}get initializer(){return this._initializer}get activeComponentsInSession(){return this._activeComponentsInSession}get staleComponentsInSession(){return this._staleComponentsInSession}logBranding(){console.group("Powered by: "),console.log("%cEPIGRAPH","font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"),console.log("Visit for more details: www.epigraph.us"),console.groupEnd()}registerActiveComponent(e){this._activeComponentsInSession.set(e.uuid,e),this._logger.info({title:"Registered a new Active Component",details:e,contextOverride:this._loggerContext})}deregisterActiveComponent(e){const t=this._activeComponentsInSession.get(e.uuid);t&&(this._staleComponentsInSession.set(t.uuid,t),this._activeComponentsInSession.delete(t.uuid),this._logger.info({title:"Deregistered a new Active Component",details:e,contextOverride:this._loggerContext}))}getLoggerModeNameFromEnvironment(){let e=s.LoggerModeNames.Dev;return this._environment===r.STAGING?e=s.LoggerModeNames.Staging:this._environment===r.PRODUCTION&&(e=s.LoggerModeNames.Release),e}static safeGenerateUuid(){let e="";try{e=crypto.randomUUID()}catch{console.error("crypto not available. Not generating a UUID")}return e}static generateXPath(e){let t="",i=e;for(;i;){let a=1,o=i.previousSibling;for(;o;)o.nodeName===i.nodeName&&a++,o=o.previousSibling;t=`/${i.nodeName.toLowerCase()+(a>1?`[${a}]`:"")}${t}`,i=i.parentNode}return t}}exports.ENVIRONMENT_TYPE=r;exports.Epigraph=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EpigraphLogger, LoggerModeNames } from '../EpigraphLibs/EpigraphLogger/epigraphLogger';
|
|
2
2
|
import { ENVIRONMENT_TYPE } from './constants/enums';
|
|
3
3
|
import { EpigraphUrlProcessor } from '../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor';
|
|
4
|
-
import { EpigraphBaseSolutionTypes
|
|
4
|
+
import { EpigraphBaseSolutionTypes } from './epigraphBaseSolutions';
|
|
5
5
|
/**
|
|
6
6
|
* Epigraph component is intended to be a global source of truth/tracker in a given session for all of our components.
|
|
7
7
|
* This object would be responsible for serving/communicating/validating information, wherever necessary
|
|
@@ -73,8 +73,7 @@ export declare class Epigraph {
|
|
|
73
73
|
*/
|
|
74
74
|
static generateXPath(element: HTMLElement): string;
|
|
75
75
|
}
|
|
76
|
-
export { ENVIRONMENT_TYPE
|
|
77
|
-
export type { EpigraphBaseSolutionTypes };
|
|
76
|
+
export { ENVIRONMENT_TYPE };
|
|
78
77
|
declare global {
|
|
79
78
|
interface Window {
|
|
80
79
|
epigraph: Epigraph;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { EpigraphLogger as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class g {
|
|
1
|
+
import { EpigraphLogger as p, LoggerModeNames as g } from "../EpigraphLibs/EpigraphLogger/epigraphLogger.js";
|
|
2
|
+
import { EpigraphUrlProcessor as h, QUERY_PARAMETER_NAMES as l } from "../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js";
|
|
3
|
+
var r = /* @__PURE__ */ ((i) => (i.DEVELOPMENT = "development", i.STAGING = "staging", i.PRODUCTION = "production", i))(r || {});
|
|
4
|
+
class a {
|
|
6
5
|
constructor(e) {
|
|
7
|
-
if (this._loggerContext = "EPIGRAPH", this._isReady = !1, this._logger = new
|
|
6
|
+
if (this._loggerContext = "EPIGRAPH", this._isReady = !1, this._logger = new p("EPIGRAPH LOGGER"), this._environment = r.DEVELOPMENT, this._activeComponentsInSession = /* @__PURE__ */ new Map(), this._staleComponentsInSession = /* @__PURE__ */ new Map(), window.epigraph)
|
|
8
7
|
return window.epigraph.registerActiveComponent(e), window.epigraph;
|
|
9
8
|
window.epigraph = this, window.epigraph.registerActiveComponent(e), this.logBranding(), this._initializer = e, this._environment = this._initializer.environment;
|
|
10
9
|
const t = this.getLoggerModeNameFromEnvironment();
|
|
11
|
-
this._logger.setCurrentMode(t), this._urlProcessor = new
|
|
12
|
-
const
|
|
13
|
-
this._epigraphSessionId =
|
|
10
|
+
this._logger.setCurrentMode(t), this._urlProcessor = new h(), this.id = a.safeGenerateUuid();
|
|
11
|
+
const n = this._urlProcessor.getParameterInUrl(l.epigraphSessionId);
|
|
12
|
+
this._epigraphSessionId = n ?? a.safeGenerateUuid(), this._logger.info({ title: "Epigraph Object Ready!!", details: this, contextOverride: this._loggerContext }), this._isReady = !0;
|
|
14
13
|
}
|
|
15
14
|
get isReady() {
|
|
16
15
|
return this._isReady;
|
|
@@ -71,8 +70,8 @@ class g {
|
|
|
71
70
|
* @returns {LoggerModeNames} A valid logger mode name.
|
|
72
71
|
*/
|
|
73
72
|
getLoggerModeNameFromEnvironment() {
|
|
74
|
-
let e =
|
|
75
|
-
return this._environment ===
|
|
73
|
+
let e = g.Dev;
|
|
74
|
+
return this._environment === r.STAGING ? e = g.Staging : this._environment === r.PRODUCTION && (e = g.Release), e;
|
|
76
75
|
}
|
|
77
76
|
/**
|
|
78
77
|
* Generates a random UUID using crypto.randomUUID with a fallback on custom generator,
|
|
@@ -96,19 +95,17 @@ class g {
|
|
|
96
95
|
* @returns {string} The generated XPath.
|
|
97
96
|
*/
|
|
98
97
|
static generateXPath(e) {
|
|
99
|
-
let t = "",
|
|
100
|
-
for (;
|
|
101
|
-
let
|
|
102
|
-
for (;
|
|
103
|
-
|
|
104
|
-
t = `/${
|
|
98
|
+
let t = "", n = e;
|
|
99
|
+
for (; n; ) {
|
|
100
|
+
let s = 1, o = n.previousSibling;
|
|
101
|
+
for (; o; )
|
|
102
|
+
o.nodeName === n.nodeName && s++, o = o.previousSibling;
|
|
103
|
+
t = `/${n.nodeName.toLowerCase() + (s > 1 ? `[${s}]` : "")}${t}`, n = n.parentNode;
|
|
105
104
|
}
|
|
106
105
|
return t;
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
w as EpigraphBaseSolutionHtmlElement,
|
|
113
|
-
I as EpigraphBaseSolutionLitElement
|
|
109
|
+
r as ENVIRONMENT_TYPE,
|
|
110
|
+
a as Epigraph
|
|
114
111
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lit"),e=require("./epigraph.cjs");class s extends HTMLElement{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-html",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this.attachShadow({mode:"open"}),this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}class o extends r.LitElement{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-lit",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),this._isReady=!0,window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}exports.EpigraphBaseSolutionHtmlElement=s;exports.EpigraphBaseSolutionLitElement=o;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement as s } from "lit";
|
|
2
|
-
import { Epigraph as e } from "
|
|
2
|
+
import { Epigraph as e } from "./epigraph.js";
|
|
3
3
|
class h extends HTMLElement {
|
|
4
4
|
constructor(t, i) {
|
|
5
5
|
super(), this._isReady = !1, this._elementName = "epigraph-base-solution-html", this._solutionVersion = "", this._loggerContextOverride = "[EPIGRAPH BASE SOLUTION]", this.attachShadow({ mode: "open" }), this._environment = i, this._solutionVersion = t, this._xPath = e.generateXPath(this), this._uuid = e.safeGenerateUuid() ?? this._xPath, new e(this), window.epigraph.logger.info({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=Symbol("data"),u=Symbol("next"),m=class p{constructor(e){this[g]=e,this[u]=null}get data(){return this[g]}set next(e){if(!(e instanceof p)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[u]=e}get next(){return this[u]}};let f=m;const h=Symbol("head");class q{constructor(){this[h]=null}set head(e){this[h]=e}get head(){return this[h]}addToTail(e){let t=this.head;if(t){for(;t.next!==null;)t=t?.next;return t.next=new f(e)}return this.head=new f(e)}removeHead(){const e=this.head;if(e)return this.head=e.next,e.data}}const y=Symbol("queue"),o=Symbol("size");class l{constructor(){this[y]=new q,this[o]=0}get queue(){return this[y]}get size(){return this[o]}enqueue(e){this.queue.addToTail(e),this[o]++}dequeue(){const e=this.queue.removeHead();return this[o]--,e}}class A{constructor(e,t,n,s){this.name=this.pluginName="GA3-PLUGIN",this.trackingID=e,this.verboseLogging=t,this.user=n,this.trackerName=s,this.queue=new l,this.trackerInterval=0,this.trackerCreated=!1}sendEvent(e){if(this.queue.enqueue(e),window.ga!==void 0&&typeof ga=="function")try{this.dequeueAndSendEvents()}catch(t){this.logger(t)}else this.logger("Cannot send Google Analytics 3 event: ga function is not defined.");return!0}dequeueAndSendEvents(){if(this.trackerCreated){let e=this.queue.size;for(let t=0;t<e;t++){const n=this.queue.dequeue();ga(`${this.trackerName}.send`,n.type,n.category,n.action,n.label,n.interaction),this.logger(`Google Analytics 3 event successfully sent: ${n.action}`)}}else this.logger("Cannot sent Google Analytics 3 event: tracker was not created.")}async createTracker(){if(window.ga!==void 0&&typeof ga=="function")try{ga("create",this.trackingID,"auto",this.trackerName,{userId:this.user});const e=new URL(window.location.href);ga(`${this.trackerName}.set`,"page",e.pathname),ga(`${this.trackerName}.set`,"location",e.href),this.trackerCreated=!0,this.logger("Google Analytics 3 tracker successfully created."),this.dequeueAndSendEvents(),window.clearInterval(this.trackerInterval)}catch(e){this.logger(e)}else this.logger("Error: Cannot create tracker, ga function is not defined.")}logger(e){this.verboseLogging&&console.warn(e)}getUniquePluginIdentifier(){return this.pluginName+"-"+this.trackingID}setupPlugin(){var e=0;this.trackerInterval=window.setInterval(()=>{this.createTracker(),++e===10&&(window.clearInterval(this.trackerInterval),this.logger("Error: Failed to create Google Analytics tracker in the allotted timeframe."))},1e3)}}class P{constructor(e,t){this.name=this.pluginName="GA4-PLUGIN",this.trackingID=e,this.verboseLogging=t,this.queue=new l,this.dataLayer=window.dataLayer,this.dataLayerName="dataLayer",this.setupDataLayer(),this.initGtag(this.dataLayerName,this.trackingID)}setupDataLayer(){if(this.dataLayer)return;const t=this.findGA4ScriptInfo(this.trackingID)?.l;t&&(this.dataLayerName=t,this.dataLayer=window[t])}initGtag(e="dataLayer",t){typeof window.gtag!="function"&&(window.gtag=function(){window[e].push(arguments),gtag("js",new Date),gtag("config",t)})}async sendEvent(e,t){this.queue.enqueue(e);let n=!0;if(t&&(n=t.hasConsent()),this.dataLayer!==void 0&&n)try{await this.dequeueAndSendEvents()}catch(s){this.logger(s)}else this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.")}async dequeueAndSendEvents(){let e=this.queue.size;for(let t=0;t<e;t++){const n=this.queue.dequeue();let s={send_to:this.trackingID,event_action:n.action,event_category:n.category,event_label:n.label,epg_event_tag:""};if("parameters"in n&&Object.assign(s,n.parameters),JSON.stringify(s).length>459)try{let a=await this.sendGA4LongParameters(s);s={send_to:this.trackingID,event_action:n.action,event_category:n.category,event_label:n.label,epg_event_tag:a}}catch{}gtag("event",n.action,s),this.logger(`Google Analytics 4 event successfully sent: ${n.action}`)}}logger(e){this.verboseLogging&&console.warn(e)}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendGA4LongParameters(e){const t="https://api.myepigraph.com/api/analytics/ga4/custom",n={parameters:e};try{const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});if(s.ok){const r=await s.json();return r&&r.id?r.id:""}else return""}catch{return""}}findGA4ScriptInfo(e){const t=document.querySelectorAll("script[src]");for(const n of t){const s=n.getAttribute("src");if(s&&s.includes(e)){const r=new URL(s,location.href),a=Object.fromEntries(r.searchParams.entries());return{fullSrc:r.href,id:a.id||void 0,l:a.l||void 0}}}return null}}class S{constructor(e,t,n,s,r=!1){this.sessionId=t,this.xPath=n,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=e,this.verboseLogging=s,this.queue=new l,this.url=r?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event"}async sendEvent(e,t){this.queue.enqueue(e);let n=!0;t&&(n=t.hasConsent()),n&&await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let e=0;e<this.queue.size;e++){const t=this.queue.dequeue(),n={experience_id:this.trackingID,action:t.action,parameters:t.parameters};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(n)})).status===204,""}catch{return""}}return""}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}}class v{constructor(e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroup!==void 0){let e=window.OnetrustActiveGroup;e!==void 0&&e.split(",").forEach(n=>{n===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}}var d=(i=>(i.OneTrust="onetrust",i))(d||{});/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/var w;const c=Symbol("analyticsPluginsMap");w=c;class I{constructor(e,t){this[w]=new Map,this._consentPlugin=null,e&&t&&(this._consentPlugin=this.buildConsentPlugin(e,t))}addEventPlugin(e){this[c].has(e.getUniquePluginIdentifier())||(this[c].set(e.getUniquePluginIdentifier(),e),e.setupPlugin())}sendEvent(e){this[c].forEach(t=>{t.sendEvent(e,this._consentPlugin)})}buildConsentPlugin(e,t){return e.toLowerCase()===d.OneTrust.toLowerCase()?new v(t):null}}exports.ConsentPluginNames=d;exports.EpigraphAnalytics=I;exports.GA3AnalyticsPlugin=A;exports.GA4AnalyticsPlugin=P;exports.NexusAnalyticsPlugin=S;exports.OneTrustConsentPlugin=v;
|
|
@@ -1,8 +1,335 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const d = Symbol("data"), u = Symbol("next"), w = class y {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
this[d] = e, this[u] = null;
|
|
4
|
+
}
|
|
5
|
+
get data() {
|
|
6
|
+
return this[d];
|
|
7
|
+
}
|
|
8
|
+
set next(e) {
|
|
9
|
+
if (!(e instanceof y) && e !== null)
|
|
10
|
+
throw new Error(
|
|
11
|
+
"This node is not an instance of the custom class 'Node'."
|
|
12
|
+
);
|
|
13
|
+
this[u] = e;
|
|
14
|
+
}
|
|
15
|
+
get next() {
|
|
16
|
+
return this[u];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
let g = w;
|
|
20
|
+
const h = Symbol("head");
|
|
21
|
+
class m {
|
|
22
|
+
constructor() {
|
|
23
|
+
this[h] = null;
|
|
24
|
+
}
|
|
25
|
+
set head(e) {
|
|
26
|
+
this[h] = e;
|
|
27
|
+
}
|
|
28
|
+
get head() {
|
|
29
|
+
return this[h];
|
|
30
|
+
}
|
|
31
|
+
addToTail(e) {
|
|
32
|
+
let t = this.head;
|
|
33
|
+
if (t) {
|
|
34
|
+
for (; t.next !== null; )
|
|
35
|
+
t = t?.next;
|
|
36
|
+
return t.next = new g(e);
|
|
37
|
+
}
|
|
38
|
+
return this.head = new g(e);
|
|
39
|
+
}
|
|
40
|
+
removeHead() {
|
|
41
|
+
const e = this.head;
|
|
42
|
+
if (e)
|
|
43
|
+
return this.head = e.next, e.data;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const f = Symbol("queue"), o = Symbol("size");
|
|
47
|
+
class l {
|
|
48
|
+
constructor() {
|
|
49
|
+
this[f] = new m(), this[o] = 0;
|
|
50
|
+
}
|
|
51
|
+
get queue() {
|
|
52
|
+
return this[f];
|
|
53
|
+
}
|
|
54
|
+
get size() {
|
|
55
|
+
return this[o];
|
|
56
|
+
}
|
|
57
|
+
enqueue(e) {
|
|
58
|
+
this.queue.addToTail(e), this[o]++;
|
|
59
|
+
}
|
|
60
|
+
dequeue() {
|
|
61
|
+
const e = this.queue.removeHead();
|
|
62
|
+
return this[o]--, e;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
class I {
|
|
66
|
+
constructor(e, t, n, s) {
|
|
67
|
+
this.name = this.pluginName = "GA3-PLUGIN", this.trackingID = e, this.verboseLogging = t, this.user = n, this.trackerName = s, this.queue = new l(), this.trackerInterval = 0, this.trackerCreated = !1;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* This function will send an Event to GA3.
|
|
71
|
+
*
|
|
72
|
+
* @param eventData AnalyticsEvent The event to be tracked
|
|
73
|
+
*/
|
|
74
|
+
sendEvent(e) {
|
|
75
|
+
if (this.queue.enqueue(e), window.ga !== void 0 && typeof ga == "function")
|
|
76
|
+
try {
|
|
77
|
+
this.dequeueAndSendEvents();
|
|
78
|
+
} catch (t) {
|
|
79
|
+
this.logger(t);
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
this.logger("Cannot send Google Analytics 3 event: ga function is not defined.");
|
|
83
|
+
return !0;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Send all events that are in the queue
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
dequeueAndSendEvents() {
|
|
90
|
+
if (this.trackerCreated) {
|
|
91
|
+
let e = this.queue.size;
|
|
92
|
+
for (let t = 0; t < e; t++) {
|
|
93
|
+
const n = this.queue.dequeue();
|
|
94
|
+
ga(
|
|
95
|
+
`${this.trackerName}.send`,
|
|
96
|
+
n.type,
|
|
97
|
+
n.category,
|
|
98
|
+
n.action,
|
|
99
|
+
n.label,
|
|
100
|
+
n.interaction
|
|
101
|
+
), this.logger(`Google Analytics 3 event successfully sent: ${n.action}`);
|
|
102
|
+
}
|
|
103
|
+
} else
|
|
104
|
+
this.logger("Cannot sent Google Analytics 3 event: tracker was not created.");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* GA3 requires that a tracker be created prior to being sent. This is called from the constructor. It is
|
|
108
|
+
* important to note that the promise that is inherently returned is ignored in the constructor at this
|
|
109
|
+
* time. This is due to the events that are added will be queued from the page. This script requires
|
|
110
|
+
* that the GA script has been imported on the page already as it does not check for it today.
|
|
111
|
+
*
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
async createTracker() {
|
|
115
|
+
if (window.ga !== void 0 && typeof ga == "function")
|
|
116
|
+
try {
|
|
117
|
+
ga("create", this.trackingID, "auto", this.trackerName, {
|
|
118
|
+
userId: this.user
|
|
119
|
+
});
|
|
120
|
+
const e = new URL(window.location.href);
|
|
121
|
+
ga(`${this.trackerName}.set`, "page", e.pathname), ga(`${this.trackerName}.set`, "location", e.href), this.trackerCreated = !0, this.logger("Google Analytics 3 tracker successfully created."), this.dequeueAndSendEvents(), window.clearInterval(this.trackerInterval);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
this.logger(e);
|
|
124
|
+
}
|
|
125
|
+
else
|
|
126
|
+
this.logger("Error: Cannot create tracker, ga function is not defined.");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks if verboseLogging is enabled, then logs the error
|
|
130
|
+
* @param err
|
|
131
|
+
*/
|
|
132
|
+
logger(e) {
|
|
133
|
+
this.verboseLogging && console.warn(e);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a unique plugin identifier so that tracking ID's can be the same across multiple plugins.
|
|
137
|
+
*/
|
|
138
|
+
getUniquePluginIdentifier() {
|
|
139
|
+
return this.pluginName + "-" + this.trackingID;
|
|
140
|
+
}
|
|
141
|
+
setupPlugin() {
|
|
142
|
+
var e = 0;
|
|
143
|
+
this.trackerInterval = window.setInterval(() => {
|
|
144
|
+
this.createTracker(), ++e === 10 && (window.clearInterval(this.trackerInterval), this.logger("Error: Failed to create Google Analytics tracker in the allotted timeframe."));
|
|
145
|
+
}, 1e3);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
class A {
|
|
149
|
+
constructor(e, t) {
|
|
150
|
+
this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = e, this.verboseLogging = t, this.queue = new l(), this.dataLayer = window.dataLayer, this.dataLayerName = "dataLayer", this.setupDataLayer(), this.initGtag(this.dataLayerName, this.trackingID);
|
|
151
|
+
}
|
|
152
|
+
setupDataLayer() {
|
|
153
|
+
if (this.dataLayer) return;
|
|
154
|
+
const t = this.findGA4ScriptInfo(this.trackingID)?.l;
|
|
155
|
+
t && (this.dataLayerName = t, this.dataLayer = window[t]);
|
|
156
|
+
}
|
|
157
|
+
initGtag(e = "dataLayer", t) {
|
|
158
|
+
typeof window.gtag != "function" && (window.gtag = function() {
|
|
159
|
+
window[e].push(arguments), gtag("js", /* @__PURE__ */ new Date()), gtag("config", t);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* This function will send an Event to GA3.
|
|
164
|
+
*
|
|
165
|
+
* @param eventData AnalyticsEvent The event to be tracked
|
|
166
|
+
* @param consentPlugin
|
|
167
|
+
*/
|
|
168
|
+
async sendEvent(e, t) {
|
|
169
|
+
this.queue.enqueue(e);
|
|
170
|
+
let n = !0;
|
|
171
|
+
if (t && (n = t.hasConsent()), this.dataLayer !== void 0 && n)
|
|
172
|
+
try {
|
|
173
|
+
await this.dequeueAndSendEvents();
|
|
174
|
+
} catch (s) {
|
|
175
|
+
this.logger(s);
|
|
176
|
+
}
|
|
177
|
+
else
|
|
178
|
+
this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.");
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Send all events that are in the queue
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
async dequeueAndSendEvents() {
|
|
185
|
+
let e = this.queue.size;
|
|
186
|
+
for (let t = 0; t < e; t++) {
|
|
187
|
+
const n = this.queue.dequeue();
|
|
188
|
+
let s = {
|
|
189
|
+
send_to: this.trackingID,
|
|
190
|
+
event_action: n.action,
|
|
191
|
+
event_category: n.category,
|
|
192
|
+
event_label: n.label,
|
|
193
|
+
epg_event_tag: ""
|
|
194
|
+
};
|
|
195
|
+
if ("parameters" in n && Object.assign(s, n.parameters), JSON.stringify(s).length > 459)
|
|
196
|
+
try {
|
|
197
|
+
let a = await this.sendGA4LongParameters(s);
|
|
198
|
+
s = {
|
|
199
|
+
send_to: this.trackingID,
|
|
200
|
+
event_action: n.action,
|
|
201
|
+
event_category: n.category,
|
|
202
|
+
event_label: n.label,
|
|
203
|
+
epg_event_tag: a
|
|
204
|
+
};
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
gtag("event", n.action, s), this.logger(`Google Analytics 4 event successfully sent: ${n.action}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Checks if verboseLogging is enabled, then logs the error
|
|
212
|
+
* @param err
|
|
213
|
+
*/
|
|
214
|
+
logger(e) {
|
|
215
|
+
this.verboseLogging && console.warn(e);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns a unique plugin identifier so that tracking ID's can be the same across multiple plugins.
|
|
219
|
+
*/
|
|
220
|
+
getUniquePluginIdentifier() {
|
|
221
|
+
return this.name + "-" + this.trackingID;
|
|
222
|
+
}
|
|
223
|
+
setupPlugin() {
|
|
224
|
+
this.dataLayer !== void 0 && this.dequeueAndSendEvents();
|
|
225
|
+
}
|
|
226
|
+
async sendGA4LongParameters(e) {
|
|
227
|
+
const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = {
|
|
228
|
+
parameters: e
|
|
229
|
+
};
|
|
230
|
+
try {
|
|
231
|
+
const s = await fetch(t, {
|
|
232
|
+
method: "POST",
|
|
233
|
+
// Assuming it's a POST request, adjust if necessary
|
|
234
|
+
headers: {
|
|
235
|
+
"Content-Type": "application/json",
|
|
236
|
+
Accept: "application/json"
|
|
237
|
+
},
|
|
238
|
+
body: JSON.stringify(n)
|
|
239
|
+
});
|
|
240
|
+
if (s.ok) {
|
|
241
|
+
const r = await s.json();
|
|
242
|
+
return r && r.id ? r.id : "";
|
|
243
|
+
} else
|
|
244
|
+
return "";
|
|
245
|
+
} catch {
|
|
246
|
+
return "";
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
findGA4ScriptInfo(e) {
|
|
250
|
+
const t = document.querySelectorAll("script[src]");
|
|
251
|
+
for (const n of t) {
|
|
252
|
+
const s = n.getAttribute("src");
|
|
253
|
+
if (s && s.includes(e)) {
|
|
254
|
+
const r = new URL(s, location.href), a = Object.fromEntries(r.searchParams.entries());
|
|
255
|
+
return {
|
|
256
|
+
fullSrc: r.href,
|
|
257
|
+
id: a.id || void 0,
|
|
258
|
+
l: a.l || void 0
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
class L {
|
|
266
|
+
constructor(e, t, n, s, r = !1) {
|
|
267
|
+
this.sessionId = t, this.xPath = n, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = e, this.verboseLogging = s, this.queue = new l(), this.url = r ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event";
|
|
268
|
+
}
|
|
269
|
+
async sendEvent(e, t) {
|
|
270
|
+
this.queue.enqueue(e);
|
|
271
|
+
let n = !0;
|
|
272
|
+
t && (n = t.hasConsent()), n && await this.dequeueAndSendEvents();
|
|
273
|
+
}
|
|
274
|
+
async dequeueAndSendEvents() {
|
|
275
|
+
for (let e = 0; e < this.queue.size; e++) {
|
|
276
|
+
const t = this.queue.dequeue(), n = {
|
|
277
|
+
experience_id: this.trackingID,
|
|
278
|
+
action: t.action,
|
|
279
|
+
parameters: t.parameters
|
|
280
|
+
};
|
|
281
|
+
try {
|
|
282
|
+
return (await fetch(this.url, {
|
|
283
|
+
method: "POST",
|
|
284
|
+
// Assuming it's a POST request, adjust if necessary
|
|
285
|
+
headers: {
|
|
286
|
+
"Content-Type": "application/json",
|
|
287
|
+
Accept: "application/json",
|
|
288
|
+
"EPG-SESSION-ID": this.sessionId,
|
|
289
|
+
"EPG-XPATH": this.xPath,
|
|
290
|
+
Origin: typeof window < "u" ? window.location.origin : ""
|
|
291
|
+
},
|
|
292
|
+
body: JSON.stringify(n)
|
|
293
|
+
})).status === 204, "";
|
|
294
|
+
} catch {
|
|
295
|
+
return "";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return "";
|
|
299
|
+
}
|
|
300
|
+
getUniquePluginIdentifier() {
|
|
301
|
+
return this.name + "-" + this.trackingID;
|
|
302
|
+
}
|
|
303
|
+
setupPlugin() {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
class q {
|
|
307
|
+
constructor(e) {
|
|
308
|
+
this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Checks to see if the user has consented. If this is false, it will block all analytics
|
|
312
|
+
*/
|
|
313
|
+
hasConsent() {
|
|
314
|
+
if (this.consentSet)
|
|
315
|
+
return this.consent;
|
|
316
|
+
if (window.OnetrustActiveGroup !== void 0) {
|
|
317
|
+
let e = window.OnetrustActiveGroup;
|
|
318
|
+
e !== void 0 && e.split(",").forEach((n) => {
|
|
319
|
+
n === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return this.consent;
|
|
323
|
+
}
|
|
324
|
+
addConsentChangedListener() {
|
|
325
|
+
window.addEventListener("load", () => {
|
|
326
|
+
this.hasConsent(), window.OneTrust !== void 0 && typeof window.OneTrust == "object" && window.OneTrust.OnConsentChanged(() => {
|
|
327
|
+
this.consentSet = !1, this.hasConsent();
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
var p = /* @__PURE__ */ ((i) => (i.OneTrust = "onetrust", i))(p || {});
|
|
6
333
|
/**
|
|
7
334
|
* @license
|
|
8
335
|
* Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
|
|
@@ -19,12 +346,12 @@ import { ConsentPluginNames as l } from "../../lib/EpigraphLibs/EpigraphAnalytic
|
|
|
19
346
|
* See the License for the specific language governing permissions and
|
|
20
347
|
* limitations under the License.
|
|
21
348
|
*/
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
class
|
|
26
|
-
constructor(
|
|
27
|
-
this[
|
|
349
|
+
var v;
|
|
350
|
+
const c = Symbol("analyticsPluginsMap");
|
|
351
|
+
v = c;
|
|
352
|
+
class S {
|
|
353
|
+
constructor(e, t) {
|
|
354
|
+
this[v] = /* @__PURE__ */ new Map(), this._consentPlugin = null, e && t && (this._consentPlugin = this.buildConsentPlugin(e, t));
|
|
28
355
|
}
|
|
29
356
|
/**
|
|
30
357
|
* Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
|
|
@@ -33,20 +360,20 @@ class a {
|
|
|
33
360
|
*
|
|
34
361
|
* @param plugin
|
|
35
362
|
*/
|
|
36
|
-
addEventPlugin(
|
|
37
|
-
this[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
),
|
|
363
|
+
addEventPlugin(e) {
|
|
364
|
+
this[c].has(e.getUniquePluginIdentifier()) || (this[c].set(
|
|
365
|
+
e.getUniquePluginIdentifier(),
|
|
366
|
+
e
|
|
367
|
+
), e.setupPlugin());
|
|
41
368
|
}
|
|
42
369
|
/**
|
|
43
370
|
* Send an Event to all plugins
|
|
44
371
|
*
|
|
45
372
|
* @param eventData
|
|
46
373
|
*/
|
|
47
|
-
sendEvent(
|
|
48
|
-
this[
|
|
49
|
-
t.sendEvent(
|
|
374
|
+
sendEvent(e) {
|
|
375
|
+
this[c].forEach((t) => {
|
|
376
|
+
t.sendEvent(e, this._consentPlugin);
|
|
50
377
|
});
|
|
51
378
|
}
|
|
52
379
|
/**
|
|
@@ -55,15 +382,15 @@ class a {
|
|
|
55
382
|
* @param consentIdentifier
|
|
56
383
|
* @private
|
|
57
384
|
*/
|
|
58
|
-
buildConsentPlugin(
|
|
59
|
-
return
|
|
385
|
+
buildConsentPlugin(e, t) {
|
|
386
|
+
return e.toLowerCase() === p.OneTrust.toLowerCase() ? new q(t) : null;
|
|
60
387
|
}
|
|
61
388
|
}
|
|
62
389
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
390
|
+
p as ConsentPluginNames,
|
|
391
|
+
S as EpigraphAnalytics,
|
|
392
|
+
I as GA3AnalyticsPlugin,
|
|
393
|
+
A as GA4AnalyticsPlugin,
|
|
394
|
+
L as NexusAnalyticsPlugin,
|
|
395
|
+
q as OneTrustConsentPlugin
|
|
69
396
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as SLL } from './single-linked-list.js';
|
|
2
|
+
import { AnalyticsEvent } from '../analytics-event-interface.ts';
|
|
2
3
|
declare const $queue: unique symbol;
|
|
3
4
|
declare const $size: unique symbol;
|
|
4
5
|
export default class Queue {
|
|
@@ -7,7 +8,7 @@ export default class Queue {
|
|
|
7
8
|
constructor();
|
|
8
9
|
get queue(): SLL;
|
|
9
10
|
get size(): number;
|
|
10
|
-
enqueue(data:
|
|
11
|
-
dequeue():
|
|
11
|
+
enqueue(data: AnalyticsEvent): void;
|
|
12
|
+
dequeue(): AnalyticsEvent;
|
|
12
13
|
}
|
|
13
14
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s=(l=>(l.Release="release",l.Staging="staging",l.Dev="dev",l))(s||{}),t=(l=>(l.Info="info",l.Warn="warn",l.Error="error",l))(t||{});class a{constructor(o){this.context="EPIGRAPH-LOGGER",this._allModes={release:{name:"release",allows:["error"]},staging:{name:"staging",allows:["warn","error"]},dev:{name:"dev",allows:["info","warn","error"]}},this._currentMode="release",o&&(this.context=o.toLocaleUpperCase())}get modes(){return this._allModes}setCurrentMode(o){if(!Object.keys(this._allModes).includes(o)){console.warn(`"${o}": is not a valid logger mode`);return}this._currentMode=o}_isLogTypeAllowedInCurrentMode(o){return this._allModes[this._currentMode].allows.includes(o)}info({title:o,details:r="",contextOverride:e=void 0}){if(!this._isLogTypeAllowedInCurrentMode("info"))return;const n=e||this.context;console.groupCollapsed(`[${n}]: ${o}`),console.log(r),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}warn({title:o,details:r="",contextOverride:e=void 0}){if(!this._isLogTypeAllowedInCurrentMode("warn"))return;const n=e||this.context;console.groupCollapsed(`%c[${n}]: ${o}`,"color: orange;"),console.warn(r),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}error({title:o,details:r="",contextOverride:e=void 0}){if(!this._isLogTypeAllowedInCurrentMode("error"))return;const n=e||this.context;console.groupCollapsed(`%c[${n}]: ${o}`,"color: red;"),console.error(r),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}table({title:o,details:r={},contextOverride:e=void 0,logType:n="info"}){if(!this._isLogTypeAllowedInCurrentMode(n))return;const c=e||this.context;console.groupCollapsed(`[${c}]: ${o}`),console.table(r),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}group({title:o,contextOverride:r=void 0,logType:e="info"}){if(!this._isLogTypeAllowedInCurrentMode(e))return;const n=r||this.context;console.group(`%c ${n} GROUP`,o)}groupCollapsed({title:o,contextOverride:r=void 0,logType:e="info"}){if(!this._isLogTypeAllowedInCurrentMode(e))return;const n=r||this.context;console.groupCollapsed(`%c ${n} GROUP`,o)}groupEnd(){this._isLogTypeAllowedInCurrentMode("info")&&(console.log("----------------------------------"),console.groupEnd())}}exports.EpigraphLogger=a;exports.LogTypes=t;exports.LoggerModeNames=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../EpigraphResultFactory/epigraphResultFactory.cjs");class P{constructor(e="https://api.myepigraph.com/api/",i,r,s="",a="",n="v1/"){this.epigraphXPath="",this.epigraphComponentVersion=s,this.epigraphSessionId=r,this.epigraphXPath=a,this.baseUrl=e+n,this.epgLocation=i}async getConfiguratorByExperienceId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator/experience_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorByClientAccessKey(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator/client_access_key/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorLiteByExperienceId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator-lite/experience_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorLiteByProjectId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator-lite/project_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async postExperienceSaveAndShare(e,i){const r="experience/"+e+"/save/",s=this.buildNexusUrl(r),a={save_data:JSON.stringify(i)},n=new Headers;return n.set("Content-Type","application/json"),await this.callNexusAPI(s,"POST",JSON.stringify(a),n)}async getExperienceSaveAndShare(e,i){const r="experience/"+e+"/save/"+i,s=this.buildNexusUrl(r);return await this.callNexusAPI(s,"GET")}async callNexusAPI(e,i="GET",r,s=new Headers){s=this.addRequiredHeaders(s);const a={method:i,body:r,headers:s};try{const n=await fetch(e,a),o=await n.json();if(!n.ok){let u="Unable to retrieve configurator experience";return o.message&&(u=o.message),Promise.resolve(c.failureResult(o,n.status,u))}return Promise.resolve(c.successResult(o,n.status))}catch{return Promise.resolve(c.failureResult({},500,"Unknown error"))}}buildNexusUrl(e,i={}){let r=new URL(this.baseUrl);r.pathname+=e;for(const[s,a]of Object.entries(i))r.searchParams.set(s,a);return r}addRequiredHeaders(e){return e.has("accept")||e.set("accept","application/json"),e.has("EPG-Location")||e.set("EPG-location",this.epgLocation),e.has("EPG-Session-ID")||e.set("EPG-Session-ID",this.epigraphSessionId),e.has("EPG-XPATH")||e.set("EPG-XPATH",this.epigraphXPath),e.has("EPG-Version")||e.set("EPG-Version",this.epigraphComponentVersion),e}}var p=(t=>(t.PRODUCTION="https://api.myepigraph.com/api/",t.STAGING="https://nexus.epigraph.dev/api/",t.LOCAL="https://nexus.test/api/",t))(p||{}),l=(t=>(t.CLIENT_ACCESS_KEY="client_access_key",t.EXPERIENCE_ID="experience_id",t.PROJECT_ID="project_id",t))(l||{}),h=(t=>(t.CONFIGURATOR="experience/configurator/",t.CONFIGURATOR_LITE="experience/configurator-lite/",t.EXPERIENCE="experience/",t.SAVE="save/",t))(h||{}),E=(t=>(t.V1="v1/",t))(E||{}),g=(t=>(t.GET="GET",t.POST="POST",t.PUT="PUT",t.DELETE="DELETE",t))(g||{});exports.EpigraphNexusAPI=P;exports.HTTPMethod=g;exports.NexusAPIResourceIdentifier=l;exports.NexusAPIRoutes=h;exports.NexusAPIVersions=E;exports.NexusEndpoints=p;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("lit"),Z=require("qr-creator");/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const R=globalThis,w=R.trustedTypes,k=w?w.createPolicy("lit-html",{createHTML:i=>i}):void 0,P="$lit$",u=`lit$${Math.random().toFixed(9).slice(2)}$`,W="?"+u,F=`<${W}>`,g=document,M=()=>g.createComment(""),C=i=>i===null||typeof i!="object"&&typeof i!="function",L=Array.isArray,J=i=>L(i)||typeof i?.[Symbol.iterator]=="function",E=`[
|
|
6
|
+
\f\r]`,m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,B=/>/g,p=RegExp(`>|${E}(?:([^\\s"'>=/]+)(${E}*=${E}*(?:[^
|
|
7
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),q=/'/g,D=/"/g,z=/^(?:script|style|textarea|title)$/i,H=Symbol.for("lit-noChange"),a=Symbol.for("lit-nothing"),j=new WeakMap,f=g.createTreeWalker(g,129);function V(i,t){if(!L(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return k!==void 0?k.createHTML(t):t}const K=(i,t)=>{const e=i.length-1,s=[];let n,o=t===2?"<svg>":t===3?"<math>":"",r=m;for(let d=0;d<e;d++){const h=i[d];let c,$,l=-1,A=0;for(;A<h.length&&(r.lastIndex=A,$=r.exec(h),$!==null);)A=r.lastIndex,r===m?$[1]==="!--"?r=O:$[1]!==void 0?r=B:$[2]!==void 0?(z.test($[2])&&(n=RegExp("</"+$[2],"g")),r=p):$[3]!==void 0&&(r=p):r===p?$[0]===">"?(r=n??m,l=-1):$[1]===void 0?l=-2:(l=r.lastIndex-$[2].length,c=$[1],r=$[3]===void 0?p:$[3]==='"'?D:q):r===D||r===q?r=p:r===O||r===B?r=m:(r=p,n=void 0);const _=r===p&&i[d+1].startsWith("/>")?" ":"";o+=r===m?h+F:l>=0?(s.push(c),h.slice(0,l)+P+h.slice(l)+u+_):h+u+(l===-2?d:_)}return[V(i,o+(i[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class b{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let o=0,r=0;const d=t.length-1,h=this.parts,[c,$]=K(t,e);if(this.el=b.createElement(c,s),f.currentNode=this.el.content,e===2||e===3){const l=this.el.content.firstChild;l.replaceWith(...l.childNodes)}for(;(n=f.nextNode())!==null&&h.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const l of n.getAttributeNames())if(l.endsWith(P)){const A=$[r++],_=n.getAttribute(l).split(u),x=/([.?@])?(.*)/.exec(A);h.push({type:1,index:o,name:x[2],strings:_,ctor:x[1]==="."?Y:x[1]==="?"?tt:x[1]==="@"?et:S}),n.removeAttribute(l)}else l.startsWith(u)&&(h.push({type:6,index:o}),n.removeAttribute(l));if(z.test(n.tagName)){const l=n.textContent.split(u),A=l.length-1;if(A>0){n.textContent=w?w.emptyScript:"";for(let _=0;_<A;_++)n.append(l[_],M()),f.nextNode(),h.push({type:2,index:++o});n.append(l[A],M())}}}else if(n.nodeType===8)if(n.data===W)h.push({type:2,index:o});else{let l=-1;for(;(l=n.data.indexOf(u,l+1))!==-1;)h.push({type:7,index:o}),l+=u.length-1}o++}}static createElement(t,e){const s=g.createElement("template");return s.innerHTML=t,s}}function v(i,t,e=i,s){if(t===H)return t;let n=s!==void 0?e._$Co?.[s]:e._$Cl;const o=C(t)?void 0:t._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),o===void 0?n=void 0:(n=new o(i),n._$AT(i,e,s)),s!==void 0?(e._$Co??=[])[s]=n:e._$Cl=n),n!==void 0&&(t=v(i,n._$AS(i,t.values),n,s)),t}class X{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??g).importNode(e,!0);f.currentNode=n;let o=f.nextNode(),r=0,d=0,h=s[0];for(;h!==void 0;){if(r===h.index){let c;h.type===2?c=new G(o,o.nextSibling,this,t):h.type===1?c=new h.ctor(o,h.name,h.strings,this,t):h.type===6&&(c=new st(o,this,t)),this._$AV.push(c),h=s[++d]}r!==h?.index&&(o=f.nextNode(),r++)}return f.currentNode=g,n}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class G{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=a,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=v(this,t,e),C(t)?t===a||t==null||t===""?(this._$AH!==a&&this._$AR(),this._$AH=a):t!==this._$AH&&t!==H&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):J(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==a&&C(this._$AH)?this._$AA.nextSibling.data=t:this.T(g.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=b.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const o=new X(n,this),r=o.u(this.options);o.p(e),this.T(r),this._$AH=o}}_$AC(t){let e=j.get(t.strings);return e===void 0&&j.set(t.strings,e=new b(t)),e}k(t){L(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,n=0;for(const o of t)n===e.length?e.push(s=new G(this.O(M()),this.O(M()),this,this.options)):s=e[n],s._$AI(o),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class S{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,o){this.type=1,this._$AH=a,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=a}_$AI(t,e=this,s,n){const o=this.strings;let r=!1;if(o===void 0)t=v(this,t,e,0),r=!C(t)||t!==this._$AH&&t!==H,r&&(this._$AH=t);else{const d=t;let h,c;for(t=o[0],h=0;h<o.length-1;h++)c=v(this,d[s+h],e,h),c===H&&(c=this._$AH[h]),r||=!C(c)||c!==this._$AH[h],c===a?t=a:t!==a&&(t+=(c??"")+o[h+1]),this._$AH[h]=c}r&&!n&&this.j(t)}j(t){t===a?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Y extends S{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===a?void 0:t}}class tt extends S{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==a)}}class et extends S{constructor(t,e,s,n,o){super(t,e,s,n,o),this.type=5}_$AI(t,e=this){if((t=v(this,t,e,0)??a)===H)return;const s=this._$AH,n=t===a&&s!==a||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==a&&(s===a||n);n&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class st{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){v(this,t)}}const it=R.litHtmlPolyfillSupport;it?.(b,G),(R.litHtmlVersions??=[]).push("3.3.0");/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2020 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/const nt=i=>i.strings===void 0;/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright 2017 Google LLC
|
|
14
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
15
|
+
*/const ot={CHILD:2},rt=i=>(...t)=>({_$litDirective$:i,values:t});class ht{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/**
|
|
16
|
+
* @license
|
|
17
|
+
* Copyright 2017 Google LLC
|
|
18
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
+
*/const y=(i,t)=>{const e=i._$AN;if(e===void 0)return!1;for(const s of e)s._$AO?.(t,!1),y(s,t);return!0},T=i=>{let t,e;do{if((t=i._$AM)===void 0)break;e=t._$AN,e.delete(i),i=t}while(e?.size===0)},Q=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),ct(t)}};function lt(i){this._$AN!==void 0?(T(this),this._$AM=i,Q(this)):this._$AM=i}function at(i,t=!1,e=0){const s=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(t)if(Array.isArray(s))for(let o=e;o<s.length;o++)y(s[o],!1),T(s[o]);else s!=null&&(y(s,!1),T(s));else y(this,i)}const ct=i=>{i.type==ot.CHILD&&(i._$AP??=at,i._$AQ??=lt)};class $t extends ht{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),Q(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(y(this,t),T(this))}setValue(t){if(nt(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2020 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
+
*/const dt=()=>new At;class At{}const I=new WeakMap,_t=rt(class extends $t{render(i){return a}update(i,[t]){const e=t!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=i.options?.host,this.rt(this.ct=i.element)),a}rt(i){if(this.isConnected||(i=void 0),typeof this.G=="function"){const t=this.ht??globalThis;let e=I.get(t);e===void 0&&(e=new WeakMap,I.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,i),i!==void 0&&this.G.call(this.ht,i)}else this.G.value=i}get lt(){return typeof this.G=="function"?I.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});class N extends U.LitElement{constructor(){super(...arguments),this._qrCodeGenCanvasRef=dt()}static{this.webComponentName="epigraph-qr-code-generator"}static{this.styles=U.css`
|
|
24
|
+
:host {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
`}dataUritoBlob(t){const e=t.split(",");if(e.length!==2)throw new Error("Invalid data URI format");const s=e[0].split(":")[1].split(";")[0],n=atob(e[1]),o=new Uint8Array(Array.from(n,r=>r.charCodeAt(0)));return new Blob([o],{type:s})}generateQrCode(t={text:"www.epigraph.us",radius:.5,ecLevel:"H",fill:"black",background:null,size:256}){if(!this._qrCodeGenCanvasRef.value)return"";Z.render(t,this._qrCodeGenCanvasRef.value);const e=this._qrCodeGenCanvasRef.value.toDataURL(),s=this.dataUritoBlob(e);return URL.createObjectURL(s)}render(){return U.html`
|
|
28
|
+
<canvas id="qrCode" ${_t(this._qrCodeGenCanvasRef)}></canvas>
|
|
29
|
+
`}}window.customElements.get(N.webComponentName)===void 0&&window.customElements.define(N.webComponentName,N);exports.EpigraphQrCodeGenerator=N;
|