From f0c492a65785be76ba09280dcae25c7320e7ed4a Mon Sep 17 00:00:00 2001 From: tbitw2549 Date: Sun, 25 Aug 2024 14:03:00 +0300 Subject: [PATCH] fix: default empty media query, add new templates --- .../nuxt/src/components/runtime/client-delayed-component.ts | 4 ++-- packages/nuxt/src/components/templates.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/components/runtime/client-delayed-component.ts b/packages/nuxt/src/components/runtime/client-delayed-component.ts index fc64a7da82..1a5f4c21eb 100644 --- a/packages/nuxt/src/components/runtime/client-delayed-component.ts +++ b/packages/nuxt/src/components/runtime/client-delayed-component.ts @@ -73,7 +73,7 @@ export const createLazyMediaComponent = (componentLoader: AsyncComponentLoader) if (import.meta.server) { return () => h(defineAsyncComponent(componentLoader), attrs) } - return () => h(delayedHydrationComponent(componentLoader, hydrateOnMediaQuery(attrs.hydrate as string | undefined))) + return () => h(delayedHydrationComponent(componentLoader, hydrateOnMediaQuery(attrs.hydrate as string | undefined ?? ''))) }, }) } @@ -98,4 +98,4 @@ export const createLazyIfComponent = (componentLoader: AsyncComponentLoader) => return () => h(delayedHydrationComponent(componentLoader, strategy)) }, }) -} \ No newline at end of file +} diff --git a/packages/nuxt/src/components/templates.ts b/packages/nuxt/src/components/templates.ts index e7a44f7339..b5122d0159 100644 --- a/packages/nuxt/src/components/templates.ts +++ b/packages/nuxt/src/components/templates.ts @@ -126,6 +126,9 @@ interface _GlobalComponents { ${componentTypes.map(([pascalName, type]) => ` 'LazyIdle${pascalName}': ${type} & DefineComponent<{hydrate?: IdleRequestOptions}>`).join('\n')} ${componentTypes.map(([pascalName, type]) => ` 'LazyVisible${pascalName}': ${type} & DefineComponent<{hydrate?: Partial}>`).join('\n')} ${componentTypes.map(([pascalName, type]) => ` 'LazyEvent${pascalName}': ${type} & DefineComponent<{hydrate?: Array}>`).join('\n')} + ${componentTypes.map(([pascalName, type]) => ` 'LazyMedia${pascalName}': ${type} & DefineComponent<{hydrate?: string}>`).join('\n')} + ${componentTypes.map(([pascalName, type]) => ` 'LazyIf${pascalName}': ${type} & DefineComponent<{hydrate?: unknown}>`).join('\n')} + ${componentTypes.map(([pascalName, type]) => ` 'LazyNever${pascalName}': ${type}`).join('\n')} } declare module 'vue' { @@ -137,6 +140,9 @@ ${componentTypes.map(([pascalName, type]) => `export const Lazy${pascalName}: ${ ${componentTypes.map(([pascalName, type]) => `export const LazyIdle${pascalName}: ${type} & DefineComponent<{hydrate?: IdleRequestOptions}>`).join('\n')} ${componentTypes.map(([pascalName, type]) => `export const LazyVisible${pascalName}: ${type} & DefineComponent<{hydrate?: Partial}>`).join('\n')} ${componentTypes.map(([pascalName, type]) => `export const LazyEvent${pascalName}: ${type} & DefineComponent<{hydrate?: Array}>`).join('\n')} +${componentTypes.map(([pascalName, type]) => `export const LazyMedia${pascalName}: ${type} & DefineComponent<{hydrate?: string}>`).join('\n')} +${componentTypes.map(([pascalName, type]) => `export const LazyIf${pascalName}: ${type} & DefineComponent<{hydrate?: unknown}>`).join('\n')} +${componentTypes.map(([pascalName, type]) => `export const LazyNever${pascalName}: ${type}`).join('\n')} export const componentNames: string[] `