move type guards into folder

This commit is contained in:
Mads Rasmussen
2023-05-15 15:20:19 +02:00
parent 20bac8a1c3
commit 266ca4c9ea
12 changed files with 23 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
import { hasDefaultExport } from './has-default-export.function';
import { isManifestClassConstructorType } from './is-manifest-class-instance-type.function';
import { isManifestClassConstructorType } from './type-guards';
import { loadExtension } from './load-extension.function';
import type { ClassConstructor } from '@umbraco-cms/backoffice/models';
import type { ManifestClass } from '@umbraco-cms/backoffice/extensions-registry';

View File

@@ -1,7 +1,10 @@
import { createExtensionElement } from './create-extension-element.function';
import { isManifestElementableType } from './is-manifest-elementable-type.function';
import { isManifestElementableType } from './type-guards';
export async function createExtensionElementOrFallback(manifest: any, fallbackElementName: string): Promise<HTMLElement | undefined> {
export async function createExtensionElementOrFallback(
manifest: any,
fallbackElementName: string
): Promise<HTMLElement | undefined> {
if (isManifestElementableType(manifest)) {
return createExtensionElement(manifest);
}

View File

@@ -1,5 +1,5 @@
import { hasDefaultExport } from './has-default-export.function';
import { isManifestElementNameType } from './is-manifest-element-name-type.function';
import { isManifestElementNameType } from './type-guards';
import { loadExtension } from './load-extension.function';
import type { HTMLElementConstructor } from '@umbraco-cms/backoffice/models';
import type { ManifestElement } from '@umbraco-cms/backoffice/extensions-registry';

View File

@@ -1,11 +1,8 @@
export * from './registry/extension.registry';
export * from './type-guards';
export * from './create-extension-element.function';
export * from './has-default-export.function';
export * from './has-init-export.function';
export * from './is-manifest-element-name-type.function';
export * from './is-manifest-elementable-type.function';
export * from './is-manifest-js-type.function';
export * from './is-manifest-loader-type.function';
export * from './load-extension.function';
export * from './create-extension-element-or-fallback.function';
export * from './create-extension-class.function';

View File

@@ -1,5 +1,4 @@
import { isManifestJSType } from './is-manifest-js-type.function';
import { isManifestLoaderType } from './is-manifest-loader-type.function';
import { isManifestJSType, isManifestLoaderType } from './type-guards';
import type { ManifestWithLoader } from '@umbraco-cms/backoffice/extensions-registry';
export async function loadExtension<T = unknown>(manifest: ManifestWithLoader<T>): Promise<T | null> {

View File

@@ -0,0 +1,6 @@
export * from './is-manifest-class-instance-type.function';
export * from './is-manifest-classable-type.function';
export * from './is-manifest-element-name-type.function';
export * from './is-manifest-elementable-type.function';
export * from './is-manifest-js-type.function';
export * from './is-manifest-loader-type.function';

View File

@@ -4,5 +4,9 @@ import { isManifestClassConstructorType } from './is-manifest-class-instance-typ
import type { ManifestBase, ManifestClass } from '@umbraco-cms/backoffice/extensions-registry';
export function isManifestClassableType(manifest: ManifestBase): manifest is ManifestClass {
return isManifestClassConstructorType(manifest) || isManifestLoaderType<object>(manifest) || isManifestJSType<object>(manifest);
return (
isManifestClassConstructorType(manifest) ||
isManifestLoaderType<object>(manifest) ||
isManifestJSType<object>(manifest)
);
}

View File

@@ -3,7 +3,9 @@ import { isManifestJSType } from './is-manifest-js-type.function';
import { isManifestLoaderType } from './is-manifest-loader-type.function';
import type { ManifestElement, ManifestBase } from '@umbraco-cms/backoffice/extensions-registry';
export function isManifestElementableType<ElementType extends HTMLElement = HTMLElement>(manifest: ManifestBase): manifest is ManifestElement {
export function isManifestElementableType<ElementType extends HTMLElement = HTMLElement>(
manifest: ManifestBase
): manifest is ManifestElement {
return (
isManifestElementNameType(manifest) ||
isManifestLoaderType<ElementType>(manifest) ||