diff --git a/frontend/src/components/AppComponent.vue b/frontend/src/components/AppComponent.vue index 03196d00..a2c4e566 100644 --- a/frontend/src/components/AppComponent.vue +++ b/frontend/src/components/AppComponent.vue @@ -78,7 +78,7 @@ const props = defineProps<{ const componentName = computed(() => { if (props.block.isContainer()) return props.block.originalElement || "div" let name = props.block.componentName - if (props.block.isCustomVueComponent) { + if (window.is_preview && props.block.isCustomVueComponent) { name = customVueComponentsRegistry.value[name] if (!name) return h(MissingComponent, { componentName: props.block.componentName }) } diff --git a/frontend/src/renderer.ts b/frontend/src/renderer.ts index 88ca9730..0b4cfdee 100644 --- a/frontend/src/renderer.ts +++ b/frontend/src/renderer.ts @@ -21,6 +21,19 @@ app.use(spritePlugin) registerGlobalComponents(app) window.__APP_COMPONENTS__ = app._context.components +declare global { + interface Window { + is_developer_mode?: boolean + is_preview?: boolean + __APP_COMPONENTS__: any + [key: string]: string + } +} + +if (window.is_preview && typeof window.is_preview === "string") { + window.is_preview = window.is_preview === "1" || window.is_preview === "True" +} + const frappeApp = (window as any).frappe_app if (frappeApp) { registerCustomVueComponents(frappeApp).then(() => { diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 281481c7..02e45ae8 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -11,7 +11,7 @@ export default { "./node_modules/frappe-ui/frappe/**/*.{vue,js,ts,jsx,tsx}", "../node_modules/frappe-ui/frappe/**/*.{vue,js,ts,jsx,tsx}", "../../*/studio/**/*.{vue,js,ts,jsx,tsx}", - "!../../**/node_modules/**", + "!../../*/studio/**/node_modules/**", ], theme: { extend: {}, diff --git a/studio/build.py b/studio/build.py index 7b2c8858..ad4024ba 100644 --- a/studio/build.py +++ b/studio/build.py @@ -198,17 +198,12 @@ def _add_custom_vue_component(self, componentName: str): break -def build_standard_apps(app: str | None = None) -> None: - """Scan all apps on the bench for studio/ folders and build each exported app. +def build_standard_apps(apps: list[str] | None = None) -> None: + """Scan passed apps on the bench for studio/ folders and build each exported app. This function works without DB access — it reads component data from exported JSON files on disk. - - Args: - app: Only build studio apps exported to this specific frappe app """ - apps = [app] if app else frappe.get_all_apps() - for frappe_app in apps: studio_folder = get_studio_folder(frappe_app) if not os.path.exists(studio_folder): @@ -272,7 +267,9 @@ def get_studio_folder(frappe_app: str) -> str | None: return frappe.get_app_source_path(frappe_app, "studio") -def after_build() -> None: - """Hook called after `bench build`. Builds all standard studio apps""" +def after_app_build(built_apps: list[str]) -> None: + """Hook called after any app is built. Builds studio apps for the built apps.""" + if not built_apps: + return click.secho("\nBuilding Studio Apps...", fg="cyan") - build_standard_apps() + build_standard_apps(built_apps) diff --git a/studio/hooks.py b/studio/hooks.py index 25553631..f4edd7d1 100644 --- a/studio/hooks.py +++ b/studio/hooks.py @@ -81,7 +81,7 @@ # before_install = "studio.install.before_install" # after_install = "studio.install.after_install" after_migrate = "studio.sync.after_migrate" -after_build = "studio.build.after_build" +after_app_build = "studio.build.after_app_build" # Uninstallation # ------------