@marvalt/wadapter 2.3.19 → 2.3.20

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/dist/index.d.ts CHANGED
@@ -441,8 +441,8 @@ declare class WordPressClient {
441
441
  blocks_count?: number;
442
442
  }>;
443
443
  /**
444
- * Fetch WordPress Reading Settings from custom endpoint
445
- * @returns Settings including front page information
444
+ * Fetch WordPress Settings from custom endpoint
445
+ * @returns Settings including front page information and site branding
446
446
  */
447
447
  getSettings(): Promise<{
448
448
  show_on_front: string;
@@ -453,6 +453,18 @@ declare class WordPressClient {
453
453
  slug: string;
454
454
  title: string;
455
455
  };
456
+ logo?: {
457
+ id: number;
458
+ url: string;
459
+ cloudflare_url?: string;
460
+ };
461
+ site_icon?: {
462
+ id: number;
463
+ url: string;
464
+ cloudflare_url?: string;
465
+ };
466
+ site_name?: string;
467
+ site_description?: string;
456
468
  }>;
457
469
  }
458
470
 
@@ -734,6 +746,39 @@ declare function useGravityFormsConfig(formId: number, config?: GravityFormsConf
734
746
  refetch: () => Promise<void>;
735
747
  };
736
748
 
749
+ /**
750
+ * @license GPL-3.0-or-later
751
+ *
752
+ * This file is part of the MarVAlt Open SDK.
753
+ * Copyright (c) 2025 Vibune Pty Ltd.
754
+ *
755
+ * This program is free software: you can redistribute it and/or modify
756
+ * it under the terms of the GNU General Public License as published by
757
+ * the Free Software Foundation, either version 3 of the License, or
758
+ * (at your option) any later version.
759
+ *
760
+ * This program is distributed in the hope that it will be useful,
761
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
762
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
763
+ * See the GNU General Public License for more details.
764
+ */
765
+ /**
766
+ * Hook to get the frontpage slug using standardized approach
767
+ *
768
+ * Priority:
769
+ * 1. front_page metadata from generator (WordPress Reading Settings or slug 'frontpage')
770
+ * 2. Fallback to getFrontpage() utility (slug check: 'frontpage', 'home', '')
771
+ *
772
+ * @param overrideSlug - Optional override slug (if provided, this takes precedence)
773
+ * @param dataPath - Path to WordPress static data JSON file (default: '/wordpress-data.json')
774
+ * @returns Object with slug, loading state, and error
775
+ */
776
+ declare function useFrontpageSlug(overrideSlug?: string, dataPath?: string): {
777
+ slug: string | undefined;
778
+ loading: boolean;
779
+ error: Error | null;
780
+ };
781
+
737
782
  /**
738
783
  * @license GPL-3.0-or-later
739
784
  *
@@ -857,8 +902,29 @@ declare function useGravityFormsContext(): GravityFormsContextType;
857
902
  * See the GNU General Public License for more details.
858
903
  */
859
904
 
905
+ interface FrontPageMetadata {
906
+ id: number;
907
+ slug: string;
908
+ title: string;
909
+ }
910
+ interface SiteSettings {
911
+ logo?: {
912
+ id: number;
913
+ url: string;
914
+ cloudflare_url?: string;
915
+ };
916
+ site_icon?: {
917
+ id: number;
918
+ url: string;
919
+ cloudflare_url?: string;
920
+ };
921
+ site_name?: string;
922
+ site_description?: string;
923
+ }
860
924
  interface WordPressStaticData {
861
925
  generatedAt?: string;
926
+ front_page?: FrontPageMetadata;
927
+ site_settings?: SiteSettings;
862
928
  posts: WordPressPost[];
863
929
  pages: WordPressPage[];
864
930
  media: WordPressMedia[];
@@ -872,6 +938,16 @@ declare function getWordPressPages(): WordPressPage[];
872
938
  declare function getWordPressMedia(): WordPressMedia[];
873
939
  declare function getWordPressCategories(): WordPressCategory[];
874
940
  declare function getWordPressTags(): WordPressTag[];
941
+ /**
942
+ * Get frontpage metadata from static data
943
+ * This is set by the generator based on WordPress Reading Settings or slug 'frontpage'
944
+ */
945
+ declare function getFrontpageMetadata(): FrontPageMetadata | undefined;
946
+ /**
947
+ * Get site settings (logo, site icon, site name, description) from static data
948
+ * This is set by the generator from WordPress theme mods and options
949
+ */
950
+ declare function getSiteSettings(): SiteSettings | undefined;
875
951
 
876
952
  /**
877
953
  * @license GPL-3.0-or-later
@@ -1000,5 +1076,89 @@ declare function validateFormData(formData: Record<string, any>, rules: Record<s
1000
1076
  errors: Record<string, string[]>;
1001
1077
  };
1002
1078
 
1003
- export { GravityForm, GravityFormsClient, GravityFormsProvider, WordPressClient, WordPressContent, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, getActiveForms, getFormById, getPublishedForms, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
1004
- export type { EmailVerificationData, FormProtectionConfig, FormProtectionResult, FormProtectionValidation, GravityFormConfirmation, GravityFormField, GravityFormNotification, GravityFormSubmission, GravityFormSubmissionResult, GravityFormsConfig, GravityFormsStaticData, TransformedWordPressMedia, TransformedWordPressPage, TransformedWordPressPost, UseGravityFormsResult, UseWordPressResult, WordPressAuthor, WordPressCategory, WordPressConfig, WordPressMedia, WordPressPage, WordPressPost, WordPressQueryParams, WordPressStaticData, WordPressTag };
1079
+ /**
1080
+ * @license GPL-3.0-or-later
1081
+ *
1082
+ * This file is part of the MarVAlt Open SDK.
1083
+ * Copyright (c) 2025 Vibune Pty Ltd.
1084
+ *
1085
+ * This program is free software: you can redistribute it and/or modify
1086
+ * it under the terms of the GNU General Public License as published by
1087
+ * the Free Software Foundation, either version 3 of the License, or
1088
+ * (at your option) any later version.
1089
+ *
1090
+ * This program is distributed in the hope that it will be useful,
1091
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1092
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1093
+ * See the GNU General Public License for more details.
1094
+ */
1095
+
1096
+ /**
1097
+ * Menu item structure for navigation menus
1098
+ */
1099
+ interface MenuItem {
1100
+ id: number;
1101
+ title: string;
1102
+ slug: string;
1103
+ url: string;
1104
+ children?: MenuItem[];
1105
+ menuOrder: number;
1106
+ }
1107
+ /**
1108
+ * Get root pages (pages with parent = 0)
1109
+ * Sorted by menu_order
1110
+ */
1111
+ declare function getRootPages(pages: WordPressPage[]): WordPressPage[];
1112
+ /**
1113
+ * Get child pages of a specific parent
1114
+ * Sorted by menu_order
1115
+ */
1116
+ declare function getChildPages(pages: WordPressPage[], parentId: number): WordPressPage[];
1117
+ /**
1118
+ * Build hierarchical page structure
1119
+ * Returns pages with nested children arrays
1120
+ */
1121
+ interface HierarchicalPage extends WordPressPage {
1122
+ children?: HierarchicalPage[];
1123
+ }
1124
+ declare function buildPageHierarchy(pages: WordPressPage[]): HierarchicalPage[];
1125
+ /**
1126
+ * Build menu structure from WordPress pages
1127
+ * Converts WordPress pages to a generic menu structure
1128
+ *
1129
+ * @param pages - Array of WordPress pages
1130
+ * @param baseUrl - Base URL for building page URLs (default: '/')
1131
+ * @param filterPublished - Only include published pages (default: true)
1132
+ * @returns Array of menu items with nested children
1133
+ */
1134
+ declare function buildMenuStructure(pages: WordPressPage[], baseUrl?: string, filterPublished?: boolean): MenuItem[];
1135
+ /**
1136
+ * Find a page by slug
1137
+ */
1138
+ declare function findPageBySlug(pages: WordPressPage[], slug: string): WordPressPage | undefined;
1139
+ /**
1140
+ * Find a page by ID
1141
+ */
1142
+ declare function findPageById(pages: WordPressPage[], id: number): WordPressPage | undefined;
1143
+ /**
1144
+ * Get frontpage (page with slug 'frontpage' or 'home')
1145
+ * Useful for determining homepage content
1146
+ */
1147
+ declare function getFrontpage(pages: WordPressPage[]): WordPressPage | undefined;
1148
+ /**
1149
+ * Get frontpage slug using standardized approach
1150
+ *
1151
+ * Priority:
1152
+ * 1. front_page metadata from generator (WordPress Reading Settings or slug 'frontpage')
1153
+ * 2. Fallback to getFrontpage() utility (slug check: 'frontpage', 'home', '')
1154
+ *
1155
+ * @param pages - Array of WordPress pages (optional, used for fallback)
1156
+ * @param frontPageMetadata - Frontpage metadata from static data (optional)
1157
+ * @returns Frontpage slug string, or undefined if not found
1158
+ */
1159
+ declare function getFrontpageSlug(pages?: WordPressPage[], frontPageMetadata?: {
1160
+ slug: string;
1161
+ } | undefined): string | undefined;
1162
+
1163
+ export { GravityForm, GravityFormsClient, GravityFormsProvider, WordPressClient, WordPressContent, WordPressProvider, buildMenuStructure, buildPageHierarchy, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, findPageById, findPageBySlug, getActiveForms, getChildPages, getFormById, getFrontpage, getFrontpageMetadata, getFrontpageSlug, getPublishedForms, getRootPages, getSiteSettings, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useFrontpageSlug, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
1164
+ export type { EmailVerificationData, FormProtectionConfig, FormProtectionResult, FormProtectionValidation, FrontPageMetadata, GravityFormConfirmation, GravityFormField, GravityFormNotification, GravityFormSubmission, GravityFormSubmissionResult, GravityFormsConfig, GravityFormsStaticData, HierarchicalPage, MenuItem, SiteSettings, TransformedWordPressMedia, TransformedWordPressPage, TransformedWordPressPost, UseGravityFormsResult, UseWordPressResult, WordPressAuthor, WordPressCategory, WordPressConfig, WordPressMedia, WordPressPage, WordPressPost, WordPressQueryParams, WordPressStaticData, WordPressTag };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,sCAAsC,CAAC;AAGrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAM9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,sCAAsC,CAAC;AAGrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAM9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -256,8 +256,8 @@ class WordPressClient {
256
256
  return this.makeRequest(`/wp-custom/v1/pages/${pageId}/blocks`);
257
257
  }
258
258
  /**
259
- * Fetch WordPress Reading Settings from custom endpoint
260
- * @returns Settings including front page information
259
+ * Fetch WordPress Settings from custom endpoint
260
+ * @returns Settings including front page information and site branding
261
261
  */
262
262
  async getSettings() {
263
263
  return this.makeRequest('/wp-custom/v1/settings');
@@ -693,6 +693,287 @@ function useGravityFormsConfig(formId, config) {
693
693
  };
694
694
  }
695
695
 
696
+ /**
697
+ * @license GPL-3.0-or-later
698
+ *
699
+ * This file is part of the MarVAlt Open SDK.
700
+ * Copyright (c) 2025 Vibune Pty Ltd.
701
+ *
702
+ * This program is free software: you can redistribute it and/or modify
703
+ * it under the terms of the GNU General Public License as published by
704
+ * the Free Software Foundation, either version 3 of the License, or
705
+ * (at your option) any later version.
706
+ *
707
+ * This program is distributed in the hope that it will be useful,
708
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
709
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
710
+ * See the GNU General Public License for more details.
711
+ */
712
+ let wordpressStaticData = null;
713
+ async function loadWordPressData(path = '/wordpress-data.json') {
714
+ try {
715
+ const res = await fetch(path);
716
+ if (!res.ok)
717
+ return null;
718
+ wordpressStaticData = (await res.json());
719
+ return wordpressStaticData;
720
+ }
721
+ catch {
722
+ return null;
723
+ }
724
+ }
725
+ function hasWordPressStatic() {
726
+ return !!wordpressStaticData && Array.isArray(wordpressStaticData.posts);
727
+ }
728
+ function getWordPressPosts() {
729
+ return wordpressStaticData?.posts ?? [];
730
+ }
731
+ function getWordPressPages() {
732
+ return wordpressStaticData?.pages ?? [];
733
+ }
734
+ function getWordPressMedia() {
735
+ return wordpressStaticData?.media ?? [];
736
+ }
737
+ function getWordPressCategories() {
738
+ return wordpressStaticData?.categories ?? [];
739
+ }
740
+ function getWordPressTags() {
741
+ return wordpressStaticData?.tags ?? [];
742
+ }
743
+ /**
744
+ * Get frontpage metadata from static data
745
+ * This is set by the generator based on WordPress Reading Settings or slug 'frontpage'
746
+ */
747
+ function getFrontpageMetadata() {
748
+ return wordpressStaticData?.front_page;
749
+ }
750
+ /**
751
+ * Get site settings (logo, site icon, site name, description) from static data
752
+ * This is set by the generator from WordPress theme mods and options
753
+ */
754
+ function getSiteSettings() {
755
+ return wordpressStaticData?.site_settings;
756
+ }
757
+
758
+ /**
759
+ * @license GPL-3.0-or-later
760
+ *
761
+ * This file is part of the MarVAlt Open SDK.
762
+ * Copyright (c) 2025 Vibune Pty Ltd.
763
+ *
764
+ * This program is free software: you can redistribute it and/or modify
765
+ * it under the terms of the GNU General Public License as published by
766
+ * the Free Software Foundation, either version 3 of the License, or
767
+ * (at your option) any later version.
768
+ *
769
+ * This program is distributed in the hope that it will be useful,
770
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
771
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
772
+ * See the GNU General Public License for more details.
773
+ */
774
+ /**
775
+ * Get root pages (pages with parent = 0)
776
+ * Sorted by menu_order
777
+ */
778
+ function getRootPages(pages) {
779
+ return pages
780
+ .filter(page => page.parent === 0)
781
+ .sort((a, b) => a.menu_order - b.menu_order);
782
+ }
783
+ /**
784
+ * Get child pages of a specific parent
785
+ * Sorted by menu_order
786
+ */
787
+ function getChildPages(pages, parentId) {
788
+ return pages
789
+ .filter(page => page.parent === parentId)
790
+ .sort((a, b) => a.menu_order - b.menu_order);
791
+ }
792
+ function buildPageHierarchy(pages) {
793
+ const pageMap = new Map();
794
+ const rootPages = [];
795
+ // Create map of all pages with children array
796
+ pages.forEach(page => {
797
+ pageMap.set(page.id, { ...page, children: [] });
798
+ });
799
+ // Build hierarchy
800
+ pages.forEach(page => {
801
+ const hierarchicalPage = pageMap.get(page.id);
802
+ if (page.parent === 0) {
803
+ rootPages.push(hierarchicalPage);
804
+ }
805
+ else {
806
+ const parent = pageMap.get(page.parent);
807
+ if (parent) {
808
+ if (!parent.children) {
809
+ parent.children = [];
810
+ }
811
+ parent.children.push(hierarchicalPage);
812
+ }
813
+ }
814
+ });
815
+ // Sort root pages and recursively sort children
816
+ const sortByMenuOrder = (pages) => {
817
+ return pages
818
+ .sort((a, b) => a.menu_order - b.menu_order)
819
+ .map(page => ({
820
+ ...page,
821
+ children: page.children ? sortByMenuOrder(page.children) : undefined,
822
+ }));
823
+ };
824
+ return sortByMenuOrder(rootPages);
825
+ }
826
+ /**
827
+ * Build menu structure from WordPress pages
828
+ * Converts WordPress pages to a generic menu structure
829
+ *
830
+ * @param pages - Array of WordPress pages
831
+ * @param baseUrl - Base URL for building page URLs (default: '/')
832
+ * @param filterPublished - Only include published pages (default: true)
833
+ * @returns Array of menu items with nested children
834
+ */
835
+ function buildMenuStructure(pages, baseUrl = '/', filterPublished = true) {
836
+ // Filter published pages if requested
837
+ const filteredPages = filterPublished
838
+ ? pages.filter(page => page.status === 'publish')
839
+ : pages;
840
+ // Build hierarchy
841
+ const hierarchicalPages = buildPageHierarchy(filteredPages);
842
+ // Convert to menu items
843
+ const convertToMenuItem = (page) => {
844
+ const url = baseUrl === '/'
845
+ ? `/${page.slug}`
846
+ : `${baseUrl.replace(/\/$/, '')}/${page.slug}`;
847
+ const menuItem = {
848
+ id: page.id,
849
+ title: page.title?.rendered || page.slug,
850
+ slug: page.slug,
851
+ url,
852
+ menuOrder: page.menu_order,
853
+ };
854
+ // Add children if they exist
855
+ if (page.children && page.children.length > 0) {
856
+ menuItem.children = page.children.map(convertToMenuItem);
857
+ }
858
+ return menuItem;
859
+ };
860
+ return hierarchicalPages.map(convertToMenuItem);
861
+ }
862
+ /**
863
+ * Find a page by slug
864
+ */
865
+ function findPageBySlug(pages, slug) {
866
+ return pages.find(page => page.slug === slug);
867
+ }
868
+ /**
869
+ * Find a page by ID
870
+ */
871
+ function findPageById(pages, id) {
872
+ return pages.find(page => page.id === id);
873
+ }
874
+ /**
875
+ * Get frontpage (page with slug 'frontpage' or 'home')
876
+ * Useful for determining homepage content
877
+ */
878
+ function getFrontpage(pages) {
879
+ return pages.find(page => page.slug === 'frontpage' ||
880
+ page.slug === 'home' ||
881
+ page.slug === '');
882
+ }
883
+ /**
884
+ * Get frontpage slug using standardized approach
885
+ *
886
+ * Priority:
887
+ * 1. front_page metadata from generator (WordPress Reading Settings or slug 'frontpage')
888
+ * 2. Fallback to getFrontpage() utility (slug check: 'frontpage', 'home', '')
889
+ *
890
+ * @param pages - Array of WordPress pages (optional, used for fallback)
891
+ * @param frontPageMetadata - Frontpage metadata from static data (optional)
892
+ * @returns Frontpage slug string, or undefined if not found
893
+ */
894
+ function getFrontpageSlug(pages, frontPageMetadata) {
895
+ // First priority: Use metadata from generator (WordPress Reading Settings or slug 'frontpage')
896
+ if (frontPageMetadata?.slug) {
897
+ return frontPageMetadata.slug;
898
+ }
899
+ // Fallback: Check pages for slug 'frontpage', 'home', or ''
900
+ if (pages) {
901
+ const frontpage = getFrontpage(pages);
902
+ return frontpage?.slug;
903
+ }
904
+ return undefined;
905
+ }
906
+
907
+ /**
908
+ * @license GPL-3.0-or-later
909
+ *
910
+ * This file is part of the MarVAlt Open SDK.
911
+ * Copyright (c) 2025 Vibune Pty Ltd.
912
+ *
913
+ * This program is free software: you can redistribute it and/or modify
914
+ * it under the terms of the GNU General Public License as published by
915
+ * the Free Software Foundation, either version 3 of the License, or
916
+ * (at your option) any later version.
917
+ *
918
+ * This program is distributed in the hope that it will be useful,
919
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
920
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
921
+ * See the GNU General Public License for more details.
922
+ */
923
+ // React Hook for Frontpage Slug
924
+ // Standardized approach for determining frontpage slug from WordPress static data
925
+ /**
926
+ * Hook to get the frontpage slug using standardized approach
927
+ *
928
+ * Priority:
929
+ * 1. front_page metadata from generator (WordPress Reading Settings or slug 'frontpage')
930
+ * 2. Fallback to getFrontpage() utility (slug check: 'frontpage', 'home', '')
931
+ *
932
+ * @param overrideSlug - Optional override slug (if provided, this takes precedence)
933
+ * @param dataPath - Path to WordPress static data JSON file (default: '/wordpress-data.json')
934
+ * @returns Object with slug, loading state, and error
935
+ */
936
+ function useFrontpageSlug(overrideSlug, dataPath = '/wordpress-data.json') {
937
+ const [slug, setSlug] = useState(overrideSlug);
938
+ const [loading, setLoading] = useState(true);
939
+ const [error, setError] = useState(null);
940
+ useEffect(() => {
941
+ // If override slug is provided, use it immediately
942
+ if (overrideSlug) {
943
+ setSlug(overrideSlug);
944
+ setLoading(false);
945
+ return;
946
+ }
947
+ const fetchFrontpageSlug = async () => {
948
+ try {
949
+ setLoading(true);
950
+ setError(null);
951
+ // Load WordPress static data
952
+ await loadWordPressData(dataPath);
953
+ // Get frontpage metadata and pages
954
+ const frontPageMetadata = getFrontpageMetadata();
955
+ const pages = getWordPressPages();
956
+ // Use standardized utility to get frontpage slug
957
+ const frontpageSlug = getFrontpageSlug(pages, frontPageMetadata);
958
+ setSlug(frontpageSlug);
959
+ }
960
+ catch (err) {
961
+ setError(err instanceof Error ? err : new Error('Failed to load frontpage slug'));
962
+ setSlug(undefined);
963
+ }
964
+ finally {
965
+ setLoading(false);
966
+ }
967
+ };
968
+ fetchFrontpageSlug();
969
+ }, [overrideSlug, dataPath]);
970
+ return {
971
+ slug,
972
+ loading,
973
+ error,
974
+ };
975
+ }
976
+
696
977
  var jsxRuntime = {exports: {}};
697
978
 
698
979
  var reactJsxRuntime_production_min = {};
@@ -2226,54 +2507,6 @@ function useGravityFormsContext() {
2226
2507
  return context;
2227
2508
  }
2228
2509
 
2229
- /**
2230
- * @license GPL-3.0-or-later
2231
- *
2232
- * This file is part of the MarVAlt Open SDK.
2233
- * Copyright (c) 2025 Vibune Pty Ltd.
2234
- *
2235
- * This program is free software: you can redistribute it and/or modify
2236
- * it under the terms of the GNU General Public License as published by
2237
- * the Free Software Foundation, either version 3 of the License, or
2238
- * (at your option) any later version.
2239
- *
2240
- * This program is distributed in the hope that it will be useful,
2241
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2242
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2243
- * See the GNU General Public License for more details.
2244
- */
2245
- let wordpressStaticData = null;
2246
- async function loadWordPressData(path = '/wordpress-data.json') {
2247
- try {
2248
- const res = await fetch(path);
2249
- if (!res.ok)
2250
- return null;
2251
- wordpressStaticData = (await res.json());
2252
- return wordpressStaticData;
2253
- }
2254
- catch {
2255
- return null;
2256
- }
2257
- }
2258
- function hasWordPressStatic() {
2259
- return !!wordpressStaticData && Array.isArray(wordpressStaticData.posts);
2260
- }
2261
- function getWordPressPosts() {
2262
- return wordpressStaticData?.posts ?? [];
2263
- }
2264
- function getWordPressPages() {
2265
- return wordpressStaticData?.pages ?? [];
2266
- }
2267
- function getWordPressMedia() {
2268
- return wordpressStaticData?.media ?? [];
2269
- }
2270
- function getWordPressCategories() {
2271
- return wordpressStaticData?.categories ?? [];
2272
- }
2273
- function getWordPressTags() {
2274
- return wordpressStaticData?.tags ?? [];
2275
- }
2276
-
2277
2510
  /**
2278
2511
  * @license GPL-3.0-or-later
2279
2512
  *
@@ -2495,5 +2728,5 @@ function validateFormData(formData, rules) {
2495
2728
  return { isValid, errors };
2496
2729
  }
2497
2730
 
2498
- export { GravityForm, GravityFormsClient, GravityFormsProvider, WordPressClient, WordPressContent, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, getActiveForms, getFormById, getPublishedForms, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
2731
+ export { GravityForm, GravityFormsClient, GravityFormsProvider, WordPressClient, WordPressContent, WordPressProvider, buildMenuStructure, buildPageHierarchy, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, findPageById, findPageBySlug, getActiveForms, getChildPages, getFormById, getFrontpage, getFrontpageMetadata, getFrontpageSlug, getPublishedForms, getRootPages, getSiteSettings, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useFrontpageSlug, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
2499
2732
  //# sourceMappingURL=index.esm.js.map