@szymonpiatek/nextwordpress 0.0.17 → 0.0.18

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.
@@ -1,5 +1,5 @@
1
- export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.cjs';
1
+ export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.cjs';
2
2
  import 'react';
3
- import '../types-DVzJO3P-.cjs';
3
+ import '../types-CM3v08Fh.cjs';
4
4
  import 'swr/mutation';
5
5
  import 'swr';
@@ -1,5 +1,5 @@
1
- export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.js';
1
+ export { AuthContextValue, AuthProvider, AuthUser, CartAction, CartContextValue, CartItem, CartProvider, CheckoutOptions, CustomerContextValue, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats } from '../hooks/index.js';
2
2
  import 'react';
3
- import '../types-DVzJO3P-.js';
3
+ import '../types-CM3v08Fh.js';
4
4
  import 'swr/mutation';
5
5
  import 'swr';
@@ -359,44 +359,6 @@ function useResetUserPassword(config) {
359
359
  }
360
360
  );
361
361
  }
362
- function readConsentFromDocument(cookieName) {
363
- if (typeof document === "undefined") return null;
364
- const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
365
- if (!match) return null;
366
- if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
367
- try {
368
- const parsed = JSON.parse(decodeURIComponent(match[1]));
369
- if (typeof parsed !== "object" || parsed === null) return null;
370
- return parsed;
371
- } catch {
372
- return null;
373
- }
374
- }
375
- function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
376
- const [consent, setConsentState] = useState(null);
377
- const [isLoaded, setIsLoaded] = useState(false);
378
- useEffect(() => {
379
- setConsentState(readConsentFromDocument(cookieName));
380
- setIsLoaded(true);
381
- }, [cookieName]);
382
- const setConsent = useCallback(
383
- async (categories) => {
384
- const res = await fetch(consentPath, {
385
- method: "POST",
386
- headers: { "Content-Type": "application/json" },
387
- body: JSON.stringify(categories)
388
- });
389
- const data = await res.json();
390
- setConsentState(data);
391
- },
392
- [consentPath]
393
- );
394
- const clearConsent = useCallback(async () => {
395
- await fetch(consentPath, { method: "DELETE" });
396
- setConsentState(null);
397
- }, [consentPath]);
398
- return { consent, isLoaded, setConsent, clearConsent };
399
- }
400
362
 
401
363
  // src/integrations/restApi/core/client/types.ts
402
364
  var WordPressAPIError = class extends Error {
@@ -521,6 +483,88 @@ function createFetcher(config) {
521
483
  return { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful, wpMutate, wpUpload };
522
484
  }
523
485
 
486
+ // src/integrations/restApi/core/mutations/passwordReset/mutations.ts
487
+ function createPasswordResetMutations2(fetcher) {
488
+ const { wpMutate } = fetcher;
489
+ async function sendPasswordResetEmail(input) {
490
+ return wpMutate(
491
+ "/wp-json/wp/v2/users/lost-password",
492
+ input,
493
+ "POST"
494
+ );
495
+ }
496
+ async function resetUserPassword(input) {
497
+ return wpMutate(
498
+ "/wp-json/wp/v2/users/reset-password",
499
+ input,
500
+ "POST"
501
+ );
502
+ }
503
+ return { sendPasswordResetEmail, resetUserPassword };
504
+ }
505
+
506
+ // src/hooks/auth/useSendPasswordResetEmailRest.ts
507
+ function useSendPasswordResetEmailRest(config) {
508
+ return useSWRMutation(
509
+ `send-password-reset-rest:${config.serverURL}`,
510
+ async (_, { arg }) => {
511
+ return createPasswordResetMutations2(createFetcher(config)).sendPasswordResetEmail({
512
+ username: arg.username
513
+ });
514
+ }
515
+ );
516
+ }
517
+ function useResetUserPasswordRest(config) {
518
+ return useSWRMutation(
519
+ `reset-user-password-rest:${config.serverURL}`,
520
+ async (_, { arg }) => {
521
+ return createPasswordResetMutations2(createFetcher(config)).resetUserPassword({
522
+ key: arg.key,
523
+ login: arg.login,
524
+ password: arg.password
525
+ });
526
+ }
527
+ );
528
+ }
529
+ function readConsentFromDocument(cookieName) {
530
+ if (typeof document === "undefined") return null;
531
+ const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
532
+ if (!match) return null;
533
+ if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
534
+ try {
535
+ const parsed = JSON.parse(decodeURIComponent(match[1]));
536
+ if (typeof parsed !== "object" || parsed === null) return null;
537
+ return parsed;
538
+ } catch {
539
+ return null;
540
+ }
541
+ }
542
+ function useCookieConsent(consentPath = "/api/cookie-consent", cookieName = "cookie_notice_accepted") {
543
+ const [consent, setConsentState] = useState(null);
544
+ const [isLoaded, setIsLoaded] = useState(false);
545
+ useEffect(() => {
546
+ setConsentState(readConsentFromDocument(cookieName));
547
+ setIsLoaded(true);
548
+ }, [cookieName]);
549
+ const setConsent = useCallback(
550
+ async (categories) => {
551
+ const res = await fetch(consentPath, {
552
+ method: "POST",
553
+ headers: { "Content-Type": "application/json" },
554
+ body: JSON.stringify(categories)
555
+ });
556
+ const data = await res.json();
557
+ setConsentState(data);
558
+ },
559
+ [consentPath]
560
+ );
561
+ const clearConsent = useCallback(async () => {
562
+ await fetch(consentPath, { method: "DELETE" });
563
+ setConsentState(null);
564
+ }, [consentPath]);
565
+ return { consent, isLoaded, setConsent, clearConsent };
566
+ }
567
+
524
568
  // src/integrations/restApi/core/posts/queries.ts
525
569
  function createPostsQueries(fetcher) {
526
570
  const { wpFetch, wpFetchGraceful, wpFetchPaginated, wpFetchPaginatedGraceful } = fetcher;
@@ -1577,6 +1621,6 @@ function useCF7Submit(config) {
1577
1621
  );
1578
1622
  }
1579
1623
 
1580
- export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useSendPasswordResetEmail, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
1624
+ export { AuthProvider, CartProvider, WooCommerceCustomerProvider, cartReducer, useAuth, useCF7Submit, useCart, useCookieConsent, useCustomer, useFeaturedProducts, useGQLPostBySlug, useGQLPosts, usePost, usePostBySlug, usePosts, usePostsPaginated, useProduct, useProductBySlug, useProducts, useProductsPaginated, useResetUserPassword, useResetUserPasswordRest, useSendPasswordResetEmail, useSendPasswordResetEmailRest, useWPGraphQL, useWPULike, useWPULikeCheck, useWPULikeStats };
1581
1625
  //# sourceMappingURL=index.js.map
1582
1626
  //# sourceMappingURL=index.js.map