funuicss 3.7.0 → 3.7.2
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/css/fun.css +552 -71
- package/index.d.ts +1 -1
- package/index.js +6 -1
- package/package.json +1 -1
- package/ui/calendar/Calendar.js +1 -1
- package/ui/chart/Bar.d.ts +98 -12
- package/ui/chart/Bar.js +387 -40
- package/ui/chart/Line.js +246 -149
- package/ui/chart/Pie.d.ts +61 -7
- package/ui/chart/Pie.js +314 -38
- package/ui/drop/Dropdown.d.ts +4 -3
- package/ui/drop/Dropdown.js +24 -29
- package/ui/input/Input.js +46 -21
- package/ui/richtext/RichText.js +1 -1
- package/ui/specials/Circle.d.ts +2 -1
- package/ui/specials/Circle.js +2 -5
- package/ui/table/Table.d.ts +2 -1
- package/ui/table/Table.js +66 -63
- package/ui/text/Text.d.ts +1 -1
- package/ui/text/Text.js +50 -49
- package/ui/theme/theme.d.ts +34 -0
- package/ui/theme/theme.js +198 -18
- package/ui/vista/Vista.js +135 -49
- package/utils/componentUtils.js +27 -4
package/ui/text/Text.js
CHANGED
|
@@ -30,52 +30,53 @@ var react_1 = __importDefault(require("react"));
|
|
|
30
30
|
var pi_1 = require("react-icons/pi");
|
|
31
31
|
var componentUtils_1 = require("../../utils/componentUtils");
|
|
32
32
|
var Text = function (_a) {
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
? mergeWithLocal(localProps)
|
|
43
|
-
: { props: localProps }).props;
|
|
44
|
-
// Extract final values - local props take precedence, handle empty strings properly
|
|
33
|
+
var _b;
|
|
34
|
+
var id = _a.id, bg = _a.bg, color = _a.color, children = _a.children, hoverBg = _a.hoverBg, hoverText = _a.hoverText, text = _a.text, funcss = _a.funcss, emp = _a.emp, bold = _a.bold, block = _a.block, body = _a.body, article = _a.article, light = _a.light, lighter = _a.lighter, italic = _a.italic, weight = _a.weight, underline = _a.underline, align = _a.align, lineHeight = _a.lineHeight, letterSpacing = _a.letterSpacing, uppercase = _a.uppercase, lowercase = _a.lowercase, capitalize = _a.capitalize, textDecoration = _a.textDecoration, textTransform = _a.textTransform, whiteSpace = _a.whiteSpace, wordBreak = _a.wordBreak, fontFamily = _a.fontFamily, truncate = _a.truncate, textShadow = _a.textShadow, textAlign = _a.textAlign, customStyles = _a.customStyles, monospace = _a.monospace, quote = _a.quote, opacity = _a.opacity, _c = _a.variant, variant = _c === void 0 ? '' : _c, size = _a.size, margin = _a.margin, padding = _a.padding, rest = __rest(_a, ["id", "bg", "color", "children", "hoverBg", "hoverText", "text", "funcss", "emp", "bold", "block", "body", "article", "light", "lighter", "italic", "weight", "underline", "align", "lineHeight", "letterSpacing", "uppercase", "lowercase", "capitalize", "textDecoration", "textTransform", "whiteSpace", "wordBreak", "fontFamily", "truncate", "textShadow", "textAlign", "customStyles", "monospace", "quote", "opacity", "variant", "size", "margin", "padding"]);
|
|
35
|
+
// Use component configuration (simplified - let the hook handle empty variant)
|
|
36
|
+
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Text', variant).mergeWithLocal;
|
|
37
|
+
// Create local props object - include ALL props
|
|
38
|
+
var localProps = __assign({ bg: bg, color: color, hoverBg: hoverBg, hoverText: hoverText, funcss: funcss, emp: emp, bold: bold, block: block, body: body, article: article, light: light, lighter: lighter, italic: italic, weight: weight, underline: underline, align: align, lineHeight: lineHeight, letterSpacing: letterSpacing, uppercase: uppercase, lowercase: lowercase, capitalize: capitalize, textDecoration: textDecoration, textTransform: textTransform, whiteSpace: whiteSpace, wordBreak: wordBreak, fontFamily: fontFamily, truncate: truncate, textShadow: textShadow, textAlign: textAlign, monospace: monospace, quote: quote, opacity: opacity, size: size, margin: margin, padding: padding }, rest);
|
|
39
|
+
// Merge with config - LOCAL PROPS OVERRIDE CONFIG (consistent with Button)
|
|
40
|
+
var mergedProps = mergeWithLocal(localProps).props;
|
|
41
|
+
// Extract final values - use NULLISH COALESCING like Button component
|
|
45
42
|
var final = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
43
|
+
// Use local props first, fallback to merged props
|
|
44
|
+
bg: bg !== null && bg !== void 0 ? bg : mergedProps.bg,
|
|
45
|
+
color: color !== null && color !== void 0 ? color : mergedProps.color,
|
|
46
|
+
hoverBg: hoverBg !== null && hoverBg !== void 0 ? hoverBg : mergedProps.hoverBg,
|
|
47
|
+
hoverText: hoverText !== null && hoverText !== void 0 ? hoverText : mergedProps.hoverText,
|
|
48
|
+
funcss: funcss !== null && funcss !== void 0 ? funcss : mergedProps.funcss,
|
|
49
|
+
emp: emp !== null && emp !== void 0 ? emp : mergedProps.emp,
|
|
50
|
+
bold: bold !== null && bold !== void 0 ? bold : mergedProps.bold,
|
|
51
|
+
block: block !== null && block !== void 0 ? block : mergedProps.block,
|
|
52
|
+
body: body !== null && body !== void 0 ? body : mergedProps.body,
|
|
53
|
+
article: article !== null && article !== void 0 ? article : mergedProps.article,
|
|
54
|
+
light: light !== null && light !== void 0 ? light : mergedProps.light,
|
|
55
|
+
lighter: lighter !== null && lighter !== void 0 ? lighter : mergedProps.lighter,
|
|
56
|
+
italic: italic !== null && italic !== void 0 ? italic : mergedProps.italic,
|
|
57
|
+
weight: weight !== null && weight !== void 0 ? weight : mergedProps.weight,
|
|
58
|
+
underline: underline !== null && underline !== void 0 ? underline : mergedProps.underline,
|
|
59
|
+
align: align !== null && align !== void 0 ? align : mergedProps.align,
|
|
60
|
+
lineHeight: lineHeight !== null && lineHeight !== void 0 ? lineHeight : mergedProps.lineHeight,
|
|
61
|
+
letterSpacing: letterSpacing !== null && letterSpacing !== void 0 ? letterSpacing : mergedProps.letterSpacing,
|
|
62
|
+
uppercase: uppercase !== null && uppercase !== void 0 ? uppercase : mergedProps.uppercase,
|
|
63
|
+
lowercase: lowercase !== null && lowercase !== void 0 ? lowercase : mergedProps.lowercase,
|
|
64
|
+
capitalize: capitalize !== null && capitalize !== void 0 ? capitalize : mergedProps.capitalize,
|
|
65
|
+
textDecoration: textDecoration !== null && textDecoration !== void 0 ? textDecoration : mergedProps.textDecoration,
|
|
66
|
+
textTransform: textTransform !== null && textTransform !== void 0 ? textTransform : mergedProps.textTransform,
|
|
67
|
+
whiteSpace: whiteSpace !== null && whiteSpace !== void 0 ? whiteSpace : mergedProps.whiteSpace,
|
|
68
|
+
wordBreak: wordBreak !== null && wordBreak !== void 0 ? wordBreak : mergedProps.wordBreak,
|
|
69
|
+
fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : mergedProps.fontFamily,
|
|
70
|
+
truncate: truncate !== null && truncate !== void 0 ? truncate : mergedProps.truncate,
|
|
71
|
+
textShadow: textShadow !== null && textShadow !== void 0 ? textShadow : mergedProps.textShadow,
|
|
72
|
+
textAlign: textAlign !== null && textAlign !== void 0 ? textAlign : mergedProps.textAlign,
|
|
73
|
+
monospace: monospace !== null && monospace !== void 0 ? monospace : mergedProps.monospace,
|
|
74
|
+
quote: quote !== null && quote !== void 0 ? quote : mergedProps.quote,
|
|
75
|
+
opacity: opacity !== null && opacity !== void 0 ? opacity : mergedProps.opacity,
|
|
76
|
+
size: (_b = size !== null && size !== void 0 ? size : mergedProps.size) !== null && _b !== void 0 ? _b : 'base',
|
|
77
|
+
margin: margin !== null && margin !== void 0 ? margin : mergedProps.margin,
|
|
78
|
+
text: text !== null && text !== void 0 ? text : mergedProps.text,
|
|
79
|
+
padding: padding !== null && padding !== void 0 ? padding : mergedProps.padding,
|
|
79
80
|
};
|
|
80
81
|
// If margin is provided, force block display
|
|
81
82
|
var shouldBeBlock = final.block || !!final.margin;
|
|
@@ -103,8 +104,8 @@ var Text = function (_a) {
|
|
|
103
104
|
final.align ? " text-".concat(final.align, " ") : '',
|
|
104
105
|
final.monospace ? 'monospace' : '',
|
|
105
106
|
final.bg || '',
|
|
106
|
-
hoverText ? "hover-text-".concat(hoverText) : '',
|
|
107
|
-
hoverBg ? "hover-".concat(hoverBg) : '',
|
|
107
|
+
final.hoverText ? "hover-text-".concat(final.hoverText) : '',
|
|
108
|
+
final.hoverBg ? "hover-".concat(final.hoverBg) : '',
|
|
108
109
|
final.light ? 'lightText' : final.lighter ? 'lighterText' : '',
|
|
109
110
|
final.italic ? 'italicText' : '',
|
|
110
111
|
final.underline ? 'underlineText' : '',
|
|
@@ -122,7 +123,7 @@ var Text = function (_a) {
|
|
|
122
123
|
return (react_1.default.createElement(Tag, __assign({ id: id, className: classNames, style: mergedStyles }, rest),
|
|
123
124
|
final.quote && (react_1.default.createElement("div", null,
|
|
124
125
|
react_1.default.createElement(pi_1.PiQuotesLight, null))),
|
|
125
|
-
children,
|
|
126
|
-
text));
|
|
126
|
+
children, final === null || final === void 0 ? void 0 :
|
|
127
|
+
final.text));
|
|
127
128
|
};
|
|
128
129
|
exports.default = Text;
|
package/ui/theme/theme.d.ts
CHANGED
|
@@ -17,10 +17,16 @@ interface ProjectData {
|
|
|
17
17
|
components?: Record<string, any>;
|
|
18
18
|
default_variation?: ThemeVariant;
|
|
19
19
|
variables?: Variable[];
|
|
20
|
+
assets?: Asset[];
|
|
20
21
|
name?: string;
|
|
21
22
|
project_id?: string;
|
|
22
23
|
version?: number;
|
|
23
24
|
updated_at?: string;
|
|
25
|
+
trustedDomains?: Array<{
|
|
26
|
+
domain: string;
|
|
27
|
+
status: string;
|
|
28
|
+
isDefault?: boolean;
|
|
29
|
+
}>;
|
|
24
30
|
}
|
|
25
31
|
interface ThemeProviderProps {
|
|
26
32
|
theme: ThemeName;
|
|
@@ -61,3 +67,31 @@ export declare const useTypographyValue: (property: string) => string | undefine
|
|
|
61
67
|
export declare const useComponentVariant: (componentName: string, variantName?: string) => any;
|
|
62
68
|
export declare const useVariables: () => Variable[];
|
|
63
69
|
export declare const useVariable: (name: string) => any;
|
|
70
|
+
interface Asset {
|
|
71
|
+
name: string;
|
|
72
|
+
url: string;
|
|
73
|
+
file_type: string;
|
|
74
|
+
}
|
|
75
|
+
export declare const getAsset: (name: string) => Asset | undefined;
|
|
76
|
+
export declare const getAllAssets: () => Asset[];
|
|
77
|
+
export declare const getAssetValue: (name: string) => string | undefined;
|
|
78
|
+
export declare const getAssetType: (name: string) => string | undefined;
|
|
79
|
+
export declare const getAssetInfo: (name: string) => {
|
|
80
|
+
value: string;
|
|
81
|
+
type: string;
|
|
82
|
+
name: string;
|
|
83
|
+
} | undefined;
|
|
84
|
+
export declare const useAssets: () => Asset[];
|
|
85
|
+
export declare const useAsset: (name: string) => Asset | undefined;
|
|
86
|
+
export declare const useAssetValue: (name: string) => string | undefined;
|
|
87
|
+
export declare const useAssetType: (name: string) => string | undefined;
|
|
88
|
+
export declare const useAssetInfo: (name: string) => {
|
|
89
|
+
value: string;
|
|
90
|
+
type: string;
|
|
91
|
+
name: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
export declare const useAssetsByType: (type: string) => Asset[];
|
|
94
|
+
export declare const useImageAssets: () => Asset[];
|
|
95
|
+
export declare const useVideoAssets: () => Asset[];
|
|
96
|
+
export declare const useAudioAssets: () => Asset[];
|
|
97
|
+
export declare const useDocumentAssets: () => Asset[];
|
package/ui/theme/theme.js
CHANGED
|
@@ -70,7 +70,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
-
exports.useVariable = exports.useVariables = exports.useComponentVariant = exports.useTypographyValue = exports.useColor = exports.useProjectData = exports.useThemeConfig = exports.useTypography = exports.useColors = exports.useComponentConfig = exports.useThemeValue = exports.getAllVariables = exports.getVariable = exports.useVariant = exports.useTheme = void 0;
|
|
73
|
+
exports.useDocumentAssets = exports.useAudioAssets = exports.useVideoAssets = exports.useImageAssets = exports.useAssetsByType = exports.useAssetInfo = exports.useAssetType = exports.useAssetValue = exports.useAsset = exports.useAssets = exports.getAssetInfo = exports.getAssetType = exports.getAssetValue = exports.getAllAssets = exports.getAsset = exports.useVariable = exports.useVariables = exports.useComponentVariant = exports.useTypographyValue = exports.useColor = exports.useProjectData = exports.useThemeConfig = exports.useTypography = exports.useColors = exports.useComponentConfig = exports.useThemeValue = exports.getAllVariables = exports.getVariable = exports.useVariant = exports.useTheme = void 0;
|
|
74
74
|
var react_1 = __importStar(require("react"));
|
|
75
75
|
var themes_1 = require("./themes");
|
|
76
76
|
var darkenUtils_1 = require("./darkenUtils");
|
|
@@ -97,10 +97,70 @@ var useVariant = function () {
|
|
|
97
97
|
};
|
|
98
98
|
exports.useVariant = useVariant;
|
|
99
99
|
/* -------------------------------------------------------------------------- */
|
|
100
|
+
/* ORIGIN VALIDATION */
|
|
101
|
+
/* -------------------------------------------------------------------------- */
|
|
102
|
+
var getCurrentOrigin = function () {
|
|
103
|
+
if (typeof window === 'undefined')
|
|
104
|
+
return '';
|
|
105
|
+
// For local development, return localhost
|
|
106
|
+
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
|
107
|
+
return 'localhost';
|
|
108
|
+
}
|
|
109
|
+
// For production, return the domain without protocol and www
|
|
110
|
+
var domain = window.location.hostname;
|
|
111
|
+
domain = domain.replace(/^www\./, '');
|
|
112
|
+
return domain;
|
|
113
|
+
};
|
|
114
|
+
var validateOriginAccess = function (projectId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
+
var currentOrigin, projectData, trustedDomains, hasAccess, error_1;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
if (!projectId) {
|
|
120
|
+
console.error('❌ No project ID provided');
|
|
121
|
+
return [2 /*return*/, false];
|
|
122
|
+
}
|
|
123
|
+
currentOrigin = getCurrentOrigin();
|
|
124
|
+
console.log("\uD83D\uDD0D Validating origin access for: ".concat(currentOrigin));
|
|
125
|
+
_a.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
_a.trys.push([1, 3, , 4]);
|
|
128
|
+
return [4 /*yield*/, loadThemeFromCDN(projectId)];
|
|
129
|
+
case 2:
|
|
130
|
+
projectData = _a.sent();
|
|
131
|
+
if (!projectData) {
|
|
132
|
+
console.error('❌ Project not found or inaccessible');
|
|
133
|
+
return [2 /*return*/, false];
|
|
134
|
+
}
|
|
135
|
+
trustedDomains = projectData.trustedDomains || [];
|
|
136
|
+
hasAccess = trustedDomains.some(function (domain) {
|
|
137
|
+
var trustedDomain = domain.domain.toLowerCase();
|
|
138
|
+
var currentDomain = currentOrigin.toLowerCase();
|
|
139
|
+
// Exact match or subdomain match
|
|
140
|
+
return currentDomain === trustedDomain ||
|
|
141
|
+
currentDomain.endsWith('.' + trustedDomain) ||
|
|
142
|
+
(trustedDomain === 'localhost' && currentOrigin === 'localhost');
|
|
143
|
+
});
|
|
144
|
+
if (!hasAccess) {
|
|
145
|
+
console.error("\u274C Access denied: Origin \"".concat(currentOrigin, "\" is not in trusted domains"));
|
|
146
|
+
console.log('📋 Trusted domains:', trustedDomains.map(function (d) { return d.domain; }));
|
|
147
|
+
return [2 /*return*/, false];
|
|
148
|
+
}
|
|
149
|
+
console.log('✅ Origin validation passed');
|
|
150
|
+
return [2 /*return*/, true];
|
|
151
|
+
case 3:
|
|
152
|
+
error_1 = _a.sent();
|
|
153
|
+
console.error('❌ Error during origin validation:', error_1);
|
|
154
|
+
return [2 /*return*/, false];
|
|
155
|
+
case 4: return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); };
|
|
159
|
+
/* -------------------------------------------------------------------------- */
|
|
100
160
|
/* LOCAL FILE MANAGEMENT */
|
|
101
161
|
/* -------------------------------------------------------------------------- */
|
|
102
162
|
var loadLocalTheme = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
-
var response, data,
|
|
163
|
+
var response, data, error_2;
|
|
104
164
|
return __generator(this, function (_a) {
|
|
105
165
|
switch (_a.label) {
|
|
106
166
|
case 0:
|
|
@@ -118,7 +178,7 @@ var loadLocalTheme = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
118
178
|
return [2 /*return*/, data];
|
|
119
179
|
case 3: return [3 /*break*/, 5];
|
|
120
180
|
case 4:
|
|
121
|
-
|
|
181
|
+
error_2 = _a.sent();
|
|
122
182
|
console.log('No local theme file found');
|
|
123
183
|
return [3 /*break*/, 5];
|
|
124
184
|
case 5: return [2 /*return*/, null];
|
|
@@ -129,7 +189,7 @@ var loadLocalTheme = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
129
189
|
/* CDN THEME LOADER */
|
|
130
190
|
/* -------------------------------------------------------------------------- */
|
|
131
191
|
var loadThemeFromCDN = function (projectId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
-
var publicUrl, response, data,
|
|
192
|
+
var publicUrl, response, data, error_3;
|
|
133
193
|
return __generator(this, function (_a) {
|
|
134
194
|
switch (_a.label) {
|
|
135
195
|
case 0:
|
|
@@ -151,8 +211,8 @@ var loadThemeFromCDN = function (projectId) { return __awaiter(void 0, void 0, v
|
|
|
151
211
|
_a.label = 4;
|
|
152
212
|
case 4: return [3 /*break*/, 6];
|
|
153
213
|
case 5:
|
|
154
|
-
|
|
155
|
-
console.error('Error loading from Firebase Storage:',
|
|
214
|
+
error_3 = _a.sent();
|
|
215
|
+
console.error('Error loading from Firebase Storage:', error_3);
|
|
156
216
|
return [3 /*break*/, 6];
|
|
157
217
|
case 6: return [2 /*return*/, null];
|
|
158
218
|
}
|
|
@@ -246,9 +306,16 @@ var ThemeProvider = function (_a) {
|
|
|
246
306
|
});
|
|
247
307
|
}
|
|
248
308
|
}, [theme]);
|
|
249
|
-
/* ---------------------- CDN Theme Sync with
|
|
309
|
+
/* ---------------------- CDN Theme Sync with Origin Validation ----------------------- */
|
|
250
310
|
(0, react_1.useEffect)(function () {
|
|
251
|
-
if (typeof window === 'undefined'
|
|
311
|
+
if (typeof window === 'undefined') {
|
|
312
|
+
setIsLoading(false);
|
|
313
|
+
setIsInitialLoad(false);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (!projectId) {
|
|
317
|
+
console.error('❌ ThemeProvider: No projectId provided');
|
|
318
|
+
setError('Project ID is required');
|
|
252
319
|
setIsLoading(false);
|
|
253
320
|
setIsInitialLoad(false);
|
|
254
321
|
return;
|
|
@@ -256,17 +323,27 @@ var ThemeProvider = function (_a) {
|
|
|
256
323
|
var root = document.documentElement;
|
|
257
324
|
var pollTimer;
|
|
258
325
|
var syncTheme = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
259
|
-
var localTheme, localVersion, cdnTheme, cdnVersion, err_1;
|
|
326
|
+
var hasAccess, localTheme, localVersion, cdnTheme, cdnVersion, err_1;
|
|
260
327
|
return __generator(this, function (_a) {
|
|
261
328
|
switch (_a.label) {
|
|
262
329
|
case 0:
|
|
263
|
-
_a.trys.push([0,
|
|
264
|
-
|
|
330
|
+
_a.trys.push([0, 4, 5, 6]);
|
|
331
|
+
console.log('🔄 Starting theme sync with origin validation...');
|
|
332
|
+
return [4 /*yield*/, validateOriginAccess(projectId)];
|
|
265
333
|
case 1:
|
|
334
|
+
hasAccess = _a.sent();
|
|
335
|
+
if (!hasAccess) {
|
|
336
|
+
setError('Access denied: This domain is not authorized to use this theme');
|
|
337
|
+
setIsLoading(false);
|
|
338
|
+
setIsInitialLoad(false);
|
|
339
|
+
return [2 /*return*/];
|
|
340
|
+
}
|
|
341
|
+
return [4 /*yield*/, loadLocalTheme()];
|
|
342
|
+
case 2:
|
|
266
343
|
localTheme = _a.sent();
|
|
267
344
|
localVersion = (localTheme === null || localTheme === void 0 ? void 0 : localTheme.version) || 0;
|
|
268
345
|
return [4 /*yield*/, loadThemeFromCDN(projectId)];
|
|
269
|
-
case
|
|
346
|
+
case 3:
|
|
270
347
|
cdnTheme = _a.sent();
|
|
271
348
|
cdnVersion = (cdnTheme === null || cdnTheme === void 0 ? void 0 : cdnTheme.version) || 0;
|
|
272
349
|
if (cdnTheme) {
|
|
@@ -298,17 +375,17 @@ var ThemeProvider = function (_a) {
|
|
|
298
375
|
console.warn('⚠️ No theme found');
|
|
299
376
|
setError('Theme not found');
|
|
300
377
|
}
|
|
301
|
-
return [3 /*break*/,
|
|
302
|
-
case
|
|
378
|
+
return [3 /*break*/, 6];
|
|
379
|
+
case 4:
|
|
303
380
|
err_1 = _a.sent();
|
|
304
|
-
console.error('Error syncing theme:', err_1);
|
|
381
|
+
console.error('❌ Error syncing theme:', err_1);
|
|
305
382
|
setError('Failed to sync theme');
|
|
306
|
-
return [3 /*break*/,
|
|
307
|
-
case
|
|
383
|
+
return [3 /*break*/, 6];
|
|
384
|
+
case 5:
|
|
308
385
|
setIsLoading(false);
|
|
309
386
|
setIsInitialLoad(false);
|
|
310
387
|
return [7 /*endfinally*/];
|
|
311
|
-
case
|
|
388
|
+
case 6: return [2 /*return*/];
|
|
312
389
|
}
|
|
313
390
|
});
|
|
314
391
|
}); };
|
|
@@ -331,6 +408,8 @@ var ThemeProvider = function (_a) {
|
|
|
331
408
|
setProjectData(data);
|
|
332
409
|
// Cache for variable access
|
|
333
410
|
cachedProjectData = data;
|
|
411
|
+
// Cache for asset access
|
|
412
|
+
cachedAssets = data.assets || [];
|
|
334
413
|
// Apply all theme config to CSS variables
|
|
335
414
|
applyThemeConfig(themeConfig, root);
|
|
336
415
|
};
|
|
@@ -417,3 +496,104 @@ var useVariable = function (name) {
|
|
|
417
496
|
return variable === null || variable === void 0 ? void 0 : variable.value;
|
|
418
497
|
};
|
|
419
498
|
exports.useVariable = useVariable;
|
|
499
|
+
var cachedAssets = [];
|
|
500
|
+
var getAsset = function (name) {
|
|
501
|
+
if (!cachedAssets.length) {
|
|
502
|
+
console.warn('No assets available. Make sure ThemeProvider is mounted and assets are loaded.');
|
|
503
|
+
return undefined;
|
|
504
|
+
}
|
|
505
|
+
var asset = cachedAssets.find(function (a) { return a.name === name; });
|
|
506
|
+
return asset;
|
|
507
|
+
};
|
|
508
|
+
exports.getAsset = getAsset;
|
|
509
|
+
var getAllAssets = function () {
|
|
510
|
+
return cachedAssets;
|
|
511
|
+
};
|
|
512
|
+
exports.getAllAssets = getAllAssets;
|
|
513
|
+
var getAssetValue = function (name) {
|
|
514
|
+
var asset = (0, exports.getAsset)(name);
|
|
515
|
+
return asset === null || asset === void 0 ? void 0 : asset.url;
|
|
516
|
+
};
|
|
517
|
+
exports.getAssetValue = getAssetValue;
|
|
518
|
+
var getAssetType = function (name) {
|
|
519
|
+
var asset = (0, exports.getAsset)(name);
|
|
520
|
+
return asset === null || asset === void 0 ? void 0 : asset.file_type;
|
|
521
|
+
};
|
|
522
|
+
exports.getAssetType = getAssetType;
|
|
523
|
+
var getAssetInfo = function (name) {
|
|
524
|
+
var asset = (0, exports.getAsset)(name);
|
|
525
|
+
if (!asset)
|
|
526
|
+
return undefined;
|
|
527
|
+
return {
|
|
528
|
+
value: asset.url,
|
|
529
|
+
type: asset.file_type,
|
|
530
|
+
name: asset.name
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
exports.getAssetInfo = getAssetInfo;
|
|
534
|
+
/* -------------------------------------------------------------------------- */
|
|
535
|
+
/* ASSETS HOOKS */
|
|
536
|
+
/* -------------------------------------------------------------------------- */
|
|
537
|
+
// Hook to access all assets
|
|
538
|
+
var useAssets = function () {
|
|
539
|
+
var projectData = (0, exports.useTheme)().projectData;
|
|
540
|
+
return (projectData === null || projectData === void 0 ? void 0 : projectData.assets) || [];
|
|
541
|
+
};
|
|
542
|
+
exports.useAssets = useAssets;
|
|
543
|
+
// Hook to get a specific asset
|
|
544
|
+
var useAsset = function (name) {
|
|
545
|
+
var assets = (0, exports.useAssets)();
|
|
546
|
+
var asset = assets.find(function (a) { return a.name === name; });
|
|
547
|
+
return asset;
|
|
548
|
+
};
|
|
549
|
+
exports.useAsset = useAsset;
|
|
550
|
+
// Hook to get asset URL (most common use case)
|
|
551
|
+
var useAssetValue = function (name) {
|
|
552
|
+
var asset = (0, exports.useAsset)(name);
|
|
553
|
+
return asset === null || asset === void 0 ? void 0 : asset.url;
|
|
554
|
+
};
|
|
555
|
+
exports.useAssetValue = useAssetValue;
|
|
556
|
+
// Hook to get asset type
|
|
557
|
+
var useAssetType = function (name) {
|
|
558
|
+
var asset = (0, exports.useAsset)(name);
|
|
559
|
+
return asset === null || asset === void 0 ? void 0 : asset.file_type;
|
|
560
|
+
};
|
|
561
|
+
exports.useAssetType = useAssetType;
|
|
562
|
+
// Hook to get complete asset info
|
|
563
|
+
var useAssetInfo = function (name) {
|
|
564
|
+
var asset = (0, exports.useAsset)(name);
|
|
565
|
+
if (!asset)
|
|
566
|
+
return undefined;
|
|
567
|
+
return {
|
|
568
|
+
value: asset.url,
|
|
569
|
+
type: asset.file_type,
|
|
570
|
+
name: asset.name
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
exports.useAssetInfo = useAssetInfo;
|
|
574
|
+
// Hook to filter assets by type
|
|
575
|
+
var useAssetsByType = function (type) {
|
|
576
|
+
var assets = (0, exports.useAssets)();
|
|
577
|
+
return assets.filter(function (asset) { return asset.file_type === type; });
|
|
578
|
+
};
|
|
579
|
+
exports.useAssetsByType = useAssetsByType;
|
|
580
|
+
// Hook to get image assets
|
|
581
|
+
var useImageAssets = function () {
|
|
582
|
+
return (0, exports.useAssetsByType)('image');
|
|
583
|
+
};
|
|
584
|
+
exports.useImageAssets = useImageAssets;
|
|
585
|
+
// Hook to get video assets
|
|
586
|
+
var useVideoAssets = function () {
|
|
587
|
+
return (0, exports.useAssetsByType)('video');
|
|
588
|
+
};
|
|
589
|
+
exports.useVideoAssets = useVideoAssets;
|
|
590
|
+
// Hook to get audio assets
|
|
591
|
+
var useAudioAssets = function () {
|
|
592
|
+
return (0, exports.useAssetsByType)('audio');
|
|
593
|
+
};
|
|
594
|
+
exports.useAudioAssets = useAudioAssets;
|
|
595
|
+
// Hook to get document assets
|
|
596
|
+
var useDocumentAssets = function () {
|
|
597
|
+
return (0, exports.useAssetsByType)('document');
|
|
598
|
+
};
|
|
599
|
+
exports.useDocumentAssets = useDocumentAssets;
|