@bravostudioai/react 0.1.14 → 0.1.16
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/cli/commands/generate.js +90 -85
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/codegen/generator.js +218 -212
- package/dist/codegen/generator.js.map +1 -1
- package/dist/components/EncoreApp.js +34 -22
- package/dist/components/EncoreApp.js.map +1 -1
- package/dist/components.js +524 -537
- package/dist/components.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/packages/encore-lib/constants.js.map +1 -1
- package/dist/src/cli/commands/generate.d.ts.map +1 -1
- package/dist/src/codegen/generator.d.ts +5 -1
- package/dist/src/codegen/generator.d.ts.map +1 -1
- package/dist/src/components/EncoreApp.d.ts.map +1 -1
- package/dist/src/components.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/generate.ts +9 -1
- package/src/codegen/generator.ts +12 -1
- package/src/components/EncoreApp.tsx +9 -1
- package/src/components.tsx +11 -6
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,0DACsB,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,0DACsB,CAAC;AAG1D,eAAO,MAAM,wBAAwB,oDACc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../constants.ts"],"sourcesContent":["export const CONST_APPS_SERVICE_URL =\n \"https://apps-service-585087176299.us-central1.run.app\";\n\nexport const CONST_COMPONENTS_CDN_URL =\n \"https://bsai-public.sfo3.digitaloceanspaces.com\";\n"],"names":["CONST_APPS_SERVICE_URL","CONST_COMPONENTS_CDN_URL"],"mappings":"AAAO,MAAMA,IACX,
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../constants.ts"],"sourcesContent":["export const CONST_APPS_SERVICE_URL =\n \"https://apps-service-585087176299.us-central1.run.app\";\n// export const CONST_APPS_SERVICE_URL = \"http://localhost:3001\";\n\nexport const CONST_COMPONENTS_CDN_URL =\n \"https://bsai-public.sfo3.digitaloceanspaces.com\";\n"],"names":["CONST_APPS_SERVICE_URL","CONST_COMPONENTS_CDN_URL"],"mappings":"AAAO,MAAMA,IACX,yDAGWC,IACX;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAsWA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBAyD/C"}
|
|
@@ -4,7 +4,11 @@ export interface ComponentMetadata {
|
|
|
4
4
|
events: string[];
|
|
5
5
|
jsx: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function generateComponentCode(appId: string, pageId: string, componentName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[], isProduction?: boolean
|
|
7
|
+
export declare function generateComponentCode(appId: string, pageId: string, componentName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[], isProduction?: boolean, pageMeta?: {
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
aspectRatio?: number;
|
|
11
|
+
}): string;
|
|
8
12
|
export declare function generateReadme(appId: string, pageId: string, appName: string, pageName: string, componentName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[]): string;
|
|
9
13
|
export declare function generateComponentMetadata(_appName: string, pageName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[]): ComponentMetadata;
|
|
10
14
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/codegen/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,GAAE,OAAe,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/codegen/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CACnC,KAAK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6vBP,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;AA6jGf,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAoDxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -271,7 +271,15 @@ async function generateWrapper({
|
|
|
271
271
|
forms,
|
|
272
272
|
selectInputs,
|
|
273
273
|
actionButtons,
|
|
274
|
-
!!isProduction
|
|
274
|
+
!!isProduction,
|
|
275
|
+
{
|
|
276
|
+
width: pageData.style?.width,
|
|
277
|
+
height: pageData.style?.height,
|
|
278
|
+
aspectRatio:
|
|
279
|
+
pageData.style?.width && pageData.style?.height
|
|
280
|
+
? pageData.style.width / pageData.style.height
|
|
281
|
+
: undefined,
|
|
282
|
+
}
|
|
275
283
|
);
|
|
276
284
|
|
|
277
285
|
const readmeContent = generateReadme(
|
package/src/codegen/generator.ts
CHANGED
|
@@ -28,7 +28,12 @@ export function generateComponentCode(
|
|
|
28
28
|
forms: FormInfo[],
|
|
29
29
|
selectInputs: SelectInputInfo[],
|
|
30
30
|
actionButtons: ActionButtonInfo[],
|
|
31
|
-
isProduction: boolean = false
|
|
31
|
+
isProduction: boolean = false,
|
|
32
|
+
pageMeta?: {
|
|
33
|
+
width?: number;
|
|
34
|
+
height?: number;
|
|
35
|
+
aspectRatio?: number;
|
|
36
|
+
}
|
|
32
37
|
): string {
|
|
33
38
|
// Generate prop types
|
|
34
39
|
const propTypes: string[] = [];
|
|
@@ -439,6 +444,12 @@ ${dataMapping.join("\n")}
|
|
|
439
444
|
}
|
|
440
445
|
|
|
441
446
|
export default ${componentName};
|
|
447
|
+
|
|
448
|
+
export const PageMeta = {
|
|
449
|
+
width: ${pageMeta?.width ?? "undefined"},
|
|
450
|
+
height: ${pageMeta?.height ?? "undefined"},
|
|
451
|
+
aspectRatio: ${pageMeta?.aspectRatio ?? "undefined"},
|
|
452
|
+
};
|
|
442
453
|
`;
|
|
443
454
|
}
|
|
444
455
|
|
|
@@ -828,7 +828,15 @@ const EncoreApp = ({
|
|
|
828
828
|
overflow: "hidden",
|
|
829
829
|
}}
|
|
830
830
|
>
|
|
831
|
-
<div
|
|
831
|
+
<div
|
|
832
|
+
ref={contentWrapperRef}
|
|
833
|
+
style={{
|
|
834
|
+
width: "100%",
|
|
835
|
+
height: "100%",
|
|
836
|
+
display: "flex",
|
|
837
|
+
flexDirection: "column",
|
|
838
|
+
}}
|
|
839
|
+
>
|
|
832
840
|
<Suspense fallback={fallback || <div />}>
|
|
833
841
|
<EncoreComponentIdContext.Provider value={{ componentId }}>
|
|
834
842
|
<EncoreActionContext.Provider value={{ onAction }}>
|
package/src/components.tsx
CHANGED
|
@@ -136,12 +136,7 @@ const useEncoreStyle = (
|
|
|
136
136
|
|
|
137
137
|
if (!style) return undefined;
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
const debugIds = [
|
|
141
|
-
"01KB929X1DQJN954WNGF5AH38B", // Slider
|
|
142
|
-
"01KB929X1KK5TX0K8VBNP6ZDPG", // Hero Container
|
|
143
|
-
"01KB929X17VWVF3A2J2DY0KHC5", // Page
|
|
144
|
-
];
|
|
139
|
+
if (!style) return undefined;
|
|
145
140
|
// We don't have 'id' here directly in useEncoreStyle, but we can try to infer or pass it.
|
|
146
141
|
// Actually, let's just log if we see interesting positioning values or if we can pass ID.
|
|
147
142
|
// Since we can't easily pass ID without changing signature, let's add logging in the components themselves.
|
|
@@ -196,10 +191,18 @@ const useEncoreStyle = (
|
|
|
196
191
|
: style.positioning.left;
|
|
197
192
|
|
|
198
193
|
// HEURISTIC: Detect if element should be centered horizontally
|
|
194
|
+
let shouldCenterHorizontally = false;
|
|
195
|
+
|
|
196
|
+
// Explicit valid check from StyleDto
|
|
197
|
+
if (style.horizontalPosition === "center") {
|
|
198
|
+
shouldCenterHorizontally = true;
|
|
199
|
+
}
|
|
200
|
+
|
|
199
201
|
// If element has explicit width that's nearly full-width (>= 95% of container) and left position
|
|
200
202
|
// is in the range 15-35% (which suggests the element should be centered but is
|
|
201
203
|
// currently positioned from its left edge), center it using transform
|
|
202
204
|
if (
|
|
205
|
+
!shouldCenterHorizontally &&
|
|
203
206
|
hasExplicitDimensions &&
|
|
204
207
|
style.layout?.layoutSizingHorizontal === "FIXED" &&
|
|
205
208
|
style.layout?.size?.x
|
|
@@ -250,6 +253,7 @@ const useEncoreStyle = (
|
|
|
250
253
|
result.left = "50%";
|
|
251
254
|
result.right = "auto";
|
|
252
255
|
}
|
|
256
|
+
result.transform = "translateX(-50%)";
|
|
253
257
|
} else {
|
|
254
258
|
if (hasInset) {
|
|
255
259
|
// Preserve original inset if not centering
|
|
@@ -1584,6 +1588,7 @@ const TextComponent: React.FC<ComponentProps> = ({ id, name, nodeData }) => {
|
|
|
1584
1588
|
const styleWithFont = nodeData.fontId
|
|
1585
1589
|
? { ...bravoStyle, fontId: nodeData.fontId }
|
|
1586
1590
|
: bravoStyle;
|
|
1591
|
+
|
|
1587
1592
|
const style = useEncoreStyle(styleWithFont, {
|
|
1588
1593
|
debug: false,
|
|
1589
1594
|
});
|