@picked/client 0.0.1-dev.1763359305886 → 0.0.1-dev.1763361588231

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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var y=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../user-session-nuW7qzmd.cjs"),d=require("../logger-BsmHUUw1.cjs"),l=require("../experience-instance-B2l_MG7I.cjs"),S=require("effector"),c=require("../supports-YvpQZxbh.cjs"),u=require("../storage-DuRlyFaY.cjs"),w=(i,e,t)=>{const s=e.name,n=e.setup(i);if(n){const a=t[s]??{};t[s]=Object.freeze({...a,...n})}};function v(i){const e=typeof window<"u",t={client:i,responses:i.responses.listStore.getState(),fields:i.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(t)}const I=()=>S.createEvent(),P=()=>"0.0.1-dev.1763359305886";function k(){if(c.supportsDocument()){const i=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of i)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function x(){if(!c.supportsWindow())return{};const i=new URLSearchParams(window.location.search),e={},t=new Set;for(const[n]of i.entries())n.startsWith("picked-")&&t.add(n);for(const n of t){const a=n.replace("picked-","");e[a]=i.getAll(n)}const s=u.createStorageKey("s");if(t.size>0)u.sessionStore.set(s,e);else{const n=u.sessionStore.get(s);if(n)return n.json()||{}}return e}class h{constructor(e){o(this,"options");o(this,"isReady",!1);o(this,"project");o(this,"plugins",{});o(this,"eventBus",I());o(this,"organizationId");o(this,"projectId");o(this,"apiUrl");o(this,"session");o(this,"searchParams",x());o(this,"history",r.createHistory());o(this,"components",r.createComponentIndex({client:this}));o(this,"experienceInstances",l.createExperienceInstanceIndex({client:this}));o(this,"experiences",r.createExperienceIndex({client:this}));o(this,"frameworks",r.createFrameworkIndex({client:this}));o(this,"predicates",r.createPredicateIndex({client:this}));o(this,"features",r.createFeatureIndex({client:this}));o(this,"responses",r.createResponseIndex({client:this}));o(this,"fields",r.createFieldIndex());o(this,"actions",r.createActionIndex());d.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||k(),this.session=r.initialiseSession(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.eventBus({type:"initialized",version:P()}),d.logger("info","Picked client initialized.")}start(){r.ping(this),(async()=>{c.supportsDocument()&&(document.body&&r.initialiseExperiences(this),await l.domInteractive(),await r.initialiseExperiences(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session}))})()}registerFramework(e){r.setupFramework(e,this.frameworks)}registerComponent(e,t){r.setupComponent(e,t,this.components)}registerPlugin(e){w(this,e,this.plugins)}registerFeature(e,t){r.setupFeature(e,t,this.features)}registerPredicate(e,t){r.setupPredicate(e,t,this.predicates)}registerField(e){r.setupField(e,this.fields)}registerAction(e,t){r.setupAction(e,t,this.actions)}registerExperience(e){e.component&&r.setupComponent(`experience:${e.id}`,e.component,this.components),r.setupExperience(e,this.experiences)}getStateSnapshot(){return v(this)}async launchExperienceById(e){const t=this.experiences.getById(e).getState();if(!t){d.logger("warn",`Experience with id '${e}' not found.`);return}r.initialiseExperience(this,t)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(t=>{if(Array.isArray(t)){t.forEach(n=>{this.registerPlugin(n)});return}const s=typeof t=="function"?t():t;if(Array.isArray(s)){s.forEach(n=>this.registerPlugin(n));return}this.registerPlugin(s)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([t,s])=>{const n=typeof s=="function"?s():s;this.registerFeature(t,n)}),this.searchParams.feature&&this.searchParams.feature.forEach(t=>{try{const[s,n]=t.split(":");if(!s||!n)return;let a=n;a==="true"&&(a=!0),a==="false"&&(a=!1),this.registerFeature(s,{key:`${a}`,name:s,decide:()=>a,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Predicate "${t}" is not a function.`);return}this.registerPredicate(t,s)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Action "${t}" is not a function.`);return}this.registerAction(t,s)})}getPluginConfig(e){return this.plugins[e]??{}}}o(h,"logger",d.logger);function f(i){var e;return((e=i.options)==null?void 0:e.some(t=>"condition"in t))??!1}function E(i){return i.some(e=>e.condition||f(e))}async function C(i,e){return e.length===0||!E(e)?e:(await Promise.all(e.map(async s=>{if(!(s.condition?await l.evaluateRuleLogic(i,s.condition):!0))return null;if(!s.options||!f(s))return s;const g=(await Promise.all(s.options.map(async p=>p.condition?await l.evaluateRuleLogic(i,p.condition)?p:null:p))).filter(p=>p!==null);return g.length===s.options.length?s:g.length===0?null:{...s,options:g}}))).filter(s=>s!==null)}const R=i=>{const e=new h(i);return c.bindClient(e),e};exports.evaluateRuleLogic=l.evaluateRuleLogic;exports.isPickedRoot=l.isPickedRoot;exports.supportsCookies=c.supportsCookies;exports.supportsCryptoRandomUUID=c.supportsCryptoRandomUUID;exports.supportsDocument=c.supportsDocument;exports.supportsHistory=c.supportsHistory;exports.supportsIntersectionObserver=c.supportsIntersectionObserver;exports.supportsLocalStorage=c.supportsLocalStorage;exports.supportsLocation=c.supportsLocation;exports.supportsSessionStorage=c.supportsSessionStorage;exports.supportsShadowRoot=c.supportsShadowRoot;exports.supportsWebComponents=c.supportsWebComponents;exports.supportsWindow=c.supportsWindow;exports.createStorageKey=u.createStorageKey;exports.localStore=u.localStore;exports.sessionStore=u.sessionStore;exports.subscribe=u.subscribe;exports.Picked=h;exports.createClient=R;exports.getStepFields=C;
1
+ "use strict";var m=Object.defineProperty;var y=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../user-session-nuW7qzmd.cjs"),d=require("../logger-BsmHUUw1.cjs"),l=require("../experience-instance-B2l_MG7I.cjs"),S=require("effector"),c=require("../supports-YvpQZxbh.cjs"),u=require("../storage-DuRlyFaY.cjs"),w=(i,e,t)=>{const s=e.name,n=e.setup(i);if(n){const a=t[s]??{};t[s]=Object.freeze({...a,...n})}};function v(i){const e=typeof window<"u",t={client:i,responses:i.responses.listStore.getState(),fields:i.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(t)}const I=()=>S.createEvent(),P=()=>"0.0.1-dev.1763361588231";function k(){if(c.supportsDocument()){const i=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of i)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function x(){if(!c.supportsWindow())return{};const i=new URLSearchParams(window.location.search),e={},t=new Set;for(const[n]of i.entries())n.startsWith("picked-")&&t.add(n);for(const n of t){const a=n.replace("picked-","");e[a]=i.getAll(n)}const s=u.createStorageKey("s");if(t.size>0)u.sessionStore.set(s,e);else{const n=u.sessionStore.get(s);if(n)return n.json()||{}}return e}class h{constructor(e){o(this,"options");o(this,"isReady",!1);o(this,"project");o(this,"plugins",{});o(this,"eventBus",I());o(this,"organizationId");o(this,"projectId");o(this,"apiUrl");o(this,"session");o(this,"searchParams",x());o(this,"history",r.createHistory());o(this,"components",r.createComponentIndex({client:this}));o(this,"experienceInstances",l.createExperienceInstanceIndex({client:this}));o(this,"experiences",r.createExperienceIndex({client:this}));o(this,"frameworks",r.createFrameworkIndex({client:this}));o(this,"predicates",r.createPredicateIndex({client:this}));o(this,"features",r.createFeatureIndex({client:this}));o(this,"responses",r.createResponseIndex({client:this}));o(this,"fields",r.createFieldIndex());o(this,"actions",r.createActionIndex());d.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||k(),this.session=r.initialiseSession(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.eventBus({type:"initialized",version:P()}),d.logger("info","Picked client initialized.")}start(){r.ping(this),(async()=>{c.supportsDocument()&&(document.body&&r.initialiseExperiences(this),await l.domInteractive(),await r.initialiseExperiences(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session}))})()}registerFramework(e){r.setupFramework(e,this.frameworks)}registerComponent(e,t){r.setupComponent(e,t,this.components)}registerPlugin(e){w(this,e,this.plugins)}registerFeature(e,t){r.setupFeature(e,t,this.features)}registerPredicate(e,t){r.setupPredicate(e,t,this.predicates)}registerField(e){r.setupField(e,this.fields)}registerAction(e,t){r.setupAction(e,t,this.actions)}registerExperience(e){e.component&&r.setupComponent(`experience:${e.id}`,e.component,this.components),r.setupExperience(e,this.experiences)}getStateSnapshot(){return v(this)}async launchExperienceById(e){const t=this.experiences.getById(e).getState();if(!t){d.logger("warn",`Experience with id '${e}' not found.`);return}r.initialiseExperience(this,t)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(t=>{if(Array.isArray(t)){t.forEach(n=>{this.registerPlugin(n)});return}const s=typeof t=="function"?t():t;if(Array.isArray(s)){s.forEach(n=>this.registerPlugin(n));return}this.registerPlugin(s)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([t,s])=>{const n=typeof s=="function"?s():s;this.registerFeature(t,n)}),this.searchParams.feature&&this.searchParams.feature.forEach(t=>{try{const[s,n]=t.split(":");if(!s||!n)return;let a=n;a==="true"&&(a=!0),a==="false"&&(a=!1),this.registerFeature(s,{key:`${a}`,name:s,decide:()=>a,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Predicate "${t}" is not a function.`);return}this.registerPredicate(t,s)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Action "${t}" is not a function.`);return}this.registerAction(t,s)})}getPluginConfig(e){return this.plugins[e]??{}}}o(h,"logger",d.logger);function f(i){var e;return((e=i.options)==null?void 0:e.some(t=>"condition"in t))??!1}function E(i){return i.some(e=>e.condition||f(e))}async function C(i,e){return e.length===0||!E(e)?e:(await Promise.all(e.map(async s=>{if(!(s.condition?await l.evaluateRuleLogic(i,s.condition):!0))return null;if(!s.options||!f(s))return s;const g=(await Promise.all(s.options.map(async p=>p.condition?await l.evaluateRuleLogic(i,p.condition)?p:null:p))).filter(p=>p!==null);return g.length===s.options.length?s:g.length===0?null:{...s,options:g}}))).filter(s=>s!==null)}const R=i=>{const e=new h(i);return c.bindClient(e),e};exports.evaluateRuleLogic=l.evaluateRuleLogic;exports.isPickedRoot=l.isPickedRoot;exports.supportsCookies=c.supportsCookies;exports.supportsCryptoRandomUUID=c.supportsCryptoRandomUUID;exports.supportsDocument=c.supportsDocument;exports.supportsHistory=c.supportsHistory;exports.supportsIntersectionObserver=c.supportsIntersectionObserver;exports.supportsLocalStorage=c.supportsLocalStorage;exports.supportsLocation=c.supportsLocation;exports.supportsSessionStorage=c.supportsSessionStorage;exports.supportsShadowRoot=c.supportsShadowRoot;exports.supportsWebComponents=c.supportsWebComponents;exports.supportsWindow=c.supportsWindow;exports.createStorageKey=u.createStorageKey;exports.localStore=u.localStore;exports.sessionStore=u.sessionStore;exports.subscribe=u.subscribe;exports.Picked=h;exports.createClient=R;exports.getStepFields=C;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../supports-YvpQZxbh.cjs");require("../../../user-session-nuW7qzmd.cjs");require("../../../experience-instance-B2l_MG7I.cjs");require("effector");function c(){if(!r.supportsWindow()||!window.pickedConfig)throw new Error("Picked config not found. Ensure the Picked Script is enabled on your Shopify storefront");return window.pickedConfig}function d(){if(r.supportsWindow())return c().customer}function s(){if(r.supportsWindow())return c().product}function u(){if(r.supportsWindow())return c().collection}function l(){if(r.supportsWindow())return c().experiments}function f(){var e;if(r.supportsWindow())return(e=c().storefront_api)==null?void 0:e.token}const t={homepage:/^\/$/,page:/(?:^|\/)pages\/[^/]+$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},n=(e,o)=>o?!!e.exec(o.pathname):!1,a=(e,o)=>{if(o){const i=e.exec(o.pathname);if(i)return i[1]}},p=e=>{var o,i;switch(e){case"product":return((o=s())==null?void 0:o.handle)??!1;case"collection":return((i=u())==null?void 0:i.handle)??!1;default:return!1}},h={"is-page":({location:e})=>n(t.page,e),"get-page-handle":({location:e})=>a(t.page,e),"is-product-page":()=>!!p("product"),"get-product-handle":()=>p("product"),"is-collection-page":()=>!!p("collection"),"get-collection-handle":()=>p("collection"),"is-blog-page":({location:e})=>n(t.blog,e),"get-blog-handle":({location:e})=>a(t.blog,e),"is-article-page":({location:e})=>n(t.article,e),"get-article-handle":({location:e})=>a(t.article,e),"is-app-proxy-page":({location:e})=>n(t.appProxy,e),"get-app-proxy-handle":({location:e})=>a(t.appProxy,e),"is-account-page":({location:e})=>n(t.accountWildcard,e),"is-login-page":({location:e})=>n(t.accountLogin,e),"is-register-page":({location:e})=>n(t.accountRegister,e),"is-cart-page":({location:e})=>n(t.cart,e),"is-checkout-page":({location:e})=>n(t.checkout,e),"is-homepage":({location:e})=>n(t.homepage,e)};function g(){if(!r.supportsWindow()||!window.Shopify)throw new Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");return window.Shopify}function y(e){var o,i;return typeof((i=(o=g())==null?void 0:o.analytics)==null?void 0:i.publish)=="function"}const P=()=>({name:"shopify",setup:e=>{Object.entries(h).forEach(([o,i])=>{e.registerPredicate(`shopify-${o}`,i)}),r.supportsWindow()&&e.eventBus.watch(o=>{y()&&o.type==="session"&&window.Shopify.analytics.publish("picked:session",{id:o.id})})}});exports.getPickedConfig=c;exports.getPickedConfigCollection=u;exports.getPickedConfigCustomer=d;exports.getPickedConfigExperiments=l;exports.getPickedConfigProduct=s;exports.getPickedConfigStorefrontApiToken=f;exports.getShopify=g;exports.shopifyPlugin=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../supports-YvpQZxbh.cjs");require("../../../user-session-nuW7qzmd.cjs");require("../../../experience-instance-B2l_MG7I.cjs");require("effector");function c(){if(r.supportsWindow())return window.pickedConfig}function l(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.customer}function s(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.product}function u(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.collection}function d(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.experiments}function f(){var e,o;if(r.supportsWindow())return(o=(e=c())==null?void 0:e.storefront_api)==null?void 0:o.token}const t={homepage:/^\/$/,page:/(?:^|\/)pages\/[^/]+$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},n=(e,o)=>o?!!e.exec(o.pathname):!1,a=(e,o)=>{if(o){const i=e.exec(o.pathname);if(i)return i[1]}},p=e=>{var o,i;switch(e){case"product":return((o=s())==null?void 0:o.handle)??!1;case"collection":return((i=u())==null?void 0:i.handle)??!1;default:return!1}},h={"is-page":({location:e})=>n(t.page,e),"get-page-handle":({location:e})=>a(t.page,e),"is-product-page":()=>!!p("product"),"get-product-handle":()=>p("product"),"is-collection-page":()=>!!p("collection"),"get-collection-handle":()=>p("collection"),"is-blog-page":({location:e})=>n(t.blog,e),"get-blog-handle":({location:e})=>a(t.blog,e),"is-article-page":({location:e})=>n(t.article,e),"get-article-handle":({location:e})=>a(t.article,e),"is-app-proxy-page":({location:e})=>n(t.appProxy,e),"get-app-proxy-handle":({location:e})=>a(t.appProxy,e),"is-account-page":({location:e})=>n(t.accountWildcard,e),"is-login-page":({location:e})=>n(t.accountLogin,e),"is-register-page":({location:e})=>n(t.accountRegister,e),"is-cart-page":({location:e})=>n(t.cart,e),"is-checkout-page":({location:e})=>n(t.checkout,e),"is-homepage":({location:e})=>n(t.homepage,e)};function g(){if(!r.supportsWindow()||!window.Shopify)throw new Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");return window.Shopify}function y(e){var o,i;return typeof((i=(o=g())==null?void 0:o.analytics)==null?void 0:i.publish)=="function"}const P=()=>({name:"shopify",setup:e=>{Object.entries(h).forEach(([o,i])=>{e.registerPredicate(`shopify-${o}`,i)}),r.supportsWindow()&&e.eventBus.watch(o=>{y()&&o.type==="session"&&window.Shopify.analytics.publish("picked:session",{id:o.id})})}});exports.getPickedConfig=c;exports.getPickedConfigCollection=u;exports.getPickedConfigCustomer=l;exports.getPickedConfigExperiments=d;exports.getPickedConfigProduct=s;exports.getPickedConfigStorefrontApiToken=f;exports.getShopify=g;exports.shopifyPlugin=P;
package/dist/esm/index.js CHANGED
@@ -29,7 +29,7 @@ function N(i) {
29
29
  };
30
30
  return Object.freeze(t);
31
31
  }
32
- const T = () => W(), V = () => "0.0.1-dev.1763359305886";
32
+ const T = () => W(), V = () => "0.0.1-dev.1763361588231";
33
33
  function G() {
34
34
  if (h()) {
35
35
  const i = [
@@ -2,35 +2,36 @@ import { a as r } from "../../../supports-DBMT17KZ.js";
2
2
  import "../../../user-session-DINAj_Ci.js";
3
3
  import "../../../experience-instance-CeuHLrdL.js";
4
4
  import "effector";
5
- function c() {
6
- if (!r() || !window.pickedConfig)
7
- throw new Error(
8
- "Picked config not found. Ensure the Picked Script is enabled on your Shopify storefront"
9
- );
10
- return window.pickedConfig;
5
+ function a() {
6
+ if (r())
7
+ return window.pickedConfig;
11
8
  }
12
- function w() {
9
+ function P() {
10
+ var e;
13
11
  if (r())
14
- return c().customer;
12
+ return (e = a()) == null ? void 0 : e.customer;
15
13
  }
16
14
  function s() {
15
+ var e;
17
16
  if (r())
18
- return c().product;
17
+ return (e = a()) == null ? void 0 : e.product;
19
18
  }
20
19
  function u() {
20
+ var e;
21
21
  if (r())
22
- return c().collection;
22
+ return (e = a()) == null ? void 0 : e.collection;
23
23
  }
24
- function k() {
24
+ function b() {
25
+ var e;
25
26
  if (r())
26
- return c().experiments;
27
+ return (e = a()) == null ? void 0 : e.experiments;
27
28
  }
28
- function P() {
29
- var e;
29
+ function k() {
30
+ var e, t;
30
31
  if (r())
31
- return (e = c().storefront_api) == null ? void 0 : e.token;
32
+ return (t = (e = a()) == null ? void 0 : e.storefront_api) == null ? void 0 : t.token;
32
33
  }
33
- const t = {
34
+ const o = {
34
35
  homepage: /^\/$/,
35
36
  page: /(?:^|\/)pages\/[^/]+$/,
36
37
  blog: /(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,
@@ -41,17 +42,17 @@ const t = {
41
42
  accountWildcard: /^\/account\/.+/,
42
43
  accountLogin: /^\/account\/login(?:\/|$)/,
43
44
  accountRegister: /^\/account\/register(?:\/|$)/
44
- }, n = (e, o) => o ? !!e.exec(o.pathname) : !1, a = (e, o) => {
45
- if (o) {
46
- const i = e.exec(o.pathname);
45
+ }, n = (e, t) => t ? !!e.exec(t.pathname) : !1, c = (e, t) => {
46
+ if (t) {
47
+ const i = e.exec(t.pathname);
47
48
  if (i)
48
49
  return i[1];
49
50
  }
50
51
  }, p = (e) => {
51
- var o, i;
52
+ var t, i;
52
53
  switch (e) {
53
54
  case "product":
54
- return ((o = s()) == null ? void 0 : o.handle) ?? !1;
55
+ return ((t = s()) == null ? void 0 : t.handle) ?? !1;
55
56
  case "collection":
56
57
  return ((i = u()) == null ? void 0 : i.handle) ?? !1;
57
58
  default:
@@ -59,8 +60,8 @@ const t = {
59
60
  }
60
61
  }, g = {
61
62
  // Pages
62
- "is-page": ({ location: e }) => n(t.page, e),
63
- "get-page-handle": ({ location: e }) => a(t.page, e),
63
+ "is-page": ({ location: e }) => n(o.page, e),
64
+ "get-page-handle": ({ location: e }) => c(o.page, e),
64
65
  // Products
65
66
  "is-product-page": () => !!p("product"),
66
67
  "get-product-handle": () => p("product"),
@@ -68,24 +69,24 @@ const t = {
68
69
  "is-collection-page": () => !!p("collection"),
69
70
  "get-collection-handle": () => p("collection"),
70
71
  // Blogs
71
- "is-blog-page": ({ location: e }) => n(t.blog, e),
72
- "get-blog-handle": ({ location: e }) => a(t.blog, e),
72
+ "is-blog-page": ({ location: e }) => n(o.blog, e),
73
+ "get-blog-handle": ({ location: e }) => c(o.blog, e),
73
74
  // Blog Articles
74
- "is-article-page": ({ location: e }) => n(t.article, e),
75
- "get-article-handle": ({ location: e }) => a(t.article, e),
75
+ "is-article-page": ({ location: e }) => n(o.article, e),
76
+ "get-article-handle": ({ location: e }) => c(o.article, e),
76
77
  // Apps
77
- "is-app-proxy-page": ({ location: e }) => n(t.appProxy, e),
78
- "get-app-proxy-handle": ({ location: e }) => a(t.appProxy, e),
78
+ "is-app-proxy-page": ({ location: e }) => n(o.appProxy, e),
79
+ "get-app-proxy-handle": ({ location: e }) => c(o.appProxy, e),
79
80
  // Account
80
- "is-account-page": ({ location: e }) => n(t.accountWildcard, e),
81
- "is-login-page": ({ location: e }) => n(t.accountLogin, e),
82
- "is-register-page": ({ location: e }) => n(t.accountRegister, e),
81
+ "is-account-page": ({ location: e }) => n(o.accountWildcard, e),
82
+ "is-login-page": ({ location: e }) => n(o.accountLogin, e),
83
+ "is-register-page": ({ location: e }) => n(o.accountRegister, e),
83
84
  // Cart
84
- "is-cart-page": ({ location: e }) => n(t.cart, e),
85
+ "is-cart-page": ({ location: e }) => n(o.cart, e),
85
86
  // Checkout
86
- "is-checkout-page": ({ location: e }) => n(t.checkout, e),
87
+ "is-checkout-page": ({ location: e }) => n(o.checkout, e),
87
88
  // Homepage
88
- "is-homepage": ({ location: e }) => n(t.homepage, e)
89
+ "is-homepage": ({ location: e }) => n(o.homepage, e)
89
90
  };
90
91
  function l() {
91
92
  if (!r() || !window.Shopify)
@@ -95,28 +96,28 @@ function l() {
95
96
  return window.Shopify;
96
97
  }
97
98
  function f(e) {
98
- var o, i;
99
- return typeof ((i = (o = l()) == null ? void 0 : o.analytics) == null ? void 0 : i.publish) == "function";
99
+ var t, i;
100
+ return typeof ((i = (t = l()) == null ? void 0 : t.analytics) == null ? void 0 : i.publish) == "function";
100
101
  }
101
- const b = () => ({
102
+ const w = () => ({
102
103
  name: "shopify",
103
104
  setup: (e) => {
104
- Object.entries(g).forEach(([o, i]) => {
105
- e.registerPredicate(`shopify-${o}`, i);
106
- }), r() && e.eventBus.watch((o) => {
107
- f() && o.type === "session" && window.Shopify.analytics.publish("picked:session", {
108
- id: o.id
105
+ Object.entries(g).forEach(([t, i]) => {
106
+ e.registerPredicate(`shopify-${t}`, i);
107
+ }), r() && e.eventBus.watch((t) => {
108
+ f() && t.type === "session" && window.Shopify.analytics.publish("picked:session", {
109
+ id: t.id
109
110
  });
110
111
  });
111
112
  }
112
113
  });
113
114
  export {
114
- c as getPickedConfig,
115
+ a as getPickedConfig,
115
116
  u as getPickedConfigCollection,
116
- w as getPickedConfigCustomer,
117
- k as getPickedConfigExperiments,
117
+ P as getPickedConfigCustomer,
118
+ b as getPickedConfigExperiments,
118
119
  s as getPickedConfigProduct,
119
- P as getPickedConfigStorefrontApiToken,
120
+ k as getPickedConfigStorefrontApiToken,
120
121
  l as getShopify,
121
- b as shopifyPlugin
122
+ w as shopifyPlugin
122
123
  };
@@ -66,7 +66,7 @@ declare global {
66
66
  pickedConfig?: Readonly<Partial<CreateClientOptions> & ShopifyPickedConfig>;
67
67
  }
68
68
  }
69
- export declare function getPickedConfig(): Readonly<Partial<CreateClientOptions> & ShopifyPickedConfig>;
69
+ export declare function getPickedConfig(): Readonly<Partial<CreateClientOptions> & ShopifyPickedConfig> | undefined;
70
70
  export declare function getPickedConfigCustomer(): Partial<{
71
71
  accepts_marketing: boolean;
72
72
  email: string;
@@ -1 +1 @@
1
- {"version":3,"file":"picked-config.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/picked-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE,OAAO,CAAA;IAGhB,EAAE,EAAE,MAAM,CAAA;IAGV,IAAI,EAAE,MAAM,CAAA;IAGZ,OAAO,EAAE,MAAM,CAAA;IAGf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,kBAAkB,EAAE,MAAM,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEF,MAAM,MAAM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B,CAAA;IAC7B,UAAU,CAAC,EAAE,sBAAsB,CAAA;IACnC,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAA;IACtC,cAAc,CAAC,EAAE;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC,CAAA;KAC5E;CACF;AAED,wBAAgB,eAAe,iEAQ9B;AAED,wBAAgB,uBAAuB;uBArClB,OAAO;WACnB,MAAM;gBACD,MAAM,GAAG,IAAI;iBACZ,OAAO;QAChB,MAAM;eACC,MAAM,GAAG,IAAI;kBACV,MAAM;WACb,MAAM,GAAG,IAAI;gBACR,OAAO;eAmCpB;AAED,wBAAgB,sBAAsB;eA7DzB,OAAO;iBACL,6BAA6B,EAAE;oBAC5B,MAAM;YACd,MAAM;QACV,MAAM;gBACE,eAAe;WACpB,MAAM;UACP,MAAM,EAAE;WACP,MAAM;UACP,MAAM;SACP,MAAM;cACD,0BAA0B,EAAE;YAC9B,MAAM;eAuDf;AAED,wBAAgB,yBAAyB;WA9FhC,MAAM;QACT,MAAM;YACF,MAAM;eAkGf;AAED,wBAAgB,0BAA0B,yCAMzC;AAED,wBAAgB,iCAAiC,uBAMhD"}
1
+ {"version":3,"file":"picked-config.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shopify/picked-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE,OAAO,CAAA;IAGhB,EAAE,EAAE,MAAM,CAAA;IAGV,IAAI,EAAE,MAAM,CAAA;IAGZ,OAAO,EAAE,MAAM,CAAA;IAGf,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC;IAC3C,KAA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,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.1-dev.1763359305886",
3
+ "version": "0.0.1-dev.1763361588231",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },