rename ManifestCore to ManifestTypes
This commit is contained in:
@@ -7,12 +7,13 @@ import { Subscription } from 'rxjs';
|
||||
import { UmbContextConsumerMixin } from '../../../core/context';
|
||||
import { UmbExtensionRegistry } from '../../../core/extension';
|
||||
import { isManifestElementType } from '../../../core/extension/is-extension.function';
|
||||
import type { ManifestCore } from '../../../core/models';
|
||||
|
||||
import type { ManifestTypes } from '../../../core/models';
|
||||
|
||||
@customElement('umb-editor-extensions')
|
||||
export class UmbEditorExtensionsElement extends UmbContextConsumerMixin(LitElement) {
|
||||
@state()
|
||||
private _extensions: Array<ManifestCore> = [];
|
||||
private _extensions: Array<ManifestTypes> = [];
|
||||
|
||||
private _extensionRegistry?: UmbExtensionRegistry;
|
||||
private _extensionsSubscription?: Subscription;
|
||||
|
||||
@@ -3,19 +3,20 @@ import { BehaviorSubject, map, Observable } from 'rxjs';
|
||||
import { createExtensionElement } from './create-extension-element.function';
|
||||
|
||||
import type {
|
||||
ManifestCore,
|
||||
ManifestTypes,
|
||||
ManifestDashboard,
|
||||
ManifestEditorView,
|
||||
ManifestEntrypoint,
|
||||
ManifestPropertyAction,
|
||||
ManifestPropertyEditorUI,
|
||||
ManifestSection,
|
||||
ManifestCustom,
|
||||
} from '../models';
|
||||
export class UmbExtensionRegistry {
|
||||
private _extensions = new BehaviorSubject<Array<ManifestCore>>([]);
|
||||
private _extensions = new BehaviorSubject<Array<ManifestTypes>>([]);
|
||||
public readonly extensions = this._extensions.asObservable();
|
||||
|
||||
register(manifest: ManifestCore): void {
|
||||
register(manifest: ManifestTypes): void {
|
||||
const extensionsValues = this._extensions.getValue();
|
||||
const extension = extensionsValues.find((extension) => extension.alias === manifest.alias);
|
||||
|
||||
@@ -32,7 +33,8 @@ export class UmbExtensionRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
getByAlias(alias: string): Observable<ManifestCore | null> {
|
||||
getByAlias<T extends ManifestTypes>(alias: string): Observable<T | null>;
|
||||
getByAlias(alias: string) {
|
||||
// TODO: make pipes prettier/simpler/reuseable
|
||||
return this.extensions.pipe(map((dataTypes) => dataTypes.find((extension) => extension.alias === alias) || null));
|
||||
}
|
||||
@@ -46,9 +48,9 @@ export class UmbExtensionRegistry {
|
||||
extensionsOfType(type: 'propertyEditorUI'): Observable<Array<ManifestPropertyEditorUI>>;
|
||||
extensionsOfType(type: 'propertyAction'): Observable<Array<ManifestPropertyAction>>;
|
||||
extensionsOfType(type: 'entrypoint'): Observable<Array<ManifestEntrypoint>>;
|
||||
extensionsOfType(type: string): Observable<Array<ManifestCore>>;
|
||||
extensionsOfType<T extends ManifestCore>(type: string): Observable<Array<T>>;
|
||||
extensionsOfType(type: string) {
|
||||
extensionsOfType(type: 'custom'): Observable<Array<ManifestCustom>>;
|
||||
extensionsOfType<T extends ManifestTypes>(type: string): Observable<Array<T>>;
|
||||
extensionsOfType(type: string): Observable<Array<ManifestTypes>> {
|
||||
return this.extensions.pipe(map((exts) => exts.filter((ext) => ext.type === type)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ManifestCore } from '../models';
|
||||
import { ManifestTypes } from '../models';
|
||||
|
||||
export type ManifestLoaderType = ManifestCore & { loader: () => Promise<object | HTMLElement> };
|
||||
export type ManifestLoaderType = ManifestTypes & { loader: () => Promise<object | HTMLElement> };
|
||||
|
||||
export function loadExtension(manifest: ManifestCore) {
|
||||
export function loadExtension(manifest: ManifestTypes) {
|
||||
// TODO: change this back to dynamic import after POC. Vite complains about the dynamic imports in the public folder but doesn't include the temp app_plugins folder in the final build.
|
||||
// return import(/* @vite-ignore */ manifest.js);
|
||||
if (isManifestLoaderType(manifest)) {
|
||||
@@ -32,6 +32,6 @@ export function loadExtension(manifest: ManifestCore) {
|
||||
}) as Promise<null>;
|
||||
}
|
||||
|
||||
export function isManifestLoaderType(manifest: ManifestCore): manifest is ManifestLoaderType {
|
||||
export function isManifestLoaderType(manifest: ManifestTypes): manifest is ManifestLoaderType {
|
||||
return typeof (manifest as ManifestLoaderType).loader === 'function';
|
||||
}
|
||||
|
||||
@@ -16,13 +16,14 @@ export type UmbracoInstallerDatabaseModel = components['schemas']['InstallDataba
|
||||
export type UmbracoInstallerUserModel = components['schemas']['InstallUserModel'];
|
||||
export type TelemetryModel = components['schemas']['TelemetryModel'];
|
||||
export type ServerStatus = components['schemas']['ServerStatus'];
|
||||
export type ManifestCore = components['schemas']['Manifest'];
|
||||
export type ManifestTypes = components['schemas']['Manifest'];
|
||||
export type ManifestSection = components['schemas']['IManifestSection'];
|
||||
export type ManifestPropertyEditorUI = components['schemas']['IManifestPropertyEditorUI'];
|
||||
export type ManifestDashboard = components['schemas']['IManifestDashboard'];
|
||||
export type ManifestEditorView = components['schemas']['IManifestEditorView'];
|
||||
export type ManifestPropertyAction = components['schemas']['IManifestPropertyAction'];
|
||||
export type ManifestEntrypoint = components['schemas']['IManifestEntrypoint'];
|
||||
export type ManifestCustom = components['schemas']['IManifestCustom'];
|
||||
|
||||
export type ManifestElementType =
|
||||
| ManifestSection
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { ManifestCore } from './core/models';
|
||||
import type { ManifestTypes } from './core/models';
|
||||
|
||||
// TODO: consider moving weight from meta to the main part of the manifest. We need it for every extension.
|
||||
// TODO: consider adding a label property as part of the meta. It might make sense to have an "extension" name label where one is needed.
|
||||
export const internalManifests: Array<ManifestCore & { loader: () => Promise<object | HTMLElement> }> = [
|
||||
export const internalManifests: Array<ManifestTypes & { loader: () => Promise<object | HTMLElement> }> = [
|
||||
{
|
||||
type: 'section',
|
||||
alias: 'Umb.Section.Content',
|
||||
|
||||
Reference in New Issue
Block a user