refactor: native feature management (#2350)

This commit is contained in:
Mo
2023-07-12 12:56:08 -05:00
committed by GitHub
parent 49f7581cd8
commit 078ef3772c
223 changed files with 3996 additions and 3438 deletions

View File

@@ -1,26 +1,47 @@
import { ComponentArea, FeatureIdentifier } from '@standardnotes/features'
import { ActionObserver, PermissionDialog, SNComponent, SNNote } from '@standardnotes/models'
import { ComponentViewerItem } from './ComponentViewerItem'
import {
ComponentArea,
ComponentFeatureDescription,
EditorFeatureDescription,
IframeComponentFeatureDescription,
ThemeFeatureDescription,
} from '@standardnotes/features'
import {
ActionObserver,
ComponentInterface,
ComponentOrNativeFeature,
PermissionDialog,
SNNote,
} from '@standardnotes/models'
import { DesktopManagerInterface } from '../Device/DesktopManagerInterface'
import { ComponentViewerInterface } from './ComponentViewerInterface'
export interface ComponentManagerInterface {
urlForComponent(component: SNComponent): string | undefined
urlForComponent(uiFeature: ComponentOrNativeFeature<ComponentFeatureDescription>): string | undefined
setDesktopManager(desktopManager: DesktopManagerInterface): void
componentsForArea(area: ComponentArea): SNComponent[]
editorForNote(note: SNNote): SNComponent | undefined
doesEditorChangeRequireAlert(from: SNComponent | undefined, to: SNComponent | undefined): boolean
thirdPartyComponentsForArea(area: ComponentArea): ComponentInterface[]
editorForNote(note: SNNote): ComponentOrNativeFeature<EditorFeatureDescription | IframeComponentFeatureDescription>
doesEditorChangeRequireAlert(
from: ComponentOrNativeFeature<IframeComponentFeatureDescription | EditorFeatureDescription> | undefined,
to: ComponentOrNativeFeature<IframeComponentFeatureDescription | EditorFeatureDescription> | undefined,
): boolean
showEditorChangeAlert(): Promise<boolean>
destroyComponentViewer(viewer: ComponentViewerInterface): void
createComponentViewer(
component: SNComponent,
contextItem?: string,
uiFeature: ComponentOrNativeFeature<IframeComponentFeatureDescription>,
item: ComponentViewerItem,
actionObserver?: ActionObserver,
urlOverride?: string,
): ComponentViewerInterface
presentPermissionsDialog(_dialog: PermissionDialog): void
legacyGetDefaultEditor(): SNComponent | undefined
componentWithIdentifier(identifier: FeatureIdentifier | string): SNComponent | undefined
toggleTheme(uuid: string): Promise<void>
toggleComponent(uuid: string): Promise<void>
legacyGetDefaultEditor(): ComponentInterface | undefined
isThemeActive(theme: ComponentOrNativeFeature<ThemeFeatureDescription>): boolean
toggleTheme(theme: ComponentOrNativeFeature<ThemeFeatureDescription>): Promise<void>
getActiveThemes(): ComponentOrNativeFeature<ThemeFeatureDescription>[]
getActiveThemesIdentifiers(): string[]
isComponentActive(component: ComponentInterface): boolean
toggleComponent(component: ComponentInterface): Promise<void>
}

View File

@@ -2,20 +2,22 @@ import {
ActionObserver,
ComponentEventObserver,
ComponentMessage,
DecryptedItemInterface,
SNComponent,
ComponentOrNativeFeature,
} from '@standardnotes/models'
import { FeatureStatus } from '../Feature/FeatureStatus'
import { ComponentViewerError } from './ComponentViewerError'
import { IframeComponentFeatureDescription } from '@standardnotes/features'
export interface ComponentViewerInterface {
readonly component: SNComponent
readonly url?: string
identifier: string
lockReadonly: boolean
sessionKey?: string
overrideContextItem?: DecryptedItemInterface
get componentUuid(): string
readonly identifier: string
readonly lockReadonly: boolean
readonly sessionKey?: string
get url(): string
get componentUniqueIdentifier(): string
getComponentOrFeatureItem(): ComponentOrNativeFeature<IframeComponentFeatureDescription>
destroy(): void
setReadonly(readonly: boolean): void
getFeatureStatus(): FeatureStatus

View File

@@ -0,0 +1,9 @@
import { DecryptedItemInterface } from '@standardnotes/models'
export type ComponentViewerItem = { uuid: string } | { readonlyItem: DecryptedItemInterface }
export function isComponentViewerItemReadonlyItem(
item: ComponentViewerItem,
): item is { readonlyItem: DecryptedItemInterface } {
return 'readonlyItem' in item
}