import { AttrChangeInfo, MountInit, RootCnfg, ObservedSourceOfTruthAttribute, MOSE} from '../../mount-observer/types'; import { RegExpExt } from '../lib/prs/types'; import {IObject$tring, CSSQuery, StringWithAutocompleteOptions} from '../types'; export type stringArray = string | Array; export type stringArrayOrTree = Array | [string, Array]; // export interface AttrParts { // root: string, // base: string, // branch: string, // leaf: string, // } type prefixDelimiter = '-' | ':' | '--'; /** * Abbrev. for EnhancementMountConfig */ export type EMC = EnhancementMountConfig export interface AttrCacheConfig { enable: 'always' | 'instantiating', clone?: boolean } export type SafeProps = StringWithAutocompleteOptions< | 'textContent' | 'value' | 'object' | 'checked' | '^aria' >; export type EventListenerClass = {new(): EventListenerObject} export type EventListenerOrFn = EventListener | ((e: Event) => void) | EventListenerClass; export type HandlerKey = string; export type HandlerName = string; export type EventType = string; type CustomHandlers = Map; type CustomHandlerCluster = Map; // type EventTypeToListenerAndOptions = Map; // export interface ListenerAndOptions { // listener: EventListenerOrFn, // options?: OnOptions // } export type MappedListeners = {[key: string]: EventListenerOrFn} export interface IW { q: CSSQuery, /** * "addEventListeners or Actions" * @param eventsToAdd */ a(eventsToAdd: MappedListeners): IW, /** * set properties * @param propsToMerge */ s(propsToMerge: Partial): IW, r(refs: {[key: string]: any}): IW, listeners: MappedListeners, props: Partial, refs: {[key: string]: any}, primaryVal: any; } export interface EnhancementMountConfig{ id?: string; enhancedElementInstanceOf?: Array<{new(): Element}>, enhancedElementMatches?: string, enhPropKey: HandlerKey, /** * If not specified, will be defaulted to the enhPropKey * This allows for registered event handlers that are tied to a particular * enhancement to be scoped within a Shadow DOM realm */ handlerKey?: string, hasRootIn?: Array, preBaseDelimiter?: prefixDelimiter, base?: string, preBranchDelimiter?: prefixDelimiter, branches?: Array, //TODO watchedBranches?: Array, //TODO preLeafDelimiter?: prefixDelimiter, //TODO leaves?: Partial<{[key in keyof TBranches & string]: stringArray}>, //TODO hostMatches?: CSSQuery, //TODO hostInstanceOf?: Array<{new(): HTMLElement}>, block?: boolean, //TODO unblock?: boolean, importEnh?: () => Promise<{new(): IEnhancement}> map?: {[key: AttrCoordinates]: AttrMapPoint}, /** * Observed Source of Truth Attributes [TODO, need better name] */ osotas? : Array>, cacheConfig?: AttrCacheConfig, mapLocalNameTo?: keyof TProps, mapEnhKeyTo?: keyof TProps, mapEmcTo?: keyof TProps, allowedMutations?: {[key: CSSQuery]: []} top?: EnhancementMountConfig, ws?: Array, /** * map the where clause to this */ mapWSTo?: keyof TProps, primaryProp?: keyof TProps } export type AttrMapPoint = keyof TProps & string | AttrMapConfig export interface AttrMapConfig { instanceOf?: | 'Object' | 'String' | 'StringOrStrings' | 'Object$tring' | 'Object$entences' | 'DSSArray' | 'Boolean' | 'Number', mapsTo?: '.' | keyof TProps, valIfFalsy?: any, strValMapsTo?: keyof TProps, objValMapsTo?: '.' | keyof TProps, arrValMapsTo?: keyof TProps, strArrMapsTo?: keyof TProps, regExpExts?: Partial<{[key in keyof TProps]: RegExpExt[]}>; parsedRegExps?: boolean; } export type Branchitude = number; export type Leafitude = number; export type AttrCoordinates = `${Branchitude}.${Leafitude}`; export type MountBeHive = Partial>; export interface EnhancementInfo { initialPropValues?: any, initialAttrInfo?: Array, mountCnfg: EMC, synConfig: EMC, observedAttrs: Array | undefined, ws?: Array } export interface BEAllProps { resolved: boolean; rejected: boolean; enhancedElement: TElement; } export interface IEnhancement extends BEAllProps{ attach(el: TElement, enhancement: EnhancementInfo): Promise; detach(el: TElement): Promise; resolved: boolean; rejected: boolean; readonly enhancedElement: TElement; whenResolved(): Promise; de(src: EventTarget, name: string) : Event, attrChgCB(attrChangeInfos: Array) : void, channelEvent(e: Event): void; //parsedFrom: string; //autoImport?: boolean | string; } export interface OnOptions extends EventListenerOptions{ initOn?: 'resolved' }