@wearejh/m2-pwa-engine 0.36.0 → 0.38.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.38.0](https://github.com/WeareJH/mage-mono/compare/v0.37.0...v0.38.0) (2025-11-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **m2-pwa-engine:** refine product page type detection to exclude category pages ([b102300](https://github.com/WeareJH/mage-mono/commit/b1023008b8aaebcb28f48cffd8c0d80e545befc9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **m2-pwa-engine:** add nosto anchor support for nosto OnSite campaign ([fcadb6e](https://github.com/WeareJH/mage-mono/commit/fcadb6e714effcf07598750eb1323e4553b534bf))
|
|
17
|
+
* **m2-pwa-engine:** export componentNameToPageType helper function ([c23d392](https://github.com/WeareJH/mage-mono/commit/c23d3920528e458fea7b870f1a459310f9b9024d))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [0.37.0](https://github.com/WeareJH/mage-mono/compare/v0.36.0...v0.37.0) (2025-09-09)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **m2-pwa-engine:** fix import reference to m2-pwa-vars (WOOD-2710) ([0228224](https://github.com/WeareJH/mage-mono/commit/022822473aa38ad29b508142d2449a1ae555aa79))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
# [0.36.0](https://github.com/WeareJH/mage-mono/compare/v0.35.0...v0.36.0) (2025-09-09)
|
|
7
35
|
|
|
8
36
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EMPTY, Observable, of } from 'rxjs';
|
|
2
2
|
import { ignoreElements, share, tap, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { Action } from 'redux';
|
|
4
|
-
import { ASSET_PREFIX } from 'm2-pwa-vars';
|
|
4
|
+
import { ASSET_PREFIX } from '@wearejh/m2-pwa-vars';
|
|
5
5
|
|
|
6
6
|
import { RuntimeActions, RuntimeMsg, RuntimeEnv } from '../runtime.register';
|
|
7
7
|
import { createDebug } from '../../utils/runtimeDebug';
|
|
@@ -24,7 +24,7 @@ exports[`inlineCriticalCss: false 1`] = `
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
</head>
|
|
27
|
-
<body>
|
|
27
|
+
<body data-nosto-anchor=\\"viewport\\" data-nosto-page-type=\\"home\\">
|
|
28
28
|
|
|
29
29
|
<div id=\\"root\\"><p>hello world</p></div>
|
|
30
30
|
<script type=\\"text/json\\" id=\\"apollo-client-state\\">{}</script>
|
|
@@ -71,7 +71,7 @@ exports[`inlineCriticalCss: true 1`] = `
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
</head>
|
|
74
|
-
<body>
|
|
74
|
+
<body data-nosto-anchor=\\"viewport\\" data-nosto-page-type=\\"home\\">
|
|
75
75
|
|
|
76
76
|
<div id=\\"root\\"><p>hello world</p></div>
|
|
77
77
|
<script type=\\"text/json\\" id=\\"apollo-client-state\\">{}</script>
|
|
@@ -118,7 +118,7 @@ exports[`timestamp: 123456 1`] = `
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
</head>
|
|
121
|
-
<body>
|
|
121
|
+
<body data-nosto-anchor=\\"viewport\\" data-nosto-page-type=\\"home\\">
|
|
122
122
|
|
|
123
123
|
<div id=\\"root\\"><p>hello world</p></div>
|
|
124
124
|
<script type=\\"text/json\\" id=\\"apollo-client-state\\">{}</script>
|
|
@@ -161,7 +161,7 @@ exports[`works with content 1`] = `
|
|
|
161
161
|
<script id=\\"modernizr\\">!function(e,n,t){function r(e,n){return typeof e===n}function o(){var e,n,t,o,s,i,l;for(var a in S)if(S.hasOwnProperty(a)){if(e=[],n=S[a],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;t<n.options.aliases.length;t++)e.push(n.options.aliases[t].toLowerCase());for(o=r(n.fn,\\"function\\")?n.fn():n.fn,s=0;s<e.length;s++)i=e[s],l=i.split(\\".\\"),1===l.length?Modernizr[l[0]]=o:(!Modernizr[l[0]]||Modernizr[l[0]]instanceof Boolean||(Modernizr[l[0]]=new Boolean(Modernizr[l[0]])),Modernizr[l[0]][l[1]]=o),C.push((o?\\"\\":\\"no-\\")+l.join(\\"-\\"))}}function s(e){var n=_.className,t=Modernizr._config.classPrefix||\\"\\";if(x&&(n=n.baseVal),Modernizr._config.enableJSClass){var r=new RegExp(\\"(^|\\\\\\\\s)\\"+t+\\"no-js(\\\\\\\\s|$)\\");n=n.replace(r,\\"$1\\"+t+\\"js$2\\")}Modernizr._config.enableClasses&&(n+=\\" \\"+t+e.join(\\" \\"+t),x?_.className.baseVal=n:_.className=n)}function i(e,n){return!!~(\\"\\"+e).indexOf(n)}function l(){return\\"function\\"!=typeof n.createElement?n.createElement(arguments[0]):x?n.createElementNS.call(n,\\"http://www.w3.org/2000/svg\\",arguments[0]):n.createElement.apply(n,arguments)}function a(e){return e.replace(/([a-z])-([a-z])/g,function(e,n,t){return n+t.toUpperCase()}).replace(/^-/,\\"\\")}function f(e,n){return function(){return e.apply(n,arguments)}}function u(e,n,t){var o;for(var s in e)if(e[s]in n)return t===!1?e[s]:(o=n[e[s]],r(o,\\"function\\")?f(o,t||n):o);return!1}function c(e){return e.replace(/([A-Z])/g,function(e,n){return\\"-\\"+n.toLowerCase()}).replace(/^ms-/,\\"-ms-\\")}function d(n,t,r){var o;if(\\"getComputedStyle\\"in e){o=getComputedStyle.call(e,n,t);var s=e.console;if(null!==o)r&&(o=o.getPropertyValue(r));else if(s){var i=s.error?\\"error\\":\\"log\\";s[i].call(s,\\"getComputedStyle returning null, its possible modernizr test results are inaccurate\\")}}else o=!t&&n.currentStyle&&n.currentStyle[r];return o}function p(){var e=n.body;return e||(e=l(x?\\"svg\\":\\"body\\"),e.fake=!0),e}function m(e,t,r,o){var s,i,a,f,u=\\"modernizr\\",c=l(\\"div\\"),d=p();if(parseInt(r,10))for(;r--;)a=l(\\"div\\"),a.id=o?o[r]:u+(r+1),c.appendChild(a);return s=l(\\"style\\"),s.type=\\"text/css\\",s.id=\\"s\\"+u,(d.fake?d:c).appendChild(s),d.appendChild(c),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(n.createTextNode(e)),c.id=u,d.fake&&(d.style.background=\\"\\",d.style.overflow=\\"hidden\\",f=_.style.overflow,_.style.overflow=\\"hidden\\",_.appendChild(d)),i=t(c,e),d.fake?(d.parentNode.removeChild(d),_.style.overflow=f,_.offsetHeight):c.parentNode.removeChild(c),!!i}function y(n,r){var o=n.length;if(\\"CSS\\"in e&&\\"supports\\"in e.CSS){for(;o--;)if(e.CSS.supports(c(n[o]),r))return!0;return!1}if(\\"CSSSupportsRule\\"in e){for(var s=[];o--;)s.push(\\"(\\"+c(n[o])+\\":\\"+r+\\")\\");return s=s.join(\\" or \\"),m(\\"@supports (\\"+s+\\") { #modernizr { position: absolute; } }\\",function(e){return\\"absolute\\"==d(e,null,\\"position\\")})}return t}function v(e,n,o,s){function f(){c&&(delete N.style,delete N.modElem)}if(s=r(s,\\"undefined\\")?!1:s,!r(o,\\"undefined\\")){var u=y(e,o);if(!r(u,\\"undefined\\"))return u}for(var c,d,p,m,v,g=[\\"modernizr\\",\\"tspan\\",\\"samp\\"];!N.style&&g.length;)c=!0,N.modElem=l(g.shift()),N.style=N.modElem.style;for(p=e.length,d=0;p>d;d++)if(m=e[d],v=N.style[m],i(m,\\"-\\")&&(m=a(m)),N.style[m]!==t){if(s||r(o,\\"undefined\\"))return f(),\\"pfx\\"==n?m:!0;try{N.style[m]=o}catch(h){}if(N.style[m]!=v)return f(),\\"pfx\\"==n?m:!0}return f(),!1}function g(e,n,t,o,s){var i=e.charAt(0).toUpperCase()+e.slice(1),l=(e+\\" \\"+P.join(i+\\" \\")+i).split(\\" \\");return r(n,\\"string\\")||r(n,\\"undefined\\")?v(l,n,o,s):(l=(e+\\" \\"+z.join(i+\\" \\")+i).split(\\" \\"),u(l,n,t))}function h(e,n,r){return g(e,t,t,n,r)}var C=[],S=[],w={_version:\\"3.6.0\\",_config:{classPrefix:\\"\\",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){S.push({name:e,fn:n,options:t})},addAsyncTest:function(e){S.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=w,Modernizr=new Modernizr;var _=n.documentElement,x=\\"svg\\"===_.nodeName.toLowerCase(),b=\\"Moz O ms Webkit\\",P=w._config.usePrefixes?b.split(\\" \\"):[];w._cssomPrefixes=P;var z=w._config.usePrefixes?b.toLowerCase().split(\\" \\"):[];w._domPrefixes=z;var E={elem:l(\\"modernizr\\")};Modernizr._q.push(function(){delete E.elem});var N={style:E.elem.style};Modernizr._q.unshift(function(){delete N.style}),w.testAllProps=g,w.testAllProps=h,Modernizr.addTest(\\"flexboxlegacy\\",h(\\"boxDirection\\",\\"reverse\\",!0)),o(),s(C),delete w.addTest,delete w.addAsyncTest;for(var T=0;T<Modernizr._q.length;T++)Modernizr._q[T]();e.Modernizr=Modernizr}(window,document);</script>
|
|
162
162
|
|
|
163
163
|
</head>
|
|
164
|
-
<body>
|
|
164
|
+
<body data-nosto-anchor=\\"viewport\\" data-nosto-page-type=\\"unknown\\">
|
|
165
165
|
|
|
166
166
|
<div id=\\"root\\"><p>Hello world!</p></div>
|
|
167
167
|
<script type=\\"text/json\\" id=\\"apollo-client-state\\">{}</script>
|
|
@@ -12,6 +12,39 @@ import { assetsToUrls, getAssetsForType, getJsEntryPointFilePaths, Stats } from
|
|
|
12
12
|
import { SsrResult } from './ssrMiddleware';
|
|
13
13
|
import { reduxState as renderReduxState } from './templates/reduxState';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Maps component names to Nosto page types for campaign targeting.
|
|
17
|
+
* Exported so it can be used both server-side and client-side.
|
|
18
|
+
*/
|
|
19
|
+
export function componentNameToPageType(componentName: string): string {
|
|
20
|
+
const lowerName = componentName.toLowerCase();
|
|
21
|
+
|
|
22
|
+
switch (lowerName) {
|
|
23
|
+
case 'basket':
|
|
24
|
+
return 'cart';
|
|
25
|
+
|
|
26
|
+
case 'category':
|
|
27
|
+
case 'categoryproductlist':
|
|
28
|
+
return 'category';
|
|
29
|
+
|
|
30
|
+
case 'product':
|
|
31
|
+
case 'simpleproduct':
|
|
32
|
+
case 'configurableproduct':
|
|
33
|
+
return 'product';
|
|
34
|
+
|
|
35
|
+
case 'catalogsearch':
|
|
36
|
+
return 'search';
|
|
37
|
+
|
|
38
|
+
case 'cmspage':
|
|
39
|
+
return 'cms';
|
|
40
|
+
|
|
41
|
+
default:
|
|
42
|
+
// For other known pages (home, checkout, customer, notfound) or unknown pages,
|
|
43
|
+
// return the component name as-is (lowercase)
|
|
44
|
+
return lowerName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
15
48
|
type HtmlProps = {
|
|
16
49
|
content?: string;
|
|
17
50
|
state?: any;
|
|
@@ -32,6 +65,7 @@ type HtmlProps = {
|
|
|
32
65
|
lang?: string;
|
|
33
66
|
runtimeEnv?: RuntimeEnv;
|
|
34
67
|
ie11?: boolean;
|
|
68
|
+
componentName?: string;
|
|
35
69
|
};
|
|
36
70
|
|
|
37
71
|
export function renderShell(props: HtmlProps) {
|
|
@@ -53,8 +87,12 @@ export function renderShell(props: HtmlProps) {
|
|
|
53
87
|
lang = 'en',
|
|
54
88
|
runtimeEnv,
|
|
55
89
|
ie11 = true,
|
|
90
|
+
componentName,
|
|
56
91
|
} = props;
|
|
92
|
+
|
|
57
93
|
const { modules, nomodules, prefix, preloads } = fsFiles(js, legacyJs);
|
|
94
|
+
const pageType = componentName ? componentNameToPageType(componentName) : 'unknown';
|
|
95
|
+
|
|
58
96
|
return `
|
|
59
97
|
<html lang="${lang}">
|
|
60
98
|
<head>
|
|
@@ -69,7 +107,7 @@ export function renderShell(props: HtmlProps) {
|
|
|
69
107
|
${ie11 ? MODERNIZR : ''}
|
|
70
108
|
${beforeHeadEnd}
|
|
71
109
|
</head>
|
|
72
|
-
<body>
|
|
110
|
+
<body data-nosto-anchor="viewport" data-nosto-page-type="${pageType}">
|
|
73
111
|
${afterBodyStart}
|
|
74
112
|
<div id="root">${content}</div>
|
|
75
113
|
${gqlState(state)}
|
|
@@ -157,6 +195,7 @@ export function fromResult(input: InputParams): (result: SsrResult) => string {
|
|
|
157
195
|
version,
|
|
158
196
|
runtimeEnv,
|
|
159
197
|
ie11,
|
|
198
|
+
componentName: resolvedUrl.componentName,
|
|
160
199
|
});
|
|
161
200
|
return output;
|
|
162
201
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wearejh/m2-pwa-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Shane Osbourne <shane.osbourne8@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@wearejh/m2-pwa-vars": "^0.
|
|
22
|
-
"@wearejh/swagger-rxjs": "^0.
|
|
21
|
+
"@wearejh/m2-pwa-vars": "^0.38.0",
|
|
22
|
+
"@wearejh/swagger-rxjs": "^0.38.0",
|
|
23
23
|
"history": "^4.10.1",
|
|
24
24
|
"loadcss": "^0.0.2"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "2aecacf8dcc26e0ee50f89b49704f9f4ec1ae1b6"
|
|
27
27
|
}
|