move type guards into folder
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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';
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
@@ -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) ||
|
||||
Reference in New Issue
Block a user