@marvalt/wadapter 2.3.20 → 2.3.22
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/client/wordpress-client.d.ts +33 -0
- package/dist/client/wordpress-client.d.ts.map +1 -1
- package/dist/generators/wordpress/wordpress-generator.d.ts +2 -1
- package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -1
- package/dist/generators.cjs +27 -0
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.esm.js +27 -0
- package/dist/generators.esm.js.map +1 -1
- package/dist/index.d.ts +120 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +146 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -1
- package/dist/static/wordpress-static.d.ts +35 -0
- package/dist/static/wordpress-static.d.ts.map +1 -1
- package/dist/utils/theme-styles.d.ts +50 -0
- package/dist/utils/theme-styles.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -265,6 +265,13 @@ class WordPressClient {
|
|
|
265
265
|
async getSettings() {
|
|
266
266
|
return this.makeRequest('/wp-custom/v1/settings');
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Fetch Theme Styles from custom endpoint
|
|
270
|
+
* @returns Theme customization settings (typography, colors, backgrounds, shadows, layout)
|
|
271
|
+
*/
|
|
272
|
+
async getThemeStyles() {
|
|
273
|
+
return this.makeRequest('/wp-custom/v1/theme-styles');
|
|
274
|
+
}
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
/**
|
|
@@ -757,6 +764,13 @@ function getFrontpageMetadata() {
|
|
|
757
764
|
function getSiteSettings() {
|
|
758
765
|
return wordpressStaticData?.site_settings;
|
|
759
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Get theme styles (typography, colors, backgrounds, shadows, layout) from static data
|
|
769
|
+
* This is set by the generator from WordPress Customizer settings
|
|
770
|
+
*/
|
|
771
|
+
function getThemeStyles() {
|
|
772
|
+
return wordpressStaticData?.theme_styles;
|
|
773
|
+
}
|
|
760
774
|
|
|
761
775
|
/**
|
|
762
776
|
* @license GPL-3.0-or-later
|
|
@@ -2731,6 +2745,138 @@ function validateFormData(formData, rules) {
|
|
|
2731
2745
|
return { isValid, errors };
|
|
2732
2746
|
}
|
|
2733
2747
|
|
|
2748
|
+
/**
|
|
2749
|
+
* @license GPL-3.0-or-later
|
|
2750
|
+
*
|
|
2751
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2752
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2753
|
+
*
|
|
2754
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2755
|
+
* it under the terms of the GNU General Public License as published by
|
|
2756
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2757
|
+
* (at your option) any later version.
|
|
2758
|
+
*
|
|
2759
|
+
* This program is distributed in the hope that it will be useful,
|
|
2760
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2761
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2762
|
+
* See the GNU General Public License for more details.
|
|
2763
|
+
*/
|
|
2764
|
+
/**
|
|
2765
|
+
* List of popular Google Fonts (for detection and validation)
|
|
2766
|
+
*/
|
|
2767
|
+
const GOOGLE_FONTS = [
|
|
2768
|
+
'Montserrat',
|
|
2769
|
+
'Open Sans',
|
|
2770
|
+
'Roboto',
|
|
2771
|
+
'Lato',
|
|
2772
|
+
'Poppins',
|
|
2773
|
+
'Source Sans Pro',
|
|
2774
|
+
'Raleway',
|
|
2775
|
+
'Oswald',
|
|
2776
|
+
'Playfair Display',
|
|
2777
|
+
'Merriweather',
|
|
2778
|
+
'Ubuntu',
|
|
2779
|
+
'Nunito',
|
|
2780
|
+
'Inter',
|
|
2781
|
+
'Work Sans',
|
|
2782
|
+
'Crimson Text',
|
|
2783
|
+
'Libre Baskerville',
|
|
2784
|
+
'PT Sans',
|
|
2785
|
+
'PT Serif',
|
|
2786
|
+
'Dancing Script',
|
|
2787
|
+
'Bebas Neue',
|
|
2788
|
+
'Fira Sans',
|
|
2789
|
+
'Noto Sans',
|
|
2790
|
+
'Noto Serif',
|
|
2791
|
+
'Rubik',
|
|
2792
|
+
'Mukta',
|
|
2793
|
+
'Cabin',
|
|
2794
|
+
'Dosis',
|
|
2795
|
+
'Arimo',
|
|
2796
|
+
'Titillium Web',
|
|
2797
|
+
];
|
|
2798
|
+
/**
|
|
2799
|
+
* Sanitize font name - removes "family" prefix and cleans the name
|
|
2800
|
+
*
|
|
2801
|
+
* @param fontName - Font name to sanitize
|
|
2802
|
+
* @returns Sanitized font name
|
|
2803
|
+
*/
|
|
2804
|
+
function sanitizeFontName(fontName) {
|
|
2805
|
+
if (!fontName)
|
|
2806
|
+
return '';
|
|
2807
|
+
// Remove "family" prefix if present (case insensitive)
|
|
2808
|
+
let cleaned = fontName.replace(/^family\s*/i, '').trim();
|
|
2809
|
+
return cleaned;
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* Format font-family CSS value with quotes and fallback
|
|
2813
|
+
*
|
|
2814
|
+
* @param fontName - Font name to format
|
|
2815
|
+
* @param fallback - Fallback font (default: 'sans-serif')
|
|
2816
|
+
* @returns Formatted font-family CSS value
|
|
2817
|
+
*/
|
|
2818
|
+
function formatFontFamily(fontName, fallback = 'sans-serif') {
|
|
2819
|
+
if (!fontName)
|
|
2820
|
+
return fallback;
|
|
2821
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2822
|
+
if (!cleaned)
|
|
2823
|
+
return fallback;
|
|
2824
|
+
// If font name contains spaces, wrap in quotes
|
|
2825
|
+
const quotedFont = cleaned.includes(' ') ? `"${cleaned}"` : cleaned;
|
|
2826
|
+
return `${quotedFont}, ${fallback}`;
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Load Google Font dynamically via link tag
|
|
2830
|
+
*
|
|
2831
|
+
* @param fontName - Google Font name to load
|
|
2832
|
+
* @param weights - Font weights to load (default: 400, 500, 600, 700)
|
|
2833
|
+
*/
|
|
2834
|
+
function loadGoogleFont(fontName, weights = [400, 500, 600, 700]) {
|
|
2835
|
+
if (typeof document === 'undefined') {
|
|
2836
|
+
// Server-side rendering - skip
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (!fontName)
|
|
2840
|
+
return;
|
|
2841
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2842
|
+
if (!cleaned)
|
|
2843
|
+
return;
|
|
2844
|
+
// Check if it's a Google Font
|
|
2845
|
+
const isGoogleFont = GOOGLE_FONTS.some(font => font.toLowerCase() === cleaned.toLowerCase());
|
|
2846
|
+
if (!isGoogleFont) {
|
|
2847
|
+
// Not a Google Font, assume it's a system font or custom font
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
// Check if font is already loaded
|
|
2851
|
+
const fontId = `wp-google-font-${cleaned.toLowerCase().replace(/\s+/g, '-')}`;
|
|
2852
|
+
if (document.getElementById(fontId)) {
|
|
2853
|
+
return; // Already loaded
|
|
2854
|
+
}
|
|
2855
|
+
// Create link element for Google Fonts
|
|
2856
|
+
const link = document.createElement('link');
|
|
2857
|
+
link.id = fontId;
|
|
2858
|
+
link.rel = 'stylesheet';
|
|
2859
|
+
// Build Google Fonts URL with weights
|
|
2860
|
+
const weightsParam = weights.join(';');
|
|
2861
|
+
link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(cleaned)}:wght@${weightsParam}&display=swap`;
|
|
2862
|
+
document.head.appendChild(link);
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Check if a font name is a Google Font
|
|
2866
|
+
*
|
|
2867
|
+
* @param fontName - Font name to check
|
|
2868
|
+
* @returns True if the font is a Google Font
|
|
2869
|
+
*/
|
|
2870
|
+
function isGoogleFont(fontName) {
|
|
2871
|
+
if (!fontName)
|
|
2872
|
+
return false;
|
|
2873
|
+
const cleaned = sanitizeFontName(fontName);
|
|
2874
|
+
if (!cleaned)
|
|
2875
|
+
return false;
|
|
2876
|
+
return GOOGLE_FONTS.some(font => font.toLowerCase() === cleaned.toLowerCase());
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
exports.GOOGLE_FONTS = GOOGLE_FONTS;
|
|
2734
2880
|
exports.GravityForm = GravityForm;
|
|
2735
2881
|
exports.GravityFormsClient = GravityFormsClient;
|
|
2736
2882
|
exports.GravityFormsProvider = GravityFormsProvider;
|
|
@@ -2744,6 +2890,7 @@ exports.createGravityFormsConfig = createGravityFormsConfig;
|
|
|
2744
2890
|
exports.createWordPressConfig = createWordPressConfig;
|
|
2745
2891
|
exports.findPageById = findPageById;
|
|
2746
2892
|
exports.findPageBySlug = findPageBySlug;
|
|
2893
|
+
exports.formatFontFamily = formatFontFamily;
|
|
2747
2894
|
exports.getActiveForms = getActiveForms;
|
|
2748
2895
|
exports.getChildPages = getChildPages;
|
|
2749
2896
|
exports.getFormById = getFormById;
|
|
@@ -2753,6 +2900,7 @@ exports.getFrontpageSlug = getFrontpageSlug;
|
|
|
2753
2900
|
exports.getPublishedForms = getPublishedForms;
|
|
2754
2901
|
exports.getRootPages = getRootPages;
|
|
2755
2902
|
exports.getSiteSettings = getSiteSettings;
|
|
2903
|
+
exports.getThemeStyles = getThemeStyles;
|
|
2756
2904
|
exports.getWordPressCategories = getWordPressCategories;
|
|
2757
2905
|
exports.getWordPressMedia = getWordPressMedia;
|
|
2758
2906
|
exports.getWordPressPages = getWordPressPages;
|
|
@@ -2760,8 +2908,11 @@ exports.getWordPressPosts = getWordPressPosts;
|
|
|
2760
2908
|
exports.getWordPressTags = getWordPressTags;
|
|
2761
2909
|
exports.hasGravityFormsStatic = hasGravityFormsStatic;
|
|
2762
2910
|
exports.hasWordPressStatic = hasWordPressStatic;
|
|
2911
|
+
exports.isGoogleFont = isGoogleFont;
|
|
2912
|
+
exports.loadGoogleFont = loadGoogleFont;
|
|
2763
2913
|
exports.loadGravityFormsData = loadGravityFormsData;
|
|
2764
2914
|
exports.loadWordPressData = loadWordPressData;
|
|
2915
|
+
exports.sanitizeFontName = sanitizeFontName;
|
|
2765
2916
|
exports.sanitizeHtml = sanitizeHtml;
|
|
2766
2917
|
exports.transformWordPressMedia = transformWordPressMedia;
|
|
2767
2918
|
exports.transformWordPressMediaItems = transformWordPressMediaItems;
|