@nosto/nosto-react 1.0.0 → 2.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/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(C,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react","react-dom/client"],h):(C=typeof globalThis<"u"?globalThis:C||self,h(C["@nosto/nosto-react"]={},C.React,C.ReactDOM))})(this,function(C,h,He){"use strict";const ne=h.createContext({account:"",currentVariation:"",pageType:"",responseMode:"HTML",clientScriptLoaded:!1,useRenderCampaigns:()=>({renderCampaigns:()=>{},pageTypeUpdated:!1})});function x(){const n=h.useContext(ne);if(!n)throw new Error("No nosto context found");return n}const ge=n=>String(n)==="[object Object]";function ye(n){if(!ge(n))return!1;const o=n.constructor;if(o===void 0)return!0;const a=o.prototype;return!(!ge(a)||!a.hasOwnProperty("isPrototypeOf"))}function oe(n,o){if(n===o)return!0;if(n instanceof Date&&o instanceof Date)return n.getTime()===o.getTime();if(n instanceof Array&&o instanceof Array)return n.length!==o.length?!1:n.every((a,u)=>oe(a,o[u]));if(ye(n)&&ye(o)){const a=Object.entries(n);return a.length!==Object.keys(o).length?!1:a.every(([u,d])=>oe(d,o[u]))}return!1}function he(n,o){return h.useEffect(n,Je(o))}function Je(n){const o=h.useRef(n),a=h.useRef(0);return oe(n,o.current)||(o.current=n,a.current+=1),h.useMemo(()=>o.current,[a.current])}function L(n,o,a){const{clientScriptLoaded:u,currentVariation:d,responseMode:c}=x();(a!=null&&a.deep?he:h.useEffect)(()=>{u&&window.nostojs(p=>{p.defaultSession().setVariation(d).setResponseMode(c),n(p)})},[u,d,c,...o??[]])}function ze(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("404");return L(async c=>{const i=await c.defaultSession().viewNotFound().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Ge(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("other");return L(async c=>{const i=await c.defaultSession().viewOther().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Ke(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("checkout");return L(async c=>{const i=await c.defaultSession().viewCart().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Xe(n){const{product:o,tagging:a,placements:u}=n,{recommendationComponent:d,useRenderCampaigns:c}=x(),{renderCampaigns:i,pageTypeUpdated:p}=c("product");return L(async v=>{const N=await v.defaultSession().viewProduct(a??o).setPlacements(u||v.placements.getPlacements()).load();i(N,v)},[o,d,p],{deep:!0}),null}function Ze(n){const{category:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("home");return L(async p=>{const v=await p.defaultSession().viewCategory(o).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[o,u,i]),null}function Qe(n){const{query:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("search");return L(async p=>{const v=await p.defaultSession().viewSearch(o).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[o,u,i]),null}function M(n){return!n||typeof n!="object"||et(n)||tt(n)?n:Array.isArray(n)?n.map(M):Object.keys(n).reduce((o,a)=>{const u=a[0].toLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(d,c)=>"_"+c.toLowerCase());return o[u]=M(n[a]),o},{})}function et(n){return Object.prototype.toString.call(n)==="[object Date]"}function tt(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function rt(n){const{order:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("order");return L(async p=>{const v=await p.defaultSession().addOrder(M(o)).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[u,i]),null}function nt(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("home");return L(async c=>{const i=await c.defaultSession().viewFrontPage().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}var ae={exports:{}},q={};/**
1
+ (function(h,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react","react-dom/client"],w):(h=typeof globalThis<"u"?globalThis:h||self,w(h["@nosto/nosto-react"]={},h.React,h.ReactDOM))})(this,function(h,w,Me){"use strict";const ue=r=>String(r)==="[object Object]";function le(r){if(!ue(r))return!1;const n=r.constructor;if(n===void 0)return!0;const a=n.prototype;return!(!ue(a)||!a.hasOwnProperty("isPrototypeOf"))}function Z(r,n){if(r===n)return!0;if(r instanceof Date&&n instanceof Date)return r.getTime()===n.getTime();if(r instanceof Array&&n instanceof Array)return r.length!==n.length?!1:r.every((a,c)=>Z(a,n[c]));if(le(r)&&le(n)){const a=Object.entries(r);return a.length!==Object.keys(n).length?!1:a.every(([c,i])=>Z(i,n[c]))}return!1}function fe(r,n){return w.useEffect(r,We(n))}function We(r){const n=w.useRef(r),a=w.useRef(0);return Z(r,n.current)||(n.current=r,a.current+=1),w.useMemo(()=>n.current,[a.current])}const Q=w.createContext({account:"",currentVariation:"",responseMode:"HTML",clientScriptLoaded:!1});function H(){return w.useContext(Q)}function k(r,n,a){const{clientScriptLoaded:c,currentVariation:i,responseMode:m}=H();(a!=null&&a.deep?fe:w.useEffect)(()=>{c&&window.nostojs(p=>{p.defaultSession().setVariation(i).setResponseMode(m),r(p)})},[c,i,m,...n??[]])}var ee={exports:{}},M={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ee;function ot(){if(Ee)return q;Ee=1;var n=h,o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,d=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function i(p,v,N){var _,S={},k=null,I=null;N!==void 0&&(k=""+N),v.key!==void 0&&(k=""+v.key),v.ref!==void 0&&(I=v.ref);for(_ in v)u.call(v,_)&&!c.hasOwnProperty(_)&&(S[_]=v[_]);if(p&&p.defaultProps)for(_ in v=p.defaultProps,v)S[_]===void 0&&(S[_]=v[_]);return{$$typeof:o,type:p,key:k,ref:I,props:S,_owner:d.current}}return q.Fragment=a,q.jsx=i,q.jsxs=i,q}var B={};/**
9
+ */var de;function Ve(){if(de)return M;de=1;var r=w,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function R(p,g,O){var b,f={},P=null,j=null;O!==void 0&&(P=""+O),g.key!==void 0&&(P=""+g.key),g.ref!==void 0&&(j=g.ref);for(b in g)c.call(g,b)&&!m.hasOwnProperty(b)&&(f[b]=g[b]);if(p&&p.defaultProps)for(b in g=p.defaultProps,g)f[b]===void 0&&(f[b]=g[b]);return{$$typeof:n,type:p,key:P,ref:j,props:f,_owner:i.current}}return M.Fragment=a,M.jsx=R,M.jsxs=R,M}var W={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,12 +14,12 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Ce;function at(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var n=h,o=Symbol.for("react.element"),a=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),p=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),G=Symbol.iterator,se="@@iterator";function A(e){if(e===null||typeof e!="object")return null;var t=G&&e[G]||e[se];return typeof t=="function"?t:null}var T=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];y("error",e,r)}}function y(e,t,r){{var s=T.ReactDebugCurrentFrame,m=s.getStackAddendum();m!==""&&(t+="%s",r=r.concat([m]));var g=r.map(function(f){return String(f)});g.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,g)}}var P=!1,O=!1,$=!1,U=!1,ie=!1,K;K=Symbol.for("react.module.reference");function X(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===c||ie||e===d||e===N||e===_||U||e===I||P||O||$||typeof e=="object"&&e!==null&&(e.$$typeof===k||e.$$typeof===S||e.$$typeof===i||e.$$typeof===p||e.$$typeof===v||e.$$typeof===K||e.getModuleId!==void 0))}function be(e,t,r){var s=e.displayName;if(s)return s;var m=t.displayName||t.name||"";return m!==""?r+"("+m+")":r}function _e(e){return e.displayName||"Context"}function D(e){if(e==null)return null;if(typeof e.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case a:return"Portal";case c:return"Profiler";case d:return"StrictMode";case N:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return _e(t)+".Consumer";case i:var r=e;return _e(r._context)+".Provider";case v:return be(e,e.render,"ForwardRef");case S:var s=e.displayName||null;return s!==null?s:D(e.type)||"Memo";case k:{var m=e,g=m._payload,f=m._init;try{return D(f(g))}catch{return null}}}return null}var W=Object.assign,H=0,we,Te,Se,Pe,Oe,je,xe;function Ne(){}Ne.__reactDisabledLog=!0;function lt(){{if(H===0){we=console.log,Te=console.info,Se=console.warn,Pe=console.error,Oe=console.group,je=console.groupCollapsed,xe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}H++}}function ft(){{if(H--,H===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:we}),info:W({},e,{value:Te}),warn:W({},e,{value:Se}),error:W({},e,{value:Pe}),group:W({},e,{value:Oe}),groupCollapsed:W({},e,{value:je}),groupEnd:W({},e,{value:xe})})}H<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=T.ReactCurrentDispatcher,ue;function Z(e,t,r){{if(ue===void 0)try{throw Error()}catch(m){var s=m.stack.trim().match(/\n( *(at )?)/);ue=s&&s[1]||""}return`
18
- `+ue+e}}var le=!1,Q;{var dt=typeof WeakMap=="function"?WeakMap:Map;Q=new dt}function Ae(e,t){if(!e||le)return"";{var r=Q.get(e);if(r!==void 0)return r}var s;le=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var g;g=ce.current,ce.current=null,lt();try{if(t){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(F){s=F}Reflect.construct(e,[],f)}else{try{f.call()}catch(F){s=F}e.call(f.prototype)}}else{try{throw Error()}catch(F){s=F}e()}}catch(F){if(F&&s&&typeof F.stack=="string"){for(var l=F.stack.split(`
19
- `),w=s.stack.split(`
20
- `),E=l.length-1,b=w.length-1;E>=1&&b>=0&&l[E]!==w[b];)b--;for(;E>=1&&b>=0;E--,b--)if(l[E]!==w[b]){if(E!==1||b!==1)do if(E--,b--,b<0||l[E]!==w[b]){var j=`
21
- `+l[E].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&Q.set(e,j),j}while(E>=1&&b>=0);break}}}finally{le=!1,ce.current=g,ft(),Error.prepareStackTrace=m}var Y=e?e.displayName||e.name:"",Be=Y?Z(Y):"";return typeof e=="function"&&Q.set(e,Be),Be}function mt(e,t,r){return Ae(e,!1)}function pt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ee(e,t,r){if(e==null)return"";if(typeof e=="function")return Ae(e,pt(e));if(typeof e=="string")return Z(e);switch(e){case N:return Z("Suspense");case _:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return mt(e.render);case S:return ee(e.type,t,r);case k:{var s=e,m=s._payload,g=s._init;try{return ee(g(m),t,r)}catch{}}}return""}var te=Object.prototype.hasOwnProperty,ke={},De=T.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=ee(e.type,e._source,t?t.type:null);De.setExtraStackFrame(r)}else De.setExtraStackFrame(null)}function vt(e,t,r,s,m){{var g=Function.call.bind(te);for(var f in e)if(g(e,f)){var l=void 0;try{if(typeof e[f]!="function"){var w=Error((s||"React class")+": "+r+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}l=e[f](t,f,s,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){l=E}l&&!(l instanceof Error)&&(re(m),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,f,typeof l),re(null)),l instanceof Error&&!(l.message in ke)&&(ke[l.message]=!0,re(m),R("Failed %s type: %s",r,l.message),re(null))}}}var gt=Array.isArray;function fe(e){return gt(e)}function yt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function ht(e){try{return Fe(e),!1}catch{return!0}}function Fe(e){return""+e}function Le(e){if(ht(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yt(e)),Fe(e)}var J=T.ReactCurrentOwner,Et={key:!0,ref:!0,__self:!0,__source:!0},Ie,$e,de;de={};function Ct(e){if(te.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Rt(e){if(te.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function bt(e,t){if(typeof e.ref=="string"&&J.current&&t&&J.current.stateNode!==t){var r=D(J.current.type);de[r]||(R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',D(J.current.type),e.ref),de[r]=!0)}}function _t(e,t){{var r=function(){Ie||(Ie=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function wt(e,t){{var r=function(){$e||($e=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var Tt=function(e,t,r,s,m,g,f){var l={$$typeof:o,type:e,key:t,ref:r,props:f,_owner:g};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function St(e,t,r,s,m){{var g,f={},l=null,w=null;r!==void 0&&(Le(r),l=""+r),Rt(t)&&(Le(t.key),l=""+t.key),Ct(t)&&(w=t.ref,bt(t,m));for(g in t)te.call(t,g)&&!Et.hasOwnProperty(g)&&(f[g]=t[g]);if(e&&e.defaultProps){var E=e.defaultProps;for(g in E)f[g]===void 0&&(f[g]=E[g])}if(l||w){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&_t(f,b),w&&wt(f,b)}return Tt(e,l,w,m,s,J.current,f)}}var me=T.ReactCurrentOwner,Ue=T.ReactDebugCurrentFrame;function V(e){if(e){var t=e._owner,r=ee(e.type,e._source,t?t.type:null);Ue.setExtraStackFrame(r)}else Ue.setExtraStackFrame(null)}var pe;pe=!1;function ve(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function We(){{if(me.current){var e=D(me.current.type);if(e)return`
17
+ */var me;function Ye(){return me||(me=1,process.env.NODE_ENV!=="production"&&function(){var r=w,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),p=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),F=Symbol.iterator,z="@@iterator";function J(e){if(e===null||typeof e!="object")return null;var t=F&&e[F]||e[z];return typeof t=="function"?t:null}var T=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(e){{for(var t=arguments.length,o=new Array(t>1?t-1:0),s=1;s<t;s++)o[s-1]=arguments[s];it("error",e,o)}}function it(e,t,o){{var s=T.ReactDebugCurrentFrame,d=s.getStackAddendum();d!==""&&(t+="%s",o=o.concat([d]));var v=o.map(function(l){return String(l)});v.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,v)}}var st=!1,ct=!1,ut=!1,lt=!1,ft=!1,ve;ve=Symbol.for("react.module.reference");function dt(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===m||ft||e===i||e===O||e===b||lt||e===j||st||ct||ut||typeof e=="object"&&e!==null&&(e.$$typeof===P||e.$$typeof===f||e.$$typeof===R||e.$$typeof===p||e.$$typeof===g||e.$$typeof===ve||e.getModuleId!==void 0))}function mt(e,t,o){var s=e.displayName;if(s)return s;var d=t.displayName||t.name||"";return d!==""?o+"("+d+")":o}function pe(e){return e.displayName||"Context"}function N(e){if(e==null)return null;if(typeof e.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case c:return"Fragment";case a:return"Portal";case m:return"Profiler";case i:return"StrictMode";case O:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return pe(t)+".Consumer";case R:var o=e;return pe(o._context)+".Provider";case g:return mt(e,e.render,"ForwardRef");case f:var s=e.displayName||null;return s!==null?s:N(e.type)||"Memo";case P:{var d=e,v=d._payload,l=d._init;try{return N(l(v))}catch{return null}}}return null}var D=Object.assign,U=0,ge,ye,he,Re,Ee,we,be;function _e(){}_e.__reactDisabledLog=!0;function vt(){{if(U===0){ge=console.log,ye=console.info,he=console.warn,Re=console.error,Ee=console.group,we=console.groupCollapsed,be=console.groupEnd;var e={configurable:!0,enumerable:!0,value:_e,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}U++}}function pt(){{if(U--,U===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:ge}),info:D({},e,{value:ye}),warn:D({},e,{value:he}),error:D({},e,{value:Re}),group:D({},e,{value:Ee}),groupCollapsed:D({},e,{value:we}),groupEnd:D({},e,{value:be})})}U<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var te=T.ReactCurrentDispatcher,re;function G(e,t,o){{if(re===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);re=s&&s[1]||""}return`
18
+ `+re+e}}var ne=!1,K;{var gt=typeof WeakMap=="function"?WeakMap:Map;K=new gt}function Ce(e,t){if(!e||ne)return"";{var o=K.get(e);if(o!==void 0)return o}var s;ne=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var v;v=te.current,te.current=null,vt();try{if(t){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(x){s=x}Reflect.construct(e,[],l)}else{try{l.call()}catch(x){s=x}e.call(l.prototype)}}else{try{throw Error()}catch(x){s=x}e()}}catch(x){if(x&&s&&typeof x.stack=="string"){for(var u=x.stack.split(`
19
+ `),C=s.stack.split(`
20
+ `),y=u.length-1,E=C.length-1;y>=1&&E>=0&&u[y]!==C[E];)E--;for(;y>=1&&E>=0;y--,E--)if(u[y]!==C[E]){if(y!==1||E!==1)do if(y--,E--,E<0||u[y]!==C[E]){var S=`
21
+ `+u[y].replace(" at new "," at ");return e.displayName&&S.includes("<anonymous>")&&(S=S.replace("<anonymous>",e.displayName)),typeof e=="function"&&K.set(e,S),S}while(y>=1&&E>=0);break}}}finally{ne=!1,te.current=v,pt(),Error.prepareStackTrace=d}var I=e?e.displayName||e.name:"",Ie=I?G(I):"";return typeof e=="function"&&K.set(e,Ie),Ie}function yt(e,t,o){return Ce(e,!1)}function ht(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function $(e,t,o){if(e==null)return"";if(typeof e=="function")return Ce(e,ht(e));if(typeof e=="string")return G(e);switch(e){case O:return G("Suspense");case b:return G("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case g:return yt(e.render);case f:return $(e.type,t,o);case P:{var s=e,d=s._payload,v=s._init;try{return $(v(d),t,o)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,Pe={},Se=T.ReactDebugCurrentFrame;function q(e){if(e){var t=e._owner,o=$(e.type,e._source,t?t.type:null);Se.setExtraStackFrame(o)}else Se.setExtraStackFrame(null)}function Rt(e,t,o,s,d){{var v=Function.call.bind(X);for(var l in e)if(v(e,l)){var u=void 0;try{if(typeof e[l]!="function"){var C=Error((s||"React class")+": "+o+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw C.name="Invariant Violation",C}u=e[l](t,l,s,o,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){u=y}u&&!(u instanceof Error)&&(q(d),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",o,l,typeof u),q(null)),u instanceof Error&&!(u.message in Pe)&&(Pe[u.message]=!0,q(d),_("Failed %s type: %s",o,u.message),q(null))}}}var Et=Array.isArray;function oe(e){return Et(e)}function wt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,o=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o}}function bt(e){try{return Oe(e),!1}catch{return!0}}function Oe(e){return""+e}function Te(e){if(bt(e))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wt(e)),Oe(e)}var B=T.ReactCurrentOwner,_t={key:!0,ref:!0,__self:!0,__source:!0},je,Ne,ae;ae={};function Ct(e){if(X.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Pt(e){if(X.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function St(e,t){if(typeof e.ref=="string"&&B.current&&t&&B.current.stateNode!==t){var o=N(B.current.type);ae[o]||(_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',N(B.current.type),e.ref),ae[o]=!0)}}function Ot(e,t){{var o=function(){je||(je=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}}function Tt(e,t){{var o=function(){Ne||(Ne=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};o.isReactWarning=!0,Object.defineProperty(e,"ref",{get:o,configurable:!0})}}var jt=function(e,t,o,s,d,v,l){var u={$$typeof:n,type:e,key:t,ref:o,props:l,_owner:v};return u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u};function Nt(e,t,o,s,d){{var v,l={},u=null,C=null;o!==void 0&&(Te(o),u=""+o),Pt(t)&&(Te(t.key),u=""+t.key),Ct(t)&&(C=t.ref,St(t,d));for(v in t)X.call(t,v)&&!_t.hasOwnProperty(v)&&(l[v]=t[v]);if(e&&e.defaultProps){var y=e.defaultProps;for(v in y)l[v]===void 0&&(l[v]=y[v])}if(u||C){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;u&&Ot(l,E),C&&Tt(l,E)}return jt(e,u,C,d,s,B.current,l)}}var ie=T.ReactCurrentOwner,xe=T.ReactDebugCurrentFrame;function L(e){if(e){var t=e._owner,o=$(e.type,e._source,t?t.type:null);xe.setExtraStackFrame(o)}else xe.setExtraStackFrame(null)}var se;se=!1;function ce(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function ke(){{if(ie.current){var e=N(ie.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function Pt(e){return""}var Ve={};function Ot(e){{var t=We();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
23
+ Check the render method of \``+e+"`."}return""}}function xt(e){return""}var Ae={};function kt(e){{var t=ke();if(!t){var o=typeof e=="string"?e:e.displayName||e.name;o&&(t=`
24
24
 
25
- Check the top-level render call using <`+r+">.")}return t}}function Ye(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Ot(t);if(Ve[r])return;Ve[r]=!0;var s="";e&&e._owner&&e._owner!==me.current&&(s=" It was passed a child from "+D(e._owner.type)+"."),V(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,s),V(null)}}function Me(e,t){{if(typeof e!="object")return;if(fe(e))for(var r=0;r<e.length;r++){var s=e[r];ve(s)&&Ye(s,t)}else if(ve(e))e._store&&(e._store.validated=!0);else if(e){var m=A(e);if(typeof m=="function"&&m!==e.entries)for(var g=m.call(e),f;!(f=g.next()).done;)ve(f.value)&&Ye(f.value,t)}}}function jt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===S))r=t.propTypes;else return;if(r){var s=D(t);vt(r,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!pe){pe=!0;var m=D(t);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var s=t[r];if(s!=="children"&&s!=="key"){V(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),V(null);break}}e.ref!==null&&(V(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}function qe(e,t,r,s,m,g){{var f=X(e);if(!f){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var w=Pt();w?l+=w:l+=We();var E;e===null?E="null":fe(e)?E="array":e!==void 0&&e.$$typeof===o?(E="<"+(D(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,l)}var b=St(e,t,r,m,g);if(b==null)return b;if(f){var j=t.children;if(j!==void 0)if(s)if(fe(j)){for(var Y=0;Y<j.length;Y++)Me(j[Y],e);Object.freeze&&Object.freeze(j)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Me(j,e)}return e===u?xt(b):jt(b),b}}function Nt(e,t,r){return qe(e,t,r,!0)}function At(e,t,r){return qe(e,t,r,!1)}var kt=At,Dt=Nt;B.Fragment=u,B.jsx=kt,B.jsxs=Dt}()),B}process.env.NODE_ENV==="production"?ae.exports=ot():ae.exports=at();var Re=ae.exports;const z=Re.jsx,st=Re.Fragment;function it(n){const{id:o,pageType:a}=n;return z("div",{className:"nosto_element",id:o},o+(a||""))}function ct(n){const{account:o,multiCurrency:a=!1,host:u,children:d,recommendationComponent:c,shopifyMarkets:i}=n,[p,v]=h.useState(!1),N=h.useMemo(()=>p,[p]),_=a?n.currentVariation:"",S=h.isValidElement(c)?"JSON_ORIGINAL":"HTML";function k(A){return h.cloneElement(c,{nostoRecommendation:A.nostoRecommendation})}const[I,G]=h.useState("");function se(A=""){const T=h.useRef({});h.useEffect(()=>{I!==A&&G(A)},[]);const R=A===I;function y(P,O){if(S=="HTML")O.placements.injectCampaigns(P.recommendations);else{const $=P.campaigns.recommendations;for(const U in $){const ie=$[U],K="#"+U,X=()=>document.querySelector(K);X()&&(T.current[U]||(T.current[U]=He.createRoot(X())),T.current[U].render(z(k,{nostoRecommendation:ie})))}}}return{renderCampaigns:y,pageTypeUpdated:R}}return h.useEffect(()=>{var A,T,R;if(window.nostojs||(window.nostojs=y=>{(window.nostojs.q=window.nostojs.q||[]).push(y)},window.nostojs(y=>y.setAutoLoad(!1))),!document.querySelectorAll("[nosto-client-script]").length&&!i){const y=document.createElement("script");y.type="text/javascript",y.src="//"+(u||"connect.nosto.com")+"/include/"+o,y.async=!0,y.setAttribute("nosto-client-script",""),y.onload=()=>{var P;typeof jest<"u"&&((P=window.nosto)==null||P.reload({site:"localhost"})),v(!0)},document.body.appendChild(y)}if(i){const y=document.querySelector("[nosto-client-script]"),P=document.querySelector("#nosto-sandbox");if(!y||(y==null?void 0:y.getAttribute("nosto-language"))!==(i==null?void 0:i.language)||(y==null?void 0:y.getAttribute("nosto-market-id"))!==(i==null?void 0:i.marketId)){p&&v(!1),(A=y==null?void 0:y.parentNode)==null||A.removeChild(y),(T=P==null?void 0:P.parentNode)==null||T.removeChild(P);const O=document.createElement("script");O.type="text/javascript",O.src="//"+(u||"connect.nosto.com")+`/script/shopify/market/nosto.js?merchant=${o}&market=${i.marketId||""}&locale=${((R=i==null?void 0:i.language)==null?void 0:R.toLowerCase())||""}`,O.async=!0,O.setAttribute("nosto-client-script",""),O.setAttribute("nosto-language",(i==null?void 0:i.language)||""),O.setAttribute("nosto-market-id",String(i==null?void 0:i.marketId)),O.onload=()=>{var $;typeof jest<"u"&&(($=window.nosto)==null||$.reload({site:"localhost"})),v(!0)},document.body.appendChild(O)}}},[p,i]),z(ne.Provider,{value:{account:o,clientScriptLoaded:N,currentVariation:_,responseMode:S,recommendationComponent:c,useRenderCampaigns:se,pageType:I},children:d})}function ut(n){const{cart:o,customer:a}=n??{},{clientScriptLoaded:u}=x();return he(()=>{const d=o?M(o):void 0,c=a?M(a):void 0;u&&window.nostojs(i=>{i.defaultSession().setResponseMode("HTML").setCart(d).setCustomer(c).viewOther().load()})},[u,o,a]),z(st,{})}C.Nosto404=ze,C.NostoCategory=Ze,C.NostoCheckout=Ke,C.NostoContext=ne,C.NostoHome=nt,C.NostoOrder=rt,C.NostoOther=Ge,C.NostoPlacement=it,C.NostoProduct=Xe,C.NostoProvider=ct,C.NostoSearch=Qe,C.NostoSession=ut,C.useNostoContext=x,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
25
+ Check the top-level render call using <`+o+">.")}return t}}function De(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var o=kt(t);if(Ae[o])return;Ae[o]=!0;var s="";e&&e._owner&&e._owner!==ie.current&&(s=" It was passed a child from "+N(e._owner.type)+"."),L(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',o,s),L(null)}}function Fe(e,t){{if(typeof e!="object")return;if(oe(e))for(var o=0;o<e.length;o++){var s=e[o];ce(s)&&De(s,t)}else if(ce(e))e._store&&(e._store.validated=!0);else if(e){var d=J(e);if(typeof d=="function"&&d!==e.entries)for(var v=d.call(e),l;!(l=v.next()).done;)ce(l.value)&&De(l.value,t)}}}function At(e){{var t=e.type;if(t==null||typeof t=="string")return;var o;if(typeof t=="function")o=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===g||t.$$typeof===f))o=t.propTypes;else return;if(o){var s=N(t);Rt(o,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!se){se=!0;var d=N(t);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dt(e){{for(var t=Object.keys(e.props),o=0;o<t.length;o++){var s=t[o];if(s!=="children"&&s!=="key"){L(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),L(null);break}}e.ref!==null&&(L(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),L(null))}}function Le(e,t,o,s,d,v){{var l=dt(e);if(!l){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var C=xt();C?u+=C:u+=ke();var y;e===null?y="null":oe(e)?y="array":e!==void 0&&e.$$typeof===n?(y="<"+(N(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,u)}var E=Nt(e,t,o,d,v);if(E==null)return E;if(l){var S=t.children;if(S!==void 0)if(s)if(oe(S)){for(var I=0;I<S.length;I++)Fe(S[I],e);Object.freeze&&Object.freeze(S)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Fe(S,e)}return e===c?Dt(E):At(E),E}}function Ft(e,t,o){return Le(e,t,o,!0)}function Lt(e,t,o){return Le(e,t,o,!1)}var It=Lt,Mt=Ft;W.Fragment=c,W.jsx=It,W.jsxs=Mt}()),W}process.env.NODE_ENV==="production"?ee.exports=Ve():ee.exports=Ye();var V=ee.exports;function Ue(r){return w.cloneElement(r.recommendationComponent,{nostoRecommendation:r.nostoRecommendation})}function Be(r){if(!window.nostojs)throw new Error("Nosto has not yet been initialized");window.nostojs(n=>{n.placements.injectCampaigns(r.recommendations)})}function A(){const{responseMode:r,recommendationComponent:n}=H(),a=w.useRef({});if(r=="HTML")return{renderCampaigns:Be};function c(i){var R;const m=((R=i.campaigns)==null?void 0:R.recommendations)??{};for(const p in m){const g=m[p],O="#"+p,b=document.querySelector(O);b&&(a.current[p]||(a.current[p]=Me.createRoot(b)),a.current[p].render(V.jsx(Ue,{recommendationComponent:n,nostoRecommendation:g})))}}return{renderCampaigns:c}}function He(){return typeof window.nosto<"u"}function ze(r,n){return new Promise((a,c)=>{const i=document.createElement("script");i.type="text/javascript",i.src=r,i.async=!0,i.onload=()=>a(),i.onerror=()=>c(),Object.entries((n==null?void 0:n.attributes)??{}).forEach(([m,R])=>i.setAttribute(m,R)),(n==null?void 0:n.position)==="head"?document.head.appendChild(i):document.body.appendChild(i)})}function Je(r){const{host:n="connect.nosto.com",scriptLoader:a=ze,account:c,shopifyMarkets:i,loadScript:m=!0}=r,[R,p]=w.useState(!1);return w.useEffect(()=>{function g(){var f;"nostoReactTest"in window&&((f=window.nosto)==null||f.reload({site:"localhost"})),p(!0)}async function O(f,P={}){const j=`//${n}${f}`,F={"nosto-client-script":"",...P};await a(j,{attributes:F}),g()}function b(){var z,J;const f=document.querySelector("[nosto-client-script]"),P=String((i==null?void 0:i.marketId)||""),j=(i==null?void 0:i.language)||"",F=(f==null?void 0:f.getAttribute("nosto-language"))!==j||(f==null?void 0:f.getAttribute("nosto-market-id"))!==P;if(!f||F){R&&p(!1);const T=document.querySelector("#nosto-sandbox");(z=f==null?void 0:f.parentNode)==null||z.removeChild(f),(J=T==null?void 0:T.parentNode)==null||J.removeChild(T);const _=`/script/shopify/market/nosto.js?merchant=${c}&market=${P}&locale=${j.toLowerCase()}`;O(_,{"nosto-language":j,"nosto-market-id":P})}}if(window.nostojs||(window.nostojs=f=>{(window.nostojs.q=window.nostojs.q||[]).push(f)},window.nostojs(f=>f.setAutoLoad(!1))),!m){window.nosto?g():window.nostojs(g);return}if(!He()&&!i){const f=`/include/${c}`;O(f)}i&&b()},[i==null?void 0:i.marketId,i==null?void 0:i.language]),{clientScriptLoaded:R}}function Ge(r){const{renderCampaigns:n}=A();return k(async a=>{const c=await a.defaultSession().viewNotFound().setPlacements(r.placements||a.placements.getPlacements()).load();n(c)}),null}function Ke(r){const{renderCampaigns:n}=A();return k(async a=>{const c=await a.defaultSession().viewOther().setPlacements(r.placements||a.placements.getPlacements()).load();n(c)}),null}function $e(r){const{renderCampaigns:n}=A();return k(async a=>{const c=await a.defaultSession().viewCart().setPlacements(r.placements||a.placements.getPlacements()).load();n(c)}),null}function Xe(r){const{product:n,tagging:a,placements:c}=r,{renderCampaigns:i}=A();return k(async m=>{const R=await m.defaultSession().viewProduct(a??n).setPlacements(c||m.placements.getPlacements()).load();i(R)},[n,a==null?void 0:a.selected_sku_id]),null}function qe(r){const{category:n,placements:a}=r,{renderCampaigns:c}=A();return k(async i=>{const m=await i.defaultSession().viewCategory(n).setPlacements(a||i.placements.getPlacements()).load();c(m)},[n]),null}function Ze(r){const{query:n,placements:a}=r,{renderCampaigns:c}=A();return k(async i=>{const m=await i.defaultSession().viewSearch(n).setPlacements(a||i.placements.getPlacements()).load();c(m)},[n]),null}function Y(r){return!r||typeof r!="object"||Qe(r)||et(r)?r:Array.isArray(r)?r.map(Y):Object.keys(r).reduce((n,a)=>{const c=a[0].toLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(i,m)=>"_"+m.toLowerCase());return n[c]=Y(r[a]),n},{})}function Qe(r){return Object.prototype.toString.call(r)==="[object Date]"}function et(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function tt(r){const{order:n,placements:a}=r,{renderCampaigns:c}=A();return k(async i=>{const m=await i.defaultSession().addOrder(Y(n)).setPlacements(a||i.placements.getPlacements()).load();c(m)},[n],{deep:!0}),null}function rt(r){const{renderCampaigns:n}=A();return k(async a=>{const c=await a.defaultSession().viewFrontPage().setPlacements(r.placements||a.placements.getPlacements()).load();n(c)}),null}function nt(r){const{id:n,pageType:a}=r;return V.jsx("div",{className:"nosto_element",id:n},n+(a||""))}function ot(r){const{account:n,multiCurrency:a=!1,children:c,recommendationComponent:i}=r,m=a?r.currentVariation:"";if(i&&!w.isValidElement(i))throw new Error("The recommendationComponent prop must be a valid React element. Please provide a valid React element.");const R=i?"JSON_ORIGINAL":"HTML",{clientScriptLoaded:p}=Je(r);return V.jsx(Q.Provider,{value:{account:n,clientScriptLoaded:p,currentVariation:m,responseMode:R,recommendationComponent:i},children:c})}function at(r){const{cart:n,customer:a}=r??{},{clientScriptLoaded:c}=H();return fe(()=>{const i=n?Y(n):void 0,m=a?Y(a):void 0;c&&window.nostojs(R=>{R.defaultSession().setResponseMode("HTML").setCart(i).setCustomer(m).viewOther().load()})},[c,n,a]),V.jsx(V.Fragment,{})}h.Nosto404=Ge,h.NostoCategory=qe,h.NostoCheckout=$e,h.NostoContext=Q,h.NostoHome=rt,h.NostoOrder=tt,h.NostoOther=Ke,h.NostoPlacement=nt,h.NostoProduct=Xe,h.NostoProvider=ot,h.NostoSearch=Ze,h.NostoSession=at,h.useNostoContext=H,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nosto/nosto-react",
3
3
  "description": "Component library to simply implementing Nosto on React.",
4
- "version": "1.0.0",
4
+ "version": "2.1.0",
5
5
  "author": "Mridang Agarwalla, Dominik Gilg",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "clean": "rimraf dist",
23
23
  "prettier": "prettier '{src,spec}/**' --list-different",
24
24
  "prettier:fix": "prettier '{src,spec}/**' --write",
25
- "test": "jest spec",
25
+ "test": "vitest run --silent",
26
26
  "typedoc": "typedoc src/index.ts"
27
27
  },
28
28
  "files": [
@@ -30,30 +30,29 @@
30
30
  "src"
31
31
  ],
32
32
  "devDependencies": {
33
- "@testing-library/jest-dom": "^5.16.5",
34
- "@testing-library/react": "^14.0.0",
33
+ "@testing-library/jest-dom": "^6.4.8",
34
+ "@testing-library/react": "^16.0.0",
35
35
  "@testing-library/user-event": "^14.4.3",
36
- "@types/jest": "^29.5.0",
37
36
  "@types/react": "^18.0.0",
38
37
  "@types/react-dom": "^18.0.0",
39
38
  "@types/user-event": "^4.1.1",
40
39
  "@typescript-eslint/eslint-plugin": "^6.11.0",
41
40
  "@typescript-eslint/parser": "^6.11.0",
42
- "@vitejs/plugin-react": "^1.3.0",
41
+ "@vitejs/plugin-react": "^4.3.1",
43
42
  "eslint": "^8.53.0",
44
43
  "eslint-plugin-promise": "^6.1.1",
45
44
  "eslint-plugin-react": "^7.33.2",
46
- "jest": "^29.5.0",
47
- "jest-environment-jsdom": "^29.5.0",
48
45
  "prettier": "^2.0.5",
49
46
  "react": "*",
50
47
  "react-dom": "*",
48
+ "react-router": "^6.25.1",
49
+ "react-router-dom": "^6.25.1",
51
50
  "rimraf": "^3.0.2",
52
- "ts-jest": "^29.1.0",
53
51
  "typedoc": "^0.24.1",
54
52
  "typescript": "^4.6.3",
55
53
  "vite": "^5.2.10",
56
- "vite-plugin-dts": "^3.9.1"
54
+ "vite-plugin-dts": "^3.9.1",
55
+ "vitest": "^2.0.5"
57
56
  },
58
57
  "main": "./dist/index.umd.js",
59
58
  "module": "./dist/index.es.js",
@@ -68,13 +67,5 @@
68
67
  "bugs": {
69
68
  "url": "https://github.com/Nosto/nosto-react/issues"
70
69
  },
71
- "homepage": "https://github.com/Nosto/nosto-react#readme",
72
- "jest": {
73
- "preset": "ts-jest",
74
- "testEnvironment": "jsdom",
75
- "testEnvironmentOptions": {
76
- "resources": "usable",
77
- "runScripts": "dangerously"
78
- }
79
- }
70
+ "homepage": "https://github.com/Nosto/nosto-react#readme"
80
71
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your cart and checkout pages by using the `Nosto404` component.
@@ -22,9 +21,7 @@ import { useNostoApi } from "../utils/hooks"
22
21
  * @group Components
23
22
  */
24
23
  export default function Nosto404(props: { placements?: string[] }) {
25
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
26
-
27
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("404")
24
+ const { renderCampaigns } = useRenderCampaigns()
28
25
 
29
26
  useNostoApi(
30
27
  async (api) => {
@@ -32,9 +29,7 @@ export default function Nosto404(props: { placements?: string[] }) {
32
29
  .viewNotFound()
33
30
  .setPlacements(props.placements || api.placements.getPlacements())
34
31
  .load()
35
- renderCampaigns(data, api)
36
- },
37
- [recommendationComponent, pageTypeUpdated]
38
- )
32
+ renderCampaigns(data)
33
+ })
39
34
  return null
40
35
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your category and collection pages by using the NostoCategory component.
@@ -25,9 +24,7 @@ import { useNostoApi } from "../utils/hooks"
25
24
  */
26
25
  export default function NostoCategory(props: { category: string; placements?: string[] }) {
27
26
  const { category, placements } = props
28
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
29
-
30
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("home")
27
+ const { renderCampaigns } = useRenderCampaigns()
31
28
 
32
29
  useNostoApi(
33
30
  async (api) => {
@@ -35,9 +32,9 @@ export default function NostoCategory(props: { category: string; placements?: st
35
32
  .viewCategory(category)
36
33
  .setPlacements(placements || api.placements.getPlacements())
37
34
  .load()
38
- renderCampaigns(data, api)
35
+ renderCampaigns(data)
39
36
  },
40
- [category, recommendationComponent, pageTypeUpdated]
37
+ [category]
41
38
  )
42
39
  return null
43
40
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your cart and checkout pages by using the NostoCheckout component.
@@ -21,9 +20,7 @@ import { useNostoApi } from "../utils/hooks"
21
20
  * @group Components
22
21
  */
23
22
  export default function NostoCheckout(props: { placements?: string[] }) {
24
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
25
-
26
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("checkout")
23
+ const { renderCampaigns } = useRenderCampaigns()
27
24
 
28
25
  useNostoApi(
29
26
  async (api) => {
@@ -31,9 +28,7 @@ export default function NostoCheckout(props: { placements?: string[] }) {
31
28
  .viewCart()
32
29
  .setPlacements(props.placements || api.placements.getPlacements())
33
30
  .load()
34
- renderCampaigns(data, api)
35
- },
36
- [recommendationComponent, pageTypeUpdated]
37
- )
31
+ renderCampaigns(data)
32
+ })
38
33
  return null
39
34
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
2
 
4
3
  /**
5
4
  * The `NostoHome` component must be used to personalise the home page. The component does not require any props.
@@ -25,9 +24,7 @@ import { useNostoApi } from "../utils/hooks"
25
24
  * @group Components
26
25
  */
27
26
  export default function NostoHome(props: { placements?: string[] }) {
28
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
29
-
30
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("home")
27
+ const { renderCampaigns } = useRenderCampaigns()
31
28
 
32
29
  useNostoApi(
33
30
  async (api) => {
@@ -35,9 +32,8 @@ export default function NostoHome(props: { placements?: string[] }) {
35
32
  .viewFrontPage()
36
33
  .setPlacements(props.placements || api.placements.getPlacements())
37
34
  .load()
38
- renderCampaigns(data, api)
39
- },
40
- [recommendationComponent, pageTypeUpdated]
35
+ renderCampaigns(data)
36
+ }
41
37
  )
42
38
  return null
43
39
  }
@@ -1,7 +1,6 @@
1
1
  import { Order } from "../types"
2
- import { useNostoContext } from "./context"
2
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
3
  import { snakeize } from "../utils/snakeize"
4
- import { useNostoApi } from "../utils/hooks"
5
4
 
6
5
  /**
7
6
  * You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
@@ -27,9 +26,7 @@ export default function NostoOrder(props: {
27
26
  placements?: string[]
28
27
  }) {
29
28
  const { order, placements } = props
30
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
31
-
32
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("order")
29
+ const { renderCampaigns } = useRenderCampaigns()
33
30
 
34
31
  useNostoApi(
35
32
  async (api) => {
@@ -37,9 +34,10 @@ export default function NostoOrder(props: {
37
34
  .addOrder(snakeize(order))
38
35
  .setPlacements(placements || api.placements.getPlacements())
39
36
  .load()
40
- renderCampaigns(data, api)
37
+ renderCampaigns(data)
41
38
  },
42
- [recommendationComponent, pageTypeUpdated]
39
+ [order],
40
+ { deep: true }
43
41
  )
44
42
  return null
45
43
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your miscellaneous pages by using the NostoOther component.
@@ -21,9 +20,7 @@ import { useNostoApi } from "../utils/hooks"
21
20
  * @group Components
22
21
  */
23
22
  export default function NostoOther(props: { placements?: string[] }) {
24
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
25
-
26
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("other")
23
+ const { renderCampaigns } = useRenderCampaigns()
27
24
 
28
25
  useNostoApi(
29
26
  async (api) => {
@@ -31,9 +28,7 @@ export default function NostoOther(props: { placements?: string[] }) {
31
28
  .viewOther()
32
29
  .setPlacements(props.placements || api.placements.getPlacements())
33
30
  .load()
34
- renderCampaigns(data, api)
35
- },
36
- [recommendationComponent, pageTypeUpdated]
37
- )
31
+ renderCampaigns(data)
32
+ })
38
33
  return null
39
34
  }
@@ -1,5 +1,3 @@
1
- import React from "react"
2
-
3
1
  /**
4
2
  * Nosto React has a special component called NostoPlacement.
5
3
  * The component is a simply a hidden `<div>` placeholder into which Nosto injects recommendations or personalises the content between the tags.
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
2
  import { Product } from "../types"
4
3
 
5
4
  /**
@@ -32,9 +31,7 @@ export default function NostoProduct(props: {
32
31
  placements?: string[]
33
32
  }) {
34
33
  const { product, tagging, placements } = props
35
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
36
-
37
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("product")
34
+ const { renderCampaigns } = useRenderCampaigns()
38
35
 
39
36
  useNostoApi(
40
37
  async (api) => {
@@ -42,10 +39,9 @@ export default function NostoProduct(props: {
42
39
  .viewProduct(tagging ?? product)
43
40
  .setPlacements(placements || api.placements.getPlacements())
44
41
  .load()
45
- renderCampaigns(data, api)
42
+ renderCampaigns(data)
46
43
  },
47
- [product, recommendationComponent, pageTypeUpdated],
48
- { deep: true }
44
+ [product, tagging?.selected_sku_id]
49
45
  )
50
46
  return null
51
47
  }