vdb-ai-chat 1.0.77 → 1.0.78

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 (99) hide show
  1. package/dist/chat-widget.js +461 -1
  2. package/lib/commonjs/api.js +27 -55
  3. package/lib/commonjs/api.js.map +1 -1
  4. package/lib/commonjs/components/ChatHeader.js +0 -2
  5. package/lib/commonjs/components/ChatHeader.js.map +1 -1
  6. package/lib/commonjs/components/ChatWidget.js +21 -55
  7. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  8. package/lib/commonjs/components/LazyProductsFetcher.js +3 -5
  9. package/lib/commonjs/components/LazyProductsFetcher.js.map +1 -1
  10. package/lib/commonjs/components/utils.js +34 -42
  11. package/lib/commonjs/components/utils.js.map +1 -1
  12. package/lib/commonjs/contexts/ThemeProvider.js +21 -44
  13. package/lib/commonjs/contexts/ThemeProvider.js.map +1 -1
  14. package/lib/commonjs/index.web.js +6 -17
  15. package/lib/commonjs/index.web.js.map +1 -1
  16. package/lib/commonjs/storage.js +4 -14
  17. package/lib/commonjs/storage.js.map +1 -1
  18. package/lib/commonjs/theme.js +1 -229
  19. package/lib/commonjs/theme.js.map +1 -1
  20. package/lib/module/api.js +27 -53
  21. package/lib/module/api.js.map +1 -1
  22. package/lib/module/components/ChatHeader.js +0 -2
  23. package/lib/module/components/ChatHeader.js.map +1 -1
  24. package/lib/module/components/ChatWidget.js +22 -56
  25. package/lib/module/components/ChatWidget.js.map +1 -1
  26. package/lib/module/components/LazyProductsFetcher.js +3 -5
  27. package/lib/module/components/LazyProductsFetcher.js.map +1 -1
  28. package/lib/module/components/utils.js +34 -42
  29. package/lib/module/components/utils.js.map +1 -1
  30. package/lib/module/contexts/ThemeProvider.js +16 -39
  31. package/lib/module/contexts/ThemeProvider.js.map +1 -1
  32. package/lib/module/index.web.js +6 -17
  33. package/lib/module/index.web.js.map +1 -1
  34. package/lib/module/storage.js +4 -14
  35. package/lib/module/storage.js.map +1 -1
  36. package/lib/module/theme.js +0 -228
  37. package/lib/module/theme.js.map +1 -1
  38. package/lib/typescript/api.d.ts +2 -12
  39. package/lib/typescript/api.d.ts.map +1 -1
  40. package/lib/typescript/components/ChatHeader.d.ts.map +1 -1
  41. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  42. package/lib/typescript/components/LazyProductsFetcher.d.ts +0 -3
  43. package/lib/typescript/components/LazyProductsFetcher.d.ts.map +1 -1
  44. package/lib/typescript/components/utils.d.ts +1 -0
  45. package/lib/typescript/components/utils.d.ts.map +1 -1
  46. package/lib/typescript/contexts/ThemeProvider.d.ts.map +1 -1
  47. package/lib/typescript/index.web.d.ts +1 -23
  48. package/lib/typescript/index.web.d.ts.map +1 -1
  49. package/lib/typescript/storage.d.ts.map +1 -1
  50. package/lib/typescript/theme.d.ts +0 -228
  51. package/lib/typescript/theme.d.ts.map +1 -1
  52. package/lib/typescript/types.d.ts +0 -4
  53. package/lib/typescript/types.d.ts.map +1 -1
  54. package/package.json +1 -2
  55. package/src/api.ts +24 -60
  56. package/src/components/ChatHeader.tsx +0 -2
  57. package/src/components/ChatWidget.tsx +86 -137
  58. package/src/components/LazyProductsFetcher.tsx +2 -7
  59. package/src/components/utils.ts +34 -42
  60. package/src/contexts/ThemeProvider.tsx +10 -32
  61. package/src/index.web.tsx +13 -59
  62. package/src/storage.ts +4 -14
  63. package/src/theme.ts +0 -230
  64. package/src/types.ts +0 -4
  65. package/lib/commonjs/components/ButtonContent.js +0 -54
  66. package/lib/commonjs/components/ButtonContent.js.map +0 -1
  67. package/lib/commonjs/components/FloatingChatButton.js +0 -197
  68. package/lib/commonjs/components/FloatingChatButton.js.map +0 -1
  69. package/lib/commonjs/config/storeConfigLoader.js +0 -161
  70. package/lib/commonjs/config/storeConfigLoader.js.map +0 -1
  71. package/lib/commonjs/config/types.js +0 -2
  72. package/lib/commonjs/config/types.js.map +0 -1
  73. package/lib/commonjs/utils/pluginUrlBuilder.js +0 -288
  74. package/lib/commonjs/utils/pluginUrlBuilder.js.map +0 -1
  75. package/lib/module/components/ButtonContent.js +0 -48
  76. package/lib/module/components/ButtonContent.js.map +0 -1
  77. package/lib/module/components/FloatingChatButton.js +0 -190
  78. package/lib/module/components/FloatingChatButton.js.map +0 -1
  79. package/lib/module/config/storeConfigLoader.js +0 -153
  80. package/lib/module/config/storeConfigLoader.js.map +0 -1
  81. package/lib/module/config/types.js +0 -2
  82. package/lib/module/config/types.js.map +0 -1
  83. package/lib/module/utils/pluginUrlBuilder.js +0 -279
  84. package/lib/module/utils/pluginUrlBuilder.js.map +0 -1
  85. package/lib/typescript/components/ButtonContent.d.ts +0 -5
  86. package/lib/typescript/components/ButtonContent.d.ts.map +0 -1
  87. package/lib/typescript/components/FloatingChatButton.d.ts +0 -8
  88. package/lib/typescript/components/FloatingChatButton.d.ts.map +0 -1
  89. package/lib/typescript/config/storeConfigLoader.d.ts +0 -25
  90. package/lib/typescript/config/storeConfigLoader.d.ts.map +0 -1
  91. package/lib/typescript/config/types.d.ts +0 -49
  92. package/lib/typescript/config/types.d.ts.map +0 -1
  93. package/lib/typescript/utils/pluginUrlBuilder.d.ts +0 -43
  94. package/lib/typescript/utils/pluginUrlBuilder.d.ts.map +0 -1
  95. package/src/components/ButtonContent.tsx +0 -54
  96. package/src/components/FloatingChatButton.tsx +0 -204
  97. package/src/config/storeConfigLoader.ts +0 -175
  98. package/src/config/types.ts +0 -51
  99. package/src/utils/pluginUrlBuilder.ts +0 -528
@@ -1,197 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.AISearchButtonVisual = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _native = _interopRequireWildcard(require("styled-components/native"));
10
- var _reactI18next = require("react-i18next");
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
- const isWeb = _reactNative.Platform.OS === "web";
13
- const BUTTON_HEIGHT = 48;
14
- const BUTTON_WIDTH = isWeb ? 181 : 167;
15
- const BORDER_WIDTH = 3;
16
- const AISearchButtonVisual = exports.AISearchButtonVisual = /*#__PURE__*/(0, _react.memo)(({
17
- typography,
18
- height = BUTTON_HEIGHT
19
- }) => {
20
- const theme = (0, _native.useTheme)();
21
- const {
22
- t
23
- } = (0, _reactI18next.useTranslation)();
24
- const COLOR_1 = theme["diam-01"] || "#804195";
25
- const COLOR_2 = theme["jewelry-01"] || "#58B8A5";
26
- const SHADOW_COLOR_1 = theme["diam-01"] || "#804195";
27
- const SHADOW_COLOR_2 = theme["jewelry-01"] || "#58B8A5";
28
- const SHADOW_COLOR_3 = "#6C7AC8";
29
- (0, _react.useEffect)(() => {
30
- if (isWeb && typeof document !== "undefined") {
31
- const styleId = "ai-search-button-animations";
32
- if (!document.getElementById(styleId)) {
33
- const style = document.createElement("style");
34
- style.id = styleId;
35
- style.textContent = `
36
- @keyframes rotateGradient {
37
- from { transform: rotate(0deg); }
38
- to { transform: rotate(360deg); }
39
- }
40
- @keyframes rotateShadow {
41
- 0% { box-shadow: 0 0 20px 4px ${SHADOW_COLOR_1}; }
42
- 33% { box-shadow: 0 0 25px 6px ${SHADOW_COLOR_2}; }
43
- 66% { box-shadow: 0 0 22px 5px ${SHADOW_COLOR_3}; }
44
- 100% { box-shadow: 0 0 20px 4px ${SHADOW_COLOR_1}; }
45
- }
46
- .ai-search-glow-container {
47
- animation: rotateShadow 3s ease-in-out infinite;
48
- }
49
- .ai-search-gradient-border {
50
- animation: rotateGradient 2.5s linear infinite;
51
- }
52
- `;
53
- document.head.appendChild(style);
54
- }
55
- }
56
- }, [SHADOW_COLOR_1, SHADOW_COLOR_2, SHADOW_COLOR_3]);
57
- if (isWeb) {
58
- return /*#__PURE__*/_react.default.createElement("div", {
59
- className: "ai-search-glow-container",
60
- style: {
61
- width: BUTTON_WIDTH,
62
- height: height,
63
- borderRadius: height / 2,
64
- display: "flex",
65
- alignItems: "center",
66
- justifyContent: "center",
67
- position: "relative"
68
- }
69
- }, /*#__PURE__*/_react.default.createElement("div", {
70
- style: {
71
- position: "absolute",
72
- width: BUTTON_WIDTH,
73
- height: height,
74
- borderRadius: height / 2,
75
- overflow: "hidden",
76
- display: "flex",
77
- alignItems: "center",
78
- justifyContent: "center"
79
- }
80
- }, /*#__PURE__*/_react.default.createElement("div", {
81
- className: "ai-search-gradient-border",
82
- style: {
83
- width: BUTTON_WIDTH * 2.5,
84
- height: BUTTON_WIDTH * 2.5,
85
- borderRadius: BUTTON_WIDTH * 1.25,
86
- background: `linear-gradient(135deg, ${COLOR_1}, ${COLOR_2}, ${COLOR_1}, ${COLOR_2})`
87
- }
88
- })), /*#__PURE__*/_react.default.createElement("div", {
89
- style: {
90
- width: BUTTON_WIDTH - BORDER_WIDTH * 2,
91
- height: height - BORDER_WIDTH * 2,
92
- borderRadius: (height - BORDER_WIDTH * 2) / 2,
93
- backgroundColor: theme["main-01"] || "#292735",
94
- display: "flex",
95
- alignItems: "center",
96
- justifyContent: "center",
97
- flexDirection: "row",
98
- gap: 2,
99
- zIndex: 1
100
- }
101
- }, /*#__PURE__*/_react.default.createElement("img", {
102
- src: "https://cdn.vdbapp.com/ai/chat-widget/assets/img/VDB_LOGO_WHITE.svg",
103
- alt: "VDB",
104
- style: {
105
- width: 84,
106
- height: 24
107
- }
108
- }), /*#__PURE__*/_react.default.createElement("span", {
109
- style: {
110
- color: theme["diam-05"] || "#ffffff",
111
- fontWeight: 500,
112
- letterSpacing: 0.3,
113
- fontSize: 14,
114
- fontFamily: "Roboto, sans-serif"
115
- }
116
- }, t("AI Search"))));
117
- }
118
-
119
- // Native implementation (simplified without reanimated)
120
- return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
121
- style: [styles.glowContainer, {
122
- width: BUTTON_WIDTH,
123
- height
124
- }]
125
- }, /*#__PURE__*/_react.default.createElement(GradientWrapper, {
126
- width: BUTTON_WIDTH,
127
- height: height
128
- }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
129
- style: [styles.gradientBorder, {
130
- backgroundColor: COLOR_1
131
- }]
132
- })), /*#__PURE__*/_react.default.createElement(ButtonContainer, {
133
- height: height
134
- }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
135
- style: [styles.text, {
136
- color: theme["diam-05"] || "#ffffff"
137
- }]
138
- }, t("AI Search"))));
139
- });
140
- const styles = _reactNative.StyleSheet.create({
141
- glowContainer: {
142
- borderRadius: BUTTON_HEIGHT / 2,
143
- alignItems: "center",
144
- justifyContent: "center",
145
- shadowColor: "#6C7AC8",
146
- shadowOffset: {
147
- width: 3,
148
- height: 3
149
- },
150
- shadowOpacity: 1,
151
- shadowRadius: 14,
152
- elevation: 10
153
- },
154
- gradientBorder: {
155
- width: BUTTON_WIDTH * 2.5,
156
- height: BUTTON_WIDTH * 2.5,
157
- borderRadius: BUTTON_WIDTH * 1.25
158
- },
159
- text: {
160
- fontWeight: "500",
161
- letterSpacing: 0.3,
162
- fontSize: 14
163
- }
164
- });
165
- const GradientWrapper = _native.default.View`
166
- position: absolute;
167
- width: ${({
168
- width
169
- }) => width}px;
170
- height: ${({
171
- height
172
- }) => height}px;
173
- border-radius: ${({
174
- height
175
- }) => height / 2}px;
176
- overflow: hidden;
177
- align-items: center;
178
- justify-content: center;
179
- `;
180
- const ButtonContainer = _native.default.View`
181
- width: ${BUTTON_WIDTH - BORDER_WIDTH * 2}px;
182
- height: ${({
183
- height
184
- }) => height - BORDER_WIDTH * 2}px;
185
- border-radius: ${({
186
- height
187
- }) => (height - BORDER_WIDTH * 2) / 2}px;
188
- background-color: ${({
189
- theme
190
- }) => theme["main-01"]};
191
- align-items: center;
192
- justify-content: center;
193
- flex-direction: row;
194
- gap: 2px;
195
- z-index: 1;
196
- `;
197
- //# sourceMappingURL=FloatingChatButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_native","_reactI18next","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isWeb","Platform","OS","BUTTON_HEIGHT","BUTTON_WIDTH","BORDER_WIDTH","AISearchButtonVisual","exports","memo","typography","height","theme","useTheme","useTranslation","COLOR_1","COLOR_2","SHADOW_COLOR_1","SHADOW_COLOR_2","SHADOW_COLOR_3","useEffect","document","styleId","getElementById","style","createElement","id","textContent","head","appendChild","className","width","borderRadius","display","alignItems","justifyContent","position","overflow","background","backgroundColor","flexDirection","gap","zIndex","src","alt","color","fontWeight","letterSpacing","fontSize","fontFamily","View","styles","glowContainer","GradientWrapper","gradientBorder","ButtonContainer","Text","text","StyleSheet","create","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","styled"],"sourceRoot":"../../../src","sources":["components/FloatingChatButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,uBAAA,CAAAC,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAA+C,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EA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AE,CAAC;IACrCmD,aAAa,EAAE,CAAC;IAChBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;EACb,CAAC;EACDV,cAAc,EAAE;IACdvB,KAAK,EAAE1B,YAAY,GAAG,GAAG;IACzBM,MAAM,EAAEN,YAAY,GAAG,GAAG;IAC1B2B,YAAY,EAAE3B,YAAY,GAAG;EAC/B,CAAC;EACDoD,IAAI,EAAE;IACJX,UAAU,EAAE,KAAK;IACjBC,aAAa,EAAE,GAAG;IAClBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;AAEF,MAAMK,eAAe,GAAGY,eAAM,CAACf,IAG7B;AACF;AACA,WAAW,CAAC;EAAEnB;AAAyB,CAAC,KAAKA,KAAK;AAClD,YAAY,CAAC;EAAEpB;AAA2B,CAAC,KAAKA,MAAM;AACtD,mBAAmB,CAAC;EAAEA;AAA2B,CAAC,KAAKA,MAAM,GAAG,CAAC;AACjE;AACA;AACA;AACA,CAAC;AAED,MAAM4C,eAAe,GAAGU,eAAM,CAACf,IAG7B;AACF,WAAW7C,YAAY,GAAGC,YAAY,GAAG,CAAC;AAC1C,YAAY,CAAC;EAAEK;AAA2B,CAAC,KAAKA,MAAM,GAAGL,YAAY,GAAG,CAAC;AACzE,mBAAmB,CAAC;EAAEK;AAA2B,CAAC,KAC9C,CAACA,MAAM,GAAGL,YAAY,GAAG,CAAC,IAAI,CAAC;AACnC,sBAAsB,CAAC;EAAEM;AAA+B,CAAC,KAAKA,KAAK,CAAC,SAAS,CAAC;AAC9E;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clearConfigCache = clearConfigCache;
7
- exports.getStoreNameFromUrl = getStoreNameFromUrl;
8
- exports.loadStoreConfig = loadStoreConfig;
9
- /**
10
- * Store Configuration Loader
11
- *
12
- * Handles loading store-specific configuration from CDN,
13
- * with caching and fallback support.
14
- */
15
-
16
- const CONFIG_CDN_BASE_URL = "https://cdn.vdbapp.com/config/shopify-ai";
17
- const CONFIG_CACHE_KEY = "vdb_store_config";
18
- const CACHE_TTL_MS = 30 * 60 * 1000; // 30 minutes
19
-
20
- /**
21
- * Extracts the store name from the current URL hostname.
22
- * Examples:
23
- * - "test-before-live-vdb-app.myshopify.com" → "test-before-live-vdb-app"
24
- * - "shopify.vdbapp.com" → "shopify-vdbapp"
25
- */
26
- function getStoreNameFromUrl() {
27
- if (typeof window === "undefined") {
28
- return null;
29
- }
30
- try {
31
- const hostname = window.location.hostname;
32
-
33
- // Handle myshopify.com domains
34
- if (hostname.endsWith(".myshopify.com")) {
35
- return hostname.replace(".myshopify.com", "");
36
- }
37
-
38
- // Handle other domains - use hostname with dots replaced by dashes
39
- return hostname.replace(/\./g, "-");
40
- } catch {
41
- return null;
42
- }
43
- }
44
-
45
- /**
46
- * Gets cached config from localStorage if valid.
47
- */
48
- function getCachedConfig(storeName) {
49
- try {
50
- const raw = localStorage.getItem(CONFIG_CACHE_KEY);
51
- if (!raw) return null;
52
- const cached = JSON.parse(raw);
53
-
54
- // Check if cache is for the same store
55
- if (cached.storeName !== storeName) {
56
- localStorage.removeItem(CONFIG_CACHE_KEY);
57
- return null;
58
- }
59
-
60
- // Check if cache has expired
61
- if (Date.now() - cached.timestamp > CACHE_TTL_MS) {
62
- localStorage.removeItem(CONFIG_CACHE_KEY);
63
- return null;
64
- }
65
- return cached.config;
66
- } catch {
67
- return null;
68
- }
69
- }
70
-
71
- /**
72
- * Saves config to localStorage cache.
73
- */
74
- function cacheConfig(storeName, config) {
75
- try {
76
- const cached = {
77
- config,
78
- timestamp: Date.now(),
79
- storeName
80
- };
81
- localStorage.setItem(CONFIG_CACHE_KEY, JSON.stringify(cached));
82
- } catch {
83
- // Storage unavailable, continue without caching
84
- }
85
- }
86
-
87
- /**
88
- * Fetches store configuration from CDN.
89
- * Returns null if fetch fails.
90
- */
91
- async function fetchConfigFromCdn(storeName, timeoutMs = 5000) {
92
- const url = `${CONFIG_CDN_BASE_URL}/${storeName}.json`;
93
- try {
94
- const controller = new AbortController();
95
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
96
- const response = await fetch(url, {
97
- method: "GET",
98
- signal: controller.signal,
99
- headers: {
100
- Accept: "application/json"
101
- }
102
- });
103
- clearTimeout(timeoutId);
104
- if (!response.ok) {
105
- if (response.status === 404) {
106
- console.warn(`[StoreConfig] Config not found for store: ${storeName}`);
107
- } else {
108
- console.warn(`[StoreConfig] Failed to fetch config: HTTP ${response.status}`);
109
- }
110
- return null;
111
- }
112
- const config = await response.json();
113
- return config;
114
- } catch (error) {
115
- if (error.name === "AbortError") {
116
- console.warn(`[StoreConfig] Config fetch timed out for store: ${storeName}`);
117
- } else {
118
- console.warn(`[StoreConfig] Failed to fetch config:`, error);
119
- }
120
- return null;
121
- }
122
- }
123
-
124
- /**
125
- * Loads store configuration.
126
- * Checks cache first, then fetches from CDN if needed.
127
- * Returns null if no config available (will use hardcoded defaults).
128
- */
129
- async function loadStoreConfig() {
130
- const storeName = getStoreNameFromUrl();
131
- if (!storeName) {
132
- console.warn("[StoreConfig] Could not determine store name from URL");
133
- return null;
134
- }
135
-
136
- // Check cache first
137
- const cached = getCachedConfig(storeName);
138
- if (cached) {
139
- return cached;
140
- }
141
-
142
- // Fetch from CDN
143
- const config = await fetchConfigFromCdn(storeName);
144
- if (config) {
145
- // Cache successful fetch
146
- cacheConfig(storeName, config);
147
- }
148
- return config;
149
- }
150
-
151
- /**
152
- * Clears the cached store configuration.
153
- */
154
- function clearConfigCache() {
155
- try {
156
- localStorage.removeItem(CONFIG_CACHE_KEY);
157
- } catch {
158
- // Ignore
159
- }
160
- }
161
- //# sourceMappingURL=storeConfigLoader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CONFIG_CDN_BASE_URL","CONFIG_CACHE_KEY","CACHE_TTL_MS","getStoreNameFromUrl","window","hostname","location","endsWith","replace","getCachedConfig","storeName","raw","localStorage","getItem","cached","JSON","parse","removeItem","Date","now","timestamp","config","cacheConfig","setItem","stringify","fetchConfigFromCdn","timeoutMs","url","controller","AbortController","timeoutId","setTimeout","abort","response","fetch","method","signal","headers","Accept","clearTimeout","ok","status","console","warn","json","error","name","loadStoreConfig","clearConfigCache"],"sourceRoot":"../../../src","sources":["config/storeConfigLoader.ts"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,mBAAmB,GAAG,0CAA0C;AACtE,MAAMC,gBAAgB,GAAG,kBAAkB;AAC3C,MAAMC,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;;AAQrC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAA,EAAkB;EACnD,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,IAAI;EACb;EAEA,IAAI;IACF,MAAMC,QAAQ,GAAGD,MAAM,CAACE,QAAQ,CAACD,QAAQ;;IAEzC;IACA,IAAIA,QAAQ,CAACE,QAAQ,CAAC,gBAAgB,CAAC,EAAE;MACvC,OAAOF,QAAQ,CAACG,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;IAC/C;;IAEA;IACA,OAAOH,QAAQ,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACrC,CAAC,CAAC,MAAM;IACN,OAAO,IAAI;EACb;AACF;;AAEA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,SAAiB,EAAsB;EAC9D,IAAI;IACF,MAAMC,GAAG,GAAGC,YAAY,CAACC,OAAO,CAACZ,gBAAgB,CAAC;IAClD,IAAI,CAACU,GAAG,EAAE,OAAO,IAAI;IAErB,MAAMG,MAAoB,GAAGC,IAAI,CAACC,KAAK,CAACL,GAAG,CAAC;;IAE5C;IACA,IAAIG,MAAM,CAACJ,SAAS,KAAKA,SAAS,EAAE;MAClCE,YAAY,CAACK,UAAU,CAAChB,gBAAgB,CAAC;MACzC,OAAO,IAA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Root":"../../../src","sources":["config/types.ts"],"mappings":"","ignoreList":[]}
@@ -1,288 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SYMMETRY_GRADES = exports.POLISH_GRADES = exports.DEFAULT_URL_PARAMS = exports.DEFAULT_PLUGIN_API_PAYLOAD = exports.CUT_GRADES = exports.COLOR_GRADES = exports.CLARITY_GRADES = void 0;
7
- exports.buildPluginApiPayload = buildPluginApiPayload;
8
- exports.buildPluginItemUrl = buildPluginItemUrl;
9
- exports.buildPluginViewAllUrl = buildPluginViewAllUrl;
10
- exports.getParentBaseDomain = getParentBaseDomain;
11
- /**
12
- * Plugin URL Builder Utilities
13
- *
14
- * Builds Shopify-compatible deep link URLs for plugin mode.
15
- * Used when useAsPlugin is true to generate URLs that work with the Shopify store's
16
- * URL parameter structure.
17
- */
18
-
19
- const DEFAULT_URL_PARAMS = exports.DEFAULT_URL_PARAMS = {
20
- structure: "new",
21
- carat_min: "0.00",
22
- carat_max: "20.00",
23
- depth_min: "0.0",
24
- depth_max: "100.0",
25
- table_min: "0.0",
26
- table_max: "100.0",
27
- budget_min: "0.00",
28
- budget_max: "9597850.08",
29
- ratio_min: "0.0",
30
- ratio_max: "100.0"
31
- };
32
- const COLOR_GRADES = exports.COLOR_GRADES = ["D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
33
- const CLARITY_GRADES = exports.CLARITY_GRADES = ["FL", "IF", "VVS1", "VVS2", "VS1", "VS2", "SI1", "SI2", "SI3", "I1", "I2", "I3"];
34
- const CUT_GRADES = exports.CUT_GRADES = ["Ideal", "Excellent", "Very Good", "Good", "Fair", "Poor"];
35
- const POLISH_GRADES = exports.POLISH_GRADES = ["Ideal", "Excellent", "Very Good", "Good", "Fair", "Poor"];
36
- const SYMMETRY_GRADES = exports.SYMMETRY_GRADES = ["Ideal", "Excellent", "Very Good", "Good", "Fair", "Poor"];
37
-
38
- /**
39
- * Gets all values in a grade array between from and to (inclusive)
40
- */
41
- function getGradesInRange(grades, from, to) {
42
- if (!from && !to) return [];
43
- if (from === "D" && to === "Z") return [];
44
- const fromIndex = from ? grades.indexOf(from) : 0;
45
- const toIndex = to ? grades.indexOf(to) : grades.length - 1;
46
- if (fromIndex === -1 && toIndex === -1) return [];
47
- const startIndex = fromIndex === -1 ? 0 : fromIndex;
48
- const endIndex = toIndex === -1 ? grades.length - 1 : toIndex;
49
- const minIndex = Math.min(startIndex, endIndex);
50
- const maxIndex = Math.max(startIndex, endIndex);
51
- return grades.slice(minIndex, maxIndex + 1);
52
- }
53
-
54
- /**
55
- * Gets the base domain of the parent page by splitting on '?'
56
- */
57
- function getParentBaseDomain() {
58
- if (typeof window === "undefined") {
59
- return "";
60
- }
61
- return window.location.href.split("?")[0];
62
- }
63
-
64
- /**
65
- * Builds a plugin URL for item press action
66
- * @param itemId - The product ID
67
- * @param pdpTemplate - Optional PDP link template (e.g., "?structure=new&proids={id}")
68
- */
69
- function buildPluginItemUrl(itemId, pdpTemplate) {
70
- const baseDomain = getParentBaseDomain();
71
- const template = pdpTemplate || "?structure=new&proids={id}";
72
- return baseDomain + template.replace("{id}", String(itemId));
73
- }
74
-
75
- /**
76
- * Builds a plugin URL for view all action with search parameters
77
- * @param aiPayload - The AI search payload
78
- * @param urlDefaults - Optional URL defaults from store config
79
- */
80
- function buildPluginViewAllUrl(aiPayload, urlDefaults) {
81
- const baseDomain = getParentBaseDomain();
82
- const params = buildSearchParams(aiPayload, urlDefaults);
83
- return `${baseDomain}?${params}`;
84
- }
85
-
86
- /**
87
- * Builds URL search parameters from AI payload
88
- * Only includes base defaults, other params added only if AI provides them
89
- * @param aiPayload - The AI search payload
90
- * @param urlDefaults - Optional URL defaults from store config
91
- */
92
- function buildSearchParams(aiPayload, urlDefaults) {
93
- const params = [];
94
-
95
- // Merge store config defaults with hardcoded defaults
96
- const defaults = {
97
- ...DEFAULT_URL_PARAMS,
98
- ...urlDefaults
99
- };
100
- params.push(`structure=${defaults.structure}`);
101
- const caratMin = aiPayload.size_from ?? defaults.carat_min;
102
- const caratMax = aiPayload.size_to ?? defaults.carat_max;
103
- params.push(`carat_min=${encodeURIComponent(String(caratMin))}`);
104
- params.push(`carat_max=${encodeURIComponent(String(caratMax))}`);
105
- const depthMin = aiPayload.depth_percent_from !== undefined && aiPayload.depth_percent_from !== "0" && aiPayload.depth_percent_to !== "100" ? aiPayload.depth_percent_from : defaults.depth_min;
106
- const depthMax = aiPayload.depth_percent_to !== undefined && aiPayload.depth_percent_from !== "0" && aiPayload.depth_percent_to !== "100" ? aiPayload.depth_percent_to : defaults.depth_max;
107
- params.push(`depth_min=${encodeURIComponent(String(depthMin))}`);
108
- params.push(`depth_max=${encodeURIComponent(String(depthMax))}`);
109
- const tableMin = aiPayload.table_percent_from !== undefined && aiPayload.table_percent_from !== "0" && aiPayload.table_percent_to !== "100" ? aiPayload.table_percent_from : defaults.table_min;
110
- const tableMax = aiPayload.table_percent_to !== undefined && aiPayload.table_percent_from !== "0" && aiPayload.table_percent_to !== "100" ? aiPayload.table_percent_to : defaults.table_max;
111
- params.push(`table_min=${encodeURIComponent(String(tableMin))}`);
112
- params.push(`table_max=${encodeURIComponent(String(tableMax))}`);
113
- const budgetMin = aiPayload.price_total_from ?? defaults.budget_min;
114
- const budgetMax = aiPayload.price_total_to ?? defaults.budget_max;
115
- params.push(`budget_min=${encodeURIComponent(String(budgetMin))}`);
116
- params.push(`budget_max=${encodeURIComponent(String(budgetMax))}`);
117
- params.push(`ratio_min=${defaults.ratio_min}`);
118
- params.push(`ratio_max=${defaults.ratio_max}`);
119
- if (aiPayload.shapes && Array.isArray(aiPayload.shapes) && aiPayload.shapes.length > 0) {
120
- params.push(`shapes=${aiPayload.shapes.map(s => encodeURIComponent(s)).join(",")}`);
121
- }
122
- const colorValues = getGradesInRange(COLOR_GRADES, aiPayload.color_from, aiPayload.color_to);
123
- if (colorValues.length > 0) {
124
- params.push(`colors=${colorValues.map(v => encodeURIComponent(v)).join(",")}`);
125
- }
126
- const clarityValues = getGradesInRange(CLARITY_GRADES, aiPayload.clarity_from, aiPayload.clarity_to);
127
- if (clarityValues.length > 0) {
128
- params.push(`clarity=${clarityValues.map(v => encodeURIComponent(v)).join(",")}`);
129
- }
130
- if (aiPayload.cut_from !== undefined || aiPayload.cut_to !== undefined) {
131
- const cutValues = getGradesInRange(CUT_GRADES, aiPayload.cut_from, aiPayload.cut_to);
132
- if (cutValues.length > 0) {
133
- params.push(`cuts=${cutValues.map(v => encodeURIComponent(v)).join(",")}`);
134
- }
135
- }
136
- if (aiPayload.polish_from !== undefined || aiPayload.polish_to !== undefined) {
137
- const polishValues = getGradesInRange(POLISH_GRADES, aiPayload.polish_from, aiPayload.polish_to);
138
- if (polishValues.length > 0) {
139
- params.push(`polish=${polishValues.map(v => encodeURIComponent(v)).join(",")}`);
140
- }
141
- }
142
- if (aiPayload.symmetry_from !== undefined || aiPayload.symmetry_to !== undefined) {
143
- const symmetryValues = getGradesInRange(SYMMETRY_GRADES, aiPayload.symmetry_from, aiPayload.symmetry_to);
144
- if (symmetryValues.length > 0) {
145
- params.push(`symmetry=${symmetryValues.map(v => encodeURIComponent(v)).join(",")}`);
146
- }
147
- }
148
- if (aiPayload.fluorescence_intensities && Array.isArray(aiPayload.fluorescence_intensities) && aiPayload.fluorescence_intensities.length > 0) {
149
- params.push(`fluor=${aiPayload.fluorescence_intensities.map(f => encodeURIComponent(f)).join(",")}`);
150
- }
151
- if (aiPayload.labs && Array.isArray(aiPayload.labs) && aiPayload.labs.length > 0) {
152
- params.push(`labs=${aiPayload.labs.map(l => encodeURIComponent(l)).join(",")}`);
153
- }
154
- if (aiPayload.enhancements && Array.isArray(aiPayload.enhancements) && aiPayload.enhancements.length > 0) {
155
- params.push(`treatment=${aiPayload.enhancements.map(e => encodeURIComponent(e)).join(",")}`);
156
- }
157
- if (aiPayload.vendor_locations && Array.isArray(aiPayload.vendor_locations) && aiPayload.vendor_locations.length > 0) {
158
- params.push(`origin=${aiPayload.vendor_locations.map(v => encodeURIComponent(v)).join(",")}`);
159
- }
160
- if (aiPayload.with_available_items === true || aiPayload.with_available_items === "true") {
161
- params.push(`own_inventory=${encodeURIComponent("In-Stock Inventory")}`);
162
- }
163
- if (aiPayload.fancy_colors && Array.isArray(aiPayload.fancy_colors) && aiPayload.fancy_colors.length > 0) {
164
- params.push(`fancy=${aiPayload.fancy_colors.map(f => encodeURIComponent(f)).join(",")}`);
165
- }
166
- return params.join("&");
167
- }
168
-
169
- /**
170
- * Default payload for Shopify plugin API calls
171
- */
172
- const DEFAULT_PLUGIN_API_PAYLOAD = exports.DEFAULT_PLUGIN_API_PAYLOAD = {
173
- type: "Diamond",
174
- cut_from: "Good",
175
- cut_to: "Ideal",
176
- polish_from: "Good",
177
- polish_to: "Ideal",
178
- symmetry_from: "Good",
179
- symmetry_to: "Ideal",
180
- depth_percent_from: "0",
181
- depth_percent_to: "100",
182
- table_percent_from: "0.0",
183
- table_percent_to: "100.0",
184
- fluorescence_intensities: ["None", "Faint", "Very Slight", "Medium", "Slight"],
185
- labs: ["GIA", "AGS", "IGI"],
186
- size_from: "0.00",
187
- size_to: "20.00",
188
- price_total_from: "0",
189
- price_total_to: "9590762.18",
190
- page_number: 1,
191
- page_size: 12,
192
- with_images: false,
193
- with_videos: false
194
- };
195
-
196
- /**
197
- * Transforms AI payload to Shopify-compatible API payload
198
- * Starts with defaults and overrides with AI values
199
- * @param aiPayload - The AI search payload
200
- * @param apiDefaults - Optional API defaults from store config
201
- */
202
- function buildPluginApiPayload(aiPayload, apiDefaults) {
203
- // Merge store config defaults with hardcoded defaults
204
- const payload = {
205
- ...DEFAULT_PLUGIN_API_PAYLOAD,
206
- ...apiDefaults
207
- };
208
- if (aiPayload.shapes && Array.isArray(aiPayload.shapes) && aiPayload.shapes.length > 0) {
209
- payload.shapes = aiPayload.shapes;
210
- }
211
- if (aiPayload.clarity_from !== undefined) {
212
- payload.clarity_from = aiPayload.clarity_from;
213
- }
214
- if (aiPayload.clarity_to !== undefined) {
215
- payload.clarity_to = aiPayload.clarity_to;
216
- }
217
- if (aiPayload.size_from !== undefined) {
218
- payload.size_from = String(aiPayload.size_from);
219
- }
220
- if (aiPayload.size_to !== undefined) {
221
- payload.size_to = String(aiPayload.size_to);
222
- }
223
- if (aiPayload.color_from !== undefined) {
224
- payload.color_from = aiPayload.color_from;
225
- }
226
- if (aiPayload.color_to !== undefined) {
227
- payload.color_to = aiPayload.color_to;
228
- }
229
- if (aiPayload.cut_from !== undefined) {
230
- payload.cut_from = aiPayload.cut_from;
231
- }
232
- if (aiPayload.cut_to !== undefined) {
233
- payload.cut_to = aiPayload.cut_to;
234
- }
235
- if (aiPayload.polish_from !== undefined) {
236
- payload.polish_from = aiPayload.polish_from;
237
- }
238
- if (aiPayload.polish_to !== undefined) {
239
- payload.polish_to = aiPayload.polish_to;
240
- }
241
- if (aiPayload.symmetry_from !== undefined) {
242
- payload.symmetry_from = aiPayload.symmetry_from;
243
- }
244
- if (aiPayload.symmetry_to !== undefined) {
245
- payload.symmetry_to = aiPayload.symmetry_to;
246
- }
247
- if (aiPayload.depth_percent_from !== undefined && aiPayload.depth_percent_from !== "0" && aiPayload.depth_percent_to !== "100") {
248
- payload.depth_percent_from = String(aiPayload.depth_percent_from);
249
- }
250
- if (aiPayload.depth_percent_to !== undefined && aiPayload.depth_percent_from !== "0" && aiPayload.depth_percent_to !== "100") {
251
- payload.depth_percent_to = String(aiPayload.depth_percent_to);
252
- }
253
- if (aiPayload.table_percent_from !== undefined) {
254
- payload.table_percent_from = String(aiPayload.table_percent_from);
255
- }
256
- if (aiPayload.table_percent_to !== undefined) {
257
- payload.table_percent_to = String(aiPayload.table_percent_to);
258
- }
259
- if (aiPayload.fluorescence_intensities && Array.isArray(aiPayload.fluorescence_intensities) && aiPayload.fluorescence_intensities.length > 0) {
260
- payload.fluorescence_intensities = aiPayload.fluorescence_intensities;
261
- }
262
- if (aiPayload.labs && Array.isArray(aiPayload.labs) && aiPayload.labs.length > 0) {
263
- payload.labs = aiPayload.labs;
264
- }
265
- if (aiPayload.price_total_from !== undefined) {
266
- payload.price_total_from = String(aiPayload.price_total_from);
267
- }
268
- if (aiPayload.price_total_to !== undefined) {
269
- payload.price_total_to = String(aiPayload.price_total_to);
270
- }
271
- if (aiPayload.lab_grown === true || aiPayload.lab_grown === "true") {
272
- payload.type = "Lab Grown Diamond";
273
- }
274
- if (aiPayload.fancy_colors && Array.isArray(aiPayload.fancy_colors) && aiPayload.fancy_colors.length > 0) {
275
- payload.fancy_colors = aiPayload.fancy_colors;
276
- }
277
- if (aiPayload.enhancements && Array.isArray(aiPayload.enhancements) && aiPayload.enhancements.length > 0) {
278
- payload.enhancements = aiPayload.enhancements;
279
- }
280
- if (aiPayload.vendor_locations && Array.isArray(aiPayload.vendor_locations) && aiPayload.vendor_locations.length > 0) {
281
- payload.vendor_locations = aiPayload.vendor_locations;
282
- }
283
- if (aiPayload.with_available_items !== undefined) {
284
- payload.with_available_items = aiPayload.with_available_items === true || aiPayload.with_available_items === "true";
285
- }
286
- return payload;
287
- }
288
- //# sourceMappingURL=pluginUrlBuilder.js.map