@superblocksteam/cli 2.0.3 → 2.0.6-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ $ npm install -g @superblocksteam/cli
14
14
  $ superblocks COMMAND
15
15
  running command...
16
16
  $ superblocks (--version)
17
- @superblocksteam/cli/2.0.3 linux-x64 node-v20.19.0
17
+ @superblocksteam/cli/2.0.6-next.0 linux-x64 node-v20.19.0
18
18
  $ superblocks --help [COMMAND]
19
19
  USAGE
20
20
  $ superblocks COMMAND
@@ -48,11 +48,11 @@ var content5 = "# Data Filtering Best Practices\n\n**\u{1F6A8} CRITICAL: When im
48
48
 
49
49
  // ../../../vite-plugin-file-sync/dist/ai-service/prompts/generated/subprompts/superblocks-event-flow.js
50
50
  init_cjs_shims();
51
- var content6 = '# Event handlers with SbEventFlow\n\nRather than using standard browser event handlers, Superblocks provides a structured event handler action flow that allows you to run a series of events within the Superblocks system.\n\nImporting SbEventFlow:\n\n```jsx\nimport { SbEventFlow } from "@superblocksteam/library";\n```\n\nAll event handlers MUST be written using the `SbEventFlow` object.\n\nFor example, here we set the `isReady` state variable to `true` when the button is clicked:\n\n```jsx\nconst { isReady } = Page1;\n<SbButton onClick={SbEventFlow.setStateVar(isReady, true)} />;\n```\n\n## SbEventFlow builder pattern\n\n`SbEventFlow` provides a number of functions that can be chained together using `SbEventFlow` which correspond to actions in the Superblocks system.\n\nYou should always use these dedicated functions for individual and sequential actions.\n\nImportant: DO NOT use .run() at the end of a chain of SbEventFlow functions, it is not needed and it will throw an error.\n\n```jsx\nconst { isReady, getUserData, getPermissions } = Page1;\n<SbButton\n onClick={SbEventFlow.setQueryParams({ filter: "active" }, true)\n .setStateVar(isReady, true)\n .controlModal("loginModal", "close")\n\n // run APIs allows you to run Superblocks APIs by name using string arrays\n // Each runAPIs call executes the list of API names supplied in parallel\n .runApis([getUserData, getPermissions])\n\n // set a state variable\'s value\n .showAlert("Workflow complete", "success")\n .navigateTo({ url: "/dashboard", newWindow: false })}\n/>;\n```\n\n#### Using RunJS (only when needed)\n\n`SbEventFlow` also has a special `runJS` event type that allows you to run any JavaScript in the browser.\n\nThis allows you to write more complex logic such as control flow.\n\nImportant:\n\n- The only things you can do in runJS is set state variables or set the public state of components, like modal.isOpen.\n- You CANNOT use SbEventFlow inside of a SbEventFlow.runJS function. If you do this, it won\'t work!\n- **State access in runJS**: Scope entities are accessible directly by their names, global state is accessible via imported globals (Global, Theme, Embed, Env).\n\nExample accessing scope entities:\n\n```jsx\n<SbButton\n label="Enable"\n buttonStyle={"SECONDARY_BUTTON"}\n onClick={SbEventFlow.runJS(() => {\n // Scope entities (variables, bound components) are accessible directly in runJS\n if (isUserAdmin.value) {\n // isUserAdmin is a bound component from scope\n myStateVar.value = true; // myStateVar is a state variable from scope\n myModal.isOpen = false; // myModal is a bound component from scope\n } else {\n console.log("This user was not an admin");\n }\n })}\n/>\n```\n\nExample accessing global state when needed:\n\n```jsx\n<SbButton\n label="Personalized Action"\n onClick={SbEventFlow.runJS(() => {\n // Import globals and access directly\n if (Global.user.groups.some((g) => g.name === "admin")) {\n // Also access scope entities (bound components) directly\n adminPanel.isVisible = true; // adminPanel is a bound component from scope\n }\n console.log(`Welcome ${Global.user.name}!`);\n })}\n/>\n```\n\nAs mentioned above, you should only use `runJS` when the flow is too complex to represent using only chained event flow actions.\n\n### SbEvent Flow Usage Examples\n\n```typescript\nimport { SbEventFlow, sbComputed } from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\nconst { fetchUserData, saveUserData, userDataVariable } = Page1;\n\n// Navigation example\nSbEventFlow.navigateTo({ url: "https://example.com", newWindow: true });\n\n// Control UI components example\nSbEventFlow.controlModal("myModal", "open");\n\n// State management example\nconst { userProfile } = Page1;\nSbEventFlow.setStateVar(userProfile, { name: "John", role: "Admin" });\n\n// Chaining multiple actions\nSbEventFlow.runApis([fetchUserData])\n .setStateVar(\n userDataVariable,\n sbComputed(() => {\n fetchUserData.response;\n }),\n )\n .showAlert("Data loaded successfully", "success");\n\n// Conditional flow with success/error handlers\nconst successFlow = SbEventFlow.showAlert("Success!", "success");\nconst errorFlow = SbEventFlow.showAlert("An error occurred", "error");\nSbEventFlow.runApis([saveUserData], successFlow, errorFlow);\n```\n\n**SbEventFlow: Managing Events and Side Effects in Superblocks**\n\n## Important Syntax Rules\n\n- Always use function braces with SbEventFlow.runJS. Example: `SbEventFlow.runJS(() => { someFunction(); })` not `SbEventFlow.runJS(() => someFunction())`\n- SbEventFlow.runApis() accepts an array of direct API entity references. Example: `SbEventFlow.runApis([fetchUserData, saveUserData])`\n';
51
+ var content6 = '# Event handlers with SbEventFlow\n\nRather than using standard browser event handlers, Superblocks provides a structured event handler action flow that allows you to run a series of events within the Superblocks system.\n\nImporting SbEventFlow:\n\n```jsx\nimport { SbEventFlow } from "@superblocksteam/library";\n```\n\nAll event handlers MUST be written using the `SbEventFlow` object.\n\nFor example, here we set the `isReady` state variable to `true` when the button is clicked:\n\n```jsx\nconst { isReady } = Page1;\n<SbButton onClick={SbEventFlow.setStateVar(isReady, true)} />;\n```\n\n## SbEventFlow builder pattern\n\n`SbEventFlow` provides a number of functions that can be chained together using `SbEventFlow` which correspond to actions in the Superblocks system.\n\nYou should always use these dedicated functions for individual and sequential actions.\n\nImportant: DO NOT use .run() at the end of a chain of SbEventFlow functions, it is not needed and it will throw an error.\n\n```jsx\nconst { isReady, getUserData, getPermissions, LoginModal } = Page1;\n<SbButton\n onClick={SbEventFlow.setQueryParams({ filter: "active" }, true)\n .setStateVar(isReady, true)\n .controlModal(LoginModal, "close")\n\n // run APIs allows you to run Superblocks APIs by name using string arrays\n // Each runAPIs call executes the list of API names supplied in parallel\n .runApis([getUserData, getPermissions])\n\n // set a state variable\'s value\n .showAlert("Workflow complete", "success")\n .navigateTo({ url: "/dashboard", newWindow: false })}\n/>;\n```\n\n#### Using RunJS (only when needed)\n\n`SbEventFlow` also has a special `runJS` event type that allows you to run any JavaScript in the browser.\n\nThis allows you to write more complex logic such as control flow.\n\nImportant:\n\n- The only things you can do in runJS is set state variables or set the public state of components, like modal.isOpen.\n- You CANNOT use SbEventFlow inside of a SbEventFlow.runJS function. If you do this, it won\'t work!\n- **State access in runJS**: Scope entities are accessible directly by their names, global state is accessible via imported globals (Global, Theme, Embed, Env).\n\nExample accessing scope entities:\n\n```jsx\n<SbButton\n label="Enable"\n buttonStyle={"SECONDARY_BUTTON"}\n onClick={SbEventFlow.runJS(() => {\n // Scope entities (variables, bound components) are accessible directly in runJS\n if (isUserAdmin.value) {\n // isUserAdmin is a bound component from scope\n myStateVar.value = true; // myStateVar is a state variable from scope\n myModal.isOpen = false; // myModal is a bound component from scope\n } else {\n console.log("This user was not an admin");\n }\n })}\n/>\n```\n\nExample accessing global state when needed:\n\n```jsx\n<SbButton\n label="Personalized Action"\n onClick={SbEventFlow.runJS(() => {\n // Import globals and access directly\n if (Global.user.groups.some((g) => g.name === "admin")) {\n // Also access scope entities (bound components) directly\n adminPanel.isVisible = true; // adminPanel is a bound component from scope\n }\n console.log(`Welcome ${Global.user.name}!`);\n })}\n/>\n```\n\nAs mentioned above, you should only use `runJS` when the flow is too complex to represent using only chained event flow actions.\n\n### SbEvent Flow Usage Examples\n\n```typescript\nimport { SbEventFlow, sbComputed } from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\nconst { fetchUserData, saveUserData, userDataVariable, MyModal } = Page1;\n\n// Navigation example\nSbEventFlow.navigateTo({ url: "https://example.com", newWindow: true });\n\n// Control UI components example\nSbEventFlow.controlModal(MyModal, "open");\n\n// State management example\nconst { userProfile } = Page1;\nSbEventFlow.setStateVar(userProfile, { name: "John", role: "Admin" });\n\n// Chaining multiple actions\nSbEventFlow.runApis([fetchUserData])\n .setStateVar(\n userDataVariable,\n sbComputed(() => {\n fetchUserData.response;\n }),\n )\n .showAlert("Data loaded successfully", "success");\n\n// Conditional flow with success/error handlers\nconst successFlow = SbEventFlow.showAlert("Success!", "success");\nconst errorFlow = SbEventFlow.showAlert("An error occurred", "error");\nSbEventFlow.runApis([saveUserData], successFlow, errorFlow);\n```\n\n**SbEventFlow: Managing Events and Side Effects in Superblocks**\n\n## Important Syntax Rules\n\n- Always use function braces with SbEventFlow.runJS. Example: `SbEventFlow.runJS(() => { someFunction(); })` not `SbEventFlow.runJS(() => someFunction())`\n- SbEventFlow.runApis() accepts an array of direct API entity references. Example: `SbEventFlow.runApis([fetchUserData, saveUserData])`\n';
52
52
 
53
53
  // ../../../vite-plugin-file-sync/dist/ai-service/prompts/generated/subprompts/superblocks-forms.js
54
54
  init_cjs_shims();
55
- var content7 = '### Form Layouts in Superblocks\n\n**\u{1F6A8} CRITICAL: Remember that sbComputed cannot be used as React children.** When building forms, all dynamic content must be in component properties (like `text={}`, `label={}`) not as children.\n\nWhen creating forms using form field components, follow these rules:\n\n1. Always put form components together inside an `SbContainer` with `layout="vertical"`, `width={Dim.fill()}`, and appropriate `spacing`\n2. Use `spacing={Dim.px(12)}` or similar for consistent form field spacing\n3. Do not change the label position on form components (like `SbInput`). The default is the label is above the input and we want to keep that\n4. Make all form field components and any container parents be `width={Dim.fill()}` so they are all aligned horizontally and easy to use\n\n**Example:**\n\n```jsx\n<SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput label="First Name" bind={FirstName} width={Dim.fill()} />\n <SbInput label="Last Name" bind={LastName} width={Dim.fill()} />\n <SbInput label="Email" bind={Email} inputType="EMAIL" width={Dim.fill()} />\n</SbContainer>\n```\n\n### Forms inside Modals\n\nIt\'s common to put a form inside a Modal, like for creating or editing an entity. Here are comprehensive examples showing different patterns:\n\n#### Basic Create Form Modal\n\n```tsx\n// Import required components and utilities\nimport {\n SbModal,\n SbContainer,\n SbText,\n SbInput,\n SbDropdown,\n SbButton,\n Dim,\n SbEventFlow,\n} from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\n// ...\n\nconst {\n NewOrderCustomerName,\n NewOrderCustomerEmail,\n NewOrderAmount,\n NewOrderStatus,\n NewOrderNotes,\n OrdersStateVar,\n CreateOrderModal,\n} = Page1;\n\n<SbModal bind={CreateOrderModal}>\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(24)}>\n {/* Modal Header */}\n <SbContainer layout="vertical" spacing={Dim.px(8)}>\n <SbText\n text="Create New Order"\n textStyle={{\n variant: "heading4",\n }}\n />\n <SbText text="Fill out the form below to create a new order" />\n </SbContainer>\n\n {/* Form Content */}\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput\n bind={NewOrderCustomerName}\n width={Dim.fill()}\n label="Customer Name"\n placeholderText="Enter customer name"\n required={true}\n />\n\n <SbInput\n bind={NewOrderCustomerEmail}\n width={Dim.fill()}\n label="Customer Email"\n inputType="EMAIL"\n placeholderText="Enter customer email"\n required={true}\n />\n\n <SbInput\n bind={NewOrderAmount}\n width={Dim.fill()}\n label="Order Amount"\n placeholderText="Enter order amount"\n inputType="NUMBER"\n required={true}\n />\n\n <SbDropdown\n bind={NewOrderStatus}\n width={Dim.fill()}\n label="Order Status"\n options={[\n {\n label: "Pending",\n value: "pending",\n },\n {\n label: "Processing",\n value: "processing",\n },\n {\n label: "En route",\n value: "en_route",\n },\n {\n label: "Delivered",\n value: "delivered",\n },\n {\n label: "Refunded",\n value: "refunded",\n },\n ]}\n required={true}\n />\n\n <SbInput\n bind={NewOrderNotes}\n width={Dim.fill()}\n label="Order Notes"\n placeholderText="Optional notes about the order"\n multiline={true}\n />\n </SbContainer>\n\n {/* Modal Footer */}\n <SbContainer\n layout="horizontal"\n horizontalAlign="right"\n spacing={Dim.px(12)}\n width={Dim.fill()}\n >\n <SbButton\n label="Cancel"\n variant="secondary"\n onClick={SbEventFlow.runJS(() => {\n // Reset form components\n NewOrderCustomerName.text = "";\n NewOrderCustomerEmail.text = "";\n NewOrderAmount.text = "";\n NewOrderStatus.metaSelectedOptionValue = "";\n NewOrderNotes.text = "";\n })\n // Note how we prefer use controlModal for handling opening/closing\n // the modal rather than setting the modal\'s open property directly\n .controlModal("CreateOrderModal", "close")}\n />\n <SbButton\n label="Create Order"\n variant="primary"\n onClick={SbEventFlow.runJS(() => {\n // Create new order using the form values\n const newOrder = {\n id: `ORD_${Math.floor(Math.random() * 10000)\n .toString()\n .padStart(4, "0")}`,\n customerName: NewOrderCustomerName.value,\n customerEmail: NewOrderCustomerEmail.value,\n amount: NewOrderAmount.value,\n status: NewOrderStatus.selectedOptionValue,\n notes: NewOrderNotes.value,\n createdAt: new Date().toISOString(),\n };\n\n // Add to orders list or call API\n OrdersStateVar.setValue([...OrdersStateVar.value, newOrder]);\n\n // Reset form components\n NewOrderCustomerName.text = "";\n NewOrderCustomerEmail.text = "";\n NewOrderAmount.text = "";\n NewOrderStatus.metaSelectedOptionValue = "";\n NewOrderNotes.text = "";\n })\n // Note how we prefer use controlModal for handling opening/closing\n // the modal rather than setting the modal\'s open property directly\n .controlModal("CreateOrderModal", "close")}\n />\n </SbContainer>\n </SbContainer>\n</SbModal>;\n```\n\n#### Table with Edit Form Modal\n\nThis example shows a more complete pattern where a table displays data and clicking a row opens an edit modal with the form fields pre-populated:\n\n```tsx\n// Import required components and utilities\nimport {\n SbPage,\n SbSection,\n SbColumn,\n SbTable,\n SbModal,\n SbContainer,\n SbText,\n SbInput,\n SbDropdown,\n SbButton,\n Dim,\n SbEventFlow,\n sbComputed,\n} from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\nconst {\n OrdersTable,\n EditOrderModal,\n EditOrderCustomerName,\n EditOrderCustomerEmail,\n EditOrderAmount,\n EditOrderStatus,\n EditOrderNotes,\n OrdersStateVar,\n} = Page1;\n\n// Main page with table\n<SbPage name="Page1" height={Dim.fill()} width={Dim.fill()}>\n <SbSection height={Dim.fill()}>\n <SbColumn width={Dim.fill()} spacing={Dim.px(24)}>\n <SbText\n text="Orders Management"\n textStyle={{ variant: "heading2" }}\n />\n\n <SbTable\n bind={OrdersTable}\n tableData={sbComputed(() => OrdersStateVar.value)}\n onRowClick={SbEventFlow.runJS(() => {\n // Populate form fields with the selected row data\n EditOrderCustomerName.text = OrdersTable.selectedRow.customerName;\n EditOrderCustomerEmail.text = OrdersTable.selectedRow.customerEmail;\n EditOrderAmount.text = OrdersTable.selectedRow.amount;\n EditOrderStatus.metaSelectedOptionValue = OrdersTable.selectedRow.status;\n EditOrderNotes.text = OrdersTable.selectedRow.notes || "";\n })\n // Open the edit modal\n .controlModal("EditOrderModal", "open")}\n width={Dim.fill()}\n height={Dim.fill()}\n />\n </SbColumn>\n </SbSection>\n</SbPage>\n\n// Edit modal with form pre-populated from table row\n<SbModal bind={EditOrderModal}>\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(24)}>\n {/* Modal Header */}\n <SbContainer layout="vertical" spacing={Dim.px(8)}>\n <SbText\n text="Edit Order"\n textStyle={{\n variant: "heading4",\n }}\n />\n <SbText text="Update the order details below" />\n </SbContainer>\n\n {/* Form Content - Fields are pre-populated by onRowClick */}\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput\n bind={EditOrderCustomerName}\n width={Dim.fill()}\n label="Customer Name"\n placeholderText="Enter customer name"\n required={true}\n />\n\n <SbInput\n bind={EditOrderCustomerEmail}\n width={Dim.fill()}\n label="Customer Email"\n inputType="EMAIL"\n placeholderText="Enter customer email"\n required={true}\n />\n\n <SbInput\n bind={EditOrderAmount}\n width={Dim.fill()}\n label="Order Amount"\n placeholderText="Enter order amount"\n inputType="NUMBER"\n required={true}\n />\n\n <SbDropdown\n bind={EditOrderStatus}\n width={Dim.fill()}\n label="Order Status"\n options={[\n {\n label: "Pending",\n value: "pending",\n },\n {\n label: "Processing",\n value: "processing",\n },\n {\n label: "En route",\n value: "en_route",\n },\n {\n label: "Delivered",\n value: "delivered",\n },\n {\n label: "Refunded",\n value: "refunded",\n },\n ]}\n required={true}\n />\n\n <SbInput\n bind={EditOrderNotes}\n width={Dim.fill()}\n label="Order Notes"\n placeholderText="Optional notes about the order"\n multiline={true}\n />\n </SbContainer>\n\n {/* Modal Footer */}\n <SbContainer\n layout="horizontal"\n horizontalAlign="right"\n spacing={Dim.px(12)}\n width={Dim.fill()}\n >\n <SbButton\n label="Cancel"\n variant="secondary"\n onClick={SbEventFlow.controlModal("EditOrderModal", "close")}\n />\n <SbButton\n label="Save Changes"\n variant="primary"\n onClick={SbEventFlow.runJS(() => {\n // Find and update the order in the orders array\n const updatedOrders = OrdersStateVar.value.map(order => {\n if (order.id === OrdersTable.selectedRow.id) {\n return {\n ...order,\n customerName: EditOrderCustomerName.value,\n customerEmail: EditOrderCustomerEmail.value,\n amount: EditOrderAmount.value,\n status: EditOrderStatus.selectedOptionValue,\n notes: EditOrderNotes.value,\n updatedAt: new Date().toISOString(),\n };\n }\n return order;\n });\n\n // Update the orders state\n OrdersStateVar.setValue(updatedOrders);\n })\n .controlModal("EditOrderModal", "close")}\n />\n </SbContainer>\n </SbContainer>\n</SbModal>\n```\n\n**Corresponding scope.ts file for the table + edit modal example:**\n\n```ts\n// pages/Page1/scope.ts\nimport {\n createSbScope,\n SbVariable,\n SbVariablePersistence,\n} from "@superblocksteam/library";\n\nexport const Page1Scope = createSbScope<{\n OrdersTable: any;\n EditOrderModal: any;\n EditOrderCustomerName: any;\n EditOrderCustomerEmail: any;\n EditOrderAmount: any;\n EditOrderStatus: any;\n EditOrderNotes: any;\n OrdersStateVar: any;\n}>(\n () => ({\n OrdersStateVar: SbVariable({\n defaultValue: [\n {\n id: 1,\n customerName: "John Doe",\n customerEmail: "john@example.com",\n amount: 150.0,\n status: "pending",\n notes: "Rush order",\n createdAt: "2024-01-15T10:30:00Z",\n },\n {\n id: 2,\n customerName: "Jane Smith",\n customerEmail: "jane@example.com",\n amount: 89.99,\n status: "delivered",\n notes: "",\n createdAt: "2024-01-14T14:20:00Z",\n },\n ],\n persistence: SbVariablePersistence.TEMPORARY,\n }),\n }),\n {\n name: "Page1",\n },\n);\n\nexport const Page1 = Page1Scope.entities;\n```\n\n#### Alternative Population Method - Button with State Variable\n\nHere\'s another common pattern where a button populates form fields from a state variable:\n\n```tsx\n// Button that loads selected user data into edit form\n<SbButton\n label="Edit Selected User"\n onClick={SbEventFlow.runJS(() => {\n const selectedUser = SelectedUserStateVar.value;\n\n // Populate form fields from state variable\n EditUserName.text = selectedUser.name;\n EditUserEmail.text = selectedUser.email;\n EditUserRole.metaSelectedOptionValue = selectedUser.role;\n EditUserDepartment.text = selectedUser.department;\n }).controlModal("EditUserModal", "open")}\n/>\n```\n\n### Key Form Patterns\n\n1. **Create Forms**: Start with empty fields, populate from user input\n2. **Edit Forms**: Pre-populate fields with existing data from various sources\n3. **Field Population Methods**:\n - **Table Row Selection**: Use `onRowClick` to set form field values to `{TableName}.selectedRow.{columnName}` (most common)\n - **Button Actions**: Use button clicks to populate from state variables or API responses\n - **API Loading**: Fetch data and populate fields when modal opens\n - **State Variables**: Populate from existing application state\n4. **Form Validation**: Use `required={true}` on form components and validate in submit handlers\n5. **Form Reset**: Always reset form fields when canceling or after successful submission\n6. **Modal Control**: Prefer `SbEventFlow.controlModal()` over directly setting modal open property\n\n### Form Layout Best Practices\n\n- **Container Structure**: Always wrap forms in `SbContainer` with `layout="vertical"`\n- **Consistent Spacing**: Use `spacing={Dim.px(12)}` for form field spacing\n- **Full Width**: Make form fields and containers `width={Dim.fill()}` for proper alignment\n- **Modal Structure**: Use header, content, and footer containers with appropriate spacing\n- **Button Alignment**: Use `horizontalAlign="right"` for the footer containers in modals that contain buttons\n';
55
+ var content7 = '### Form Layouts in Superblocks\n\n**\u{1F6A8} CRITICAL: Remember that sbComputed cannot be used as React children.** When building forms, all dynamic content must be in component properties (like `text={}`, `label={}`) not as children.\n\nWhen creating forms using form field components, follow these rules:\n\n1. Always put form components together inside an `SbContainer` with `layout="vertical"`, `width={Dim.fill()}`, and appropriate `spacing`\n2. Use `spacing={Dim.px(12)}` or similar for consistent form field spacing\n3. Do not change the label position on form components (like `SbInput`). The default is the label is above the input and we want to keep that\n4. Make all form field components and any container parents be `width={Dim.fill()}` so they are all aligned horizontally and easy to use\n\n**Example:**\n\n```jsx\n<SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput label="First Name" bind={FirstName} width={Dim.fill()} />\n <SbInput label="Last Name" bind={LastName} width={Dim.fill()} />\n <SbInput label="Email" bind={Email} inputType="EMAIL" width={Dim.fill()} />\n</SbContainer>\n```\n\n### Forms inside Modals\n\nIt\'s common to put a form inside a Modal, like for creating or editing an entity. Here are comprehensive examples showing different patterns:\n\n#### Basic Create Form Modal\n\n```tsx\n// Import required components and utilities\nimport {\n SbModal,\n SbContainer,\n SbText,\n SbInput,\n SbDropdown,\n SbButton,\n Dim,\n SbEventFlow,\n} from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\n// ...\n\nconst {\n NewOrderCustomerName,\n NewOrderCustomerEmail,\n NewOrderAmount,\n NewOrderStatus,\n NewOrderNotes,\n OrdersStateVar,\n CreateOrderModal,\n} = Page1;\n\n<SbModal bind={CreateOrderModal}>\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(24)}>\n {/* Modal Header */}\n <SbContainer layout="vertical" spacing={Dim.px(8)}>\n <SbText\n text="Create New Order"\n textStyle={{\n variant: "heading4",\n }}\n />\n <SbText text="Fill out the form below to create a new order" />\n </SbContainer>\n\n {/* Form Content */}\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput\n bind={NewOrderCustomerName}\n width={Dim.fill()}\n label="Customer Name"\n placeholderText="Enter customer name"\n required={true}\n />\n\n <SbInput\n bind={NewOrderCustomerEmail}\n width={Dim.fill()}\n label="Customer Email"\n inputType="EMAIL"\n placeholderText="Enter customer email"\n required={true}\n />\n\n <SbInput\n bind={NewOrderAmount}\n width={Dim.fill()}\n label="Order Amount"\n placeholderText="Enter order amount"\n inputType="NUMBER"\n required={true}\n />\n\n <SbDropdown\n bind={NewOrderStatus}\n width={Dim.fill()}\n label="Order Status"\n options={[\n {\n label: "Pending",\n value: "pending",\n },\n {\n label: "Processing",\n value: "processing",\n },\n {\n label: "En route",\n value: "en_route",\n },\n {\n label: "Delivered",\n value: "delivered",\n },\n {\n label: "Refunded",\n value: "refunded",\n },\n ]}\n required={true}\n />\n\n <SbInput\n bind={NewOrderNotes}\n width={Dim.fill()}\n label="Order Notes"\n placeholderText="Optional notes about the order"\n multiline={true}\n />\n </SbContainer>\n\n {/* Modal Footer */}\n <SbContainer\n layout="horizontal"\n horizontalAlign="right"\n spacing={Dim.px(12)}\n width={Dim.fill()}\n >\n <SbButton\n label="Cancel"\n variant="secondary"\n onClick={SbEventFlow.runJS(() => {\n // Reset form components\n NewOrderCustomerName.text = "";\n NewOrderCustomerEmail.text = "";\n NewOrderAmount.text = "";\n NewOrderStatus.metaSelectedOptionValue = "";\n NewOrderNotes.text = "";\n })\n // Note how we prefer use controlModal for handling opening/closing\n // the modal rather than setting the modal\'s open property directly\n .controlModal(CreateOrderModal, "close")}\n />\n <SbButton\n label="Create Order"\n variant="primary"\n onClick={SbEventFlow.runJS(() => {\n // Create new order using the form values\n const newOrder = {\n id: `ORD_${Math.floor(Math.random() * 10000)\n .toString()\n .padStart(4, "0")}`,\n customerName: NewOrderCustomerName.value,\n customerEmail: NewOrderCustomerEmail.value,\n amount: NewOrderAmount.value,\n status: NewOrderStatus.selectedOptionValue,\n notes: NewOrderNotes.value,\n createdAt: new Date().toISOString(),\n };\n\n // Add to orders list or call API\n OrdersStateVar.setValue([...OrdersStateVar.value, newOrder]);\n\n // Reset form components\n NewOrderCustomerName.text = "";\n NewOrderCustomerEmail.text = "";\n NewOrderAmount.text = "";\n NewOrderStatus.metaSelectedOptionValue = "";\n NewOrderNotes.text = "";\n })\n // Note how we prefer use controlModal for handling opening/closing\n // the modal rather than setting the modal\'s open property directly\n .controlModal(CreateOrderModal, "close")}\n />\n </SbContainer>\n </SbContainer>\n</SbModal>;\n```\n\n#### Table with Edit Form Modal\n\nThis example shows a more complete pattern where a table displays data and clicking a row opens an edit modal with the form fields pre-populated:\n\n```tsx\n// Import required components and utilities\nimport {\n SbPage,\n SbSection,\n SbColumn,\n SbTable,\n SbModal,\n SbContainer,\n SbText,\n SbInput,\n SbDropdown,\n SbButton,\n Dim,\n SbEventFlow,\n sbComputed,\n} from "@superblocksteam/library";\nimport { Page1 } from "./scope";\n\nconst {\n OrdersTable,\n EditOrderModal,\n EditOrderCustomerName,\n EditOrderCustomerEmail,\n EditOrderAmount,\n EditOrderStatus,\n EditOrderNotes,\n OrdersStateVar,\n} = Page1;\n\n// Main page with table\n<SbPage name="Page1" height={Dim.fill()} width={Dim.fill()}>\n <SbSection height={Dim.fill()}>\n <SbColumn width={Dim.fill()} spacing={Dim.px(24)}>\n <SbText\n text="Orders Management"\n textStyle={{ variant: "heading2" }}\n />\n\n <SbTable\n bind={OrdersTable}\n tableData={sbComputed(() => OrdersStateVar.value)}\n onRowClick={SbEventFlow.runJS(() => {\n // Populate form fields with the selected row data\n EditOrderCustomerName.text = OrdersTable.selectedRow.customerName;\n EditOrderCustomerEmail.text = OrdersTable.selectedRow.customerEmail;\n EditOrderAmount.text = OrdersTable.selectedRow.amount;\n EditOrderStatus.metaSelectedOptionValue = OrdersTable.selectedRow.status;\n EditOrderNotes.text = OrdersTable.selectedRow.notes || "";\n })\n // Open the edit modal\n .controlModal(EditOrderModal, "open")}\n width={Dim.fill()}\n height={Dim.fill()}\n />\n </SbColumn>\n </SbSection>\n</SbPage>\n\n// Edit modal with form pre-populated from table row\n<SbModal bind={EditOrderModal}>\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(24)}>\n {/* Modal Header */}\n <SbContainer layout="vertical" spacing={Dim.px(8)}>\n <SbText\n text="Edit Order"\n textStyle={{\n variant: "heading4",\n }}\n />\n <SbText text="Update the order details below" />\n </SbContainer>\n\n {/* Form Content - Fields are pre-populated by onRowClick */}\n <SbContainer layout="vertical" width={Dim.fill()} spacing={Dim.px(12)}>\n <SbInput\n bind={EditOrderCustomerName}\n width={Dim.fill()}\n label="Customer Name"\n placeholderText="Enter customer name"\n required={true}\n />\n\n <SbInput\n bind={EditOrderCustomerEmail}\n width={Dim.fill()}\n label="Customer Email"\n inputType="EMAIL"\n placeholderText="Enter customer email"\n required={true}\n />\n\n <SbInput\n bind={EditOrderAmount}\n width={Dim.fill()}\n label="Order Amount"\n placeholderText="Enter order amount"\n inputType="NUMBER"\n required={true}\n />\n\n <SbDropdown\n bind={EditOrderStatus}\n width={Dim.fill()}\n label="Order Status"\n options={[\n {\n label: "Pending",\n value: "pending",\n },\n {\n label: "Processing",\n value: "processing",\n },\n {\n label: "En route",\n value: "en_route",\n },\n {\n label: "Delivered",\n value: "delivered",\n },\n {\n label: "Refunded",\n value: "refunded",\n },\n ]}\n required={true}\n />\n\n <SbInput\n bind={EditOrderNotes}\n width={Dim.fill()}\n label="Order Notes"\n placeholderText="Optional notes about the order"\n multiline={true}\n />\n </SbContainer>\n\n {/* Modal Footer */}\n <SbContainer\n layout="horizontal"\n horizontalAlign="right"\n spacing={Dim.px(12)}\n width={Dim.fill()}\n >\n <SbButton\n label="Cancel"\n variant="secondary"\n onClick={SbEventFlow.controlModal(EditOrderModal, "close")}\n />\n <SbButton\n label="Save Changes"\n variant="primary"\n onClick={SbEventFlow.runJS(() => {\n // Find and update the order in the orders array\n const updatedOrders = OrdersStateVar.value.map(order => {\n if (order.id === OrdersTable.selectedRow.id) {\n return {\n ...order,\n customerName: EditOrderCustomerName.value,\n customerEmail: EditOrderCustomerEmail.value,\n amount: EditOrderAmount.value,\n status: EditOrderStatus.selectedOptionValue,\n notes: EditOrderNotes.value,\n updatedAt: new Date().toISOString(),\n };\n }\n return order;\n });\n\n // Update the orders state\n OrdersStateVar.setValue(updatedOrders);\n })\n .controlModal(EditOrderModal, "close")}\n />\n </SbContainer>\n </SbContainer>\n</SbModal>\n```\n\n**Corresponding scope.ts file for the table + edit modal example:**\n\n```ts\n// pages/Page1/scope.ts\nimport {\n createSbScope,\n SbVariable,\n SbVariablePersistence,\n} from "@superblocksteam/library";\n\nexport const Page1Scope = createSbScope<{\n OrdersTable: any;\n EditOrderModal: any;\n EditOrderCustomerName: any;\n EditOrderCustomerEmail: any;\n EditOrderAmount: any;\n EditOrderStatus: any;\n EditOrderNotes: any;\n OrdersStateVar: any;\n}>(\n () => ({\n OrdersStateVar: SbVariable({\n defaultValue: [\n {\n id: 1,\n customerName: "John Doe",\n customerEmail: "john@example.com",\n amount: 150.0,\n status: "pending",\n notes: "Rush order",\n createdAt: "2024-01-15T10:30:00Z",\n },\n {\n id: 2,\n customerName: "Jane Smith",\n customerEmail: "jane@example.com",\n amount: 89.99,\n status: "delivered",\n notes: "",\n createdAt: "2024-01-14T14:20:00Z",\n },\n ],\n persistence: SbVariablePersistence.TEMPORARY,\n }),\n }),\n {\n name: "Page1",\n },\n);\n\nexport const Page1 = Page1Scope.entities;\n```\n\n#### Alternative Population Method - Button with State Variable\n\nHere\'s another common pattern where a button populates form fields from a state variable:\n\n```tsx\n// Button that loads selected user data into edit form\n<SbButton\n label="Edit Selected User"\n onClick={SbEventFlow.runJS(() => {\n const selectedUser = SelectedUserStateVar.value;\n\n // Populate form fields from state variable\n EditUserName.text = selectedUser.name;\n EditUserEmail.text = selectedUser.email;\n EditUserRole.metaSelectedOptionValue = selectedUser.role;\n EditUserDepartment.text = selectedUser.department;\n }).controlModal(EditUserModal, "open")}\n/>\n```\n\n### Key Form Patterns\n\n1. **Create Forms**: Start with empty fields, populate from user input\n2. **Edit Forms**: Pre-populate fields with existing data from various sources\n3. **Field Population Methods**:\n - **Table Row Selection**: Use `onRowClick` to set form field values to `{TableName}.selectedRow.{columnName}` (most common)\n - **Button Actions**: Use button clicks to populate from state variables or API responses\n - **API Loading**: Fetch data and populate fields when modal opens\n - **State Variables**: Populate from existing application state\n4. **Form Validation**: Use `required={true}` on form components and validate in submit handlers\n5. **Form Reset**: Always reset form fields when canceling or after successful submission\n6. **Modal Control**: Prefer `SbEventFlow.controlModal()` over directly setting modal open property\n\n### Form Layout Best Practices\n\n- **Container Structure**: Always wrap forms in `SbContainer` with `layout="vertical"`\n- **Consistent Spacing**: Use `spacing={Dim.px(12)}` for form field spacing\n- **Full Width**: Make form fields and containers `width={Dim.fill()}` for proper alignment\n- **Modal Structure**: Use header, content, and footer containers with appropriate spacing\n- **Button Alignment**: Use `horizontalAlign="right"` for the footer containers in modals that contain buttons\n';
56
56
 
57
57
  // ../../../vite-plugin-file-sync/dist/ai-service/prompts/generated/subprompts/superblocks-layouts.js
58
58
  init_cjs_shims();
@@ -182,7 +182,7 @@ var content31 = '## Dim\n\nThe `Dim` class is used to define dimensions for size
182
182
 
183
183
  // ../../../vite-plugin-file-sync/dist/ai-service/prompts/generated/library-typedefs/SbEventFlow.js
184
184
  init_cjs_shims();
185
- var content32 = '## SbEventFlow\n\nThe `SbEventFlow` class is used to define responses to events triggered on components (like onClick) in Superblocks. It has a number of methods that can be chained together.\n\n```typescript\nclass SbEventFlow {\n // Run custom JavaScript code\n static runJS(handler: () => void): SbEventFlow;\n runJS(handler: () => void): this;\n\n // Navigation methods\n static navigateTo(props: { url: string; newWindow?: boolean }): SbEventFlow;\n navigateTo(props: { url: string; newWindow?: boolean }): this;\n\n static navigateToApp(appId: string): SbEventFlow;\n navigateToApp(appId: string): this;\n\n static navigateToRoute(route: string): SbEventFlow;\n navigateToRoute(route: string): this;\n\n static setQueryParams(\n params: Record<string, string>,\n keepQueryParams?: boolean,\n ): SbEventFlow;\n setQueryParams(\n params: Record<string, string>,\n keepQueryParams?: boolean,\n ): this;\n\n // Control whether modals are opened or closed\n // modalId should be the name of the string value of the bind property on the modal component\n static controlModal(modalId: string, action: "open" | "close"): SbEventFlow;\n controlModal(modalId: string, action: "open" | "close"): this;\n\n static controlTimer(\n timerId: string,\n action: "start" | "stop" | "toggle",\n ): SbEventFlow;\n controlTimer(timerId: string, action: "start" | "stop" | "toggle"): this;\n\n // API methods\n static runApis(\n apis: SbApi[],\n onSuccess?: SbEventFlow,\n onError?: SbEventFlow,\n ): SbEventFlow;\n runApis(apis: SbApi[], onSuccess?: SbEventFlow, onError?: SbEventFlow): this;\n\n static cancelApis(apiNames: string[], onCancel?: SbEventFlow): SbEventFlow;\n cancelApis(apiNames: string[], onCancel?: SbEventFlow): this;\n\n // Component and state manipulation\n static resetComponent(\n widget: { id: string },\n propertyName: string,\n resetChildren: boolean,\n ): SbEventFlow;\n resetComponent(\n widget: { id: string },\n propertyName: string,\n resetChildren: boolean,\n ): this;\n\n static resetStateVar(stateVar: SbVariable): SbEventFlow;\n resetStateVar(stateVar: SbVariable): this;\n\n static setStateVar(stateVar: SbVariable, value: any): SbEventFlow;\n setStateVar(stateVar: SbVariable, value: any): this;\n\n static setComponentProperty(\n widget: { id: string },\n propertyName: string,\n value: any,\n ): SbEventFlow;\n setComponentProperty(\n widget: { id: string },\n propertyName: string,\n value: any,\n ): this;\n\n // Utility methods\n static showAlert(\n message: string,\n alertType: "info" | "success" | "warning" | "error",\n ): SbEventFlow;\n showAlert(\n message: string,\n alertType: "info" | "success" | "warning" | "error",\n ): this;\n\n static setProfile(\n profileId: string,\n profileAction: "set" | "unset",\n ): SbEventFlow;\n setProfile(profileId: string, profileAction: "set" | "unset"): this;\n\n static triggerEvent(\n eventName: string,\n eventData: Record<string, string>,\n ): SbEventFlow;\n triggerEvent(eventName: string, eventData: Record<string, string>): this;\n}\n```\n';
185
+ var content32 = '## SbEventFlow\n\nThe `SbEventFlow` class is used to define responses to events triggered on components (like onClick) in Superblocks. It has a number of methods that can be chained together.\n\n```typescript\nclass SbEventFlow {\n // Run custom JavaScript code\n static runJS(handler: () => void): SbEventFlow;\n runJS(handler: () => void): this;\n\n // Navigation methods\n static navigateTo(props: { url: string; newWindow?: boolean }): SbEventFlow;\n navigateTo(props: { url: string; newWindow?: boolean }): this;\n\n static navigateToApp(appId: string): SbEventFlow;\n navigateToApp(appId: string): this;\n\n static navigateToRoute(route: string): SbEventFlow;\n navigateToRoute(route: string): this;\n\n static setQueryParams(\n params: Record<string, string>,\n keepQueryParams?: boolean,\n ): SbEventFlow;\n setQueryParams(\n params: Record<string, string>,\n keepQueryParams?: boolean,\n ): this;\n\n // Control whether modals are opened or closed\n // Pass the bound modal component directly rather than its id\n static controlModal(\n modal: WithBindingIdentifier,\n action: "open" | "close",\n ): SbEventFlow;\n controlModal(modal: WithBindingIdentifier, action: "open" | "close"): this;\n\n static controlTimer(\n timerId: string,\n action: "start" | "stop" | "toggle",\n ): SbEventFlow;\n controlTimer(timerId: string, action: "start" | "stop" | "toggle"): this;\n\n // API methods\n static runApis(\n apis: SbApi[],\n onSuccess?: SbEventFlow,\n onError?: SbEventFlow,\n ): SbEventFlow;\n runApis(apis: SbApi[], onSuccess?: SbEventFlow, onError?: SbEventFlow): this;\n\n static cancelApis(apiNames: string[], onCancel?: SbEventFlow): SbEventFlow;\n cancelApis(apiNames: string[], onCancel?: SbEventFlow): this;\n\n // Component and state manipulation\n static resetComponent(\n widget: { id: string },\n propertyName: string,\n resetChildren: boolean,\n ): SbEventFlow;\n resetComponent(\n widget: { id: string },\n propertyName: string,\n resetChildren: boolean,\n ): this;\n\n static resetStateVar(stateVar: SbVariable): SbEventFlow;\n resetStateVar(stateVar: SbVariable): this;\n\n static setStateVar(stateVar: SbVariable, value: any): SbEventFlow;\n setStateVar(stateVar: SbVariable, value: any): this;\n\n static setComponentProperty(\n widget: { id: string },\n propertyName: string,\n value: any,\n ): SbEventFlow;\n setComponentProperty(\n widget: { id: string },\n propertyName: string,\n value: any,\n ): this;\n\n // Utility methods\n static showAlert(\n message: string,\n alertType: "info" | "success" | "warning" | "error",\n ): SbEventFlow;\n showAlert(\n message: string,\n alertType: "info" | "success" | "warning" | "error",\n ): this;\n\n static setProfile(\n profileId: string,\n profileAction: "set" | "unset",\n ): SbEventFlow;\n setProfile(profileId: string, profileAction: "set" | "unset"): this;\n\n static triggerEvent(\n eventName: string,\n eventData: Record<string, string>,\n ): SbEventFlow;\n triggerEvent(eventName: string, eventData: Record<string, string>): this;\n}\n```\n';
186
186
  export {
187
187
  library_components_exports as library_components,
188
188
  library_typedefs_exports as library_typedefs,
package/dist/index.js CHANGED
@@ -393072,7 +393072,7 @@ init_cjs_shims();
393072
393072
  init_cjs_shims();
393073
393073
  var generated = {};
393074
393074
  try {
393075
- generated = await import("./generated-W6HVWB2O.js");
393075
+ generated = await import("./generated-36L7KYTH.js");
393076
393076
  } catch (_error) {
393077
393077
  getLogger().warn("[ai-service] Generated markdown modules not found. Run `pnpm generate:markdown` first.");
393078
393078
  }
@@ -401003,6 +401003,12 @@ var BindingMetaSymbol = Symbol("binding-meta");
401003
401003
  // ../../../library-shared/dist/types/ai-operations.js
401004
401004
  init_cjs_shims();
401005
401005
 
401006
+ // ../../../library-shared/dist/types/vite.js
401007
+ init_cjs_shims();
401008
+ var VitePostMessageKind = {
401009
+ UPDATE_CUSTOM_COMPONENT: "update-custom-component"
401010
+ };
401011
+
401006
401012
  // ../../../vite-plugin-file-sync/dist/sync-service/index.js
401007
401013
  var import_shared19 = __toESM(require_dist2(), 1);
401008
401014
 
@@ -407967,9 +407973,9 @@ var extractApiDependencies = (allApiNames, apiBindingBlock) => {
407967
407973
  // ../../../vite-plugin-file-sync/dist/components-manager.js
407968
407974
  init_cjs_shims();
407969
407975
  var import_parser = __toESM(require_lib9(), 1);
407970
- var import_shared24 = __toESM(require_dist2(), 1);
407971
407976
  import fs11 from "node:fs/promises";
407972
407977
  import path23 from "node:path";
407978
+ var import_shared24 = __toESM(require_dist2(), 1);
407973
407979
 
407974
407980
  // ../../../vite-plugin-file-sync/dist/file-system-helpers.js
407975
407981
  init_cjs_shims();
@@ -408019,7 +408025,7 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408019
408025
  });
408020
408026
  for (const file of projectFiles) {
408021
408027
  const fileContents = await fs11.readFile(file, "utf-8");
408022
- const componentName = await this.getComponentName(fileContents);
408028
+ const componentName = await this.getComponentNameFromFile(fileContents);
408023
408029
  if (componentName) {
408024
408030
  this.registeredComponentNames[file] = componentName;
408025
408031
  this.fileContents[file] = fileContents;
@@ -408040,7 +408046,7 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408040
408046
  const newFileContents = await fs11.readFile(path54, "utf-8");
408041
408047
  if (existingFileContents !== newFileContents) {
408042
408048
  this.fileContents[path54] = newFileContents;
408043
- const newComponentName = await this.getComponentName(newFileContents);
408049
+ const newComponentName = await this.getComponentNameFromFile(newFileContents);
408044
408050
  const existingName = this.registeredComponentNames[path54];
408045
408051
  if (existingName && !newComponentName) {
408046
408052
  this.emit("registeredComponentRemoved", existingName);
@@ -408063,7 +408069,7 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408063
408069
  return;
408064
408070
  try {
408065
408071
  const fileContents = await fs11.readFile(path54, "utf-8");
408066
- const componentName = await this.getComponentName(fileContents);
408072
+ const componentName = await this.getComponentNameFromFile(fileContents);
408067
408073
  if (componentName) {
408068
408074
  this.registeredComponentNames[path54] = componentName;
408069
408075
  this.fileContents[path54] = fileContents;
@@ -408082,9 +408088,15 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408082
408088
  return;
408083
408089
  this.emit("registeredComponentRemoved", componentName);
408084
408090
  };
408091
+ isCustomComponentFile(path54) {
408092
+ return path54 in this.registeredComponentNames;
408093
+ }
408085
408094
  isCustomComponent(componentName) {
408086
408095
  return Object.values(this.registeredComponentNames).includes(componentName);
408087
408096
  }
408097
+ getComponentName(path54) {
408098
+ return this.registeredComponentNames[path54];
408099
+ }
408088
408100
  getComponentImportPath(componentName, rootPath) {
408089
408101
  const filePath = Object.keys(this.registeredComponentNames).find((filePath2) => this.registeredComponentNames[filePath2] === componentName);
408090
408102
  if (!filePath) {
@@ -408102,7 +408114,7 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408102
408114
  *
408103
408115
  * We can make these assumptions for now, but maybe we revisit them in the future.
408104
408116
  */
408105
- async getComponentName(fileContents) {
408117
+ async getComponentNameFromFile(fileContents) {
408106
408118
  if (!fileContents.includes("registerComponent")) {
408107
408119
  return;
408108
408120
  }
@@ -408142,11 +408154,37 @@ var ComponentsManager = class _ComponentsManager extends import_shared24.TracedE
408142
408154
  return Object.keys(this.registeredComponentNames);
408143
408155
  }
408144
408156
  };
408157
+ function getComponentSourceCode(fileContents) {
408158
+ return (
408159
+ /*js*/
408160
+ `
408161
+ ${fileContents}
408162
+ if (import.meta.hot) {
408163
+ import.meta.hot.on("vite:afterUpdate", (data) => {
408164
+ try {
408165
+ const currentFilePath = new URL(import.meta.url).pathname;
408166
+ const isFileUpdated = Array.isArray(data.updates) && data.updates.some(update => update.path === currentFilePath);
408167
+ if (isFileUpdated) {
408168
+ window.postMessage(
408169
+ {
408170
+ kind: "${VitePostMessageKind.UPDATE_CUSTOM_COMPONENT}",
408171
+ component: componentName,
408172
+ },
408173
+ "*",
408174
+ );
408175
+ }
408176
+ } catch {
408177
+ // ignore
408178
+ }
408179
+ });
408180
+ }`
408181
+ );
408182
+ }
408145
408183
 
408146
408184
  // ../../../vite-plugin-file-sync/dist/file-system-manager.js
408147
408185
  init_cjs_shims();
408148
408186
  var import_core3 = __toESM(require_lib36(), 1);
408149
- var import_types25 = __toESM(require_lib7(), 1);
408187
+ var import_types26 = __toESM(require_lib7(), 1);
408150
408188
  import fs12 from "fs/promises";
408151
408189
  import path27 from "node:path";
408152
408190
  var import_shared32 = __toESM(require_dist2(), 1);
@@ -408156,12 +408194,12 @@ var import_yaml2 = __toESM(require_dist(), 1);
408156
408194
 
408157
408195
  // ../../../vite-plugin-file-sync/dist/codegen.js
408158
408196
  init_cjs_shims();
408159
- var import_types12 = __toESM(require_lib7(), 1);
408197
+ var import_types13 = __toESM(require_lib7(), 1);
408160
408198
  var import_json5 = __toESM(require_lib10(), 1);
408161
408199
 
408162
408200
  // ../../../vite-plugin-file-sync/dist/parsing/ids.js
408163
408201
  init_cjs_shims();
408164
- var import_types11 = __toESM(require_lib7(), 1);
408202
+ var import_types12 = __toESM(require_lib7(), 1);
408165
408203
 
408166
408204
  // ../../../vite-plugin-file-sync/dist/ids.js
408167
408205
  init_cjs_shims();
@@ -408184,7 +408222,7 @@ var generatePredictableId2 = (name18) => {
408184
408222
 
408185
408223
  // ../../../vite-plugin-file-sync/dist/parsing/jsx.js
408186
408224
  init_cjs_shims();
408187
- var import_types10 = __toESM(require_lib7(), 1);
408225
+ var import_types11 = __toESM(require_lib7(), 1);
408188
408226
  var import_shared27 = __toESM(require_dist2(), 1);
408189
408227
 
408190
408228
  // ../../../vite-plugin-file-sync/dist/parsing/properties.js
@@ -408196,7 +408234,7 @@ init_cjs_shims();
408196
408234
  // ../../../vite-plugin-file-sync/dist/parsing/util.js
408197
408235
  init_cjs_shims();
408198
408236
  var import_parser2 = __toESM(require_lib9(), 1);
408199
- var import_types7 = __toESM(require_lib7(), 1);
408237
+ var import_types8 = __toESM(require_lib7(), 1);
408200
408238
  import path24 from "node:path";
408201
408239
 
408202
408240
  // ../../../vite-plugin-file-sync/dist/generate.js
@@ -408217,10 +408255,10 @@ function objectExpressionToObject(obj, context2) {
408217
408255
  }, {});
408218
408256
  }
408219
408257
  function createObjectKey(key2) {
408220
- return import_types7.default.isValidIdentifier(key2) ? import_types7.default.identifier(key2) : import_types7.default.stringLiteral(key2);
408258
+ return import_types8.default.isValidIdentifier(key2) ? import_types8.default.identifier(key2) : import_types8.default.stringLiteral(key2);
408221
408259
  }
408222
408260
  function stringToTaggedTemplate(str2) {
408223
- return import_types7.default.taggedTemplateExpression(import_types7.default.identifier("SB"), import_types7.default.templateLiteral([import_types7.default.templateElement({ raw: str2, cooked: str2 }, true)], []));
408261
+ return import_types8.default.taggedTemplateExpression(import_types8.default.identifier("SB"), import_types8.default.templateLiteral([import_types8.default.templateElement({ raw: str2, cooked: str2 }, true)], []));
408224
408262
  }
408225
408263
  function nodeToValue(node, context2) {
408226
408264
  switch (node.type) {
@@ -408239,7 +408277,7 @@ function nodeToValue(node, context2) {
408239
408277
  if (element) {
408240
408278
  return nodeToValue(element);
408241
408279
  }
408242
- return import_types7.default.nullLiteral();
408280
+ return import_types8.default.nullLiteral();
408243
408281
  });
408244
408282
  case "ObjectExpression":
408245
408283
  return objectExpressionToObject(node, context2);
@@ -408377,9 +408415,9 @@ function addImport({ path: path54, importName, importPath, isDefaultImport, onAd
408377
408415
  return;
408378
408416
  }
408379
408417
  const existingImportDeclaration = programPath.get("body").find((p) => p.isImportDeclaration() && p.node.source.value === importPath);
408380
- const importSpecifier = isDefaultImport ? import_types7.default.importDefaultSpecifier(import_types7.default.identifier(importName)) : import_types7.default.importSpecifier(import_types7.default.identifier(importName), import_types7.default.identifier(importName));
408418
+ const importSpecifier = isDefaultImport ? import_types8.default.importDefaultSpecifier(import_types8.default.identifier(importName)) : import_types8.default.importSpecifier(import_types8.default.identifier(importName), import_types8.default.identifier(importName));
408381
408419
  if (!existingImportDeclaration) {
408382
- programPath.unshiftContainer("body", import_types7.default.importDeclaration([importSpecifier], import_types7.default.stringLiteral(importPath)));
408420
+ programPath.unshiftContainer("body", import_types8.default.importDeclaration([importSpecifier], import_types8.default.stringLiteral(importPath)));
408383
408421
  } else {
408384
408422
  const existingSpecifier = existingImportDeclaration.node.specifiers.find((specifier) => specifier.type === "ImportSpecifier" && specifier.local.name === importName);
408385
408423
  if (existingSpecifier) {
@@ -408438,18 +408476,18 @@ function isSbScopeFunction(name18) {
408438
408476
  }
408439
408477
  function extractNameFromBindAttribute(bindAttribute, identifierOnly = false) {
408440
408478
  const bindValue = bindAttribute.value;
408441
- if (!bindValue || !import_types7.default.isJSXExpressionContainer(bindValue)) {
408479
+ if (!bindValue || !import_types8.default.isJSXExpressionContainer(bindValue)) {
408442
408480
  return null;
408443
408481
  }
408444
408482
  const expression = bindValue.expression;
408445
- if (import_types7.default.isIdentifier(expression)) {
408483
+ if (import_types8.default.isIdentifier(expression)) {
408446
408484
  return expression.name;
408447
408485
  }
408448
408486
  if (identifierOnly) {
408449
408487
  return null;
408450
408488
  }
408451
- if (import_types7.default.isMemberExpression(expression)) {
408452
- if (import_types7.default.isIdentifier(expression.property)) {
408489
+ if (import_types8.default.isMemberExpression(expression)) {
408490
+ if (import_types8.default.isIdentifier(expression.property)) {
408453
408491
  return expression.property.name;
408454
408492
  }
408455
408493
  }
@@ -408470,7 +408508,7 @@ function parseExpression(value2) {
408470
408508
  sourceType: "module",
408471
408509
  plugins: [["typescript", {}], "jsx"]
408472
408510
  });
408473
- const exprStatement = compiled.program.body.find((node) => import_types7.default.isExpressionStatement(node));
408511
+ const exprStatement = compiled.program.body.find((node) => import_types8.default.isExpressionStatement(node));
408474
408512
  if (exprStatement) {
408475
408513
  return exprStatement.expression;
408476
408514
  } else {
@@ -408812,10 +408850,10 @@ function toCodeEventFlow(stepDefs_) {
408812
408850
 
408813
408851
  // ../../../vite-plugin-file-sync/dist/parsing/events/to-value-events.js
408814
408852
  init_cjs_shims();
408815
- var import_types9 = __toESM(require_lib7(), 1);
408853
+ var import_types10 = __toESM(require_lib7(), 1);
408816
408854
  var import_shared26 = __toESM(require_dist2(), 1);
408817
408855
  var getApiCallbackNode = (nodePath) => {
408818
- if (nodePath && (0, import_types9.isCallExpression)(nodePath.node) && (0, import_types9.isMemberExpression)(nodePath.node.callee) && (0, import_types9.isIdentifier)(nodePath.node.callee.object) && nodePath.node.callee.object.name === "SbEventFlow") {
408856
+ if (nodePath && (0, import_types10.isCallExpression)(nodePath.node) && (0, import_types10.isMemberExpression)(nodePath.node.callee) && (0, import_types10.isIdentifier)(nodePath.node.callee.object) && nodePath.node.callee.object.name === "SbEventFlow") {
408819
408857
  return toValueEventFlow(nodePath);
408820
408858
  }
408821
408859
  return [];
@@ -409157,7 +409195,7 @@ function parseNodeProperties(node) {
409157
409195
 
409158
409196
  // ../../../vite-plugin-file-sync/dist/parsing/jsx.js
409159
409197
  function makeJSXAttribute(key2, value2) {
409160
- return import_types10.default.jsxAttribute(import_types10.default.jsxIdentifier(key2), import_types10.default.stringLiteral(value2));
409198
+ return import_types11.default.jsxAttribute(import_types11.default.jsxIdentifier(key2), import_types11.default.stringLiteral(value2));
409161
409199
  }
409162
409200
  function tagNameToWidgetType(tagName) {
409163
409201
  switch (tagName) {
@@ -409372,18 +409410,18 @@ function getVariableReferences(jsxAttribute, variablesToCheck) {
409372
409410
  let visit2 = function(node) {
409373
409411
  if (!node || typeof node !== "object")
409374
409412
  return;
409375
- if (import_types10.default.isIdentifier(node)) {
409413
+ if (import_types11.default.isIdentifier(node)) {
409376
409414
  if (variablesToCheck.has(node.name)) {
409377
409415
  result.add(node.name);
409378
409416
  }
409379
409417
  }
409380
- if (import_types10.default.isMemberExpression(node)) {
409381
- if (import_types10.default.isIdentifier(node.object) && variablesToCheck.has(node.object.name)) {
409418
+ if (import_types11.default.isMemberExpression(node)) {
409419
+ if (import_types11.default.isIdentifier(node.object) && variablesToCheck.has(node.object.name)) {
409382
409420
  result.add(node.object.name);
409383
409421
  }
409384
409422
  }
409385
- if (import_types10.default.isCallExpression(node)) {
409386
- if (import_types10.default.isIdentifier(node.callee) && variablesToCheck.has(node.callee.name)) {
409423
+ if (import_types11.default.isCallExpression(node)) {
409424
+ if (import_types11.default.isIdentifier(node.callee) && variablesToCheck.has(node.callee.name)) {
409387
409425
  result.add(node.callee.name);
409388
409426
  }
409389
409427
  }
@@ -409453,7 +409491,7 @@ function supplementElementIds({ fileName, ast, shouldModifyAst, scopeId }) {
409453
409491
  }
409454
409492
  });
409455
409493
  }
409456
- if (entitiesObject && (0, import_types11.isObjectExpression)(entitiesObject.node)) {
409494
+ if (entitiesObject && (0, import_types12.isObjectExpression)(entitiesObject.node)) {
409457
409495
  entitiesObject.node.properties.forEach((property, index) => {
409458
409496
  if (property.type === "ObjectProperty") {
409459
409497
  const name18 = nodeToValue(property.key);
@@ -409461,9 +409499,9 @@ function supplementElementIds({ fileName, ast, shouldModifyAst, scopeId }) {
409461
409499
  idMap.set(id2, entitiesObject.get(`properties.${index}`));
409462
409500
  setSbElementId(property, id2);
409463
409501
  if (shouldModifyAst) {
409464
- if ((0, import_types11.isCallExpression)(property.value) && (0, import_types11.isObjectExpression)(property.value.arguments[0])) {
409502
+ if ((0, import_types12.isCallExpression)(property.value) && (0, import_types12.isObjectExpression)(property.value.arguments[0])) {
409465
409503
  const entityConfig = property.value.arguments[0];
409466
- entityConfig.properties.push((0, import_types11.objectProperty)((0, import_types11.identifier)("id"), (0, import_types11.stringLiteral)(id2)));
409504
+ entityConfig.properties.push((0, import_types12.objectProperty)((0, import_types12.identifier)("id"), (0, import_types12.stringLiteral)(id2)));
409467
409505
  }
409468
409506
  }
409469
409507
  }
@@ -409527,11 +409565,11 @@ function generateElementId(fileName, parentPath, count) {
409527
409565
  function generateJSXElement({ id: id2, tagName, properties, children }) {
409528
409566
  const attributes = Object.entries(properties).map(([name18, value2]) => generateJSXAttribute(name18, value2));
409529
409567
  const selfClosing = children.length === 0;
409530
- const openingElement = import_types12.default.jsxOpeningElement(import_types12.default.jsxIdentifier(tagName), attributes, selfClosing);
409568
+ const openingElement = import_types13.default.jsxOpeningElement(import_types13.default.jsxIdentifier(tagName), attributes, selfClosing);
409531
409569
  if (id2) {
409532
409570
  setSbElementId(openingElement, id2);
409533
409571
  }
409534
- const jsxElement = import_types12.default.jsxElement(openingElement, selfClosing ? null : import_types12.default.jsxClosingElement(import_types12.default.jsxIdentifier(tagName)), [], selfClosing);
409572
+ const jsxElement = import_types13.default.jsxElement(openingElement, selfClosing ? null : import_types13.default.jsxClosingElement(import_types13.default.jsxIdentifier(tagName)), [], selfClosing);
409535
409573
  const childElements = children.map((child) => {
409536
409574
  return generateJSXElement(child);
409537
409575
  });
@@ -409540,10 +409578,10 @@ function generateJSXElement({ id: id2, tagName, properties, children }) {
409540
409578
  }
409541
409579
  function generateJSXAttribute(name18, info) {
409542
409580
  const valueNode = getPropertyExpression(info, name18);
409543
- if (import_types12.default.isStringLiteral(valueNode)) {
409544
- return import_types12.default.jsxAttribute(import_types12.default.jsxIdentifier(name18), valueNode);
409581
+ if (import_types13.default.isStringLiteral(valueNode)) {
409582
+ return import_types13.default.jsxAttribute(import_types13.default.jsxIdentifier(name18), valueNode);
409545
409583
  } else {
409546
- return import_types12.default.jsxAttribute(import_types12.default.jsxIdentifier(name18), import_types12.default.jsxExpressionContainer(valueNode));
409584
+ return import_types13.default.jsxAttribute(import_types13.default.jsxIdentifier(name18), import_types13.default.jsxExpressionContainer(valueNode));
409547
409585
  }
409548
409586
  }
409549
409587
  function writeNestedProperty({ node, paths, info, isDelete = false }) {
@@ -409572,9 +409610,9 @@ function writeNestedProperty({ node, paths, info, isDelete = false }) {
409572
409610
  if (isDelete) {
409573
409611
  return;
409574
409612
  }
409575
- const value3 = cleanedPaths.length > 0 ? import_types12.default.objectExpression([]) : import_types12.default.stringLiteral("");
409613
+ const value3 = cleanedPaths.length > 0 ? import_types13.default.objectExpression([]) : import_types13.default.stringLiteral("");
409576
409614
  property = currentNode.pushContainer("properties", [
409577
- import_types12.default.objectProperty(createObjectKey(currentKey.toString()), value3)
409615
+ import_types13.default.objectProperty(createObjectKey(currentKey.toString()), value3)
409578
409616
  ])[0];
409579
409617
  }
409580
409618
  const value2 = property?.get("value");
@@ -409596,7 +409634,7 @@ function writeNestedProperty({ node, paths, info, isDelete = false }) {
409596
409634
  return;
409597
409635
  }
409598
409636
  if (cleanedPaths.length > 0) {
409599
- const newObjectNode = import_types12.default.objectExpression([]);
409637
+ const newObjectNode = import_types13.default.objectExpression([]);
409600
409638
  if (currentNode.get("elements").length > 0) {
409601
409639
  if (index === 0) {
409602
409640
  currentNode = currentNode.unshiftContainer("elements", [
@@ -409615,7 +409653,7 @@ function writeNestedProperty({ node, paths, info, isDelete = false }) {
409615
409653
  }
409616
409654
  } else {
409617
409655
  currentNode = currentNode.pushContainer("elements", [
409618
- import_types12.default.stringLiteral(String(info.value))
409656
+ import_types13.default.stringLiteral(String(info.value))
409619
409657
  ])[0];
409620
409658
  }
409621
409659
  } else {
@@ -409641,7 +409679,7 @@ function getPropertyExpression(info, fieldName = "") {
409641
409679
  if (expression) {
409642
409680
  return expression;
409643
409681
  } else {
409644
- return import_types12.default.stringLiteral(code);
409682
+ return import_types13.default.stringLiteral(code);
409645
409683
  }
409646
409684
  } else if (type2 === "DIMENSION") {
409647
409685
  const code = parsingRegistry.DIMENSION.toCode(value2, info);
@@ -409649,7 +409687,7 @@ function getPropertyExpression(info, fieldName = "") {
409649
409687
  if (expression) {
409650
409688
  return expression;
409651
409689
  } else {
409652
- return import_types12.default.stringLiteral(code);
409690
+ return import_types13.default.stringLiteral(code);
409653
409691
  }
409654
409692
  }
409655
409693
  if (type2 === "EVENT") {
@@ -409658,7 +409696,7 @@ function getPropertyExpression(info, fieldName = "") {
409658
409696
  if (expression) {
409659
409697
  return expression;
409660
409698
  } else {
409661
- return import_types12.default.stringLiteral(code);
409699
+ return import_types13.default.stringLiteral(code);
409662
409700
  }
409663
409701
  }
409664
409702
  if (type2 === "EXPRESSION" && typeof value2 === "string") {
@@ -409666,7 +409704,7 @@ function getPropertyExpression(info, fieldName = "") {
409666
409704
  if (expression) {
409667
409705
  return expression;
409668
409706
  } else {
409669
- return import_types12.default.stringLiteral(value2);
409707
+ return import_types13.default.stringLiteral(value2);
409670
409708
  }
409671
409709
  } else if (type2 === "COMPUTED" && typeof value2 === "string") {
409672
409710
  let parsed;
@@ -409685,7 +409723,7 @@ function getPropertyExpression(info, fieldName = "") {
409685
409723
  } catch (e) {
409686
409724
  getLogger().error("could not generate computed expression", getErrorMeta(e));
409687
409725
  }
409688
- const fallbackLiteral = import_types12.default.templateLiteral([import_types12.default.templateElement({ raw: value2, cooked: value2 }, true)], []);
409726
+ const fallbackLiteral = import_types13.default.templateLiteral([import_types13.default.templateElement({ raw: value2, cooked: value2 }, true)], []);
409689
409727
  fallbackLiteral.extra = {
409690
409728
  computedFallback: true,
409691
409729
  error: "Could not generate computed expression"
@@ -409698,10 +409736,10 @@ function getPropertyExpression(info, fieldName = "") {
409698
409736
  const propertyInfo = isPropertyInfo(v) ? v : Property.Any(v);
409699
409737
  return getPropertyExpression(propertyInfo, fieldName);
409700
409738
  });
409701
- return import_types12.default.arrayExpression(arrayElements);
409739
+ return import_types13.default.arrayExpression(arrayElements);
409702
409740
  }
409703
409741
  if (typeof value2 === "object" && value2 !== null) {
409704
- return import_types12.default.objectExpression(Object.entries(value2).map(([key2, value3]) => {
409742
+ return import_types13.default.objectExpression(Object.entries(value2).map(([key2, value3]) => {
409705
409743
  let objectValue;
409706
409744
  if (isPropertyInfo(value3)) {
409707
409745
  objectValue = getPropertyExpression(value3, key2);
@@ -409710,38 +409748,38 @@ function getPropertyExpression(info, fieldName = "") {
409710
409748
  } else if (typeof value3 === "object" && value3 !== null) {
409711
409749
  objectValue = getPropertyExpression(Property.Any(value3), key2);
409712
409750
  } else {
409713
- objectValue = (0, import_types12.valueToNode)(value3);
409751
+ objectValue = (0, import_types13.valueToNode)(value3);
409714
409752
  }
409715
- return import_types12.default.objectProperty(createObjectKey(key2), objectValue);
409753
+ return import_types13.default.objectProperty(createObjectKey(key2), objectValue);
409716
409754
  }));
409717
409755
  }
409718
409756
  if (typeof value2 === "number") {
409719
- return import_types12.default.numericLiteral(value2);
409757
+ return import_types13.default.numericLiteral(value2);
409720
409758
  }
409721
409759
  if (typeof value2 === "boolean") {
409722
- return import_types12.default.booleanLiteral(value2);
409760
+ return import_types13.default.booleanLiteral(value2);
409723
409761
  }
409724
409762
  if (typeof value2 === "string") {
409725
409763
  if (canBeAStringLiteral(value2)) {
409726
- return import_types12.default.stringLiteral(value2);
409764
+ return import_types13.default.stringLiteral(value2);
409727
409765
  } else {
409728
- return import_types12.default.templateLiteral([import_types12.default.templateElement({ raw: value2, cooked: value2 }, true)], []);
409766
+ return import_types13.default.templateLiteral([import_types13.default.templateElement({ raw: value2, cooked: value2 }, true)], []);
409729
409767
  }
409730
409768
  }
409731
409769
  if (typeof value2 === "object" || value2 === void 0) {
409732
- return (0, import_types12.valueToNode)(value2);
409770
+ return (0, import_types13.valueToNode)(value2);
409733
409771
  }
409734
409772
  logger3.warn(`Unsupported value type: ${value2} ${type2}`);
409735
- return import_types12.default.stringLiteral(String(value2));
409773
+ return import_types13.default.stringLiteral(String(value2));
409736
409774
  } catch (e) {
409737
409775
  logger3.error(`Error generating code value: ${value2} ${type2}`, getErrorMeta(e));
409738
- return import_types12.default.stringLiteral(String(value2));
409776
+ return import_types13.default.stringLiteral(String(value2));
409739
409777
  }
409740
409778
  }
409741
409779
 
409742
409780
  // ../../../vite-plugin-file-sync/dist/custom-components.js
409743
409781
  init_cjs_shims();
409744
- var import_types13 = __toESM(require_lib7(), 1);
409782
+ var import_types14 = __toESM(require_lib7(), 1);
409745
409783
 
409746
409784
  // ../../../vite-plugin-file-sync/dist/plugin-options.js
409747
409785
  init_cjs_shims();
@@ -409766,31 +409804,31 @@ function modifyLegacyCustomComponentImports(path54, tracker) {
409766
409804
  if (!specifier)
409767
409805
  return;
409768
409806
  tracker.add(specifier.local.name);
409769
- path54.get("source").replaceWith(import_types13.default.stringLiteral(source2.replace(customFolder, `${customFolder}dist/`)));
409807
+ path54.get("source").replaceWith(import_types14.default.stringLiteral(source2.replace(customFolder, `${customFolder}dist/`)));
409770
409808
  const program = path54.scope.getProgramParent()?.path;
409771
409809
  const existingImport = program?.get("body").find((p) => p.isImportDeclaration() && p.node.source.value === "virtual:legacy-wrapper");
409772
409810
  if (existingImport) {
409773
409811
  return;
409774
409812
  }
409775
- program?.unshiftContainer("body", import_types13.default.importDeclaration([
409776
- import_types13.default.importSpecifier(import_types13.default.identifier("wrapCustomComponent"), import_types13.default.identifier("wrapCustomComponent"))
409777
- ], import_types13.default.stringLiteral("virtual:legacy-wrapper")));
409813
+ program?.unshiftContainer("body", import_types14.default.importDeclaration([
409814
+ import_types14.default.importSpecifier(import_types14.default.identifier("wrapCustomComponent"), import_types14.default.identifier("wrapCustomComponent"))
409815
+ ], import_types14.default.stringLiteral("virtual:legacy-wrapper")));
409778
409816
  }
409779
409817
  function modifyLegacyCustomComponentElements(path54, tracker) {
409780
409818
  const elementName = getTagName(path54.node.openingElement.name);
409781
409819
  if (elementName && tracker.has(elementName)) {
409782
- path54.get("openingElement").get("name").replaceWith(import_types13.default.jsxIdentifier(`Wrapped${elementName}`));
409820
+ path54.get("openingElement").get("name").replaceWith(import_types14.default.jsxIdentifier(`Wrapped${elementName}`));
409783
409821
  const closingElement = path54.get("closingElement");
409784
409822
  if (closingElement) {
409785
- closingElement.replaceWith(import_types13.default.jsxClosingElement(import_types13.default.jsxIdentifier(`Wrapped${elementName}`)));
409823
+ closingElement.replaceWith(import_types14.default.jsxClosingElement(import_types14.default.jsxIdentifier(`Wrapped${elementName}`)));
409786
409824
  }
409787
409825
  }
409788
409826
  }
409789
409827
  function addLegacyCustomComponentVariables(path54, tracker) {
409790
409828
  tracker.forEach((name18) => {
409791
- path54.unshiftContainer("body", import_types13.default.variableDeclaration("const", [
409792
- import_types13.default.variableDeclarator(import_types13.default.identifier(`Wrapped${name18}`), import_types13.default.callExpression(import_types13.default.identifier("wrapCustomComponent"), [
409793
- import_types13.default.identifier(name18)
409829
+ path54.unshiftContainer("body", import_types14.default.variableDeclaration("const", [
409830
+ import_types14.default.variableDeclarator(import_types14.default.identifier(`Wrapped${name18}`), import_types14.default.callExpression(import_types14.default.identifier("wrapCustomComponent"), [
409831
+ import_types14.default.identifier(name18)
409794
409832
  ]))
409795
409833
  ]));
409796
409834
  });
@@ -409958,7 +409996,7 @@ function getPageName(file) {
409958
409996
  init_cjs_shims();
409959
409997
  var import_core2 = __toESM(require_lib36(), 1);
409960
409998
  var import_parser4 = __toESM(require_lib9(), 1);
409961
- var import_types16 = __toESM(require_lib7(), 1);
409999
+ var import_types17 = __toESM(require_lib7(), 1);
409962
410000
  var t6 = __toESM(require_lib7(), 1);
409963
410001
 
409964
410002
  // ../../../vite-plugin-file-sync/dist/parsing/entity/index.js
@@ -410237,9 +410275,9 @@ function updateEntityNode(node, updates, entityId) {
410237
410275
  return property2.isObjectProperty() && property2.get("key").isIdentifier() && getIdentiferName(property2.node.key) === key2;
410238
410276
  });
410239
410277
  if (!property) {
410240
- configObject.pushContainer("properties", (0, import_types16.objectProperty)((0, import_types16.identifier)(key2), getPropertyExpression(info)));
410278
+ configObject.pushContainer("properties", (0, import_types17.objectProperty)((0, import_types17.identifier)(key2), getPropertyExpression(info)));
410241
410279
  } else {
410242
- property.replaceWith((0, import_types16.objectProperty)((0, import_types16.identifier)(key2), getPropertyExpression(info)));
410280
+ property.replaceWith((0, import_types17.objectProperty)((0, import_types17.identifier)(key2), getPropertyExpression(info)));
410243
410281
  }
410244
410282
  if (info.type in REQUIRED_IMPORTS_BY_PROPERTY_TYPE) {
410245
410283
  const requiredImports = REQUIRED_IMPORTS_BY_PROPERTY_TYPE[info.type];
@@ -410261,7 +410299,7 @@ function fromEntityToNode(entity) {
410261
410299
  throw new Error("Invalid entity ast definition");
410262
410300
  }
410263
410301
  return {
410264
- entity: (0, import_types16.objectProperty)((0, import_types16.identifier)(entity.name), parsedEntity.program.body[0].expression),
410302
+ entity: (0, import_types17.objectProperty)((0, import_types17.identifier)(entity.name), parsedEntity.program.body[0].expression),
410265
410303
  imports
410266
410304
  };
410267
410305
  }
@@ -410348,9 +410386,9 @@ function updateScopeUsages(scopeUsages, entityNames) {
410348
410386
  continue;
410349
410387
  const id2 = declaration.get("id");
410350
410388
  if (id2.isObjectPattern()) {
410351
- const newProperties = entityNames.map((name18) => (0, import_types16.objectProperty)(
410352
- (0, import_types16.identifier)(name18),
410353
- (0, import_types16.identifier)(name18),
410389
+ const newProperties = entityNames.map((name18) => (0, import_types17.objectProperty)(
410390
+ (0, import_types17.identifier)(name18),
410391
+ (0, import_types17.identifier)(name18),
410354
410392
  false,
410355
410393
  // computed
410356
410394
  true
@@ -410381,14 +410419,14 @@ function findEnclosingComponent(elementPath) {
410381
410419
  }
410382
410420
  function addScopeDestructuring(componentPath, scopeDefinition) {
410383
410421
  const uniqueEntityNames = [...new Set(scopeDefinition.entityNames)];
410384
- const destructuringDeclaration = (0, import_types16.variableDeclaration)("const", [
410385
- (0, import_types16.variableDeclarator)((0, import_types16.objectPattern)(uniqueEntityNames.map((name18) => (0, import_types16.objectProperty)(
410386
- (0, import_types16.identifier)(name18),
410387
- (0, import_types16.identifier)(name18),
410422
+ const destructuringDeclaration = (0, import_types17.variableDeclaration)("const", [
410423
+ (0, import_types17.variableDeclarator)((0, import_types17.objectPattern)(uniqueEntityNames.map((name18) => (0, import_types17.objectProperty)(
410424
+ (0, import_types17.identifier)(name18),
410425
+ (0, import_types17.identifier)(name18),
410388
410426
  false,
410389
410427
  // computed
410390
410428
  true
410391
- ))), (0, import_types16.identifier)(scopeDefinition.name))
410429
+ ))), (0, import_types17.identifier)(scopeDefinition.name))
410392
410430
  ]);
410393
410431
  let addedNodePath = null;
410394
410432
  if (componentPath.isFunctionDeclaration() || componentPath.isFunctionExpression() || componentPath.isArrowFunctionExpression()) {
@@ -410403,8 +410441,8 @@ function addScopeDestructuring(componentPath, scopeDefinition) {
410403
410441
  const [newPath] = body.unshiftContainer("body", destructuringDeclaration);
410404
410442
  addedNodePath = newPath;
410405
410443
  } else {
410406
- const retStatement = (0, import_types16.returnStatement)(body.node);
410407
- componentPath.node.body = (0, import_types16.blockStatement)([
410444
+ const retStatement = (0, import_types17.returnStatement)(body.node);
410445
+ componentPath.node.body = (0, import_types17.blockStatement)([
410408
410446
  destructuringDeclaration,
410409
410447
  retStatement
410410
410448
  ]);
@@ -410662,15 +410700,15 @@ function updateDestructuredEntitiesParam(scopeDef) {
410662
410700
  }
410663
410701
  return;
410664
410702
  }
410665
- const entitiesDestructuring = (0, import_types16.objectPattern)(uniqueEntityNames.map((name18) => (0, import_types16.objectProperty)(
410666
- (0, import_types16.identifier)(name18),
410667
- (0, import_types16.identifier)(name18),
410703
+ const entitiesDestructuring = (0, import_types17.objectPattern)(uniqueEntityNames.map((name18) => (0, import_types17.objectProperty)(
410704
+ (0, import_types17.identifier)(name18),
410705
+ (0, import_types17.identifier)(name18),
410668
410706
  false,
410669
410707
  // computed
410670
410708
  true
410671
410709
  )));
410672
- const entitiesProperty = (0, import_types16.objectProperty)((0, import_types16.identifier)("entities"), entitiesDestructuring);
410673
- const mainDestructuringPattern = (0, import_types16.objectPattern)([entitiesProperty]);
410710
+ const entitiesProperty = (0, import_types17.objectProperty)((0, import_types17.identifier)("entities"), entitiesDestructuring);
410711
+ const mainDestructuringPattern = (0, import_types17.objectPattern)([entitiesProperty]);
410674
410712
  if (scopeDef.scopeFunction.node.params.length > 0) {
410675
410713
  const firstParam = scopeDef.scopeFunction.get("params")[0];
410676
410714
  if (firstParam && firstParam.isObjectPattern()) {
@@ -410688,7 +410726,7 @@ function updateDestructuredEntitiesParam(scopeDef) {
410688
410726
 
410689
410727
  // ../../../vite-plugin-file-sync/dist/rename-manager.js
410690
410728
  init_cjs_shims();
410691
- var import_types19 = __toESM(require_lib7(), 1);
410729
+ var import_types20 = __toESM(require_lib7(), 1);
410692
410730
 
410693
410731
  // ../../../vite-plugin-file-sync/dist/refactor/blocks.js
410694
410732
  init_cjs_shims();
@@ -410902,7 +410940,7 @@ function getSetControlBlockExpressions2(block) {
410902
410940
 
410903
410941
  // ../../../vite-plugin-file-sync/dist/refactor/javascript.js
410904
410942
  init_cjs_shims();
410905
- var import_types18 = __toESM(require_lib7(), 1);
410943
+ var import_types19 = __toESM(require_lib7(), 1);
410906
410944
  var import_shared30 = __toESM(require_dist2(), 1);
410907
410945
  function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, checkFunctionBinding = false }) {
410908
410946
  const functionVisitor = checkFunctionBinding ? {
@@ -410917,7 +410955,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
410917
410955
  continue;
410918
410956
  const keyName = getIdentiferName(property.get("key").node);
410919
410957
  if (keyName === oldName && !property.node.shorthand) {
410920
- property.get("key").replaceInline(import_types18.default.identifier(newName));
410958
+ property.get("key").replaceInline(import_types19.default.identifier(newName));
410921
410959
  path54.skip();
410922
410960
  return;
410923
410961
  }
@@ -410934,8 +410972,8 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
410934
410972
  continue;
410935
410973
  const keyName = getIdentiferName(property.get("key").node);
410936
410974
  if (keyName === oldName) {
410937
- property.get("key").replaceInline(import_types18.default.identifier(newName));
410938
- property.get("value").replaceInline(import_types18.default.identifier(newName));
410975
+ property.get("key").replaceInline(import_types19.default.identifier(newName));
410976
+ property.get("value").replaceInline(import_types19.default.identifier(newName));
410939
410977
  property.set("shorthand", true);
410940
410978
  }
410941
410979
  }
@@ -410961,7 +410999,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
410961
410999
  return;
410962
411000
  }
410963
411001
  if (property.isIdentifier() && property.node.name === oldName) {
410964
- property.replaceInline(import_types18.default.identifier(newName));
411002
+ property.replaceInline(import_types19.default.identifier(newName));
410965
411003
  path54.skip();
410966
411004
  }
410967
411005
  }
@@ -410977,7 +411015,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
410977
411015
  if (path54.node.computed) {
410978
411016
  const property = path54.get("property");
410979
411017
  if (property.isIdentifier() && property.node.name === oldName) {
410980
- property.replaceInline(import_types18.default.identifier(newName));
411018
+ property.replaceInline(import_types19.default.identifier(newName));
410981
411019
  path54.skip();
410982
411020
  return;
410983
411021
  }
@@ -411007,7 +411045,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
411007
411045
  if (parentBinding) {
411008
411046
  for (let i2 = 0; i2 < components2.length - 1; i2++) {
411009
411047
  if (components2[i2]?.name === parentBinding && components2[i2 + 1]?.name === oldName) {
411010
- components2[i2 + 1]?.path.replaceInline(import_types18.default.identifier(newName));
411048
+ components2[i2 + 1]?.path.replaceInline(import_types19.default.identifier(newName));
411011
411049
  path54.skip();
411012
411050
  return;
411013
411051
  }
@@ -411015,7 +411053,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
411015
411053
  } else {
411016
411054
  for (const component of components2) {
411017
411055
  if (component.name === oldName) {
411018
- component.path.replaceInline(import_types18.default.identifier(newName));
411056
+ component.path.replaceInline(import_types19.default.identifier(newName));
411019
411057
  path54.skip();
411020
411058
  return;
411021
411059
  }
@@ -411033,7 +411071,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
411033
411071
  Identifier(path54) {
411034
411072
  if (path54.parentPath.isArrayExpression()) {
411035
411073
  if (path54.node.name === oldName) {
411036
- path54.replaceInline(import_types18.default.identifier(newName));
411074
+ path54.replaceInline(import_types19.default.identifier(newName));
411037
411075
  }
411038
411076
  }
411039
411077
  }
@@ -411042,7 +411080,7 @@ function renameEntityInJavascript({ oldName, newName, nodePath, parentBinding, c
411042
411080
  function deleteEntityInJavascriptArray({ name: name18, nodePath }) {
411043
411081
  nodePath.traverse({
411044
411082
  ArrayExpression(path54) {
411045
- path54.node.elements = path54.node.elements.filter((element) => !import_types18.default.isIdentifier(element) || element.name !== name18);
411083
+ path54.node.elements = path54.node.elements.filter((element) => !import_types19.default.isIdentifier(element) || element.name !== name18);
411046
411084
  path54.skip();
411047
411085
  }
411048
411086
  });
@@ -411064,40 +411102,40 @@ var RenameManager = class {
411064
411102
  oldName = extractNameFromBindAttribute(bindAttribute.node);
411065
411103
  if (oldName) {
411066
411104
  const bindValue = bindAttribute.node.value;
411067
- if (bindValue && import_types19.default.isJSXExpressionContainer(bindValue)) {
411105
+ if (bindValue && import_types20.default.isJSXExpressionContainer(bindValue)) {
411068
411106
  const expression = bindValue.expression;
411069
- if (import_types19.default.isIdentifier(expression)) {
411070
- bindAttribute.node.value = import_types19.default.jsxExpressionContainer(import_types19.default.identifier(newName));
411071
- } else if (import_types19.default.isMemberExpression(expression)) {
411107
+ if (import_types20.default.isIdentifier(expression)) {
411108
+ bindAttribute.node.value = import_types20.default.jsxExpressionContainer(import_types20.default.identifier(newName));
411109
+ } else if (import_types20.default.isMemberExpression(expression)) {
411072
411110
  const parentParts = [];
411073
411111
  let current = expression;
411074
- while (import_types19.default.isMemberExpression(current)) {
411075
- if (import_types19.default.isIdentifier(current.property)) {
411112
+ while (import_types20.default.isMemberExpression(current)) {
411113
+ if (import_types20.default.isIdentifier(current.property)) {
411076
411114
  parentParts.unshift(current.property.name);
411077
411115
  }
411078
411116
  current = current.object;
411079
411117
  }
411080
- if (import_types19.default.isIdentifier(current)) {
411118
+ if (import_types20.default.isIdentifier(current)) {
411081
411119
  parentParts.unshift(current.name);
411082
411120
  }
411083
- const newExpression = import_types19.default.cloneNode(expression, true);
411121
+ const newExpression = import_types20.default.cloneNode(expression, true);
411084
411122
  let finalMember = newExpression;
411085
- while (import_types19.default.isMemberExpression(finalMember) && import_types19.default.isMemberExpression(finalMember.property)) {
411123
+ while (import_types20.default.isMemberExpression(finalMember) && import_types20.default.isMemberExpression(finalMember.property)) {
411086
411124
  finalMember = finalMember.property;
411087
411125
  }
411088
- if (import_types19.default.isMemberExpression(finalMember) && import_types19.default.isIdentifier(finalMember.property)) {
411089
- finalMember.property = import_types19.default.identifier(newName);
411126
+ if (import_types20.default.isMemberExpression(finalMember) && import_types20.default.isIdentifier(finalMember.property)) {
411127
+ finalMember.property = import_types20.default.identifier(newName);
411090
411128
  }
411091
- bindAttribute.node.value = import_types19.default.jsxExpressionContainer(newExpression);
411129
+ bindAttribute.node.value = import_types20.default.jsxExpressionContainer(newExpression);
411092
411130
  }
411093
411131
  }
411094
411132
  }
411095
411133
  } else if (!nameAttribute) {
411096
- widgetNode.pushContainer("attributes", import_types19.default.jsxAttribute(import_types19.default.jsxIdentifier("bind"), import_types19.default.jsxExpressionContainer(import_types19.default.identifier(newName))));
411134
+ widgetNode.pushContainer("attributes", import_types20.default.jsxAttribute(import_types20.default.jsxIdentifier("bind"), import_types20.default.jsxExpressionContainer(import_types20.default.identifier(newName))));
411097
411135
  return;
411098
411136
  } else {
411099
411137
  oldName = nameAttribute.node.value ? nodeToValue(nameAttribute.node.value) : null;
411100
- widgetNode.pushContainer("attributes", import_types19.default.jsxAttribute(import_types19.default.jsxIdentifier("bind"), import_types19.default.jsxExpressionContainer(import_types19.default.identifier(newName))));
411138
+ widgetNode.pushContainer("attributes", import_types20.default.jsxAttribute(import_types20.default.jsxIdentifier("bind"), import_types20.default.jsxExpressionContainer(import_types20.default.identifier(newName))));
411101
411139
  nameAttribute.remove();
411102
411140
  }
411103
411141
  if (!oldName) {
@@ -411146,7 +411184,7 @@ var RenameManager = class {
411146
411184
  });
411147
411185
  },
411148
411186
  ArrayExpression(path54) {
411149
- if (import_types19.default.isCallExpression(path54.parentPath.node)) {
411187
+ if (import_types20.default.isCallExpression(path54.parentPath.node)) {
411150
411188
  renameEntityInJavascript({
411151
411189
  oldName,
411152
411190
  newName,
@@ -411201,57 +411239,57 @@ var RenameManager = class {
411201
411239
  // ../../../vite-plugin-file-sync/dist/source-tracker.js
411202
411240
  init_cjs_shims();
411203
411241
  var import_parser5 = __toESM(require_lib9(), 1);
411204
- var import_types23 = __toESM(require_lib7(), 1);
411242
+ var import_types24 = __toESM(require_lib7(), 1);
411205
411243
  import path26 from "node:path";
411206
411244
 
411207
411245
  // ../../../vite-plugin-file-sync/dist/parsing/theme.js
411208
411246
  init_cjs_shims();
411209
- var import_types20 = __toESM(require_lib7(), 1);
411247
+ var import_types21 = __toESM(require_lib7(), 1);
411210
411248
  function getKeyValue(key2) {
411211
- if (import_types20.default.isStringLiteral(key2.node)) {
411249
+ if (import_types21.default.isStringLiteral(key2.node)) {
411212
411250
  return key2.node.value;
411213
- } else if (import_types20.default.isIdentifier(key2.node)) {
411251
+ } else if (import_types21.default.isIdentifier(key2.node)) {
411214
411252
  return key2.node.name;
411215
411253
  }
411216
411254
  throw new Error(`Unsupported key type: ${key2.type}`);
411217
411255
  }
411218
411256
  function getKeyAst(key2) {
411219
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key2) ? import_types20.default.identifier(key2) : import_types20.default.stringLiteral(key2);
411257
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key2) ? import_types21.default.identifier(key2) : import_types21.default.stringLiteral(key2);
411220
411258
  }
411221
411259
  function createAstFromValue(value2) {
411222
411260
  if (typeof value2 === "object" && value2 !== null) {
411223
411261
  const properties = [];
411224
411262
  for (const [key2, val] of Object.entries(value2)) {
411225
- properties.push(import_types20.default.objectProperty(getKeyAst(key2), createAstFromValue(val)));
411263
+ properties.push(import_types21.default.objectProperty(getKeyAst(key2), createAstFromValue(val)));
411226
411264
  }
411227
- return import_types20.default.objectExpression(properties);
411265
+ return import_types21.default.objectExpression(properties);
411228
411266
  } else if (typeof value2 === "string") {
411229
- return import_types20.default.stringLiteral(value2);
411267
+ return import_types21.default.stringLiteral(value2);
411230
411268
  } else if (typeof value2 === "number") {
411231
- return import_types20.default.numericLiteral(value2);
411269
+ return import_types21.default.numericLiteral(value2);
411232
411270
  } else if (typeof value2 === "boolean") {
411233
- return import_types20.default.booleanLiteral(value2);
411271
+ return import_types21.default.booleanLiteral(value2);
411234
411272
  } else if (value2 === null) {
411235
- return import_types20.default.nullLiteral();
411273
+ return import_types21.default.nullLiteral();
411236
411274
  }
411237
411275
  throw new Error(`Unsupported value type: ${typeof value2}`);
411238
411276
  }
411239
411277
  function mergeThemeUpdates(nodePath, updates) {
411240
- if (!import_types20.default.isObjectExpression(nodePath.node)) {
411278
+ if (!import_types21.default.isObjectExpression(nodePath.node)) {
411241
411279
  throw new Error("Current node must be an object expression");
411242
411280
  }
411243
411281
  Object.keys(updates).forEach((updatedKey) => {
411244
411282
  const propertyNodePath = nodePath.get("properties").find((prop) => getKeyValue(prop.get("key")) === updatedKey);
411245
411283
  const currentValue = propertyNodePath?.get("value");
411246
411284
  if (!currentValue) {
411247
- const newProperty = import_types20.default.objectProperty(getKeyAst(updatedKey), createAstFromValue(updates[updatedKey]));
411285
+ const newProperty = import_types21.default.objectProperty(getKeyAst(updatedKey), createAstFromValue(updates[updatedKey]));
411248
411286
  nodePath.node.properties.push(newProperty);
411249
411287
  return;
411250
411288
  }
411251
411289
  if (Array.isArray(currentValue)) {
411252
411290
  throw new Error("Array values are not supported yet");
411253
411291
  }
411254
- if (currentValue && import_types20.default.isObjectExpression(currentValue.node)) {
411292
+ if (currentValue && import_types21.default.isObjectExpression(currentValue.node)) {
411255
411293
  mergeThemeUpdates(currentValue, updates[updatedKey]);
411256
411294
  return;
411257
411295
  }
@@ -411262,7 +411300,7 @@ var updateThemeAst = (ast, updates) => {
411262
411300
  traverse(ast, {
411263
411301
  ExportDefaultDeclaration(path54) {
411264
411302
  const themeObject = path54.get("declaration").get("expression");
411265
- if (!(import_types20.default.isTSSatisfiesExpression(path54.node.declaration) && import_types20.default.isTSTypeReference(path54.node.declaration.typeAnnotation) && import_types20.default.isIdentifier(path54.node.declaration.typeAnnotation.typeName) && path54.node.declaration.typeAnnotation.typeName.name === "AppTheme" && !Array.isArray(themeObject) && import_types20.default.isObjectExpression(themeObject.node))) {
411303
+ if (!(import_types21.default.isTSSatisfiesExpression(path54.node.declaration) && import_types21.default.isTSTypeReference(path54.node.declaration.typeAnnotation) && import_types21.default.isIdentifier(path54.node.declaration.typeAnnotation.typeName) && path54.node.declaration.typeAnnotation.typeName.name === "AppTheme" && !Array.isArray(themeObject) && import_types21.default.isObjectExpression(themeObject.node))) {
411266
411304
  throw new Error(`Could not update theme because the default export is not an object expression. We currently only support exporting the theme as a default export which should satisfy the Theme type from @superblocks/library. Example:
411267
411305
 
411268
411306
  import type { Theme } from "@superblocksteam/library";
@@ -411278,7 +411316,7 @@ var updateThemeAst = (ast, updates) => {
411278
411316
 
411279
411317
  // ../../../vite-plugin-file-sync/dist/sb-scope-manager.js
411280
411318
  init_cjs_shims();
411281
- var import_types21 = __toESM(require_lib7(), 1);
411319
+ var import_types22 = __toESM(require_lib7(), 1);
411282
411320
  import path25 from "node:path";
411283
411321
  var import_shared31 = __toESM(require_dist2(), 1);
411284
411322
  var SbScopeManager = class extends import_shared31.TracedEventEmitter {
@@ -411521,7 +411559,7 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411521
411559
  updateScopeEntity({ entityId, updates }) {
411522
411560
  const entityNode = this.sourceTracker.getElementToLocation(entityId);
411523
411561
  const filePath = this.sourceTracker.getElementToFilePath(entityId);
411524
- if (!entityNode || !(0, import_types21.isObjectProperty)(entityNode.node)) {
411562
+ if (!entityNode || !(0, import_types22.isObjectProperty)(entityNode.node)) {
411525
411563
  throw new Error("Entity to update not found " + entityId);
411526
411564
  }
411527
411565
  if (!filePath) {
@@ -411559,7 +411597,7 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411559
411597
  }
411560
411598
  const entityName = (entityNode?.node?.key).name;
411561
411599
  const filePath = this.sourceTracker.getElementToFilePath(entityId);
411562
- if (!entityNode || !(0, import_types21.isObjectProperty)(entityNode.node)) {
411600
+ if (!entityNode || !(0, import_types22.isObjectProperty)(entityNode.node)) {
411563
411601
  throw new Error("Entity to delete not found" + entityId);
411564
411602
  }
411565
411603
  if (!filePath) {
@@ -411597,14 +411635,14 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411597
411635
  };
411598
411636
  }
411599
411637
  const entityNode = this.sourceTracker.getElementToLocation(entityId);
411600
- if (!entityNode || !(0, import_types21.isObjectProperty)(entityNode.node)) {
411638
+ if (!entityNode || !(0, import_types22.isObjectProperty)(entityNode.node)) {
411601
411639
  return {
411602
411640
  changedFiles: []
411603
411641
  };
411604
411642
  }
411605
411643
  const key2 = entityNode.get("key");
411606
411644
  if (key2) {
411607
- key2.replaceWith(import_types21.default.identifier(newName));
411645
+ key2.replaceWith(import_types22.default.identifier(newName));
411608
411646
  }
411609
411647
  scopeDef.entityNames = scopeDef.entityNames.map((name18) => name18 === oldName ? newName : name18);
411610
411648
  const newEntityId = getStableEntityId(scopeDef.id, newName);
@@ -411637,7 +411675,7 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411637
411675
  if (!scopeDef.scopeComponents) {
411638
411676
  throw new Error("Scope components not found, even though we added type parameters");
411639
411677
  }
411640
- const newProperty = import_types21.default.tsPropertySignature(import_types21.default.identifier(componentName), import_types21.default.tsTypeAnnotation(import_types21.default.tsAnyKeyword()));
411678
+ const newProperty = import_types22.default.tsPropertySignature(import_types22.default.identifier(componentName), import_types22.default.tsTypeAnnotation(import_types22.default.tsAnyKeyword()));
411641
411679
  const newComponents = scopeDef.scopeComponents.pushContainer("members", newProperty);
411642
411680
  scopeDef.entityNames.push(componentName);
411643
411681
  const updatedFiles = this.updateScopeUsages(scopeDef.name, scopeDef.entityNames);
@@ -411658,7 +411696,7 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411658
411696
  const componentTypeId = getStableEntityId(scopeDef.id, componentName);
411659
411697
  const componentNode = this.sourceTracker.getElementToLocation(componentTypeId);
411660
411698
  const filePath = this.sourceTracker.getElementToFilePath(componentTypeId);
411661
- if (!componentNode || !import_types21.default.isTSPropertySignature(componentNode.node) || !filePath) {
411699
+ if (!componentNode || !import_types22.default.isTSPropertySignature(componentNode.node) || !filePath) {
411662
411700
  return [];
411663
411701
  }
411664
411702
  componentNode.remove();
@@ -411692,7 +411730,7 @@ var SbScopeManager = class extends import_shared31.TracedEventEmitter {
411692
411730
  }
411693
411731
  const key2 = componentNode.get("key");
411694
411732
  if (key2) {
411695
- key2.replaceWith(import_types21.default.identifier(newName));
411733
+ key2.replaceWith(import_types22.default.identifier(newName));
411696
411734
  }
411697
411735
  scopeDef.entityNames = scopeDef.entityNames.map((name18) => name18 === oldName ? newName : name18);
411698
411736
  delete scopeDef.scopeNameToEntityId[oldName];
@@ -412385,7 +412423,7 @@ var SourceTracker = class {
412385
412423
  }
412386
412424
  if (!parentAttr && parent) {
412387
412425
  const newAttr = openingTag.pushContainer("attributes", [
412388
- import_types23.default.jsxAttribute(import_types23.default.jsxIdentifier(parent), import_types23.default.jSXExpressionContainer(import_types23.default.objectExpression([])))
412426
+ import_types24.default.jsxAttribute(import_types24.default.jsxIdentifier(parent), import_types24.default.jSXExpressionContainer(import_types24.default.objectExpression([])))
412389
412427
  ]);
412390
412428
  parentAttr = newAttr[0];
412391
412429
  }
@@ -412409,7 +412447,7 @@ var SourceTracker = class {
412409
412447
  let attr = openingTag.get("attributes").find((attr2) => attr2.isJSXAttribute() && attr2.node.name.name === property);
412410
412448
  if (!attr) {
412411
412449
  attr = openingTag.pushContainer("attributes", [
412412
- import_types23.default.jsxAttribute(import_types23.default.jsxIdentifier(property), import_types23.default.stringLiteral(""))
412450
+ import_types24.default.jsxAttribute(import_types24.default.jsxIdentifier(property), import_types24.default.stringLiteral(""))
412413
412451
  ])[0];
412414
412452
  }
412415
412453
  const value2 = info.value;
@@ -412436,7 +412474,7 @@ var SourceTracker = class {
412436
412474
  const openingElement = element.get("openingElement");
412437
412475
  if (openingElement.node.selfClosing) {
412438
412476
  openingElement.node.selfClosing = false;
412439
- element.node.closingElement = import_types23.default.jsxClosingElement(import_types23.default.jsxIdentifier(getTagName(openingElement.node.name) ?? ""));
412477
+ element.node.closingElement = import_types24.default.jsxClosingElement(import_types24.default.jsxIdentifier(getTagName(openingElement.node.name) ?? ""));
412440
412478
  }
412441
412479
  };
412442
412480
  setProperty = async ({ source: source2, property, info }) => {
@@ -412610,7 +412648,7 @@ var SourceTracker = class {
412610
412648
  }
412611
412649
  const attributes = pageElement.get("openingElement").get("attributes");
412612
412650
  const attribute = attributes?.find((attr) => attr.isJSXAttribute() && attr.node.name.name === "name");
412613
- attribute?.replaceWith(import_types23.default.jsxAttribute(import_types23.default.jsxIdentifier("name"), import_types23.default.stringLiteral(newName)));
412651
+ attribute?.replaceWith(import_types24.default.jsxAttribute(import_types24.default.jsxIdentifier("name"), import_types24.default.stringLiteral(newName)));
412614
412652
  this.changedFiles.add(filePath);
412615
412653
  };
412616
412654
  getAddElementImports = ({ properties, children }) => {
@@ -413004,48 +413042,54 @@ var FileSyncManager = class extends import_shared32.TracedEventEmitter {
413004
413042
  }
413005
413043
  return this.sourceTracker.handleNonVisualChangeByDeletingIds(path54, content2);
413006
413044
  }
413007
- async getFileWithIds(path54) {
413045
+ async getFileWithIds(filePath) {
413008
413046
  const logger3 = getLogger();
413009
413047
  if (!this.sourceTracker) {
413010
413048
  throw new Error("Source tracker not initialized");
413011
413049
  }
413012
413050
  const files = this.sourceTracker.getCurrentFiles();
413013
- if (!files[path54]) {
413014
- throw new Error("File not found in source tracker " + path54);
413051
+ if (!files[filePath]) {
413052
+ throw new Error("File not found in source tracker " + filePath);
413015
413053
  }
413016
- const ast = files[path54].ast;
413054
+ const ast = files[filePath].ast;
413017
413055
  if (!ast) {
413018
- throw new Error("No AST found for file in source tracker " + path54);
413056
+ throw new Error("No AST found for file in source tracker " + filePath);
413019
413057
  }
413020
413058
  const clonedAst = await (0, import_core3.transformFromAstAsync)(ast, void 0, {
413021
413059
  ast: true
413022
413060
  });
413023
413061
  if (!clonedAst?.ast) {
413024
- throw new Error("Failed to clone AST for file " + path54);
413062
+ throw new Error("Failed to clone AST for file " + filePath);
413025
413063
  }
413064
+ const componentsManager = ComponentsManager.getInstance();
413026
413065
  const processedTransactions = this.getProcessedTransactionsWithNonce();
413027
413066
  const customImports = /* @__PURE__ */ new Set();
413028
- let customBuildTraversal = {};
413029
- if (isCustomBuildEnabled()) {
413030
- customBuildTraversal = {
413031
- ImportDeclaration(path55) {
413032
- modifyLegacyCustomComponentImports(path55, customImports);
413033
- },
413034
- JSXElement(path55) {
413035
- modifyLegacyCustomComponentElements(path55, customImports);
413036
- },
413037
- Program: {
413038
- // we want to write the wrapped custom elements as local variables to the file
413039
- exit(path55) {
413040
- addLegacyCustomComponentVariables(path55, customImports);
413067
+ traverse(clonedAst.ast, {
413068
+ Program: {
413069
+ exit(nodePath) {
413070
+ if (isCustomBuildEnabled()) {
413071
+ addLegacyCustomComponentVariables(nodePath, customImports);
413072
+ }
413073
+ const name18 = componentsManager.getComponentName(filePath);
413074
+ if (name18) {
413075
+ nodePath.pushContainer("body", import_types26.default.variableDeclaration("const", [
413076
+ import_types26.default.variableDeclarator(import_types26.default.identifier("componentName"), import_types26.default.stringLiteral(name18))
413077
+ ]));
413041
413078
  }
413042
413079
  }
413043
- };
413044
- }
413045
- traverse(clonedAst.ast, {
413046
- ...customBuildTraversal,
413047
- ReturnStatement(path55) {
413048
- const argument = path55.get("argument");
413080
+ },
413081
+ ImportDeclaration(path54) {
413082
+ if (isCustomBuildEnabled()) {
413083
+ modifyLegacyCustomComponentImports(path54, customImports);
413084
+ }
413085
+ },
413086
+ JSXElement(path54) {
413087
+ if (isCustomBuildEnabled()) {
413088
+ modifyLegacyCustomComponentElements(path54, customImports);
413089
+ }
413090
+ },
413091
+ ReturnStatement(path54) {
413092
+ const argument = path54.get("argument");
413049
413093
  if (!argument.isJSXElement()) {
413050
413094
  return;
413051
413095
  }
@@ -413060,22 +413104,22 @@ var FileSyncManager = class extends import_shared32.TracedEventEmitter {
413060
413104
  __info: true
413061
413105
  }));
413062
413106
  },
413063
- JSXOpeningElement(path55) {
413064
- const elementId = getSbElementId(path55.node);
413107
+ JSXOpeningElement(path54) {
413108
+ const elementId = getSbElementId(path54.node);
413065
413109
  if (elementId) {
413066
- path55.pushContainer("attributes", makeJSXAttribute(WIDGET_SOURCE_ID_ATTRIBUTE, elementId));
413110
+ path54.pushContainer("attributes", makeJSXAttribute(WIDGET_SOURCE_ID_ATTRIBUTE, elementId));
413067
413111
  }
413068
413112
  },
413069
- ObjectProperty(path55) {
413070
- const elementId = getSbElementId(path55.node);
413113
+ ObjectProperty(path54) {
413114
+ const elementId = getSbElementId(path54.node);
413071
413115
  if (!elementId) {
413072
- path55.skip();
413116
+ path54.skip();
413073
413117
  return;
413074
413118
  }
413075
- path55.traverse({
413076
- ObjectExpression(path56) {
413077
- path56.pushContainer("properties", import_types25.default.objectProperty(import_types25.default.identifier("id"), import_types25.default.stringLiteral(elementId)));
413078
- path56.skip();
413119
+ path54.traverse({
413120
+ ObjectExpression(path55) {
413121
+ path55.pushContainer("properties", import_types26.default.objectProperty(import_types26.default.identifier("id"), import_types26.default.stringLiteral(elementId)));
413122
+ path55.skip();
413079
413123
  }
413080
413124
  });
413081
413125
  }
@@ -414664,7 +414708,7 @@ var fileSyncVitePlugin = (pluginParams, options9) => {
414664
414708
  });
414665
414709
  });
414666
414710
  });
414667
- componentsManager.on("registeredComponentChanged", (name18, oldName) => {
414711
+ componentsManager.on("registeredComponentChanged", async (name18, oldName) => {
414668
414712
  triggerRegisteredComponentUpdate();
414669
414713
  if (oldName) {
414670
414714
  socketManager.callLibraryClients(async (socket) => {
@@ -414702,6 +414746,13 @@ var fileSyncVitePlugin = (pluginParams, options9) => {
414702
414746
  if (!fileContents) {
414703
414747
  throw new Error("File not found in file sync manager " + id2);
414704
414748
  }
414749
+ if (componentsManager.isCustomComponentFile(id2)) {
414750
+ const code2 = getComponentSourceCode(fileContents);
414751
+ return {
414752
+ code: code2,
414753
+ map: null
414754
+ };
414755
+ }
414705
414756
  return {
414706
414757
  code: fileContents,
414707
414758
  map: null
@@ -418477,7 +418528,7 @@ var import_util28 = __toESM(require_dist3(), 1);
418477
418528
  // ../sdk/package.json
418478
418529
  var package_default = {
418479
418530
  name: "@superblocksteam/sdk",
418480
- version: "2.0.3",
418531
+ version: "2.0.6-next.0",
418481
418532
  type: "module",
418482
418533
  description: "Superblocks JS SDK",
418483
418534
  homepage: "https://www.superblocks.com",
@@ -418519,8 +418570,8 @@ var package_default = {
418519
418570
  "@rollup/wasm-node": "^4.35.0",
418520
418571
  "@superblocksteam/bucketeer-sdk": "0.5.0",
418521
418572
  "@superblocksteam/shared": "0.9160.0",
418522
- "@superblocksteam/util": "2.0.3",
418523
- "@superblocksteam/vite-plugin-file-sync": "2.0.3",
418573
+ "@superblocksteam/util": "2.0.6-next.0",
418574
+ "@superblocksteam/vite-plugin-file-sync": "2.0.6-next.0",
418524
418575
  "@vitejs/plugin-react": "^4.3.4",
418525
418576
  axios: "^1.4.0",
418526
418577
  chokidar: "^4.0.3",
@@ -426006,7 +426057,7 @@ async function startVite({ app, httpServer: httpServer2, root: root2, mode, port
426006
426057
  };
426007
426058
  const isCustomBuildEnabled2 = await isCustomComponentsEnabled();
426008
426059
  const customFolder = path36.join(root2, "custom");
426009
- const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.3";
426060
+ const cdnUrl = "https://assets-cdn.superblocks.com/library/2.0.6-next.0";
426010
426061
  const env3 = loadEnv(mode, root2, "");
426011
426062
  const hmrPort = await getFreePort();
426012
426063
  const hmrOptions = {
@@ -585,5 +585,5 @@
585
585
  "strict": true
586
586
  }
587
587
  },
588
- "version": "2.0.3"
588
+ "version": "2.0.6-next.0"
589
589
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/cli",
3
- "version": "2.0.3",
3
+ "version": "2.0.6-next.0",
4
4
  "type": "module",
5
5
  "description": "Official Superblocks CLI",
6
6
  "homepage": "https://www.superblocks.com",
@@ -42,9 +42,9 @@
42
42
  "devDependencies": {
43
43
  "@eslint/js": "^9.16.0",
44
44
  "@oclif/test": "^4.1.11",
45
- "@superblocksteam/sdk": "2.0.3",
45
+ "@superblocksteam/sdk": "2.0.6-next.0",
46
46
  "@superblocksteam/shared": "0.9160.0",
47
- "@superblocksteam/util": "2.0.3",
47
+ "@superblocksteam/util": "2.0.6-next.0",
48
48
  "@types/babel__core": "^7.20.0",
49
49
  "@types/chai": "^4",
50
50
  "@types/fs-extra": "^11.0.1",