import * as glassEasel from 'glass-easel'; import { typeUtils, DeepCopyKind } from 'glass-easel'; export { glassEasel }; type SelectorQueryFields = { id?: boolean; dataset?: boolean; mark?: boolean; rect?: boolean; size?: boolean; scrollOffset?: boolean; properties?: string[]; context?: boolean; }; type SelectorQueryResult = { id: T['id'] extends true ? string : undefined; dataset: T['dataset'] extends true ? { [k: string]: any; } : undefined; mark: T['mark'] extends true ? { [k: string]: any; } : undefined; left: T['rect'] extends true ? number : undefined; top: T['rect'] extends true ? number : undefined; right: T['rect'] extends true ? number : undefined; bottom: T['rect'] extends true ? number : undefined; width: T['size'] extends true ? number : undefined; height: T['size'] extends true ? number : undefined; scrollLeft: T['scrollOffset'] extends true ? number : undefined; scrollTop: T['scrollOffset'] extends true ? number : undefined; scrollWidth: T['scrollOffset'] extends true ? number : undefined; scrollHeight: T['scrollOffset'] extends true ? number : undefined; } & { [K in T['properties'] extends (infer I extends string)[] ? I : never]: any; }; type BoundingClientRect = { id: string; dataset: { [k: string]: any; }; left: number; top: number; right: number; bottom: number; width: number; height: number; }; type ScrollOffset = { id: string; dataset: { [k: string]: any; }; scrollLeft: number; scrollTop: number; scrollWidth: number; scrollHeight: number; }; type ContextResult = { context: unknown; }; declare class NodesRef { private _$sq; private _$comp; private _$sel; private _$single; constructor(selectorQuery: SelectorQuery, component: GeneralComponent, selector: string | null, selectSingle: S); fields(fields: T, cb?: (res: S extends true ? SelectorQueryResult : SelectorQueryResult[]) => void): SelectorQuery; boundingClientRect(cb?: (res: S extends true ? BoundingClientRect : BoundingClientRect[]) => void): SelectorQuery; scrollOffset(cb?: (res: S extends true ? ScrollOffset : ScrollOffset[]) => void): SelectorQuery; context(cb?: (res: S extends true ? ContextResult : any[]) => void): SelectorQuery; } declare class SelectorQuery { private _$comp; /** Change where the node should be selected from */ in(component: GeneralComponent): this; /** Select the first node that matches the selector */ select(selector: string): NodesRef; /** Select all nodes that match the selector */ selectAll(selector: string): NodesRef; /** * Select the viewport of the component * * Only the size and the scroll position is meaningful when the viewport is selected. */ selectViewport(): NodesRef; /** * Execute all queries * * The `cb` is called after all queries done. */ exec(cb?: (resList: any[]) => void): void; } type IntersectionObserverMargins = { left?: number; top?: number; right?: number; bottom?: number; }; declare class IntersectionObserver { private _$comp; private _$thresholds; private _$initialRatio; private _$observeAll; private _$selector; private _$margins; private _$observers; relativeTo(selector: string, margins?: IntersectionObserverMargins): this; relativeToViewport(margins?: IntersectionObserverMargins): this; observe(targetSelector: string, listener: (status: glassEasel.backend.IntersectionStatus) => void): void; disconnect(): void; } declare class ResizeObserver { private _$comp; private _$observeAll; private _$mode; private _$observers; contentBox(): this; borderBox(): this; observe(targetSelector: string, listener: (status: glassEasel.backend.ResizeStatus) => void): void; disconnect(): void; } declare class MediaQueryObserver { private _$comp; private _$observer; observe(descriptor: glassEasel.backend.MediaQueryStatus, listener: (status: { matches: boolean; }) => void): void; disconnect(): void; } type DataList$6 = typeUtils.DataList; type PropertyList$6 = typeUtils.PropertyList; type MethodList$5 = typeUtils.MethodList; type Empty$4 = typeUtils.Empty; type PropertyValues = typeUtils.PropertyValues; type AllData = typeUtils.DataWithPropertyValues; type ExportType = [UComponentExport] extends [never] ? Component : UComponentExport; declare const determineComponentExports: (parent: GeneralBehavior[], selfExport: ((source: GeneralComponent | null) => any) | undefined) => ((source: GeneralComponent | null) => any) | undefined; type GeneralComponent = Component, Record, Record, any, Record>; type Component = ComponentCaller & { [k in keyof TMethod]: TMethod[k]; } & TExtraThisFields; declare class ComponentCaller { /** The corresponding `Component` */ _$: glassEasel.Component; /** The component path in the code space */ get is(): string; set is(value: string); /** The `id` field in the template */ get id(): string; set id(value: string); /** The `data-*` field in the template */ get dataset(): { [key: string]: any; } | null; set dataset(value: { [key: string]: any; } | null); /** The component data and property values */ get data(): typeUtils.Merge>; set data(value: AllData); /** The component data and property values (same as `data` ) */ get properties(): typeUtils.Merge>; set properties(value: AllData); /** * Group several data update calls * * This method is designed for hinting the backend that some updates should be handled together. * However, this is done automatically now, * so this method is just for backward compatibilities. */ groupSetData(callback: () => void): void; /** * Do a classic data update * * The `callback` is called after the update applies in the backend. * In most cases, you SHOULD NOT wait the backend update (that might be very slow), * and most calls, including read calls such as `selectComponent` , simply works immediately. * However, when called inside observers, * the data update will not be applied to templates immediately * (it is recommanded to use `updateData` instead in observers). */ setData(newData: Partial>>, callback?: () => void): void; /** * Schedule a classic data updates * * The data update will not be applied until next `setData` or `applyDataUpdates` call. * When called inside observers, the data update will be applied when observer ends. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ updateData(newData: Partial>>): void; /** * Schedule a data update on a single specified path * * The data update will not be applied until next `setData` or `applyDataUpdates` call. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ replaceDataOnPath(path: readonly [...T], data: typeUtils.GetFromDataPath, T>): void; /** * Schedule an array update * * The behavior is like `Array.prototype.slice` . * Break the array before the `index`-th item, delete `del` items, and insert some items here. * If `index` is undefined, negative, or larger than the length of the array, * no items will be deleted and new items will be appended to the end of the array. * The data update will not be applied until next `setData` or `applyDataUpdates` call. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ spliceArrayDataOnPath(path: readonly [...T], index: typeUtils.GetFromDataPath, T> extends any[] ? number | undefined : never, del: typeUtils.GetFromDataPath, T> extends any[] ? number | undefined : never, inserts: typeUtils.GetFromDataPath, T> extends (infer I)[] ? I[] : never): void; /** * Apply all scheduled updates immediately * * Inside observers, it is generally not . */ applyDataUpdates(): void; /** * Pending all data updates in the callback, and apply updates after callback returns * * This function helps grouping several `replaceDataOnPath` or `spliceArrayDataOnPath` calls, * and then apply them at the end of the callback. * `setData` and `applyDataUpdates` calls inside the callback still apply updates immediately. */ groupUpdates(callback: () => T): T | undefined; /** * Check whether the `other` behavior is a dependent behavior or a implemented trait behavior */ hasBehavior(behavior: GeneralBehavior | TraitBehavior): boolean; /** * Get the trait behavior implementation of the component * * Returns `undefined` if the specified trait behavior is not implemented. */ traitBehavior(traitBehavior: TraitBehavior): TOut | undefined; /** Trigger an event */ triggerEvent(name: string, detail?: any, options?: { bubbles?: boolean; composed?: boolean; capturePhase?: boolean; }): void; /** Create a selector query for searching element inside the component */ createSelectorQuery(): SelectorQuery; /** Create an intersection observer */ createIntersectionObserver(options?: { thresholds?: number[]; initialRatio?: number; observeAll?: boolean; }): IntersectionObserver; /** Create a resize observer */ createResizeObserver(options?: { observeAll?: boolean; }): ResizeObserver; /** Create an media query observer */ createMediaQueryObserver(): MediaQueryObserver; /** * Query an element inside the component * * If `componentType` is provided, this method will check the selected component type. * If the component type does not match, `null` is returned. */ selectComponent(selector: string): any; selectComponent(selector: string, componentType: ComponentType): ExportType | null; /** * Query all elements inside the component * * If `componentType` is provided, this method will check the selected component type. * If a component type does not match, it is not returned. */ selectAllComponents(selector: string): GeneralComponent[]; selectAllComponents(selector: string, componentType: ComponentType): ExportType[]; /** * Get the owner component * * If `componentType` is provided, this method will check the selected component type. * If a component type does not match, `null` is returned. */ selectOwnerComponent(): any; selectOwnerComponent(componentType: ComponentType): ExportType | null; getRelationNodes(relationKey: string): GeneralComponent[]; /** Cast the component into a general-typed one */ general(): GeneralComponent; /** * Cast the component into the specified type * * Returns `null` if the component node is not the instance of the specified component. */ asInstanceOf(componentType: ComponentType): Component | null; } declare class ComponentProto { private proto; constructor(methods: TMethod, parents: GeneralBehavior[], componentExport?: (source: GeneralComponent | null) => TComponentExport); derive(): Component; } type component_AllData = AllData; type component_Component = Component; type component_ComponentCaller = ComponentCaller; declare const component_ComponentCaller: typeof ComponentCaller; type component_ComponentProto = ComponentProto; declare const component_ComponentProto: typeof ComponentProto; type component_GeneralComponent = GeneralComponent; type component_PropertyValues = PropertyValues; declare const component_determineComponentExports: typeof determineComponentExports; declare namespace component { export { type component_AllData as AllData, type component_Component as Component, component_ComponentCaller as ComponentCaller, component_ComponentProto as ComponentProto, type Empty$4 as Empty, type component_GeneralComponent as GeneralComponent, type component_PropertyValues as PropertyValues, component_determineComponentExports as determineComponentExports }; } type ResolveBehaviorBuilder = typeUtils.IsNever extends false ? TChainingFilter extends ChainingFilterType$4 ? Omit & TChainingFilter['add'] : B : B; type DataList$5 = typeUtils.DataList; type PropertyList$5 = typeUtils.PropertyList; type ChainingFilterType$4 = typeUtils.ChainingFilterType; type ComponentMethod$4 = typeUtils.ComponentMethod; type TaggedMethod$3 = typeUtils.TaggedMethod; interface RelationHandler { list(): TTarget[]; listAsTrait: TOut extends never ? undefined : () => TOut[]; } type TraitRelationParams = { target: TraitBehavior; type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node'; linked?: (target: GeneralComponent) => void; linkChanged?: (target: GeneralComponent) => void; unlinked?: (target: GeneralComponent) => void; linkFailed?: (target: GeneralComponent) => void; }; type RelationParams = { target?: string | GeneralComponentType | GeneralBehavior | TraitBehavior; type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node'; linked?: (target: GeneralComponent) => void; linkChanged?: (target: GeneralComponent) => void; unlinked?: (target: GeneralComponent) => void; linkFailed?: (target: GeneralComponent) => void; }; type Lifetimes = { created: () => void; attached: () => void; moved: () => void; detached: () => void; ready: () => void; }; interface BuilderContext extends ThisType { self: TMethodCaller; data: typeUtils.Merge>; setData: (this: void, newData: Partial>, callback?: () => void) => void; implement: (this: void, traitBehavior: TraitBehavior, impl: TIn) => void; relation(this: void, def: TraitRelationParams & ThisType): RelationHandler; relation(this: void, def: RelationParams & ThisType): RelationHandler; observer

>, V = typeUtils.GetFromObserverPathString, P>>(this: void, paths: P, func: (newValue: V) => void): void; observer

>[], V = { [K in keyof P]: typeUtils.GetFromObserverPathString, P[K]>; }>(this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void; lifetime: (this: void, name: L, func: Lifetimes[L]) => void; pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void; method: (this: void, func: Fn) => TaggedMethod$3; listener: (this: void, func: glassEasel.EventListener) => TaggedMethod$3>; } declare const enum StyleIsolation { Isolated = "isolated", ApplyShared = "apply-shared", Shared = "shared", PageIsolated = "page-isolated", PageApplyShared = "page-apply-shared", PageShared = "page-shared" } type ComponentStaticConfig = { component?: boolean; usingComponents?: { [name: string]: string; }; componentGenerics?: { [name: string]: true | { default?: string; }; }; componentPlaceholder?: { [name: string]: string; }; styleIsolation?: StyleIsolation; /** @obsolete */ addGlobalClass?: boolean; pureDataPattern?: string; }; type ComponentDefinitionOptions = { multipleSlots?: boolean; dynamicSlots?: boolean; pureDataPattern?: RegExp; virtualHost?: boolean; dataDeepCopy?: DeepCopyKind; propertyPassingDeepCopy?: DeepCopyKind; propertyEarlyInit?: boolean; propertyComparer?: (a: any, b: any) => boolean; }; type ComponentMethod$3 = typeUtils.ComponentMethod; type BehaviorDefinition = { behaviors?: GeneralBehavior[]; properties?: TProperty; data?: TData | (() => TData); observers?: { fields?: string; observer: ComponentMethod$3; }[] | { [fields: string]: ComponentMethod$3; }; methods?: TMethod; created?: ComponentMethod$3; attached?: ComponentMethod$3; ready?: ComponentMethod$3; moved?: ComponentMethod$3; detached?: ComponentMethod$3; lifetimes?: { [name: string]: ComponentMethod$3; }; pageLifetimes?: { [name: string]: ComponentMethod$3; }; relations?: Record; externalClasses?: string[]; definitionFilter?: DefinitionFilter; export?: (source: GeneralComponent | null) => TComponentExport; }; type ComponentDefinition = { options?: ComponentDefinitionOptions; } & BehaviorDefinition; type GeneralComponentDefinition = ComponentDefinition; type PageDefinition = TExtraFields & { options?: ComponentDefinitionOptions; behaviors?: GeneralBehavior[]; data?: TData; }; type types_BehaviorDefinition = BehaviorDefinition; type types_ComponentDefinition = ComponentDefinition; type types_ComponentDefinitionOptions = ComponentDefinitionOptions; type types_ComponentStaticConfig = ComponentStaticConfig; type types_GeneralComponentDefinition = GeneralComponentDefinition; type types_PageDefinition = PageDefinition; type types_StyleIsolation = StyleIsolation; declare const types_StyleIsolation: typeof StyleIsolation; declare namespace types { export { type types_BehaviorDefinition as BehaviorDefinition, type types_ComponentDefinition as ComponentDefinition, type types_ComponentDefinitionOptions as ComponentDefinitionOptions, type types_ComponentStaticConfig as ComponentStaticConfig, type types_GeneralComponentDefinition as GeneralComponentDefinition, type types_PageDefinition as PageDefinition, types_StyleIsolation as StyleIsolation, typeUtils as utils }; } type DataList$4 = typeUtils.DataList; type PropertyList$4 = typeUtils.PropertyList; type MethodList$4 = typeUtils.MethodList; type ChainingFilterType$3 = typeUtils.ChainingFilterType; type DefinitionFilter = (target: GeneralComponentDefinition, childFilters: (((target: GeneralComponentDefinition) => void) | null)[]) => void; type GeneralBehavior = Behavior, Record, Record, any, any, Record>; declare class Behavior { } type ComponentFieldTypes = { propertyValues: PropertyValues; dataWithProperties: AllData; methods: TMethod; }; declare class ComponentType { protected readonly _$fieldTypes: ComponentFieldTypes; } type GeneralComponentType = ComponentType, Record, Record, any, Record>; declare class TraitBehavior { constructor(inner: glassEasel.TraitBehavior); } type behavior_Behavior = Behavior; declare const behavior_Behavior: typeof Behavior; type behavior_ComponentFieldTypes = ComponentFieldTypes; type behavior_ComponentType = ComponentType; declare const behavior_ComponentType: typeof ComponentType; type behavior_DefinitionFilter = DefinitionFilter; type behavior_GeneralBehavior = GeneralBehavior; type behavior_GeneralComponentType = GeneralComponentType; type behavior_TraitBehavior = TraitBehavior; declare const behavior_TraitBehavior: typeof TraitBehavior; declare namespace behavior { export { behavior_Behavior as Behavior, type behavior_ComponentFieldTypes as ComponentFieldTypes, behavior_ComponentType as ComponentType, type behavior_DefinitionFilter as DefinitionFilter, type behavior_GeneralBehavior as GeneralBehavior, type behavior_GeneralComponentType as GeneralComponentType, behavior_TraitBehavior as TraitBehavior }; } type Empty$3 = typeUtils.Empty; type DataList$3 = typeUtils.DataList; type PropertyList$3 = typeUtils.PropertyList; type PropertyType$2 = typeUtils.PropertyType; type PropertyTypeToValueType$2 = typeUtils.PropertyTypeToValueType; type MethodList$3 = typeUtils.MethodList; type ChainingFilterType$2 = typeUtils.ChainingFilterType; type ComponentMethod$2 = typeUtils.ComponentMethod; type TaggedMethod$2 = typeUtils.TaggedMethod; type UnTaggedMethod$2> = typeUtils.UnTaggedMethod; declare class BaseBehaviorBuilder { protected _$codeSpace: CodeSpace; protected _$: glassEasel.BehaviorBuilder; protected _$parents: GeneralBehavior[]; protected _$export?: (source: GeneralComponent | null) => TComponentExport; /** Implement a trait behavior */ implement(traitBehavior: TraitBehavior, impl: TIn): ResolveBehaviorBuilder; /** Add external classes */ externalClasses(list: string[]): this; export(f: (this: GeneralComponent, source: GeneralComponent | null) => TNewComponentExport): ResolveBehaviorBuilder, TChainingFilter>; /** Use another behavior */ behavior(behavior: Behavior): ResolveBehaviorBuilder, UChainingFilter>; data(gen: () => typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; staticData(data: typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; property>(name: N, def: N extends keyof (TData & TProperty) ? never : typeUtils.PropertyListItem): ResolveBehaviorBuilder>, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; /** * Add some public methods * * The public method can be used as an event handler, and can be visited in component instance. */ methods(funcs: T & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add a data observer */ observer

>, V = typeUtils.GetFromObserverPathString, P>>(paths: P, func: (this: Component, newValue: V) => void, once?: boolean): ResolveBehaviorBuilder; observer

>[], V = { [K in keyof P]: typeUtils.GetFromObserverPathString, P[K]>; }>(paths: readonly [...P], func: (this: Component, ...newValues: V extends any[] ? V : never) => void, once?: boolean): ResolveBehaviorBuilder; /** * Add a lifetime callback */ lifetime(name: L, func: (this: Component, ...args: Parameters) => ReturnType, once?: boolean): ResolveBehaviorBuilder; /** * Add a page-lifetime callback */ pageLifetime(name: string, func: (this: Component, ...args: any[]) => any, once?: boolean): ResolveBehaviorBuilder; /** * Add a relation */ relation(name: string, rel: RelationParams & ThisType>): ResolveBehaviorBuilder; init any>> | void>(func: (this: Component, builderContext: BuilderContext>) => TExport): ResolveBehaviorBuilder; }), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; definition(def: BehaviorDefinition & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; } type Empty$2 = typeUtils.Empty; type DataList$2 = typeUtils.DataList; type PropertyList$2 = typeUtils.PropertyList; type PropertyType$1 = typeUtils.PropertyType; type PropertyTypeToValueType$1 = typeUtils.PropertyTypeToValueType; type MethodList$2 = typeUtils.MethodList; type ChainingFilterType$1 = typeUtils.ChainingFilterType; type ComponentMethod$1 = typeUtils.ComponentMethod; type TaggedMethod$1 = typeUtils.TaggedMethod; type UnTaggedMethod$1> = typeUtils.UnTaggedMethod; type ChainingFilterFunc = typeUtils.ChainingFilterFunc; type DefaultBehaviorBuilder = BehaviorBuilder; declare class BehaviorBuilder extends BaseBehaviorBuilder { private _$definitionFilter; private _$chainingFilter?; /** Define a chaining filter */ chainingFilter(func: ChainingFilterFunc): ResolveBehaviorBuilder, TChainingFilter>; /** Use another behavior */ behavior(behavior: Behavior): ResolveBehaviorBuilder, UChainingFilter>; /** Set the export value when the component is being selected */ export(f: (this: GeneralComponent, source: GeneralComponent | null) => TNewComponentExport): ResolveBehaviorBuilder, TChainingFilter>; /** * Add some template data fields * * It does not support raw data, but a `gen` function which returns the new data fields. * The `gen` function executes once during component instance creation. */ data(gen: () => typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add some template data fields * * The data should be JSON-compatible, and will be cloned during component creation. */ staticData(data: typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add a single property * * The property name should be different from other properties. */ property>(name: N, def: N extends keyof (TData & TProperty) ? never : typeUtils.PropertyListItem): ResolveBehaviorBuilder>, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; /** * Add some public methods * * The public method can be used as an event handler, and can be visited in component instance. */ methods(funcs: T & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Execute a function while component instance creation * * A `BuilderContext` is provided to tweak the component creation progress. * The return value is used as the "export" value of the behavior. */ init any>> | void>(func: (this: Component, builderContext: BuilderContext>) => TExport): ResolveBehaviorBuilder; }), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; /** Apply a classic definition object */ definition(def: BehaviorDefinition & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Finish the behavior definition process */ register(): Behavior; /** * Add extra this fields type */ extraThisFieldsType(): ResolveBehaviorBuilder, TChainingFilter>; } type Empty$1 = typeUtils.Empty; type DataList$1 = typeUtils.DataList; type PropertyList$1 = typeUtils.PropertyList; type PropertyType = typeUtils.PropertyType; type PropertyTypeToValueType = typeUtils.PropertyTypeToValueType; type MethodList$1 = typeUtils.MethodList; type ChainingFilterType = typeUtils.ChainingFilterType; type ComponentMethod = typeUtils.ComponentMethod; type TaggedMethod = typeUtils.TaggedMethod; type UnTaggedMethod> = typeUtils.UnTaggedMethod; type DefaultComponentBuilder = ComponentBuilder; /** * A direct way to create a component */ declare class ComponentBuilder extends BaseBehaviorBuilder { private _$is; private _$alias?; private _$options?; private _$proto?; /** * Set the component options * * If called multiple times, only the latest call is valid. */ options(options: ComponentDefinitionOptions): ResolveBehaviorBuilder; /** Use another behavior */ behavior(behavior: Behavior): ResolveBehaviorBuilder, UChainingFilter>; /** Set the export value when the component is being selected */ export(f: (this: GeneralComponent, source: GeneralComponent | null) => TNewComponentExport): ResolveBehaviorBuilder, TChainingFilter>; /** * Add some template data fields * * It does not support raw data, but a `gen` function which returns the new data fields. * The `gen` function executes once during component instance creation. */ data(gen: () => typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add some template data fields * * The data should be JSON-compatible, and will be cloned during component creation. */ staticData(data: typeUtils.NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add a single property * * The property name should be different from other properties. */ property>(name: N, def: N extends keyof (TData & TProperty) ? never : typeUtils.PropertyListItem): ResolveBehaviorBuilder>, TMethod, TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; /** * Add some public methods * * The public method can be used as an event handler, and can be visited in component instance. */ methods(funcs: T & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Execute a function while component instance creation * * A `BuilderContext` is provided to tweak the component creation progress. * The return value is used as the "export" value of the behavior. */ init any>> | void>(func: (this: Component, builderContext: BuilderContext>) => TExport): ResolveBehaviorBuilder; }), TChainingFilter, TPendingChainingFilter, TComponentExport, TExtraThisFields>, TChainingFilter>; /** Apply a classic definition object */ definition(def: ComponentDefinition & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; pageDefinition(def: PageDefinition & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Finish the component definition process */ register(): ComponentType; /** * Add extra this fields type */ extraThisFieldsType(): ResolveBehaviorBuilder, TChainingFilter>; } type index_BehaviorBuilder = BehaviorBuilder; declare const index_BehaviorBuilder: typeof BehaviorBuilder; type index_BuilderContext = BuilderContext; type index_ComponentBuilder = ComponentBuilder; declare const index_ComponentBuilder: typeof ComponentBuilder; type index_DefaultBehaviorBuilder = DefaultBehaviorBuilder; type index_DefaultComponentBuilder = DefaultComponentBuilder; declare namespace index { export { index_BehaviorBuilder as BehaviorBuilder, type index_BuilderContext as BuilderContext, index_ComponentBuilder as ComponentBuilder, type index_DefaultBehaviorBuilder as DefaultBehaviorBuilder, type index_DefaultComponentBuilder as DefaultComponentBuilder }; } interface PageConstructor { (definition: PageDefinition & ThisType>): ComponentType; } interface ComponentConstructor { (): DefaultComponentBuilder; (definition: ComponentDefinition & ThisType>): ComponentType; } interface BehaviorConstructor { (): DefaultBehaviorBuilder; (definition: BehaviorDefinition & ThisType>): Behavior; trait(): TraitBehavior; trait(trans: (impl: TIn) => TOut): TraitBehavior; } interface ComponentEnv { Page: PageConstructor; Component: ComponentConstructor; Behavior: BehaviorConstructor; } type Empty = typeUtils.Empty; type DataList = typeUtils.DataList; type PropertyList = typeUtils.PropertyList; type MethodList = typeUtils.MethodList; /** * A component space with mini-program code manager */ declare class CodeSpace { private _$isMainSpace; private space; private styleScopeManager; private staticConfigMap; private styleSheetMap; private compiledTemplateMap; private waitingAliasMap; isMainSpace(): boolean; /** * Get the underlying component space */ getComponentSpace(): glassEasel.ComponentSpace; /** * Add a behavior for all components * * Must be called before any component registration so that the component will use this behavior. * Set to `null` to disable this behavior. */ setOverallBehavior(behavior: glassEasel.GeneralBehavior): void; /** * Import another component space as a plugin (must be in the same environment) * * Components from the imported `codeSpace` can be used with URLs. * If `domainAlias` is provided, the URL format is `plugin://DOMAIN_ALIAS/COMPONENT_SPACE_EXPORT_ALIAS` . * If `privateImport` is enabled, another URL format is `plugin-private://DOMAIN/COMPONENT_IS` . */ importCodeSpace(id: string, domainAlias?: string, privateImport?: boolean): void; /** * Add a style sheet URL with style scope name * * The URL should be recognized by the target backend. * The `path` should not contain the `.wxss` suffix. */ addStyleSheet(path: string, styleSheetUrl?: string, styleScopeName?: string): void; /** * Get a style sheet URL * * The URL should be recognized by the target backend. * The `path` should not contain the `.wxss` suffix. */ getStyleSheet(path: string): string | undefined; getStyleScopeName(path: string): string | undefined; /** * Add a compiled template * * The content is the execution result of the generated string of the template compiler. * The `path` should not contain the `.wxml` suffix. */ addCompiledTemplate(path: string, content: glassEasel.template.ComponentTemplate): void; /** * Get a compiled template * * The content is the execution result of the generated string of the template compiler. * The `path` should not contain the `.wxml` suffix. */ getCompiledTemplate(path: string): glassEasel.template.ComponentTemplate | undefined; /** * Add a static JSON config * * The `path` should not contain the `.json` suffix. */ addComponentStaticConfig(path: string, content: ComponentStaticConfig): void; /** * Get a static JSON config * * The `path` should not contain the `.json` suffix. */ getComponentStaticConfig(path: string): ComponentStaticConfig | undefined; /** * Create a component definition environment * * During the sync execution of `cb` , `Component` and `Behavior` global vars will be available. * `globalObject` should be the JavaScript global object, a.k.a. `window` in DOM. * Some global variables, a.k.a `Component` `Behavior` `Page` , * will be written into `globalObject` . * `path` should be the component path (without ".js" extension). */ globalComponentEnv(globalObject: any, path: string, cb: () => T): T; /** * Create a component definition environment * * Like `globalComponentEnv` , but the global variables are given as callback arguments. */ componentEnv(path: string, cb: (env: ComponentEnv) => T): T; /** * Build a component outside of a definition environment * * The method do not need a definition environment, so the global object pollution is avoided. * `path` should be the component path (without ".js" extension). */ component(path: string): DefaultComponentBuilder; /** * Build a behavior outside of a definition environment * * The method do not need a definition environment, so the global object pollution is avoided. */ behavior(): DefaultBehaviorBuilder; /** * Define a trait behavior */ traitBehavior(): TraitBehavior; traitBehavior(trans: (impl: TIn) => TOut): TraitBehavior; } /** * A backend context that has been associated to an environment */ declare class AssociatedBackend { private _$env; /** * Register a style sheet resource * * Some backend cannot load style sheet URL. * In this cases, the content should be registered here. */ registerStyleSheetContent(url: string, content: any): void; /** * Create a root component in specified backend * * The component is searched in the `codeSpace` with `url` . * If `url` contains "?" params, it will be parsed and try to set to component properties. */ createRoot(tagName: string, codeSpace: CodeSpace, url: string, genericTargets?: { [key: string]: string; }): Root; } /** * A root component */ declare class Root { private _$comp; /** * Get the root component */ get(): ComponentCaller; /** * Get the underlying component of the root component */ getComponent(): glassEasel.GeneralComponent; /** * Attach the root component to the backend * * This component, the `parent` and the `placeholder` MUST be in the same context. * The `parent` MUST be a parent node of the `placeholder` . * This also triggers `attached` lifetimes for components. */ attach(parent: glassEasel.GeneralBackendElement, placeholder: glassEasel.GeneralBackendElement): void; /** * Release the root component * * Some backends require this explicit call to avoid memory leaks. * This also triggers `detached` lifetimes for components. */ release(): void; } /** * A mini-program API environment * * Each environment manages multiple backend contexts. * However, a backend context should be exclusively managed by a single environment * (to avoid `StyleScopeId` confliction). * It is able to create multiple `CodeSpace` within the environment. */ declare class MiniProgramEnv { private codeSpaceMap; private globalCodeSpace; /** * Create an empty mini-program API environment */ constructor(); /** * Get a global code space in which global components can be defined * * External glass-easel based components can be defined in this code space. * All global components should be defined before any other `CodeSpace` created! */ getGlobalCodeSpace(): CodeSpace; /** * Associate a backend context * * If `backendContext` is not given, the DOM-based backend is used * (causes failure if running outside browsers). * The backend context SHOULD NOT be associated by other environments! */ associateBackend(backendContent?: glassEasel.GeneralBackendContext): AssociatedBackend; /** * Create a component space that can manage WXML, WXSS, JS and static JSON config files * * The space can be specified as a *main* space. * This makes some features available: * * the `app.wxss` will be used as a style sheet for all root components in the space; * * the `StyleIsolation.Shared` is accepted for components in the space. * Non-main spaces usually act as plugins. * `publicComponents` is a map for specifying a map of aliases and component paths. */ createCodeSpace(id: string, isMainSpace: boolean, publicComponents?: { [alias: string]: string; }): CodeSpace; /** * Get a component space by the `id` specified when created */ getCodeSpace(id: string): CodeSpace | undefined; } export { AssociatedBackend, type BehaviorConstructor, CodeSpace, type ComponentConstructor, type ComponentEnv, MiniProgramEnv, type PageConstructor, Root, behavior, index as builder, component, types };