@personizely/shopify-hydrogen 1.0.2 → 1.0.3
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/README.md +36 -4
- package/dist/index.cjs +1 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +1 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -192,7 +192,7 @@ React context provider for Personizely integration.
|
|
|
192
192
|
| `market` | `string` | ❌ | Market handle for international stores |
|
|
193
193
|
| `apiVersion` | `string` | ❌ | Storefront API version (default: `'2024-01'`) |
|
|
194
194
|
| `methods` | `object` | ❌ | Custom method overrides (see below) |
|
|
195
|
-
| `
|
|
195
|
+
| `customer` | `Customer \| null` | ❌ | Customer object for personalization |
|
|
196
196
|
|
|
197
197
|
**Currency Configuration:**
|
|
198
198
|
```tsx
|
|
@@ -245,7 +245,7 @@ methods={{
|
|
|
245
245
|
},
|
|
246
246
|
builtProductPath: ({ handle }) => `/shop/${handle}`
|
|
247
247
|
}}
|
|
248
|
-
|
|
248
|
+
customer={customer}
|
|
249
249
|
>
|
|
250
250
|
{children}
|
|
251
251
|
</PersonizelyProvider>
|
|
@@ -393,6 +393,12 @@ const itemCount = cart.getSize()
|
|
|
393
393
|
// Access adapter methods
|
|
394
394
|
const formattedPrice = adapter.formatMoney(1999, true) // "$19.99"
|
|
395
395
|
const productUrl = adapter.buildProductPath({ handle: 'my-product' })
|
|
396
|
+
|
|
397
|
+
// Get customer data (returns what was set via the customer prop)
|
|
398
|
+
const customer = adapter.getCustomer()
|
|
399
|
+
if (customer) {
|
|
400
|
+
console.log('Customer:', customer.displayName, customer.tags)
|
|
401
|
+
}
|
|
396
402
|
```
|
|
397
403
|
|
|
398
404
|
## Advanced Usage
|
|
@@ -452,17 +458,29 @@ export default function App() {
|
|
|
452
458
|
|
|
453
459
|
### Authenticated Customers
|
|
454
460
|
|
|
461
|
+
Pass customer data directly to enable customer-specific personalization:
|
|
462
|
+
|
|
455
463
|
```tsx
|
|
456
464
|
export default function App() {
|
|
457
465
|
const data = useRouteLoaderData<RootLoader>('root')
|
|
458
|
-
|
|
466
|
+
|
|
467
|
+
// Get customer data from your loader or Hydrogen's customer account
|
|
468
|
+
const customer = data.customer ? {
|
|
469
|
+
id: data.customer.id,
|
|
470
|
+
email: data.customer.email,
|
|
471
|
+
firstName: data.customer.firstName,
|
|
472
|
+
lastName: data.customer.lastName,
|
|
473
|
+
displayName: data.customer.displayName,
|
|
474
|
+
hasAccount: true,
|
|
475
|
+
tags: data.customer.tags || []
|
|
476
|
+
} : null
|
|
459
477
|
|
|
460
478
|
return (
|
|
461
479
|
<PersonizelyProvider
|
|
462
480
|
websiteApiKey="your-api-key"
|
|
463
481
|
storefrontAccessToken={data.personizely.storefrontAccessToken}
|
|
464
482
|
shopDomain={data.personizely.shopDomain}
|
|
465
|
-
|
|
483
|
+
customer={customer}
|
|
466
484
|
>
|
|
467
485
|
{children}
|
|
468
486
|
</PersonizelyProvider>
|
|
@@ -470,6 +488,20 @@ export default function App() {
|
|
|
470
488
|
}
|
|
471
489
|
```
|
|
472
490
|
|
|
491
|
+
**Customer Type:**
|
|
492
|
+
```tsx
|
|
493
|
+
type Customer = {
|
|
494
|
+
id: string
|
|
495
|
+
email?: string | null
|
|
496
|
+
phone?: string | null
|
|
497
|
+
firstName?: string | null
|
|
498
|
+
lastName?: string | null
|
|
499
|
+
displayName: string
|
|
500
|
+
hasAccount: boolean
|
|
501
|
+
tags: string[]
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
473
505
|
### Custom Product URLs
|
|
474
506
|
|
|
475
507
|
```tsx
|
package/dist/index.cjs
CHANGED
|
@@ -255,145 +255,5 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
${C}
|
|
258
|
-
`,D
|
|
259
|
-
fragment CustomerFragment on Customer {
|
|
260
|
-
id
|
|
261
|
-
email
|
|
262
|
-
phone
|
|
263
|
-
firstName
|
|
264
|
-
lastName
|
|
265
|
-
displayName
|
|
266
|
-
defaultAddress {
|
|
267
|
-
id
|
|
268
|
-
address1
|
|
269
|
-
address2
|
|
270
|
-
city
|
|
271
|
-
province
|
|
272
|
-
country
|
|
273
|
-
zip
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
`,O=`
|
|
277
|
-
fragment OrderFragment on Order {
|
|
278
|
-
id
|
|
279
|
-
orderNumber
|
|
280
|
-
processedAt
|
|
281
|
-
financialStatus
|
|
282
|
-
fulfillmentStatus
|
|
283
|
-
totalPrice {
|
|
284
|
-
amount
|
|
285
|
-
currencyCode
|
|
286
|
-
}
|
|
287
|
-
lineItems(first: 100) {
|
|
288
|
-
nodes {
|
|
289
|
-
title
|
|
290
|
-
quantity
|
|
291
|
-
variant {
|
|
292
|
-
id
|
|
293
|
-
title
|
|
294
|
-
price {
|
|
295
|
-
amount
|
|
296
|
-
currencyCode
|
|
297
|
-
}
|
|
298
|
-
image {
|
|
299
|
-
url
|
|
300
|
-
altText
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
`,k=`
|
|
307
|
-
query getCustomer($customerAccessToken: String!) {
|
|
308
|
-
customer(customerAccessToken: $customerAccessToken) {
|
|
309
|
-
...CustomerFragment
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
fragment CustomerFragment on Customer {
|
|
314
|
-
id
|
|
315
|
-
email
|
|
316
|
-
phone
|
|
317
|
-
firstName
|
|
318
|
-
lastName
|
|
319
|
-
displayName
|
|
320
|
-
defaultAddress {
|
|
321
|
-
id
|
|
322
|
-
address1
|
|
323
|
-
address2
|
|
324
|
-
city
|
|
325
|
-
province
|
|
326
|
-
country
|
|
327
|
-
zip
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
`,A=`
|
|
332
|
-
query getCustomerOrders($customerAccessToken: String!, $first: Int = 20) {
|
|
333
|
-
customer(customerAccessToken: $customerAccessToken) {
|
|
334
|
-
id
|
|
335
|
-
orders(first: $first, sortKey: PROCESSED_AT, reverse: true) {
|
|
336
|
-
nodes {
|
|
337
|
-
...OrderFragment
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
fragment OrderFragment on Order {
|
|
344
|
-
id
|
|
345
|
-
orderNumber
|
|
346
|
-
processedAt
|
|
347
|
-
financialStatus
|
|
348
|
-
fulfillmentStatus
|
|
349
|
-
totalPrice {
|
|
350
|
-
amount
|
|
351
|
-
currencyCode
|
|
352
|
-
}
|
|
353
|
-
lineItems(first: 100) {
|
|
354
|
-
nodes {
|
|
355
|
-
title
|
|
356
|
-
quantity
|
|
357
|
-
variant {
|
|
358
|
-
id
|
|
359
|
-
title
|
|
360
|
-
price {
|
|
361
|
-
amount
|
|
362
|
-
currencyCode
|
|
363
|
-
}
|
|
364
|
-
image {
|
|
365
|
-
url
|
|
366
|
-
altText
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
`;var j=class{constructor(e,t){this.customerAccessToken=null,this.client=t,this.methods=e.methods,this.currency={active:`USD`,base:`USD`,rate:1,...e.currency},this.locale=e.locale||`en-US`,this.market=e.market||null,this.pageContext={pageType:void 0,product:null,collection:null}}setCustomerAccessToken(e){this.customerAccessToken=e}async fetchProduct(e){let t=await this.client.query(w,{handle:e});if(!t.product)throw Error(`Product not found: ${e}`);return this.toProductData(t.product)}async fetchProductCollections(e,t){let n;if(t?n=await this.client.query(T,{id:`gid://shopify/Product/${t}`}):e&&(n=await this.client.query(w,{handle:e})),!n||!n.product)throw Error(`Product not found: ${t}`);return n.product.collections.nodes.map(e=>b(e.id))}async fetchRecommendations(e,t){return{intent:t,products:(await this.client.query(E,{productId:`gid://shopify/Product/${e}`,intent:t})).productRecommendations.map(e=>this.toProductData(e))||[]}}buildProductPath(e){return typeof this.methods?.builtProductPath==`function`?this.methods.builtProductPath(e):`/products/${e.handle}`}convertToBaseCurrency(e){return this.currency.rate/e}convertFromBaseCurrency(e){return this.currency.rate*e}formatMoney(e,t=!0){return typeof this.methods?.formatMoney==`function`?this.methods.formatMoney(e,t):new Intl.NumberFormat(this.locale,{style:`currency`,currency:this.currency.active,maximumFractionDigits:t?void 0:0}).format(e/100)}async getCustomer(){if(!this.customerAccessToken)return null;try{return(await this.client.query(`
|
|
374
|
-
query getCustomer($customerAccessToken: String!) {
|
|
375
|
-
customer(customerAccessToken: $customerAccessToken) {
|
|
376
|
-
...CustomerFragment
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
fragment CustomerFragment on Customer {
|
|
381
|
-
id
|
|
382
|
-
email
|
|
383
|
-
phone
|
|
384
|
-
firstName
|
|
385
|
-
lastName
|
|
386
|
-
displayName
|
|
387
|
-
defaultAddress {
|
|
388
|
-
id
|
|
389
|
-
address1
|
|
390
|
-
address2
|
|
391
|
-
city
|
|
392
|
-
province
|
|
393
|
-
country
|
|
394
|
-
zip
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
`,{customerAccessToken:this.customerAccessToken})).customer||null}catch(e){return console.error(`Error fetching customer:`,e),null}}getPageContext(){return this.pageContext}setPageContext(e){e.product&&(e.product.id=b(String(e.product.id))),e.collection&&(e.collection.id=b(String(e.collection.id))),this.pageContext=e}getVisitorId(){return null}getMarket(){return this.market}getCurrencyRate(){return this.currency.rate}toProductData(e){return{id:b(e.id),handle:e.handle,title:e.title,available:e.availableForSale,requires_selling_plan:e.requiresSellingPlan,images:e.images.nodes.map(e=>e.url),variants:e.variants.nodes.map(e=>({id:b(e.id),title:e.title,available:e.availableForSale,price:Math.round(parseFloat(e.price.amount)*100),compare_at_price:e.compareAtPrice?Math.round(parseFloat(e.compareAtPrice.amount)*100):null,featured_image:e.image?{src:e.image.url}:null,selling_plan_allocations:e.sellingPlanAllocations?.edges?.map(e=>({selling_plan_id:e.node.sellingPlan.id}))||[]}))}}},M=class{constructor(e){this.storefrontAccessToken=e.storefrontAccessToken,this.shopDomain=e.shopDomain,this.apiVersion=e.apiVersion||`2024-01`,this.endpoint=`https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`}async query(e,t){try{let n=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:t})});if(!n.ok)throw Error(`Storefront API request failed: ${n.statusText}`);let r=await n.json();if(r.errors)throw Error(`GraphQL errors: ${JSON.stringify(r.errors)}`);return r.data}catch(e){throw console.error(`Storefront API error:`,e),e}}async mutate(e,t){return this.query(e,t)}};const N=(0,c.createContext)(null);function P({websiteApiKey:e,storefrontAccessToken:t,shopDomain:n,locale:r,currency:i,market:a,apiVersion:o,scriptBaseUrl:s,methods:u,children:d,customerAccessToken:f}){let p=(0,l.useMatches)().find(e=>e.id===`root`)?.loaderData?.cart,m=(0,l.useRevalidator)(),h=(0,c.useMemo)(()=>new M({storefrontAccessToken:t,shopDomain:n,apiVersion:o}),[t,n,o]),g=(0,c.useMemo)(()=>{let e=new j({locale:r,currency:i,market:a,methods:u},h);return f&&e.setCustomerAccessToken(f),e},[]),_=(0,c.useMemo)(()=>new S(p,h,m.revalidate),[]),v=(0,c.useRef)(null);(0,c.useEffect)(()=>{p.then(e=>{e&&e!==v.current&&(_.updateCartData(e),_.notifyListeners(),v.current=e)})},[p,_]);let y=(0,c.useRef)([]),b=(0,c.useRef)([]);(0,c.useEffect)(()=>{if(typeof window>`u`)return;window.__PLY_HYDROGEN_CONFIG__={cart:_,adapter:g,onCartAdd:e=>(y.current.push(e),()=>{let t=y.current.indexOf(e);t>-1&&y.current.splice(t,1)}),onCheckout:e=>(b.current.push(e),()=>{let t=b.current.indexOf(e);t>-1&&b.current.splice(t,1)})};let t=document.createElement(`script`);return t.src=`${s||`https://static.personizely.net`}/${e}.js`,document.head.appendChild(t),()=>{delete window.__PLY_HYDROGEN_CONFIG__,t&&t.remove()}},[]);let x=(0,c.useMemo)(()=>({cart:_,adapter:g,websiteApiKey:e,triggerCartAdd:async e=>{let t=!1;for(let n of y.current)try{await n(e)&&(t=!0)}catch(e){console.error(`Cart add callback error:`,e)}return t},triggerCheckout:async()=>{let e=!1;for(let t of b.current)try{await t()&&(e=!0)}catch(e){console.error(`Checkout callback error:`,e)}return e}}),[_,g,e]);return c.default.createElement(N.Provider,{value:x},d)}function F(){let e=(0,c.useContext)(N);if(!e)throw Error(`usePersonizely must be used within a PersonizelyProvider. Make sure your component is wrapped with <PersonizelyProvider>.`);return e}function I(){let e=F();return(0,c.useCallback)(async t=>typeof window>`u`?!1:await e.triggerCartAdd({...t,id:b(String(t.id)),variantId:b(String(t.variantId)),price:Number(t.price)*100}),[e])}function L(){let e=F();return(0,c.useCallback)(async()=>typeof window>`u`?!1:await e.triggerCheckout(),[e])}function R(e){F().adapter.setPageContext(e)}exports.Adapter=j,exports.Cart=S,exports.PersonizelyProvider=P,exports.useCartAdd=I,exports.useCheckout=L,exports.usePageContext=R,exports.usePersonizely=F;
|
|
258
|
+
`;var D=class{constructor(e,t){this.customer=null,this.client=t,this.methods=e.methods,this.currency={active:`USD`,base:`USD`,rate:1,...e.currency},this.locale=e.locale||`en-US`,this.market=e.market||null,this.pageContext={pageType:void 0,product:null,collection:null}}setCustomer(e){this.customer=e}async fetchProduct(e){let t=await this.client.query(w,{handle:e});if(!t.product)throw Error(`Product not found: ${e}`);return this.toProductData(t.product)}async fetchProductCollections(e,t){let n;if(t?n=await this.client.query(T,{id:`gid://shopify/Product/${t}`}):e&&(n=await this.client.query(w,{handle:e})),!n||!n.product)throw Error(`Product not found: ${t}`);return n.product.collections.nodes.map(e=>b(e.id))}async fetchRecommendations(e,t){return{intent:t,products:(await this.client.query(E,{productId:`gid://shopify/Product/${e}`,intent:t})).productRecommendations.map(e=>this.toProductData(e))||[]}}buildProductPath(e){return typeof this.methods?.builtProductPath==`function`?this.methods.builtProductPath(e):`/products/${e.handle}`}convertToBaseCurrency(e){return this.currency.rate/e}convertFromBaseCurrency(e){return this.currency.rate*e}formatMoney(e,t=!0){return typeof this.methods?.formatMoney==`function`?this.methods.formatMoney(e,t):new Intl.NumberFormat(this.locale,{style:`currency`,currency:this.currency.active,maximumFractionDigits:t?void 0:0}).format(e/100)}getCustomer(){return this.customer}getPageContext(){return this.pageContext}setPageContext(e){e.product&&(e.product.id=b(String(e.product.id))),e.collection&&(e.collection.id=b(String(e.collection.id))),this.pageContext=e}getVisitorId(){return null}getMarket(){return this.market}getCurrencyRate(){return this.currency.rate}toProductData(e){return{id:b(e.id),handle:e.handle,title:e.title,available:e.availableForSale,requires_selling_plan:e.requiresSellingPlan,images:e.images.nodes.map(e=>e.url),variants:e.variants.nodes.map(e=>({id:b(e.id),title:e.title,available:e.availableForSale,price:Math.round(parseFloat(e.price.amount)*100),compare_at_price:e.compareAtPrice?Math.round(parseFloat(e.compareAtPrice.amount)*100):null,featured_image:e.image?{src:e.image.url}:null,selling_plan_allocations:e.sellingPlanAllocations?.edges?.map(e=>({selling_plan_id:e.node.sellingPlan.id}))||[]}))}}},O=class{constructor(e){this.storefrontAccessToken=e.storefrontAccessToken,this.shopDomain=e.shopDomain,this.apiVersion=e.apiVersion||`2024-01`,this.endpoint=`https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`}async query(e,t){try{let n=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:t})});if(!n.ok)throw Error(`Storefront API request failed: ${n.statusText}`);let r=await n.json();if(r.errors)throw Error(`GraphQL errors: ${JSON.stringify(r.errors)}`);return r.data}catch(e){throw console.error(`Storefront API error:`,e),e}}async mutate(e,t){return this.query(e,t)}};const k=(0,c.createContext)(null);function A({websiteApiKey:e,storefrontAccessToken:t,shopDomain:n,locale:r,currency:i,market:a,apiVersion:o,scriptBaseUrl:s,methods:u,children:d,customer:f}){let p=(0,l.useMatches)().find(e=>e.id===`root`)?.loaderData?.cart,m=(0,l.useRevalidator)(),h=(0,c.useMemo)(()=>new O({storefrontAccessToken:t,shopDomain:n,apiVersion:o}),[t,n,o]),g=(0,c.useMemo)(()=>new D({locale:r,currency:i,market:a,methods:u},h),[]);(0,c.useEffect)(()=>{f&&g.setCustomer(f)},[f,g]);let _=(0,c.useMemo)(()=>new S(p,h,m.revalidate),[]),v=(0,c.useRef)(null);(0,c.useEffect)(()=>{p.then(e=>{e&&e!==v.current&&(_.updateCartData(e),_.notifyListeners(),v.current=e)})},[p,_]);let y=(0,c.useRef)([]),b=(0,c.useRef)([]);(0,c.useEffect)(()=>{if(typeof window>`u`)return;window.__PLY_HYDROGEN_CONFIG__={cart:_,adapter:g,onCartAdd:e=>(y.current.push(e),()=>{let t=y.current.indexOf(e);t>-1&&y.current.splice(t,1)}),onCheckout:e=>(b.current.push(e),()=>{let t=b.current.indexOf(e);t>-1&&b.current.splice(t,1)})};let t=document.createElement(`script`);return t.src=`${s||`https://static.personizely.net`}/${e}.js`,document.head.appendChild(t),()=>{delete window.__PLY_HYDROGEN_CONFIG__,t&&t.remove()}},[]);let x=(0,c.useMemo)(()=>({cart:_,adapter:g,websiteApiKey:e,triggerCartAdd:async e=>{let t=!1;for(let n of y.current)try{await n(e)&&(t=!0)}catch(e){console.error(`Cart add callback error:`,e)}return t},triggerCheckout:async()=>{let e=!1;for(let t of b.current)try{await t()&&(e=!0)}catch(e){console.error(`Checkout callback error:`,e)}return e}}),[_,g,e]);return c.default.createElement(k.Provider,{value:x},d)}function j(){let e=(0,c.useContext)(k);if(!e)throw Error(`usePersonizely must be used within a PersonizelyProvider. Make sure your component is wrapped with <PersonizelyProvider>.`);return e}function M(){let e=j();return(0,c.useCallback)(async t=>typeof window>`u`?!1:await e.triggerCartAdd({...t,id:b(String(t.id)),variantId:b(String(t.variantId)),price:Number(t.price)*100}),[e])}function N(){let e=j();return(0,c.useCallback)(async()=>typeof window>`u`?!1:await e.triggerCheckout(),[e])}function P(e){j().adapter.setPageContext(e)}exports.Adapter=D,exports.Cart=S,exports.PersonizelyProvider=A,exports.useCartAdd=M,exports.useCheckout=N,exports.usePageContext=P,exports.usePersonizely=j;
|
|
399
259
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["result: any","linesToUpdate: any[]","linesToAdd: any[]","line","mutations: Promise<any>[]"],"sources":["../src/utils/cookies.ts","../src/graphql/queries/cart.ts","../src/utils/id.ts","../src/classes/Cart.ts","../src/graphql/queries/product.ts","../src/graphql/queries/customer.ts","../src/classes/Adapter.ts","../src/utils/storefront-client.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":["/**\n * Cookie utilities for browser storage\n * Mirrors cookie helpers from snippet-manager\n */\n\n/**\n * Read a cookie value by name\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n */\nexport function readCookie (name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const nameEQ = name + '='\n const cookies = document.cookie.split(';')\n\n for (let i = 0; i < cookies.length; i++) {\n let cookie = cookies[i]\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length)\n }\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length)\n }\n }\n\n return null\n}\n\n/**\n * Create/update a cookie\n * @param name - Cookie name\n * @param value - Cookie value\n * @param days - Expiration in days (optional, default: session cookie)\n * @param path - Cookie path (default: '/')\n */\nexport function createCookie (name: string,\n value: string,\n days?: number,\n path: string = '/'): void {\n if (typeof document === 'undefined') {\n return\n }\n\n let expires = ''\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))\n expires = '; expires=' + date.toUTCString()\n }\n\n document.cookie = name + '=' + value + expires + '; path=' + path\n}\n\n/**\n * Delete a cookie by name\n * @param name - Cookie name\n * @param path - Cookie path (default: '/')\n */\nexport function deleteCookie (name: string, path: string = '/'): void {\n createCookie(name, '', -1, path)\n}\n","/**\n * GraphQL queries and mutations for cart operations\n */\n\nexport const CART_FRAGMENT = `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n`\n\nexport const GET_CART = `\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n ${CART_FRAGMENT}\n`\n\n/**\n * Cart mutations\n */\n\nexport const CART_LINES_ADD = `\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_UPDATE = `\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_REMOVE = `\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_DISCOUNT_CODES_UPDATE = `\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_ATTRIBUTES_UPDATE = `\n mutation cartAttributesUpdate($cartId: ID!, $attributes: [AttributeInput!]!) {\n cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n","export function toGId (id: number, type: string): string {\n return `gid://shopify/${type}/${id}`\n}\n\nexport function toId (id: string): number {\n return Number(id.split('/').pop())\n}","import type { CartData, ICart } from '../types'\nimport { createCookie, readCookie } from '../utils/cookies'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n CART_LINES_ADD,\n CART_LINES_UPDATE,\n CART_LINES_REMOVE,\n CART_DISCOUNT_CODES_UPDATE,\n CART_ATTRIBUTES_UPDATE\n} from '../graphql/queries/cart'\nimport { toGId, toId } from '../utils/id'\n\nconst COUPON_COOKIE_NAME = '_ply_coupon'\n\nexport class Cart implements ICart {\n private storefrontClient: StorefrontClient\n\n private listeners: Array<(cart: CartData) => void> = []\n\n private cart: CartReturn | null = null\n\n private cartPromise: Promise<CartReturn> | null\n\n private revalidate?: () => void\n\n constructor (cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void) {\n this.storefrontClient = storefrontClient\n this.cartPromise = cartPromise\n this.revalidate = revalidate\n }\n\n /**\n * Update internal cart data\n * Called by Provider when cart data changes from loader\n */\n updateCartData (cart: CartReturn): void {\n this.cart = cart\n this.cartPromise = null\n }\n\n /**\n * Notify all listeners of cart change\n * Called by Provider when cart updates\n */\n notifyListeners (): void {\n if (!this.cart) return\n\n this.listeners.forEach((listener) => {\n try {\n if (this.cart) {\n listener(this.toCartData(this.cart))\n }\n } catch (error) {\n console.error('Cart listener error:', error)\n }\n })\n }\n\n /**\n * Check if cart data is loaded and synced\n */\n isSynced (): boolean {\n return !!this.cart\n }\n\n /**\n * Register a callback to be called when cart changes\n * Returns a function to unregister the callback\n */\n onChange (callback: (cart: CartData) => void): () => void {\n this.listeners.push(callback)\n\n // Return unsubscribe function\n return () => {\n const index = this.listeners.indexOf(callback)\n if (index > -1) {\n this.listeners.splice(index, 1)\n }\n }\n }\n\n /**\n * Fetch current cart data\n * Returns cached cart data from loader (always fresh from React Router)\n */\n async fetch (force: boolean = true): Promise<CartData | null> {\n if (this.cart && !force) {\n return this.toCartData(this.cart)\n }\n\n if (this.cartPromise) {\n this.cart = await this.cartPromise\n return this.toCartData(this.cart)\n }\n\n if (!this.cart) return null\n\n return this.toCartData(this.cart)\n }\n\n /**\n * Update cart via Storefront API mutations\n * Actions: 'add', 'update', 'change', 'clear'\n */\n async update (action: string, data: any): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n const lineIds = this.cart.lines.nodes.map((line: any) => line.id)\n\n try {\n let result: any\n\n switch (action) {\n case 'add':\n result = await this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: [{\n merchandiseId: toGId(data.id, 'ProductVariant'),\n quantity: data.quantity || 1,\n attributes: data.properties\n ? Object.entries(data.properties).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n : undefined\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesAdd?.cart) {\n this.cart = result.cartLinesAdd.cart\n this.notifyListeners()\n }\n break\n\n case 'update':\n case 'change':\n // Handle Cart AJAX API format: { updates: { [variantId]: quantity }, attributes: {...} }\n if (data.updates) {\n // Separate into lines to update vs lines to add\n const linesToUpdate: any[] = []\n const linesToAdd: any[] = []\n\n Object.entries(data.updates).forEach(([variantId, quantity]) => {\n const line = this.cart!.lines.nodes.find((line: any) =>\n toId(line.merchandise.id) === Number(variantId))\n\n if (line) {\n linesToUpdate.push({\n id: line.id,\n quantity: Number(quantity)\n })\n } else if (Number(quantity) > 0) {\n // Line doesn't exist and quantity > 0 - add it\n linesToAdd.push({\n merchandiseId: toGId(Number(variantId), 'ProductVariant'),\n quantity: Number(quantity)\n })\n }\n })\n\n // Execute mutations in parallel\n const mutations: Promise<any>[] = []\n\n if (linesToUpdate.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: linesToUpdate\n }))\n }\n\n if (linesToAdd.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: linesToAdd\n }))\n }\n\n if (mutations.length > 0) {\n const results = await Promise.all(mutations)\n // Use the last result's cart (both mutations return the updated cart)\n const lastResult = results[results.length - 1]\n if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {\n this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart\n this.notifyListeners()\n }\n }\n } else if (data.id) {\n // Handle single line item update\n result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: [{\n id: `gid://shopify/CartLine/${data.id}`,\n quantity: data.quantity\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesUpdate?.cart) {\n this.cart = result.cartLinesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle cart-level attributes update\n if (data.attributes && this.cart) {\n result = await this.storefrontClient.mutate(CART_ATTRIBUTES_UPDATE, {\n cartId: this.cart.id,\n attributes: Object.entries(data.attributes).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n })\n\n // Update local cart immediately\n if (result?.cartAttributesUpdate?.cart) {\n this.cart = result.cartAttributesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle discount update\n if (data.discount && this.cart) {\n result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [data.discount]\n })\n\n // Update local cart immediately\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n }\n break\n\n case 'clear':\n result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {\n cartId: this.cart.id,\n lineIds\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesRemove?.cart) {\n this.cart = result.cartLinesRemove.cart\n this.notifyListeners()\n }\n break\n\n default:\n console.warn(`Unknown cart action: ${action}`)\n }\n\n // Trigger revalidation to fetch fresh cart data from loader\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Cart update error:', error)\n throw error\n }\n }\n\n /**\n * Quick buy - redirect to checkout with variant\n */\n async buy (_variantId: string, _quantity: number = 1): Promise<void> {\n if (!this.cart) return\n\n const coupon = this.getCoupon()\n const baseUrl = this.cart.checkoutUrl || '/checkout'\n const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl\n\n if (typeof window !== 'undefined') {\n window.location.href = url\n }\n }\n\n /**\n * Get cart data or specific property\n */\n get (property?: string): any {\n if (!this.cart) {\n return property ? undefined : null\n }\n\n if (!property) {\n return this.toCartData(this.cart)\n }\n\n return (this.toCartData(this.cart) as any)[property]\n }\n\n /**\n * Get cart token/ID\n */\n getToken (): string | null {\n if (!this.cart) return null\n\n return this.cart.id || null\n }\n\n /**\n * Get array of product IDs in cart\n */\n getItemsIds (): string[] {\n if (!this.cart) {\n return []\n }\n\n return this.cart.lines.nodes.map(line => line.merchandise.product.id)\n }\n\n /**\n * Get cart currency code\n */\n getCurrency (): string {\n if (!this.cart) return 'USD'\n\n return this.cart.cost.totalAmount.currencyCode\n }\n\n /**\n * Get cart total value\n * For Hydrogen, currency conversion would need to be handled separately\n */\n getValue (_currency?: string): number {\n if (!this.cart) return 0\n\n return parseFloat(this.cart.cost.totalAmount.amount) * 100\n }\n\n /**\n * Get cart item count\n * @param distinct - Count distinct products instead of total quantity\n */\n getSize (distinct: boolean = false): number {\n if (!this.cart) return 0\n\n if (distinct) {\n const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id))\n return uniqueProductIds.size\n }\n\n return this.cart.totalQuantity\n }\n\n /**\n * Fetch cart collections data\n * Requires custom implementation or metafield query\n */\n async fetchCollections (_force: boolean = false): Promise<any> {\n console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.')\n return {}\n }\n\n /**\n * Apply discount code to cart\n */\n async applyCoupon (code: string, expiresIn?: number): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n // Store in cookie\n createCookie(COUPON_COOKIE_NAME, code, expiresIn)\n\n try {\n const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [code]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n\n // Trigger revalidation to fetch fresh cart data from loader (backup)\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Error applying coupon:', error)\n throw error\n }\n }\n\n /**\n * Get currently applied coupon code\n */\n getCoupon (): string | null {\n if (!this.cart) return null\n\n // First check cart discount codes\n if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {\n return this.cart.discountCodes[0].code\n }\n\n // Fall back to cookie\n return readCookie(COUPON_COOKIE_NAME)\n }\n\n /**\n * Convert Hydrogen cart to CartData format\n * For compatibility with snippet-manager\n */\n private toCartData (cart: CartReturn): CartData {\n return {\n token: cart.id,\n item_count: cart.totalQuantity || 0,\n items: (cart.lines?.nodes || []).map(line => ({\n id: toId(line.id),\n product_id: toId(line.merchandise.product.id),\n variant_id: toId(line.merchandise.id),\n price: Number(line.merchandise.price.amount) * 100,\n quantity: line.quantity\n })),\n total_price: Number(cart.cost.totalAmount.amount) * 100,\n discount_codes: cart.discountCodes,\n attributes: cart.attributes,\n note: cart.note\n }\n }\n}\n","/**\n * GraphQL queries for product operations\n */\n\nexport const PRODUCT_FRAGMENT = `\n fragment ProductFragment on Product {\n id\n handle\n title\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n requiresSellingPlan\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n id\n url\n altText\n width\n height\n }\n images(first: 10) {\n nodes {\n id\n url\n altText\n width\n height\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n quantityAvailable\n sellingPlanAllocations(first: 10) {\n edges {\n node {\n sellingPlan {\n id\n }\n }\n }\n }\n sku\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n }\n options {\n id\n name\n values\n }\n collections(first: 10) {\n nodes {\n id\n handle\n title\n }\n }\n }\n`\n\nexport const GET_PRODUCT_BY_HANDLE = `\n query getProductByHandle($handle: String!) {\n product(handle: $handle) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_BY_ID = `\n query getProductById($id: ID!) {\n product(id: $id) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_RECOMMENDATIONS = `\n query getProductRecommendations($productId: ID!) {\n productRecommendations(productId: $productId) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n","/**\n * GraphQL queries for customer operations\n */\n\nexport const CUSTOMER_FRAGMENT = `\n fragment CustomerFragment on Customer {\n id\n email\n phone\n firstName\n lastName\n displayName\n defaultAddress {\n id\n address1\n address2\n city\n province\n country\n zip\n }\n }\n`\n\nexport const ORDER_FRAGMENT = `\n fragment OrderFragment on Order {\n id\n orderNumber\n processedAt\n financialStatus\n fulfillmentStatus\n totalPrice {\n amount\n currencyCode\n }\n lineItems(first: 100) {\n nodes {\n title\n quantity\n variant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n }\n }\n }\n }\n`\n\nexport const GET_CUSTOMER = `\n query getCustomer($customerAccessToken: String!) {\n customer(customerAccessToken: $customerAccessToken) {\n ...CustomerFragment\n }\n }\n ${CUSTOMER_FRAGMENT}\n`\n\nexport const GET_CUSTOMER_ORDERS = `\n query getCustomerOrders($customerAccessToken: String!, $first: Int = 20) {\n customer(customerAccessToken: $customerAccessToken) {\n id\n orders(first: $first, sortKey: PROCESSED_AT, reverse: true) {\n nodes {\n ...OrderFragment\n }\n }\n }\n }\n ${ORDER_FRAGMENT}\n`\n","import type {\n IShopifyAdapter,\n Product,\n Customer,\n PageContext,\n PersonizelyConfig,\n PersonizelyConfigMethods,\n ProductData\n} from '../types'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID,\n GET_PRODUCT_RECOMMENDATIONS\n} from '../graphql/queries/product'\nimport { GET_CUSTOMER } from '../graphql/queries/customer'\nimport { toId } from '../utils/id'\n\nexport class Adapter implements IShopifyAdapter {\n private client: StorefrontClient\n\n private currency: {\n active: string\n base: string\n rate: number\n }\n\n private market: string | null\n\n private locale: string\n\n private pageContext: PageContext\n\n private methods?: PersonizelyConfigMethods\n\n private customerAccessToken: string | null = null\n\n constructor (config: PersonizelyConfig, storefrontClient: StorefrontClient) {\n this.client = storefrontClient\n\n this.methods = config.methods\n this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency }\n this.locale = config.locale || 'en-US'\n this.market = config.market || null\n\n this.pageContext = {\n pageType: undefined,\n product: null,\n collection: null\n }\n }\n\n /**\n * Set customer access token for authenticated requests\n */\n setCustomerAccessToken (token: string | null): void {\n this.customerAccessToken = token\n }\n\n /**\n * Fetch product by handle from Storefront API\n */\n async fetchProduct (handle: string): Promise<ProductData> {\n const data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n\n if (!data.product) {\n throw new Error(`Product not found: ${handle}`)\n }\n\n return this.toProductData(data.product)\n }\n\n /**\n * Fetch product collections metadata\n */\n async fetchProductCollections (handle: string, productId: number): Promise<number[]> {\n let data\n if (productId) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` })\n } else if (handle) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n }\n\n if (!data || !data.product) {\n throw new Error(`Product not found: ${productId}`)\n }\n\n return data.product.collections.nodes.map(c => toId(c.id))\n }\n\n /**\n * Fetch product recommendations\n */\n async fetchRecommendations (productId: number, intent: string): Promise<{ products: ProductData[], intent: string }> {\n const data = await this.client.query<{ productRecommendations: Product[] }>(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent })\n\n return {\n intent,\n products: data.productRecommendations.map(p => this.toProductData(p)) || []\n }\n }\n\n /**\n * Build product URL path\n */\n buildProductPath (product: { handle: string }): string {\n if (typeof this.methods?.builtProductPath !== 'function') return `/products/${product.handle}`\n\n return this.methods.builtProductPath(product)\n }\n\n /**\n * Convert currency amount\n */\n convertToBaseCurrency (amount: number): number {\n return this.currency.rate / amount\n }\n\n /**\n * Convert currency amount\n */\n convertFromBaseCurrency (amount: number): number {\n return this.currency.rate * amount\n }\n\n /**\n * Format money according to shop's format\n */\n formatMoney (amount: number, includeDecimals: boolean = true): string {\n if (typeof this.methods?.formatMoney !== 'function') return new Intl.NumberFormat(this.locale, {\n style: 'currency',\n currency: this.currency.active,\n maximumFractionDigits: includeDecimals ? undefined : 0\n }).format(amount / 100)\n\n return this.methods.formatMoney(amount, includeDecimals)\n }\n\n /**\n * Fetch customer data from Storefront API\n * Requires customer access token to be set\n */\n async getCustomer (): Promise<Customer | null> {\n if (!this.customerAccessToken) {\n return null\n }\n\n try {\n const data = await this.client.query<{ customer: Customer }>(GET_CUSTOMER, { customerAccessToken: this.customerAccessToken })\n\n return data.customer || null\n } catch (error) {\n console.error('Error fetching customer:', error)\n return null\n }\n }\n\n /**\n * Get current page context\n * Auto-detected from Remix router in Provider\n */\n getPageContext (): PageContext {\n return this.pageContext\n }\n\n setPageContext (context: Partial<PageContext>) {\n if (context.product) {\n context.product.id = toId(String(context.product.id))\n }\n if (context.collection) {\n context.collection.id = toId(String(context.collection.id))\n }\n this.pageContext = context\n }\n\n getVisitorId (): string | null {\n return null\n }\n\n /**\n * Get current market information\n */\n getMarket (): string | null {\n return this.market\n }\n\n /**\n * Get currency conversion rate\n * Note: Stub implementation\n */\n getCurrencyRate (): number {\n return this.currency.rate\n }\n\n /**\n * Transform Hydrogen Product to snippet-manager ProductData format\n */\n toProductData (product: Product): ProductData {\n return {\n id: toId(product.id),\n handle: product.handle,\n title: product.title,\n available: product.availableForSale,\n requires_selling_plan: product.requiresSellingPlan,\n images: product.images.nodes.map(img => img.url),\n variants: product.variants.nodes.map(variant => ({\n id: toId(variant.id),\n title: variant.title,\n available: variant.availableForSale,\n price: Math.round(parseFloat(variant.price.amount) * 100), // Convert to cents\n compare_at_price: variant.compareAtPrice\n ? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)\n : null,\n featured_image: variant.image ? { src: variant.image.url } : null,\n selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({\n selling_plan_id: edge.node.sellingPlan.id\n })) || []\n }))\n }\n }\n}\n","/**\n * Shopify Storefront API GraphQL client\n */\n\nexport type StorefrontClientConfig = {\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n}\n\nexport class StorefrontClient {\n private storefrontAccessToken: string\n\n private shopDomain: string\n\n private apiVersion: string\n\n private endpoint: string\n\n constructor (config: StorefrontClientConfig) {\n this.storefrontAccessToken = config.storefrontAccessToken\n this.shopDomain = config.shopDomain\n this.apiVersion = config.apiVersion || '2024-01'\n this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`\n }\n\n /**\n * Execute a GraphQL query against the Storefront API\n */\n async query<T = any>(query: string, variables?: Record<string, any>): Promise<T> {\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken\n },\n body: JSON.stringify({\n query,\n variables\n })\n })\n\n if (!response.ok) {\n throw new Error(`Storefront API request failed: ${response.statusText}`)\n }\n\n const result = await response.json()\n\n if (result.errors) {\n throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`)\n }\n\n return result.data as T\n } catch (error) {\n console.error('Storefront API error:', error)\n throw error\n }\n }\n\n /**\n * Execute a GraphQL mutation against the Storefront API\n */\n async mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T> {\n return this.query<T>(mutation, variables)\n }\n}\n","import React, { createContext, useEffect, useMemo, useRef, ReactNode } from 'react'\nimport { useMatches, useRevalidator } from 'react-router'\nimport {\n PersonizelyConfigMethods,\n HydrogenConfig,\n CartAddProduct\n} from '../types'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { Cart } from '../classes/Cart'\nimport { Adapter } from '../classes/Adapter'\nimport { StorefrontClient } from '../utils/storefront-client'\n\ndeclare global {\n interface Window {\n __PLY_HYDROGEN_CONFIG__?: HydrogenConfig\n }\n}\n\nexport type PersonizelyContextType = {\n cart: Cart\n adapter: Adapter\n websiteApiKey: string\n triggerCartAdd: (product: CartAddProduct) => Promise<boolean>\n triggerCheckout: () => Promise<boolean>\n}\n\nexport const PersonizelyContext = createContext<PersonizelyContextType | null>(null)\n\nexport type PersonizelyProviderProps = {\n websiteApiKey: string\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n scriptBaseUrl?: string\n locale?: string\n currency?: {\n rate: number\n active: string\n base: string\n }\n market?: string\n methods?: PersonizelyConfigMethods\n children: ReactNode\n /**\n * Optional: Customer access token for authenticated requests\n */\n customerAccessToken?: string | null\n}\n\nexport function PersonizelyProvider ({\n websiteApiKey,\n storefrontAccessToken,\n shopDomain,\n locale,\n currency,\n market,\n apiVersion,\n scriptBaseUrl,\n methods,\n children,\n customerAccessToken\n}: PersonizelyProviderProps) {\n const matches = useMatches()\n const rootMatch = matches.find(m => m.id === 'root')\n const localCart = (rootMatch?.loaderData as any)?.cart as Promise<CartReturn>\n const revalidator = useRevalidator()\n\n const storefrontClient = useMemo(() => {\n return new StorefrontClient({\n storefrontAccessToken,\n shopDomain,\n apiVersion\n })\n }, [storefrontAccessToken, shopDomain, apiVersion])\n\n const adapter = useMemo(() => {\n const adapterInstance = new Adapter({\n locale,\n currency,\n market,\n methods\n }, storefrontClient)\n\n if (customerAccessToken) {\n adapterInstance.setCustomerAccessToken(customerAccessToken)\n }\n\n return adapterInstance\n }, [])\n\n const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), [])\n\n // Update cart data when it changes from the loader\n const prevCartDataRef = useRef<CartReturn | null>(null)\n useEffect(() => {\n localCart.then((data) => {\n if (data && data !== prevCartDataRef.current) {\n cart.updateCartData(data)\n cart.notifyListeners()\n prevCartDataRef.current = data\n }\n })\n }, [localCart, cart])\n\n const cartAddCallbacksRef = useRef<Array<(product: CartAddProduct) => Promise<boolean>>>([])\n const checkoutCallbacksRef = useRef<Array<() => Promise<boolean>>>([])\n\n // Set up window.__PLY_HYDROGEN_CONFIG__ and load Personizely script\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n\n window.__PLY_HYDROGEN_CONFIG__ = {\n cart,\n adapter,\n onCartAdd: (callback) => {\n cartAddCallbacksRef.current.push(callback)\n\n return () => {\n const index = cartAddCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n cartAddCallbacksRef.current.splice(index, 1)\n }\n }\n },\n onCheckout: (callback) => {\n checkoutCallbacksRef.current.push(callback)\n\n return () => {\n const index = checkoutCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n checkoutCallbacksRef.current.splice(index, 1)\n }\n }\n }\n }\n\n const script = document.createElement('script')\n const baseUrl = scriptBaseUrl || 'https://static.personizely.net'\n script.src = `${baseUrl}/${websiteApiKey}.js`\n document.head.appendChild(script)\n\n return () => {\n delete window.__PLY_HYDROGEN_CONFIG__\n if (script) {\n script.remove()\n }\n }\n }, [])\n\n const contextValue = useMemo(() => ({\n cart,\n adapter,\n websiteApiKey,\n triggerCartAdd: async (product: CartAddProduct): Promise<boolean> => {\n let shown = false\n for (const callback of cartAddCallbacksRef.current) {\n try {\n const result = await callback(product)\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Cart add callback error:', error)\n }\n }\n return shown\n },\n triggerCheckout: async (): Promise<boolean> => {\n let shown = false\n for (const callback of checkoutCallbacksRef.current) {\n try {\n const result = await callback()\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Checkout callback error:', error)\n }\n }\n return shown\n }\n }), [cart, adapter, websiteApiKey])\n\n return (\n <PersonizelyContext.Provider value={contextValue}>\n {children}\n </PersonizelyContext.Provider>\n )\n}\n","/**\n * usePersonizely - Access Personizely context\n */\n\nimport { useContext } from 'react'\nimport { PersonizelyContext, PersonizelyContextType } from '../components/PersonizelyProvider'\n\n/**\n * Hook to access Personizely context\n * Provides access to cart, adapter, and configuration\n *\n * @returns PersonizelyContextType\n * @throws Error if used outside PersonizelyProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { cart, adapter } = usePersonizely()\n * // Use cart and adapter...\n * }\n * ```\n */\nexport function usePersonizely (): PersonizelyContextType {\n const context = useContext(PersonizelyContext)\n\n if (!context) {\n throw new Error('usePersonizely must be used within a PersonizelyProvider. ' +\n 'Make sure your component is wrapped with <PersonizelyProvider>.')\n }\n\n return context\n}\n","/**\n * useCartAdd - Hook to trigger Personizely cart add widgets\n */\n\nimport { useCallback } from 'react'\nimport type { CartAddProduct } from '../types'\nimport { usePersonizely } from './usePersonizely'\nimport { toId } from '../utils/id'\n\n/**\n * Hook to trigger Personizely cart add event\n * Call this when a product is being added to cart to show relevant widgets\n *\n * @returns Function to trigger cart add event\n *\n * @example\n * ```tsx\n * function ProductForm({ product, selectedVariant }) {\n * const triggerCartAdd = useCartAdd()\n *\n * const handleAddToCart = async () => {\n * const widgetShown = await triggerCartAdd({\n * id: product.id,\n * variantId: selectedVariant.id,\n * price: parseFloat(selectedVariant.price.amount),\n * quantity: 1,\n * handle: product.handle\n * })\n *\n * if (!widgetShown) {\n * await cart.linesAdd([{\n * merchandiseId: selectedVariant.id,\n * quantity: 1\n * }])\n * }\n * }\n *\n * return <button onClick={handleAddToCart}>Add to Cart</button>\n * }\n * ```\n */\nexport function useCartAdd () {\n const personizely = usePersonizely()\n\n return useCallback(async (product: CartAddProduct): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCartAdd({\n ...product,\n id: toId(String(product.id)),\n variantId: toId(String(product.variantId)),\n price: Number(product.price) * 100\n })\n }, [personizely])\n}\n","/**\n * useCheckout - Hook to trigger Personizely checkout widgets\n */\n\nimport { useCallback } from 'react'\nimport { usePersonizely } from './usePersonizely'\n\n/**\n * Hook to trigger Personizely checkout event\n * Call this when proceeding to checkout to show relevant widgets\n *\n * @returns Function to trigger checkout event\n *\n * @example\n * ```tsx\n * function CheckoutButton() {\n * const triggerCheckout = useCheckout()\n *\n * const handleCheckout = async () => {\n * const widgetShown = await triggerCheckout()\n *\n * if (!widgetShown) {\n * window.location.href = cart.checkoutUrl\n * }\n * }\n *\n * return <button onClick={handleCheckout}>Checkout</button>\n * }\n * ```\n */\nexport function useCheckout () {\n const personizely = usePersonizely()\n\n return useCallback(async (): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCheckout()\n }, [personizely])\n}\n","import { usePersonizely } from './usePersonizely'\nimport { PageContext } from '../types'\n\nexport function usePageContext (context: Partial<PageContext>) {\n const personizely = usePersonizely()\n\n personizely.adapter.setPageContext(context)\n}\n"],"mappings":"0hBAUA,SAAgB,EAAY,EAA6B,CACvD,GAAI,OAAO,SAAa,IACtB,OAAO,KAGT,IAAM,EAAS,EAAO,IAChB,EAAU,SAAS,OAAO,MAAM,IAAI,CAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAI,EAAS,EAAQ,GACrB,KAAO,EAAO,OAAO,EAAE,GAAK,KAC1B,EAAS,EAAO,UAAU,EAAG,EAAO,OAAO,CAE7C,GAAI,EAAO,QAAQ,EAAO,GAAK,EAC7B,OAAO,EAAO,UAAU,EAAO,OAAQ,EAAO,OAAO,CAIzD,OAAO,KAUT,SAAgB,EAAc,EAC5B,EACA,EACA,EAAe,IAAW,CAC1B,GAAI,OAAO,SAAa,IACtB,OAGF,IAAI,EAAU,GACd,GAAI,EAAM,CACR,IAAM,EAAO,IAAI,KACjB,EAAK,QAAQ,EAAK,SAAS,CAAI,EAAO,GAAK,GAAK,GAAK,IAAM,CAC3D,EAAU,aAAe,EAAK,aAAa,CAG7C,SAAS,OAAS,EAAO,IAAM,EAAQ,EAAU,UAAY,ECjD/D,MAAa,EAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8EhB,EAAW;;;;;;IAMpB,EAAc;EAOL,EAAiB;;;;;;;;;;;;IAY1B,EAAc;EAGL,EAAoB;;;;;;;;;;;;IAY7B,EAAc;EAGL,EAAoB;;;;;;;;;;;;IAY7B,EAAc;EAGL,EAA6B;;;;;;;;;;;;IAYtC,EAAc;EAGL,EAAyB;;;;;;;;;;;;IAYlC,EAAc;ECvKlB,SAAgB,EAAO,EAAY,EAAsB,CACvD,MAAO,iBAAiB,EAAK,GAAG,IAGlC,SAAgB,EAAM,EAAoB,CACxC,OAAO,OAAO,EAAG,MAAM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ACZ,IAAK,IAAM,KAAY,EAAqB,QAC1C,GAAI,CACa,MAAM,GAAU,GAE7B,EAAQ,UAEH,EAAO,CACd,QAAQ,MAAM,2BAA4B,EAAM,CAGpD,OAAO,GAEV,EAAG,CAAC,EAAM,EAAS,EAAc,CAAC,CAEnC,OACE,EAAA,QAAA,cAAC,EAAmB,SAAA,CAAS,MAAO,EAAA,CACjC,EAC2B,CCtKlC,SAAgB,GAA0C,CACxD,IAAM,GAAA,EAAA,EAAA,YAAqB,EAAmB,CAE9C,GAAI,CAAC,EACH,MAAU,MAAM,4HACoD,CAGtE,OAAO,ECWT,SAAgB,GAAc,CAC5B,IAAM,EAAc,GAAgB,CAEpC,OAAA,EAAA,EAAA,aAAmB,KAAO,IACpB,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,eAAe,CACtC,GAAG,EACH,GAAI,EAAK,OAAO,EAAQ,GAAG,CAAC,CAC5B,UAAW,EAAK,OAAO,EAAQ,UAAU,CAAC,CAC1C,MAAO,OAAO,EAAQ,MAAM,CAAG,IAChC,CAAC,CACD,CAAC,EAAY,CAAC,CCzBnB,SAAgB,GAAe,CAC7B,IAAM,EAAc,GAAgB,CAEpC,OAAA,EAAA,EAAA,aAAmB,SACb,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,iBAAiB,CACzC,CAAC,EAAY,CAAC,CCpCnB,SAAgB,EAAgB,EAA+B,CACzC,GAAgB,CAExB,QAAQ,eAAe,EAAQ"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["result: any","linesToUpdate: any[]","linesToAdd: any[]","line","mutations: Promise<any>[]"],"sources":["../src/utils/cookies.ts","../src/graphql/queries/cart.ts","../src/utils/id.ts","../src/classes/Cart.ts","../src/graphql/queries/product.ts","../src/classes/Adapter.ts","../src/utils/storefront-client.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":["/**\n * Cookie utilities for browser storage\n * Mirrors cookie helpers from snippet-manager\n */\n\n/**\n * Read a cookie value by name\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n */\nexport function readCookie (name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const nameEQ = name + '='\n const cookies = document.cookie.split(';')\n\n for (let i = 0; i < cookies.length; i++) {\n let cookie = cookies[i]\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length)\n }\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length)\n }\n }\n\n return null\n}\n\n/**\n * Create/update a cookie\n * @param name - Cookie name\n * @param value - Cookie value\n * @param days - Expiration in days (optional, default: session cookie)\n * @param path - Cookie path (default: '/')\n */\nexport function createCookie (name: string,\n value: string,\n days?: number,\n path: string = '/'): void {\n if (typeof document === 'undefined') {\n return\n }\n\n let expires = ''\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))\n expires = '; expires=' + date.toUTCString()\n }\n\n document.cookie = name + '=' + value + expires + '; path=' + path\n}\n\n/**\n * Delete a cookie by name\n * @param name - Cookie name\n * @param path - Cookie path (default: '/')\n */\nexport function deleteCookie (name: string, path: string = '/'): void {\n createCookie(name, '', -1, path)\n}\n","/**\n * GraphQL queries and mutations for cart operations\n */\n\nexport const CART_FRAGMENT = `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n`\n\nexport const GET_CART = `\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n ${CART_FRAGMENT}\n`\n\n/**\n * Cart mutations\n */\n\nexport const CART_LINES_ADD = `\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_UPDATE = `\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_REMOVE = `\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_DISCOUNT_CODES_UPDATE = `\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_ATTRIBUTES_UPDATE = `\n mutation cartAttributesUpdate($cartId: ID!, $attributes: [AttributeInput!]!) {\n cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n","export function toGId (id: number, type: string): string {\n return `gid://shopify/${type}/${id}`\n}\n\nexport function toId (id: string): number {\n return Number(id.split('/').pop())\n}","import type { CartData, ICart } from '../types'\nimport { createCookie, readCookie } from '../utils/cookies'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n CART_LINES_ADD,\n CART_LINES_UPDATE,\n CART_LINES_REMOVE,\n CART_DISCOUNT_CODES_UPDATE,\n CART_ATTRIBUTES_UPDATE\n} from '../graphql/queries/cart'\nimport { toGId, toId } from '../utils/id'\n\nconst COUPON_COOKIE_NAME = '_ply_coupon'\n\nexport class Cart implements ICart {\n private storefrontClient: StorefrontClient\n\n private listeners: Array<(cart: CartData) => void> = []\n\n private cart: CartReturn | null = null\n\n private cartPromise: Promise<CartReturn> | null\n\n private revalidate?: () => void\n\n constructor (cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void) {\n this.storefrontClient = storefrontClient\n this.cartPromise = cartPromise\n this.revalidate = revalidate\n }\n\n /**\n * Update internal cart data\n * Called by Provider when cart data changes from loader\n */\n updateCartData (cart: CartReturn): void {\n this.cart = cart\n this.cartPromise = null\n }\n\n /**\n * Notify all listeners of cart change\n * Called by Provider when cart updates\n */\n notifyListeners (): void {\n if (!this.cart) return\n\n this.listeners.forEach((listener) => {\n try {\n if (this.cart) {\n listener(this.toCartData(this.cart))\n }\n } catch (error) {\n console.error('Cart listener error:', error)\n }\n })\n }\n\n /**\n * Check if cart data is loaded and synced\n */\n isSynced (): boolean {\n return !!this.cart\n }\n\n /**\n * Register a callback to be called when cart changes\n * Returns a function to unregister the callback\n */\n onChange (callback: (cart: CartData) => void): () => void {\n this.listeners.push(callback)\n\n // Return unsubscribe function\n return () => {\n const index = this.listeners.indexOf(callback)\n if (index > -1) {\n this.listeners.splice(index, 1)\n }\n }\n }\n\n /**\n * Fetch current cart data\n * Returns cached cart data from loader (always fresh from React Router)\n */\n async fetch (force: boolean = true): Promise<CartData | null> {\n if (this.cart && !force) {\n return this.toCartData(this.cart)\n }\n\n if (this.cartPromise) {\n this.cart = await this.cartPromise\n return this.toCartData(this.cart)\n }\n\n if (!this.cart) return null\n\n return this.toCartData(this.cart)\n }\n\n /**\n * Update cart via Storefront API mutations\n * Actions: 'add', 'update', 'change', 'clear'\n */\n async update (action: string, data: any): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n const lineIds = this.cart.lines.nodes.map((line: any) => line.id)\n\n try {\n let result: any\n\n switch (action) {\n case 'add':\n result = await this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: [{\n merchandiseId: toGId(data.id, 'ProductVariant'),\n quantity: data.quantity || 1,\n attributes: data.properties\n ? Object.entries(data.properties).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n : undefined\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesAdd?.cart) {\n this.cart = result.cartLinesAdd.cart\n this.notifyListeners()\n }\n break\n\n case 'update':\n case 'change':\n // Handle Cart AJAX API format: { updates: { [variantId]: quantity }, attributes: {...} }\n if (data.updates) {\n // Separate into lines to update vs lines to add\n const linesToUpdate: any[] = []\n const linesToAdd: any[] = []\n\n Object.entries(data.updates).forEach(([variantId, quantity]) => {\n const line = this.cart!.lines.nodes.find((line: any) =>\n toId(line.merchandise.id) === Number(variantId))\n\n if (line) {\n linesToUpdate.push({\n id: line.id,\n quantity: Number(quantity)\n })\n } else if (Number(quantity) > 0) {\n // Line doesn't exist and quantity > 0 - add it\n linesToAdd.push({\n merchandiseId: toGId(Number(variantId), 'ProductVariant'),\n quantity: Number(quantity)\n })\n }\n })\n\n // Execute mutations in parallel\n const mutations: Promise<any>[] = []\n\n if (linesToUpdate.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: linesToUpdate\n }))\n }\n\n if (linesToAdd.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: linesToAdd\n }))\n }\n\n if (mutations.length > 0) {\n const results = await Promise.all(mutations)\n // Use the last result's cart (both mutations return the updated cart)\n const lastResult = results[results.length - 1]\n if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {\n this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart\n this.notifyListeners()\n }\n }\n } else if (data.id) {\n // Handle single line item update\n result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: [{\n id: `gid://shopify/CartLine/${data.id}`,\n quantity: data.quantity\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesUpdate?.cart) {\n this.cart = result.cartLinesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle cart-level attributes update\n if (data.attributes && this.cart) {\n result = await this.storefrontClient.mutate(CART_ATTRIBUTES_UPDATE, {\n cartId: this.cart.id,\n attributes: Object.entries(data.attributes).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n })\n\n // Update local cart immediately\n if (result?.cartAttributesUpdate?.cart) {\n this.cart = result.cartAttributesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle discount update\n if (data.discount && this.cart) {\n result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [data.discount]\n })\n\n // Update local cart immediately\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n }\n break\n\n case 'clear':\n result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {\n cartId: this.cart.id,\n lineIds\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesRemove?.cart) {\n this.cart = result.cartLinesRemove.cart\n this.notifyListeners()\n }\n break\n\n default:\n console.warn(`Unknown cart action: ${action}`)\n }\n\n // Trigger revalidation to fetch fresh cart data from loader\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Cart update error:', error)\n throw error\n }\n }\n\n /**\n * Quick buy - redirect to checkout with variant\n */\n async buy (_variantId: string, _quantity: number = 1): Promise<void> {\n if (!this.cart) return\n\n const coupon = this.getCoupon()\n const baseUrl = this.cart.checkoutUrl || '/checkout'\n const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl\n\n if (typeof window !== 'undefined') {\n window.location.href = url\n }\n }\n\n /**\n * Get cart data or specific property\n */\n get (property?: string): any {\n if (!this.cart) {\n return property ? undefined : null\n }\n\n if (!property) {\n return this.toCartData(this.cart)\n }\n\n return (this.toCartData(this.cart) as any)[property]\n }\n\n /**\n * Get cart token/ID\n */\n getToken (): string | null {\n if (!this.cart) return null\n\n return this.cart.id || null\n }\n\n /**\n * Get array of product IDs in cart\n */\n getItemsIds (): string[] {\n if (!this.cart) {\n return []\n }\n\n return this.cart.lines.nodes.map(line => line.merchandise.product.id)\n }\n\n /**\n * Get cart currency code\n */\n getCurrency (): string {\n if (!this.cart) return 'USD'\n\n return this.cart.cost.totalAmount.currencyCode\n }\n\n /**\n * Get cart total value\n * For Hydrogen, currency conversion would need to be handled separately\n */\n getValue (_currency?: string): number {\n if (!this.cart) return 0\n\n return parseFloat(this.cart.cost.totalAmount.amount) * 100\n }\n\n /**\n * Get cart item count\n * @param distinct - Count distinct products instead of total quantity\n */\n getSize (distinct: boolean = false): number {\n if (!this.cart) return 0\n\n if (distinct) {\n const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id))\n return uniqueProductIds.size\n }\n\n return this.cart.totalQuantity\n }\n\n /**\n * Fetch cart collections data\n * Requires custom implementation or metafield query\n */\n async fetchCollections (_force: boolean = false): Promise<any> {\n console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.')\n return {}\n }\n\n /**\n * Apply discount code to cart\n */\n async applyCoupon (code: string, expiresIn?: number): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n // Store in cookie\n createCookie(COUPON_COOKIE_NAME, code, expiresIn)\n\n try {\n const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [code]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n\n // Trigger revalidation to fetch fresh cart data from loader (backup)\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Error applying coupon:', error)\n throw error\n }\n }\n\n /**\n * Get currently applied coupon code\n */\n getCoupon (): string | null {\n if (!this.cart) return null\n\n // First check cart discount codes\n if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {\n return this.cart.discountCodes[0].code\n }\n\n // Fall back to cookie\n return readCookie(COUPON_COOKIE_NAME)\n }\n\n /**\n * Convert Hydrogen cart to CartData format\n * For compatibility with snippet-manager\n */\n private toCartData (cart: CartReturn): CartData {\n return {\n token: cart.id,\n item_count: cart.totalQuantity || 0,\n items: (cart.lines?.nodes || []).map(line => ({\n id: toId(line.id),\n product_id: toId(line.merchandise.product.id),\n variant_id: toId(line.merchandise.id),\n price: Number(line.merchandise.price.amount) * 100,\n quantity: line.quantity\n })),\n total_price: Number(cart.cost.totalAmount.amount) * 100,\n discount_codes: cart.discountCodes,\n attributes: cart.attributes,\n note: cart.note\n }\n }\n}\n","/**\n * GraphQL queries for product operations\n */\n\nexport const PRODUCT_FRAGMENT = `\n fragment ProductFragment on Product {\n id\n handle\n title\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n requiresSellingPlan\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n id\n url\n altText\n width\n height\n }\n images(first: 10) {\n nodes {\n id\n url\n altText\n width\n height\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n quantityAvailable\n sellingPlanAllocations(first: 10) {\n edges {\n node {\n sellingPlan {\n id\n }\n }\n }\n }\n sku\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n }\n options {\n id\n name\n values\n }\n collections(first: 10) {\n nodes {\n id\n handle\n title\n }\n }\n }\n`\n\nexport const GET_PRODUCT_BY_HANDLE = `\n query getProductByHandle($handle: String!) {\n product(handle: $handle) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_BY_ID = `\n query getProductById($id: ID!) {\n product(id: $id) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_RECOMMENDATIONS = `\n query getProductRecommendations($productId: ID!) {\n productRecommendations(productId: $productId) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n","import type {\n IShopifyAdapter,\n Product,\n Customer,\n PageContext,\n PersonizelyConfig,\n PersonizelyConfigMethods,\n ProductData\n} from '../types'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID,\n GET_PRODUCT_RECOMMENDATIONS\n} from '../graphql/queries/product'\nimport { toId } from '../utils/id'\n\nexport class Adapter implements IShopifyAdapter {\n private client: StorefrontClient\n\n private currency: {\n active: string\n base: string\n rate: number\n }\n\n private market: string | null\n\n private locale: string\n\n private pageContext: PageContext\n\n private methods?: PersonizelyConfigMethods\n\n private customer: Customer | null = null\n\n constructor (config: PersonizelyConfig, storefrontClient: StorefrontClient) {\n this.client = storefrontClient\n\n this.methods = config.methods\n this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency }\n this.locale = config.locale || 'en-US'\n this.market = config.market || null\n\n this.pageContext = {\n pageType: undefined,\n product: null,\n collection: null\n }\n }\n\n /**\n * Set customer data\n * Allows library users to provide customer information directly\n */\n setCustomer (customer: Customer | null): void {\n this.customer = customer\n }\n\n /**\n * Fetch product by handle from Storefront API\n */\n async fetchProduct (handle: string): Promise<ProductData> {\n const data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n\n if (!data.product) {\n throw new Error(`Product not found: ${handle}`)\n }\n\n return this.toProductData(data.product)\n }\n\n /**\n * Fetch product collections metadata\n */\n async fetchProductCollections (handle: string, productId: number): Promise<number[]> {\n let data\n if (productId) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` })\n } else if (handle) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n }\n\n if (!data || !data.product) {\n throw new Error(`Product not found: ${productId}`)\n }\n\n return data.product.collections.nodes.map(c => toId(c.id))\n }\n\n /**\n * Fetch product recommendations\n */\n async fetchRecommendations (productId: number, intent: string): Promise<{ products: ProductData[], intent: string }> {\n const data = await this.client.query<{ productRecommendations: Product[] }>(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent })\n\n return {\n intent,\n products: data.productRecommendations.map(p => this.toProductData(p)) || []\n }\n }\n\n /**\n * Build product URL path\n */\n buildProductPath (product: { handle: string }): string {\n if (typeof this.methods?.builtProductPath !== 'function') return `/products/${product.handle}`\n\n return this.methods.builtProductPath(product)\n }\n\n /**\n * Convert currency amount\n */\n convertToBaseCurrency (amount: number): number {\n return this.currency.rate / amount\n }\n\n /**\n * Convert currency amount\n */\n convertFromBaseCurrency (amount: number): number {\n return this.currency.rate * amount\n }\n\n /**\n * Format money according to shop's format\n */\n formatMoney (amount: number, includeDecimals: boolean = true): string {\n if (typeof this.methods?.formatMoney !== 'function') return new Intl.NumberFormat(this.locale, {\n style: 'currency',\n currency: this.currency.active,\n maximumFractionDigits: includeDecimals ? undefined : 0\n }).format(amount / 100)\n\n return this.methods.formatMoney(amount, includeDecimals)\n }\n\n /**\n * Get customer data\n * Returns the customer object set via setCustomer()\n */\n getCustomer (): Customer | null {\n return this.customer\n }\n\n /**\n * Get current page context\n * Auto-detected from Remix router in Provider\n */\n getPageContext (): PageContext {\n return this.pageContext\n }\n\n setPageContext (context: Partial<PageContext>) {\n if (context.product) {\n context.product.id = toId(String(context.product.id))\n }\n if (context.collection) {\n context.collection.id = toId(String(context.collection.id))\n }\n this.pageContext = context\n }\n\n getVisitorId (): string | null {\n return null\n }\n\n /**\n * Get current market information\n */\n getMarket (): string | null {\n return this.market\n }\n\n /**\n * Get currency conversion rate\n * Note: Stub implementation\n */\n getCurrencyRate (): number {\n return this.currency.rate\n }\n\n /**\n * Transform Hydrogen Product to snippet-manager ProductData format\n */\n toProductData (product: Product): ProductData {\n return {\n id: toId(product.id),\n handle: product.handle,\n title: product.title,\n available: product.availableForSale,\n requires_selling_plan: product.requiresSellingPlan,\n images: product.images.nodes.map(img => img.url),\n variants: product.variants.nodes.map(variant => ({\n id: toId(variant.id),\n title: variant.title,\n available: variant.availableForSale,\n price: Math.round(parseFloat(variant.price.amount) * 100), // Convert to cents\n compare_at_price: variant.compareAtPrice\n ? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)\n : null,\n featured_image: variant.image ? { src: variant.image.url } : null,\n selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({\n selling_plan_id: edge.node.sellingPlan.id\n })) || []\n }))\n }\n }\n}\n","/**\n * Shopify Storefront API GraphQL client\n */\n\nexport type StorefrontClientConfig = {\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n}\n\nexport class StorefrontClient {\n private storefrontAccessToken: string\n\n private shopDomain: string\n\n private apiVersion: string\n\n private endpoint: string\n\n constructor (config: StorefrontClientConfig) {\n this.storefrontAccessToken = config.storefrontAccessToken\n this.shopDomain = config.shopDomain\n this.apiVersion = config.apiVersion || '2024-01'\n this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`\n }\n\n /**\n * Execute a GraphQL query against the Storefront API\n */\n async query<T = any>(query: string, variables?: Record<string, any>): Promise<T> {\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken\n },\n body: JSON.stringify({\n query,\n variables\n })\n })\n\n if (!response.ok) {\n throw new Error(`Storefront API request failed: ${response.statusText}`)\n }\n\n const result = await response.json()\n\n if (result.errors) {\n throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`)\n }\n\n return result.data as T\n } catch (error) {\n console.error('Storefront API error:', error)\n throw error\n }\n }\n\n /**\n * Execute a GraphQL mutation against the Storefront API\n */\n async mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T> {\n return this.query<T>(mutation, variables)\n }\n}\n","import React, { createContext, useEffect, useMemo, useRef, ReactNode } from 'react'\nimport { useMatches, useRevalidator } from 'react-router'\nimport {\n PersonizelyConfigMethods,\n HydrogenConfig,\n CartAddProduct,\n Customer\n} from '../types'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { Cart } from '../classes/Cart'\nimport { Adapter } from '../classes/Adapter'\nimport { StorefrontClient } from '../utils/storefront-client'\n\ndeclare global {\n interface Window {\n __PLY_HYDROGEN_CONFIG__?: HydrogenConfig\n }\n}\n\nexport type PersonizelyContextType = {\n cart: Cart\n adapter: Adapter\n websiteApiKey: string\n triggerCartAdd: (product: CartAddProduct) => Promise<boolean>\n triggerCheckout: () => Promise<boolean>\n}\n\nexport const PersonizelyContext = createContext<PersonizelyContextType | null>(null)\n\nexport type PersonizelyProviderProps = {\n websiteApiKey: string\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n scriptBaseUrl?: string\n locale?: string\n currency?: {\n rate: number\n active: string\n base: string\n }\n market?: string\n methods?: PersonizelyConfigMethods\n children: ReactNode\n /**\n * Optional: Customer object for personalization\n */\n customer?: Customer | null\n}\n\nexport function PersonizelyProvider ({\n websiteApiKey,\n storefrontAccessToken,\n shopDomain,\n locale,\n currency,\n market,\n apiVersion,\n scriptBaseUrl,\n methods,\n children,\n customer\n}: PersonizelyProviderProps) {\n const matches = useMatches()\n const rootMatch = matches.find(m => m.id === 'root')\n const localCart = (rootMatch?.loaderData as any)?.cart as Promise<CartReturn>\n const revalidator = useRevalidator()\n\n const storefrontClient = useMemo(() => {\n return new StorefrontClient({\n storefrontAccessToken,\n shopDomain,\n apiVersion\n })\n }, [storefrontAccessToken, shopDomain, apiVersion])\n\n const adapter = useMemo(() => {\n return new Adapter({\n locale,\n currency,\n market,\n methods\n }, storefrontClient)\n }, [])\n\n useEffect(() => {\n if (customer) {\n adapter.setCustomer(customer)\n }\n }, [customer, adapter])\n\n const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), [])\n\n // Update cart data when it changes from the loader\n const prevCartDataRef = useRef<CartReturn | null>(null)\n useEffect(() => {\n localCart.then((data) => {\n if (data && data !== prevCartDataRef.current) {\n cart.updateCartData(data)\n cart.notifyListeners()\n prevCartDataRef.current = data\n }\n })\n }, [localCart, cart])\n\n const cartAddCallbacksRef = useRef<Array<(product: CartAddProduct) => Promise<boolean>>>([])\n const checkoutCallbacksRef = useRef<Array<() => Promise<boolean>>>([])\n\n // Set up window.__PLY_HYDROGEN_CONFIG__ and load Personizely script\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n\n window.__PLY_HYDROGEN_CONFIG__ = {\n cart,\n adapter,\n onCartAdd: (callback) => {\n cartAddCallbacksRef.current.push(callback)\n\n return () => {\n const index = cartAddCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n cartAddCallbacksRef.current.splice(index, 1)\n }\n }\n },\n onCheckout: (callback) => {\n checkoutCallbacksRef.current.push(callback)\n\n return () => {\n const index = checkoutCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n checkoutCallbacksRef.current.splice(index, 1)\n }\n }\n }\n }\n\n const script = document.createElement('script')\n const baseUrl = scriptBaseUrl || 'https://static.personizely.net'\n script.src = `${baseUrl}/${websiteApiKey}.js`\n document.head.appendChild(script)\n\n return () => {\n delete window.__PLY_HYDROGEN_CONFIG__\n if (script) {\n script.remove()\n }\n }\n }, [])\n\n const contextValue = useMemo(() => ({\n cart,\n adapter,\n websiteApiKey,\n triggerCartAdd: async (product: CartAddProduct): Promise<boolean> => {\n let shown = false\n for (const callback of cartAddCallbacksRef.current) {\n try {\n const result = await callback(product)\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Cart add callback error:', error)\n }\n }\n return shown\n },\n triggerCheckout: async (): Promise<boolean> => {\n let shown = false\n for (const callback of checkoutCallbacksRef.current) {\n try {\n const result = await callback()\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Checkout callback error:', error)\n }\n }\n return shown\n }\n }), [cart, adapter, websiteApiKey])\n\n return (\n <PersonizelyContext.Provider value={contextValue}>\n {children}\n </PersonizelyContext.Provider>\n )\n}\n","/**\n * usePersonizely - Access Personizely context\n */\n\nimport { useContext } from 'react'\nimport { PersonizelyContext, PersonizelyContextType } from '../components/PersonizelyProvider'\n\n/**\n * Hook to access Personizely context\n * Provides access to cart, adapter, and configuration\n *\n * @returns PersonizelyContextType\n * @throws Error if used outside PersonizelyProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { cart, adapter } = usePersonizely()\n * // Use cart and adapter...\n * }\n * ```\n */\nexport function usePersonizely (): PersonizelyContextType {\n const context = useContext(PersonizelyContext)\n\n if (!context) {\n throw new Error('usePersonizely must be used within a PersonizelyProvider. ' +\n 'Make sure your component is wrapped with <PersonizelyProvider>.')\n }\n\n return context\n}\n","/**\n * useCartAdd - Hook to trigger Personizely cart add widgets\n */\n\nimport { useCallback } from 'react'\nimport type { CartAddProduct } from '../types'\nimport { usePersonizely } from './usePersonizely'\nimport { toId } from '../utils/id'\n\n/**\n * Hook to trigger Personizely cart add event\n * Call this when a product is being added to cart to show relevant widgets\n *\n * @returns Function to trigger cart add event\n *\n * @example\n * ```tsx\n * function ProductForm({ product, selectedVariant }) {\n * const triggerCartAdd = useCartAdd()\n *\n * const handleAddToCart = async () => {\n * const widgetShown = await triggerCartAdd({\n * id: product.id,\n * variantId: selectedVariant.id,\n * price: parseFloat(selectedVariant.price.amount),\n * quantity: 1,\n * handle: product.handle\n * })\n *\n * if (!widgetShown) {\n * await cart.linesAdd([{\n * merchandiseId: selectedVariant.id,\n * quantity: 1\n * }])\n * }\n * }\n *\n * return <button onClick={handleAddToCart}>Add to Cart</button>\n * }\n * ```\n */\nexport function useCartAdd () {\n const personizely = usePersonizely()\n\n return useCallback(async (product: CartAddProduct): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCartAdd({\n ...product,\n id: toId(String(product.id)),\n variantId: toId(String(product.variantId)),\n price: Number(product.price) * 100\n })\n }, [personizely])\n}\n","/**\n * useCheckout - Hook to trigger Personizely checkout widgets\n */\n\nimport { useCallback } from 'react'\nimport { usePersonizely } from './usePersonizely'\n\n/**\n * Hook to trigger Personizely checkout event\n * Call this when proceeding to checkout to show relevant widgets\n *\n * @returns Function to trigger checkout event\n *\n * @example\n * ```tsx\n * function CheckoutButton() {\n * const triggerCheckout = useCheckout()\n *\n * const handleCheckout = async () => {\n * const widgetShown = await triggerCheckout()\n *\n * if (!widgetShown) {\n * window.location.href = cart.checkoutUrl\n * }\n * }\n *\n * return <button onClick={handleCheckout}>Checkout</button>\n * }\n * ```\n */\nexport function useCheckout () {\n const personizely = usePersonizely()\n\n return useCallback(async (): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCheckout()\n }, [personizely])\n}\n","import { usePersonizely } from './usePersonizely'\nimport { PageContext } from '../types'\n\nexport function usePageContext (context: Partial<PageContext>) {\n const personizely = usePersonizely()\n\n personizely.adapter.setPageContext(context)\n}\n"],"mappings":"0hBAUA,SAAgB,EAAY,EAA6B,CACvD,GAAI,OAAO,SAAa,IACtB,OAAO,KAGT,IAAM,EAAS,EAAO,IAChB,EAAU,SAAS,OAAO,MAAM,IAAI,CAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAI,EAAS,EAAQ,GACrB,KAAO,EAAO,OAAO,EAAE,GAAK,KAC1B,EAAS,EAAO,UAAU,EAAG,EAAO,OAAO,CAE7C,GAAI,EAAO,QAAQ,EAAO,GAAK,EAC7B,OAAO,EAAO,UAAU,EAAO,OAAQ,EA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SAAgB,EAAgB,EAA+B,CACzC,GAAgB,CAExB,QAAQ,eAAe,EAAQ"}
|
package/dist/index.d.cts
CHANGED
|
@@ -30,7 +30,7 @@ interface IShopifyAdapter {
|
|
|
30
30
|
convertToBaseCurrency(amount: number): number;
|
|
31
31
|
convertFromBaseCurrency(amount: number): number;
|
|
32
32
|
formatMoney(amount: number, includeDecimals: boolean): string;
|
|
33
|
-
getCustomer():
|
|
33
|
+
getCustomer(): Customer | null;
|
|
34
34
|
getPageContext(): PageContext;
|
|
35
35
|
getVisitorId(): string | null;
|
|
36
36
|
getMarket(): string | null;
|
|
@@ -258,9 +258,9 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
258
258
|
private locale;
|
|
259
259
|
private pageContext;
|
|
260
260
|
private methods?;
|
|
261
|
-
private
|
|
261
|
+
private customer;
|
|
262
262
|
constructor(config: PersonizelyConfig, storefrontClient: StorefrontClient);
|
|
263
|
-
|
|
263
|
+
setCustomer(customer: Customer | null): void;
|
|
264
264
|
fetchProduct(handle: string): Promise<ProductData>;
|
|
265
265
|
fetchProductCollections(handle: string, productId: number): Promise<number[]>;
|
|
266
266
|
fetchRecommendations(productId: number, intent: string): Promise<{
|
|
@@ -273,7 +273,7 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
273
273
|
convertToBaseCurrency(amount: number): number;
|
|
274
274
|
convertFromBaseCurrency(amount: number): number;
|
|
275
275
|
formatMoney(amount: number, includeDecimals?: boolean): string;
|
|
276
|
-
getCustomer():
|
|
276
|
+
getCustomer(): Customer | null;
|
|
277
277
|
getPageContext(): PageContext;
|
|
278
278
|
setPageContext(context: Partial<PageContext>): void;
|
|
279
279
|
getVisitorId(): string | null;
|
|
@@ -310,7 +310,7 @@ type PersonizelyProviderProps = {
|
|
|
310
310
|
market?: string;
|
|
311
311
|
methods?: PersonizelyConfigMethods;
|
|
312
312
|
children: ReactNode;
|
|
313
|
-
|
|
313
|
+
customer?: Customer | null;
|
|
314
314
|
};
|
|
315
315
|
declare function PersonizelyProvider({
|
|
316
316
|
websiteApiKey,
|
|
@@ -323,7 +323,7 @@ declare function PersonizelyProvider({
|
|
|
323
323
|
scriptBaseUrl,
|
|
324
324
|
methods,
|
|
325
325
|
children,
|
|
326
|
-
|
|
326
|
+
customer
|
|
327
327
|
}: PersonizelyProviderProps): React.JSX.Element;
|
|
328
328
|
//#endregion
|
|
329
329
|
//#region src/hooks/usePersonizely.d.ts
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/interfaces.ts","../src/types/index.ts","../src/utils/storefront-client.ts","../src/classes/Cart.ts","../src/classes/Adapter.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":[],"mappings":";;;;UAWiB,KAAA;;4BAUW;EAVX,KAAA,CAAA,KAAK,CAAA,EAAA,OAAA,CAAA,EAgBI,OAhBJ,CAgBY,QAhBZ,GAAA,IAAA,CAAA;EAUM,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,GAAA,CAAA,EAYS,OAZT,CAAA,IAAA,CAAA;EAMM,GAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAR,GAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,GAAA;EAMW,QAAA,EAAA,EAAA,MAAA,GAAA,IAAA;EAoCA,WAAA,EAAA,EAAA,MAAA,EAAA;EAKY,QAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAO,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAWvC,gBAAA,CAAA,KAAe,CAAA,EAAA,OAAA,CAAA,EAhBK,OAgBL,CAAA,GAAA,CAAA;EAIQ,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAfS,OAeT,CAAA,IAAA,CAAA;EAAR,SAAA,EAAA,EAAA,MAAA,GAAA,IAAA;;AAY+C,UAhB9D,eAAA,CAgB8D;EAApB,YAAA,CAAA,MAAA,EAAA,MAAA,CAAA,EAZ3B,OAY2B,CAZnB,WAYmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/interfaces.ts","../src/types/index.ts","../src/utils/storefront-client.ts","../src/classes/Cart.ts","../src/classes/Adapter.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":[],"mappings":";;;;UAWiB,KAAA;;4BAUW;EAVX,KAAA,CAAA,KAAK,CAAA,EAAA,OAAA,CAAA,EAgBI,OAhBJ,CAgBY,QAhBZ,GAAA,IAAA,CAAA;EAUM,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,GAAA,CAAA,EAYS,OAZT,CAAA,IAAA,CAAA;EAMM,GAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAR,GAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,GAAA;EAMW,QAAA,EAAA,EAAA,MAAA,GAAA,IAAA;EAoCA,WAAA,EAAA,EAAA,MAAA,EAAA;EAKY,QAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAO,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAWvC,gBAAA,CAAA,KAAe,CAAA,EAAA,OAAA,CAAA,EAhBK,OAgBL,CAAA,GAAA,CAAA;EAIQ,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAfS,OAeT,CAAA,IAAA,CAAA;EAAR,SAAA,EAAA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number): number;
|
|
31
31
|
convertFromBaseCurrency(amount: number): number;
|
|
32
32
|
formatMoney(amount: number, includeDecimals: boolean): string;
|
|
33
|
-
getCustomer():
|
|
33
|
+
getCustomer(): Customer | null;
|
|
34
34
|
getPageContext(): PageContext;
|
|
35
35
|
getVisitorId(): string | null;
|
|
36
36
|
getMarket(): string | null;
|
|
@@ -258,9 +258,9 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
258
258
|
private locale;
|
|
259
259
|
private pageContext;
|
|
260
260
|
private methods?;
|
|
261
|
-
private
|
|
261
|
+
private customer;
|
|
262
262
|
constructor(config: PersonizelyConfig, storefrontClient: StorefrontClient);
|
|
263
|
-
|
|
263
|
+
setCustomer(customer: Customer | null): void;
|
|
264
264
|
fetchProduct(handle: string): Promise<ProductData>;
|
|
265
265
|
fetchProductCollections(handle: string, productId: number): Promise<number[]>;
|
|
266
266
|
fetchRecommendations(productId: number, intent: string): Promise<{
|
|
@@ -273,7 +273,7 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
273
273
|
convertToBaseCurrency(amount: number): number;
|
|
274
274
|
convertFromBaseCurrency(amount: number): number;
|
|
275
275
|
formatMoney(amount: number, includeDecimals?: boolean): string;
|
|
276
|
-
getCustomer():
|
|
276
|
+
getCustomer(): Customer | null;
|
|
277
277
|
getPageContext(): PageContext;
|
|
278
278
|
setPageContext(context: Partial<PageContext>): void;
|
|
279
279
|
getVisitorId(): string | null;
|
|
@@ -310,7 +310,7 @@ type PersonizelyProviderProps = {
|
|
|
310
310
|
market?: string;
|
|
311
311
|
methods?: PersonizelyConfigMethods;
|
|
312
312
|
children: ReactNode;
|
|
313
|
-
|
|
313
|
+
customer?: Customer | null;
|
|
314
314
|
};
|
|
315
315
|
declare function PersonizelyProvider({
|
|
316
316
|
websiteApiKey,
|
|
@@ -323,7 +323,7 @@ declare function PersonizelyProvider({
|
|
|
323
323
|
scriptBaseUrl,
|
|
324
324
|
methods,
|
|
325
325
|
children,
|
|
326
|
-
|
|
326
|
+
customer
|
|
327
327
|
}: PersonizelyProviderProps): React.JSX.Element;
|
|
328
328
|
//#endregion
|
|
329
329
|
//#region src/hooks/usePersonizely.d.ts
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/interfaces.ts","../src/types/index.ts","../src/utils/storefront-client.ts","../src/classes/Cart.ts","../src/classes/Adapter.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":[],"mappings":";;;;UAWiB,KAAA;;4BAUW;EAVX,KAAA,CAAA,KAAK,CAAA,EAAA,OAAA,CAAA,EAgBI,OAhBJ,CAgBY,QAhBZ,GAAA,IAAA,CAAA;EAUM,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,GAAA,CAAA,EAYS,OAZT,CAAA,IAAA,CAAA;EAMM,GAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAR,GAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,GAAA;EAMW,QAAA,EAAA,EAAA,MAAA,GAAA,IAAA;EAoCA,WAAA,EAAA,EAAA,MAAA,EAAA;EAKY,QAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAO,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAWvC,gBAAA,CAAA,KAAe,CAAA,EAAA,OAAA,CAAA,EAhBK,OAgBL,CAAA,GAAA,CAAA;EAIQ,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAfS,OAeT,CAAA,IAAA,CAAA;EAAR,SAAA,EAAA,EAAA,MAAA,GAAA,IAAA;;AAY+C,UAhB9D,eAAA,CAgB8D;EAApB,YAAA,CAAA,MAAA,EAAA,MAAA,CAAA,EAZ3B,OAY2B,CAZnB,WAYmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/interfaces.ts","../src/types/index.ts","../src/utils/storefront-client.ts","../src/classes/Cart.ts","../src/classes/Adapter.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":[],"mappings":";;;;UAWiB,KAAA;;4BAUW;EAVX,KAAA,CAAA,KAAK,CAAA,EAAA,OAAA,CAAA,EAgBI,OAhBJ,CAgBY,QAhBZ,GAAA,IAAA,CAAA;EAUM,MAAA,CAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,GAAA,CAAA,EAYS,OAZT,CAAA,IAAA,CAAA;EAMM,GAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAR,GAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,GAAA;EAMW,QAAA,EAAA,EAAA,MAAA,GAAA,IAAA;EAoCA,WAAA,EAAA,EAAA,MAAA,EAAA;EAKY,QAAA,CAAA,QAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAAO,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAWvC,gBAAA,CAAA,KAAe,CAAA,EAAA,OAAA,CAAA,EAhBK,OAgBL,CAAA,GAAA,CAAA;EAIQ,WAAA,CAAA,IAAA,EAAA,MAAA,EAAA,SAAA,CAAA,EAAA,MAAA,CAAA,EAfS,OAeT,CAAA,IAAA,CAAA;EAAR,SAAA,EAAA,EAAA,MAAA,GAAA,IAAA;;AAY+C,UAhB9D,eAAA,CAgB8D;EAApB,YAAA,CAAA,MAAA,EAAA,MAAA,CAAA,EAZ3B,OAY2B,CAZnB,WAYmB,CAAA;EA0B1C,uBAAA,CAAA,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EAAR;;AA0CW,KKlDzB,sBAAA,GLkDyB;EAKY,IAAA,EKtDzC,ILsDyC;EAAO,OAAA,EKrD7C,OLqD6C;EAWvC,aAAA,EAAA,MAAe;EAIQ,cAAA,EAAA,CAAA,OAAA,EKlEZ,cLkEY,EAAA,GKlEO,OLkEP,CAAA,OAAA,CAAA;EAAR,eAAA,EAAA,GAAA,GKjEP,OLiEO,CAAA,OAAA,CAAA;CAK8B;AAOH,KKxE/C,wBAAA,GLwE+C;EA0B1C,aAAA,EAAA,MAAA;EAKG,qBAAA,EAAA,MAAA;EAAW,UAAA,EAAA,MAAA;;;;EC/HnB,QAAA,CAAA,EAAA;IAaA,IAAA,EAAA,MAAA;IAaA,MAAO,EAAA,MAAA;IAOR,IAAA,EAAA,MAAA;EAGA,CAAA;EAEO,MAAA,CAAA,EAAA,MAAA;EACJ,OAAA,CAAA,EIFF,wBJEE;EAKH,QAAA,EINC,SJMD;EAIA,QAAA,CAAA,EINE,QJMF,GAAA,IAAA;CAAa;AAMZ,iBITI,mBAAA,CJSG;EAAA,aAAA;EAAA,qBAAA;EAAA,UAAA;EAAA,MAAA;EAAA,QAAA;EAAA,MAAA;EAAA,UAAA;EAAA,aAAA;EAAA,OAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EIGhB,wBJHgB,CAAA,EIGQ,KAAA,CAAA,GAAA,CAAA,OJHR;;;iBKrCH,cAAA,CAAA,GAAmB;;;iBCmBnB,UAAA,CAAA,aAGqB,mBAAiB;;;iBCdtC,WAAA,CAAA,SAGe;;;iBC9Bf,cAAA,UAAyB,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ interface IShopifyAdapter {
|
|
|
30
30
|
convertToBaseCurrency(amount: number): number;
|
|
31
31
|
convertFromBaseCurrency(amount: number): number;
|
|
32
32
|
formatMoney(amount: number, includeDecimals: boolean): string;
|
|
33
|
-
getCustomer():
|
|
33
|
+
getCustomer(): Customer | null;
|
|
34
34
|
getPageContext(): PageContext;
|
|
35
35
|
getVisitorId(): string | null;
|
|
36
36
|
getMarket(): string | null;
|
|
@@ -258,9 +258,9 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
258
258
|
private locale;
|
|
259
259
|
private pageContext;
|
|
260
260
|
private methods?;
|
|
261
|
-
private
|
|
261
|
+
private customer;
|
|
262
262
|
constructor(config: PersonizelyConfig, storefrontClient: StorefrontClient);
|
|
263
|
-
|
|
263
|
+
setCustomer(customer: Customer | null): void;
|
|
264
264
|
fetchProduct(handle: string): Promise<ProductData>;
|
|
265
265
|
fetchProductCollections(handle: string, productId: number): Promise<number[]>;
|
|
266
266
|
fetchRecommendations(productId: number, intent: string): Promise<{
|
|
@@ -273,7 +273,7 @@ declare class Adapter implements IShopifyAdapter {
|
|
|
273
273
|
convertToBaseCurrency(amount: number): number;
|
|
274
274
|
convertFromBaseCurrency(amount: number): number;
|
|
275
275
|
formatMoney(amount: number, includeDecimals?: boolean): string;
|
|
276
|
-
getCustomer():
|
|
276
|
+
getCustomer(): Customer | null;
|
|
277
277
|
getPageContext(): PageContext;
|
|
278
278
|
setPageContext(context: Partial<PageContext>): void;
|
|
279
279
|
getVisitorId(): string | null;
|
|
@@ -310,7 +310,7 @@ type PersonizelyProviderProps = {
|
|
|
310
310
|
market?: string;
|
|
311
311
|
methods?: PersonizelyConfigMethods;
|
|
312
312
|
children: ReactNode;
|
|
313
|
-
|
|
313
|
+
customer?: Customer | null;
|
|
314
314
|
};
|
|
315
315
|
declare function PersonizelyProvider({
|
|
316
316
|
websiteApiKey,
|
|
@@ -323,7 +323,7 @@ declare function PersonizelyProvider({
|
|
|
323
323
|
scriptBaseUrl,
|
|
324
324
|
methods,
|
|
325
325
|
children,
|
|
326
|
-
|
|
326
|
+
customer
|
|
327
327
|
}: PersonizelyProviderProps): React.JSX.Element;
|
|
328
328
|
//#endregion
|
|
329
329
|
//#region src/hooks/usePersonizely.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -248,30 +248,5 @@ import e,{createContext as t,useCallback as n,useContext as r,useEffect as i,use
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
${x}
|
|
251
|
-
`;var T=class{constructor(e,t){this.
|
|
252
|
-
query getCustomer($customerAccessToken: String!) {
|
|
253
|
-
customer(customerAccessToken: $customerAccessToken) {
|
|
254
|
-
...CustomerFragment
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
fragment CustomerFragment on Customer {
|
|
259
|
-
id
|
|
260
|
-
email
|
|
261
|
-
phone
|
|
262
|
-
firstName
|
|
263
|
-
lastName
|
|
264
|
-
displayName
|
|
265
|
-
defaultAddress {
|
|
266
|
-
id
|
|
267
|
-
address1
|
|
268
|
-
address2
|
|
269
|
-
city
|
|
270
|
-
province
|
|
271
|
-
country
|
|
272
|
-
zip
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
`,{customerAccessToken:this.customerAccessToken})).customer||null}catch(e){return console.error(`Error fetching customer:`,e),null}}getPageContext(){return this.pageContext}setPageContext(e){e.product&&(e.product.id=v(String(e.product.id))),e.collection&&(e.collection.id=v(String(e.collection.id))),this.pageContext=e}getVisitorId(){return null}getMarket(){return this.market}getCurrencyRate(){return this.currency.rate}toProductData(e){return{id:v(e.id),handle:e.handle,title:e.title,available:e.availableForSale,requires_selling_plan:e.requiresSellingPlan,images:e.images.nodes.map(e=>e.url),variants:e.variants.nodes.map(e=>({id:v(e.id),title:e.title,available:e.availableForSale,price:Math.round(parseFloat(e.price.amount)*100),compare_at_price:e.compareAtPrice?Math.round(parseFloat(e.compareAtPrice.amount)*100):null,featured_image:e.image?{src:e.image.url}:null,selling_plan_allocations:e.sellingPlanAllocations?.edges?.map(e=>({selling_plan_id:e.node.sellingPlan.id}))||[]}))}}},E=class{constructor(e){this.storefrontAccessToken=e.storefrontAccessToken,this.shopDomain=e.shopDomain,this.apiVersion=e.apiVersion||`2024-01`,this.endpoint=`https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`}async query(e,t){try{let n=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:t})});if(!n.ok)throw Error(`Storefront API request failed: ${n.statusText}`);let r=await n.json();if(r.errors)throw Error(`GraphQL errors: ${JSON.stringify(r.errors)}`);return r.data}catch(e){throw console.error(`Storefront API error:`,e),e}}async mutate(e,t){return this.query(e,t)}};const D=t(null);function O({websiteApiKey:t,storefrontAccessToken:n,shopDomain:r,locale:l,currency:u,market:d,apiVersion:f,scriptBaseUrl:p,methods:m,children:h,customerAccessToken:g}){let _=s().find(e=>e.id===`root`)?.loaderData?.cart,v=c(),y=a(()=>new E({storefrontAccessToken:n,shopDomain:r,apiVersion:f}),[n,r,f]),x=a(()=>{let e=new T({locale:l,currency:u,market:d,methods:m},y);return g&&e.setCustomerAccessToken(g),e},[]),S=a(()=>new b(_,y,v.revalidate),[]),C=o(null);i(()=>{_.then(e=>{e&&e!==C.current&&(S.updateCartData(e),S.notifyListeners(),C.current=e)})},[_,S]);let w=o([]),O=o([]);i(()=>{if(typeof window>`u`)return;window.__PLY_HYDROGEN_CONFIG__={cart:S,adapter:x,onCartAdd:e=>(w.current.push(e),()=>{let t=w.current.indexOf(e);t>-1&&w.current.splice(t,1)}),onCheckout:e=>(O.current.push(e),()=>{let t=O.current.indexOf(e);t>-1&&O.current.splice(t,1)})};let e=document.createElement(`script`);return e.src=`${p||`https://static.personizely.net`}/${t}.js`,document.head.appendChild(e),()=>{delete window.__PLY_HYDROGEN_CONFIG__,e&&e.remove()}},[]);let k=a(()=>({cart:S,adapter:x,websiteApiKey:t,triggerCartAdd:async e=>{let t=!1;for(let n of w.current)try{await n(e)&&(t=!0)}catch(e){console.error(`Cart add callback error:`,e)}return t},triggerCheckout:async()=>{let e=!1;for(let t of O.current)try{await t()&&(e=!0)}catch(e){console.error(`Checkout callback error:`,e)}return e}}),[S,x,t]);return e.createElement(D.Provider,{value:k},h)}function k(){let e=r(D);if(!e)throw Error(`usePersonizely must be used within a PersonizelyProvider. Make sure your component is wrapped with <PersonizelyProvider>.`);return e}function A(){let e=k();return n(async t=>typeof window>`u`?!1:await e.triggerCartAdd({...t,id:v(String(t.id)),variantId:v(String(t.variantId)),price:Number(t.price)*100}),[e])}function j(){let e=k();return n(async()=>typeof window>`u`?!1:await e.triggerCheckout(),[e])}function M(e){k().adapter.setPageContext(e)}export{T as Adapter,b as Cart,O as PersonizelyProvider,A as useCartAdd,j as useCheckout,M as usePageContext,k as usePersonizely};
|
|
251
|
+
`;var T=class{constructor(e,t){this.customer=null,this.client=t,this.methods=e.methods,this.currency={active:`USD`,base:`USD`,rate:1,...e.currency},this.locale=e.locale||`en-US`,this.market=e.market||null,this.pageContext={pageType:void 0,product:null,collection:null}}setCustomer(e){this.customer=e}async fetchProduct(e){let t=await this.client.query(S,{handle:e});if(!t.product)throw Error(`Product not found: ${e}`);return this.toProductData(t.product)}async fetchProductCollections(e,t){let n;if(t?n=await this.client.query(C,{id:`gid://shopify/Product/${t}`}):e&&(n=await this.client.query(S,{handle:e})),!n||!n.product)throw Error(`Product not found: ${t}`);return n.product.collections.nodes.map(e=>v(e.id))}async fetchRecommendations(e,t){return{intent:t,products:(await this.client.query(w,{productId:`gid://shopify/Product/${e}`,intent:t})).productRecommendations.map(e=>this.toProductData(e))||[]}}buildProductPath(e){return typeof this.methods?.builtProductPath==`function`?this.methods.builtProductPath(e):`/products/${e.handle}`}convertToBaseCurrency(e){return this.currency.rate/e}convertFromBaseCurrency(e){return this.currency.rate*e}formatMoney(e,t=!0){return typeof this.methods?.formatMoney==`function`?this.methods.formatMoney(e,t):new Intl.NumberFormat(this.locale,{style:`currency`,currency:this.currency.active,maximumFractionDigits:t?void 0:0}).format(e/100)}getCustomer(){return this.customer}getPageContext(){return this.pageContext}setPageContext(e){e.product&&(e.product.id=v(String(e.product.id))),e.collection&&(e.collection.id=v(String(e.collection.id))),this.pageContext=e}getVisitorId(){return null}getMarket(){return this.market}getCurrencyRate(){return this.currency.rate}toProductData(e){return{id:v(e.id),handle:e.handle,title:e.title,available:e.availableForSale,requires_selling_plan:e.requiresSellingPlan,images:e.images.nodes.map(e=>e.url),variants:e.variants.nodes.map(e=>({id:v(e.id),title:e.title,available:e.availableForSale,price:Math.round(parseFloat(e.price.amount)*100),compare_at_price:e.compareAtPrice?Math.round(parseFloat(e.compareAtPrice.amount)*100):null,featured_image:e.image?{src:e.image.url}:null,selling_plan_allocations:e.sellingPlanAllocations?.edges?.map(e=>({selling_plan_id:e.node.sellingPlan.id}))||[]}))}}},E=class{constructor(e){this.storefrontAccessToken=e.storefrontAccessToken,this.shopDomain=e.shopDomain,this.apiVersion=e.apiVersion||`2024-01`,this.endpoint=`https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`}async query(e,t){try{let n=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:t})});if(!n.ok)throw Error(`Storefront API request failed: ${n.statusText}`);let r=await n.json();if(r.errors)throw Error(`GraphQL errors: ${JSON.stringify(r.errors)}`);return r.data}catch(e){throw console.error(`Storefront API error:`,e),e}}async mutate(e,t){return this.query(e,t)}};const D=t(null);function O({websiteApiKey:t,storefrontAccessToken:n,shopDomain:r,locale:l,currency:u,market:d,apiVersion:f,scriptBaseUrl:p,methods:m,children:h,customer:g}){let _=s().find(e=>e.id===`root`)?.loaderData?.cart,v=c(),y=a(()=>new E({storefrontAccessToken:n,shopDomain:r,apiVersion:f}),[n,r,f]),x=a(()=>new T({locale:l,currency:u,market:d,methods:m},y),[]);i(()=>{g&&x.setCustomer(g)},[g,x]);let S=a(()=>new b(_,y,v.revalidate),[]),C=o(null);i(()=>{_.then(e=>{e&&e!==C.current&&(S.updateCartData(e),S.notifyListeners(),C.current=e)})},[_,S]);let w=o([]),O=o([]);i(()=>{if(typeof window>`u`)return;window.__PLY_HYDROGEN_CONFIG__={cart:S,adapter:x,onCartAdd:e=>(w.current.push(e),()=>{let t=w.current.indexOf(e);t>-1&&w.current.splice(t,1)}),onCheckout:e=>(O.current.push(e),()=>{let t=O.current.indexOf(e);t>-1&&O.current.splice(t,1)})};let e=document.createElement(`script`);return e.src=`${p||`https://static.personizely.net`}/${t}.js`,document.head.appendChild(e),()=>{delete window.__PLY_HYDROGEN_CONFIG__,e&&e.remove()}},[]);let k=a(()=>({cart:S,adapter:x,websiteApiKey:t,triggerCartAdd:async e=>{let t=!1;for(let n of w.current)try{await n(e)&&(t=!0)}catch(e){console.error(`Cart add callback error:`,e)}return t},triggerCheckout:async()=>{let e=!1;for(let t of O.current)try{await t()&&(e=!0)}catch(e){console.error(`Checkout callback error:`,e)}return e}}),[S,x,t]);return e.createElement(D.Provider,{value:k},h)}function k(){let e=r(D);if(!e)throw Error(`usePersonizely must be used within a PersonizelyProvider. Make sure your component is wrapped with <PersonizelyProvider>.`);return e}function A(){let e=k();return n(async t=>typeof window>`u`?!1:await e.triggerCartAdd({...t,id:v(String(t.id)),variantId:v(String(t.variantId)),price:Number(t.price)*100}),[e])}function j(){let e=k();return n(async()=>typeof window>`u`?!1:await e.triggerCheckout(),[e])}function M(e){k().adapter.setPageContext(e)}export{T as Adapter,b as Cart,O as PersonizelyProvider,A as useCartAdd,j as useCheckout,M as usePageContext,k as usePersonizely};
|
|
277
252
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["result: any","linesToUpdate: any[]","linesToAdd: any[]","line","mutations: Promise<any>[]"],"sources":["../src/utils/cookies.ts","../src/graphql/queries/cart.ts","../src/utils/id.ts","../src/classes/Cart.ts","../src/graphql/queries/product.ts","../src/graphql/queries/customer.ts","../src/classes/Adapter.ts","../src/utils/storefront-client.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":["/**\n * Cookie utilities for browser storage\n * Mirrors cookie helpers from snippet-manager\n */\n\n/**\n * Read a cookie value by name\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n */\nexport function readCookie (name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const nameEQ = name + '='\n const cookies = document.cookie.split(';')\n\n for (let i = 0; i < cookies.length; i++) {\n let cookie = cookies[i]\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length)\n }\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length)\n }\n }\n\n return null\n}\n\n/**\n * Create/update a cookie\n * @param name - Cookie name\n * @param value - Cookie value\n * @param days - Expiration in days (optional, default: session cookie)\n * @param path - Cookie path (default: '/')\n */\nexport function createCookie (name: string,\n value: string,\n days?: number,\n path: string = '/'): void {\n if (typeof document === 'undefined') {\n return\n }\n\n let expires = ''\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))\n expires = '; expires=' + date.toUTCString()\n }\n\n document.cookie = name + '=' + value + expires + '; path=' + path\n}\n\n/**\n * Delete a cookie by name\n * @param name - Cookie name\n * @param path - Cookie path (default: '/')\n */\nexport function deleteCookie (name: string, path: string = '/'): void {\n createCookie(name, '', -1, path)\n}\n","/**\n * GraphQL queries and mutations for cart operations\n */\n\nexport const CART_FRAGMENT = `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n`\n\nexport const GET_CART = `\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n ${CART_FRAGMENT}\n`\n\n/**\n * Cart mutations\n */\n\nexport const CART_LINES_ADD = `\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_UPDATE = `\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_REMOVE = `\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_DISCOUNT_CODES_UPDATE = `\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_ATTRIBUTES_UPDATE = `\n mutation cartAttributesUpdate($cartId: ID!, $attributes: [AttributeInput!]!) {\n cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n","export function toGId (id: number, type: string): string {\n return `gid://shopify/${type}/${id}`\n}\n\nexport function toId (id: string): number {\n return Number(id.split('/').pop())\n}","import type { CartData, ICart } from '../types'\nimport { createCookie, readCookie } from '../utils/cookies'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n CART_LINES_ADD,\n CART_LINES_UPDATE,\n CART_LINES_REMOVE,\n CART_DISCOUNT_CODES_UPDATE,\n CART_ATTRIBUTES_UPDATE\n} from '../graphql/queries/cart'\nimport { toGId, toId } from '../utils/id'\n\nconst COUPON_COOKIE_NAME = '_ply_coupon'\n\nexport class Cart implements ICart {\n private storefrontClient: StorefrontClient\n\n private listeners: Array<(cart: CartData) => void> = []\n\n private cart: CartReturn | null = null\n\n private cartPromise: Promise<CartReturn> | null\n\n private revalidate?: () => void\n\n constructor (cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void) {\n this.storefrontClient = storefrontClient\n this.cartPromise = cartPromise\n this.revalidate = revalidate\n }\n\n /**\n * Update internal cart data\n * Called by Provider when cart data changes from loader\n */\n updateCartData (cart: CartReturn): void {\n this.cart = cart\n this.cartPromise = null\n }\n\n /**\n * Notify all listeners of cart change\n * Called by Provider when cart updates\n */\n notifyListeners (): void {\n if (!this.cart) return\n\n this.listeners.forEach((listener) => {\n try {\n if (this.cart) {\n listener(this.toCartData(this.cart))\n }\n } catch (error) {\n console.error('Cart listener error:', error)\n }\n })\n }\n\n /**\n * Check if cart data is loaded and synced\n */\n isSynced (): boolean {\n return !!this.cart\n }\n\n /**\n * Register a callback to be called when cart changes\n * Returns a function to unregister the callback\n */\n onChange (callback: (cart: CartData) => void): () => void {\n this.listeners.push(callback)\n\n // Return unsubscribe function\n return () => {\n const index = this.listeners.indexOf(callback)\n if (index > -1) {\n this.listeners.splice(index, 1)\n }\n }\n }\n\n /**\n * Fetch current cart data\n * Returns cached cart data from loader (always fresh from React Router)\n */\n async fetch (force: boolean = true): Promise<CartData | null> {\n if (this.cart && !force) {\n return this.toCartData(this.cart)\n }\n\n if (this.cartPromise) {\n this.cart = await this.cartPromise\n return this.toCartData(this.cart)\n }\n\n if (!this.cart) return null\n\n return this.toCartData(this.cart)\n }\n\n /**\n * Update cart via Storefront API mutations\n * Actions: 'add', 'update', 'change', 'clear'\n */\n async update (action: string, data: any): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n const lineIds = this.cart.lines.nodes.map((line: any) => line.id)\n\n try {\n let result: any\n\n switch (action) {\n case 'add':\n result = await this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: [{\n merchandiseId: toGId(data.id, 'ProductVariant'),\n quantity: data.quantity || 1,\n attributes: data.properties\n ? Object.entries(data.properties).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n : undefined\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesAdd?.cart) {\n this.cart = result.cartLinesAdd.cart\n this.notifyListeners()\n }\n break\n\n case 'update':\n case 'change':\n // Handle Cart AJAX API format: { updates: { [variantId]: quantity }, attributes: {...} }\n if (data.updates) {\n // Separate into lines to update vs lines to add\n const linesToUpdate: any[] = []\n const linesToAdd: any[] = []\n\n Object.entries(data.updates).forEach(([variantId, quantity]) => {\n const line = this.cart!.lines.nodes.find((line: any) =>\n toId(line.merchandise.id) === Number(variantId))\n\n if (line) {\n linesToUpdate.push({\n id: line.id,\n quantity: Number(quantity)\n })\n } else if (Number(quantity) > 0) {\n // Line doesn't exist and quantity > 0 - add it\n linesToAdd.push({\n merchandiseId: toGId(Number(variantId), 'ProductVariant'),\n quantity: Number(quantity)\n })\n }\n })\n\n // Execute mutations in parallel\n const mutations: Promise<any>[] = []\n\n if (linesToUpdate.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: linesToUpdate\n }))\n }\n\n if (linesToAdd.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: linesToAdd\n }))\n }\n\n if (mutations.length > 0) {\n const results = await Promise.all(mutations)\n // Use the last result's cart (both mutations return the updated cart)\n const lastResult = results[results.length - 1]\n if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {\n this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart\n this.notifyListeners()\n }\n }\n } else if (data.id) {\n // Handle single line item update\n result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: [{\n id: `gid://shopify/CartLine/${data.id}`,\n quantity: data.quantity\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesUpdate?.cart) {\n this.cart = result.cartLinesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle cart-level attributes update\n if (data.attributes && this.cart) {\n result = await this.storefrontClient.mutate(CART_ATTRIBUTES_UPDATE, {\n cartId: this.cart.id,\n attributes: Object.entries(data.attributes).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n })\n\n // Update local cart immediately\n if (result?.cartAttributesUpdate?.cart) {\n this.cart = result.cartAttributesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle discount update\n if (data.discount && this.cart) {\n result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [data.discount]\n })\n\n // Update local cart immediately\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n }\n break\n\n case 'clear':\n result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {\n cartId: this.cart.id,\n lineIds\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesRemove?.cart) {\n this.cart = result.cartLinesRemove.cart\n this.notifyListeners()\n }\n break\n\n default:\n console.warn(`Unknown cart action: ${action}`)\n }\n\n // Trigger revalidation to fetch fresh cart data from loader\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Cart update error:', error)\n throw error\n }\n }\n\n /**\n * Quick buy - redirect to checkout with variant\n */\n async buy (_variantId: string, _quantity: number = 1): Promise<void> {\n if (!this.cart) return\n\n const coupon = this.getCoupon()\n const baseUrl = this.cart.checkoutUrl || '/checkout'\n const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl\n\n if (typeof window !== 'undefined') {\n window.location.href = url\n }\n }\n\n /**\n * Get cart data or specific property\n */\n get (property?: string): any {\n if (!this.cart) {\n return property ? undefined : null\n }\n\n if (!property) {\n return this.toCartData(this.cart)\n }\n\n return (this.toCartData(this.cart) as any)[property]\n }\n\n /**\n * Get cart token/ID\n */\n getToken (): string | null {\n if (!this.cart) return null\n\n return this.cart.id || null\n }\n\n /**\n * Get array of product IDs in cart\n */\n getItemsIds (): string[] {\n if (!this.cart) {\n return []\n }\n\n return this.cart.lines.nodes.map(line => line.merchandise.product.id)\n }\n\n /**\n * Get cart currency code\n */\n getCurrency (): string {\n if (!this.cart) return 'USD'\n\n return this.cart.cost.totalAmount.currencyCode\n }\n\n /**\n * Get cart total value\n * For Hydrogen, currency conversion would need to be handled separately\n */\n getValue (_currency?: string): number {\n if (!this.cart) return 0\n\n return parseFloat(this.cart.cost.totalAmount.amount) * 100\n }\n\n /**\n * Get cart item count\n * @param distinct - Count distinct products instead of total quantity\n */\n getSize (distinct: boolean = false): number {\n if (!this.cart) return 0\n\n if (distinct) {\n const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id))\n return uniqueProductIds.size\n }\n\n return this.cart.totalQuantity\n }\n\n /**\n * Fetch cart collections data\n * Requires custom implementation or metafield query\n */\n async fetchCollections (_force: boolean = false): Promise<any> {\n console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.')\n return {}\n }\n\n /**\n * Apply discount code to cart\n */\n async applyCoupon (code: string, expiresIn?: number): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n // Store in cookie\n createCookie(COUPON_COOKIE_NAME, code, expiresIn)\n\n try {\n const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [code]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n\n // Trigger revalidation to fetch fresh cart data from loader (backup)\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Error applying coupon:', error)\n throw error\n }\n }\n\n /**\n * Get currently applied coupon code\n */\n getCoupon (): string | null {\n if (!this.cart) return null\n\n // First check cart discount codes\n if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {\n return this.cart.discountCodes[0].code\n }\n\n // Fall back to cookie\n return readCookie(COUPON_COOKIE_NAME)\n }\n\n /**\n * Convert Hydrogen cart to CartData format\n * For compatibility with snippet-manager\n */\n private toCartData (cart: CartReturn): CartData {\n return {\n token: cart.id,\n item_count: cart.totalQuantity || 0,\n items: (cart.lines?.nodes || []).map(line => ({\n id: toId(line.id),\n product_id: toId(line.merchandise.product.id),\n variant_id: toId(line.merchandise.id),\n price: Number(line.merchandise.price.amount) * 100,\n quantity: line.quantity\n })),\n total_price: Number(cart.cost.totalAmount.amount) * 100,\n discount_codes: cart.discountCodes,\n attributes: cart.attributes,\n note: cart.note\n }\n }\n}\n","/**\n * GraphQL queries for product operations\n */\n\nexport const PRODUCT_FRAGMENT = `\n fragment ProductFragment on Product {\n id\n handle\n title\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n requiresSellingPlan\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n id\n url\n altText\n width\n height\n }\n images(first: 10) {\n nodes {\n id\n url\n altText\n width\n height\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n quantityAvailable\n sellingPlanAllocations(first: 10) {\n edges {\n node {\n sellingPlan {\n id\n }\n }\n }\n }\n sku\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n }\n options {\n id\n name\n values\n }\n collections(first: 10) {\n nodes {\n id\n handle\n title\n }\n }\n }\n`\n\nexport const GET_PRODUCT_BY_HANDLE = `\n query getProductByHandle($handle: String!) {\n product(handle: $handle) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_BY_ID = `\n query getProductById($id: ID!) {\n product(id: $id) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_RECOMMENDATIONS = `\n query getProductRecommendations($productId: ID!) {\n productRecommendations(productId: $productId) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n","/**\n * GraphQL queries for customer operations\n */\n\nexport const CUSTOMER_FRAGMENT = `\n fragment CustomerFragment on Customer {\n id\n email\n phone\n firstName\n lastName\n displayName\n defaultAddress {\n id\n address1\n address2\n city\n province\n country\n zip\n }\n }\n`\n\nexport const ORDER_FRAGMENT = `\n fragment OrderFragment on Order {\n id\n orderNumber\n processedAt\n financialStatus\n fulfillmentStatus\n totalPrice {\n amount\n currencyCode\n }\n lineItems(first: 100) {\n nodes {\n title\n quantity\n variant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n }\n }\n }\n }\n`\n\nexport const GET_CUSTOMER = `\n query getCustomer($customerAccessToken: String!) {\n customer(customerAccessToken: $customerAccessToken) {\n ...CustomerFragment\n }\n }\n ${CUSTOMER_FRAGMENT}\n`\n\nexport const GET_CUSTOMER_ORDERS = `\n query getCustomerOrders($customerAccessToken: String!, $first: Int = 20) {\n customer(customerAccessToken: $customerAccessToken) {\n id\n orders(first: $first, sortKey: PROCESSED_AT, reverse: true) {\n nodes {\n ...OrderFragment\n }\n }\n }\n }\n ${ORDER_FRAGMENT}\n`\n","import type {\n IShopifyAdapter,\n Product,\n Customer,\n PageContext,\n PersonizelyConfig,\n PersonizelyConfigMethods,\n ProductData\n} from '../types'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID,\n GET_PRODUCT_RECOMMENDATIONS\n} from '../graphql/queries/product'\nimport { GET_CUSTOMER } from '../graphql/queries/customer'\nimport { toId } from '../utils/id'\n\nexport class Adapter implements IShopifyAdapter {\n private client: StorefrontClient\n\n private currency: {\n active: string\n base: string\n rate: number\n }\n\n private market: string | null\n\n private locale: string\n\n private pageContext: PageContext\n\n private methods?: PersonizelyConfigMethods\n\n private customerAccessToken: string | null = null\n\n constructor (config: PersonizelyConfig, storefrontClient: StorefrontClient) {\n this.client = storefrontClient\n\n this.methods = config.methods\n this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency }\n this.locale = config.locale || 'en-US'\n this.market = config.market || null\n\n this.pageContext = {\n pageType: undefined,\n product: null,\n collection: null\n }\n }\n\n /**\n * Set customer access token for authenticated requests\n */\n setCustomerAccessToken (token: string | null): void {\n this.customerAccessToken = token\n }\n\n /**\n * Fetch product by handle from Storefront API\n */\n async fetchProduct (handle: string): Promise<ProductData> {\n const data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n\n if (!data.product) {\n throw new Error(`Product not found: ${handle}`)\n }\n\n return this.toProductData(data.product)\n }\n\n /**\n * Fetch product collections metadata\n */\n async fetchProductCollections (handle: string, productId: number): Promise<number[]> {\n let data\n if (productId) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` })\n } else if (handle) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n }\n\n if (!data || !data.product) {\n throw new Error(`Product not found: ${productId}`)\n }\n\n return data.product.collections.nodes.map(c => toId(c.id))\n }\n\n /**\n * Fetch product recommendations\n */\n async fetchRecommendations (productId: number, intent: string): Promise<{ products: ProductData[], intent: string }> {\n const data = await this.client.query<{ productRecommendations: Product[] }>(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent })\n\n return {\n intent,\n products: data.productRecommendations.map(p => this.toProductData(p)) || []\n }\n }\n\n /**\n * Build product URL path\n */\n buildProductPath (product: { handle: string }): string {\n if (typeof this.methods?.builtProductPath !== 'function') return `/products/${product.handle}`\n\n return this.methods.builtProductPath(product)\n }\n\n /**\n * Convert currency amount\n */\n convertToBaseCurrency (amount: number): number {\n return this.currency.rate / amount\n }\n\n /**\n * Convert currency amount\n */\n convertFromBaseCurrency (amount: number): number {\n return this.currency.rate * amount\n }\n\n /**\n * Format money according to shop's format\n */\n formatMoney (amount: number, includeDecimals: boolean = true): string {\n if (typeof this.methods?.formatMoney !== 'function') return new Intl.NumberFormat(this.locale, {\n style: 'currency',\n currency: this.currency.active,\n maximumFractionDigits: includeDecimals ? undefined : 0\n }).format(amount / 100)\n\n return this.methods.formatMoney(amount, includeDecimals)\n }\n\n /**\n * Fetch customer data from Storefront API\n * Requires customer access token to be set\n */\n async getCustomer (): Promise<Customer | null> {\n if (!this.customerAccessToken) {\n return null\n }\n\n try {\n const data = await this.client.query<{ customer: Customer }>(GET_CUSTOMER, { customerAccessToken: this.customerAccessToken })\n\n return data.customer || null\n } catch (error) {\n console.error('Error fetching customer:', error)\n return null\n }\n }\n\n /**\n * Get current page context\n * Auto-detected from Remix router in Provider\n */\n getPageContext (): PageContext {\n return this.pageContext\n }\n\n setPageContext (context: Partial<PageContext>) {\n if (context.product) {\n context.product.id = toId(String(context.product.id))\n }\n if (context.collection) {\n context.collection.id = toId(String(context.collection.id))\n }\n this.pageContext = context\n }\n\n getVisitorId (): string | null {\n return null\n }\n\n /**\n * Get current market information\n */\n getMarket (): string | null {\n return this.market\n }\n\n /**\n * Get currency conversion rate\n * Note: Stub implementation\n */\n getCurrencyRate (): number {\n return this.currency.rate\n }\n\n /**\n * Transform Hydrogen Product to snippet-manager ProductData format\n */\n toProductData (product: Product): ProductData {\n return {\n id: toId(product.id),\n handle: product.handle,\n title: product.title,\n available: product.availableForSale,\n requires_selling_plan: product.requiresSellingPlan,\n images: product.images.nodes.map(img => img.url),\n variants: product.variants.nodes.map(variant => ({\n id: toId(variant.id),\n title: variant.title,\n available: variant.availableForSale,\n price: Math.round(parseFloat(variant.price.amount) * 100), // Convert to cents\n compare_at_price: variant.compareAtPrice\n ? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)\n : null,\n featured_image: variant.image ? { src: variant.image.url } : null,\n selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({\n selling_plan_id: edge.node.sellingPlan.id\n })) || []\n }))\n }\n }\n}\n","/**\n * Shopify Storefront API GraphQL client\n */\n\nexport type StorefrontClientConfig = {\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n}\n\nexport class StorefrontClient {\n private storefrontAccessToken: string\n\n private shopDomain: string\n\n private apiVersion: string\n\n private endpoint: string\n\n constructor (config: StorefrontClientConfig) {\n this.storefrontAccessToken = config.storefrontAccessToken\n this.shopDomain = config.shopDomain\n this.apiVersion = config.apiVersion || '2024-01'\n this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`\n }\n\n /**\n * Execute a GraphQL query against the Storefront API\n */\n async query<T = any>(query: string, variables?: Record<string, any>): Promise<T> {\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken\n },\n body: JSON.stringify({\n query,\n variables\n })\n })\n\n if (!response.ok) {\n throw new Error(`Storefront API request failed: ${response.statusText}`)\n }\n\n const result = await response.json()\n\n if (result.errors) {\n throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`)\n }\n\n return result.data as T\n } catch (error) {\n console.error('Storefront API error:', error)\n throw error\n }\n }\n\n /**\n * Execute a GraphQL mutation against the Storefront API\n */\n async mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T> {\n return this.query<T>(mutation, variables)\n }\n}\n","import React, { createContext, useEffect, useMemo, useRef, ReactNode } from 'react'\nimport { useMatches, useRevalidator } from 'react-router'\nimport {\n PersonizelyConfigMethods,\n HydrogenConfig,\n CartAddProduct\n} from '../types'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { Cart } from '../classes/Cart'\nimport { Adapter } from '../classes/Adapter'\nimport { StorefrontClient } from '../utils/storefront-client'\n\ndeclare global {\n interface Window {\n __PLY_HYDROGEN_CONFIG__?: HydrogenConfig\n }\n}\n\nexport type PersonizelyContextType = {\n cart: Cart\n adapter: Adapter\n websiteApiKey: string\n triggerCartAdd: (product: CartAddProduct) => Promise<boolean>\n triggerCheckout: () => Promise<boolean>\n}\n\nexport const PersonizelyContext = createContext<PersonizelyContextType | null>(null)\n\nexport type PersonizelyProviderProps = {\n websiteApiKey: string\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n scriptBaseUrl?: string\n locale?: string\n currency?: {\n rate: number\n active: string\n base: string\n }\n market?: string\n methods?: PersonizelyConfigMethods\n children: ReactNode\n /**\n * Optional: Customer access token for authenticated requests\n */\n customerAccessToken?: string | null\n}\n\nexport function PersonizelyProvider ({\n websiteApiKey,\n storefrontAccessToken,\n shopDomain,\n locale,\n currency,\n market,\n apiVersion,\n scriptBaseUrl,\n methods,\n children,\n customerAccessToken\n}: PersonizelyProviderProps) {\n const matches = useMatches()\n const rootMatch = matches.find(m => m.id === 'root')\n const localCart = (rootMatch?.loaderData as any)?.cart as Promise<CartReturn>\n const revalidator = useRevalidator()\n\n const storefrontClient = useMemo(() => {\n return new StorefrontClient({\n storefrontAccessToken,\n shopDomain,\n apiVersion\n })\n }, [storefrontAccessToken, shopDomain, apiVersion])\n\n const adapter = useMemo(() => {\n const adapterInstance = new Adapter({\n locale,\n currency,\n market,\n methods\n }, storefrontClient)\n\n if (customerAccessToken) {\n adapterInstance.setCustomerAccessToken(customerAccessToken)\n }\n\n return adapterInstance\n }, [])\n\n const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), [])\n\n // Update cart data when it changes from the loader\n const prevCartDataRef = useRef<CartReturn | null>(null)\n useEffect(() => {\n localCart.then((data) => {\n if (data && data !== prevCartDataRef.current) {\n cart.updateCartData(data)\n cart.notifyListeners()\n prevCartDataRef.current = data\n }\n })\n }, [localCart, cart])\n\n const cartAddCallbacksRef = useRef<Array<(product: CartAddProduct) => Promise<boolean>>>([])\n const checkoutCallbacksRef = useRef<Array<() => Promise<boolean>>>([])\n\n // Set up window.__PLY_HYDROGEN_CONFIG__ and load Personizely script\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n\n window.__PLY_HYDROGEN_CONFIG__ = {\n cart,\n adapter,\n onCartAdd: (callback) => {\n cartAddCallbacksRef.current.push(callback)\n\n return () => {\n const index = cartAddCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n cartAddCallbacksRef.current.splice(index, 1)\n }\n }\n },\n onCheckout: (callback) => {\n checkoutCallbacksRef.current.push(callback)\n\n return () => {\n const index = checkoutCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n checkoutCallbacksRef.current.splice(index, 1)\n }\n }\n }\n }\n\n const script = document.createElement('script')\n const baseUrl = scriptBaseUrl || 'https://static.personizely.net'\n script.src = `${baseUrl}/${websiteApiKey}.js`\n document.head.appendChild(script)\n\n return () => {\n delete window.__PLY_HYDROGEN_CONFIG__\n if (script) {\n script.remove()\n }\n }\n }, [])\n\n const contextValue = useMemo(() => ({\n cart,\n adapter,\n websiteApiKey,\n triggerCartAdd: async (product: CartAddProduct): Promise<boolean> => {\n let shown = false\n for (const callback of cartAddCallbacksRef.current) {\n try {\n const result = await callback(product)\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Cart add callback error:', error)\n }\n }\n return shown\n },\n triggerCheckout: async (): Promise<boolean> => {\n let shown = false\n for (const callback of checkoutCallbacksRef.current) {\n try {\n const result = await callback()\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Checkout callback error:', error)\n }\n }\n return shown\n }\n }), [cart, adapter, websiteApiKey])\n\n return (\n <PersonizelyContext.Provider value={contextValue}>\n {children}\n </PersonizelyContext.Provider>\n )\n}\n","/**\n * usePersonizely - Access Personizely context\n */\n\nimport { useContext } from 'react'\nimport { PersonizelyContext, PersonizelyContextType } from '../components/PersonizelyProvider'\n\n/**\n * Hook to access Personizely context\n * Provides access to cart, adapter, and configuration\n *\n * @returns PersonizelyContextType\n * @throws Error if used outside PersonizelyProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { cart, adapter } = usePersonizely()\n * // Use cart and adapter...\n * }\n * ```\n */\nexport function usePersonizely (): PersonizelyContextType {\n const context = useContext(PersonizelyContext)\n\n if (!context) {\n throw new Error('usePersonizely must be used within a PersonizelyProvider. ' +\n 'Make sure your component is wrapped with <PersonizelyProvider>.')\n }\n\n return context\n}\n","/**\n * useCartAdd - Hook to trigger Personizely cart add widgets\n */\n\nimport { useCallback } from 'react'\nimport type { CartAddProduct } from '../types'\nimport { usePersonizely } from './usePersonizely'\nimport { toId } from '../utils/id'\n\n/**\n * Hook to trigger Personizely cart add event\n * Call this when a product is being added to cart to show relevant widgets\n *\n * @returns Function to trigger cart add event\n *\n * @example\n * ```tsx\n * function ProductForm({ product, selectedVariant }) {\n * const triggerCartAdd = useCartAdd()\n *\n * const handleAddToCart = async () => {\n * const widgetShown = await triggerCartAdd({\n * id: product.id,\n * variantId: selectedVariant.id,\n * price: parseFloat(selectedVariant.price.amount),\n * quantity: 1,\n * handle: product.handle\n * })\n *\n * if (!widgetShown) {\n * await cart.linesAdd([{\n * merchandiseId: selectedVariant.id,\n * quantity: 1\n * }])\n * }\n * }\n *\n * return <button onClick={handleAddToCart}>Add to Cart</button>\n * }\n * ```\n */\nexport function useCartAdd () {\n const personizely = usePersonizely()\n\n return useCallback(async (product: CartAddProduct): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCartAdd({\n ...product,\n id: toId(String(product.id)),\n variantId: toId(String(product.variantId)),\n price: Number(product.price) * 100\n })\n }, [personizely])\n}\n","/**\n * useCheckout - Hook to trigger Personizely checkout widgets\n */\n\nimport { useCallback } from 'react'\nimport { usePersonizely } from './usePersonizely'\n\n/**\n * Hook to trigger Personizely checkout event\n * Call this when proceeding to checkout to show relevant widgets\n *\n * @returns Function to trigger checkout event\n *\n * @example\n * ```tsx\n * function CheckoutButton() {\n * const triggerCheckout = useCheckout()\n *\n * const handleCheckout = async () => {\n * const widgetShown = await triggerCheckout()\n *\n * if (!widgetShown) {\n * window.location.href = cart.checkoutUrl\n * }\n * }\n *\n * return <button onClick={handleCheckout}>Checkout</button>\n * }\n * ```\n */\nexport function useCheckout () {\n const personizely = usePersonizely()\n\n return useCallback(async (): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCheckout()\n }, [personizely])\n}\n","import { usePersonizely } from './usePersonizely'\nimport { PageContext } from '../types'\n\nexport function usePageContext (context: Partial<PageContext>) {\n const personizely = usePersonizely()\n\n personizely.adapter.setPageContext(context)\n}\n"],"mappings":"gLAUA,SAAgB,EAAY,EAA6B,CACvD,GAAI,OAAO,SAAa,IACtB,OAAO,KAGT,IAAM,EAAS,EAAO,IAChB,EAAU,SAAS,OAAO,MAAM,IAAI,CAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAI,EAAS,EAAQ,GACrB,KAAO,EAAO,OAAO,EAAE,GAAK,KAC1B,EAAS,EAAO,UAAU,EAAG,EAAO,OAAO,CAE7C,GAAI,EAAO,QAAQ,EAAO,GAAK,EAC7B,OAAO,EAAO,UAAU,EAAO,OAAQ,EAAO,OAAO,CAIzD,OAAO,KAUT,SAAgB,EAAc,EAC5B,EACA,EACA,EAAe,IAAW,CAC1B,GAAI,OAAO,SAAa,IACtB,OAGF,IAAI,EAAU,GACd,GAAI,EAAM,CACR,IAAM,EAAO,IAAI,KACjB,EAAK,QAAQ,EAAK,SAAS,CAAI,EAAO,GAAK,GAAK,GAAK,IAAM,CAC3D,EAAU,aAAe,EAAK,aAAa,CAG7C,SAAS,OAAS,EAAO,IAAM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QACzC,GAAI,CACa,MAAM,EAAS,EAAQ,GAEpC,EAAQ,UAEH,EAAO,CACd,QAAQ,MAAM,2BAA4B,EAAM,CAGpD,OAAO,GAET,gBAAiB,SAA8B,CAC7C,IAAI,EAAQ,GACZ,IAAK,IAAM,KAAY,EAAqB,QAC1C,GAAI,CACa,MAAM,GAAU,GAE7B,EAAQ,UAEH,EAAO,CACd,QAAQ,MAAM,2BAA4B,EAAM,CAGpD,OAAO,GAEV,EAAG,CAAC,EAAM,EAAS,EAAc,CAAC,CAEnC,OACE,EAAA,cAAC,EAAmB,SAAA,CAAS,MAAO,EAAA,CACjC,EAC2B,CCtKlC,SAAgB,GAA0C,CACxD,IAAM,EAAU,EAAW,EAAmB,CAE9C,GAAI,CAAC,EACH,MAAU,MAAM,4HACoD,CAGtE,OAAO,ECWT,SAAgB,GAAc,CAC5B,IAAM,EAAc,GAAgB,CAEpC,OAAO,EAAY,KAAO,IACpB,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,eAAe,CACtC,GAAG,EACH,GAAI,EAAK,OAAO,EAAQ,GAAG,CAAC,CAC5B,UAAW,EAAK,OAAO,EAAQ,UAAU,CAAC,CAC1C,MAAO,OAAO,EAAQ,MAAM,CAAG,IAChC,CAAC,CACD,CAAC,EAAY,CAAC,CCzBnB,SAAgB,GAAe,CAC7B,IAAM,EAAc,GAAgB,CAEpC,OAAO,EAAY,SACb,OAAO,OAAW,IACb,GAGF,MAAM,EAAY,iBAAiB,CACzC,CAAC,EAAY,CAAC,CCpCnB,SAAgB,EAAgB,EAA+B,CACzC,GAAgB,CAExB,QAAQ,eAAe,EAAQ"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["result: any","linesToUpdate: any[]","linesToAdd: any[]","line","mutations: Promise<any>[]"],"sources":["../src/utils/cookies.ts","../src/graphql/queries/cart.ts","../src/utils/id.ts","../src/classes/Cart.ts","../src/graphql/queries/product.ts","../src/classes/Adapter.ts","../src/utils/storefront-client.ts","../src/components/PersonizelyProvider.tsx","../src/hooks/usePersonizely.ts","../src/hooks/useCartAdd.ts","../src/hooks/useCheckout.ts","../src/hooks/usePageContext.ts"],"sourcesContent":["/**\n * Cookie utilities for browser storage\n * Mirrors cookie helpers from snippet-manager\n */\n\n/**\n * Read a cookie value by name\n * @param name - Cookie name\n * @returns Cookie value or null if not found\n */\nexport function readCookie (name: string): string | null {\n if (typeof document === 'undefined') {\n return null\n }\n\n const nameEQ = name + '='\n const cookies = document.cookie.split(';')\n\n for (let i = 0; i < cookies.length; i++) {\n let cookie = cookies[i]\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length)\n }\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length)\n }\n }\n\n return null\n}\n\n/**\n * Create/update a cookie\n * @param name - Cookie name\n * @param value - Cookie value\n * @param days - Expiration in days (optional, default: session cookie)\n * @param path - Cookie path (default: '/')\n */\nexport function createCookie (name: string,\n value: string,\n days?: number,\n path: string = '/'): void {\n if (typeof document === 'undefined') {\n return\n }\n\n let expires = ''\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))\n expires = '; expires=' + date.toUTCString()\n }\n\n document.cookie = name + '=' + value + expires + '; path=' + path\n}\n\n/**\n * Delete a cookie by name\n * @param name - Cookie name\n * @param path - Cookie path (default: '/')\n */\nexport function deleteCookie (name: string, path: string = '/'): void {\n createCookie(name, '', -1, path)\n}\n","/**\n * GraphQL queries and mutations for cart operations\n */\n\nexport const CART_FRAGMENT = `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n nodes {\n id\n quantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n amountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n title\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n selectedOptions {\n name\n value\n }\n product {\n id\n handle\n title\n featuredImage {\n url\n altText\n }\n tags\n }\n }\n }\n attributes {\n key\n value\n }\n }\n }\n discountCodes {\n code\n applicable\n }\n attributes {\n key\n value\n }\n }\n`\n\nexport const GET_CART = `\n query getCart($cartId: ID!) {\n cart(id: $cartId) {\n ...CartFragment\n }\n }\n ${CART_FRAGMENT}\n`\n\n/**\n * Cart mutations\n */\n\nexport const CART_LINES_ADD = `\n mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_UPDATE = `\n mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_LINES_REMOVE = `\n mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_DISCOUNT_CODES_UPDATE = `\n mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n\nexport const CART_ATTRIBUTES_UPDATE = `\n mutation cartAttributesUpdate($cartId: ID!, $attributes: [AttributeInput!]!) {\n cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {\n cart {\n ...CartFragment\n }\n userErrors {\n field\n message\n }\n }\n }\n ${CART_FRAGMENT}\n`\n","export function toGId (id: number, type: string): string {\n return `gid://shopify/${type}/${id}`\n}\n\nexport function toId (id: string): number {\n return Number(id.split('/').pop())\n}","import type { CartData, ICart } from '../types'\nimport { createCookie, readCookie } from '../utils/cookies'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n CART_LINES_ADD,\n CART_LINES_UPDATE,\n CART_LINES_REMOVE,\n CART_DISCOUNT_CODES_UPDATE,\n CART_ATTRIBUTES_UPDATE\n} from '../graphql/queries/cart'\nimport { toGId, toId } from '../utils/id'\n\nconst COUPON_COOKIE_NAME = '_ply_coupon'\n\nexport class Cart implements ICart {\n private storefrontClient: StorefrontClient\n\n private listeners: Array<(cart: CartData) => void> = []\n\n private cart: CartReturn | null = null\n\n private cartPromise: Promise<CartReturn> | null\n\n private revalidate?: () => void\n\n constructor (cartPromise: Promise<CartReturn>, storefrontClient: StorefrontClient, revalidate?: () => void) {\n this.storefrontClient = storefrontClient\n this.cartPromise = cartPromise\n this.revalidate = revalidate\n }\n\n /**\n * Update internal cart data\n * Called by Provider when cart data changes from loader\n */\n updateCartData (cart: CartReturn): void {\n this.cart = cart\n this.cartPromise = null\n }\n\n /**\n * Notify all listeners of cart change\n * Called by Provider when cart updates\n */\n notifyListeners (): void {\n if (!this.cart) return\n\n this.listeners.forEach((listener) => {\n try {\n if (this.cart) {\n listener(this.toCartData(this.cart))\n }\n } catch (error) {\n console.error('Cart listener error:', error)\n }\n })\n }\n\n /**\n * Check if cart data is loaded and synced\n */\n isSynced (): boolean {\n return !!this.cart\n }\n\n /**\n * Register a callback to be called when cart changes\n * Returns a function to unregister the callback\n */\n onChange (callback: (cart: CartData) => void): () => void {\n this.listeners.push(callback)\n\n // Return unsubscribe function\n return () => {\n const index = this.listeners.indexOf(callback)\n if (index > -1) {\n this.listeners.splice(index, 1)\n }\n }\n }\n\n /**\n * Fetch current cart data\n * Returns cached cart data from loader (always fresh from React Router)\n */\n async fetch (force: boolean = true): Promise<CartData | null> {\n if (this.cart && !force) {\n return this.toCartData(this.cart)\n }\n\n if (this.cartPromise) {\n this.cart = await this.cartPromise\n return this.toCartData(this.cart)\n }\n\n if (!this.cart) return null\n\n return this.toCartData(this.cart)\n }\n\n /**\n * Update cart via Storefront API mutations\n * Actions: 'add', 'update', 'change', 'clear'\n */\n async update (action: string, data: any): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n const lineIds = this.cart.lines.nodes.map((line: any) => line.id)\n\n try {\n let result: any\n\n switch (action) {\n case 'add':\n result = await this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: [{\n merchandiseId: toGId(data.id, 'ProductVariant'),\n quantity: data.quantity || 1,\n attributes: data.properties\n ? Object.entries(data.properties).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n : undefined\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesAdd?.cart) {\n this.cart = result.cartLinesAdd.cart\n this.notifyListeners()\n }\n break\n\n case 'update':\n case 'change':\n // Handle Cart AJAX API format: { updates: { [variantId]: quantity }, attributes: {...} }\n if (data.updates) {\n // Separate into lines to update vs lines to add\n const linesToUpdate: any[] = []\n const linesToAdd: any[] = []\n\n Object.entries(data.updates).forEach(([variantId, quantity]) => {\n const line = this.cart!.lines.nodes.find((line: any) =>\n toId(line.merchandise.id) === Number(variantId))\n\n if (line) {\n linesToUpdate.push({\n id: line.id,\n quantity: Number(quantity)\n })\n } else if (Number(quantity) > 0) {\n // Line doesn't exist and quantity > 0 - add it\n linesToAdd.push({\n merchandiseId: toGId(Number(variantId), 'ProductVariant'),\n quantity: Number(quantity)\n })\n }\n })\n\n // Execute mutations in parallel\n const mutations: Promise<any>[] = []\n\n if (linesToUpdate.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: linesToUpdate\n }))\n }\n\n if (linesToAdd.length > 0) {\n mutations.push(this.storefrontClient.mutate(CART_LINES_ADD, {\n cartId: this.cart.id,\n lines: linesToAdd\n }))\n }\n\n if (mutations.length > 0) {\n const results = await Promise.all(mutations)\n // Use the last result's cart (both mutations return the updated cart)\n const lastResult = results[results.length - 1]\n if (lastResult?.cartLinesUpdate?.cart || lastResult?.cartLinesAdd?.cart) {\n this.cart = lastResult.cartLinesUpdate?.cart || lastResult.cartLinesAdd?.cart\n this.notifyListeners()\n }\n }\n } else if (data.id) {\n // Handle single line item update\n result = await this.storefrontClient.mutate(CART_LINES_UPDATE, {\n cartId: this.cart.id,\n lines: [{\n id: `gid://shopify/CartLine/${data.id}`,\n quantity: data.quantity\n }]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesUpdate?.cart) {\n this.cart = result.cartLinesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle cart-level attributes update\n if (data.attributes && this.cart) {\n result = await this.storefrontClient.mutate(CART_ATTRIBUTES_UPDATE, {\n cartId: this.cart.id,\n attributes: Object.entries(data.attributes).map(([key, value]) => ({\n key,\n value: String(value)\n }))\n })\n\n // Update local cart immediately\n if (result?.cartAttributesUpdate?.cart) {\n this.cart = result.cartAttributesUpdate.cart\n this.notifyListeners()\n }\n }\n\n // Handle discount update\n if (data.discount && this.cart) {\n result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [data.discount]\n })\n\n // Update local cart immediately\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n }\n break\n\n case 'clear':\n result = await this.storefrontClient.mutate(CART_LINES_REMOVE, {\n cartId: this.cart.id,\n lineIds\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartLinesRemove?.cart) {\n this.cart = result.cartLinesRemove.cart\n this.notifyListeners()\n }\n break\n\n default:\n console.warn(`Unknown cart action: ${action}`)\n }\n\n // Trigger revalidation to fetch fresh cart data from loader\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Cart update error:', error)\n throw error\n }\n }\n\n /**\n * Quick buy - redirect to checkout with variant\n */\n async buy (_variantId: string, _quantity: number = 1): Promise<void> {\n if (!this.cart) return\n\n const coupon = this.getCoupon()\n const baseUrl = this.cart.checkoutUrl || '/checkout'\n const url = coupon ? `${baseUrl}?discount=${coupon}` : baseUrl\n\n if (typeof window !== 'undefined') {\n window.location.href = url\n }\n }\n\n /**\n * Get cart data or specific property\n */\n get (property?: string): any {\n if (!this.cart) {\n return property ? undefined : null\n }\n\n if (!property) {\n return this.toCartData(this.cart)\n }\n\n return (this.toCartData(this.cart) as any)[property]\n }\n\n /**\n * Get cart token/ID\n */\n getToken (): string | null {\n if (!this.cart) return null\n\n return this.cart.id || null\n }\n\n /**\n * Get array of product IDs in cart\n */\n getItemsIds (): string[] {\n if (!this.cart) {\n return []\n }\n\n return this.cart.lines.nodes.map(line => line.merchandise.product.id)\n }\n\n /**\n * Get cart currency code\n */\n getCurrency (): string {\n if (!this.cart) return 'USD'\n\n return this.cart.cost.totalAmount.currencyCode\n }\n\n /**\n * Get cart total value\n * For Hydrogen, currency conversion would need to be handled separately\n */\n getValue (_currency?: string): number {\n if (!this.cart) return 0\n\n return parseFloat(this.cart.cost.totalAmount.amount) * 100\n }\n\n /**\n * Get cart item count\n * @param distinct - Count distinct products instead of total quantity\n */\n getSize (distinct: boolean = false): number {\n if (!this.cart) return 0\n\n if (distinct) {\n const uniqueProductIds = new Set(this.cart.lines.nodes.map(line => line.merchandise.product.id))\n return uniqueProductIds.size\n }\n\n return this.cart.totalQuantity\n }\n\n /**\n * Fetch cart collections data\n * Requires custom implementation or metafield query\n */\n async fetchCollections (_force: boolean = false): Promise<any> {\n console.warn('fetchCollections: Not implemented for Hydrogen. Use custom metafield query.')\n return {}\n }\n\n /**\n * Apply discount code to cart\n */\n async applyCoupon (code: string, expiresIn?: number): Promise<void> {\n if (!this.cart) {\n throw new Error('Cart not initialized')\n }\n\n // Store in cookie\n createCookie(COUPON_COOKIE_NAME, code, expiresIn)\n\n try {\n const result = await this.storefrontClient.mutate(CART_DISCOUNT_CODES_UPDATE, {\n cartId: this.cart.id,\n discountCodes: [code]\n })\n\n // Update local cart immediately with mutation response\n if (result?.cartDiscountCodesUpdate?.cart) {\n this.cart = result.cartDiscountCodesUpdate.cart\n this.notifyListeners()\n }\n\n // Trigger revalidation to fetch fresh cart data from loader (backup)\n if (this.revalidate) {\n this.revalidate()\n }\n } catch (error) {\n console.error('Error applying coupon:', error)\n throw error\n }\n }\n\n /**\n * Get currently applied coupon code\n */\n getCoupon (): string | null {\n if (!this.cart) return null\n\n // First check cart discount codes\n if (this.cart.discountCodes && this.cart.discountCodes.length > 0) {\n return this.cart.discountCodes[0].code\n }\n\n // Fall back to cookie\n return readCookie(COUPON_COOKIE_NAME)\n }\n\n /**\n * Convert Hydrogen cart to CartData format\n * For compatibility with snippet-manager\n */\n private toCartData (cart: CartReturn): CartData {\n return {\n token: cart.id,\n item_count: cart.totalQuantity || 0,\n items: (cart.lines?.nodes || []).map(line => ({\n id: toId(line.id),\n product_id: toId(line.merchandise.product.id),\n variant_id: toId(line.merchandise.id),\n price: Number(line.merchandise.price.amount) * 100,\n quantity: line.quantity\n })),\n total_price: Number(cart.cost.totalAmount.amount) * 100,\n discount_codes: cart.discountCodes,\n attributes: cart.attributes,\n note: cart.note\n }\n }\n}\n","/**\n * GraphQL queries for product operations\n */\n\nexport const PRODUCT_FRAGMENT = `\n fragment ProductFragment on Product {\n id\n handle\n title\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n requiresSellingPlan\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n id\n url\n altText\n width\n height\n }\n images(first: 10) {\n nodes {\n id\n url\n altText\n width\n height\n }\n }\n variants(first: 100) {\n nodes {\n id\n title\n availableForSale\n quantityAvailable\n sellingPlanAllocations(first: 10) {\n edges {\n node {\n sellingPlan {\n id\n }\n }\n }\n }\n sku\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url\n altText\n width\n height\n }\n }\n }\n options {\n id\n name\n values\n }\n collections(first: 10) {\n nodes {\n id\n handle\n title\n }\n }\n }\n`\n\nexport const GET_PRODUCT_BY_HANDLE = `\n query getProductByHandle($handle: String!) {\n product(handle: $handle) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_BY_ID = `\n query getProductById($id: ID!) {\n product(id: $id) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n\nexport const GET_PRODUCT_RECOMMENDATIONS = `\n query getProductRecommendations($productId: ID!) {\n productRecommendations(productId: $productId) {\n ...ProductFragment\n }\n }\n ${PRODUCT_FRAGMENT}\n`\n","import type {\n IShopifyAdapter,\n Product,\n Customer,\n PageContext,\n PersonizelyConfig,\n PersonizelyConfigMethods,\n ProductData\n} from '../types'\nimport { StorefrontClient } from '../utils/storefront-client'\nimport {\n GET_PRODUCT_BY_HANDLE, GET_PRODUCT_BY_ID,\n GET_PRODUCT_RECOMMENDATIONS\n} from '../graphql/queries/product'\nimport { toId } from '../utils/id'\n\nexport class Adapter implements IShopifyAdapter {\n private client: StorefrontClient\n\n private currency: {\n active: string\n base: string\n rate: number\n }\n\n private market: string | null\n\n private locale: string\n\n private pageContext: PageContext\n\n private methods?: PersonizelyConfigMethods\n\n private customer: Customer | null = null\n\n constructor (config: PersonizelyConfig, storefrontClient: StorefrontClient) {\n this.client = storefrontClient\n\n this.methods = config.methods\n this.currency = { active: 'USD', base: 'USD', rate: 1, ...config.currency }\n this.locale = config.locale || 'en-US'\n this.market = config.market || null\n\n this.pageContext = {\n pageType: undefined,\n product: null,\n collection: null\n }\n }\n\n /**\n * Set customer data\n * Allows library users to provide customer information directly\n */\n setCustomer (customer: Customer | null): void {\n this.customer = customer\n }\n\n /**\n * Fetch product by handle from Storefront API\n */\n async fetchProduct (handle: string): Promise<ProductData> {\n const data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n\n if (!data.product) {\n throw new Error(`Product not found: ${handle}`)\n }\n\n return this.toProductData(data.product)\n }\n\n /**\n * Fetch product collections metadata\n */\n async fetchProductCollections (handle: string, productId: number): Promise<number[]> {\n let data\n if (productId) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_ID, { id: `gid://shopify/Product/${productId}` })\n } else if (handle) {\n data = await this.client.query<{ product: Product }>(GET_PRODUCT_BY_HANDLE, { handle })\n }\n\n if (!data || !data.product) {\n throw new Error(`Product not found: ${productId}`)\n }\n\n return data.product.collections.nodes.map(c => toId(c.id))\n }\n\n /**\n * Fetch product recommendations\n */\n async fetchRecommendations (productId: number, intent: string): Promise<{ products: ProductData[], intent: string }> {\n const data = await this.client.query<{ productRecommendations: Product[] }>(GET_PRODUCT_RECOMMENDATIONS, { productId: `gid://shopify/Product/${productId}`, intent })\n\n return {\n intent,\n products: data.productRecommendations.map(p => this.toProductData(p)) || []\n }\n }\n\n /**\n * Build product URL path\n */\n buildProductPath (product: { handle: string }): string {\n if (typeof this.methods?.builtProductPath !== 'function') return `/products/${product.handle}`\n\n return this.methods.builtProductPath(product)\n }\n\n /**\n * Convert currency amount\n */\n convertToBaseCurrency (amount: number): number {\n return this.currency.rate / amount\n }\n\n /**\n * Convert currency amount\n */\n convertFromBaseCurrency (amount: number): number {\n return this.currency.rate * amount\n }\n\n /**\n * Format money according to shop's format\n */\n formatMoney (amount: number, includeDecimals: boolean = true): string {\n if (typeof this.methods?.formatMoney !== 'function') return new Intl.NumberFormat(this.locale, {\n style: 'currency',\n currency: this.currency.active,\n maximumFractionDigits: includeDecimals ? undefined : 0\n }).format(amount / 100)\n\n return this.methods.formatMoney(amount, includeDecimals)\n }\n\n /**\n * Get customer data\n * Returns the customer object set via setCustomer()\n */\n getCustomer (): Customer | null {\n return this.customer\n }\n\n /**\n * Get current page context\n * Auto-detected from Remix router in Provider\n */\n getPageContext (): PageContext {\n return this.pageContext\n }\n\n setPageContext (context: Partial<PageContext>) {\n if (context.product) {\n context.product.id = toId(String(context.product.id))\n }\n if (context.collection) {\n context.collection.id = toId(String(context.collection.id))\n }\n this.pageContext = context\n }\n\n getVisitorId (): string | null {\n return null\n }\n\n /**\n * Get current market information\n */\n getMarket (): string | null {\n return this.market\n }\n\n /**\n * Get currency conversion rate\n * Note: Stub implementation\n */\n getCurrencyRate (): number {\n return this.currency.rate\n }\n\n /**\n * Transform Hydrogen Product to snippet-manager ProductData format\n */\n toProductData (product: Product): ProductData {\n return {\n id: toId(product.id),\n handle: product.handle,\n title: product.title,\n available: product.availableForSale,\n requires_selling_plan: product.requiresSellingPlan,\n images: product.images.nodes.map(img => img.url),\n variants: product.variants.nodes.map(variant => ({\n id: toId(variant.id),\n title: variant.title,\n available: variant.availableForSale,\n price: Math.round(parseFloat(variant.price.amount) * 100), // Convert to cents\n compare_at_price: variant.compareAtPrice\n ? Math.round(parseFloat(variant.compareAtPrice.amount) * 100)\n : null,\n featured_image: variant.image ? { src: variant.image.url } : null,\n selling_plan_allocations: variant.sellingPlanAllocations?.edges?.map(edge => ({\n selling_plan_id: edge.node.sellingPlan.id\n })) || []\n }))\n }\n }\n}\n","/**\n * Shopify Storefront API GraphQL client\n */\n\nexport type StorefrontClientConfig = {\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n}\n\nexport class StorefrontClient {\n private storefrontAccessToken: string\n\n private shopDomain: string\n\n private apiVersion: string\n\n private endpoint: string\n\n constructor (config: StorefrontClientConfig) {\n this.storefrontAccessToken = config.storefrontAccessToken\n this.shopDomain = config.shopDomain\n this.apiVersion = config.apiVersion || '2024-01'\n this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`\n }\n\n /**\n * Execute a GraphQL query against the Storefront API\n */\n async query<T = any>(query: string, variables?: Record<string, any>): Promise<T> {\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken\n },\n body: JSON.stringify({\n query,\n variables\n })\n })\n\n if (!response.ok) {\n throw new Error(`Storefront API request failed: ${response.statusText}`)\n }\n\n const result = await response.json()\n\n if (result.errors) {\n throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`)\n }\n\n return result.data as T\n } catch (error) {\n console.error('Storefront API error:', error)\n throw error\n }\n }\n\n /**\n * Execute a GraphQL mutation against the Storefront API\n */\n async mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T> {\n return this.query<T>(mutation, variables)\n }\n}\n","import React, { createContext, useEffect, useMemo, useRef, ReactNode } from 'react'\nimport { useMatches, useRevalidator } from 'react-router'\nimport {\n PersonizelyConfigMethods,\n HydrogenConfig,\n CartAddProduct,\n Customer\n} from '../types'\nimport type { CartReturn } from '@shopify/hydrogen'\nimport { Cart } from '../classes/Cart'\nimport { Adapter } from '../classes/Adapter'\nimport { StorefrontClient } from '../utils/storefront-client'\n\ndeclare global {\n interface Window {\n __PLY_HYDROGEN_CONFIG__?: HydrogenConfig\n }\n}\n\nexport type PersonizelyContextType = {\n cart: Cart\n adapter: Adapter\n websiteApiKey: string\n triggerCartAdd: (product: CartAddProduct) => Promise<boolean>\n triggerCheckout: () => Promise<boolean>\n}\n\nexport const PersonizelyContext = createContext<PersonizelyContextType | null>(null)\n\nexport type PersonizelyProviderProps = {\n websiteApiKey: string\n storefrontAccessToken: string\n shopDomain: string\n apiVersion?: string\n scriptBaseUrl?: string\n locale?: string\n currency?: {\n rate: number\n active: string\n base: string\n }\n market?: string\n methods?: PersonizelyConfigMethods\n children: ReactNode\n /**\n * Optional: Customer object for personalization\n */\n customer?: Customer | null\n}\n\nexport function PersonizelyProvider ({\n websiteApiKey,\n storefrontAccessToken,\n shopDomain,\n locale,\n currency,\n market,\n apiVersion,\n scriptBaseUrl,\n methods,\n children,\n customer\n}: PersonizelyProviderProps) {\n const matches = useMatches()\n const rootMatch = matches.find(m => m.id === 'root')\n const localCart = (rootMatch?.loaderData as any)?.cart as Promise<CartReturn>\n const revalidator = useRevalidator()\n\n const storefrontClient = useMemo(() => {\n return new StorefrontClient({\n storefrontAccessToken,\n shopDomain,\n apiVersion\n })\n }, [storefrontAccessToken, shopDomain, apiVersion])\n\n const adapter = useMemo(() => {\n return new Adapter({\n locale,\n currency,\n market,\n methods\n }, storefrontClient)\n }, [])\n\n useEffect(() => {\n if (customer) {\n adapter.setCustomer(customer)\n }\n }, [customer, adapter])\n\n const cart = useMemo(() => new Cart(localCart, storefrontClient, revalidator.revalidate), [])\n\n // Update cart data when it changes from the loader\n const prevCartDataRef = useRef<CartReturn | null>(null)\n useEffect(() => {\n localCart.then((data) => {\n if (data && data !== prevCartDataRef.current) {\n cart.updateCartData(data)\n cart.notifyListeners()\n prevCartDataRef.current = data\n }\n })\n }, [localCart, cart])\n\n const cartAddCallbacksRef = useRef<Array<(product: CartAddProduct) => Promise<boolean>>>([])\n const checkoutCallbacksRef = useRef<Array<() => Promise<boolean>>>([])\n\n // Set up window.__PLY_HYDROGEN_CONFIG__ and load Personizely script\n useEffect(() => {\n if (typeof window === 'undefined') {\n return\n }\n\n window.__PLY_HYDROGEN_CONFIG__ = {\n cart,\n adapter,\n onCartAdd: (callback) => {\n cartAddCallbacksRef.current.push(callback)\n\n return () => {\n const index = cartAddCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n cartAddCallbacksRef.current.splice(index, 1)\n }\n }\n },\n onCheckout: (callback) => {\n checkoutCallbacksRef.current.push(callback)\n\n return () => {\n const index = checkoutCallbacksRef.current.indexOf(callback)\n if (index > -1) {\n checkoutCallbacksRef.current.splice(index, 1)\n }\n }\n }\n }\n\n const script = document.createElement('script')\n const baseUrl = scriptBaseUrl || 'https://static.personizely.net'\n script.src = `${baseUrl}/${websiteApiKey}.js`\n document.head.appendChild(script)\n\n return () => {\n delete window.__PLY_HYDROGEN_CONFIG__\n if (script) {\n script.remove()\n }\n }\n }, [])\n\n const contextValue = useMemo(() => ({\n cart,\n adapter,\n websiteApiKey,\n triggerCartAdd: async (product: CartAddProduct): Promise<boolean> => {\n let shown = false\n for (const callback of cartAddCallbacksRef.current) {\n try {\n const result = await callback(product)\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Cart add callback error:', error)\n }\n }\n return shown\n },\n triggerCheckout: async (): Promise<boolean> => {\n let shown = false\n for (const callback of checkoutCallbacksRef.current) {\n try {\n const result = await callback()\n if (result) {\n shown = true\n }\n } catch (error) {\n console.error('Checkout callback error:', error)\n }\n }\n return shown\n }\n }), [cart, adapter, websiteApiKey])\n\n return (\n <PersonizelyContext.Provider value={contextValue}>\n {children}\n </PersonizelyContext.Provider>\n )\n}\n","/**\n * usePersonizely - Access Personizely context\n */\n\nimport { useContext } from 'react'\nimport { PersonizelyContext, PersonizelyContextType } from '../components/PersonizelyProvider'\n\n/**\n * Hook to access Personizely context\n * Provides access to cart, adapter, and configuration\n *\n * @returns PersonizelyContextType\n * @throws Error if used outside PersonizelyProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { cart, adapter } = usePersonizely()\n * // Use cart and adapter...\n * }\n * ```\n */\nexport function usePersonizely (): PersonizelyContextType {\n const context = useContext(PersonizelyContext)\n\n if (!context) {\n throw new Error('usePersonizely must be used within a PersonizelyProvider. ' +\n 'Make sure your component is wrapped with <PersonizelyProvider>.')\n }\n\n return context\n}\n","/**\n * useCartAdd - Hook to trigger Personizely cart add widgets\n */\n\nimport { useCallback } from 'react'\nimport type { CartAddProduct } from '../types'\nimport { usePersonizely } from './usePersonizely'\nimport { toId } from '../utils/id'\n\n/**\n * Hook to trigger Personizely cart add event\n * Call this when a product is being added to cart to show relevant widgets\n *\n * @returns Function to trigger cart add event\n *\n * @example\n * ```tsx\n * function ProductForm({ product, selectedVariant }) {\n * const triggerCartAdd = useCartAdd()\n *\n * const handleAddToCart = async () => {\n * const widgetShown = await triggerCartAdd({\n * id: product.id,\n * variantId: selectedVariant.id,\n * price: parseFloat(selectedVariant.price.amount),\n * quantity: 1,\n * handle: product.handle\n * })\n *\n * if (!widgetShown) {\n * await cart.linesAdd([{\n * merchandiseId: selectedVariant.id,\n * quantity: 1\n * }])\n * }\n * }\n *\n * return <button onClick={handleAddToCart}>Add to Cart</button>\n * }\n * ```\n */\nexport function useCartAdd () {\n const personizely = usePersonizely()\n\n return useCallback(async (product: CartAddProduct): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCartAdd({\n ...product,\n id: toId(String(product.id)),\n variantId: toId(String(product.variantId)),\n price: Number(product.price) * 100\n })\n }, [personizely])\n}\n","/**\n * useCheckout - Hook to trigger Personizely checkout widgets\n */\n\nimport { useCallback } from 'react'\nimport { usePersonizely } from './usePersonizely'\n\n/**\n * Hook to trigger Personizely checkout event\n * Call this when proceeding to checkout to show relevant widgets\n *\n * @returns Function to trigger checkout event\n *\n * @example\n * ```tsx\n * function CheckoutButton() {\n * const triggerCheckout = useCheckout()\n *\n * const handleCheckout = async () => {\n * const widgetShown = await triggerCheckout()\n *\n * if (!widgetShown) {\n * window.location.href = cart.checkoutUrl\n * }\n * }\n *\n * return <button onClick={handleCheckout}>Checkout</button>\n * }\n * ```\n */\nexport function useCheckout () {\n const personizely = usePersonizely()\n\n return useCallback(async (): Promise<boolean> => {\n if (typeof window === 'undefined') {\n return false\n }\n\n return await personizely.triggerCheckout()\n }, [personizely])\n}\n","import { usePersonizely } from './usePersonizely'\nimport { PageContext } from '../types'\n\nexport function usePageContext (context: Partial<PageContext>) {\n const personizely = usePersonizely()\n\n personizely.adapter.setPageContext(context)\n}\n"],"mappings":"gLAUA,SAAgB,EAAY,EAA6B,CACvD,GAAI,OAAO,SAAa,IACtB,OAAO,KAGT,IAAM,EAAS,EAAO,IAChB,EAAU,SAAS,OAAO,MAAM,IAAI,CAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAI,EAAS,EAAQ,GACrB,KAAO,EAAO,OAAO,EAAE,GAAK,KAC1B,EAAS,EAAO,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