@griddo/cx 10.4.28 → 10.4.30

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/src/utils.ts CHANGED
@@ -7,13 +7,12 @@
7
7
  //
8
8
  // NOTE: Browserify doesn't work with the mixture of typescript + webpack 5 + SSR
9
9
 
10
- import type { Dimensions } from "./types";
11
10
  import type { Fields } from "@griddo/core";
12
11
 
13
12
  /**
14
13
  * Sanitize a string separated by commas.
15
14
  */
16
- export function cleanCommaSeparated(str: string) {
15
+ function cleanCommaSeparated(str: string) {
17
16
  return str
18
17
  .split(",")
19
18
  .map((item) => item.trim())
@@ -30,7 +29,7 @@ export function cleanCommaSeparated(str: string) {
30
29
  * @param format Format of the image
31
30
  * @returns A composed URL for the Cloudinary or DAM service
32
31
  */
33
- export function formatImage(
32
+ function formatImage(
34
33
  image: Fields.Image | string,
35
34
  width: number,
36
35
  height: number,
@@ -71,72 +70,4 @@ function addCloudinaryParams(image: string, params: string) {
71
70
  return `https://${head}/${params}${fullId}`;
72
71
  }
73
72
 
74
- /**
75
- * TODO: JSDoc
76
- */
77
- export function composeAnalytics(
78
- page: {
79
- pageContext: {
80
- siteScript: string;
81
- page: {
82
- dimensions: Dimensions;
83
- };
84
- };
85
- },
86
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
- generateAutomaticDimensions = (page: Record<string, unknown>) => null
88
- ) {
89
- const {
90
- pageContext: {
91
- siteScript: siteScriptBulk,
92
- page: { dimensions },
93
- },
94
- } = page;
95
-
96
- const analyticsScript = siteScriptBulk ? siteScriptBulk.trim() : "";
97
-
98
- // Las dimensiones o DataLayer
99
- const dynamicValuePrefix = "__SCRIPT:";
100
- const dimensionValues = isObject(dimensions?.values)
101
- ? dimensions?.values
102
- : {};
103
- const automaticDimensionValues = generateAutomaticDimensions
104
- ? generateAutomaticDimensions(page)
105
- : {};
106
- const allDimensionsValues = {
107
- ...dimensionValues,
108
- ...automaticDimensionValues,
109
- } as Record<string, string>;
110
-
111
- const allDimensions = [];
112
-
113
- for (const dimension of Object.keys(allDimensionsValues)) {
114
- const dimensionValue = allDimensionsValues[dimension];
115
- allDimensions.push(
116
- `"${dimension}":${
117
- dimensionValue?.startsWith(dynamicValuePrefix)
118
- ? `${dimensionValue.slice(
119
- dynamicValuePrefix.length,
120
- dimensionValue.endsWith(";") ? -1 : dimensionValue.length
121
- )}`
122
- : `"${dimensionValue}"`
123
- }`
124
- );
125
- }
126
-
127
- const analyticsDimensions = allDimensions.length
128
- ? `{${allDimensions.join(",")}}`
129
- : null;
130
-
131
- return {
132
- analyticsScript,
133
- analyticsDimensions,
134
- };
135
- }
136
-
137
- /**
138
- * Return true if the argument is an object (not null)
139
- */
140
- export function isObject(value: unknown) {
141
- return typeof value === "object" && value !== null && !Array.isArray(value);
142
- }
73
+ export { cleanCommaSeparated, formatImage };
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- declare function Foo(): JSX.Element;
3
- export default Foo;
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
-
3
- function Foo() {
4
- return <div>React</div>;
5
- }
6
-
7
- export default Foo;