@bravostudioai/react 0.1.6 โ 0.1.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravostudioai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vite": "^7.2.4"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"react": "^
|
|
58
|
-
"react-dom": "^
|
|
57
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
58
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -341,7 +341,7 @@ Arguments:
|
|
|
341
341
|
outputPath Path where the generated TSX file(s) should be saved
|
|
342
342
|
|
|
343
343
|
Environment variables:
|
|
344
|
-
APPS_SERVICE_URL Base URL for the apps service
|
|
344
|
+
APPS_SERVICE_URL Base URL for the apps service
|
|
345
345
|
|
|
346
346
|
Example:
|
|
347
347
|
generate-wrapper.ts 01KA964B1T6KCKSKCNMYSTKRKZ 01KA964B2F42MN4WGCYDTG1Y70 ./src/components/MyEncoreApp.tsx
|
|
@@ -99,6 +99,9 @@ const EncoreApp = ({
|
|
|
99
99
|
console.log("Render: EncoreApp");
|
|
100
100
|
console.log("๐ฅ ENCORE-LIB SOURCE CODE IS ACTIVE ๐ฅ");
|
|
101
101
|
console.log("โจ ENCORE-LIB UPDATED - TEST MESSAGE โจ");
|
|
102
|
+
console.log(
|
|
103
|
+
`[AG_DEBUG] [EncoreApp] Render Start. appId: ${appId}, pageId: ${pageId}`
|
|
104
|
+
);
|
|
102
105
|
|
|
103
106
|
// CRITICAL: Set baseURL BEFORE any hooks that might trigger fetches
|
|
104
107
|
// This must happen synchronously, not in useEffect, because useSWR will fetch immediately
|
|
@@ -198,6 +201,22 @@ const EncoreApp = ({
|
|
|
198
201
|
type AppDataWithFonts = { app?: { fonts?: EncoreFont[] } };
|
|
199
202
|
const fonts: EncoreFont[] =
|
|
200
203
|
(app?.data as AppDataWithFonts | undefined)?.app?.fonts ?? [];
|
|
204
|
+
|
|
205
|
+
console.log(
|
|
206
|
+
`[AG_DEBUG] [EncoreApp] ๐ Font check initiated. Found ${
|
|
207
|
+
fonts?.length || 0
|
|
208
|
+
} fonts in app definition.`
|
|
209
|
+
);
|
|
210
|
+
if (fonts && fonts.length > 0) {
|
|
211
|
+
console.log(
|
|
212
|
+
"[AG_DEBUG] [EncoreApp] Font list:",
|
|
213
|
+
fonts.map(
|
|
214
|
+
(f) =>
|
|
215
|
+
`${f.fontName?.family} (${f.fontName?.postScriptName}) - Broken: ${f.broken} - URL: ${f.url}`
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
201
220
|
if (!fonts || fonts.length === 0) return;
|
|
202
221
|
if (typeof window === "undefined" || !("FontFace" in window)) return;
|
|
203
222
|
fonts.forEach((f) => {
|
|
@@ -215,44 +234,30 @@ const EncoreApp = ({
|
|
|
215
234
|
);
|
|
216
235
|
}
|
|
217
236
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/(?:^|-)(Thin|ExtraLight|Light|Regular|Medium|SemiBold|Bold|ExtraBold|Black)(?:-|$)/i
|
|
224
|
-
);
|
|
225
|
-
if (weightMatch) {
|
|
226
|
-
const weightName = weightMatch[1].toLowerCase();
|
|
227
|
-
const weightMap: Record<string, number> = {
|
|
228
|
-
thin: 100,
|
|
229
|
-
extralight: 200,
|
|
230
|
-
light: 300,
|
|
231
|
-
regular: 400,
|
|
232
|
-
medium: 500,
|
|
233
|
-
semibold: 600,
|
|
234
|
-
bold: 700,
|
|
235
|
-
extrabold: 800,
|
|
236
|
-
black: 900,
|
|
237
|
-
};
|
|
238
|
-
weight = weightMap[weightName] || 400;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Create FontFace with weight descriptor if we inferred it
|
|
243
|
-
const fontFace =
|
|
244
|
-
weight !== undefined
|
|
245
|
-
? new FontFace(family, `url(${url})`, { weight: weight.toString() })
|
|
246
|
-
: new FontFace(family, `url(${url})`);
|
|
237
|
+
const familyName = postScriptName || family;
|
|
238
|
+
const fontFace = new FontFace(familyName, `url(${url})`, {
|
|
239
|
+
weight: "100 900",
|
|
240
|
+
style: "normal",
|
|
241
|
+
});
|
|
247
242
|
|
|
248
243
|
fontFace
|
|
249
244
|
.load()
|
|
250
245
|
.then((ff) => {
|
|
251
246
|
document.fonts.add(ff);
|
|
247
|
+
console.log(
|
|
248
|
+
`[AG_DEBUG] [EncoreApp] โ
Font loaded successfully: "${familyName}" - Source: ${url}`
|
|
249
|
+
);
|
|
250
|
+
// Check if it's usable - check for any weight since we registered 100-900
|
|
251
|
+
const isCheckPassed = document.fonts.check(
|
|
252
|
+
`400 12px "${familyName}"`
|
|
253
|
+
);
|
|
254
|
+
console.log(
|
|
255
|
+
`[AG_DEBUG] [EncoreApp] ๐งช document.fonts.check result for "${familyName}": ${isCheckPassed}`
|
|
256
|
+
);
|
|
252
257
|
})
|
|
253
258
|
.catch((err) => {
|
|
254
259
|
console.warn(
|
|
255
|
-
`[EncoreApp] Failed to load font "${
|
|
260
|
+
`[AG_DEBUG] [EncoreApp] โ Failed to load font "${
|
|
256
261
|
postScriptName || family
|
|
257
262
|
}" from ${url}`,
|
|
258
263
|
err
|
|
@@ -301,9 +306,23 @@ const EncoreApp = ({
|
|
|
301
306
|
`/devices/apps/${appId}/node/${pageId}${
|
|
302
307
|
useLocalFlag ? "?useLocal=1" : ""
|
|
303
308
|
}`;
|
|
309
|
+
|
|
310
|
+
console.log(`[AG_DEBUG] [EncoreApp] pageUrl: ${pageUrl}`);
|
|
311
|
+
|
|
304
312
|
const pageSWR = useSWR(pageUrl, fetcher, { suspense: !!pageUrl });
|
|
305
313
|
const pageData = pageDefinition ? { data: pageDefinition } : pageSWR;
|
|
306
314
|
|
|
315
|
+
console.log(
|
|
316
|
+
`[AG_DEBUG] [EncoreApp] pageData.data type: ${typeof pageData?.data}, hasData: ${!!pageData?.data}`
|
|
317
|
+
);
|
|
318
|
+
if (pageData?.data) {
|
|
319
|
+
console.log(
|
|
320
|
+
`[AG_DEBUG] [EncoreApp] pageData.data JSON: ${JSON.stringify(
|
|
321
|
+
pageData.data
|
|
322
|
+
).substring(0, 1000)}`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
307
326
|
// Debug logging commented out to prevent console flooding
|
|
308
327
|
/*
|
|
309
328
|
useEffect(() => {
|
|
@@ -467,12 +486,25 @@ const EncoreApp = ({
|
|
|
467
486
|
// Only recreate when the actual data changes, not on every render
|
|
468
487
|
const context = useMemo(() => {
|
|
469
488
|
let clientData = pageData.data?.clientData;
|
|
489
|
+
console.log(
|
|
490
|
+
`[AG_DEBUG] [EncoreApp] useMemo: clientData present? ${!!clientData}, Keys: ${Object.keys(
|
|
491
|
+
clientData || {}
|
|
492
|
+
)}`
|
|
493
|
+
);
|
|
470
494
|
|
|
471
495
|
// --- GENERIC DATA PATCHING START ---
|
|
472
496
|
// Recursively patch the data to fix layout and slider issues based on heuristics
|
|
473
497
|
const patchPageData = (node: any) => {
|
|
474
498
|
if (!node || typeof node !== "object") return;
|
|
475
499
|
|
|
500
|
+
// Log font usage
|
|
501
|
+
if (node.componentId || node.type === "component:text") {
|
|
502
|
+
console.log(
|
|
503
|
+
`[AG_DEBUG] [EncoreApp] ๐ฆ Node ${node.id} (${node.type}) Style:`,
|
|
504
|
+
JSON.stringify(node.style)
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
476
508
|
// 1. Layout Heuristic: If children widths sum to ~100% or ~375px, force HORIZONTAL layout
|
|
477
509
|
// RELAXED: No longer requires layoutSizingHorizontal: "FIXED" - width data alone is sufficient
|
|
478
510
|
if (
|
package/src/components.tsx
CHANGED
|
@@ -455,7 +455,15 @@ const useEncoreStyle = (
|
|
|
455
455
|
if (style.opacity) result.opacity = style.opacity * 0.01;
|
|
456
456
|
if (style.fontId) {
|
|
457
457
|
const fontFamily = fontIdToFamily[style.fontId] || "sans-serif";
|
|
458
|
-
|
|
458
|
+
// Ensure font family name is quoted for names with spaces/special characters
|
|
459
|
+
result.fontFamily = `"${fontFamily}"`;
|
|
460
|
+
|
|
461
|
+
console.log(`[AG_DEBUG] [useEncoreStyle] Font Resolution:`, {
|
|
462
|
+
fontId: style.fontId,
|
|
463
|
+
resolvedFamily: fontFamily,
|
|
464
|
+
fontWeight: style.fontWeight,
|
|
465
|
+
finalStyle: result.fontFamily,
|
|
466
|
+
});
|
|
459
467
|
}
|
|
460
468
|
if (style.borderRadius) {
|
|
461
469
|
result.borderRadius = percentOfParentWidthToPx(style.borderRadius);
|
|
@@ -68,7 +68,10 @@ const useEncoreState = create<EncoreState>((set) => ({
|
|
|
68
68
|
app.app?.fonts?.reduce?.(
|
|
69
69
|
(acc: Record<string, string>, font: any) => ({
|
|
70
70
|
...acc,
|
|
71
|
-
[font.id]:
|
|
71
|
+
[font.id]:
|
|
72
|
+
font.fontName?.postScriptName ||
|
|
73
|
+
font.fontName?.family ||
|
|
74
|
+
"sans-serif",
|
|
72
75
|
}),
|
|
73
76
|
{}
|
|
74
77
|
) ?? {},
|