@joy-loyalty/hydrogen 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +134 -2
  3. package/dist/cache-control.d.ts +8 -0
  4. package/dist/cache-control.js +6 -0
  5. package/dist/csp.d.ts +14 -0
  6. package/dist/csp.js +33 -0
  7. package/dist/headless-host-adapter.d.ts +5 -0
  8. package/dist/headless-host-adapter.js +197 -0
  9. package/dist/host-adapter/capabilities.d.ts +3 -0
  10. package/dist/host-adapter/capabilities.js +12 -0
  11. package/dist/host-adapter/data-source.d.ts +3 -0
  12. package/dist/host-adapter/data-source.js +49 -0
  13. package/dist/host-adapter/product-fetcher.d.ts +2 -0
  14. package/dist/host-adapter/product-fetcher.js +37 -0
  15. package/dist/host-adapter/promoted-collections.d.ts +2 -0
  16. package/dist/host-adapter/promoted-collections.js +43 -0
  17. package/dist/host-adapter/types.d.ts +212 -0
  18. package/dist/host-adapter/types.js +1 -0
  19. package/dist/hydrogen-cart-port.d.ts +134 -0
  20. package/dist/hydrogen-cart-port.js +245 -0
  21. package/dist/index.d.ts +26 -0
  22. package/dist/index.js +15 -0
  23. package/dist/joy-widget.d.ts +29 -0
  24. package/dist/joy-widget.js +291 -0
  25. package/dist/lib/JoyProvider.d.ts +47 -0
  26. package/dist/lib/JoyProvider.js +95 -0
  27. package/dist/lib/account-links.d.ts +5 -0
  28. package/dist/lib/account-links.js +65 -0
  29. package/dist/lib/apply-behavior.d.ts +12 -0
  30. package/dist/lib/apply-behavior.js +26 -0
  31. package/dist/lib/core-loader.d.ts +63 -0
  32. package/dist/lib/core-loader.js +160 -0
  33. package/dist/lib/core-manifest.d.ts +7 -0
  34. package/dist/lib/core-manifest.js +54 -0
  35. package/dist/lib/core-preload-links.d.ts +8 -0
  36. package/dist/lib/core-preload-links.js +8 -0
  37. package/dist/lib/coupon-mapper.d.ts +95 -0
  38. package/dist/lib/coupon-mapper.js +167 -0
  39. package/dist/lib/custom-links.d.ts +22 -0
  40. package/dist/lib/custom-links.js +56 -0
  41. package/dist/lib/deeplink.d.ts +25 -0
  42. package/dist/lib/deeplink.js +92 -0
  43. package/dist/lib/earn-signup-gate.d.ts +3 -0
  44. package/dist/lib/earn-signup-gate.js +31 -0
  45. package/dist/lib/facebook-ref-link.d.ts +13 -0
  46. package/dist/lib/facebook-ref-link.js +31 -0
  47. package/dist/lib/headless-referral-origin.d.ts +2 -0
  48. package/dist/lib/headless-referral-origin.js +24 -0
  49. package/dist/lib/headless-source.d.ts +8 -0
  50. package/dist/lib/headless-source.js +71 -0
  51. package/dist/lib/image.d.ts +2 -0
  52. package/dist/lib/image.js +14 -0
  53. package/dist/lib/metafield-blob.d.ts +33 -0
  54. package/dist/lib/metafield-blob.js +76 -0
  55. package/dist/lib/money.d.ts +6 -0
  56. package/dist/lib/money.js +25 -0
  57. package/dist/lib/order-mapper.d.ts +44 -0
  58. package/dist/lib/order-mapper.js +141 -0
  59. package/dist/lib/place-order-scope.d.ts +6 -0
  60. package/dist/lib/place-order-scope.js +22 -0
  61. package/dist/lib/points.d.ts +5 -0
  62. package/dist/lib/points.js +10 -0
  63. package/dist/lib/recently-viewed-tracker.d.ts +1 -0
  64. package/dist/lib/recently-viewed-tracker.js +34 -0
  65. package/dist/lib/recommended-loader.d.ts +43 -0
  66. package/dist/lib/recommended-loader.js +111 -0
  67. package/dist/lib/referral-share.d.ts +4 -0
  68. package/dist/lib/referral-share.js +33 -0
  69. package/dist/lib/safe-navigation-url.d.ts +1 -0
  70. package/dist/lib/safe-navigation-url.js +9 -0
  71. package/dist/lib/server-token.d.ts +41 -0
  72. package/dist/lib/server-token.js +87 -0
  73. package/dist/lib/shop-locale.d.ts +1 -0
  74. package/dist/lib/shop-locale.js +21 -0
  75. package/dist/lib/social-earn.d.ts +11 -0
  76. package/dist/lib/social-earn.js +25 -0
  77. package/dist/lib/storefront-fonts.d.ts +5 -0
  78. package/dist/lib/storefront-fonts.js +52 -0
  79. package/dist/lib/token.d.ts +14 -0
  80. package/dist/lib/token.js +135 -0
  81. package/dist/lib/write-review.d.ts +2 -0
  82. package/dist/lib/write-review.js +44 -0
  83. package/dist/loyalty-page/JoyLoyaltyPage.d.ts +151 -0
  84. package/dist/loyalty-page/JoyLoyaltyPage.js +447 -0
  85. package/dist/loyalty-page/compose-home.d.ts +35 -0
  86. package/dist/loyalty-page/compose-home.js +177 -0
  87. package/dist/loyalty-page/skeleton.d.ts +11 -0
  88. package/dist/loyalty-page/skeleton.js +99 -0
  89. package/dist/orchestrator/context.d.ts +61 -0
  90. package/dist/orchestrator/context.js +64 -0
  91. package/dist/orchestrator/gated.d.ts +1 -0
  92. package/dist/orchestrator/gated.js +14 -0
  93. package/dist/orchestrator/handlers/account.d.ts +19 -0
  94. package/dist/orchestrator/handlers/account.js +266 -0
  95. package/dist/orchestrator/handlers/birthday.d.ts +6 -0
  96. package/dist/orchestrator/handlers/birthday.js +128 -0
  97. package/dist/orchestrator/handlers/earn.d.ts +5 -0
  98. package/dist/orchestrator/handlers/earn.js +258 -0
  99. package/dist/orchestrator/handlers/milestone-tier.d.ts +5 -0
  100. package/dist/orchestrator/handlers/milestone-tier.js +123 -0
  101. package/dist/orchestrator/handlers/profile.d.ts +5 -0
  102. package/dist/orchestrator/handlers/profile.js +262 -0
  103. package/dist/orchestrator/handlers/redeem.d.ts +6 -0
  104. package/dist/orchestrator/handlers/redeem.js +464 -0
  105. package/dist/orchestrator/handlers/referral.d.ts +5 -0
  106. package/dist/orchestrator/handlers/referral.js +218 -0
  107. package/dist/orchestrator/render.d.ts +2 -0
  108. package/dist/orchestrator/render.js +193 -0
  109. package/dist/render-adapter.d.ts +50 -0
  110. package/dist/render-adapter.js +422 -0
  111. package/dist/routes/joy-place-order-scope.d.ts +12 -0
  112. package/dist/routes/joy-place-order-scope.js +32 -0
  113. package/dist/routes/joy-products.d.ts +48 -0
  114. package/dist/routes/joy-products.js +326 -0
  115. package/dist/routes/joy-token.d.ts +16 -0
  116. package/dist/routes/joy-token.js +32 -0
  117. package/dist/server/get-joy-initial-data.d.ts +38 -0
  118. package/dist/server/get-joy-initial-data.js +61 -0
  119. package/dist/server/get-joy-loyalty-page-data.d.ts +27 -0
  120. package/dist/server/get-joy-loyalty-page-data.js +99 -0
  121. package/dist/server/index.d.ts +8 -0
  122. package/dist/server/index.js +4 -0
  123. package/dist/widget-controller.d.ts +2 -0
  124. package/dist/widget-controller.js +1 -0
  125. package/dist/widget-orchestrator.d.ts +88 -0
  126. package/dist/widget-orchestrator.js +499 -0
  127. package/package.json +121 -4
@@ -0,0 +1,177 @@
1
+ import { resolveShopLocale } from '../lib/shop-locale.js';
2
+ const SYSTEM_TIER_BRONZE = 'bronze';
3
+ const SYSTEM_TIER_SILVER = 'silver';
4
+ const SYSTEM_TIER_GOLD = 'gold';
5
+ const SYSTEM_TIER_BRONZE_ICON_V2 = 'tier_bronze_icon';
6
+ const SYSTEM_TIER_SLIVER_ICON_V2 = 'tier_sliver_icon';
7
+ const SYSTEM_TIER_GOLD_ICON_V2 = 'tier_gold_icon';
8
+ const TYPE_BRANDING_DEFAULT = 'default';
9
+ const DEFAULT_TIER = {
10
+ name: 'New tier',
11
+ icon: SYSTEM_TIER_BRONZE_ICON_V2,
12
+ iconCustom: '',
13
+ targetPoint: 0,
14
+ targetPointUpdate: 0,
15
+ members: 0,
16
+ placedOrderReward: false,
17
+ rateMoney: '',
18
+ earnPoint: '',
19
+ isSystemTier: false,
20
+ hideDefaultTier: false,
21
+ tierNamesLanguage: {},
22
+ bgType: TYPE_BRANDING_DEFAULT,
23
+ bgImage: '',
24
+ textColor: '#785F4D',
25
+ progressBarColor: '#785F4D',
26
+ boxBgColor: '#EAD8C0',
27
+ boxTextColor: '#785F4D',
28
+ bgCardColor: '#EAD8C0',
29
+ cardOpacity: 0,
30
+ iconColor: '#222222'
31
+ };
32
+ const DEFAULT_TIERS = [
33
+ {
34
+ ...DEFAULT_TIER,
35
+ name: 'Bronze',
36
+ systemType: SYSTEM_TIER_BRONZE,
37
+ isSystemTier: true,
38
+ hideDefaultTier: false,
39
+ descriptionBlock: 'Welcome to the program',
40
+ textColor: '#785F4D',
41
+ progressBarColor: '#785F4D',
42
+ boxBgColor: '#EAD8C0',
43
+ boxTextColor: '#785F4D',
44
+ bgCardColor: '#EAD8C0'
45
+ },
46
+ {
47
+ ...DEFAULT_TIER,
48
+ icon: SYSTEM_TIER_SLIVER_ICON_V2,
49
+ name: 'Silver',
50
+ systemType: SYSTEM_TIER_SILVER,
51
+ targetPoint: 200,
52
+ targetPointUpdate: 200,
53
+ isSystemTier: true,
54
+ hideDefaultTier: false,
55
+ descriptionBlock: 'Spend 200 points to unlock',
56
+ textColor: '#000000',
57
+ progressBarColor: '#000000',
58
+ boxBgColor: '#E6E6E6',
59
+ boxTextColor: '#000000',
60
+ bgCardColor: '#E6E6E6'
61
+ },
62
+ {
63
+ ...DEFAULT_TIER,
64
+ icon: SYSTEM_TIER_GOLD_ICON_V2,
65
+ name: 'Gold',
66
+ systemType: SYSTEM_TIER_GOLD,
67
+ targetPoint: 500,
68
+ targetPointUpdate: 500,
69
+ isSystemTier: true,
70
+ hideDefaultTier: false,
71
+ descriptionBlock: 'Spend 500 points to unlock',
72
+ textColor: '#FFFFFF',
73
+ progressBarColor: '#FFFFFF',
74
+ boxBgColor: '#191919',
75
+ boxTextColor: '#FFFFFF',
76
+ bgCardColor: '#191919',
77
+ iconColor: '#191919'
78
+ }
79
+ ];
80
+ function isRecord(value) {
81
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
82
+ }
83
+ function asRecord(value) {
84
+ return isRecord(value) ? value : {};
85
+ }
86
+ function mergeTierDefaults(tiers) {
87
+ if (!Array.isArray(tiers))
88
+ return [];
89
+ return tiers.map(tier => {
90
+ const raw = asRecord(tier);
91
+ const systemDefault = DEFAULT_TIERS.find(record => record.systemType === raw.systemType);
92
+ return { ...(systemDefault || DEFAULT_TIER), ...raw };
93
+ });
94
+ }
95
+ function readBlobFields(blob) {
96
+ const b = asRecord(blob);
97
+ const program = asRecord(b.program);
98
+ return {
99
+ earning: Array.isArray(program.earning) ? program.earning : [],
100
+ spending: Array.isArray(program.spending) ? program.spending : [],
101
+ tiers: mergeTierDefaults(program.tiers),
102
+ settings: b.settings ?? {},
103
+ translation: isRecord(b.translation) ? b.translation : {},
104
+ shopInfo: b.shop ?? {},
105
+ shop: b.shop ?? {},
106
+ shopId: typeof b.shopId === 'string' ? b.shopId : '',
107
+ tierProgram: b.tierProgram ?? {},
108
+ settingsInteractWebsite: b.settingsInteractWebsite ?? {},
109
+ interactWebsiteProgram: program.interactWebsite ?? b.interactWebsiteProgram ?? {},
110
+ settingsReferral: b.settingsReferral ?? {},
111
+ referralProgram: b.referralProgram
112
+ };
113
+ }
114
+ function applyCustomEarnStatus(earning, customEarnStatus) {
115
+ const canEarnMap = customEarnStatus || {};
116
+ return earning.map(program => {
117
+ const raw = asRecord(program);
118
+ const id = raw.id;
119
+ return id !== undefined && Object.prototype.hasOwnProperty.call(canEarnMap, id)
120
+ ? { ...raw, canEarn: canEarnMap[id] }
121
+ : program;
122
+ });
123
+ }
124
+ function resolvePrimaryTranslation(apiTranslation, blobTranslation) {
125
+ if (isRecord(apiTranslation) && Object.keys(apiTranslation).length)
126
+ return apiTranslation;
127
+ const primary = typeof blobTranslation.primaryLanguage === 'string' ? blobTranslation.primaryLanguage : 'en';
128
+ return asRecord(blobTranslation[primary]);
129
+ }
130
+ function resolveDetectLocale(hostLocale, blobTranslation) {
131
+ const locale = resolveShopLocale(hostLocale, blobTranslation);
132
+ if (!locale)
133
+ return '';
134
+ const primary = typeof blobTranslation.primaryLanguage === 'string' ? blobTranslation.primaryLanguage : 'en';
135
+ return locale.toLowerCase() === primary.toLowerCase() ? '' : locale;
136
+ }
137
+ function withShopifyFirstName(customer, firstName) {
138
+ const raw = asRecord(customer);
139
+ if (!firstName || !raw.id || raw.firstName || raw.first_name)
140
+ return customer ?? {};
141
+ return { ...raw, first_name: firstName };
142
+ }
143
+ export function composeLoyaltyPageHome(blob, apiHalf, hints = {}) {
144
+ const fields = readBlobFields(blob);
145
+ return {
146
+ ...fields,
147
+ earning: applyCustomEarnStatus(fields.earning, apiHalf.customEarnStatus),
148
+ translation: { ...resolvePrimaryTranslation(apiHalf.primaryTranslation, fields.translation), ...fields.translation },
149
+ customer: withShopifyFirstName(apiHalf.customer, hints.customerFirstName),
150
+ applePassWalletSetting: apiHalf.applePassWalletSetting ?? {},
151
+ rewards: Array.isArray(apiHalf.rewards) ? apiHalf.rewards : [],
152
+ detectLocale: resolveDetectLocale(hints.locale, fields.translation),
153
+ ...(hints.detectCountry ? { detectCountry: hints.detectCountry } : {})
154
+ };
155
+ }
156
+ const POINT_LABEL_MODE_TRANSLATION = 'translation';
157
+ export function withResolvedPointLabel(translations, settings) {
158
+ const dictionary = asRecord(translations);
159
+ const s = asRecord(settings);
160
+ const seeded = { ...dictionary };
161
+ for (const [key, doc] of Object.entries(dictionary)) {
162
+ if (!isRecord(doc))
163
+ continue;
164
+ const translated = s.pointLabelMode === POINT_LABEL_MODE_TRANSLATION;
165
+ const plural = (translated && doc.points) || s.pointPlural;
166
+ const singular = (translated && doc.point) || s.pointSingular;
167
+ if (typeof plural !== 'string' || !plural)
168
+ continue;
169
+ seeded[key] = {
170
+ ...doc,
171
+ 'points.label': plural,
172
+ 'points.plural': plural,
173
+ ...(typeof singular === 'string' && singular ? { 'points.singular': singular } : {})
174
+ };
175
+ }
176
+ return seeded;
177
+ }
@@ -0,0 +1,11 @@
1
+ export declare function LoyaltyPageV2SkeletonStyles(): import("react").JSX.Element;
2
+ export interface LoyaltyPageV2SkeletonBandProps {
3
+ sectionId: string;
4
+ structure: unknown;
5
+ }
6
+ export declare function LoyaltyPageV2SkeletonBand({ sectionId, structure }: LoyaltyPageV2SkeletonBandProps): import("react").JSX.Element;
7
+ export interface LoyaltyPageV2SkeletonProps {
8
+ sectionIds: string[];
9
+ structure: unknown;
10
+ }
11
+ export declare function LoyaltyPageV2Skeleton({ sectionIds, structure }: LoyaltyPageV2SkeletonProps): import("react").JSX.Element;
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { resolveLoyaltyPageV2SkeletonShape } from '@joy-loyalty/sdk/loyalty-page-contracts';
3
+ const SKELETON_CSS = `
4
+ .joy-lpv2-skel{display:block;width:100%;max-width:1200px;margin:0 auto;padding-inline:24px;box-sizing:border-box}
5
+ .joy-lpv2-skel__band{padding-block:48px}
6
+ .joy-lpv2-skel__band--flush{padding-block:0}
7
+ .joy-lpv2-skel__sh{background:linear-gradient(90deg,#ececec 25%,#f4f4f4 37%,#ececec 63%);background-size:400% 100%;animation:joy-lpv2-skel-shimmer 1.4s ease infinite;border-radius:12px}
8
+ .joy-lpv2-skel__banner{min-height:clamp(300px,42vw,500px)}
9
+ .joy-lpv2-skel__line{width:min(340px,62%);height:24px;margin:0 auto 8px}
10
+ .joy-lpv2-skel__subline{width:min(440px,78%);height:16px;margin:0 auto 40px}
11
+ .joy-lpv2-skel__grid{display:grid;grid-template-columns:repeat(var(--joy-skel-cols,3),minmax(0,1fr));gap:20px}
12
+ .joy-lpv2-skel__card{min-height:170px}
13
+ .joy-lpv2-skel__split{display:grid;grid-template-columns:calc(var(--joy-skel-a,6) * 1fr) calc(var(--joy-skel-b,6) * 1fr);gap:24px;align-items:center}
14
+ .joy-lpv2-skel__copy{display:flex;flex-direction:column;align-items:flex-start}
15
+ .joy-lpv2-skel__copy .joy-lpv2-skel__line,.joy-lpv2-skel__copy .joy-lpv2-skel__subline{margin-inline:0;width:100%}
16
+ .joy-lpv2-skel__copy .joy-lpv2-skel__subline{margin-bottom:24px}
17
+ .joy-lpv2-skel__field{width:100%;height:44px}
18
+ .joy-lpv2-skel__media{min-height:clamp(260px,34vw,420px)}
19
+ .joy-lpv2-skel__table{display:flex;flex-direction:column;gap:8px}
20
+ .joy-lpv2-skel__thead{height:56px}
21
+ .joy-lpv2-skel__trow{height:52px}
22
+ .joy-lpv2-skel__rows{display:flex;flex-direction:column;gap:12px}
23
+ .joy-lpv2-skel__row{height:64px}
24
+ .joy-lpv2-skel__panel{min-height:220px}
25
+ @keyframes joy-lpv2-skel-shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}
26
+ @media (max-width:768px){.joy-lpv2-skel__split{grid-template-columns:1fr}}
27
+ @media (max-width:760px){.joy-lpv2-skel__thead{display:none}.joy-lpv2-skel__trow{height:170px}}
28
+ @media (max-width:1024px){.joy-lpv2-skel__grid{grid-template-columns:repeat(var(--joy-skel-cols-tablet,3),minmax(0,1fr))}}
29
+ @media (max-width:760px){.joy-lpv2-skel__grid{grid-template-columns:repeat(var(--joy-skel-cols-mobile,1),minmax(0,1fr))}}
30
+ @media (max-width:640px){.joy-lpv2-skel{padding-inline:16px}.joy-lpv2-skel__grid{gap:12px}}
31
+ @media (prefers-reduced-motion:reduce){.joy-lpv2-skel__sh{animation:none}}
32
+ `;
33
+ export function LoyaltyPageV2SkeletonStyles() {
34
+ return _jsx("style", { dangerouslySetInnerHTML: { __html: SKELETON_CSS } });
35
+ }
36
+ function sectionContentOf(structure, sectionId) {
37
+ const content = structure?.content;
38
+ const section = content?.[sectionId];
39
+ return section && typeof section === 'object' && !Array.isArray(section)
40
+ ? section
41
+ : undefined;
42
+ }
43
+ function resolveColumns(sectionContent) {
44
+ const raw = Number(sectionContent?.columns);
45
+ const cols = Number.isFinite(raw) && raw > 0 ? Math.floor(raw) : 3;
46
+ return Math.min(4, Math.max(1, cols));
47
+ }
48
+ function resolveResponsiveColumns(cols, sectionContent) {
49
+ const tablet = Math.min(3, cols);
50
+ const rawMobile = Number(sectionContent?.mobileColumns);
51
+ const mobile = Number.isFinite(rawMobile) && rawMobile > 0 ? Math.min(2, Math.floor(rawMobile)) : 1;
52
+ return { tablet, mobile: Math.min(mobile, tablet) };
53
+ }
54
+ function resolveSplitTracks(sectionContent) {
55
+ const layout = typeof sectionContent?.imageLayout === 'string' ? sectionContent.imageLayout : '6/6';
56
+ const [rawImage, rawCopy] = layout.split('/');
57
+ const image = Number(rawImage);
58
+ const copy = Number(rawCopy);
59
+ if (!Number.isFinite(image) || !Number.isFinite(copy) || image < 1 || copy < 1)
60
+ return { image: 6, copy: 6 };
61
+ return { image, copy };
62
+ }
63
+ export function LoyaltyPageV2SkeletonBand({ sectionId, structure }) {
64
+ const shape = resolveLoyaltyPageV2SkeletonShape(sectionId, structure);
65
+ const sectionContent = sectionContentOf(structure, sectionId);
66
+ if (shape === 'banner') {
67
+ return (_jsx("div", { className: "joy-lpv2-skel__band joy-lpv2-skel__band--flush", children: _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__banner" }) }));
68
+ }
69
+ if (shape === 'split') {
70
+ const tracks = resolveSplitTracks(sectionContent);
71
+ const imageFirst = sectionContent?.imagePosition === 'left';
72
+ const style = imageFirst
73
+ ? { '--joy-skel-a': tracks.image, '--joy-skel-b': tracks.copy }
74
+ : { '--joy-skel-a': tracks.copy, '--joy-skel-b': tracks.image };
75
+ const media = _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__media" });
76
+ const copyColumn = (_jsxs("div", { className: "joy-lpv2-skel__copy", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__line" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__subline" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__field" })] }));
77
+ return (_jsx("div", { className: "joy-lpv2-skel__band", children: _jsx("div", { className: "joy-lpv2-skel__split", style: style, children: imageFirst ? (_jsxs(_Fragment, { children: [media, copyColumn] })) : (_jsxs(_Fragment, { children: [copyColumn, media] })) }) }));
78
+ }
79
+ if (shape === 'table') {
80
+ return (_jsxs("div", { className: "joy-lpv2-skel__band", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__line" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__subline" }), _jsxs("div", { className: "joy-lpv2-skel__table", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__thead" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__trow" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__trow" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__trow" })] })] }));
81
+ }
82
+ if (shape === 'rows') {
83
+ return (_jsxs("div", { className: "joy-lpv2-skel__band", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__line" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__subline" }), _jsxs("div", { className: "joy-lpv2-skel__rows", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__row" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__row" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__row" })] })] }));
84
+ }
85
+ if (shape === 'panel') {
86
+ return (_jsxs("div", { className: "joy-lpv2-skel__band", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__line" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__subline" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__panel" })] }));
87
+ }
88
+ const cols = resolveColumns(sectionContent);
89
+ const { tablet, mobile } = resolveResponsiveColumns(cols, sectionContent);
90
+ const style = {
91
+ '--joy-skel-cols': cols,
92
+ '--joy-skel-cols-tablet': tablet,
93
+ '--joy-skel-cols-mobile': mobile
94
+ };
95
+ return (_jsxs("div", { className: "joy-lpv2-skel__band", children: [_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__line" }), _jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__subline" }), _jsx("div", { className: "joy-lpv2-skel__grid", style: style, children: Array.from({ length: cols }, (_, index) => (_jsx("div", { className: "joy-lpv2-skel__sh joy-lpv2-skel__card" }, index))) })] }));
96
+ }
97
+ export function LoyaltyPageV2Skeleton({ sectionIds, structure }) {
98
+ return (_jsx("div", { className: "joy-lpv2-skel", "aria-hidden": "true", children: sectionIds.map(sectionId => (_jsx(LoyaltyPageV2SkeletonBand, { sectionId: sectionId, structure: structure }, sectionId))) }));
99
+ }
@@ -0,0 +1,61 @@
1
+ import type { Program } from '@joy-loyalty/sdk/client';
2
+ import { WidgetController } from '../widget-controller.js';
3
+ import { buildAppearanceProps } from '../widget-orchestrator.js';
4
+ import type { BlobCustomer, HeadlessInitialData, WidgetAppearance } from '../widget-orchestrator.js';
5
+ import type { AuthState, DataCapabilities, HeadlessHostAdapter } from '../headless-host-adapter.js';
6
+ import type { HydrogenCartPort } from '../hydrogen-cart-port.js';
7
+ import type { WidgetCoreExports } from '../lib/core-loader.js';
8
+ import type { HeadlessRenderContext, JoyMetafieldBlob } from '../render-adapter.js';
9
+ export interface OrchestratorContext {
10
+ readonly container: HTMLElement;
11
+ readonly hostAdapter: HeadlessHostAdapter;
12
+ readonly controller: WidgetController;
13
+ element: HTMLElement;
14
+ readonly caps: DataCapabilities;
15
+ readonly coreExports?: WidgetCoreExports;
16
+ readonly openCartDrawer?: () => boolean | void;
17
+ readonly cart?: HydrogenCartPort;
18
+ readonly initialData?: HeadlessInitialData | null;
19
+ readonly blob?: JoyMetafieldBlob;
20
+ readonly useBlobPath: boolean;
21
+ renderContext: HeadlessRenderContext | null;
22
+ readonly appearance?: WidgetAppearance;
23
+ readonly appearanceProps: ReturnType<typeof buildAppearanceProps>;
24
+ readonly appearanceOverrides: Record<string, unknown>;
25
+ readonly capabilityProps: Record<string, unknown>;
26
+ shouldLoad: boolean;
27
+ activeBlob: JoyMetafieldBlob | undefined;
28
+ activeCustomer: BlobCustomer;
29
+ previousStatus: AuthState['status'];
30
+ panelOpened: boolean;
31
+ preloadDeferred: boolean;
32
+ render(customer: BlobCustomer, programs: readonly Program[]): void;
33
+ surface(work: Promise<unknown>): void;
34
+ patchCustomer(fields: Record<string, unknown>): Record<string, unknown>;
35
+ toast(english: string, vars?: Record<string, string>): void;
36
+ tLabel(english: string, vars?: Record<string, string>): string;
37
+ isAuthed(): boolean;
38
+ buildRenderContext(): HeadlessRenderContext;
39
+ buildBlobProps(customer: BlobCustomer): Record<string, unknown>;
40
+ applyStylePreset(): void;
41
+ runBeatTwo(): Promise<void>;
42
+ refresh(): Promise<void>;
43
+ loadCustomerSections(): void;
44
+ loadRewards(query?: URLSearchParams): void;
45
+ loadActivities(direction?: 'before' | 'after', cursor?: string, prop?: 'activities' | 'pointHistory'): void;
46
+ loadReferral(): void;
47
+ loadImpactHistory(): void;
48
+ loadMilestone(): void;
49
+ loadTierPerks(): void;
50
+ applyStoreCreditFromInfo(info: Record<string, unknown>): void;
51
+ }
52
+ export interface CreateOrchestratorContextOptions {
53
+ container: HTMLElement;
54
+ hostAdapter: HeadlessHostAdapter;
55
+ initialData?: HeadlessInitialData | null;
56
+ appearance?: WidgetAppearance;
57
+ cart?: HydrogenCartPort;
58
+ coreExports?: WidgetCoreExports;
59
+ openCartDrawer?: () => boolean | void;
60
+ }
61
+ export declare function createOrchestratorContext(opts: CreateOrchestratorContextOptions): OrchestratorContext;
@@ -0,0 +1,64 @@
1
+ import { WidgetController } from '../widget-controller.js';
2
+ import { clearJoyToken, dropJoyTokenIfCustomerMismatch, hasCachedJoyToken } from '../lib/token.js';
3
+ import { attachRenderCore } from './render.js';
4
+ import { buildAppearanceOverrides, buildAppearanceProps, buildProps, readCachedReferralLink } from '../widget-orchestrator.js';
5
+ export function createOrchestratorContext(opts) {
6
+ const { container, hostAdapter, initialData, appearance, cart, coreExports, openCartDrawer } = opts;
7
+ const composedAdapter = cart ? { ...hostAdapter, cart } : hostAdapter;
8
+ const controller = new WidgetController(container, composedAdapter);
9
+ const appearanceProps = buildAppearanceProps(appearance);
10
+ const appearanceOverrides = buildAppearanceOverrides(appearance);
11
+ const caps = hostAdapter.data.capabilities;
12
+ const capabilityProps = {
13
+ 'free-gift-stock': caps.freeGiftStock,
14
+ 'received-rewards': caps.receivedRewards,
15
+ 'referral-invite': caps.referralInvite,
16
+ 'referral-history': caps.referralHistory,
17
+ 'join-program': caps.joinProgram,
18
+ 'social-connect': caps.socialConnect,
19
+ 'profile-edit': caps.profileEdit,
20
+ 'hide-wallet-pass': !(caps.appleWalletPass || caps.googleWalletPass)
21
+ };
22
+ const blob = initialData?.blob;
23
+ const useBlobPath = !!(coreExports?.renderingProps && blob);
24
+ if (initialData && !initialData.customer && !initialData.shopifyCustomer && hasCachedJoyToken()) {
25
+ clearJoyToken();
26
+ }
27
+ else if (initialData?.shopifyCustomer?.id) {
28
+ dropJoyTokenIfCustomerMismatch(String(initialData.shopifyCustomer.id));
29
+ }
30
+ const ctx = {
31
+ container,
32
+ hostAdapter,
33
+ controller,
34
+ caps,
35
+ coreExports,
36
+ openCartDrawer,
37
+ cart,
38
+ initialData,
39
+ blob,
40
+ useBlobPath,
41
+ appearance,
42
+ appearanceProps,
43
+ appearanceOverrides,
44
+ capabilityProps,
45
+ activeBlob: blob,
46
+ activeCustomer: initialData?.customer,
47
+ previousStatus: hostAdapter.auth.getState().status,
48
+ panelOpened: false,
49
+ preloadDeferred: false
50
+ };
51
+ attachRenderCore(ctx);
52
+ ctx.renderContext = useBlobPath ? ctx.buildRenderContext() : null;
53
+ ctx.shouldLoad = !initialData?.customer && hostAdapter.auth.getState().status !== 'guest';
54
+ ctx.element = controller.mount({
55
+ ...(useBlobPath
56
+ ? { ...ctx.buildBlobProps(ctx.activeCustomer), ...appearanceOverrides }
57
+ : { ...buildProps(initialData?.customer, initialData?.programs ?? [], initialData?.tiers), ...appearanceProps }),
58
+ ...capabilityProps,
59
+ 'cached-referral-link': readCachedReferralLink(),
60
+ loading: ctx.shouldLoad
61
+ });
62
+ ctx.applyStylePreset();
63
+ return ctx;
64
+ }
@@ -0,0 +1 @@
1
+ export declare const GATED_EVENTS: readonly string[];
@@ -0,0 +1,14 @@
1
+ export const GATED_EVENTS = [
2
+ 'joy-wishlist-add-to-cart', 'joy-wishlist-remove', 'joy-wishlist-share', 'joy-wishlist-signin',
3
+ 'joy-wishlist-continue', 'joy-wishlist-lists-load-request', 'joy-wishlist-list-create-request',
4
+ 'joy-wishlist-list-create-confirm', 'joy-wishlist-list-rename-confirm', 'joy-wishlist-list-delete-confirm',
5
+ 'joy-wishlist-list-open', 'joy-wishlist-list-back', 'joy-wishlist-item-add-to-lists-confirm',
6
+ 'joy-wishlist-item-remove-from-list-confirm', 'joy-wishlist-row-add-to-list',
7
+ 'joy-wishlist-row-remove-from-list', 'joy-favorite-toggle',
8
+ 'joy-sso-request-otp', 'joy-sso-verify-otp', 'joy-sso-google-login', 'joy-sso-facebook-login', 'joy-sso-shop-app-login',
9
+ 'joy-privacy-save',
10
+ 'joy-reviews-submit', 'joy-reviews-page-change',
11
+ 'joy-copy-referral',
12
+ 'joy-load-reward',
13
+ 'joy-aov-chip-click'
14
+ ];
@@ -0,0 +1,19 @@
1
+ import type { Activity } from '@joy-loyalty/sdk/client';
2
+ import type { OrchestratorContext } from '../context.js';
3
+ interface ActivityViewModel {
4
+ id: string;
5
+ title: string;
6
+ points: number;
7
+ isPositive: boolean;
8
+ createdAt?: string;
9
+ date: string;
10
+ couponCode: string | null;
11
+ orderId: string | null;
12
+ }
13
+ export declare function mapActivityRows(activities: Activity[], ctx: Pick<OrchestratorContext, 'coreExports' | 'activeBlob' | 'renderContext'>, countryCode?: string): ActivityViewModel[];
14
+ export interface AccountHandlers {
15
+ loadOrders(): void;
16
+ loadStoreCreditTransactions(direction?: 'before' | 'after'): void;
17
+ }
18
+ export declare function registerAccountHandlers(ctx: OrchestratorContext): AccountHandlers;
19
+ export {};