@griddo/cx 1.62.2 → 1.62.5

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/gatsby-browser.js CHANGED
@@ -1,153 +1,111 @@
1
- /* eslint-disable node/no-unpublished-require */
2
1
  /* eslint-disable node/no-missing-require */
3
2
 
4
- let builderBrowserConfig;
5
-
6
- // Intance Gatsby Browser configuration file
7
- // Se intenta hacer require del archivo builder.config que solo está en la
8
- // instancia. De no existir, se avisa por consola.
9
- // TODO: Añadir un método infalible para saber si es monorepo o instancia.
10
- try {
11
- builderBrowserConfig = require('../../../builder.browser');
12
- console.log('Instance build.config loaded');
13
- } catch (e) {
14
- builderBrowserConfig = require('../griddo-components/builder.browser');
15
- console.warn('Loading builder.config from Griddo monorepo');
16
- }
17
-
18
- // Gatsby API Browser
19
- // Si builderBrowserConfig.* es "truthy" es que `builderBrowserConfig` no es `undefined`, es decir se
20
- // está ejecutando en la instancia y * está definido en el archivo de la
21
- // instancia para ejecutar código.
3
+ const { browser } = require('components');
22
4
 
23
5
  exports.disableCorePrefetching = () => {
24
- if (builderBrowserConfig.disableCorePrefetching) {
25
- builderBrowserConfig.disableCorePrefetching();
6
+ if (browser.disableCorePrefetching) {
7
+ browser.disableCorePrefetching();
26
8
  }
27
9
  };
28
10
 
29
11
  exports.onClientEntry = () => {
30
- if (builderBrowserConfig.onClientEntry) {
31
- builderBrowserConfig.onClientEntry();
12
+ if (browser.onClientEntry) {
13
+ browser.onClientEntry();
32
14
  }
33
15
  };
34
16
 
35
17
  exports.onInitialClientRender = () => {
36
- if (builderBrowserConfig.onInitialClientRender) {
37
- builderBrowserConfig.onInitialClientRender();
18
+ if (browser.onInitialClientRender) {
19
+ browser.onInitialClientRender();
38
20
  }
39
21
  };
40
22
 
41
23
  exports.onPostPrefetchPathname = props => {
42
- if (builderBrowserConfig.onPostPrefetchPathname) {
43
- builderBrowserConfig.onPostPrefetchPathname(props);
24
+ if (browser.onPostPrefetchPathname) {
25
+ browser.onPostPrefetchPathname(props);
44
26
  }
45
27
  };
46
28
 
47
29
  exports.onPreRouteUpdate = props => {
48
- if (builderBrowserConfig.onPreRouteUpdate) {
49
- builderBrowserConfig.onPreRouteUpdate(props);
30
+ if (browser.onPreRouteUpdate) {
31
+ browser.onPreRouteUpdate(props);
50
32
  }
51
33
  };
52
34
 
53
35
  exports.onPrefetchPathname = props => {
54
- if (builderBrowserConfig.onPrefetchPathname) {
55
- builderBrowserConfig.onPrefetchPathname(props);
36
+ if (browser.onPrefetchPathname) {
37
+ browser.onPrefetchPathname(props);
56
38
  }
57
39
  };
58
40
 
59
41
  exports.onRouteUpdateDelayed = props => {
60
- if (builderBrowserConfig.onServiceWorkerActive) {
61
- builderBrowserConfig.onRouteUpdateDelayed(props);
42
+ if (browser.onServiceWorkerActive) {
43
+ browser.onRouteUpdateDelayed(props);
62
44
  }
63
45
  };
64
46
 
65
47
  exports.onServiceWorkerActive = props => {
66
- if (builderBrowserConfig.onServiceWorkerActive) {
67
- builderBrowserConfig.onServiceWorkerActive(props);
48
+ if (browser.onServiceWorkerActive) {
49
+ browser.onServiceWorkerActive(props);
68
50
  }
69
51
  };
70
52
 
71
53
  exports.onServiceWorkerInstalled = props => {
72
- if (builderBrowserConfig.onServiceWorkerInstalled) {
73
- builderBrowserConfig.onServiceWorkerInstalled(props);
54
+ if (browser.onServiceWorkerInstalled) {
55
+ browser.onServiceWorkerInstalled(props);
74
56
  }
75
57
  };
76
58
 
77
59
  exports.onServiceWorkerRedundant = props => {
78
- if (builderBrowserConfig.onServiceWorkerRedundant) {
79
- builderBrowserConfig.onServiceWorkerRedundant(props);
60
+ if (browser.onServiceWorkerRedundant) {
61
+ browser.onServiceWorkerRedundant(props);
80
62
  }
81
63
  };
82
64
 
83
65
  exports.onServiceWorkerUpdateFound = props => {
84
- if (builderBrowserConfig.onServiceWorkerUpdateFound) {
85
- builderBrowserConfig.onServiceWorkerUpdateFound(props);
66
+ if (browser.onServiceWorkerUpdateFound) {
67
+ browser.onServiceWorkerUpdateFound(props);
86
68
  }
87
69
  };
88
70
 
89
71
  exports.onServiceWorkerUpdateReady = props => {
90
- if (builderBrowserConfig.onServiceWorkerUpdateReady) {
91
- builderBrowserConfig.onServiceWorkerUpdateReady(props);
72
+ if (browser.onServiceWorkerUpdateReady) {
73
+ browser.onServiceWorkerUpdateReady(props);
92
74
  }
93
75
  };
94
76
 
95
77
  exports.registerServiceWorker = () => {
96
- if (builderBrowserConfig.registerServiceWorker) {
97
- builderBrowserConfig.registerServiceWorker();
78
+ if (browser.registerServiceWorker) {
79
+ browser.registerServiceWorker();
98
80
  }
99
81
  };
100
82
 
101
83
  exports.replaceHydrateFunction = () => {
102
- if (builderBrowserConfig.replaceHydrateFunction) {
103
- builderBrowserConfig.replaceHydrateFunction();
84
+ if (browser.replaceHydrateFunction) {
85
+ browser.replaceHydrateFunction();
104
86
  }
105
87
  };
106
88
 
107
89
  exports.shouldUpdateScroll = props => {
108
- if (builderBrowserConfig.shouldUpdateScroll) {
109
- builderBrowserConfig.shouldUpdateScroll(props);
90
+ if (browser.shouldUpdateScroll) {
91
+ browser.shouldUpdateScroll(props);
110
92
  }
111
93
  };
112
94
 
113
95
  exports.wrapRootElement = props => {
114
- if (builderBrowserConfig.wrapPageElement) {
115
- return builderBrowserConfig.wrapRootElement(props);
96
+ if (browser.wrapPageElement) {
97
+ return browser.wrapRootElement(props);
116
98
  }
117
99
  };
118
100
 
119
101
  exports.wrapRootElement = props => {
120
- if (builderBrowserConfig.wrapRootElement) {
121
- return builderBrowserConfig.wrapRootElement(props);
102
+ if (browser.wrapRootElement) {
103
+ return browser.wrapRootElement(props);
122
104
  }
123
105
  };
124
106
 
125
107
  exports.onRouteUpdate = props => {
126
- // Instance onRouteUpdate
127
- if (builderBrowserConfig.onRouteUpdate) {
128
- builderBrowserConfig.onRouteUpdate(props);
129
- }
130
-
131
- // Griddo onRouteUpdate
132
- if (!window || !document || !location || !location.hash) return;
133
-
134
- const headerHeight =
135
- document.querySelector('.griddo-header')?.offsetHeight || 0;
136
- if (location.hash !== '') {
137
- window.scrollTo({
138
- left: 0,
139
- top: getOffset(location.hash).top - headerHeight,
140
- behavior: 'smooth',
141
- });
108
+ if (browser.onRouteUpdate) {
109
+ browser.onRouteUpdate(props);
142
110
  }
143
111
  };
144
-
145
- // Functions
146
-
147
- function getOffset(el) {
148
- const rect = document?.querySelector(el)?.getBoundingClientRect();
149
- return {
150
- left: rect?.left + window?.scrollX,
151
- top: rect?.top + window?.scrollY,
152
- };
153
- }
package/gatsby-config.js CHANGED
@@ -4,13 +4,14 @@ require('dotenv').config();
4
4
 
5
5
  const assetPrefix = process.env.ASSET_PREFIX || undefined;
6
6
 
7
- // Gatsby plugins configuration file from client
8
- // TODO: Filter the configuration to allow just supported plugins?
9
- const { plugins } = require(computils.resolveComponentsPath(
7
+ // Gatsby configuration file from client
8
+ const { plugins, ...gatsbyConfig } = require(computils.resolveComponentsPath(
10
9
  'builder.config.js'
11
10
  ));
12
11
 
13
12
  const CONFIG = {
13
+ // cliente config
14
+ ...gatsbyConfig,
14
15
  plugins: [
15
16
  // client plugins
16
17
  ...plugins,
package/gatsby-ssr.js CHANGED
@@ -1,50 +1,33 @@
1
- /* eslint-disable node/no-unpublished-require */
2
1
  /* eslint-disable node/no-missing-require */
3
2
 
4
- let builderSSRConfig;
3
+ const { ssr } = require('components');
5
4
 
6
- // Intance Gatsby Browser configuration file
7
- // Se intenta hacer require del archivo builder.config que solo está en la
8
- // instancia. De no existir, se avisa por consola.
9
- // TODO: Añadir un método infalible para saber si es monorepo o instancia.
10
- try {
11
- builderSSRConfig = require('../../../builder.ssr');
12
- console.log('Instance build.ssr loaded');
13
- } catch (e) {
14
- builderSSRConfig = require('../griddo-components/builder.ssr');
15
- console.warn('Loading builder.ssr from Griddo monorepo');
16
- }
17
-
18
- // Gatsby SSR Browser
19
- // Si builderSSRConfig.* es "truthy" es que `builderSSRConfig` no es `undefined`, es decir se
20
- // está ejecutando en la instancia y * está definido en el archivo de la
21
- // instancia para ejecutar código.
22
5
  exports.onRenderBody = props => {
23
- if (builderSSRConfig.onRenderBody) {
24
- builderSSRConfig.onRenderBody(props);
6
+ if (ssr.onRenderBody) {
7
+ ssr.onRenderBody(props);
25
8
  }
26
9
  };
27
10
 
28
11
  exports.onPreRenderHTML = props => {
29
- if (builderSSRConfig.onPreRenderHTML) {
30
- builderSSRConfig.onPreRenderHTML(props);
12
+ if (ssr.onPreRenderHTML) {
13
+ ssr.onPreRenderHTML(props);
31
14
  }
32
15
  };
33
16
 
34
17
  exports.replaceRenderer = props => {
35
- if (builderSSRConfig.replaceRenderer) {
36
- builderSSRConfig.replaceRenderer(props);
18
+ if (ssr.replaceRenderer) {
19
+ ssr.replaceRenderer(props);
37
20
  }
38
21
  };
39
22
 
40
23
  exports.wrapPageElement = props => {
41
- if (builderSSRConfig.wrapPageElement) {
42
- return builderSSRConfig.wrapPageElement(props);
24
+ if (ssr.wrapPageElement) {
25
+ return ssr.wrapPageElement(props);
43
26
  }
44
27
  };
45
28
 
46
29
  exports.wrapRootElement = props => {
47
- if (builderSSRConfig.wrapRootElement) {
48
- return builderSSRConfig.wrapRootElement(props);
30
+ if (ssr.wrapRootElement) {
31
+ return ssr.wrapRootElement(props);
49
32
  }
50
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "1.62.2",
4
+ "version": "1.62.5",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -66,7 +66,7 @@
66
66
  "react-helmet": "^6.0.0"
67
67
  },
68
68
  "devDependencies": {
69
- "@griddo/eslint-config-back": "^1.62.2",
69
+ "@griddo/eslint-config-back": "^1.62.5",
70
70
  "eslint": "^7.5.0",
71
71
  "eslint-plugin-node": "^11.1.0",
72
72
  "eslint-plugin-react": "7.14.3",
@@ -98,5 +98,5 @@
98
98
  "publishConfig": {
99
99
  "access": "public"
100
100
  },
101
- "gitHead": "df32ddb1e4be034954e3f1f8af032af0e56453c6"
101
+ "gitHead": "d4be19767faaf8863532465cf19844f17ef38bcc"
102
102
  }