@epigraph/epigraph-std-lib 3.3.1 → 4.0.1-alpha

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.
Files changed (39) hide show
  1. package/README.md +32 -14
  2. package/dist/Epigraph/epigraph.d.ts +2 -2
  3. package/dist/Epigraph/epigraph.js +114 -0
  4. package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +69 -0
  5. package/dist/EpigraphLibs/EpigraphAnalytics/types/index.d.ts +7 -0
  6. package/dist/EpigraphLibs/EpigraphLogger/epigraphLogger.d.ts +3 -4
  7. package/dist/EpigraphLibs/EpigraphLogger/epigraphLogger.js +199 -0
  8. package/dist/EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.js +153 -0
  9. package/dist/EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.js +69 -0
  10. package/dist/EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.js +28 -0
  11. package/dist/EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.js +67 -0
  12. package/dist/EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.d.ts +1 -1
  13. package/dist/EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js +76 -0
  14. package/dist/epigraph-std-lib.d.ts +1 -3
  15. package/dist/epigraph-std-lib.js +0 -37462
  16. package/dist/lib/Epigraph/constants/enums.js +4 -0
  17. package/dist/lib/Epigraph/epigraphBaseSolution.js +70 -0
  18. package/dist/lib/EpigraphLibs/EpigraphAnalytics/consent-plugins/consent-plugin-names.js +4 -0
  19. package/dist/lib/EpigraphLibs/EpigraphAnalytics/consent-plugins/one-trust-consent-plugin.js +29 -0
  20. package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/node.js +22 -0
  21. package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/queue.js +23 -0
  22. package/dist/lib/EpigraphLibs/EpigraphAnalytics/generics/single-linked-list.js +30 -0
  23. package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/ga3-analytics-plugin.js +87 -0
  24. package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.js +124 -0
  25. package/dist/lib/EpigraphLibs/EpigraphAnalytics/plugins/nexus-analytics-plugin.js +45 -0
  26. package/dist/lib/EpigraphLibs/EpigraphUnitsConverter/conversions.js +26 -0
  27. package/dist/lib/EpigraphLibs/EpigraphUnitsConverter/enums.js +5 -0
  28. package/dist/node_modules/lit-html/async-directive.js +67 -0
  29. package/dist/node_modules/lit-html/directive-helpers.js +10 -0
  30. package/dist/node_modules/lit-html/directive.js +27 -0
  31. package/dist/node_modules/lit-html/directives/ref.js +40 -0
  32. package/dist/node_modules/lit-html/lit-html.js +225 -0
  33. package/dist/vite-env.d.ts +1 -0
  34. package/package.json +56 -24
  35. package/dist/EpigraphLibs/epigraphLibs.d.ts +0 -9
  36. package/dist/ThirdPartyLibs/thirdPartyLibs.d.ts +0 -15
  37. package/dist/ThirdPartyLibs/three-gltf-extensions/exporters/KHR_materials_variants/KHR_materials_variants_exporter.d.ts +0 -9
  38. package/dist/ThirdPartyLibs/three-gltf-extensions/loaders/KHR_materials_variants/KHR_materials_variants.d.ts +0 -6
  39. /package/dist/EpigraphLibs/EpigraphAnalytics/{EpigraphAnalytics.d.ts → epigraphAnalytics.d.ts} +0 -0
@@ -0,0 +1,69 @@
1
+ import { LitElement as s, css as i, html as l } from "lit";
2
+ import { createRef as c, ref as m } from "../../node_modules/lit-html/directives/ref.js";
3
+ import d from "qr-creator";
4
+ class a extends s {
5
+ constructor() {
6
+ super(...arguments), this._qrCodeGenCanvasRef = c();
7
+ }
8
+ static {
9
+ this.webComponentName = "epigraph-qr-code-generator";
10
+ }
11
+ static {
12
+ this.styles = i`
13
+ :host {
14
+ display: none;
15
+ }
16
+ `;
17
+ }
18
+ /**
19
+ * Converts any given data uri to a blob.
20
+ *
21
+ * @param {string} dataUri Raw data URI, either fetched from an HTML Canvas or any other valid source.
22
+ * @returns {Blob} The generate blob.
23
+ */
24
+ dataUritoBlob(e) {
25
+ const t = atob(e.split(",")[1]), r = e.split(",")[0].split(":")[1].split(";")[0], o = [];
26
+ for (let n = 0; n < t.length; n++)
27
+ o.push(t.charCodeAt(n));
28
+ return new Blob([new Uint8Array(o)], { type: r });
29
+ }
30
+ /**
31
+ * Generates a QR code as image data url for the qrCodeContent provided.
32
+ *
33
+ * @param {string} qrCodeContent The content to be embedded in the QR code.
34
+ * @returns {string} Session data URL for the generated QR code.
35
+ */
36
+ generateQrCode(e = {
37
+ text: "www.epigraph.us",
38
+ radius: 0.5,
39
+ // 0.0 to 0.5
40
+ ecLevel: "H",
41
+ // L, M, Q, H
42
+ fill: "black",
43
+ // foreground color
44
+ background: null,
45
+ // color or null for transparent
46
+ size: 256
47
+ // in pixels
48
+ }) {
49
+ if (!this._qrCodeGenCanvasRef.value)
50
+ return "";
51
+ d.render(e, this._qrCodeGenCanvasRef.value);
52
+ const t = this._qrCodeGenCanvasRef.value.toDataURL(), r = this.dataUritoBlob(t);
53
+ return URL.createObjectURL(r);
54
+ }
55
+ /**
56
+ * Override for the LitElement's render method.
57
+ *
58
+ * @returns {html} HTML to be rendered by this component.
59
+ */
60
+ render() {
61
+ return l`
62
+ <canvas id="qrCode" ${m(this._qrCodeGenCanvasRef)}></canvas>
63
+ `;
64
+ }
65
+ }
66
+ window.customElements.get(a.webComponentName) === void 0 && window.customElements.define(a.webComponentName, a);
67
+ export {
68
+ a as EpigraphQrCodeGenerator
69
+ };
@@ -0,0 +1,28 @@
1
+ class u {
2
+ constructor(s, t, r, a = "") {
3
+ this._success = s, this._payload = t, this._status = r, this._message = a;
4
+ }
5
+ get success() {
6
+ return this._success;
7
+ }
8
+ get payload() {
9
+ return this._payload;
10
+ }
11
+ get status() {
12
+ return this._status;
13
+ }
14
+ get message() {
15
+ return this._message;
16
+ }
17
+ }
18
+ function c(e, s, t = "") {
19
+ return new u(!0, e, s, t);
20
+ }
21
+ function n(e, s, t = "") {
22
+ return new u(!1, e, s, t);
23
+ }
24
+ export {
25
+ u as Result,
26
+ n as failureResult,
27
+ c as successResult
28
+ };
@@ -0,0 +1,67 @@
1
+ import { ConversionFactors as s } from "../../lib/EpigraphLibs/EpigraphUnitsConverter/conversions.js";
2
+ import { UnitTypes as o, DistanceUnits as t } from "../../lib/EpigraphLibs/EpigraphUnitsConverter/enums.js";
3
+ class e {
4
+ constructor(i, r) {
5
+ if (this._type = o.DISTANCE, this._rawValue = i, this._rawValueUnit = r, r !== t.meter) {
6
+ const n = e.convert(this._rawValue, r, t.meter);
7
+ this._rawValue = n.value, this._rawValueUnit = n.valueUnit;
8
+ }
9
+ }
10
+ get type() {
11
+ return this._type;
12
+ }
13
+ static buildConvertedUnitResult(i, r) {
14
+ return {
15
+ value: i,
16
+ valueUnit: r,
17
+ valueWithUnit: `${i.toFixed(2)}${r}`
18
+ };
19
+ }
20
+ static convert(i, r, n) {
21
+ let a = i, u = n;
22
+ if (r === n)
23
+ return e.buildConvertedUnitResult(a, u);
24
+ const l = s[`${r}-${n}`];
25
+ return a = i * l, e.buildConvertedUnitResult(a, u);
26
+ }
27
+ /** ----------------- METRIC UNITS ----------------- */
28
+ get inMillimeters() {
29
+ return e.convert(this._rawValue, this._rawValueUnit, t.millimeter);
30
+ }
31
+ get inCentimeters() {
32
+ return e.convert(this._rawValue, this._rawValueUnit, t.centimeter);
33
+ }
34
+ get inDecimeters() {
35
+ return e.convert(this._rawValue, this._rawValueUnit, t.decimeter);
36
+ }
37
+ get inMeters() {
38
+ return e.convert(this._rawValue, this._rawValueUnit, t.meter);
39
+ }
40
+ get inDecameters() {
41
+ return e.convert(this._rawValue, this._rawValueUnit, t.decameter);
42
+ }
43
+ get inHectometers() {
44
+ return e.convert(this._rawValue, this._rawValueUnit, t.hectometer);
45
+ }
46
+ get inKilometers() {
47
+ return e.convert(this._rawValue, this._rawValueUnit, t.kilometer);
48
+ }
49
+ /** ----------------- METRIC UNITS ----------------- */
50
+ get inInches() {
51
+ return e.convert(this._rawValue, this._rawValueUnit, t.inch);
52
+ }
53
+ get inFeet() {
54
+ return e.convert(this._rawValue, this._rawValueUnit, t.foot);
55
+ }
56
+ get inYard() {
57
+ return e.convert(this._rawValue, this._rawValueUnit, t.yard);
58
+ }
59
+ get inMiles() {
60
+ return e.convert(this._rawValue, this._rawValueUnit, t.mile);
61
+ }
62
+ }
63
+ export {
64
+ e as Distance,
65
+ t as DistanceUnits,
66
+ o as UnitTypes
67
+ };
@@ -8,7 +8,7 @@ export declare const enum QUERY_PARAMETER_NAMES {
8
8
  epigraphSessionId = "eid",
9
9
  action = "a"
10
10
  }
11
- export declare class UrlProcessor {
11
+ export declare class EpigraphUrlProcessor {
12
12
  private _baseUrl;
13
13
  constructor(baseUrl?: string);
14
14
  get baseUrl(): string;
@@ -0,0 +1,76 @@
1
+ var i = /* @__PURE__ */ ((r) => (r.AR = "ar", r))(i || {}), c = /* @__PURE__ */ ((r) => (r.type = "t", r.identifierType = "idt", r.identifier = "id", r.epigraphSessionId = "eid", r.action = "a", r))(c || {});
2
+ class l {
3
+ constructor(e = window.location.href) {
4
+ this._baseUrl = e;
5
+ }
6
+ get baseUrl() {
7
+ return this._baseUrl;
8
+ }
9
+ set baseUrl(e) {
10
+ this._baseUrl = e;
11
+ }
12
+ /**
13
+ * Gets the parameters from the baseUrl of this class instance.
14
+ * This handles both encrypted and decrypted URLs.
15
+ *
16
+ * @param {string} parameterToSearch Name of the parameter that needs to be queried from the current URL.
17
+ * @returns {string | null} Either the value of the parameterToSearch or null if not found.
18
+ */
19
+ getParameterInUrl(e) {
20
+ const a = new URL(this._baseUrl);
21
+ let t = a.searchParams.get(e);
22
+ return t || (t = this.decryptQueryParametersInUrl(a).searchParams.get(e)), t;
23
+ }
24
+ /**
25
+ * A convenience wrapper to test if the URL has a given parameter name in the query parameters.
26
+ * This handles both encrypted and decrypted URLs.
27
+ *
28
+ * @param {string} parameterToSearch Name of the parameter that needs to be queried from the current URL.
29
+ * @returns {boolean} Whether the parameter exists in the current URL.
30
+ */
31
+ hasParameterInUrl(e) {
32
+ return !!this.getParameterInUrl(e);
33
+ }
34
+ /**
35
+ * Generate the URL to be shown as View in your space QR code.
36
+ *
37
+ * @param {object} parametersToAdd Object containing <key>parameter_name: <value>parameter_value for the URL.
38
+ * @param {boolean} encryptParameters Whether the parameters be encrypted within the URL.
39
+ * @returns {URL} The generated URL.
40
+ */
41
+ generateQrCodeUrl(e = {}, a = !0) {
42
+ const t = new URL(this._baseUrl);
43
+ for (const [s, n] of Object.entries(e))
44
+ t.searchParams.set(s, n);
45
+ return a && this.encryptQueryParametersInUrl(t), t;
46
+ }
47
+ /**
48
+ * Encrypts the query parameters in a given URL object using base64 encoding.
49
+ *
50
+ * @param {URL} url The original url object with query parameters.
51
+ * @returns {URL} Process URL object with encrypted parameters
52
+ */
53
+ encryptQueryParametersInUrl(e) {
54
+ return e.search = btoa(e.search), e;
55
+ }
56
+ /**
57
+ * Decrypts the query parameters in a given URL object using base64 encoding.
58
+ *
59
+ * @param {URL} url The original url object with query parameters.
60
+ * @returns {URL} Process URL object with decrypted parameters
61
+ */
62
+ decryptQueryParametersInUrl(e) {
63
+ let a = e;
64
+ try {
65
+ e.search = atob(e.search.slice(1)), a = e;
66
+ } catch (t) {
67
+ window.epigraph.logger.info({ title: `Couldn't decode URL: ${e}`, details: t });
68
+ }
69
+ return a;
70
+ }
71
+ }
72
+ export {
73
+ l as EpigraphUrlProcessor,
74
+ i as QUERY_PARAMETER_ACTION_NAMES,
75
+ c as QUERY_PARAMETER_NAMES
76
+ };
@@ -1,3 +1 @@
1
- export * from './Epigraph/epigraph';
2
- export * from './EpigraphLibs/epigraphLibs';
3
- export * from './ThirdPartyLibs/thirdPartyLibs';
1
+ export {};