@tapstack/siteio-react-sdk
Advanced tools
+15
-11
@@ -64,12 +64,2 @@ import * as react_jsx_runtime from 'react/jsx-runtime'; | ||
| } | ||
| interface ProjectData { | ||
| project: { | ||
| id: number; | ||
| public_id: string; | ||
| name: string; | ||
| theme: Theme; | ||
| }; | ||
| pages: PageData[]; | ||
| components: ComponentData[]; | ||
| } | ||
| interface PageData { | ||
@@ -89,2 +79,16 @@ id: number; | ||
| } | ||
| interface ProjectStyles { | ||
| css: string; | ||
| } | ||
| interface ProjectData { | ||
| project: { | ||
| id: number; | ||
| public_id: string; | ||
| name: string; | ||
| theme: Theme; | ||
| }; | ||
| pages: PageData[]; | ||
| components: ComponentData[]; | ||
| styles?: ProjectStyles; | ||
| } | ||
| interface ThemeItem { | ||
@@ -167,2 +171,2 @@ variable: string; | ||
| export { type BaseBlock, type Block, type BooleanExpression, type BooleanOperand, type ComparisonOperator, type ComparisonType, type Component, type ComponentBlock, type ComponentData, type ComponentRegistry, type DefaultComponentBlock, type ElementBlock, type FieldOperand, type LogicalOperatorType, type NAryLogicalOperator, type PageData, PreviewBlockRenderer, type ProjectData, RewebProject, type RewebProjectProps, type RewebSDKConfig, type TextBlock, type Theme, type ThemeItem, type ValueOperand, fetchProject }; | ||
| export { type BaseBlock, type Block, type BooleanExpression, type BooleanOperand, type ComparisonOperator, type ComparisonType, type Component, type ComponentBlock, type ComponentData, type ComponentRegistry, type DefaultComponentBlock, type ElementBlock, type FieldOperand, type LogicalOperatorType, type NAryLogicalOperator, type PageData, PreviewBlockRenderer, type ProjectData, type ProjectStyles, RewebProject, type RewebProjectProps, type RewebSDKConfig, type TextBlock, type Theme, type ThemeItem, type ValueOperand, fetchProject }; |
+15
-11
@@ -64,12 +64,2 @@ import * as react_jsx_runtime from 'react/jsx-runtime'; | ||
| } | ||
| interface ProjectData { | ||
| project: { | ||
| id: number; | ||
| public_id: string; | ||
| name: string; | ||
| theme: Theme; | ||
| }; | ||
| pages: PageData[]; | ||
| components: ComponentData[]; | ||
| } | ||
| interface PageData { | ||
@@ -89,2 +79,16 @@ id: number; | ||
| } | ||
| interface ProjectStyles { | ||
| css: string; | ||
| } | ||
| interface ProjectData { | ||
| project: { | ||
| id: number; | ||
| public_id: string; | ||
| name: string; | ||
| theme: Theme; | ||
| }; | ||
| pages: PageData[]; | ||
| components: ComponentData[]; | ||
| styles?: ProjectStyles; | ||
| } | ||
| interface ThemeItem { | ||
@@ -167,2 +171,2 @@ variable: string; | ||
| export { type BaseBlock, type Block, type BooleanExpression, type BooleanOperand, type ComparisonOperator, type ComparisonType, type Component, type ComponentBlock, type ComponentData, type ComponentRegistry, type DefaultComponentBlock, type ElementBlock, type FieldOperand, type LogicalOperatorType, type NAryLogicalOperator, type PageData, PreviewBlockRenderer, type ProjectData, RewebProject, type RewebProjectProps, type RewebSDKConfig, type TextBlock, type Theme, type ThemeItem, type ValueOperand, fetchProject }; | ||
| export { type BaseBlock, type Block, type BooleanExpression, type BooleanOperand, type ComparisonOperator, type ComparisonType, type Component, type ComponentBlock, type ComponentData, type ComponentRegistry, type DefaultComponentBlock, type ElementBlock, type FieldOperand, type LogicalOperatorType, type NAryLogicalOperator, type PageData, PreviewBlockRenderer, type ProjectData, type ProjectStyles, RewebProject, type RewebProjectProps, type RewebSDKConfig, type TextBlock, type Theme, type ThemeItem, type ValueOperand, fetchProject }; |
+135
-8
| 'use strict'; | ||
| var react = require('react'); | ||
| var LucideIcons = require('lucide-react'); | ||
| var jsxRuntime = require('react/jsx-runtime'); | ||
| var clsx = require('clsx'); | ||
| var tailwindMerge = require('tailwind-merge'); | ||
| var jsxRuntime = require('react/jsx-runtime'); | ||
| function _interopNamespace(e) { | ||
| if (e && e.__esModule) return e; | ||
| var n = Object.create(null); | ||
| if (e) { | ||
| Object.keys(e).forEach(function (k) { | ||
| if (k !== 'default') { | ||
| var d = Object.getOwnPropertyDescriptor(e, k); | ||
| Object.defineProperty(n, k, d.get ? d : { | ||
| enumerable: true, | ||
| get: function () { return e[k]; } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| n.default = e; | ||
| return Object.freeze(n); | ||
| } | ||
| var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons); | ||
| // src/utils/fetchProject.ts | ||
@@ -28,2 +49,22 @@ async function fetchProject({ | ||
| } | ||
| var Icon = react.forwardRef( | ||
| ({ name, size = 24, className, strokeWidth, ...props }, ref) => { | ||
| const IconComponent = LucideIcons__namespace[name]; | ||
| if (!IconComponent) { | ||
| console.warn(`[SiteIO SDK] Icon "${name}" not found in lucide-react`); | ||
| return /* @__PURE__ */ jsxRuntime.jsx("span", { className, style: { width: size, height: size } }); | ||
| } | ||
| return /* @__PURE__ */ jsxRuntime.jsx( | ||
| IconComponent, | ||
| { | ||
| ref, | ||
| size, | ||
| className, | ||
| strokeWidth, | ||
| ...props | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
| Icon.displayName = "Icon"; | ||
@@ -43,2 +84,5 @@ // src/utils/blockUtils.ts | ||
| } | ||
| var SDK_BUILT_IN_COMPONENTS = { | ||
| Icon | ||
| }; | ||
| var DEFAULT_COMPONENT_TAGS = { | ||
@@ -52,2 +96,12 @@ Button: "button", | ||
| Separator: "hr", | ||
| Badge: "span", | ||
| Card: "div", | ||
| CardContent: "div", | ||
| CardHeader: "div", | ||
| CardTitle: "h3", | ||
| CardDescription: "p", | ||
| CardFooter: "div", | ||
| Avatar: "span", | ||
| AvatarImage: "img", | ||
| AvatarFallback: "span", | ||
| Table: "table", | ||
@@ -112,2 +166,5 @@ TableHeader: "thead", | ||
| if (isDefaultComponentBlock(block)) { | ||
| if (SDK_BUILT_IN_COMPONENTS[block.component]) { | ||
| return SDK_BUILT_IN_COMPONENTS[block.component]; | ||
| } | ||
| if (componentRegistry && componentRegistry[block.component]) { | ||
@@ -250,3 +307,5 @@ return componentRegistry[block.component]; | ||
| const { | ||
| // React/Radix props | ||
| asChild, | ||
| // Next.js Image props | ||
| blurDataURL, | ||
@@ -261,2 +320,48 @@ fill, | ||
| srcSet, | ||
| // Framer Motion animation props | ||
| whileHover, | ||
| whileTap, | ||
| whileFocus, | ||
| whileDrag, | ||
| whileInView, | ||
| animate, | ||
| initial, | ||
| exit, | ||
| transition, | ||
| variants, | ||
| layout, | ||
| layoutId, | ||
| drag, | ||
| dragConstraints, | ||
| dragElastic, | ||
| dragMomentum, | ||
| dragTransition, | ||
| dragPropagation, | ||
| dragControls, | ||
| dragListener, | ||
| dragSnapToOrigin, | ||
| onDrag, | ||
| onDragStart, | ||
| onDragEnd, | ||
| onDirectionLock, | ||
| onDragTransitionEnd, | ||
| onAnimationStart, | ||
| onAnimationComplete, | ||
| onUpdate, | ||
| onPan, | ||
| onPanStart, | ||
| onPanEnd, | ||
| onTap, | ||
| onTapStart, | ||
| onTapCancel, | ||
| onHoverStart, | ||
| onHoverEnd, | ||
| onViewportEnter, | ||
| onViewportLeave, | ||
| viewport, | ||
| custom, | ||
| inherit, | ||
| // Other non-DOM props that might leak through | ||
| motionValue, | ||
| transformTemplate, | ||
| ...clean | ||
@@ -350,18 +455,26 @@ } = p ?? {}; | ||
| const fontFamily = `"${font.value}"`; | ||
| styles.push(` ${font.variable}: ${fontFamily};`); | ||
| styles.push(` ${font.variable}: ${fontFamily} !important;`); | ||
| }); | ||
| styles.push(` --radius: ${theme.borderRadius}rem;`); | ||
| styles.push(` --radius: ${theme.borderRadius}rem !important;`); | ||
| Object.values(theme.colors).forEach((color) => { | ||
| styles.push(` ${color.variable}: ${color.value};`); | ||
| styles.push(` ${color.variable}: ${color.value} !important;`); | ||
| }); | ||
| return `:root { | ||
| const scopedStyles = styles.map((s) => s.replace(" !important", "")); | ||
| return ` | ||
| /* SiteIO Theme Variables - Global scope for CSS variable inheritance */ | ||
| :root { | ||
| ${styles.join("\n")} | ||
| } | ||
| /* SiteIO Theme Variables - Scoped to SDK component */ | ||
| [data-siteio-theme] { | ||
| ${styles.join("\n")} | ||
| } | ||
| /* Ensure child elements also have access to variables */ | ||
| [data-siteio-theme] * { | ||
| ${styles.join("\n")} | ||
| }`; | ||
| ${scopedStyles.join("\n")} | ||
| } | ||
| `.trim(); | ||
| } | ||
| async function RewebProject({ | ||
@@ -411,4 +524,18 @@ projectId, | ||
| const themeStyles = applyThemeToStyleTag(data.project.theme); | ||
| const projectCss = data.styles?.css ?? ""; | ||
| const debugInfo = ` | ||
| /* SiteIO SDK Debug Info: | ||
| * Theme colors count: ${Object.keys(data.project.theme?.colors || {}).length} | ||
| * Project CSS length: ${projectCss.length} chars | ||
| * Theme styles length: ${themeStyles.length} chars | ||
| */`; | ||
| return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ | ||
| /* @__PURE__ */ jsxRuntime.jsx("style", { dangerouslySetInnerHTML: { __html: themeStyles } }), | ||
| /* @__PURE__ */ jsxRuntime.jsx( | ||
| "style", | ||
| { | ||
| "data-siteio-theme-styles": true, | ||
| dangerouslySetInnerHTML: { __html: debugInfo + "\n" + themeStyles } | ||
| } | ||
| ), | ||
| projectCss ? /* @__PURE__ */ jsxRuntime.jsx("style", { "data-siteio-project-css": true, dangerouslySetInnerHTML: { __html: projectCss } }) : null, | ||
| /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-siteio-theme": true, children: currentPage.blocks.map((block) => /* @__PURE__ */ jsxRuntime.jsx( | ||
@@ -415,0 +542,0 @@ PreviewBlockRenderer, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/utils/fetchProject.ts","../src/utils/blockUtils.ts","../src/utils/booleanExpressions.ts","../src/utils/propsUtils.ts","../src/utils/cn.ts","../src/components/PreviewBlockRenderer.tsx","../src/utils/theme.ts","../src/components/RewebProject.tsx"],"names":["twMerge","clsx","forwardRef","jsx","Fragment","component","jsxs"],"mappings":";;;;;;;;AAQA,eAAsB,YAAA,CAAa;AAAA,EACjC,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAS,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,SAAS,MAAA,GAAS;AACpE,CAAA,E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AAG,CAAA;AAAA,oBACzDA,cAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAsB,mBAAA,EAAiB,IAAA,EACzC,QAAA,EAAA,WAAA,CAAY,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,qBACvBA,cAAAA;AAAA,MAAC,oBAAA;AAAA,MAAA;AAAA,QAEC,KAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,KAAA,CAAM;AAAA,KAKd,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"index.js","sourcesContent":["import { ProjectData } from \"../types\";\n\nexport interface FetchProjectOptions {\n projectId: string;\n token: string;\n apiUrl?: string;\n}\n\nexport async function fetchProject({\n projectId,\n token,\n apiUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost:3000\",\n}: FetchProjectOptions): Promise<ProjectData> {\n const url = new URL(`${apiUrl}/api/project/${projectId}`);\n url.searchParams.set(\"token\", token);\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: \"Unknown error\" }));\n throw new Error(error.error || `Failed to fetch project: ${response.statusText}`);\n }\n\n return response.json();\n}\n\n\n\n\n","import { Block, ElementBlock, DefaultComponentBlock, TextBlock, ComponentBlock, ComponentRegistry } from \"../types\";\n\nexport function isTextBlock(block: Block): block is TextBlock {\n return block.type === \"text\";\n}\n\nexport function isElementBlock(block: Block): block is ElementBlock {\n return block.type === \"element\";\n}\n\nexport function isDefaultComponentBlock(block: Block): block is DefaultComponentBlock {\n return block.type === \"component\";\n}\n\nexport function isComponentBlock(block: Block): block is ComponentBlock {\n return block.type === \"custom-component\";\n}\n\n/**\n * Default fallback tags for components when no registry is provided.\n * Maps component names to semantic HTML elements.\n */\nconst DEFAULT_COMPONENT_TAGS: Record<string, keyof JSX.IntrinsicElements> = {\n Button: \"button\",\n Link: \"a\",\n Image: \"img\",\n Input: \"input\",\n Textarea: \"textarea\",\n Label: \"label\",\n Separator: \"hr\",\n Table: \"table\",\n TableHeader: \"thead\",\n TableBody: \"tbody\",\n TableFooter: \"tfoot\",\n TableRow: \"tr\",\n TableHead: \"th\",\n TableCell: \"td\",\n TableCaption: \"caption\",\n};\n\nexport function getBlockCurrentClassNames(block: Block): string[] {\n const defaultClassNames = block.classNames?.default || [];\n const addedClassNames = block.classNames?.added || [];\n const removedClassNames = block.classNames?.removed || [];\n\n // Start with the default class names\n let currentClassNames = [...defaultClassNames];\n\n // Add the added class names\n currentClassNames = currentClassNames.concat(addedClassNames);\n\n // Remove the removed class names\n currentClassNames = currentClassNames.filter(\n (className) => !removedClassNames.includes(className),\n );\n\n // Return the unique set of class names\n return Array.from(new Set(currentClassNames));\n}\n\nconst VIEWPORT_HEIGHT = 900;\n\nexport function convertVhClassesToPx(classNames: string[]): string[] {\n const viewportHeight = VIEWPORT_HEIGHT;\n\n const vhUnits = [\"vh\", \"dvh\", \"svh\", \"lvh\"];\n const screenClasses = [\"h-screen\", \"h-dvh\", \"h-svh\", \"h-lvh\"];\n\n return classNames.map((className) => {\n // Handle h-screen and similar classes\n const screenMatch = screenClasses.find((sc) => className.includes(sc));\n if (screenMatch) {\n return className.replace(screenMatch, `h-[${viewportHeight}px]`);\n }\n\n // Handle percentage-based vh units\n for (const unit of vhUnits) {\n if (className.includes(unit)) {\n const match = className.match(new RegExp(`(\\\\d+)${unit}`));\n if (match) {\n const value = parseInt(match[1], 10);\n const pxValue = (value / 100) * viewportHeight;\n return className.replace(`${value}${unit}`, `${pxValue}px`);\n }\n }\n }\n\n return className;\n });\n}\n\nexport function getBlockClassnamesToApply(\n block: Block,\n options?: {\n isPreview?: boolean;\n replaceVhClasses?: boolean;\n },\n): string[] {\n const { isPreview = false, replaceVhClasses = true } = options || {};\n let currentClassNames = getBlockCurrentClassNames(block);\n\n if (isPreview) {\n const isLink = isElementBlock(block) && block.tag === \"a\";\n\n if (isLink) {\n currentClassNames = [...currentClassNames, \"cursor-pointer\"];\n }\n }\n\n if (replaceVhClasses) {\n return convertVhClassesToPx(currentClassNames);\n }\n\n return currentClassNames;\n}\n\n/**\n * Gets the tag or component to render for a block.\n * \n * @param block - The block to get the tag for\n * @param componentRegistry - Optional registry of React components\n * @returns A React component, HTML tag name, or undefined\n */\nexport function getBlockTagName(\n block: ElementBlock | DefaultComponentBlock,\n componentRegistry?: ComponentRegistry,\n): React.ComponentType<any> | keyof JSX.IntrinsicElements | undefined {\n if (isDefaultComponentBlock(block)) {\n // First, try to get the component from the registry\n if (componentRegistry && componentRegistry[block.component]) {\n return componentRegistry[block.component];\n }\n \n // Fallback to semantic HTML tags for common components\n if (DEFAULT_COMPONENT_TAGS[block.component]) {\n return DEFAULT_COMPONENT_TAGS[block.component];\n }\n \n // Last resort: render as div\n return \"div\";\n }\n\n return (block.tag as keyof JSX.IntrinsicElements) ?? \"div\";\n}\n\n\n\n\n","import { BooleanExpression, ComparisonOperator, NAryLogicalOperator } from \"../types\";\n\nexport function evaluateExpression(\n expression: BooleanExpression,\n props: Record<string, any>,\n): boolean {\n if (\"type\" in expression && (expression.type === \"and\" || expression.type === \"or\" || expression.type === \"not\")) {\n return evaluateNAryLogicalOperator(expression as NAryLogicalOperator, props);\n }\n\n if (\"type\" in expression && (expression.type === \"eq\" || expression.type === \"neq\")) {\n return evaluateComparisonOperator(expression as ComparisonOperator, props);\n }\n\n return true;\n}\n\nfunction evaluateNAryLogicalOperator(\n operator: NAryLogicalOperator,\n props: Record<string, any>,\n): boolean {\n if (operator.type === \"not\") {\n if (operator.operands.length !== 1) return true;\n return !evaluateExpression(operator.operands[0], props);\n }\n\n if (operator.type === \"and\") {\n return operator.operands.every((operand) => evaluateExpression(operand, props));\n }\n\n if (operator.type === \"or\") {\n return operator.operands.some((operand) => evaluateExpression(operand, props));\n }\n\n return true;\n}\n\nfunction evaluateComparisonOperator(\n operator: ComparisonOperator,\n props: Record<string, any>,\n): boolean {\n const leftValue = getOperandValue(operator.left, props);\n const rightValue = getOperandValue(operator.right, props);\n\n if (operator.type === \"eq\") {\n return leftValue === rightValue;\n }\n\n if (operator.type === \"neq\") {\n return leftValue !== rightValue;\n }\n\n return true;\n}\n\nfunction getOperandValue(operand: { type: string; value: any }, props: Record<string, any>): any {\n if (operand.type === \"field\") {\n return props[operand.value];\n }\n\n if (operand.type === \"value\") {\n return operand.value;\n }\n\n return undefined;\n}\n\n\n\n\n","import { Block, Component, TextBlock } from \"../types\";\nimport { isComponentBlock, isDefaultComponentBlock, isElementBlock } from \"./blockUtils\";\n\nexport interface CurrentComponent {\n id: string;\n props: Record<string, any>;\n propsConfig: Record<string, any>;\n}\n\nfunction isPropValue(value: any): boolean {\n return typeof value === \"string\" && value.startsWith(\"{{\") && value.endsWith(\"}}\");\n}\n\nfunction getPropNameFromValue(value: string): string {\n return value.slice(2, -2).trim();\n}\n\nexport function getBlockText(block: TextBlock, props?: Record<string, any>): string {\n if (block.text.startsWith(\"{\") && props) {\n const propName = block.text.slice(1, -1).replace(\"props.\", \"\");\n return props?.[propName]?.toString() || block.text;\n }\n return block.text;\n}\n\nexport function htmlToText(html: string): string {\n if (typeof window === \"undefined\") return html;\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, \"text/html\");\n return doc.body.textContent || \"\";\n}\n\nexport function getBlockProps(\n block: Block,\n currentComponent: CurrentComponent | null,\n): Record<string, any> {\n const props = { ...block.props };\n if (!currentComponent) return props;\n\n for (const key in props) {\n const value = props[key];\n\n // If a prop is set to the prop of a component, substitute it with the actual value of the component prop\n if (isPropValue(value)) {\n const propName = getPropNameFromValue(value);\n const componentPropValue = currentComponent.props[propName];\n\n if (componentPropValue !== undefined) {\n props[key] = componentPropValue;\n }\n }\n }\n\n return props;\n}\n\nexport function getBlockPropsToApply(\n block: Block,\n currentComponent: CurrentComponent | null,\n options?: {\n isPreview?: boolean;\n },\n): Record<string, any> {\n const { isPreview = false } = options || {};\n\n // If it's the instance of a component, the props don't need to be applied to the component block itself,\n // rather they are handled by the component block renderer.\n const props = isComponentBlock(block) ? {} : getBlockProps(block, currentComponent);\n\n if (!isPreview) {\n // If it's a Link component, set href to \"#\" so it doesn't navigate anywhere\n if (isDefaultComponentBlock(block) && block.component === \"Link\") {\n props.href = \"#\";\n } else {\n // Otherwise, just delete href (for a normal anchor tag)\n delete props.href;\n }\n\n const isButton =\n (isDefaultComponentBlock(block) && block.component === \"Button\") ||\n (isElementBlock(block) && block.tag === \"button\");\n if (isButton) {\n props.type = \"button\";\n }\n }\n\n // Remove React/Next.js-specific props that shouldn't be passed to DOM elements\n // This must happen for both preview and non-preview modes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...domProps\n } = props;\n\n return {\n ...domProps,\n \"data-block-id\": block.id,\n };\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n\n\n\n","import { forwardRef } from \"react\";\nimport { Block, Component, ComponentRegistry } from \"../types\";\nimport {\n isTextBlock,\n isComponentBlock,\n getBlockClassnamesToApply,\n getBlockTagName,\n} from \"../utils/blockUtils\";\nimport { evaluateExpression } from \"../utils/booleanExpressions\";\nimport {\n getBlockProps,\n getBlockPropsToApply,\n getBlockText,\n htmlToText,\n CurrentComponent,\n} from \"../utils/propsUtils\";\nimport { cn } from \"../utils/cn\";\n\ninterface PreviewBlockRendererProps {\n block: Block;\n components?: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[];\n currentComponent?: CurrentComponent | null;\n replaceVhClasses?: boolean;\n className?: string;\n /** Registry of UI components (Button, Card, etc.) for proper rendering */\n componentRegistry?: ComponentRegistry;\n [key: string]: any;\n}\n\nexport const PreviewChildrenRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n ({ block, ...restProps }, ref) => {\n if (!block.children) return null;\n\n if (block.children.length === 1) {\n return <PreviewBlockRenderer block={block.children[0]} ref={ref} {...restProps} />;\n }\n\n return (\n <>\n {block.children.map((child: Block) => (\n <PreviewBlockRenderer key={child.id} block={child} {...restProps} />\n ))}\n </>\n );\n },\n);\n\nPreviewChildrenRenderer.displayName = \"ChildrenRenderer\";\n\nconst stripNonDomProps = (p: Record<string, any>) => {\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...clean\n } = p ?? {};\n return clean;\n};\n\nexport const PreviewBlockRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n (\n {\n block,\n components = [],\n currentComponent,\n replaceVhClasses = false,\n componentRegistry,\n ...rest\n },\n ref,\n ) => {\n const classNamesToApply = getBlockClassnamesToApply(block, {\n isPreview: false, // SSR mode - no preview features\n replaceVhClasses,\n });\n const className = cn(\n // If is text block, don't apply the className from the parent (with asChild), since text blocks normally can't have props at all since they're just text nodes.\n classNamesToApply,\n isTextBlock(block) ? undefined : rest?.className,\n );\n const blockProps = getBlockPropsToApply(block, currentComponent ?? null, {\n isPreview: false, // SSR mode - no preview/client-side features\n });\n\n if (block.renderCondition) {\n const shouldRender = evaluateExpression(block.renderCondition, currentComponent?.props ?? {});\n if (!shouldRender) return null;\n }\n\n if (isTextBlock(block)) {\n return <>{htmlToText(getBlockText(block, currentComponent?.props))}</>;\n }\n\n if (isComponentBlock(block)) {\n const component = components.find(\n (component: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">) =>\n component.id === block.componentId,\n );\n if (!component) return null;\n\n // For nested components, the props could be set to a prop of the outer component\n const currentComponentProps = getBlockProps(block, currentComponent ?? null);\n const innerCurrentComponent: CurrentComponent = {\n id: component.id,\n props: currentComponentProps,\n propsConfig: component.propsConfig,\n };\n\n return (\n <PreviewBlockRenderer\n block={component.blocks[0]}\n components={components}\n currentComponent={innerCurrentComponent}\n componentRegistry={componentRegistry}\n className={className}\n />\n );\n }\n\n const Tag = getBlockTagName(block, componentRegistry);\n if (!Tag) return null;\n\n const mergedProps: Record<string, any> = {\n // ...rest shouldn't be passed to text blocks because they normally can't have props at all since they're just text nodes.\n ...(isTextBlock(block) ? {} : rest),\n className,\n // blockProps Needs to be after ...rest to override the props passed from a parent component (e.g. data-block-id). (for child of asChild component)\n ...blockProps,\n ref,\n };\n\n // In SSR mode, links work normally - no client-side navigation needed\n // Remove onClick handlers that would require client-side code\n\n // Only strip non-DOM props when Tag is a real DOM element (string), not a React component\n const finalProps = typeof Tag === \"string\" ? stripNonDomProps(mergedProps) : mergedProps;\n\n if (!block.children?.length) {\n return <Tag {...finalProps} />;\n }\n\n return (\n <Tag {...finalProps}>\n <PreviewChildrenRenderer\n block={block}\n components={components}\n currentComponent={currentComponent}\n componentRegistry={componentRegistry}\n />\n </Tag>\n );\n },\n);\n\nPreviewBlockRenderer.displayName = \"BlockRenderer\";\n","import { Theme, ThemeItem } from \"../types\";\n\nexport function applyFontsToDocument(document: Document, fonts: ThemeItem[]) {\n const root = document.documentElement;\n const head = document.head;\n\n // Simple implementation - in production you'd want to handle Google Fonts and local fonts\n fonts.forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n root.style.setProperty(font.variable, fontFamily);\n });\n}\n\nexport function applyColorToDocument(document: Document, color: ThemeItem) {\n document.documentElement.style.setProperty(color.variable, color.value);\n}\n\nexport function applyBorderRadiusToDocument(document: Document, borderRadius: number) {\n document.documentElement.style.setProperty(\"--radius\", `${borderRadius}rem`);\n}\n\nexport function applyThemeToDocument(document: Document, theme: Theme) {\n applyFontsToDocument(document, Object.values(theme.fonts));\n applyBorderRadiusToDocument(document, theme.borderRadius);\n Object.values(theme.colors).forEach((color) => applyColorToDocument(document, color));\n}\n\n/**\n * Generate CSS styles for theme that can be injected into a style tag for SSR.\n * This is a pure function that works on the server.\n * Uses scoped selectors to ensure SiteIO theme variables take precedence over project theme.\n */\nexport function applyThemeToStyleTag(theme: Theme): string {\n const styles: string[] = [];\n\n // Apply fonts\n Object.values(theme.fonts).forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n styles.push(` ${font.variable}: ${fontFamily};`);\n });\n\n // Apply border radius\n styles.push(` --radius: ${theme.borderRadius}rem;`);\n\n // Apply colors - SiteIO uses HSL format (e.g., \"250 93% 66%\")\n Object.values(theme.colors).forEach((color) => {\n styles.push(` ${color.variable}: ${color.value};`);\n });\n\n // Use :root with higher specificity by placing it after other styles\n // Also add scoped selector to ensure variables work within SiteIO component\n // The order matters - this style tag should be injected after the project's global CSS\n return `:root {\\n${styles.join(\"\\n\")}\\n}\\n[data-siteio-theme] {\\n${styles.join(\"\\n\")}\\n}\\n[data-siteio-theme] * {\\n${styles.join(\"\\n\")}\\n}`;\n}\n\n\n\n\n","import { fetchProject } from \"../utils/fetchProject\";\nimport { PreviewBlockRenderer } from \"./PreviewBlockRenderer\";\nimport { RewebProjectProps, Component, ProjectData } from \"../types\";\nimport { applyThemeToStyleTag } from \"../utils/theme\";\n\n/**\n * Pure SSR server component that fetches and renders project data on the server.\n * No client-side JavaScript required - works entirely in SSR mode.\n */\nexport async function RewebProject({\n projectId,\n token,\n initialPageId,\n config,\n className,\n componentRegistry,\n}: RewebProjectProps) {\n // Fetch data on the server\n let data: ProjectData;\n let error: Error | null = null;\n\n try {\n data = await fetchProject({\n projectId,\n token,\n apiUrl: config?.apiUrl,\n });\n } catch (err) {\n error = err instanceof Error ? err : new Error(\"Failed to fetch project\");\n // Return error UI - this will be rendered on server\n return (\n <div className={className}>\n <div>Error: {error.message}</div>\n </div>\n );\n }\n\n // Determine which page to render\n let currentPageId = initialPageId;\n if (!currentPageId) {\n // Find home page (url === \"/\")\n const homePage = data.pages.find((page) => page.url === \"/\");\n if (homePage) {\n currentPageId = homePage.public_id;\n } else if (data.pages.length > 0) {\n currentPageId = data.pages[0].public_id;\n }\n }\n\n const currentPage = data.pages.find((page) => page.public_id === currentPageId);\n if (!currentPage) {\n return (\n <div className={className}>\n <div>Page not found</div>\n </div>\n );\n }\n\n // Prepare components data\n const components: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[] = data.components.map(\n (component) => ({\n id: component.public_id,\n blocks: component.blocks,\n propsConfig: component.props_config,\n }),\n );\n\n // Generate theme styles for SSR\n const themeStyles = applyThemeToStyleTag(data.project.theme);\n\n return (\n <>\n {/* Inject theme styles for SSR - scoped to SiteIO component */}\n <style dangerouslySetInnerHTML={{ __html: themeStyles }} />\n <div className={className} data-siteio-theme>\n {currentPage.blocks.map((block) => (\n <PreviewBlockRenderer\n key={block.id}\n block={block}\n components={components}\n componentRegistry={componentRegistry}\n />\n ))}\n </div>\n </>\n );\n}\n"]} | ||
| {"version":3,"sources":["../src/utils/fetchProject.ts","../src/components/Icon.tsx","../src/utils/blockUtils.ts","../src/utils/booleanExpressions.ts","../src/utils/propsUtils.ts","../src/utils/cn.ts","../src/components/PreviewBlockRenderer.tsx","../src/utils/theme.ts","../src/components/RewebProject.tsx"],"names":["forwardRef","LucideIcons","jsx","twMerge","clsx","Fragment","component","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,eAAsB,YAAA,CAAa;AAAA,EACjC,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAS,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,SAAS,MAAA,GAAS;AACpE,CAAA,EAA8C;AAC5C,EAAA,MAAM,MAAM,IAAI,GAAA,CAAI,GAAG,MAAM,CAAA,aAAA,EAAgB,SAAS,CAAA,CAAE,CAAA;AACxD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AAEnC,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,UAAS,EAAG;AAAA,IAC3C,MAAA,EAAQ,KAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB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AAA,QAEC,KAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,KAAA,CAAM;AAAA,KAKd,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"index.js","sourcesContent":["import { ProjectData } from \"../types\";\n\nexport interface FetchProjectOptions {\n projectId: string;\n token: string;\n apiUrl?: string;\n}\n\nexport async function fetchProject({\n projectId,\n token,\n apiUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost:3000\",\n}: FetchProjectOptions): Promise<ProjectData> {\n const url = new URL(`${apiUrl}/api/project/${projectId}`);\n url.searchParams.set(\"token\", token);\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: \"Unknown error\" }));\n throw new Error(error.error || `Failed to fetch project: ${response.statusText}`);\n }\n\n return response.json();\n}\n\n\n\n\n","import * as LucideIcons from \"lucide-react\";\nimport { forwardRef } from \"react\";\n\ninterface IconProps {\n name: string;\n size?: number;\n className?: string;\n strokeWidth?: number;\n [key: string]: any;\n}\n\n/**\n * Dynamic icon component that renders Lucide React icons by name.\n * This allows the SDK to render any icon used in the SiteIO builder.\n */\nexport const Icon = forwardRef<SVGSVGElement, IconProps>(\n ({ name, size = 24, className, strokeWidth, ...props }, ref) => {\n // Get the icon component from Lucide\n const IconComponent = (LucideIcons as Record<string, any>)[name];\n\n if (!IconComponent) {\n // Return empty span if icon not found to avoid breaking the layout\n console.warn(`[SiteIO SDK] Icon \"${name}\" not found in lucide-react`);\n return <span className={className} style={{ width: size, height: size }} />;\n }\n\n return (\n <IconComponent\n ref={ref}\n size={size}\n className={className}\n strokeWidth={strokeWidth}\n {...props}\n />\n );\n },\n);\n\nIcon.displayName = \"Icon\";\n","import { Icon } from \"../components/Icon\";\nimport {\n Block,\n ElementBlock,\n DefaultComponentBlock,\n TextBlock,\n ComponentBlock,\n ComponentRegistry,\n} from \"../types\";\n\nexport function isTextBlock(block: Block): block is TextBlock {\n return block.type === \"text\";\n}\n\nexport function isElementBlock(block: Block): block is ElementBlock {\n return block.type === \"element\";\n}\n\nexport function isDefaultComponentBlock(block: Block): block is DefaultComponentBlock {\n return block.type === \"component\";\n}\n\nexport function isComponentBlock(block: Block): block is ComponentBlock {\n return block.type === \"custom-component\";\n}\n\n/**\n * Built-in SDK components that are always available.\n * These don't require the user to install any additional packages.\n */\nexport const SDK_BUILT_IN_COMPONENTS: ComponentRegistry = {\n Icon,\n};\n\n/**\n * Default fallback tags for components when no registry is provided.\n * Maps component names to semantic HTML elements.\n * Note: These are FALLBACKS - the actual styling comes from the compiled CSS.\n */\nconst DEFAULT_COMPONENT_TAGS: Record<string, keyof JSX.IntrinsicElements> = {\n Button: \"button\",\n Link: \"a\",\n Image: \"img\",\n Input: \"input\",\n Textarea: \"textarea\",\n Label: \"label\",\n Separator: \"hr\",\n Badge: \"span\",\n Card: \"div\",\n CardContent: \"div\",\n CardHeader: \"div\",\n CardTitle: \"h3\",\n CardDescription: \"p\",\n CardFooter: \"div\",\n Avatar: \"span\",\n AvatarImage: \"img\",\n AvatarFallback: \"span\",\n Table: \"table\",\n TableHeader: \"thead\",\n TableBody: \"tbody\",\n TableFooter: \"tfoot\",\n TableRow: \"tr\",\n TableHead: \"th\",\n TableCell: \"td\",\n TableCaption: \"caption\",\n};\n\nexport function getBlockCurrentClassNames(block: Block): string[] {\n const defaultClassNames = block.classNames?.default || [];\n const addedClassNames = block.classNames?.added || [];\n const removedClassNames = block.classNames?.removed || [];\n\n // Start with the default class names\n let currentClassNames = [...defaultClassNames];\n\n // Add the added class names\n currentClassNames = currentClassNames.concat(addedClassNames);\n\n // Remove the removed class names\n currentClassNames = currentClassNames.filter(\n (className) => !removedClassNames.includes(className),\n );\n\n // Return the unique set of class names\n return Array.from(new Set(currentClassNames));\n}\n\nconst VIEWPORT_HEIGHT = 900;\n\nexport function convertVhClassesToPx(classNames: string[]): string[] {\n const viewportHeight = VIEWPORT_HEIGHT;\n\n const vhUnits = [\"vh\", \"dvh\", \"svh\", \"lvh\"];\n const screenClasses = [\"h-screen\", \"h-dvh\", \"h-svh\", \"h-lvh\"];\n\n return classNames.map((className) => {\n // Handle h-screen and similar classes\n const screenMatch = screenClasses.find((sc) => className.includes(sc));\n if (screenMatch) {\n return className.replace(screenMatch, `h-[${viewportHeight}px]`);\n }\n\n // Handle percentage-based vh units\n for (const unit of vhUnits) {\n if (className.includes(unit)) {\n const match = className.match(new RegExp(`(\\\\d+)${unit}`));\n if (match) {\n const value = parseInt(match[1], 10);\n const pxValue = (value / 100) * viewportHeight;\n return className.replace(`${value}${unit}`, `${pxValue}px`);\n }\n }\n }\n\n return className;\n });\n}\n\nexport function getBlockClassnamesToApply(\n block: Block,\n options?: {\n isPreview?: boolean;\n replaceVhClasses?: boolean;\n },\n): string[] {\n const { isPreview = false, replaceVhClasses = true } = options || {};\n let currentClassNames = getBlockCurrentClassNames(block);\n\n if (isPreview) {\n const isLink = isElementBlock(block) && block.tag === \"a\";\n\n if (isLink) {\n currentClassNames = [...currentClassNames, \"cursor-pointer\"];\n }\n }\n\n if (replaceVhClasses) {\n return convertVhClassesToPx(currentClassNames);\n }\n\n return currentClassNames;\n}\n\n/**\n * Gets the tag or component to render for a block.\n *\n * @param block - The block to get the tag for\n * @param componentRegistry - Optional registry of React components\n * @returns A React component, HTML tag name, or undefined\n */\nexport function getBlockTagName(\n block: ElementBlock | DefaultComponentBlock,\n componentRegistry?: ComponentRegistry,\n): React.ComponentType<any> | keyof JSX.IntrinsicElements | undefined {\n if (isDefaultComponentBlock(block)) {\n // First, check SDK built-in components (Icon, etc.)\n if (SDK_BUILT_IN_COMPONENTS[block.component]) {\n return SDK_BUILT_IN_COMPONENTS[block.component];\n }\n\n // Then, try to get the component from the user's registry\n if (componentRegistry && componentRegistry[block.component]) {\n return componentRegistry[block.component];\n }\n\n // Fallback to semantic HTML tags for common components\n if (DEFAULT_COMPONENT_TAGS[block.component]) {\n return DEFAULT_COMPONENT_TAGS[block.component];\n }\n\n // Last resort: render as div\n return \"div\";\n }\n\n return (block.tag as keyof JSX.IntrinsicElements) ?? \"div\";\n}\n","import { BooleanExpression, ComparisonOperator, NAryLogicalOperator } from \"../types\";\n\nexport function evaluateExpression(\n expression: BooleanExpression,\n props: Record<string, any>,\n): boolean {\n if (\"type\" in expression && (expression.type === \"and\" || expression.type === \"or\" || expression.type === \"not\")) {\n return evaluateNAryLogicalOperator(expression as NAryLogicalOperator, props);\n }\n\n if (\"type\" in expression && (expression.type === \"eq\" || expression.type === \"neq\")) {\n return evaluateComparisonOperator(expression as ComparisonOperator, props);\n }\n\n return true;\n}\n\nfunction evaluateNAryLogicalOperator(\n operator: NAryLogicalOperator,\n props: Record<string, any>,\n): boolean {\n if (operator.type === \"not\") {\n if (operator.operands.length !== 1) return true;\n return !evaluateExpression(operator.operands[0], props);\n }\n\n if (operator.type === \"and\") {\n return operator.operands.every((operand) => evaluateExpression(operand, props));\n }\n\n if (operator.type === \"or\") {\n return operator.operands.some((operand) => evaluateExpression(operand, props));\n }\n\n return true;\n}\n\nfunction evaluateComparisonOperator(\n operator: ComparisonOperator,\n props: Record<string, any>,\n): boolean {\n const leftValue = getOperandValue(operator.left, props);\n const rightValue = getOperandValue(operator.right, props);\n\n if (operator.type === \"eq\") {\n return leftValue === rightValue;\n }\n\n if (operator.type === \"neq\") {\n return leftValue !== rightValue;\n }\n\n return true;\n}\n\nfunction getOperandValue(operand: { type: string; value: any }, props: Record<string, any>): any {\n if (operand.type === \"field\") {\n return props[operand.value];\n }\n\n if (operand.type === \"value\") {\n return operand.value;\n }\n\n return undefined;\n}\n\n\n\n\n","import { Block, Component, TextBlock } from \"../types\";\nimport { isComponentBlock, isDefaultComponentBlock, isElementBlock } from \"./blockUtils\";\n\nexport interface CurrentComponent {\n id: string;\n props: Record<string, any>;\n propsConfig: Record<string, any>;\n}\n\nfunction isPropValue(value: any): boolean {\n return typeof value === \"string\" && value.startsWith(\"{{\") && value.endsWith(\"}}\");\n}\n\nfunction getPropNameFromValue(value: string): string {\n return value.slice(2, -2).trim();\n}\n\nexport function getBlockText(block: TextBlock, props?: Record<string, any>): string {\n if (block.text.startsWith(\"{\") && props) {\n const propName = block.text.slice(1, -1).replace(\"props.\", \"\");\n return props?.[propName]?.toString() || block.text;\n }\n return block.text;\n}\n\nexport function htmlToText(html: string): string {\n if (typeof window === \"undefined\") return html;\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, \"text/html\");\n return doc.body.textContent || \"\";\n}\n\nexport function getBlockProps(\n block: Block,\n currentComponent: CurrentComponent | null,\n): Record<string, any> {\n const props = { ...block.props };\n if (!currentComponent) return props;\n\n for (const key in props) {\n const value = props[key];\n\n // If a prop is set to the prop of a component, substitute it with the actual value of the component prop\n if (isPropValue(value)) {\n const propName = getPropNameFromValue(value);\n const componentPropValue = currentComponent.props[propName];\n\n if (componentPropValue !== undefined) {\n props[key] = componentPropValue;\n }\n }\n }\n\n return props;\n}\n\nexport function getBlockPropsToApply(\n block: Block,\n currentComponent: CurrentComponent | null,\n options?: {\n isPreview?: boolean;\n },\n): Record<string, any> {\n const { isPreview = false } = options || {};\n\n // If it's the instance of a component, the props don't need to be applied to the component block itself,\n // rather they are handled by the component block renderer.\n const props = isComponentBlock(block) ? {} : getBlockProps(block, currentComponent);\n\n if (!isPreview) {\n // If it's a Link component, set href to \"#\" so it doesn't navigate anywhere\n if (isDefaultComponentBlock(block) && block.component === \"Link\") {\n props.href = \"#\";\n } else {\n // Otherwise, just delete href (for a normal anchor tag)\n delete props.href;\n }\n\n const isButton =\n (isDefaultComponentBlock(block) && block.component === \"Button\") ||\n (isElementBlock(block) && block.tag === \"button\");\n if (isButton) {\n props.type = \"button\";\n }\n }\n\n // Remove React/Next.js-specific props that shouldn't be passed to DOM elements\n // This must happen for both preview and non-preview modes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...domProps\n } = props;\n\n return {\n ...domProps,\n \"data-block-id\": block.id,\n };\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n\n\n\n","import { forwardRef } from \"react\";\nimport { Block, Component, ComponentRegistry } from \"../types\";\nimport {\n isTextBlock,\n isComponentBlock,\n getBlockClassnamesToApply,\n getBlockTagName,\n} from \"../utils/blockUtils\";\nimport { evaluateExpression } from \"../utils/booleanExpressions\";\nimport {\n getBlockProps,\n getBlockPropsToApply,\n getBlockText,\n htmlToText,\n CurrentComponent,\n} from \"../utils/propsUtils\";\nimport { cn } from \"../utils/cn\";\n\ninterface PreviewBlockRendererProps {\n block: Block;\n components?: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[];\n currentComponent?: CurrentComponent | null;\n replaceVhClasses?: boolean;\n className?: string;\n /** Registry of UI components (Button, Card, etc.) for proper rendering */\n componentRegistry?: ComponentRegistry;\n [key: string]: any;\n}\n\nexport const PreviewChildrenRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n ({ block, ...restProps }, ref) => {\n if (!block.children) return null;\n\n if (block.children.length === 1) {\n return <PreviewBlockRenderer block={block.children[0]} ref={ref} {...restProps} />;\n }\n\n return (\n <>\n {block.children.map((child: Block) => (\n <PreviewBlockRenderer key={child.id} block={child} {...restProps} />\n ))}\n </>\n );\n },\n);\n\nPreviewChildrenRenderer.displayName = \"ChildrenRenderer\";\n\n/**\n * Strip props that are not valid DOM attributes.\n * This includes React-specific props, Next.js Image props, and Framer Motion animation props.\n */\nconst stripNonDomProps = (p: Record<string, any>) => {\n const {\n // React/Radix props\n asChild,\n // Next.js Image props\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n // Framer Motion animation props\n whileHover,\n whileTap,\n whileFocus,\n whileDrag,\n whileInView,\n animate,\n initial,\n exit,\n transition,\n variants,\n layout,\n layoutId,\n drag,\n dragConstraints,\n dragElastic,\n dragMomentum,\n dragTransition,\n dragPropagation,\n dragControls,\n dragListener,\n dragSnapToOrigin,\n onDrag,\n onDragStart,\n onDragEnd,\n onDirectionLock,\n onDragTransitionEnd,\n onAnimationStart,\n onAnimationComplete,\n onUpdate,\n onPan,\n onPanStart,\n onPanEnd,\n onTap,\n onTapStart,\n onTapCancel,\n onHoverStart,\n onHoverEnd,\n onViewportEnter,\n onViewportLeave,\n viewport,\n custom,\n inherit,\n // Other non-DOM props that might leak through\n motionValue,\n transformTemplate,\n ...clean\n } = p ?? {};\n return clean;\n};\n\nexport const PreviewBlockRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n (\n {\n block,\n components = [],\n currentComponent,\n replaceVhClasses = false,\n componentRegistry,\n ...rest\n },\n ref,\n ) => {\n const classNamesToApply = getBlockClassnamesToApply(block, {\n isPreview: false, // SSR mode - no preview features\n replaceVhClasses,\n });\n const className = cn(\n // If is text block, don't apply the className from the parent (with asChild), since text blocks normally can't have props at all since they're just text nodes.\n classNamesToApply,\n isTextBlock(block) ? undefined : rest?.className,\n );\n const blockProps = getBlockPropsToApply(block, currentComponent ?? null, {\n isPreview: false, // SSR mode - no preview/client-side features\n });\n\n if (block.renderCondition) {\n const shouldRender = evaluateExpression(block.renderCondition, currentComponent?.props ?? {});\n if (!shouldRender) return null;\n }\n\n if (isTextBlock(block)) {\n return <>{htmlToText(getBlockText(block, currentComponent?.props))}</>;\n }\n\n if (isComponentBlock(block)) {\n const component = components.find(\n (component: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">) =>\n component.id === block.componentId,\n );\n if (!component) return null;\n\n // For nested components, the props could be set to a prop of the outer component\n const currentComponentProps = getBlockProps(block, currentComponent ?? null);\n const innerCurrentComponent: CurrentComponent = {\n id: component.id,\n props: currentComponentProps,\n propsConfig: component.propsConfig,\n };\n\n return (\n <PreviewBlockRenderer\n block={component.blocks[0]}\n components={components}\n currentComponent={innerCurrentComponent}\n componentRegistry={componentRegistry}\n className={className}\n />\n );\n }\n\n const Tag = getBlockTagName(block, componentRegistry);\n if (!Tag) return null;\n\n const mergedProps: Record<string, any> = {\n // ...rest shouldn't be passed to text blocks because they normally can't have props at all since they're just text nodes.\n ...(isTextBlock(block) ? {} : rest),\n className,\n // blockProps Needs to be after ...rest to override the props passed from a parent component (e.g. data-block-id). (for child of asChild component)\n ...blockProps,\n ref,\n };\n\n // In SSR mode, links work normally - no client-side navigation needed\n // Remove onClick handlers that would require client-side code\n\n // Only strip non-DOM props when Tag is a real DOM element (string), not a React component\n const finalProps = typeof Tag === \"string\" ? stripNonDomProps(mergedProps) : mergedProps;\n\n if (!block.children?.length) {\n return <Tag {...finalProps} />;\n }\n\n return (\n <Tag {...finalProps}>\n <PreviewChildrenRenderer\n block={block}\n components={components}\n currentComponent={currentComponent}\n componentRegistry={componentRegistry}\n />\n </Tag>\n );\n },\n);\n\nPreviewBlockRenderer.displayName = \"BlockRenderer\";\n","import { Theme, ThemeItem } from \"../types\";\n\nexport function applyFontsToDocument(document: Document, fonts: ThemeItem[]) {\n const root = document.documentElement;\n const head = document.head;\n\n // Simple implementation - in production you'd want to handle Google Fonts and local fonts\n fonts.forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n root.style.setProperty(font.variable, fontFamily);\n });\n}\n\nexport function applyColorToDocument(document: Document, color: ThemeItem) {\n document.documentElement.style.setProperty(color.variable, color.value);\n}\n\nexport function applyBorderRadiusToDocument(document: Document, borderRadius: number) {\n document.documentElement.style.setProperty(\"--radius\", `${borderRadius}rem`);\n}\n\nexport function applyThemeToDocument(document: Document, theme: Theme) {\n applyFontsToDocument(document, Object.values(theme.fonts));\n applyBorderRadiusToDocument(document, theme.borderRadius);\n Object.values(theme.colors).forEach((color) => applyColorToDocument(document, color));\n}\n\n/**\n * Generate CSS styles for theme that can be injected into a style tag for SSR.\n * This is a pure function that works on the server.\n * Uses scoped selectors to ensure SiteIO theme variables take precedence over project theme.\n */\nexport function applyThemeToStyleTag(theme: Theme): string {\n const styles: string[] = [];\n\n // Apply fonts\n Object.values(theme.fonts).forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n styles.push(` ${font.variable}: ${fontFamily} !important;`);\n });\n\n // Apply border radius\n styles.push(` --radius: ${theme.borderRadius}rem !important;`);\n\n // Apply colors - SiteIO uses HSL format (e.g., \"250 93% 66%\")\n Object.values(theme.colors).forEach((color) => {\n styles.push(` ${color.variable}: ${color.value} !important;`);\n });\n\n // Use high specificity selectors to ensure SiteIO theme variables override consuming app\n // The [data-siteio-theme] attribute is added to the SDK wrapper element\n const scopedStyles = styles.map((s) => s.replace(\" !important\", \"\"));\n\n return `\n/* SiteIO Theme Variables - Global scope for CSS variable inheritance */\n:root {\n${styles.join(\"\\n\")}\n}\n\n/* SiteIO Theme Variables - Scoped to SDK component */\n[data-siteio-theme] {\n${styles.join(\"\\n\")}\n}\n\n/* Ensure child elements also have access to variables */\n[data-siteio-theme] * {\n${scopedStyles.join(\"\\n\")}\n}\n`.trim();\n}\n","import { fetchProject } from \"../utils/fetchProject\";\nimport { PreviewBlockRenderer } from \"./PreviewBlockRenderer\";\nimport { RewebProjectProps, Component, ProjectData } from \"../types\";\nimport { applyThemeToStyleTag } from \"../utils/theme\";\n\n/**\n * Pure SSR server component that fetches and renders project data on the server.\n * No client-side JavaScript required - works entirely in SSR mode.\n */\nexport async function RewebProject({\n projectId,\n token,\n initialPageId,\n config,\n className,\n componentRegistry,\n}: RewebProjectProps) {\n // Fetch data on the server\n let data: ProjectData;\n let error: Error | null = null;\n\n try {\n data = await fetchProject({\n projectId,\n token,\n apiUrl: config?.apiUrl,\n });\n } catch (err) {\n error = err instanceof Error ? err : new Error(\"Failed to fetch project\");\n // Return error UI - this will be rendered on server\n return (\n <div className={className}>\n <div>Error: {error.message}</div>\n </div>\n );\n }\n\n // Determine which page to render\n let currentPageId = initialPageId;\n if (!currentPageId) {\n // Find home page (url === \"/\")\n const homePage = data.pages.find((page) => page.url === \"/\");\n if (homePage) {\n currentPageId = homePage.public_id;\n } else if (data.pages.length > 0) {\n currentPageId = data.pages[0].public_id;\n }\n }\n\n const currentPage = data.pages.find((page) => page.public_id === currentPageId);\n if (!currentPage) {\n return (\n <div className={className}>\n <div>Page not found</div>\n </div>\n );\n }\n\n // Prepare components data\n const components: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[] = data.components.map(\n (component) => ({\n id: component.public_id,\n blocks: component.blocks,\n propsConfig: component.props_config,\n }),\n );\n\n // Generate theme styles for SSR\n const themeStyles = applyThemeToStyleTag(data.project.theme);\n const projectCss = data.styles?.css ?? \"\";\n\n // Debug info (visible in page source)\n const debugInfo = `\n/* SiteIO SDK Debug Info:\n * Theme colors count: ${Object.keys(data.project.theme?.colors || {}).length}\n * Project CSS length: ${projectCss.length} chars\n * Theme styles length: ${themeStyles.length} chars\n */`;\n\n return (\n <>\n {/* Inject theme styles for SSR - scoped to SiteIO component */}\n <style\n data-siteio-theme-styles\n dangerouslySetInnerHTML={{ __html: debugInfo + \"\\n\" + themeStyles }}\n />\n {projectCss ? (\n <style data-siteio-project-css dangerouslySetInnerHTML={{ __html: projectCss }} />\n ) : null}\n <div className={className} data-siteio-theme>\n {currentPage.blocks.map((block) => (\n <PreviewBlockRenderer\n key={block.id}\n block={block}\n components={components}\n componentRegistry={componentRegistry}\n />\n ))}\n </div>\n </>\n );\n}\n"]} |
+115
-8
| import { forwardRef } from 'react'; | ||
| import * as LucideIcons from 'lucide-react'; | ||
| import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; | ||
| import { clsx } from 'clsx'; | ||
| import { twMerge } from 'tailwind-merge'; | ||
| import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; | ||
@@ -26,2 +27,22 @@ // src/utils/fetchProject.ts | ||
| } | ||
| var Icon = forwardRef( | ||
| ({ name, size = 24, className, strokeWidth, ...props }, ref) => { | ||
| const IconComponent = LucideIcons[name]; | ||
| if (!IconComponent) { | ||
| console.warn(`[SiteIO SDK] Icon "${name}" not found in lucide-react`); | ||
| return /* @__PURE__ */ jsx("span", { className, style: { width: size, height: size } }); | ||
| } | ||
| return /* @__PURE__ */ jsx( | ||
| IconComponent, | ||
| { | ||
| ref, | ||
| size, | ||
| className, | ||
| strokeWidth, | ||
| ...props | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
| Icon.displayName = "Icon"; | ||
@@ -41,2 +62,5 @@ // src/utils/blockUtils.ts | ||
| } | ||
| var SDK_BUILT_IN_COMPONENTS = { | ||
| Icon | ||
| }; | ||
| var DEFAULT_COMPONENT_TAGS = { | ||
@@ -50,2 +74,12 @@ Button: "button", | ||
| Separator: "hr", | ||
| Badge: "span", | ||
| Card: "div", | ||
| CardContent: "div", | ||
| CardHeader: "div", | ||
| CardTitle: "h3", | ||
| CardDescription: "p", | ||
| CardFooter: "div", | ||
| Avatar: "span", | ||
| AvatarImage: "img", | ||
| AvatarFallback: "span", | ||
| Table: "table", | ||
@@ -110,2 +144,5 @@ TableHeader: "thead", | ||
| if (isDefaultComponentBlock(block)) { | ||
| if (SDK_BUILT_IN_COMPONENTS[block.component]) { | ||
| return SDK_BUILT_IN_COMPONENTS[block.component]; | ||
| } | ||
| if (componentRegistry && componentRegistry[block.component]) { | ||
@@ -248,3 +285,5 @@ return componentRegistry[block.component]; | ||
| const { | ||
| // React/Radix props | ||
| asChild, | ||
| // Next.js Image props | ||
| blurDataURL, | ||
@@ -259,2 +298,48 @@ fill, | ||
| srcSet, | ||
| // Framer Motion animation props | ||
| whileHover, | ||
| whileTap, | ||
| whileFocus, | ||
| whileDrag, | ||
| whileInView, | ||
| animate, | ||
| initial, | ||
| exit, | ||
| transition, | ||
| variants, | ||
| layout, | ||
| layoutId, | ||
| drag, | ||
| dragConstraints, | ||
| dragElastic, | ||
| dragMomentum, | ||
| dragTransition, | ||
| dragPropagation, | ||
| dragControls, | ||
| dragListener, | ||
| dragSnapToOrigin, | ||
| onDrag, | ||
| onDragStart, | ||
| onDragEnd, | ||
| onDirectionLock, | ||
| onDragTransitionEnd, | ||
| onAnimationStart, | ||
| onAnimationComplete, | ||
| onUpdate, | ||
| onPan, | ||
| onPanStart, | ||
| onPanEnd, | ||
| onTap, | ||
| onTapStart, | ||
| onTapCancel, | ||
| onHoverStart, | ||
| onHoverEnd, | ||
| onViewportEnter, | ||
| onViewportLeave, | ||
| viewport, | ||
| custom, | ||
| inherit, | ||
| // Other non-DOM props that might leak through | ||
| motionValue, | ||
| transformTemplate, | ||
| ...clean | ||
@@ -348,18 +433,26 @@ } = p ?? {}; | ||
| const fontFamily = `"${font.value}"`; | ||
| styles.push(` ${font.variable}: ${fontFamily};`); | ||
| styles.push(` ${font.variable}: ${fontFamily} !important;`); | ||
| }); | ||
| styles.push(` --radius: ${theme.borderRadius}rem;`); | ||
| styles.push(` --radius: ${theme.borderRadius}rem !important;`); | ||
| Object.values(theme.colors).forEach((color) => { | ||
| styles.push(` ${color.variable}: ${color.value};`); | ||
| styles.push(` ${color.variable}: ${color.value} !important;`); | ||
| }); | ||
| return `:root { | ||
| const scopedStyles = styles.map((s) => s.replace(" !important", "")); | ||
| return ` | ||
| /* SiteIO Theme Variables - Global scope for CSS variable inheritance */ | ||
| :root { | ||
| ${styles.join("\n")} | ||
| } | ||
| /* SiteIO Theme Variables - Scoped to SDK component */ | ||
| [data-siteio-theme] { | ||
| ${styles.join("\n")} | ||
| } | ||
| /* Ensure child elements also have access to variables */ | ||
| [data-siteio-theme] * { | ||
| ${styles.join("\n")} | ||
| }`; | ||
| ${scopedStyles.join("\n")} | ||
| } | ||
| `.trim(); | ||
| } | ||
| async function RewebProject({ | ||
@@ -409,4 +502,18 @@ projectId, | ||
| const themeStyles = applyThemeToStyleTag(data.project.theme); | ||
| const projectCss = data.styles?.css ?? ""; | ||
| const debugInfo = ` | ||
| /* SiteIO SDK Debug Info: | ||
| * Theme colors count: ${Object.keys(data.project.theme?.colors || {}).length} | ||
| * Project CSS length: ${projectCss.length} chars | ||
| * Theme styles length: ${themeStyles.length} chars | ||
| */`; | ||
| return /* @__PURE__ */ jsxs(Fragment, { children: [ | ||
| /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: themeStyles } }), | ||
| /* @__PURE__ */ jsx( | ||
| "style", | ||
| { | ||
| "data-siteio-theme-styles": true, | ||
| dangerouslySetInnerHTML: { __html: debugInfo + "\n" + themeStyles } | ||
| } | ||
| ), | ||
| projectCss ? /* @__PURE__ */ jsx("style", { "data-siteio-project-css": true, dangerouslySetInnerHTML: { __html: projectCss } }) : null, | ||
| /* @__PURE__ */ jsx("div", { className, "data-siteio-theme": true, children: currentPage.blocks.map((block) => /* @__PURE__ */ jsx( | ||
@@ -413,0 +520,0 @@ PreviewBlockRenderer, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/utils/fetchProject.ts","../src/utils/blockUtils.ts","../src/utils/booleanExpressions.ts","../src/utils/propsUtils.ts","../src/utils/cn.ts","../src/components/PreviewBlockRenderer.tsx","../src/utils/theme.ts","../src/components/RewebProject.tsx"],"names":["component","jsx","Fragment"],"mappings":";;;;;;AAQA,eAAsB,YAAA,CAAa;AAAA,EACjC,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAS,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,SAAS,MAAA,GAAS;AACpE,CAAA,EAA8C;AAC5C,EAAA,MAAM,MAAM,IAAI,GAAA,CAAI,GAAG,MAAM,CAAA,aAAA,EAAgB,SAAS,CAAA,CAAE,CAAA;AACxD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AAEnC,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,UAAS,EAAG;AAAA,IAC3C,MAAA,EAAQ,KAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;A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AS,CAAA,EAAG;AAChC,MAAA,aAAA,GAAgB,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA,CAAE,SAAA;AAAA,IAChC;AAAA,EACF;AAEA,EAAA,MAAM,WAAA,GAAc,KAAK,KAAA,CAAM,IAAA,CAAK,CAAC,IAAA,KAAS,IAAA,CAAK,cAAc,aAAa,CAAA;AAC9E,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,uBACEA,IAAC,KAAA,EAAA,EAAI,SAAA,EACH,0BAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,4BAAc,CAAA,EACrB,CAAA;AAAA,EAEJ;AAGA,EAAA,MAAM,UAAA,GAAiE,KAAK,UAAA,CAAW,GAAA;AAAA,IACrF,CAAC,SAAA,MAAe;AAAA,MACd,IAAI,SAAA,CAAU,SAAA;AAAA,MACd,QAAQ,SAAA,CAAU,MAAA;AAAA,MAClB,aAAa,SAAA,CAAU;AAAA,KACzB;AAAA,GACF;AAGA,EAAA,MAAM,WAAA,GAAc,oBAAA,CAAqB,IAAA,CAAK,OAAA,CAAQ,KAAK,CAAA;AAE3D,EAAA,uBACE,IAAA,CAAAC,UAAA,EAEE,QAAA,EAAA;AAAA,oBAAAD,IAAC,OAAA,EAAA,EAAM,uBAAA,EAAyB,EAAE,MAAA,EAAQ,aAAY,EAAG,CAAA;AAAA,oBACzDA,GAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAsB,mBAAA,EAAiB,IAAA,EACzC,QAAA,EAAA,WAAA,CAAY,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,qBACvBA,GAAAA;AAAA,MAAC,oBAAA;AAAA,MAAA;AAAA,QAEC,KAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,KAAA,CAAM;AAAA,KAKd,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"index.mjs","sourcesContent":["import { ProjectData } from \"../types\";\n\nexport interface FetchProjectOptions {\n projectId: string;\n token: string;\n apiUrl?: string;\n}\n\nexport async function fetchProject({\n projectId,\n token,\n apiUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost:3000\",\n}: FetchProjectOptions): Promise<ProjectData> {\n const url = new URL(`${apiUrl}/api/project/${projectId}`);\n url.searchParams.set(\"token\", token);\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: \"Unknown error\" }));\n throw new Error(error.error || `Failed to fetch project: ${response.statusText}`);\n }\n\n return response.json();\n}\n\n\n\n\n","import { Block, ElementBlock, DefaultComponentBlock, TextBlock, ComponentBlock, ComponentRegistry } from \"../types\";\n\nexport function isTextBlock(block: Block): block is TextBlock {\n return block.type === \"text\";\n}\n\nexport function isElementBlock(block: Block): block is ElementBlock {\n return block.type === \"element\";\n}\n\nexport function isDefaultComponentBlock(block: Block): block is DefaultComponentBlock {\n return block.type === \"component\";\n}\n\nexport function isComponentBlock(block: Block): block is ComponentBlock {\n return block.type === \"custom-component\";\n}\n\n/**\n * Default fallback tags for components when no registry is provided.\n * Maps component names to semantic HTML elements.\n */\nconst DEFAULT_COMPONENT_TAGS: Record<string, keyof JSX.IntrinsicElements> = {\n Button: \"button\",\n Link: \"a\",\n Image: \"img\",\n Input: \"input\",\n Textarea: \"textarea\",\n Label: \"label\",\n Separator: \"hr\",\n Table: \"table\",\n TableHeader: \"thead\",\n TableBody: \"tbody\",\n TableFooter: \"tfoot\",\n TableRow: \"tr\",\n TableHead: \"th\",\n TableCell: \"td\",\n TableCaption: \"caption\",\n};\n\nexport function getBlockCurrentClassNames(block: Block): string[] {\n const defaultClassNames = block.classNames?.default || [];\n const addedClassNames = block.classNames?.added || [];\n const removedClassNames = block.classNames?.removed || [];\n\n // Start with the default class names\n let currentClassNames = [...defaultClassNames];\n\n // Add the added class names\n currentClassNames = currentClassNames.concat(addedClassNames);\n\n // Remove the removed class names\n currentClassNames = currentClassNames.filter(\n (className) => !removedClassNames.includes(className),\n );\n\n // Return the unique set of class names\n return Array.from(new Set(currentClassNames));\n}\n\nconst VIEWPORT_HEIGHT = 900;\n\nexport function convertVhClassesToPx(classNames: string[]): string[] {\n const viewportHeight = VIEWPORT_HEIGHT;\n\n const vhUnits = [\"vh\", \"dvh\", \"svh\", \"lvh\"];\n const screenClasses = [\"h-screen\", \"h-dvh\", \"h-svh\", \"h-lvh\"];\n\n return classNames.map((className) => {\n // Handle h-screen and similar classes\n const screenMatch = screenClasses.find((sc) => className.includes(sc));\n if (screenMatch) {\n return className.replace(screenMatch, `h-[${viewportHeight}px]`);\n }\n\n // Handle percentage-based vh units\n for (const unit of vhUnits) {\n if (className.includes(unit)) {\n const match = className.match(new RegExp(`(\\\\d+)${unit}`));\n if (match) {\n const value = parseInt(match[1], 10);\n const pxValue = (value / 100) * viewportHeight;\n return className.replace(`${value}${unit}`, `${pxValue}px`);\n }\n }\n }\n\n return className;\n });\n}\n\nexport function getBlockClassnamesToApply(\n block: Block,\n options?: {\n isPreview?: boolean;\n replaceVhClasses?: boolean;\n },\n): string[] {\n const { isPreview = false, replaceVhClasses = true } = options || {};\n let currentClassNames = getBlockCurrentClassNames(block);\n\n if (isPreview) {\n const isLink = isElementBlock(block) && block.tag === \"a\";\n\n if (isLink) {\n currentClassNames = [...currentClassNames, \"cursor-pointer\"];\n }\n }\n\n if (replaceVhClasses) {\n return convertVhClassesToPx(currentClassNames);\n }\n\n return currentClassNames;\n}\n\n/**\n * Gets the tag or component to render for a block.\n * \n * @param block - The block to get the tag for\n * @param componentRegistry - Optional registry of React components\n * @returns A React component, HTML tag name, or undefined\n */\nexport function getBlockTagName(\n block: ElementBlock | DefaultComponentBlock,\n componentRegistry?: ComponentRegistry,\n): React.ComponentType<any> | keyof JSX.IntrinsicElements | undefined {\n if (isDefaultComponentBlock(block)) {\n // First, try to get the component from the registry\n if (componentRegistry && componentRegistry[block.component]) {\n return componentRegistry[block.component];\n }\n \n // Fallback to semantic HTML tags for common components\n if (DEFAULT_COMPONENT_TAGS[block.component]) {\n return DEFAULT_COMPONENT_TAGS[block.component];\n }\n \n // Last resort: render as div\n return \"div\";\n }\n\n return (block.tag as keyof JSX.IntrinsicElements) ?? \"div\";\n}\n\n\n\n\n","import { BooleanExpression, ComparisonOperator, NAryLogicalOperator } from \"../types\";\n\nexport function evaluateExpression(\n expression: BooleanExpression,\n props: Record<string, any>,\n): boolean {\n if (\"type\" in expression && (expression.type === \"and\" || expression.type === \"or\" || expression.type === \"not\")) {\n return evaluateNAryLogicalOperator(expression as NAryLogicalOperator, props);\n }\n\n if (\"type\" in expression && (expression.type === \"eq\" || expression.type === \"neq\")) {\n return evaluateComparisonOperator(expression as ComparisonOperator, props);\n }\n\n return true;\n}\n\nfunction evaluateNAryLogicalOperator(\n operator: NAryLogicalOperator,\n props: Record<string, any>,\n): boolean {\n if (operator.type === \"not\") {\n if (operator.operands.length !== 1) return true;\n return !evaluateExpression(operator.operands[0], props);\n }\n\n if (operator.type === \"and\") {\n return operator.operands.every((operand) => evaluateExpression(operand, props));\n }\n\n if (operator.type === \"or\") {\n return operator.operands.some((operand) => evaluateExpression(operand, props));\n }\n\n return true;\n}\n\nfunction evaluateComparisonOperator(\n operator: ComparisonOperator,\n props: Record<string, any>,\n): boolean {\n const leftValue = getOperandValue(operator.left, props);\n const rightValue = getOperandValue(operator.right, props);\n\n if (operator.type === \"eq\") {\n return leftValue === rightValue;\n }\n\n if (operator.type === \"neq\") {\n return leftValue !== rightValue;\n }\n\n return true;\n}\n\nfunction getOperandValue(operand: { type: string; value: any }, props: Record<string, any>): any {\n if (operand.type === \"field\") {\n return props[operand.value];\n }\n\n if (operand.type === \"value\") {\n return operand.value;\n }\n\n return undefined;\n}\n\n\n\n\n","import { Block, Component, TextBlock } from \"../types\";\nimport { isComponentBlock, isDefaultComponentBlock, isElementBlock } from \"./blockUtils\";\n\nexport interface CurrentComponent {\n id: string;\n props: Record<string, any>;\n propsConfig: Record<string, any>;\n}\n\nfunction isPropValue(value: any): boolean {\n return typeof value === \"string\" && value.startsWith(\"{{\") && value.endsWith(\"}}\");\n}\n\nfunction getPropNameFromValue(value: string): string {\n return value.slice(2, -2).trim();\n}\n\nexport function getBlockText(block: TextBlock, props?: Record<string, any>): string {\n if (block.text.startsWith(\"{\") && props) {\n const propName = block.text.slice(1, -1).replace(\"props.\", \"\");\n return props?.[propName]?.toString() || block.text;\n }\n return block.text;\n}\n\nexport function htmlToText(html: string): string {\n if (typeof window === \"undefined\") return html;\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, \"text/html\");\n return doc.body.textContent || \"\";\n}\n\nexport function getBlockProps(\n block: Block,\n currentComponent: CurrentComponent | null,\n): Record<string, any> {\n const props = { ...block.props };\n if (!currentComponent) return props;\n\n for (const key in props) {\n const value = props[key];\n\n // If a prop is set to the prop of a component, substitute it with the actual value of the component prop\n if (isPropValue(value)) {\n const propName = getPropNameFromValue(value);\n const componentPropValue = currentComponent.props[propName];\n\n if (componentPropValue !== undefined) {\n props[key] = componentPropValue;\n }\n }\n }\n\n return props;\n}\n\nexport function getBlockPropsToApply(\n block: Block,\n currentComponent: CurrentComponent | null,\n options?: {\n isPreview?: boolean;\n },\n): Record<string, any> {\n const { isPreview = false } = options || {};\n\n // If it's the instance of a component, the props don't need to be applied to the component block itself,\n // rather they are handled by the component block renderer.\n const props = isComponentBlock(block) ? {} : getBlockProps(block, currentComponent);\n\n if (!isPreview) {\n // If it's a Link component, set href to \"#\" so it doesn't navigate anywhere\n if (isDefaultComponentBlock(block) && block.component === \"Link\") {\n props.href = \"#\";\n } else {\n // Otherwise, just delete href (for a normal anchor tag)\n delete props.href;\n }\n\n const isButton =\n (isDefaultComponentBlock(block) && block.component === \"Button\") ||\n (isElementBlock(block) && block.tag === \"button\");\n if (isButton) {\n props.type = \"button\";\n }\n }\n\n // Remove React/Next.js-specific props that shouldn't be passed to DOM elements\n // This must happen for both preview and non-preview modes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...domProps\n } = props;\n\n return {\n ...domProps,\n \"data-block-id\": block.id,\n };\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n\n\n\n","import { forwardRef } from \"react\";\nimport { Block, Component, ComponentRegistry } from \"../types\";\nimport {\n isTextBlock,\n isComponentBlock,\n getBlockClassnamesToApply,\n getBlockTagName,\n} from \"../utils/blockUtils\";\nimport { evaluateExpression } from \"../utils/booleanExpressions\";\nimport {\n getBlockProps,\n getBlockPropsToApply,\n getBlockText,\n htmlToText,\n CurrentComponent,\n} from \"../utils/propsUtils\";\nimport { cn } from \"../utils/cn\";\n\ninterface PreviewBlockRendererProps {\n block: Block;\n components?: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[];\n currentComponent?: CurrentComponent | null;\n replaceVhClasses?: boolean;\n className?: string;\n /** Registry of UI components (Button, Card, etc.) for proper rendering */\n componentRegistry?: ComponentRegistry;\n [key: string]: any;\n}\n\nexport const PreviewChildrenRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n ({ block, ...restProps }, ref) => {\n if (!block.children) return null;\n\n if (block.children.length === 1) {\n return <PreviewBlockRenderer block={block.children[0]} ref={ref} {...restProps} />;\n }\n\n return (\n <>\n {block.children.map((child: Block) => (\n <PreviewBlockRenderer key={child.id} block={child} {...restProps} />\n ))}\n </>\n );\n },\n);\n\nPreviewChildrenRenderer.displayName = \"ChildrenRenderer\";\n\nconst stripNonDomProps = (p: Record<string, any>) => {\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...clean\n } = p ?? {};\n return clean;\n};\n\nexport const PreviewBlockRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n (\n {\n block,\n components = [],\n currentComponent,\n replaceVhClasses = false,\n componentRegistry,\n ...rest\n },\n ref,\n ) => {\n const classNamesToApply = getBlockClassnamesToApply(block, {\n isPreview: false, // SSR mode - no preview features\n replaceVhClasses,\n });\n const className = cn(\n // If is text block, don't apply the className from the parent (with asChild), since text blocks normally can't have props at all since they're just text nodes.\n classNamesToApply,\n isTextBlock(block) ? undefined : rest?.className,\n );\n const blockProps = getBlockPropsToApply(block, currentComponent ?? null, {\n isPreview: false, // SSR mode - no preview/client-side features\n });\n\n if (block.renderCondition) {\n const shouldRender = evaluateExpression(block.renderCondition, currentComponent?.props ?? {});\n if (!shouldRender) return null;\n }\n\n if (isTextBlock(block)) {\n return <>{htmlToText(getBlockText(block, currentComponent?.props))}</>;\n }\n\n if (isComponentBlock(block)) {\n const component = components.find(\n (component: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">) =>\n component.id === block.componentId,\n );\n if (!component) return null;\n\n // For nested components, the props could be set to a prop of the outer component\n const currentComponentProps = getBlockProps(block, currentComponent ?? null);\n const innerCurrentComponent: CurrentComponent = {\n id: component.id,\n props: currentComponentProps,\n propsConfig: component.propsConfig,\n };\n\n return (\n <PreviewBlockRenderer\n block={component.blocks[0]}\n components={components}\n currentComponent={innerCurrentComponent}\n componentRegistry={componentRegistry}\n className={className}\n />\n );\n }\n\n const Tag = getBlockTagName(block, componentRegistry);\n if (!Tag) return null;\n\n const mergedProps: Record<string, any> = {\n // ...rest shouldn't be passed to text blocks because they normally can't have props at all since they're just text nodes.\n ...(isTextBlock(block) ? {} : rest),\n className,\n // blockProps Needs to be after ...rest to override the props passed from a parent component (e.g. data-block-id). (for child of asChild component)\n ...blockProps,\n ref,\n };\n\n // In SSR mode, links work normally - no client-side navigation needed\n // Remove onClick handlers that would require client-side code\n\n // Only strip non-DOM props when Tag is a real DOM element (string), not a React component\n const finalProps = typeof Tag === \"string\" ? stripNonDomProps(mergedProps) : mergedProps;\n\n if (!block.children?.length) {\n return <Tag {...finalProps} />;\n }\n\n return (\n <Tag {...finalProps}>\n <PreviewChildrenRenderer\n block={block}\n components={components}\n currentComponent={currentComponent}\n componentRegistry={componentRegistry}\n />\n </Tag>\n );\n },\n);\n\nPreviewBlockRenderer.displayName = \"BlockRenderer\";\n","import { Theme, ThemeItem } from \"../types\";\n\nexport function applyFontsToDocument(document: Document, fonts: ThemeItem[]) {\n const root = document.documentElement;\n const head = document.head;\n\n // Simple implementation - in production you'd want to handle Google Fonts and local fonts\n fonts.forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n root.style.setProperty(font.variable, fontFamily);\n });\n}\n\nexport function applyColorToDocument(document: Document, color: ThemeItem) {\n document.documentElement.style.setProperty(color.variable, color.value);\n}\n\nexport function applyBorderRadiusToDocument(document: Document, borderRadius: number) {\n document.documentElement.style.setProperty(\"--radius\", `${borderRadius}rem`);\n}\n\nexport function applyThemeToDocument(document: Document, theme: Theme) {\n applyFontsToDocument(document, Object.values(theme.fonts));\n applyBorderRadiusToDocument(document, theme.borderRadius);\n Object.values(theme.colors).forEach((color) => applyColorToDocument(document, color));\n}\n\n/**\n * Generate CSS styles for theme that can be injected into a style tag for SSR.\n * This is a pure function that works on the server.\n * Uses scoped selectors to ensure SiteIO theme variables take precedence over project theme.\n */\nexport function applyThemeToStyleTag(theme: Theme): string {\n const styles: string[] = [];\n\n // Apply fonts\n Object.values(theme.fonts).forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n styles.push(` ${font.variable}: ${fontFamily};`);\n });\n\n // Apply border radius\n styles.push(` --radius: ${theme.borderRadius}rem;`);\n\n // Apply colors - SiteIO uses HSL format (e.g., \"250 93% 66%\")\n Object.values(theme.colors).forEach((color) => {\n styles.push(` ${color.variable}: ${color.value};`);\n });\n\n // Use :root with higher specificity by placing it after other styles\n // Also add scoped selector to ensure variables work within SiteIO component\n // The order matters - this style tag should be injected after the project's global CSS\n return `:root {\\n${styles.join(\"\\n\")}\\n}\\n[data-siteio-theme] {\\n${styles.join(\"\\n\")}\\n}\\n[data-siteio-theme] * {\\n${styles.join(\"\\n\")}\\n}`;\n}\n\n\n\n\n","import { fetchProject } from \"../utils/fetchProject\";\nimport { PreviewBlockRenderer } from \"./PreviewBlockRenderer\";\nimport { RewebProjectProps, Component, ProjectData } from \"../types\";\nimport { applyThemeToStyleTag } from \"../utils/theme\";\n\n/**\n * Pure SSR server component that fetches and renders project data on the server.\n * No client-side JavaScript required - works entirely in SSR mode.\n */\nexport async function RewebProject({\n projectId,\n token,\n initialPageId,\n config,\n className,\n componentRegistry,\n}: RewebProjectProps) {\n // Fetch data on the server\n let data: ProjectData;\n let error: Error | null = null;\n\n try {\n data = await fetchProject({\n projectId,\n token,\n apiUrl: config?.apiUrl,\n });\n } catch (err) {\n error = err instanceof Error ? err : new Error(\"Failed to fetch project\");\n // Return error UI - this will be rendered on server\n return (\n <div className={className}>\n <div>Error: {error.message}</div>\n </div>\n );\n }\n\n // Determine which page to render\n let currentPageId = initialPageId;\n if (!currentPageId) {\n // Find home page (url === \"/\")\n const homePage = data.pages.find((page) => page.url === \"/\");\n if (homePage) {\n currentPageId = homePage.public_id;\n } else if (data.pages.length > 0) {\n currentPageId = data.pages[0].public_id;\n }\n }\n\n const currentPage = data.pages.find((page) => page.public_id === currentPageId);\n if (!currentPage) {\n return (\n <div className={className}>\n <div>Page not found</div>\n </div>\n );\n }\n\n // Prepare components data\n const components: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[] = data.components.map(\n (component) => ({\n id: component.public_id,\n blocks: component.blocks,\n propsConfig: component.props_config,\n }),\n );\n\n // Generate theme styles for SSR\n const themeStyles = applyThemeToStyleTag(data.project.theme);\n\n return (\n <>\n {/* Inject theme styles for SSR - scoped to SiteIO component */}\n <style dangerouslySetInnerHTML={{ __html: themeStyles }} />\n <div className={className} data-siteio-theme>\n {currentPage.blocks.map((block) => (\n <PreviewBlockRenderer\n key={block.id}\n block={block}\n components={components}\n componentRegistry={componentRegistry}\n />\n ))}\n </div>\n </>\n );\n}\n"]} | ||
| {"version":3,"sources":["../src/utils/fetchProject.ts","../src/components/Icon.tsx","../src/utils/blockUtils.ts","../src/utils/booleanExpressions.ts","../src/utils/propsUtils.ts","../src/utils/cn.ts","../src/components/PreviewBlockRenderer.tsx","../src/utils/theme.ts","../src/components/RewebProject.tsx"],"names":["forwardRef","jsx","component","Fragment"],"mappings":";;;;;;;AAQA,eAAsB,YAAA,CAAa;AAAA,EACjC,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAS,OAAO,MAAA,KAAW,WAAA,GAAc,MAAA,CAAO,SAAS,MAAA,GAAS;AACpE,CAAA,EAA8C;AAC5C,EAAA,MAAM,MAAM,IAAI,GAAA,CAAI,GAAG,MAAM,CAAA,aAAA,EAAgB,SAAS,CAAA,CAAE,CAAA;AACxD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AAEnC,EAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,CAAI,UAAS,EAAG;AAAA,IAC3C,MAAA,EAAQ,KAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,IAAA,MAAM,KAAA,GAAQ,MAAM,QAAA,CAAS,IAAA,EAAK,CAAE,MAAM,OAAO,EAAE,KAAA,EAAO,eAAA,EAAgB,CAAE,CAAA;AAC5E,IAAA,MAAM,IAAI,KAAA,CAAM,KAAA,CAAM,SAAS,CAAA,yBAAA,EAA4B,QAAA,CAAS,UAAU,CAAA,CAAE,CAAA;AAAA,EAClF;AAEA,EAAA,OAAO,SAAS,IAAA,EAAK;AACvB;ACdO,IAAM,IAAA,GAAO,UAAA;AAAA,EAClB,CAAC,EAAE,IAAA,EAAM,IAAA,GAAO,EAAA,EAAI,WAAW,WAAA,EAAa,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AAE9D,IAAA,MAAM,aAAA,GAAiB,YA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CAAO,KAAK,IAAA,CAAK,OAAA,CAAQ,OAAO,MAAA,IAAU,EAAE,CAAA,CAAE,MAAM;AAAA,uBAAA,EACpD,WAAW,MAAM,CAAA;AAAA,wBAAA,EAChB,YAAY,MAAM,CAAA;AAAA,GAAA,CAAA;AAG1C,EAAA,uBACE,IAAA,CAAAE,UAAA,EAEE,QAAA,EAAA;AAAA,oBAAAF,GAAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,0BAAA,EAAwB,IAAA;AAAA,QACxB,uBAAA,EAAyB,EAAE,MAAA,EAAQ,SAAA,GAAY,OAAO,WAAA;AAAY;AAAA,KACpE;AAAA,IACC,UAAA,mBACCA,GAAAA,CAAC,OAAA,EAAA,EAAM,yBAAA,EAAuB,IAAA,EAAC,uBAAA,EAAyB,EAAE,MAAA,EAAQ,UAAA,EAAW,EAAG,CAAA,GAC9E,IAAA;AAAA,oBACJA,GAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAsB,mBAAA,EAAiB,IAAA,EACzC,QAAA,EAAA,WAAA,CAAY,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,qBACvBA,GAAAA;AAAA,MAAC,oBAAA;AAAA,MAAA;AAAA,QAEC,KAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OAAA;AAAA,MAHK,KAAA,CAAM;AAAA,KAKd,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"index.mjs","sourcesContent":["import { ProjectData } from \"../types\";\n\nexport interface FetchProjectOptions {\n projectId: string;\n token: string;\n apiUrl?: string;\n}\n\nexport async function fetchProject({\n projectId,\n token,\n apiUrl = typeof window !== \"undefined\" ? window.location.origin : \"http://localhost:3000\",\n}: FetchProjectOptions): Promise<ProjectData> {\n const url = new URL(`${apiUrl}/api/project/${projectId}`);\n url.searchParams.set(\"token\", token);\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: \"Unknown error\" }));\n throw new Error(error.error || `Failed to fetch project: ${response.statusText}`);\n }\n\n return response.json();\n}\n\n\n\n\n","import * as LucideIcons from \"lucide-react\";\nimport { forwardRef } from \"react\";\n\ninterface IconProps {\n name: string;\n size?: number;\n className?: string;\n strokeWidth?: number;\n [key: string]: any;\n}\n\n/**\n * Dynamic icon component that renders Lucide React icons by name.\n * This allows the SDK to render any icon used in the SiteIO builder.\n */\nexport const Icon = forwardRef<SVGSVGElement, IconProps>(\n ({ name, size = 24, className, strokeWidth, ...props }, ref) => {\n // Get the icon component from Lucide\n const IconComponent = (LucideIcons as Record<string, any>)[name];\n\n if (!IconComponent) {\n // Return empty span if icon not found to avoid breaking the layout\n console.warn(`[SiteIO SDK] Icon \"${name}\" not found in lucide-react`);\n return <span className={className} style={{ width: size, height: size }} />;\n }\n\n return (\n <IconComponent\n ref={ref}\n size={size}\n className={className}\n strokeWidth={strokeWidth}\n {...props}\n />\n );\n },\n);\n\nIcon.displayName = \"Icon\";\n","import { Icon } from \"../components/Icon\";\nimport {\n Block,\n ElementBlock,\n DefaultComponentBlock,\n TextBlock,\n ComponentBlock,\n ComponentRegistry,\n} from \"../types\";\n\nexport function isTextBlock(block: Block): block is TextBlock {\n return block.type === \"text\";\n}\n\nexport function isElementBlock(block: Block): block is ElementBlock {\n return block.type === \"element\";\n}\n\nexport function isDefaultComponentBlock(block: Block): block is DefaultComponentBlock {\n return block.type === \"component\";\n}\n\nexport function isComponentBlock(block: Block): block is ComponentBlock {\n return block.type === \"custom-component\";\n}\n\n/**\n * Built-in SDK components that are always available.\n * These don't require the user to install any additional packages.\n */\nexport const SDK_BUILT_IN_COMPONENTS: ComponentRegistry = {\n Icon,\n};\n\n/**\n * Default fallback tags for components when no registry is provided.\n * Maps component names to semantic HTML elements.\n * Note: These are FALLBACKS - the actual styling comes from the compiled CSS.\n */\nconst DEFAULT_COMPONENT_TAGS: Record<string, keyof JSX.IntrinsicElements> = {\n Button: \"button\",\n Link: \"a\",\n Image: \"img\",\n Input: \"input\",\n Textarea: \"textarea\",\n Label: \"label\",\n Separator: \"hr\",\n Badge: \"span\",\n Card: \"div\",\n CardContent: \"div\",\n CardHeader: \"div\",\n CardTitle: \"h3\",\n CardDescription: \"p\",\n CardFooter: \"div\",\n Avatar: \"span\",\n AvatarImage: \"img\",\n AvatarFallback: \"span\",\n Table: \"table\",\n TableHeader: \"thead\",\n TableBody: \"tbody\",\n TableFooter: \"tfoot\",\n TableRow: \"tr\",\n TableHead: \"th\",\n TableCell: \"td\",\n TableCaption: \"caption\",\n};\n\nexport function getBlockCurrentClassNames(block: Block): string[] {\n const defaultClassNames = block.classNames?.default || [];\n const addedClassNames = block.classNames?.added || [];\n const removedClassNames = block.classNames?.removed || [];\n\n // Start with the default class names\n let currentClassNames = [...defaultClassNames];\n\n // Add the added class names\n currentClassNames = currentClassNames.concat(addedClassNames);\n\n // Remove the removed class names\n currentClassNames = currentClassNames.filter(\n (className) => !removedClassNames.includes(className),\n );\n\n // Return the unique set of class names\n return Array.from(new Set(currentClassNames));\n}\n\nconst VIEWPORT_HEIGHT = 900;\n\nexport function convertVhClassesToPx(classNames: string[]): string[] {\n const viewportHeight = VIEWPORT_HEIGHT;\n\n const vhUnits = [\"vh\", \"dvh\", \"svh\", \"lvh\"];\n const screenClasses = [\"h-screen\", \"h-dvh\", \"h-svh\", \"h-lvh\"];\n\n return classNames.map((className) => {\n // Handle h-screen and similar classes\n const screenMatch = screenClasses.find((sc) => className.includes(sc));\n if (screenMatch) {\n return className.replace(screenMatch, `h-[${viewportHeight}px]`);\n }\n\n // Handle percentage-based vh units\n for (const unit of vhUnits) {\n if (className.includes(unit)) {\n const match = className.match(new RegExp(`(\\\\d+)${unit}`));\n if (match) {\n const value = parseInt(match[1], 10);\n const pxValue = (value / 100) * viewportHeight;\n return className.replace(`${value}${unit}`, `${pxValue}px`);\n }\n }\n }\n\n return className;\n });\n}\n\nexport function getBlockClassnamesToApply(\n block: Block,\n options?: {\n isPreview?: boolean;\n replaceVhClasses?: boolean;\n },\n): string[] {\n const { isPreview = false, replaceVhClasses = true } = options || {};\n let currentClassNames = getBlockCurrentClassNames(block);\n\n if (isPreview) {\n const isLink = isElementBlock(block) && block.tag === \"a\";\n\n if (isLink) {\n currentClassNames = [...currentClassNames, \"cursor-pointer\"];\n }\n }\n\n if (replaceVhClasses) {\n return convertVhClassesToPx(currentClassNames);\n }\n\n return currentClassNames;\n}\n\n/**\n * Gets the tag or component to render for a block.\n *\n * @param block - The block to get the tag for\n * @param componentRegistry - Optional registry of React components\n * @returns A React component, HTML tag name, or undefined\n */\nexport function getBlockTagName(\n block: ElementBlock | DefaultComponentBlock,\n componentRegistry?: ComponentRegistry,\n): React.ComponentType<any> | keyof JSX.IntrinsicElements | undefined {\n if (isDefaultComponentBlock(block)) {\n // First, check SDK built-in components (Icon, etc.)\n if (SDK_BUILT_IN_COMPONENTS[block.component]) {\n return SDK_BUILT_IN_COMPONENTS[block.component];\n }\n\n // Then, try to get the component from the user's registry\n if (componentRegistry && componentRegistry[block.component]) {\n return componentRegistry[block.component];\n }\n\n // Fallback to semantic HTML tags for common components\n if (DEFAULT_COMPONENT_TAGS[block.component]) {\n return DEFAULT_COMPONENT_TAGS[block.component];\n }\n\n // Last resort: render as div\n return \"div\";\n }\n\n return (block.tag as keyof JSX.IntrinsicElements) ?? \"div\";\n}\n","import { BooleanExpression, ComparisonOperator, NAryLogicalOperator } from \"../types\";\n\nexport function evaluateExpression(\n expression: BooleanExpression,\n props: Record<string, any>,\n): boolean {\n if (\"type\" in expression && (expression.type === \"and\" || expression.type === \"or\" || expression.type === \"not\")) {\n return evaluateNAryLogicalOperator(expression as NAryLogicalOperator, props);\n }\n\n if (\"type\" in expression && (expression.type === \"eq\" || expression.type === \"neq\")) {\n return evaluateComparisonOperator(expression as ComparisonOperator, props);\n }\n\n return true;\n}\n\nfunction evaluateNAryLogicalOperator(\n operator: NAryLogicalOperator,\n props: Record<string, any>,\n): boolean {\n if (operator.type === \"not\") {\n if (operator.operands.length !== 1) return true;\n return !evaluateExpression(operator.operands[0], props);\n }\n\n if (operator.type === \"and\") {\n return operator.operands.every((operand) => evaluateExpression(operand, props));\n }\n\n if (operator.type === \"or\") {\n return operator.operands.some((operand) => evaluateExpression(operand, props));\n }\n\n return true;\n}\n\nfunction evaluateComparisonOperator(\n operator: ComparisonOperator,\n props: Record<string, any>,\n): boolean {\n const leftValue = getOperandValue(operator.left, props);\n const rightValue = getOperandValue(operator.right, props);\n\n if (operator.type === \"eq\") {\n return leftValue === rightValue;\n }\n\n if (operator.type === \"neq\") {\n return leftValue !== rightValue;\n }\n\n return true;\n}\n\nfunction getOperandValue(operand: { type: string; value: any }, props: Record<string, any>): any {\n if (operand.type === \"field\") {\n return props[operand.value];\n }\n\n if (operand.type === \"value\") {\n return operand.value;\n }\n\n return undefined;\n}\n\n\n\n\n","import { Block, Component, TextBlock } from \"../types\";\nimport { isComponentBlock, isDefaultComponentBlock, isElementBlock } from \"./blockUtils\";\n\nexport interface CurrentComponent {\n id: string;\n props: Record<string, any>;\n propsConfig: Record<string, any>;\n}\n\nfunction isPropValue(value: any): boolean {\n return typeof value === \"string\" && value.startsWith(\"{{\") && value.endsWith(\"}}\");\n}\n\nfunction getPropNameFromValue(value: string): string {\n return value.slice(2, -2).trim();\n}\n\nexport function getBlockText(block: TextBlock, props?: Record<string, any>): string {\n if (block.text.startsWith(\"{\") && props) {\n const propName = block.text.slice(1, -1).replace(\"props.\", \"\");\n return props?.[propName]?.toString() || block.text;\n }\n return block.text;\n}\n\nexport function htmlToText(html: string): string {\n if (typeof window === \"undefined\") return html;\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, \"text/html\");\n return doc.body.textContent || \"\";\n}\n\nexport function getBlockProps(\n block: Block,\n currentComponent: CurrentComponent | null,\n): Record<string, any> {\n const props = { ...block.props };\n if (!currentComponent) return props;\n\n for (const key in props) {\n const value = props[key];\n\n // If a prop is set to the prop of a component, substitute it with the actual value of the component prop\n if (isPropValue(value)) {\n const propName = getPropNameFromValue(value);\n const componentPropValue = currentComponent.props[propName];\n\n if (componentPropValue !== undefined) {\n props[key] = componentPropValue;\n }\n }\n }\n\n return props;\n}\n\nexport function getBlockPropsToApply(\n block: Block,\n currentComponent: CurrentComponent | null,\n options?: {\n isPreview?: boolean;\n },\n): Record<string, any> {\n const { isPreview = false } = options || {};\n\n // If it's the instance of a component, the props don't need to be applied to the component block itself,\n // rather they are handled by the component block renderer.\n const props = isComponentBlock(block) ? {} : getBlockProps(block, currentComponent);\n\n if (!isPreview) {\n // If it's a Link component, set href to \"#\" so it doesn't navigate anywhere\n if (isDefaultComponentBlock(block) && block.component === \"Link\") {\n props.href = \"#\";\n } else {\n // Otherwise, just delete href (for a normal anchor tag)\n delete props.href;\n }\n\n const isButton =\n (isDefaultComponentBlock(block) && block.component === \"Button\") ||\n (isElementBlock(block) && block.tag === \"button\");\n if (isButton) {\n props.type = \"button\";\n }\n }\n\n // Remove React/Next.js-specific props that shouldn't be passed to DOM elements\n // This must happen for both preview and non-preview modes\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n asChild,\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n ...domProps\n } = props;\n\n return {\n ...domProps,\n \"data-block-id\": block.id,\n };\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\n\n\n\n","import { forwardRef } from \"react\";\nimport { Block, Component, ComponentRegistry } from \"../types\";\nimport {\n isTextBlock,\n isComponentBlock,\n getBlockClassnamesToApply,\n getBlockTagName,\n} from \"../utils/blockUtils\";\nimport { evaluateExpression } from \"../utils/booleanExpressions\";\nimport {\n getBlockProps,\n getBlockPropsToApply,\n getBlockText,\n htmlToText,\n CurrentComponent,\n} from \"../utils/propsUtils\";\nimport { cn } from \"../utils/cn\";\n\ninterface PreviewBlockRendererProps {\n block: Block;\n components?: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[];\n currentComponent?: CurrentComponent | null;\n replaceVhClasses?: boolean;\n className?: string;\n /** Registry of UI components (Button, Card, etc.) for proper rendering */\n componentRegistry?: ComponentRegistry;\n [key: string]: any;\n}\n\nexport const PreviewChildrenRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n ({ block, ...restProps }, ref) => {\n if (!block.children) return null;\n\n if (block.children.length === 1) {\n return <PreviewBlockRenderer block={block.children[0]} ref={ref} {...restProps} />;\n }\n\n return (\n <>\n {block.children.map((child: Block) => (\n <PreviewBlockRenderer key={child.id} block={child} {...restProps} />\n ))}\n </>\n );\n },\n);\n\nPreviewChildrenRenderer.displayName = \"ChildrenRenderer\";\n\n/**\n * Strip props that are not valid DOM attributes.\n * This includes React-specific props, Next.js Image props, and Framer Motion animation props.\n */\nconst stripNonDomProps = (p: Record<string, any>) => {\n const {\n // React/Radix props\n asChild,\n // Next.js Image props\n blurDataURL,\n fill,\n placeholder,\n priority,\n quality,\n sizes,\n unoptimized,\n loader,\n srcSet,\n // Framer Motion animation props\n whileHover,\n whileTap,\n whileFocus,\n whileDrag,\n whileInView,\n animate,\n initial,\n exit,\n transition,\n variants,\n layout,\n layoutId,\n drag,\n dragConstraints,\n dragElastic,\n dragMomentum,\n dragTransition,\n dragPropagation,\n dragControls,\n dragListener,\n dragSnapToOrigin,\n onDrag,\n onDragStart,\n onDragEnd,\n onDirectionLock,\n onDragTransitionEnd,\n onAnimationStart,\n onAnimationComplete,\n onUpdate,\n onPan,\n onPanStart,\n onPanEnd,\n onTap,\n onTapStart,\n onTapCancel,\n onHoverStart,\n onHoverEnd,\n onViewportEnter,\n onViewportLeave,\n viewport,\n custom,\n inherit,\n // Other non-DOM props that might leak through\n motionValue,\n transformTemplate,\n ...clean\n } = p ?? {};\n return clean;\n};\n\nexport const PreviewBlockRenderer = forwardRef<HTMLElement, PreviewBlockRendererProps>(\n (\n {\n block,\n components = [],\n currentComponent,\n replaceVhClasses = false,\n componentRegistry,\n ...rest\n },\n ref,\n ) => {\n const classNamesToApply = getBlockClassnamesToApply(block, {\n isPreview: false, // SSR mode - no preview features\n replaceVhClasses,\n });\n const className = cn(\n // If is text block, don't apply the className from the parent (with asChild), since text blocks normally can't have props at all since they're just text nodes.\n classNamesToApply,\n isTextBlock(block) ? undefined : rest?.className,\n );\n const blockProps = getBlockPropsToApply(block, currentComponent ?? null, {\n isPreview: false, // SSR mode - no preview/client-side features\n });\n\n if (block.renderCondition) {\n const shouldRender = evaluateExpression(block.renderCondition, currentComponent?.props ?? {});\n if (!shouldRender) return null;\n }\n\n if (isTextBlock(block)) {\n return <>{htmlToText(getBlockText(block, currentComponent?.props))}</>;\n }\n\n if (isComponentBlock(block)) {\n const component = components.find(\n (component: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">) =>\n component.id === block.componentId,\n );\n if (!component) return null;\n\n // For nested components, the props could be set to a prop of the outer component\n const currentComponentProps = getBlockProps(block, currentComponent ?? null);\n const innerCurrentComponent: CurrentComponent = {\n id: component.id,\n props: currentComponentProps,\n propsConfig: component.propsConfig,\n };\n\n return (\n <PreviewBlockRenderer\n block={component.blocks[0]}\n components={components}\n currentComponent={innerCurrentComponent}\n componentRegistry={componentRegistry}\n className={className}\n />\n );\n }\n\n const Tag = getBlockTagName(block, componentRegistry);\n if (!Tag) return null;\n\n const mergedProps: Record<string, any> = {\n // ...rest shouldn't be passed to text blocks because they normally can't have props at all since they're just text nodes.\n ...(isTextBlock(block) ? {} : rest),\n className,\n // blockProps Needs to be after ...rest to override the props passed from a parent component (e.g. data-block-id). (for child of asChild component)\n ...blockProps,\n ref,\n };\n\n // In SSR mode, links work normally - no client-side navigation needed\n // Remove onClick handlers that would require client-side code\n\n // Only strip non-DOM props when Tag is a real DOM element (string), not a React component\n const finalProps = typeof Tag === \"string\" ? stripNonDomProps(mergedProps) : mergedProps;\n\n if (!block.children?.length) {\n return <Tag {...finalProps} />;\n }\n\n return (\n <Tag {...finalProps}>\n <PreviewChildrenRenderer\n block={block}\n components={components}\n currentComponent={currentComponent}\n componentRegistry={componentRegistry}\n />\n </Tag>\n );\n },\n);\n\nPreviewBlockRenderer.displayName = \"BlockRenderer\";\n","import { Theme, ThemeItem } from \"../types\";\n\nexport function applyFontsToDocument(document: Document, fonts: ThemeItem[]) {\n const root = document.documentElement;\n const head = document.head;\n\n // Simple implementation - in production you'd want to handle Google Fonts and local fonts\n fonts.forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n root.style.setProperty(font.variable, fontFamily);\n });\n}\n\nexport function applyColorToDocument(document: Document, color: ThemeItem) {\n document.documentElement.style.setProperty(color.variable, color.value);\n}\n\nexport function applyBorderRadiusToDocument(document: Document, borderRadius: number) {\n document.documentElement.style.setProperty(\"--radius\", `${borderRadius}rem`);\n}\n\nexport function applyThemeToDocument(document: Document, theme: Theme) {\n applyFontsToDocument(document, Object.values(theme.fonts));\n applyBorderRadiusToDocument(document, theme.borderRadius);\n Object.values(theme.colors).forEach((color) => applyColorToDocument(document, color));\n}\n\n/**\n * Generate CSS styles for theme that can be injected into a style tag for SSR.\n * This is a pure function that works on the server.\n * Uses scoped selectors to ensure SiteIO theme variables take precedence over project theme.\n */\nexport function applyThemeToStyleTag(theme: Theme): string {\n const styles: string[] = [];\n\n // Apply fonts\n Object.values(theme.fonts).forEach((font) => {\n const fontFamily = `\"${font.value}\"`;\n styles.push(` ${font.variable}: ${fontFamily} !important;`);\n });\n\n // Apply border radius\n styles.push(` --radius: ${theme.borderRadius}rem !important;`);\n\n // Apply colors - SiteIO uses HSL format (e.g., \"250 93% 66%\")\n Object.values(theme.colors).forEach((color) => {\n styles.push(` ${color.variable}: ${color.value} !important;`);\n });\n\n // Use high specificity selectors to ensure SiteIO theme variables override consuming app\n // The [data-siteio-theme] attribute is added to the SDK wrapper element\n const scopedStyles = styles.map((s) => s.replace(\" !important\", \"\"));\n\n return `\n/* SiteIO Theme Variables - Global scope for CSS variable inheritance */\n:root {\n${styles.join(\"\\n\")}\n}\n\n/* SiteIO Theme Variables - Scoped to SDK component */\n[data-siteio-theme] {\n${styles.join(\"\\n\")}\n}\n\n/* Ensure child elements also have access to variables */\n[data-siteio-theme] * {\n${scopedStyles.join(\"\\n\")}\n}\n`.trim();\n}\n","import { fetchProject } from \"../utils/fetchProject\";\nimport { PreviewBlockRenderer } from \"./PreviewBlockRenderer\";\nimport { RewebProjectProps, Component, ProjectData } from \"../types\";\nimport { applyThemeToStyleTag } from \"../utils/theme\";\n\n/**\n * Pure SSR server component that fetches and renders project data on the server.\n * No client-side JavaScript required - works entirely in SSR mode.\n */\nexport async function RewebProject({\n projectId,\n token,\n initialPageId,\n config,\n className,\n componentRegistry,\n}: RewebProjectProps) {\n // Fetch data on the server\n let data: ProjectData;\n let error: Error | null = null;\n\n try {\n data = await fetchProject({\n projectId,\n token,\n apiUrl: config?.apiUrl,\n });\n } catch (err) {\n error = err instanceof Error ? err : new Error(\"Failed to fetch project\");\n // Return error UI - this will be rendered on server\n return (\n <div className={className}>\n <div>Error: {error.message}</div>\n </div>\n );\n }\n\n // Determine which page to render\n let currentPageId = initialPageId;\n if (!currentPageId) {\n // Find home page (url === \"/\")\n const homePage = data.pages.find((page) => page.url === \"/\");\n if (homePage) {\n currentPageId = homePage.public_id;\n } else if (data.pages.length > 0) {\n currentPageId = data.pages[0].public_id;\n }\n }\n\n const currentPage = data.pages.find((page) => page.public_id === currentPageId);\n if (!currentPage) {\n return (\n <div className={className}>\n <div>Page not found</div>\n </div>\n );\n }\n\n // Prepare components data\n const components: Pick<Component, \"id\" | \"blocks\" | \"propsConfig\">[] = data.components.map(\n (component) => ({\n id: component.public_id,\n blocks: component.blocks,\n propsConfig: component.props_config,\n }),\n );\n\n // Generate theme styles for SSR\n const themeStyles = applyThemeToStyleTag(data.project.theme);\n const projectCss = data.styles?.css ?? \"\";\n\n // Debug info (visible in page source)\n const debugInfo = `\n/* SiteIO SDK Debug Info:\n * Theme colors count: ${Object.keys(data.project.theme?.colors || {}).length}\n * Project CSS length: ${projectCss.length} chars\n * Theme styles length: ${themeStyles.length} chars\n */`;\n\n return (\n <>\n {/* Inject theme styles for SSR - scoped to SiteIO component */}\n <style\n data-siteio-theme-styles\n dangerouslySetInnerHTML={{ __html: debugInfo + \"\\n\" + themeStyles }}\n />\n {projectCss ? (\n <style data-siteio-project-css dangerouslySetInnerHTML={{ __html: projectCss }} />\n ) : null}\n <div className={className} data-siteio-theme>\n {currentPage.blocks.map((block) => (\n <PreviewBlockRenderer\n key={block.id}\n block={block}\n components={components}\n componentRegistry={componentRegistry}\n />\n ))}\n </div>\n </>\n );\n}\n"]} |
+6
-1
| { | ||
| "name": "@tapstack/siteio-react-sdk", | ||
| "version": "0.0.7", | ||
| "version": "0.0.8", | ||
| "description": "SDK for rendering SiteIO projects in external Next.js applications", | ||
@@ -38,2 +38,3 @@ "main": "./dist/index.js", | ||
| "clsx": "^2.1.1", | ||
| "lucide-react": "^0.468.0", | ||
| "tailwind-merge": "^2.3.0" | ||
@@ -44,2 +45,6 @@ }, | ||
| "@types/react-dom": "^18.0.0", | ||
| "autoprefixer": "^10.4.20", | ||
| "postcss": "^8.4.47", | ||
| "tailwindcss": "^3.4.17", | ||
| "tailwindcss-animate": "^1.0.1", | ||
| "tsup": "^8.0.0", | ||
@@ -46,0 +51,0 @@ "typescript": "^5.7.3" |
+3
-39
@@ -15,43 +15,8 @@ # @tapstack/siteio-react-sdk | ||
| ### Tailwind CSS Setup (Required) | ||
| ### Styling & CSS Delivery | ||
| The SDK uses Tailwind CSS for styling. You **must** configure Tailwind CSS in your Next.js project for styles to work correctly. | ||
| The SDK now fetches the exact Tailwind CSS that was generated in the Reweb builder and injects it into your page during SSR together with the project theme variables. That means you no longer need to configure Tailwind CSS in the consuming project—drop in the component and it renders with the same styles that you defined in the builder. | ||
| **Quick Setup:** | ||
| If you want to merge SiteIO CSS with your own Tailwind pipeline (for example to tree-shake utilities or share classes across the rest of your app), you can still follow the optional instructions in [TAILWIND_SETUP.md](./TAILWIND_SETUP.md). | ||
| 1. Install Tailwind CSS (if not already installed): | ||
| ```bash | ||
| npm install -D tailwindcss postcss autoprefixer | ||
| npx tailwindcss init -p | ||
| ``` | ||
| 2. Update your `tailwind.config.js` to include a safelist (required for dynamic classes): | ||
| ```js | ||
| module.exports = { | ||
| content: [ | ||
| './app/**/*.{js,ts,jsx,tsx,mdx}', | ||
| './components/**/*.{js,ts,jsx,tsx,mdx}', | ||
| ], | ||
| safelist: [ | ||
| { | ||
| pattern: /./, // Include all Tailwind classes (required for dynamic classes from API) | ||
| }, | ||
| ], | ||
| theme: { | ||
| extend: {}, | ||
| }, | ||
| plugins: [], | ||
| } | ||
| ``` | ||
| 3. Ensure your global CSS includes Tailwind directives: | ||
| ```css | ||
| /* app/globals.css */ | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| ``` | ||
| **See [TAILWIND_SETUP.md](./TAILWIND_SETUP.md) for detailed setup instructions and troubleshooting.** | ||
| ## Quick Start | ||
@@ -230,2 +195,1 @@ | ||
| MIT | ||
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
128242
16.18%1217
23.55%5
25%8
100%194
-15.65%+ Added
+ Added