From e00cb430b0125bf80ca35cb6ff0478ec3080a0eb Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 19 Mar 2025 17:02:32 +0100 Subject: [PATCH] feat: eager app mode --- .../components/inputs/AppDateTimeInput.svelte | 49 ++++++++++--- .../apps/editor/RecomputeAllComponents.svelte | 2 +- .../apps/editor/SubGridEditor.svelte | 2 +- .../editor/contextPanel/LazyModePanel.svelte | 70 +++++++++++++------ frontend/src/lib/components/apps/types.ts | 1 + 5 files changed, 89 insertions(+), 35 deletions(-) diff --git a/frontend/src/lib/components/apps/components/inputs/AppDateTimeInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppDateTimeInput.svelte index 7dc67ad5a6..276d542b79 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppDateTimeInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppDateTimeInput.svelte @@ -1,11 +1,13 @@ -{#if everVisible} +{#if everVisible || $app.eagerRendering}
@@ -19,32 +26,51 @@ When lazy mode is enabled, components are not rendered until they are needed. This can significantly improve the performance of your app, especially on mobile devices.
- You can enable lazy mode below, but you will need to declare the list of components whose initialization - is expected to see initialized before the initial refresh of the app happens. + Semi-Lazy mode is enabled by default, where components are initialized but are in a hidden state. + Lazy mode is when components are not initialized at all. - { - $app.lazyInitRequire = e.detail ? [] : undefined - code = JSON.stringify($app.lazyInitRequire) + { + if (e.detail == 'eager') { + $app.eagerRendering = true + $app.lazyInitRequire = undefined + } else if (e.detail == 'semi-lazy') { + $app.eagerRendering = undefined + $app.lazyInitRequire = undefined + } else { + $app.eagerRendering = undefined + $app.lazyInitRequire = [] + code = JSON.stringify($app.lazyInitRequire) + } }} - options={{ - right: 'Lazy mode' - }} - /> - -
- {#if $app.lazyInitRequire != undefined} + let:item + > + + + + + {#if selectedRendering == 'eager'} +
+ In eager mode, all components will be fully initialized, even when they are not visible. +
+ {:else if selectedRendering == 'semi-lazy'} +
+ In semi-lazy mode, components will be semi-initialized when hidden. That is the default + mode. +
+ {:else if selectedRendering == 'lazy'} +
{'e.g: ["a", "b"]'}, no need to put background runnables ids - {:else} - Without lazy mode, all components' initialization will be waited on the initial refresh. - {/if} -
+
+ {/if}
diff --git a/frontend/src/lib/components/apps/types.ts b/frontend/src/lib/components/apps/types.ts index 3317709ce0..e58618f99b 100644 --- a/frontend/src/lib/components/apps/types.ts +++ b/frontend/src/lib/components/apps/types.ts @@ -165,6 +165,7 @@ export type App = { subgrids?: Record theme: AppTheme | undefined lazyInitRequire?: string[] | undefined + eagerRendering?: boolean | undefined hideLegacyTopBar?: boolean | undefined mobileViewOnSmallerScreens?: boolean | undefined version?: number