@simpleapps-com/augur-hooks 2026.11.1 → 2026.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXPORTS.md +3 -0
- package/dist/checkout/index.cjs +14 -14
- package/dist/checkout/index.js +1 -1
- package/dist/{chunk-UTDAFIQP.js → chunk-2BTOULIS.js} +45 -10
- package/dist/chunk-2BTOULIS.js.map +1 -0
- package/dist/{chunk-QB7VB5FZ.cjs → chunk-BWBJPKLV.cjs} +46 -11
- package/dist/chunk-BWBJPKLV.cjs.map +1 -0
- package/dist/duration.d.ts +16 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/hooks/use-checkout-persistence.d.ts +4 -3
- package/dist/hooks/use-checkout-persistence.d.ts.map +1 -1
- package/dist/hooks/use-pagination-prefetch.d.ts +5 -4
- package/dist/hooks/use-pagination-prefetch.d.ts.map +1 -1
- package/dist/index.cjs +66 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/persistence/create-persister.d.ts.map +1 -1
- package/dist/persistence/use-persistence.d.ts +1 -1
- package/dist/persistence/use-persistence.d.ts.map +1 -1
- package/dist/persistence/use-storage-monitor.d.ts.map +1 -1
- package/dist/rules.d.ts +22 -4
- package/dist/rules.d.ts.map +1 -1
- package/dist/server.cjs +2 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/user-write-clearing.d.ts +28 -0
- package/dist/user-write-clearing.d.ts.map +1 -0
- package/llms.txt +10 -0
- package/package.json +6 -5
- package/dist/chunk-QB7VB5FZ.cjs.map +0 -1
- package/dist/chunk-UTDAFIQP.js.map +0 -1
- package/dist/queries/cache-helper.d.ts +0 -16
- package/dist/queries/cache-helper.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,10 @@ var _chunk6Z6JGK2Ccjs = require('./chunk-6Z6JGK2C.cjs');
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _chunkBWBJPKLVcjs = require('./chunk-BWBJPKLV.cjs');
|
|
32
35
|
|
|
33
36
|
// src/provider.tsx
|
|
34
37
|
var _react = require('react');
|
|
@@ -45,7 +48,7 @@ var AugurOptionsContext = _react.createContext.call(void 0, null);
|
|
|
45
48
|
var AugurSiteContext = _react.createContext.call(void 0, void 0);
|
|
46
49
|
function AugurHooksProvider({ api, auth, cache, site, children }) {
|
|
47
50
|
const proxyConfig = cache ? { cache: { static: cache.static, semiStatic: cache.semiStatic } } : void 0;
|
|
48
|
-
const proxyConfigRef =
|
|
51
|
+
const proxyConfigRef = _chunkBWBJPKLVcjs.useLatest.call(void 0, proxyConfig);
|
|
49
52
|
const options = _react.useMemo.call(void 0, () => {
|
|
50
53
|
const config = proxyConfigRef.current;
|
|
51
54
|
if (api) return _augurcore.createOptionsProxy.call(void 0, api, config);
|
|
@@ -179,9 +182,9 @@ function useStock(invMastUid, options = {}) {
|
|
|
179
182
|
const query = _reactquery.useQuery.call(void 0, {
|
|
180
183
|
...proxyOpts,
|
|
181
184
|
...resolvedQueryFn ? { queryFn: resolvedQueryFn } : {},
|
|
182
|
-
enabled:
|
|
185
|
+
enabled: _chunkBWBJPKLVcjs.stockEnabled.call(void 0, options.enabled, !!invMastUid),
|
|
183
186
|
retry: 3,
|
|
184
|
-
retryDelay:
|
|
187
|
+
retryDelay: _chunkBWBJPKLVcjs.stockRetryDelay
|
|
185
188
|
});
|
|
186
189
|
const stockData = _nullishCoalesce(query.data, () => ( null));
|
|
187
190
|
const resolved = _react.useMemo.call(void 0,
|
|
@@ -205,30 +208,21 @@ function useStock(invMastUid, options = {}) {
|
|
|
205
208
|
// src/hooks/use-cart-actions.ts
|
|
206
209
|
|
|
207
210
|
|
|
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
|
|
217
211
|
function requireCartUid(cartHdrUid) {
|
|
218
212
|
const num = typeof cartHdrUid === "string" ? Number(cartHdrUid) : cartHdrUid;
|
|
219
|
-
const uid =
|
|
213
|
+
const uid = _chunkBWBJPKLVcjs.requiredCartUid.call(void 0, num === void 0 || Number.isNaN(num) ? void 0 : num);
|
|
220
214
|
if (uid === null) throw new Error("Cart UID is not set");
|
|
221
215
|
return uid;
|
|
222
216
|
}
|
|
223
217
|
function liveCart() {
|
|
224
|
-
const { cartHdrUid, cartLines } =
|
|
218
|
+
const { cartHdrUid, cartLines } = _chunkBWBJPKLVcjs.useCartStore.getState();
|
|
225
219
|
return { uid: requireCartUid(cartHdrUid), lines: cartLines };
|
|
226
220
|
}
|
|
227
221
|
function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
228
|
-
const existingIndex =
|
|
222
|
+
const existingIndex = _chunkBWBJPKLVcjs.indexOfUidFrom.call(void 0, uidsOf(cartLines), item.invMastUid, 0);
|
|
229
223
|
if (existingIndex >= 0) {
|
|
230
224
|
return cartLines.map(
|
|
231
|
-
(line, index) => index === existingIndex ? { ...line, quantity:
|
|
225
|
+
(line, index) => index === existingIndex ? { ...line, quantity: _chunkBWBJPKLVcjs.qtyOrZero.call(void 0, line.quantity) + item.quantity } : line
|
|
232
226
|
);
|
|
233
227
|
}
|
|
234
228
|
return [
|
|
@@ -251,7 +245,7 @@ function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
|
|
|
251
245
|
function reverseAdd(cartLines, invMastUid, quantity) {
|
|
252
246
|
return cartLines.flatMap((line) => {
|
|
253
247
|
if (line.invMastUid !== invMastUid) return [line];
|
|
254
|
-
return
|
|
248
|
+
return _chunkBWBJPKLVcjs.keepsAfterReverse.call(void 0, line.quantity, quantity) ? [{ ...line, quantity: _chunkBWBJPKLVcjs.qtyOrZero.call(void 0, line.quantity) - quantity }] : [];
|
|
255
249
|
});
|
|
256
250
|
}
|
|
257
251
|
function reverseQuantity(cartLines, invMastUid, previousQuantity) {
|
|
@@ -262,13 +256,13 @@ function reverseQuantity(cartLines, invMastUid, previousQuantity) {
|
|
|
262
256
|
}
|
|
263
257
|
function restoreRemoved(cartLines, invMastUid, removedLine) {
|
|
264
258
|
if (!removedLine) return cartLines;
|
|
265
|
-
if (hasNumberFrom(uidsOf(cartLines), invMastUid, 0)) return cartLines;
|
|
259
|
+
if (_chunkBWBJPKLVcjs.hasNumberFrom.call(void 0, uidsOf(cartLines), invMastUid, 0)) return cartLines;
|
|
266
260
|
return [...cartLines, removedLine];
|
|
267
261
|
}
|
|
268
262
|
function mergeRestore(cartLines, snapshot) {
|
|
269
263
|
const merged = [...cartLines];
|
|
270
264
|
for (const line of snapshot) {
|
|
271
|
-
if (!hasNumberFrom(uidsOf(merged), line.invMastUid, 0)) merged.push(line);
|
|
265
|
+
if (!_chunkBWBJPKLVcjs.hasNumberFrom.call(void 0, uidsOf(merged), line.invMastUid, 0)) merged.push(line);
|
|
272
266
|
}
|
|
273
267
|
return merged;
|
|
274
268
|
}
|
|
@@ -295,9 +289,9 @@ async function settleCartOp(op, options, notify, invalidate) {
|
|
|
295
289
|
}
|
|
296
290
|
function useCartActions(callbacks) {
|
|
297
291
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
298
|
-
const cartHdrUid =
|
|
299
|
-
const cartLines =
|
|
300
|
-
const setCartLines =
|
|
292
|
+
const cartHdrUid = _chunkBWBJPKLVcjs.useCartHdrUid.call(void 0, );
|
|
293
|
+
const cartLines = _chunkBWBJPKLVcjs.useCartLines.call(void 0, );
|
|
294
|
+
const setCartLines = _chunkBWBJPKLVcjs.useSetCartLines.call(void 0, );
|
|
301
295
|
const notify = callbacks.toast;
|
|
302
296
|
const invalidateCartCache = _react.useCallback.call(void 0, () => {
|
|
303
297
|
void queryClient.invalidateQueries({ queryKey: ["cartLines", cartHdrUid] });
|
|
@@ -325,7 +319,7 @@ function useCartActions(callbacks) {
|
|
|
325
319
|
errorMessage: "Failed to add item to cart. Please try again.",
|
|
326
320
|
showToast,
|
|
327
321
|
rollback: () => setCartLines(
|
|
328
|
-
reverseAdd(
|
|
322
|
+
reverseAdd(_chunkBWBJPKLVcjs.useCartStore.getState().cartLines, item.invMastUid, item.quantity)
|
|
329
323
|
)
|
|
330
324
|
},
|
|
331
325
|
options,
|
|
@@ -351,7 +345,7 @@ function useCartActions(callbacks) {
|
|
|
351
345
|
errorMessage: "Failed to update quantity. Please try again.",
|
|
352
346
|
showToast,
|
|
353
347
|
rollback: () => setCartLines(
|
|
354
|
-
reverseQuantity(
|
|
348
|
+
reverseQuantity(_chunkBWBJPKLVcjs.useCartStore.getState().cartLines, invMastUid, previousQuantity)
|
|
355
349
|
)
|
|
356
350
|
},
|
|
357
351
|
options,
|
|
@@ -378,7 +372,7 @@ function useCartActions(callbacks) {
|
|
|
378
372
|
errorMessage: "Failed to remove item. Please try again.",
|
|
379
373
|
showToast,
|
|
380
374
|
rollback: () => setCartLines(
|
|
381
|
-
restoreRemoved(
|
|
375
|
+
restoreRemoved(_chunkBWBJPKLVcjs.useCartStore.getState().cartLines, invMastUid, removedLine)
|
|
382
376
|
)
|
|
383
377
|
},
|
|
384
378
|
options,
|
|
@@ -400,7 +394,7 @@ function useCartActions(callbacks) {
|
|
|
400
394
|
infoMessage: "Cart cleared",
|
|
401
395
|
errorMessage: "Failed to clear cart. Please try again.",
|
|
402
396
|
showToast,
|
|
403
|
-
rollback: () => setCartLines(mergeRestore(
|
|
397
|
+
rollback: () => setCartLines(mergeRestore(_chunkBWBJPKLVcjs.useCartStore.getState().cartLines, snapshot))
|
|
404
398
|
},
|
|
405
399
|
options,
|
|
406
400
|
notify,
|
|
@@ -475,10 +469,10 @@ function useCartInitialization(session, callbacks) {
|
|
|
475
469
|
const saveCartToken = _nullishCoalesce(callbacks.saveCartToken, () => ( defaultSaveCartToken));
|
|
476
470
|
const generateCartToken = _nullishCoalesce(callbacks.generateCartToken, () => ( defaultGenerateCartToken));
|
|
477
471
|
const auth = useAugurAuth();
|
|
478
|
-
const cartHdrUid =
|
|
479
|
-
const setCartHdrUid =
|
|
480
|
-
const setCartLines =
|
|
481
|
-
const clearCart =
|
|
472
|
+
const cartHdrUid = _chunkBWBJPKLVcjs.useCartHdrUid.call(void 0, );
|
|
473
|
+
const setCartHdrUid = _chunkBWBJPKLVcjs.useSetCartHdrUid.call(void 0, );
|
|
474
|
+
const setCartLines = _chunkBWBJPKLVcjs.useSetCartLines.call(void 0, );
|
|
475
|
+
const clearCart = _chunkBWBJPKLVcjs.useClearCart.call(void 0, );
|
|
482
476
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
483
477
|
const effectiveStatus = session.status;
|
|
484
478
|
const effectiveUserId = _nullishCoalesce(session.userId, () => ( _optionalChain([auth, 'optionalAccess', _16 => _16.userId])));
|
|
@@ -581,7 +575,7 @@ function useCartPricing(options = {}) {
|
|
|
581
575
|
const proxy = useAugurOptions();
|
|
582
576
|
const auth = useAugurAuth();
|
|
583
577
|
const site = useAugurSite();
|
|
584
|
-
const cartLines =
|
|
578
|
+
const cartLines = _chunkBWBJPKLVcjs.useCartLines.call(void 0, );
|
|
585
579
|
const customerId = _nullishCoalesce(_nullishCoalesce(options.customerId, () => ( _optionalChain([auth, 'optionalAccess', _18 => _18.customerId]))), () => ( _optionalChain([site, 'optionalAccess', _19 => _19.defaults, 'optionalAccess', _20 => _20.customerId])));
|
|
586
580
|
const priceFn = options.queryFn;
|
|
587
581
|
const priceQueries = _reactquery.useQueries.call(void 0, {
|
|
@@ -659,13 +653,14 @@ function useCartPricing(options = {}) {
|
|
|
659
653
|
// src/hooks/use-pagination-prefetch.ts
|
|
660
654
|
|
|
661
655
|
|
|
656
|
+
|
|
662
657
|
var usePaginationPrefetch = ({
|
|
663
658
|
queryKey,
|
|
664
659
|
queryFn,
|
|
665
660
|
pageSize,
|
|
666
661
|
queryKeyFn,
|
|
667
|
-
staleTime =
|
|
668
|
-
gcTime =
|
|
662
|
+
staleTime = _augurutils.toMillis.call(void 0, _augurutils.minutes.call(void 0, 10)),
|
|
663
|
+
gcTime = _augurutils.toMillis.call(void 0, _augurutils.minutes.call(void 0, 30)),
|
|
669
664
|
enabled = true
|
|
670
665
|
}) => {
|
|
671
666
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
@@ -698,6 +693,10 @@ var usePaginationPrefetch = ({
|
|
|
698
693
|
// src/persistence/use-persistence.ts
|
|
699
694
|
|
|
700
695
|
|
|
696
|
+
|
|
697
|
+
// src/persistence/create-persister.ts
|
|
698
|
+
|
|
699
|
+
|
|
701
700
|
// src/persistence/serializer.ts
|
|
702
701
|
function serialize(data) {
|
|
703
702
|
return JSON.stringify(data, (_key, value) => {
|
|
@@ -753,7 +752,7 @@ var noopPersister = {
|
|
|
753
752
|
};
|
|
754
753
|
function createPersister(config) {
|
|
755
754
|
if (typeof window === "undefined") return noopPersister;
|
|
756
|
-
const throttleMs = _nullishCoalesce(config.throttleMs, () => (
|
|
755
|
+
const throttleMs = _nullishCoalesce(config.throttleMs, () => ( _augurutils.toMillis.call(void 0, _augurutils.seconds.call(void 0, 1))));
|
|
757
756
|
const limits = _nullishCoalesce(config.limits, () => ( {}));
|
|
758
757
|
let timer;
|
|
759
758
|
let pending;
|
|
@@ -791,10 +790,11 @@ function createPersister(config) {
|
|
|
791
790
|
|
|
792
791
|
// src/persistence/use-storage-monitor.ts
|
|
793
792
|
|
|
794
|
-
|
|
793
|
+
|
|
794
|
+
var CHECK_INTERVAL = _augurutils.toMillis.call(void 0, _augurutils.minutes.call(void 0, 5));
|
|
795
795
|
function useStorageMonitor(config) {
|
|
796
796
|
const { key, limits = {}, maxStorageMB = 3 } = config;
|
|
797
|
-
const limitKeysRef =
|
|
797
|
+
const limitKeysRef = _chunkBWBJPKLVcjs.useLatest.call(void 0, Object.keys(limits));
|
|
798
798
|
const limitCount = limitKeysRef.current.length;
|
|
799
799
|
_react.useEffect.call(void 0, () => {
|
|
800
800
|
const limitKeys = limitKeysRef.current;
|
|
@@ -826,7 +826,7 @@ function useStorageMonitor(config) {
|
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
828
|
evict();
|
|
829
|
-
const id = setInterval(evict,
|
|
829
|
+
const id = setInterval(evict, CHECK_INTERVAL);
|
|
830
830
|
return () => clearInterval(id);
|
|
831
831
|
}, [key, maxStorageMB, limitCount, limitKeysRef]);
|
|
832
832
|
}
|
|
@@ -847,7 +847,7 @@ function useAugurPersistence(config) {
|
|
|
847
847
|
shouldDehydrateQuery: (query) => {
|
|
848
848
|
const key = query.queryKey;
|
|
849
849
|
const hasHead = Array.isArray(key) && key.length > 0;
|
|
850
|
-
return
|
|
850
|
+
return _chunkBWBJPKLVcjs.shouldPersistOf.call(void 0,
|
|
851
851
|
hasHead,
|
|
852
852
|
query.state.status === "success",
|
|
853
853
|
hasHead && persistableKeys.includes(key[0])
|
|
@@ -858,12 +858,37 @@ function useAugurPersistence(config) {
|
|
|
858
858
|
);
|
|
859
859
|
return {
|
|
860
860
|
persister,
|
|
861
|
-
maxAge: isMounted ? _nullishCoalesce(config.maxAge, () => (
|
|
861
|
+
maxAge: isMounted ? _nullishCoalesce(config.maxAge, () => ( _augurutils.toMillis.call(void 0, _augurutils.hours.call(void 0, 24)))) : 0,
|
|
862
862
|
buster: isDev ? String(Date.now()) : `${PERSISTED_DATA_FORMAT}:${_nullishCoalesce(config.buster, () => ( ""))}`,
|
|
863
863
|
dehydrateOptions
|
|
864
864
|
};
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
// src/user-write-clearing.ts
|
|
868
|
+
|
|
869
|
+
function keyPathOf(key) {
|
|
870
|
+
const segments = _nullishCoalesce(key, () => ( []));
|
|
871
|
+
const n = _chunkBWBJPKLVcjs.leadingTextsFrom.call(void 0,
|
|
872
|
+
segments.map((s) => typeof s === "string"),
|
|
873
|
+
0
|
|
874
|
+
);
|
|
875
|
+
return _chunkBWBJPKLVcjs.keyPathFrom.call(void 0, segments, n);
|
|
876
|
+
}
|
|
877
|
+
function clearUserReadsOnWrite(queryClient, mutationKey) {
|
|
878
|
+
const writePath = keyPathOf(mutationKey);
|
|
879
|
+
return queryClient.invalidateQueries({
|
|
880
|
+
predicate: (query) => _augurcore.clearedBy.call(void 0, writePath, keyPathOf(query.queryKey))
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
function userWriteClearing(getQueryClient) {
|
|
884
|
+
return {
|
|
885
|
+
onSuccess: (_data, _variables, _context, mutation) => clearUserReadsOnWrite(getQueryClient(), mutation.options.mutationKey)
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
867
892
|
|
|
868
893
|
|
|
869
894
|
|
|
@@ -900,5 +925,5 @@ function useAugurPersistence(config) {
|
|
|
900
925
|
|
|
901
926
|
|
|
902
927
|
|
|
903
|
-
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence =
|
|
928
|
+
exports.AugurHooksProvider = AugurHooksProvider; exports.clearCheckoutPersistence = _chunkBWBJPKLVcjs.clearCheckoutPersistence; exports.clearFromSession = _chunkBWBJPKLVcjs.clearFromSession; exports.clearUserReadsOnWrite = clearUserReadsOnWrite; exports.determineOrderReadiness = _chunkBWBJPKLVcjs.determineOrderReadiness; exports.executeBatchQuery = _chunk6Z6JGK2Ccjs.executeBatchQuery; exports.getRegisteredQueryAction = _chunk6Z6JGK2Ccjs.getRegisteredQueryAction; exports.keyPathOf = keyPathOf; exports.loadFromSession = _chunkBWBJPKLVcjs.loadFromSession; exports.registerQueryAction = _chunk6Z6JGK2Ccjs.registerQueryAction; exports.saveToSession = _chunkBWBJPKLVcjs.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 = _chunkBWBJPKLVcjs.useCartHdrUid; exports.useCartInitialization = useCartInitialization; exports.useCartLineCount = _chunkBWBJPKLVcjs.useCartLineCount; exports.useCartLines = _chunkBWBJPKLVcjs.useCartLines; exports.useCartPricing = useCartPricing; exports.useCartQuantityTotal = _chunkBWBJPKLVcjs.useCartQuantityTotal; exports.useCartStore = _chunkBWBJPKLVcjs.useCartStore; exports.useCheckoutPersistence = _chunkBWBJPKLVcjs.useCheckoutPersistence; exports.useClearCart = _chunkBWBJPKLVcjs.useClearCart; exports.useDebounce = useDebounce; exports.useFormatPrice = useFormatPrice; exports.useItemFiltersStore = useItemFiltersStore; exports.useModalLifecycle = useModalLifecycle; exports.useOrderReadiness = _chunkBWBJPKLVcjs.useOrderReadiness; exports.usePaginationPrefetch = usePaginationPrefetch; exports.usePaymentFlow = _chunkBWBJPKLVcjs.usePaymentFlow; exports.useSetCartHdrUid = _chunkBWBJPKLVcjs.useSetCartHdrUid; exports.useSetCartLines = _chunkBWBJPKLVcjs.useSetCartLines; exports.useStock = useStock; exports.userWriteClearing = userWriteClearing;
|
|
904
929
|
//# sourceMappingURL=index.cjs.map
|