@simpleapps-com/augur-hooks 2.3.1 → 2026.11.1
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/EXPORTS.md +25 -65
- package/README.md +21 -246
- package/dist/checkout/create-checkout-provider.d.ts +25 -0
- package/dist/checkout/create-checkout-provider.d.ts.map +1 -0
- package/dist/checkout/index.cjs +123 -106
- package/dist/checkout/index.cjs.map +1 -1
- package/dist/checkout/index.d.ts +5 -293
- package/dist/checkout/index.d.ts.map +1 -0
- package/dist/checkout/index.js +99 -82
- package/dist/checkout/index.js.map +1 -1
- package/dist/checkout/{index.d.cts → types.d.ts} +18 -40
- package/dist/checkout/types.d.ts.map +1 -0
- package/dist/chunk-6Z6JGK2C.cjs.map +1 -1
- package/dist/chunk-QB7VB5FZ.cjs +523 -0
- package/dist/chunk-QB7VB5FZ.cjs.map +1 -0
- package/dist/{chunk-NRWH2BMN.js → chunk-UTDAFIQP.js} +237 -91
- package/dist/chunk-UTDAFIQP.js.map +1 -0
- package/dist/hooks/use-cart-actions.d.ts +68 -0
- package/dist/hooks/use-cart-actions.d.ts.map +1 -0
- package/dist/hooks/use-cart-initialization.d.ts +60 -0
- package/dist/hooks/use-cart-initialization.d.ts.map +1 -0
- package/dist/hooks/use-cart-pricing.d.ts +41 -0
- package/dist/hooks/use-cart-pricing.d.ts.map +1 -0
- package/dist/hooks/use-checkout-persistence.d.ts +40 -0
- package/dist/hooks/use-checkout-persistence.d.ts.map +1 -0
- package/dist/hooks/use-debounce.d.ts +6 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-format-price.d.ts +29 -0
- package/dist/hooks/use-format-price.d.ts.map +1 -0
- package/dist/hooks/use-latest.d.ts +8 -0
- package/dist/hooks/use-latest.d.ts.map +1 -0
- package/dist/hooks/use-modal-lifecycle.d.ts +11 -0
- package/dist/hooks/use-modal-lifecycle.d.ts.map +1 -0
- package/dist/hooks/use-order-readiness.d.ts +47 -0
- package/dist/hooks/use-order-readiness.d.ts.map +1 -0
- package/dist/hooks/use-pagination-prefetch.d.ts +26 -0
- package/dist/hooks/use-pagination-prefetch.d.ts.map +1 -0
- package/dist/{use-order-readiness-DZTIfRzw.d.ts → hooks/use-payment-flow.d.ts} +23 -67
- package/dist/hooks/use-payment-flow.d.ts.map +1 -0
- package/dist/hooks/use-stock.d.ts +32 -0
- package/dist/hooks/use-stock.d.ts.map +1 -0
- package/dist/index.cjs +251 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -456
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +230 -171
- package/dist/index.js.map +1 -1
- package/dist/persistence/apply-limits.d.ts +8 -0
- package/dist/persistence/apply-limits.d.ts.map +1 -0
- package/dist/persistence/create-persister.d.ts +10 -0
- package/dist/persistence/create-persister.d.ts.map +1 -0
- package/dist/persistence/serializer.d.ts +11 -0
- package/dist/persistence/serializer.d.ts.map +1 -0
- package/dist/persistence/use-persistence.d.ts +59 -0
- package/dist/persistence/use-persistence.d.ts.map +1 -0
- package/dist/persistence/use-storage-monitor.d.ts +11 -0
- package/dist/persistence/use-storage-monitor.d.ts.map +1 -0
- package/dist/provider.d.ts +89 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/queries/batch-query.d.ts +23 -0
- package/dist/queries/batch-query.d.ts.map +1 -0
- package/dist/queries/cache-helper.d.ts +16 -0
- package/dist/queries/cache-helper.d.ts.map +1 -0
- package/dist/queries/index.d.ts +3 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/query-action-registry.d.ts +19 -0
- package/dist/query-action-registry.d.ts.map +1 -0
- package/dist/rules.d.ts +130 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts +10 -12
- package/dist/server.d.ts.map +1 -0
- package/dist/stores/cart-store.d.ts +51 -0
- package/dist/stores/cart-store.d.ts.map +1 -0
- package/dist/stores/items-filters-store.d.ts +30 -0
- package/dist/stores/items-filters-store.d.ts.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/web/use-image-with-fallback.d.ts +16 -0
- package/dist/web/use-image-with-fallback.d.ts.map +1 -0
- package/dist/web/use-mobile-detection.d.ts +28 -0
- package/dist/web/use-mobile-detection.d.ts.map +1 -0
- package/dist/web/use-mobile-optimized-intersection.d.ts +17 -0
- package/dist/web/use-mobile-optimized-intersection.d.ts.map +1 -0
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.ts +4 -60
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js.map +1 -1
- package/llms.txt +76 -54
- package/package.json +25 -14
- package/dist/batch-query-CTlvxSmL.d.cts +0 -165
- package/dist/batch-query-CTlvxSmL.d.ts +0 -165
- package/dist/chunk-I4A5L2I6.cjs +0 -377
- package/dist/chunk-I4A5L2I6.cjs.map +0 -1
- package/dist/chunk-NRWH2BMN.js.map +0 -1
- package/dist/index.d.cts +0 -456
- package/dist/server.d.cts +0 -44
- package/dist/use-order-readiness-DZTIfRzw.d.cts +0 -137
- package/dist/web.d.cts +0 -60
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,15 @@ var _chunk6Z6JGK2Ccjs = require('./chunk-6Z6JGK2C.cjs');
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var _chunkQB7VB5FZcjs = require('./chunk-QB7VB5FZ.cjs');
|
|
24
32
|
|
|
25
33
|
// src/provider.tsx
|
|
26
34
|
var _react = require('react');
|
|
@@ -37,12 +45,14 @@ var AugurOptionsContext = _react.createContext.call(void 0, null);
|
|
|
37
45
|
var AugurSiteContext = _react.createContext.call(void 0, void 0);
|
|
38
46
|
function AugurHooksProvider({ api, auth, cache, site, children }) {
|
|
39
47
|
const proxyConfig = cache ? { cache: { static: cache.static, semiStatic: cache.semiStatic } } : void 0;
|
|
48
|
+
const proxyConfigRef = _chunkQB7VB5FZcjs.useLatest.call(void 0, proxyConfig);
|
|
40
49
|
const options = _react.useMemo.call(void 0, () => {
|
|
41
|
-
|
|
50
|
+
const config = proxyConfigRef.current;
|
|
51
|
+
if (api) return _augurcore.createOptionsProxy.call(void 0, api, config);
|
|
42
52
|
const registeredAction = _chunk6Z6JGK2Ccjs.getRegisteredQueryAction.call(void 0, );
|
|
43
|
-
if (registeredAction) return _augurcore.createQueryActionProxy.call(void 0, registeredAction,
|
|
44
|
-
return _augurcore.createKeysOnlyProxy.call(void 0,
|
|
45
|
-
}, [api]);
|
|
53
|
+
if (registeredAction) return _augurcore.createQueryActionProxy.call(void 0, registeredAction, config);
|
|
54
|
+
return _augurcore.createKeysOnlyProxy.call(void 0, config);
|
|
55
|
+
}, [api, proxyConfigRef]);
|
|
46
56
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AugurApiContext.Provider, { value: _nullishCoalesce(api, () => ( null)), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AugurAuthReactContext.Provider, { value: auth, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AugurCacheContext.Provider, { value: cache, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AugurSiteContext.Provider, { value: site, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AugurOptionsContext.Provider, { value: options, children }) }) }) }) });
|
|
47
57
|
}
|
|
48
58
|
function useAugurOptions() {
|
|
@@ -117,6 +127,7 @@ function useDebounce(value, delay = 500) {
|
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
// src/hooks/use-format-price.ts
|
|
130
|
+
var _augurutils = require('@simpleapps-com/augur-utils');
|
|
120
131
|
function normaliseOptions(optionsOrLocale, legacyCurrency) {
|
|
121
132
|
if (typeof optionsOrLocale === "string") {
|
|
122
133
|
return { locale: optionsOrLocale, currency: legacyCurrency };
|
|
@@ -124,11 +135,12 @@ function normaliseOptions(optionsOrLocale, legacyCurrency) {
|
|
|
124
135
|
return _nullishCoalesce(optionsOrLocale, () => ( {}));
|
|
125
136
|
}
|
|
126
137
|
function resolveFormatting(opts, siteFormatting) {
|
|
138
|
+
const site = _nullishCoalesce(siteFormatting, () => ( {}));
|
|
127
139
|
return {
|
|
128
|
-
locale: _nullishCoalesce(_nullishCoalesce(opts.locale, () => (
|
|
129
|
-
currency: _nullishCoalesce(_nullishCoalesce(opts.currency, () => (
|
|
130
|
-
precision: _nullishCoalesce(_nullishCoalesce(opts.precision, () => (
|
|
131
|
-
zeroLabel: _nullishCoalesce(opts.zeroLabel, () => (
|
|
140
|
+
locale: _nullishCoalesce(_nullishCoalesce(opts.locale, () => ( site.locale)), () => ( "en-US")),
|
|
141
|
+
currency: _nullishCoalesce(_nullishCoalesce(opts.currency, () => ( site.currency)), () => ( "USD")),
|
|
142
|
+
precision: _nullishCoalesce(_nullishCoalesce(opts.precision, () => ( site.precision)), () => ( 2)),
|
|
143
|
+
zeroLabel: _nullishCoalesce(opts.zeroLabel, () => ( site.zeroLabel))
|
|
132
144
|
};
|
|
133
145
|
}
|
|
134
146
|
function useFormatPrice(optionsOrLocale, legacyCurrency) {
|
|
@@ -139,13 +151,13 @@ function useFormatPrice(optionsOrLocale, legacyCurrency) {
|
|
|
139
151
|
currency,
|
|
140
152
|
precision: basePrecision,
|
|
141
153
|
zeroLabel
|
|
142
|
-
} = resolveFormatting(opts, _optionalChain([site, 'optionalAccess',
|
|
154
|
+
} = resolveFormatting(opts, _optionalChain([site, 'optionalAccess', _ => _.formatting]));
|
|
143
155
|
const formatPrice = (price, callOptions) => {
|
|
144
|
-
const effectiveValue = price * (_nullishCoalesce(_optionalChain([callOptions, 'optionalAccess',
|
|
156
|
+
const effectiveValue = _augurutils.cleanMoney.call(void 0, price * (_nullishCoalesce(_optionalChain([callOptions, 'optionalAccess', _2 => _2.quantity]), () => ( 1))));
|
|
145
157
|
if (effectiveValue === 0 && zeroLabel !== void 0) {
|
|
146
158
|
return zeroLabel;
|
|
147
159
|
}
|
|
148
|
-
const precision = _nullishCoalesce(_optionalChain([callOptions, 'optionalAccess',
|
|
160
|
+
const precision = _nullishCoalesce(_optionalChain([callOptions, 'optionalAccess', _3 => _3.precision]), () => ( basePrecision));
|
|
149
161
|
return new Intl.NumberFormat(locale, {
|
|
150
162
|
style: "currency",
|
|
151
163
|
currency,
|
|
@@ -159,7 +171,7 @@ function useFormatPrice(optionsOrLocale, legacyCurrency) {
|
|
|
159
171
|
// src/hooks/use-stock.ts
|
|
160
172
|
|
|
161
173
|
var _reactquery = require('@tanstack/react-query');
|
|
162
|
-
|
|
174
|
+
|
|
163
175
|
function useStock(invMastUid, options = {}) {
|
|
164
176
|
const proxy = useAugurOptions();
|
|
165
177
|
const resolvedQueryFn = options.queryFn;
|
|
@@ -167,22 +179,11 @@ function useStock(invMastUid, options = {}) {
|
|
|
167
179
|
const query = _reactquery.useQuery.call(void 0, {
|
|
168
180
|
...proxyOpts,
|
|
169
181
|
...resolvedQueryFn ? { queryFn: resolvedQueryFn } : {},
|
|
170
|
-
enabled: (
|
|
182
|
+
enabled: _chunkQB7VB5FZcjs.stockEnabled.call(void 0, options.enabled, !!invMastUid),
|
|
171
183
|
retry: 3,
|
|
172
|
-
|
|
173
|
-
retryDelay: (attemptIndex) => Math.min(1e3 * 2 ** attemptIndex, 1e4)
|
|
174
|
-
/* v8 ignore stop */
|
|
184
|
+
retryDelay: _chunkQB7VB5FZcjs.stockRetryDelay
|
|
175
185
|
});
|
|
176
|
-
const stockData =
|
|
177
|
-
const rawData = query.data;
|
|
178
|
-
if (!rawData) return null;
|
|
179
|
-
const inner = _nullishCoalesce(rawData.data, () => ( rawData));
|
|
180
|
-
const stock = inner;
|
|
181
|
-
return {
|
|
182
|
-
stockData: _nullishCoalesce(stock.stockData, () => ( [])),
|
|
183
|
-
companySummary: _nullishCoalesce(stock.companySummary, () => ( {}))
|
|
184
|
-
};
|
|
185
|
-
}, [query.data]);
|
|
186
|
+
const stockData = _nullishCoalesce(query.data, () => ( null));
|
|
186
187
|
const resolved = _react.useMemo.call(void 0,
|
|
187
188
|
() => _augurutils.resolveStock.call(void 0, {
|
|
188
189
|
stock: stockData,
|
|
@@ -204,16 +205,30 @@ function useStock(invMastUid, options = {}) {
|
|
|
204
205
|
// src/hooks/use-cart-actions.ts
|
|
205
206
|
|
|
206
207
|
|
|
208
|
+
|
|
209
|
+
// ../utils/src/lists.ts
|
|
210
|
+
function hasNumberFrom(xs, x, i) {
|
|
211
|
+
if (i === xs.length) return false;
|
|
212
|
+
if (xs[i] === x) return true;
|
|
213
|
+
return hasNumberFrom(xs, x, i + 1);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// src/hooks/use-cart-actions.ts
|
|
207
217
|
function requireCartUid(cartHdrUid) {
|
|
208
218
|
const num = typeof cartHdrUid === "string" ? Number(cartHdrUid) : cartHdrUid;
|
|
209
|
-
|
|
210
|
-
|
|
219
|
+
const uid = _chunkQB7VB5FZcjs.requiredCartUid.call(void 0, num === void 0 || Number.isNaN(num) ? void 0 : num);
|
|
220
|
+
if (uid === null) throw new Error("Cart UID is not set");
|
|
221
|
+
return uid;
|
|
222
|
+
}
|
|
223
|
+
function liveCart() {
|
|
224
|
+
const { cartHdrUid, cartLines } = _chunkQB7VB5FZcjs.useCartStore.getState();
|
|
225
|
+
return { uid: requireCartUid(cartHdrUid), lines: cartLines };
|
|
211
226
|
}
|
|
212
227
|
function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
213
|
-
const existingIndex =
|
|
228
|
+
const existingIndex = _chunkQB7VB5FZcjs.indexOfUidFrom.call(void 0, uidsOf(cartLines), item.invMastUid, 0);
|
|
214
229
|
if (existingIndex >= 0) {
|
|
215
230
|
return cartLines.map(
|
|
216
|
-
(line, index) => index === existingIndex ? { ...line, quantity: line.quantity + item.quantity } : line
|
|
231
|
+
(line, index) => index === existingIndex ? { ...line, quantity: _chunkQB7VB5FZcjs.qtyOrZero.call(void 0, line.quantity) + item.quantity } : line
|
|
217
232
|
);
|
|
218
233
|
}
|
|
219
234
|
return [
|
|
@@ -227,15 +242,62 @@ function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
|
227
242
|
lineNo: cartLines.length + 1,
|
|
228
243
|
lineNote: null,
|
|
229
244
|
quantity: item.quantity,
|
|
230
|
-
unitOfMeasure: item.unitOfMeasure
|
|
245
|
+
unitOfMeasure: item.unitOfMeasure,
|
|
246
|
+
key: null,
|
|
247
|
+
unitPrice: null
|
|
231
248
|
}
|
|
232
249
|
];
|
|
233
250
|
}
|
|
251
|
+
function reverseAdd(cartLines, invMastUid, quantity) {
|
|
252
|
+
return cartLines.flatMap((line) => {
|
|
253
|
+
if (line.invMastUid !== invMastUid) return [line];
|
|
254
|
+
return _chunkQB7VB5FZcjs.keepsAfterReverse.call(void 0, line.quantity, quantity) ? [{ ...line, quantity: _chunkQB7VB5FZcjs.qtyOrZero.call(void 0, line.quantity) - quantity }] : [];
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function reverseQuantity(cartLines, invMastUid, previousQuantity) {
|
|
258
|
+
if (previousQuantity === void 0) return cartLines;
|
|
259
|
+
return cartLines.map(
|
|
260
|
+
(line) => line.invMastUid === invMastUid ? { ...line, quantity: previousQuantity } : line
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
function restoreRemoved(cartLines, invMastUid, removedLine) {
|
|
264
|
+
if (!removedLine) return cartLines;
|
|
265
|
+
if (hasNumberFrom(uidsOf(cartLines), invMastUid, 0)) return cartLines;
|
|
266
|
+
return [...cartLines, removedLine];
|
|
267
|
+
}
|
|
268
|
+
function mergeRestore(cartLines, snapshot) {
|
|
269
|
+
const merged = [...cartLines];
|
|
270
|
+
for (const line of snapshot) {
|
|
271
|
+
if (!hasNumberFrom(uidsOf(merged), line.invMastUid, 0)) merged.push(line);
|
|
272
|
+
}
|
|
273
|
+
return merged;
|
|
274
|
+
}
|
|
275
|
+
function uidsOf(cartLines) {
|
|
276
|
+
return cartLines.map((line) => line.invMastUid);
|
|
277
|
+
}
|
|
278
|
+
function sendToast(notify, kind, showToast, message) {
|
|
279
|
+
if (showToast && message !== void 0) _optionalChain([notify, 'optionalAccess', _4 => _4[kind], 'optionalCall', _5 => _5(message)]);
|
|
280
|
+
}
|
|
281
|
+
async function settleCartOp(op, options, notify, invalidate) {
|
|
282
|
+
try {
|
|
283
|
+
const success = await op.call();
|
|
284
|
+
if (!success) throw new Error(op.failure);
|
|
285
|
+
invalidate();
|
|
286
|
+
sendToast(notify, "info", op.showToast, op.infoMessage);
|
|
287
|
+
_optionalChain([options, 'access', _6 => _6.onSuccess, 'optionalCall', _7 => _7()]);
|
|
288
|
+
return true;
|
|
289
|
+
} catch (error) {
|
|
290
|
+
op.rollback();
|
|
291
|
+
sendToast(notify, "error", op.showToast, op.errorMessage);
|
|
292
|
+
_optionalChain([options, 'access', _8 => _8.onError, 'optionalCall', _9 => _9(error)]);
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
234
296
|
function useCartActions(callbacks) {
|
|
235
297
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
236
|
-
const cartHdrUid =
|
|
237
|
-
const cartLines =
|
|
238
|
-
const setCartLines =
|
|
298
|
+
const cartHdrUid = _chunkQB7VB5FZcjs.useCartHdrUid.call(void 0, );
|
|
299
|
+
const cartLines = _chunkQB7VB5FZcjs.useCartLines.call(void 0, );
|
|
300
|
+
const setCartLines = _chunkQB7VB5FZcjs.useSetCartLines.call(void 0, );
|
|
239
301
|
const notify = callbacks.toast;
|
|
240
302
|
const invalidateCartCache = _react.useCallback.call(void 0, () => {
|
|
241
303
|
void queryClient.invalidateQueries({ queryKey: ["cartLines", cartHdrUid] });
|
|
@@ -245,117 +307,107 @@ function useCartActions(callbacks) {
|
|
|
245
307
|
}, [queryClient, cartHdrUid]);
|
|
246
308
|
const addToCart = _react.useCallback.call(void 0,
|
|
247
309
|
async (item, options = {}) => {
|
|
248
|
-
const { showToast = true, itemId = ""
|
|
249
|
-
const uid =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
_optionalChain([onError, 'optionalCall', _11 => _11(error)]);
|
|
274
|
-
return false;
|
|
275
|
-
}
|
|
310
|
+
const { showToast = true, itemId = "" } = options;
|
|
311
|
+
const { uid, lines: liveLines } = liveCart();
|
|
312
|
+
setCartLines(buildOptimisticAdd(liveLines, item, uid, itemId));
|
|
313
|
+
return settleCartOp(
|
|
314
|
+
{
|
|
315
|
+
call: () => callbacks.addToCart(uid, [
|
|
316
|
+
{
|
|
317
|
+
cartHdrUid: uid,
|
|
318
|
+
invMastUid: item.invMastUid,
|
|
319
|
+
quantity: item.quantity,
|
|
320
|
+
unitOfMeasure: item.unitOfMeasure
|
|
321
|
+
}
|
|
322
|
+
]),
|
|
323
|
+
failure: "Failed to add item to cart",
|
|
324
|
+
infoMessage: `${item.quantity} x ${itemId || "Item"} added to cart`,
|
|
325
|
+
errorMessage: "Failed to add item to cart. Please try again.",
|
|
326
|
+
showToast,
|
|
327
|
+
rollback: () => setCartLines(
|
|
328
|
+
reverseAdd(_chunkQB7VB5FZcjs.useCartStore.getState().cartLines, item.invMastUid, item.quantity)
|
|
329
|
+
)
|
|
330
|
+
},
|
|
331
|
+
options,
|
|
332
|
+
notify,
|
|
333
|
+
invalidateCartCache
|
|
334
|
+
);
|
|
276
335
|
},
|
|
277
|
-
[
|
|
336
|
+
[setCartLines, invalidateCartCache, callbacks, notify]
|
|
278
337
|
);
|
|
279
338
|
const updateQuantity = _react.useCallback.call(void 0,
|
|
280
339
|
async (invMastUid, newQuantity, options = {}) => {
|
|
281
|
-
const { showToast = false
|
|
282
|
-
const uid =
|
|
283
|
-
const
|
|
284
|
-
const updatedLines =
|
|
340
|
+
const { showToast = false } = options;
|
|
341
|
+
const { uid, lines: liveLines } = liveCart();
|
|
342
|
+
const previousQuantity = _optionalChain([liveLines, 'access', _10 => _10.find, 'call', _11 => _11((line) => line.invMastUid === invMastUid), 'optionalAccess', _12 => _12.quantity]);
|
|
343
|
+
const updatedLines = liveLines.map(
|
|
285
344
|
(line) => line.invMastUid === invMastUid ? { ...line, quantity: newQuantity } : line
|
|
286
345
|
);
|
|
287
346
|
setCartLines(updatedLines);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
347
|
+
return settleCartOp(
|
|
348
|
+
{
|
|
349
|
+
call: () => callbacks.updateCartLines(uid, updatedLines),
|
|
350
|
+
failure: "Failed to update quantity",
|
|
351
|
+
errorMessage: "Failed to update quantity. Please try again.",
|
|
352
|
+
showToast,
|
|
353
|
+
rollback: () => setCartLines(
|
|
354
|
+
reverseQuantity(_chunkQB7VB5FZcjs.useCartStore.getState().cartLines, invMastUid, previousQuantity)
|
|
355
|
+
)
|
|
356
|
+
},
|
|
357
|
+
options,
|
|
358
|
+
notify,
|
|
359
|
+
invalidateCartCache
|
|
360
|
+
);
|
|
302
361
|
},
|
|
303
|
-
[
|
|
362
|
+
[setCartLines, invalidateCartCache, callbacks, notify]
|
|
304
363
|
);
|
|
305
364
|
const removeFromCart = _react.useCallback.call(void 0,
|
|
306
365
|
async (invMastUid, options = {}) => {
|
|
307
|
-
const { showToast = true, itemId = ""
|
|
308
|
-
const uid =
|
|
309
|
-
const
|
|
310
|
-
setCartLines(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
366
|
+
const { showToast = true, itemId = "" } = options;
|
|
367
|
+
const { uid, lines: liveLines } = liveCart();
|
|
368
|
+
const removedLine = liveLines.find((line) => line.invMastUid === invMastUid);
|
|
369
|
+
setCartLines(liveLines.filter((line) => line.invMastUid !== invMastUid));
|
|
370
|
+
const zeroedLines = liveLines.map(
|
|
371
|
+
(line) => line.invMastUid === invMastUid ? { ...line, quantity: 0 } : line
|
|
372
|
+
);
|
|
373
|
+
return settleCartOp(
|
|
374
|
+
{
|
|
375
|
+
call: () => callbacks.updateCartLines(uid, zeroedLines),
|
|
376
|
+
failure: "Failed to remove item",
|
|
377
|
+
infoMessage: `${itemId || "Item"} removed from cart`,
|
|
378
|
+
errorMessage: "Failed to remove item. Please try again.",
|
|
379
|
+
showToast,
|
|
380
|
+
rollback: () => setCartLines(
|
|
381
|
+
restoreRemoved(_chunkQB7VB5FZcjs.useCartStore.getState().cartLines, invMastUid, removedLine)
|
|
382
|
+
)
|
|
383
|
+
},
|
|
384
|
+
options,
|
|
385
|
+
notify,
|
|
386
|
+
invalidateCartCache
|
|
387
|
+
);
|
|
331
388
|
},
|
|
332
|
-
[
|
|
389
|
+
[setCartLines, invalidateCartCache, callbacks, notify]
|
|
333
390
|
);
|
|
334
391
|
const clearCart = _react.useCallback.call(void 0,
|
|
335
392
|
async (options = {}) => {
|
|
336
|
-
const { showToast = true
|
|
337
|
-
const uid =
|
|
338
|
-
const previousCartLines = [...cartLines];
|
|
393
|
+
const { showToast = true } = options;
|
|
394
|
+
const { uid, lines: snapshot } = liveCart();
|
|
339
395
|
setCartLines([]);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
_optionalChain([onError, 'optionalCall', _22 => _22(error)]);
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
396
|
+
return settleCartOp(
|
|
397
|
+
{
|
|
398
|
+
call: () => callbacks.deleteItemsFromCart(uid),
|
|
399
|
+
failure: "Failed to clear cart",
|
|
400
|
+
infoMessage: "Cart cleared",
|
|
401
|
+
errorMessage: "Failed to clear cart. Please try again.",
|
|
402
|
+
showToast,
|
|
403
|
+
rollback: () => setCartLines(mergeRestore(_chunkQB7VB5FZcjs.useCartStore.getState().cartLines, snapshot))
|
|
404
|
+
},
|
|
405
|
+
options,
|
|
406
|
+
notify,
|
|
407
|
+
invalidateCartCache
|
|
408
|
+
);
|
|
357
409
|
},
|
|
358
|
-
[
|
|
410
|
+
[setCartLines, invalidateCartCache, callbacks, notify]
|
|
359
411
|
);
|
|
360
412
|
const isInCart = _react.useCallback.call(void 0,
|
|
361
413
|
(invMastUid) => {
|
|
@@ -365,7 +417,7 @@ function useCartActions(callbacks) {
|
|
|
365
417
|
);
|
|
366
418
|
const getItemQuantity = _react.useCallback.call(void 0,
|
|
367
419
|
(invMastUid) => {
|
|
368
|
-
return _nullishCoalesce(_optionalChain([cartLines, 'access',
|
|
420
|
+
return _nullishCoalesce(_optionalChain([cartLines, 'access', _13 => _13.find, 'call', _14 => _14((line) => line.invMastUid === invMastUid), 'optionalAccess', _15 => _15.quantity]), () => ( 0));
|
|
369
421
|
},
|
|
370
422
|
[cartLines]
|
|
371
423
|
);
|
|
@@ -410,6 +462,11 @@ function useModalLifecycle(isOpen, onClose) {
|
|
|
410
462
|
|
|
411
463
|
var MAX_RETRY_ATTEMPTS = 7;
|
|
412
464
|
var RETRY_DELAY_MS = 1e3;
|
|
465
|
+
async function waitBeforeRetry(attempt) {
|
|
466
|
+
if (attempt >= MAX_RETRY_ATTEMPTS) return;
|
|
467
|
+
const delay = Math.min(RETRY_DELAY_MS * Math.pow(1.5, attempt), 1e4);
|
|
468
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
469
|
+
}
|
|
413
470
|
var defaultGetCartToken = () => localStorage.getItem("cartToken");
|
|
414
471
|
var defaultSaveCartToken = (token) => localStorage.setItem("cartToken", token);
|
|
415
472
|
var defaultGenerateCartToken = () => crypto.randomUUID();
|
|
@@ -418,14 +475,14 @@ function useCartInitialization(session, callbacks) {
|
|
|
418
475
|
const saveCartToken = _nullishCoalesce(callbacks.saveCartToken, () => ( defaultSaveCartToken));
|
|
419
476
|
const generateCartToken = _nullishCoalesce(callbacks.generateCartToken, () => ( defaultGenerateCartToken));
|
|
420
477
|
const auth = useAugurAuth();
|
|
421
|
-
const cartHdrUid =
|
|
422
|
-
const setCartHdrUid =
|
|
423
|
-
const setCartLines =
|
|
424
|
-
const clearCart =
|
|
478
|
+
const cartHdrUid = _chunkQB7VB5FZcjs.useCartHdrUid.call(void 0, );
|
|
479
|
+
const setCartHdrUid = _chunkQB7VB5FZcjs.useSetCartHdrUid.call(void 0, );
|
|
480
|
+
const setCartLines = _chunkQB7VB5FZcjs.useSetCartLines.call(void 0, );
|
|
481
|
+
const clearCart = _chunkQB7VB5FZcjs.useClearCart.call(void 0, );
|
|
425
482
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
426
483
|
const effectiveStatus = session.status;
|
|
427
|
-
const effectiveUserId = _nullishCoalesce(session.userId, () => ( _optionalChain([auth, 'optionalAccess',
|
|
428
|
-
const effectiveCartHdrUid = _nullishCoalesce(session.cartHdrUid, () => ( _optionalChain([auth, 'optionalAccess',
|
|
484
|
+
const effectiveUserId = _nullishCoalesce(session.userId, () => ( _optionalChain([auth, 'optionalAccess', _16 => _16.userId])));
|
|
485
|
+
const effectiveCartHdrUid = _nullishCoalesce(session.cartHdrUid, () => ( _optionalChain([auth, 'optionalAccess', _17 => _17.cartHdrUid])));
|
|
429
486
|
const effectiveSession = _react.useMemo.call(void 0,
|
|
430
487
|
() => ({ status: effectiveStatus, userId: effectiveUserId, cartHdrUid: effectiveCartHdrUid }),
|
|
431
488
|
[effectiveStatus, effectiveUserId, effectiveCartHdrUid]
|
|
@@ -454,6 +511,7 @@ function useCartInitialization(session, callbacks) {
|
|
|
454
511
|
const initializeGuestCart = async () => {
|
|
455
512
|
const existingToken = getCartToken();
|
|
456
513
|
const cartToken = existingToken && typeof existingToken === "string" ? existingToken : generateCartToken();
|
|
514
|
+
let lastError;
|
|
457
515
|
while (retryCountRef.current < MAX_RETRY_ATTEMPTS) {
|
|
458
516
|
try {
|
|
459
517
|
const cartHdr = await callbacks.cartHdrLookup("0", cartToken);
|
|
@@ -464,23 +522,14 @@ function useCartInitialization(session, callbacks) {
|
|
|
464
522
|
return;
|
|
465
523
|
}
|
|
466
524
|
retryCountRef.current++;
|
|
467
|
-
|
|
468
|
-
const delay = Math.min(RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current), 1e4);
|
|
469
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
470
|
-
}
|
|
525
|
+
await waitBeforeRetry(retryCountRef.current);
|
|
471
526
|
} catch (error) {
|
|
472
|
-
|
|
473
|
-
`Cart initialization attempt ${retryCountRef.current + 1} failed:`,
|
|
474
|
-
error
|
|
475
|
-
);
|
|
527
|
+
lastError = error;
|
|
476
528
|
retryCountRef.current++;
|
|
477
|
-
|
|
478
|
-
const delay = Math.min(RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current), 1e4);
|
|
479
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
480
|
-
}
|
|
529
|
+
await waitBeforeRetry(retryCountRef.current);
|
|
481
530
|
}
|
|
482
531
|
}
|
|
483
|
-
console.error(`Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts
|
|
532
|
+
console.error(`Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts`, lastError);
|
|
484
533
|
isInitializingRef.current = false;
|
|
485
534
|
};
|
|
486
535
|
void initializeGuestCart();
|
|
@@ -515,19 +564,33 @@ function useCartInitialization(session, callbacks) {
|
|
|
515
564
|
|
|
516
565
|
|
|
517
566
|
|
|
567
|
+
function deriveLineUnitPrice(priceData, quantity) {
|
|
568
|
+
if (typeof quantity !== "number" || !Number.isFinite(quantity)) return 0;
|
|
569
|
+
try {
|
|
570
|
+
const derived = _augurutils.derivePrice.call(void 0, { priceData, quantity });
|
|
571
|
+
return derived.state === "priced" ? derived.unitPrice : 0;
|
|
572
|
+
} catch (error) {
|
|
573
|
+
if (error instanceof RangeError) return 0;
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function lineTotal(unitPrice, quantity) {
|
|
578
|
+
return Number.isFinite(quantity) ? _augurutils.cleanMoney.call(void 0, unitPrice * quantity) : 0;
|
|
579
|
+
}
|
|
518
580
|
function useCartPricing(options = {}) {
|
|
519
581
|
const proxy = useAugurOptions();
|
|
520
582
|
const auth = useAugurAuth();
|
|
521
583
|
const site = useAugurSite();
|
|
522
|
-
const cartLines =
|
|
523
|
-
const customerId = _nullishCoalesce(_nullishCoalesce(options.customerId, () => ( _optionalChain([auth, 'optionalAccess',
|
|
584
|
+
const cartLines = _chunkQB7VB5FZcjs.useCartLines.call(void 0, );
|
|
585
|
+
const customerId = _nullishCoalesce(_nullishCoalesce(options.customerId, () => ( _optionalChain([auth, 'optionalAccess', _18 => _18.customerId]))), () => ( _optionalChain([site, 'optionalAccess', _19 => _19.defaults, 'optionalAccess', _20 => _20.customerId])));
|
|
524
586
|
const priceFn = options.queryFn;
|
|
525
587
|
const priceQueries = _reactquery.useQueries.call(void 0, {
|
|
526
588
|
queries: cartLines.map((line) => {
|
|
589
|
+
const quantity = _nullishCoalesce(line.quantity, () => ( 1));
|
|
527
590
|
if (priceFn) {
|
|
528
591
|
return {
|
|
529
|
-
queryKey: ["price", _optionalChain([line, 'access',
|
|
530
|
-
queryFn: () => priceFn(line.itemId, customerId,
|
|
592
|
+
queryKey: ["price", _optionalChain([line, 'access', _21 => _21.itemId, 'optionalAccess', _22 => _22.toUpperCase, 'call', _23 => _23()]) || "", customerId, quantity],
|
|
593
|
+
queryFn: () => priceFn(line.itemId, customerId, quantity),
|
|
531
594
|
refetchOnReconnect: true,
|
|
532
595
|
refetchOnWindowFocus: false,
|
|
533
596
|
meta: { persist: true },
|
|
@@ -535,9 +598,9 @@ function useCartPricing(options = {}) {
|
|
|
535
598
|
};
|
|
536
599
|
}
|
|
537
600
|
const proxyOpts = proxy.pricing.priceEngine.list({
|
|
538
|
-
itemId: _optionalChain([line, 'access',
|
|
601
|
+
itemId: _optionalChain([line, 'access', _24 => _24.itemId, 'optionalAccess', _25 => _25.toUpperCase, 'call', _26 => _26()]) || "",
|
|
539
602
|
customerId: Number(customerId),
|
|
540
|
-
quantity
|
|
603
|
+
quantity
|
|
541
604
|
});
|
|
542
605
|
return {
|
|
543
606
|
...proxyOpts,
|
|
@@ -552,15 +615,11 @@ function useCartPricing(options = {}) {
|
|
|
552
615
|
const map = {};
|
|
553
616
|
cartLines.forEach((line, index) => {
|
|
554
617
|
const queryResult = priceQueries[index];
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
const
|
|
558
|
-
const derived = _augurutils.derivePrice.call(void 0, {
|
|
559
|
-
priceData,
|
|
560
|
-
quantity: line.quantity
|
|
561
|
-
});
|
|
618
|
+
const priceData = _optionalChain([queryResult, 'optionalAccess', _27 => _27.data]);
|
|
619
|
+
if (priceData) {
|
|
620
|
+
const unitPrice = deriveLineUnitPrice(priceData, line.quantity);
|
|
562
621
|
map[line.itemId.toUpperCase()] = {
|
|
563
|
-
unitPrice
|
|
622
|
+
unitPrice,
|
|
564
623
|
priceData
|
|
565
624
|
};
|
|
566
625
|
}
|
|
@@ -569,18 +628,18 @@ function useCartPricing(options = {}) {
|
|
|
569
628
|
}, [cartLines, priceQueries]);
|
|
570
629
|
const getUnitPrice = _react.useMemo.call(void 0, () => {
|
|
571
630
|
return (itemId) => {
|
|
572
|
-
return _nullishCoalesce(_optionalChain([prices, 'access',
|
|
631
|
+
return _nullishCoalesce(_optionalChain([prices, 'access', _28 => _28[_optionalChain([itemId, 'optionalAccess', _29 => _29.toUpperCase, 'call', _30 => _30()])], 'optionalAccess', _31 => _31.unitPrice]), () => ( 0));
|
|
573
632
|
};
|
|
574
633
|
}, [prices]);
|
|
575
634
|
const getItemTotal = _react.useMemo.call(void 0, () => {
|
|
576
635
|
return (itemId, quantity) => {
|
|
577
|
-
return getUnitPrice(itemId)
|
|
636
|
+
return lineTotal(getUnitPrice(itemId), quantity);
|
|
578
637
|
};
|
|
579
638
|
}, [getUnitPrice]);
|
|
580
639
|
const subtotal = _react.useMemo.call(void 0, () => {
|
|
581
640
|
return cartLines.reduce((sum, line) => {
|
|
582
|
-
const unitPrice = _nullishCoalesce(_optionalChain([prices, 'access',
|
|
583
|
-
return sum + unitPrice
|
|
641
|
+
const unitPrice = _nullishCoalesce(_optionalChain([prices, 'access', _32 => _32[line.itemId.toUpperCase()], 'optionalAccess', _33 => _33.unitPrice]), () => ( 0));
|
|
642
|
+
return _augurutils.cleanMoney.call(void 0, sum + lineTotal(unitPrice, line.quantity));
|
|
584
643
|
}, 0);
|
|
585
644
|
}, [cartLines, prices]);
|
|
586
645
|
const isLoading = priceQueries.some((q) => q.isLoading);
|
|
@@ -614,16 +673,12 @@ var usePaginationPrefetch = ({
|
|
|
614
673
|
async (page) => {
|
|
615
674
|
if (!enabled) return;
|
|
616
675
|
const offset = (page - 1) * pageSize;
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
});
|
|
624
|
-
} catch (error) {
|
|
625
|
-
console.warn(`Error prefetching page ${page}:`, error);
|
|
626
|
-
}
|
|
676
|
+
await queryClient.prefetchQuery({
|
|
677
|
+
queryKey: queryKeyFn ? queryKeyFn(queryKey, offset) : [...queryKey, offset],
|
|
678
|
+
queryFn: () => queryFn(offset),
|
|
679
|
+
staleTime,
|
|
680
|
+
gcTime
|
|
681
|
+
});
|
|
627
682
|
},
|
|
628
683
|
[queryKey, queryFn, pageSize, queryKeyFn, staleTime, gcTime, queryClient, enabled]
|
|
629
684
|
);
|
|
@@ -656,7 +711,7 @@ function deserialize(data) {
|
|
|
656
711
|
|
|
657
712
|
// src/persistence/apply-limits.ts
|
|
658
713
|
function applyLimits(data, limits) {
|
|
659
|
-
const queries = _optionalChain([data, 'access',
|
|
714
|
+
const queries = _optionalChain([data, 'access', _34 => _34.clientState, 'optionalAccess', _35 => _35.queries]);
|
|
660
715
|
if (!queries || Object.keys(limits).length === 0) return data;
|
|
661
716
|
const entries = queries;
|
|
662
717
|
const unlimited = [];
|
|
@@ -702,14 +757,12 @@ function createPersister(config) {
|
|
|
702
757
|
const limits = _nullishCoalesce(config.limits, () => ( {}));
|
|
703
758
|
let timer;
|
|
704
759
|
let pending;
|
|
705
|
-
function
|
|
706
|
-
if (!pending) return;
|
|
760
|
+
function write(client) {
|
|
707
761
|
try {
|
|
708
|
-
const limited = applyLimits(
|
|
762
|
+
const limited = applyLimits(client, limits);
|
|
709
763
|
window.localStorage.setItem(config.key, serialize(limited));
|
|
710
764
|
} catch (e2) {
|
|
711
765
|
}
|
|
712
|
-
pending = void 0;
|
|
713
766
|
}
|
|
714
767
|
return {
|
|
715
768
|
persistClient(client) {
|
|
@@ -717,7 +770,7 @@ function createPersister(config) {
|
|
|
717
770
|
if (!timer) {
|
|
718
771
|
timer = setTimeout(() => {
|
|
719
772
|
timer = void 0;
|
|
720
|
-
|
|
773
|
+
write(pending);
|
|
721
774
|
}, throttleMs);
|
|
722
775
|
}
|
|
723
776
|
},
|
|
@@ -741,8 +794,10 @@ function createPersister(config) {
|
|
|
741
794
|
var CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
742
795
|
function useStorageMonitor(config) {
|
|
743
796
|
const { key, limits = {}, maxStorageMB = 3 } = config;
|
|
744
|
-
const
|
|
797
|
+
const limitKeysRef = _chunkQB7VB5FZcjs.useLatest.call(void 0, Object.keys(limits));
|
|
798
|
+
const limitCount = limitKeysRef.current.length;
|
|
745
799
|
_react.useEffect.call(void 0, () => {
|
|
800
|
+
const limitKeys = limitKeysRef.current;
|
|
746
801
|
if (typeof window === "undefined" || limitKeys.length === 0) return;
|
|
747
802
|
function evict() {
|
|
748
803
|
const storage = window.localStorage;
|
|
@@ -757,7 +812,7 @@ function useStorageMonitor(config) {
|
|
|
757
812
|
const raw = storage.getItem(key);
|
|
758
813
|
if (!raw) return;
|
|
759
814
|
const parsed = JSON.parse(raw);
|
|
760
|
-
if (!_optionalChain([parsed, 'access',
|
|
815
|
+
if (!_optionalChain([parsed, 'access', _36 => _36.clientState, 'optionalAccess', _37 => _37.queries])) return;
|
|
761
816
|
parsed.clientState.queries = parsed.clientState.queries.filter(
|
|
762
817
|
(q) => {
|
|
763
818
|
if (!Array.isArray(q.queryKey)) return true;
|
|
@@ -773,10 +828,11 @@ function useStorageMonitor(config) {
|
|
|
773
828
|
evict();
|
|
774
829
|
const id = setInterval(evict, CHECK_INTERVAL_MS);
|
|
775
830
|
return () => clearInterval(id);
|
|
776
|
-
}, [key, maxStorageMB,
|
|
831
|
+
}, [key, maxStorageMB, limitCount, limitKeysRef]);
|
|
777
832
|
}
|
|
778
833
|
|
|
779
834
|
// src/persistence/use-persistence.ts
|
|
835
|
+
var PERSISTED_DATA_FORMAT = "augur-2";
|
|
780
836
|
function useAugurPersistence(config) {
|
|
781
837
|
const [persister] = _react.useState.call(void 0, () => createPersister(config));
|
|
782
838
|
const [isMounted, setIsMounted] = _react.useState.call(void 0, false);
|
|
@@ -784,15 +840,18 @@ function useAugurPersistence(config) {
|
|
|
784
840
|
setIsMounted(true);
|
|
785
841
|
}, []);
|
|
786
842
|
useStorageMonitor(config);
|
|
787
|
-
const isDev = typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
843
|
+
const isDev = typeof process !== "undefined" && _optionalChain([process, 'access', _38 => _38.env, 'optionalAccess', _39 => _39["NODE_ENV"]]) === "development";
|
|
788
844
|
const { persistableKeys } = config;
|
|
789
845
|
const dehydrateOptions = _react.useMemo.call(void 0,
|
|
790
846
|
() => ({
|
|
791
847
|
shouldDehydrateQuery: (query) => {
|
|
792
848
|
const key = query.queryKey;
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
849
|
+
const hasHead = Array.isArray(key) && key.length > 0;
|
|
850
|
+
return _chunkQB7VB5FZcjs.shouldPersistOf.call(void 0,
|
|
851
|
+
hasHead,
|
|
852
|
+
query.state.status === "success",
|
|
853
|
+
hasHead && persistableKeys.includes(key[0])
|
|
854
|
+
);
|
|
796
855
|
}
|
|
797
856
|
}),
|
|
798
857
|
[persistableKeys]
|
|
@@ -800,7 +859,7 @@ function useAugurPersistence(config) {
|
|
|
800
859
|
return {
|
|
801
860
|
persister,
|
|
802
861
|
maxAge: isMounted ? _nullishCoalesce(config.maxAge, () => ( 24 * 60 * 60 * 1e3)) : 0,
|
|
803
|
-
buster: isDev ? String(Date.now()) : _nullishCoalesce(config.buster, () => ( ""))
|
|
862
|
+
buster: isDev ? String(Date.now()) : `${PERSISTED_DATA_FORMAT}:${_nullishCoalesce(config.buster, () => ( ""))}`,
|
|
804
863
|
dehydrateOptions
|
|
805
864
|
};
|
|
806
865
|
}
|
|
@@ -841,5 +900,5 @@ function useAugurPersistence(config) {
|
|
|
841
900
|
|
|
842
901
|
|
|
843
902
|
|
|
844
|
-
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence =
|
|
903
|
+
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence = _chunkQB7VB5FZcjs.clearCheckoutPersistence; exports.clearFromSession = _chunkQB7VB5FZcjs.clearFromSession; exports.determineOrderReadiness = _chunkQB7VB5FZcjs.determineOrderReadiness; exports.executeBatchQuery = _chunk6Z6JGK2Ccjs.executeBatchQuery; exports.getRegisteredQueryAction = _chunk6Z6JGK2Ccjs.getRegisteredQueryAction; exports.loadFromSession = _chunkQB7VB5FZcjs.loadFromSession; exports.registerQueryAction = _chunk6Z6JGK2Ccjs.registerQueryAction; exports.saveToSession = _chunkQB7VB5FZcjs.saveToSession; exports.useAugurApi = useAugurApi; exports.useAugurApiOptional = useAugurApiOptional; exports.useAugurAuth = useAugurAuth; exports.useAugurCache = useAugurCache; exports.useAugurOptions = useAugurOptions; exports.useAugurPersistence = useAugurPersistence; exports.useAugurSite = useAugurSite; exports.useCartActions = useCartActions; exports.useCartHdrUid = _chunkQB7VB5FZcjs.useCartHdrUid; exports.useCartInitialization = useCartInitialization; exports.useCartLineCount = _chunkQB7VB5FZcjs.useCartLineCount; exports.useCartLines = _chunkQB7VB5FZcjs.useCartLines; exports.useCartPricing = useCartPricing; exports.useCartQuantityTotal = _chunkQB7VB5FZcjs.useCartQuantityTotal; exports.useCartStore = _chunkQB7VB5FZcjs.useCartStore; exports.useCheckoutPersistence = _chunkQB7VB5FZcjs.useCheckoutPersistence; exports.useClearCart = _chunkQB7VB5FZcjs.useClearCart; exports.useDebounce = useDebounce; exports.useFormatPrice = useFormatPrice; exports.useItemFiltersStore = useItemFiltersStore; exports.useModalLifecycle = useModalLifecycle; exports.useOrderReadiness = _chunkQB7VB5FZcjs.useOrderReadiness; exports.usePaginationPrefetch = usePaginationPrefetch; exports.usePaymentFlow = _chunkQB7VB5FZcjs.usePaymentFlow; exports.useSetCartHdrUid = _chunkQB7VB5FZcjs.useSetCartHdrUid; exports.useSetCartLines = _chunkQB7VB5FZcjs.useSetCartLines; exports.useStock = useStock;
|
|
845
904
|
//# sourceMappingURL=index.cjs.map
|