UNPKG

76.7 kBTypeScriptView Raw
1import * as LogManager from 'aurelia-logging';
2import {
3 metadata,
4 Origin,
5 protocol
6} from 'aurelia-metadata';
7import {
8 DOM,
9 PLATFORM,
10 FEATURE
11} from 'aurelia-pal';
12import {
13 TemplateRegistryEntry,
14 Loader
15} from 'aurelia-loader';
16import {
17 relativeToFile
18} from 'aurelia-path';
19import {
20 Container,
21 resolver,
22 inject
23} from 'aurelia-dependency-injection';
24import {
25 ValueConverterResource,
26 BindingBehaviorResource,
27 camelCase,
28 Binding,
29 createOverrideContext,
30 subscriberCollection,
31 bindingMode,
32 ObserverLocator,
33 EventManager
34} from 'aurelia-binding';
35import {
36 TaskQueue
37} from 'aurelia-task-queue';
38export declare interface EventHandler {
39 eventName: string;
40 bubbles: boolean;
41 capture: boolean;
42 dispose: Function;
43 handler: Function;
44}
45
46/**
47* Specifies how a view should be created.
48*/
49export declare interface ViewCreateInstruction {
50
51 /**
52 * Indicates that the view is being created by enhancing existing DOM.
53 */
54 enhance?: boolean;
55
56 /**
57 * Specifies a key/value lookup of part replacements for the view being created.
58 */
59 partReplacements?: Object;
60}
61
62/**
63* Implemented by classes that describe how a view factory should be loaded.
64*/
65export declare interface ViewStrategy {
66
67 /**
68 * Loads a view factory.
69 * @param viewEngine The view engine to use during the load process.
70 * @param compileInstruction Additional instructions to use during compilation of the view.
71 * @param loadContext The loading context used for loading all resources and dependencies.
72 * @param target A class from which to extract metadata of additional resources to load.
73 * @return A promise for the view factory that is produced by this strategy.
74 */
75 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
76}
77export declare interface IStaticViewConfig {
78 template: string | HTMLTemplateElement;
79 dependencies?: Function[] | (() => Array<Function | Promise<Function | Record<string, Function>>>);
80}
81
82/**
83* View engine hooks that enable a view resource to provide custom processing during the compilation or creation of a view.
84*/
85export declare interface ViewEngineHooks {
86
87 /**
88 * Invoked before a template is compiled.
89 * @param content The DocumentFragment to compile.
90 * @param resources The resources to compile the view against.
91 * @param instruction The compilation instruction associated with the compilation process.
92 */
93 beforeCompile?: (content: DocumentFragment, resources: ViewResources, instruction: ViewCompileInstruction) => void;
94
95 /**
96 * Invoked after a template is compiled.
97 * @param viewFactory The view factory that was produced from the compilation process.
98 */
99 afterCompile?: (viewFactory: ViewFactory) => void;
100
101 /**
102 * Invoked before a view is created.
103 * @param viewFactory The view factory that will be used to create the view.
104 * @param container The DI container used during view creation.
105 * @param content The cloned document fragment representing the view.
106 * @param instruction The view creation instruction associated with this creation process.
107 */
108 beforeCreate?: (viewFactory: ViewFactory, container: Container, content: DocumentFragment, instruction: ViewCreateInstruction) => void;
109
110 /**
111 * Invoked after a view is created.
112 * @param view The view that was created by the factory.
113 */
114 afterCreate?: (view: View) => void;
115
116 /**
117 * Invoked after the bindingContext and overrideContext are configured on the view but before the view is bound.
118 * @param view The view that was created by the factory.
119 */
120 beforeBind?: (view: View) => void;
121
122 /**
123 * Invoked before the view is unbind. The bindingContext and overrideContext are still available on the view.
124 * @param view The view that was created by the factory.
125 */
126 beforeUnbind?: (view: View) => void;
127}
128export declare interface IBindablePropertyConfig {
129
130 /**
131 * The name of the property.
132 */
133 name?: string;
134 attribute?: string;
135
136 /**
137 * The default binding mode of the property. If given string, will use to lookup
138 */
139 defaultBindingMode?: bindingMode | 'oneTime' | 'oneWay' | 'twoWay' | 'fromView' | 'toView';
140
141 /**
142 * The name of a view model method to invoke when the property is updated.
143 */
144 changeHandler?: string;
145
146 /**
147 * A default value for the property.
148 */
149 defaultValue?: any;
150
151 /**
152 * Designates the property as the default bindable property among all the other bindable properties when used in a custom attribute with multiple bindable properties.
153 */
154 primaryProperty?: boolean;
155
156 // For compatibility and future extension
157 [key: string]: any;
158}
159export declare interface IStaticResourceConfig {
160
161 /**
162 * Resource type of this class, omit equals to custom element
163 */
164 type?: 'element' | 'attribute' | 'valueConverter' | 'bindingBehavior' | 'viewEngineHooks';
165
166 /**
167 * Name of this resource. Reccommended to explicitly set to works better with minifier
168 */
169 name?: string;
170
171 /**
172 * Used to tell if a custom attribute is a template controller
173 */
174 templateController?: boolean;
175
176 /**
177 * Used to set default binding mode of default custom attribute view model "value" property
178 */
179 defaultBindingMode?: bindingMode | 'oneTime' | 'oneWay' | 'twoWay' | 'fromView' | 'toView';
180
181 /**
182 * Flags a custom attribute has dynamic options
183 */
184 hasDynamicOptions?: boolean;
185
186 /**
187 * Flag if this custom element uses native shadow dom instead of emulation
188 */
189 usesShadowDOM?: boolean;
190
191 /**
192 * Options that will be used if the element is flagged with usesShadowDOM
193 */
194 shadowDOMOptions?: ShadowRootInit;
195
196 /**
197 * Flag a custom element as containerless. Which will remove their render target
198 */
199 containerless?: boolean;
200
201 /**
202 * Custom processing of the attributes on an element before the framework inspects them.
203 */
204 processAttributes?: (viewCompiler: ViewCompiler, resources: ViewResources, node: Element, attributes: NamedNodeMap, elementInstruction: BehaviorInstruction) => void;
205
206 /**
207 * Enables custom processing of the content that is places inside the custom element by its consumer.
208 * Pass a boolean to direct the template compiler to not process
209 * the content placed inside this element. Alternatively, pass a function which
210 * can provide custom processing of the content. This function should then return
211 * a boolean indicating whether the compiler should also process the content.
212 */
213 processContent?: (viewCompiler: ViewCompiler, resources: ViewResources, node: Element, instruction: BehaviorInstruction) => boolean;
214
215 /**
216 * List of bindable properties of this custom element / custom attribute, by name or full config object
217 */
218 bindables?: string | IBindablePropertyConfig[];
219}
220
221/* eslint no-unused-vars: 0, no-constant-condition: 0 */
222/**
223* Represents a node in the view hierarchy.
224*/
225export declare interface ViewNode {
226
227 /**
228 * Binds the node and it's children.
229 * @param bindingContext The binding context to bind to.
230 * @param overrideContext A secondary binding context that can override the standard context.
231 */
232 bind(bindingContext: Object, overrideContext?: Object): void;
233
234 /**
235 * Triggers the attach for the node and its children.
236 */
237 attached(): void;
238
239 /**
240 * Triggers the detach for the node and its children.
241 */
242 detached(): void;
243
244 /**
245 * Unbinds the node and its children.
246 */
247 unbind(): void;
248}
249
250/**
251* An optional interface describing the created convention.
252*/
253export declare interface ComponentCreated {
254
255 /**
256 * Implement this hook if you want to perform custom logic after the constructor has been called.
257 * At this point in time, the view has also been created and both the view-model and the view
258 * are connected to their controller. The hook will recieve the instance of the "owningView".
259 * This is the view that the component is declared inside of. If the component itself has a view,
260 * this will be passed second.
261 */
262 created(owningView: View, myView: View): void;
263}
264
265/**
266* An optional interface describing the bind convention.
267*/
268/**
269* An optional interface describing the bind convention.
270*/
271export declare interface ComponentBind {
272
273 /**
274 * Implement this hook if you want to perform custom logic when databinding is activated on the view and view-model.
275 * The "binding context" to which the component is being bound will be passed first.
276 * An "override context" will be passed second. The override context contains information used to traverse
277 * the parent hierarchy and can also be used to add any contextual properties that the component wants to add.
278 */
279 bind(bindingContext: any, overrideContext: any): void;
280}
281
282/**
283* An optional interface describing the attached convention.
284*/
285/**
286* An optional interface describing the attached convention.
287*/
288export declare interface ComponentAttached {
289
290 /**
291 * Implement this hook if you want to perform custom logic when the component is attached to the DOM (in document).
292 */
293 attached(): void;
294}
295
296/**
297* An optional interface describing the detached convention.
298*/
299/**
300* An optional interface describing the detached convention.
301*/
302export declare interface ComponentDetached {
303
304 /**
305 * Implement this hook if you want to perform custom logic if/when the component is removed from the the DOM.
306 */
307 detached(): void;
308}
309
310/**
311* An optional interface describing the unbind convention.
312*/
313/**
314* An optional interface describing the unbind convention.
315*/
316export declare interface ComponentUnbind {
317
318 /**
319 * Implement this hook if you want to perform custom logic after the component is detached and unbound.
320 */
321 unbind(): void;
322}
323
324/**
325* An optional interface describing the getViewStrategy convention for dynamic components (used with the compose element or the router).
326*/
327/**
328* An optional interface describing the getViewStrategy convention for dynamic components (used with the compose element or the router).
329*/
330export declare interface DynamicComponentGetViewStrategy {
331
332 /**
333 * Implement this hook if you want to provide custom view strategy when this component is used with the compose element or the router.
334 */
335 getViewStrategy(): string | ViewStrategy;
336}
337
338/**
339* Instructs the composition engine how to dynamically compose a component.
340*/
341export declare interface CompositionContext {
342
343 /**
344 * The parent Container for the component creation.
345 */
346 container: Container;
347
348 /**
349 * The child Container for the component creation. One will be created from the parent if not provided.
350 */
351 childContainer?: Container;
352
353 /**
354 * The context in which the view model is executed in.
355 */
356 bindingContext: any;
357
358 /**
359 * A secondary binding context that can override the standard context.
360 */
361 overrideContext?: any;
362
363 /**
364 * The view model url or instance for the component.
365 */
366 viewModel?: any;
367
368 /**
369 * Data to be passed to the "activate" hook on the view model.
370 */
371 model?: any;
372
373 /**
374 * The HtmlBehaviorResource for the component.
375 */
376 viewModelResource?: HtmlBehaviorResource;
377
378 /**
379 * The view resources for the view in which the component should be created.
380 */
381 viewResources: ViewResources;
382
383 /**
384 * The view inside which this composition is happening.
385 */
386 owningView?: View;
387
388 /**
389 * The view url or view strategy to override the default view location convention.
390 */
391 view?: string | ViewStrategy;
392
393 /**
394 * The slot to push the dynamically composed component into.
395 */
396 viewSlot: ViewSlot;
397
398 /**
399 * Should the composition system skip calling the "activate" hook on the view model.
400 */
401 skipActivation?: boolean;
402
403 /**
404 * The element that will parent the dynamic component.
405 * It will be registered in the child container of this composition.
406 */
407 host?: Element;
408}
409export declare interface IStaticViewStrategyConfig {
410 template: string | HTMLTemplateElement;
411 dependencies?: Function[] | {};
412}
413
414/**
415* Instructs the framework in how to enhance an existing DOM structure.
416*/
417export declare interface EnhanceInstruction {
418
419 /**
420 * The DI container to use as the root for UI enhancement.
421 */
422 container?: Container;
423
424 /**
425 * The element to enhance.
426 */
427 element: Element;
428
429 /**
430 * The resources available for enhancement.
431 */
432 resources?: ViewResources;
433
434 /**
435 * A binding context for the enhancement.
436 */
437 bindingContext?: Object;
438
439 /**
440 * A secondary binding context that can override the standard context.
441 */
442 overrideContext?: any;
443}
444
445/**
446* List the events that an Animator should raise.
447*/
448export declare const animationEvent: any;
449
450/**
451 * An abstract class representing a mechanism for animating the DOM during various DOM state transitions.
452 */
453export declare class Animator {
454
455 /**
456 * Execute an 'enter' animation on an element
457 * @param element Element to animate
458 * @returns Resolved when the animation is done
459 */
460 enter(element: HTMLElement): Promise<boolean>;
461
462 /**
463 * Execute a 'leave' animation on an element
464 * @param element Element to animate
465 * @returns Resolved when the animation is done
466 */
467 leave(element: HTMLElement): Promise<boolean>;
468
469 /**
470 * Add a class to an element to trigger an animation.
471 * @param element Element to animate
472 * @param className Properties to animate or name of the effect to use
473 * @returns Resolved when the animation is done
474 */
475 removeClass(element: HTMLElement, className: string): Promise<boolean>;
476
477 /**
478 * Add a class to an element to trigger an animation.
479 * @param element Element to animate
480 * @param className Properties to animate or name of the effect to use
481 * @returns Resolved when the animation is done
482 */
483 addClass(element: HTMLElement, className: string): Promise<boolean>;
484
485 /**
486 * Execute a single animation.
487 * @param element Element to animate
488 * @param className Properties to animate or name of the effect to use. For css animators this represents the className to be added and removed right after the animation is done.
489 * @param options options for the animation (duration, easing, ...)
490 * @returns Resolved when the animation is done
491 */
492 animate(element: HTMLElement | Array<HTMLElement>, className: string): Promise<boolean>;
493
494 /**
495 * Run a sequence of animations one after the other.
496 * for example: animator.runSequence("fadeIn","callout")
497 * @param sequence An array of effectNames or classNames
498 * @returns Resolved when all animations are done
499 */
500 runSequence(animations: Array<any>): Promise<boolean>;
501
502 /**
503 * Register an effect (for JS based animators)
504 * @param effectName identifier of the effect
505 * @param properties Object with properties for the effect
506 */
507 registerEffect(effectName: string, properties: Object): void;
508
509 /**
510 * Unregister an effect (for JS based animators)
511 * @param effectName identifier of the effect
512 */
513 unregisterEffect(effectName: string): void;
514}
515
516/**
517* A mechanism by which an enlisted async render operation can notify the owning transaction when its work is done.
518*/
519export declare class CompositionTransactionNotifier {
520 constructor(owner?: any);
521
522 /**
523 * Notifies the owning transaction that its work is done.
524 */
525 done(): void;
526}
527
528/**
529* Referenced by the subsytem which wishes to control a composition transaction.
530*/
531export declare class CompositionTransactionOwnershipToken {
532 constructor(owner?: any);
533
534 /**
535 * Allows the transaction owner to wait for the completion of all child compositions.
536 * @return A promise that resolves when all child compositions are done.
537 */
538 waitForCompositionComplete(): Promise<void>;
539
540 /**
541 * Used internall to resolve the composition complete promise.
542 */
543 resolve(): void;
544}
545
546/**
547* Enables an initiator of a view composition to track any internal async rendering processes for completion.
548*/
549export declare class CompositionTransaction {
550
551 /**
552 * Creates an instance of CompositionTransaction.
553 */
554 constructor();
555
556 /**
557 * Attempt to take ownership of the composition transaction.
558 * @return An ownership token if successful, otherwise null.
559 */
560 tryCapture(): CompositionTransactionOwnershipToken;
561
562 /**
563 * Enlist an async render operation into the transaction.
564 * @return A completion notifier.
565 */
566 enlist(): CompositionTransactionNotifier;
567}
568export declare class ViewEngineHooksResource {
569 constructor();
570 initialize(container?: any, target?: any): any;
571 register(registry?: any, name?: any): any;
572 load(container?: any, target?: any): any;
573 static convention(name?: any): any;
574}
575export declare function viewEngineHooks(target?: any): any;
576
577/**
578 * Dispatches subscribets to and publishes events in the DOM.
579 * @param element
580 */
581/**
582 * Dispatches subscribets to and publishes events in the DOM.
583 * @param element
584 */
585export declare class ElementEvents {
586 constructor(element: EventTarget);
587
588 /**
589 * Dispatches an Event on the context element.
590 * @param eventName
591 * @param detail
592 * @param bubbles
593 * @param cancelable
594 */
595 publish(eventName: string, detail?: Object, bubbles?: boolean, cancelable?: boolean): any;
596
597 /**
598 * Adds and Event Listener on the context element.
599 * @return Returns the eventHandler containing a dispose method
600 */
601 subscribe(eventName: string, handler: Function, captureOrOptions?: boolean): EventHandler;
602
603 /**
604 * Adds an Event Listener on the context element, that will be disposed on the first trigger.
605 * @return Returns the eventHandler containing a dispose method
606 */
607 subscribeOnce(eventName: string, handler: Function, captureOrOptions?: boolean): EventHandler;
608
609 /**
610 * Removes all events that are listening to the specified eventName.
611 * @param eventName
612 */
613 dispose(eventName: string): void;
614
615 /**
616 * Removes all event handlers.
617 */
618 disposeAll(): any;
619}
620
621/**
622* A context that flows through the view resource load process.
623*/
624export declare class ResourceLoadContext {
625 dependencies: Object;
626
627 /**
628 * Creates an instance of ResourceLoadContext.
629 */
630 constructor();
631
632 /**
633 * Tracks a dependency that is being loaded.
634 * @param url The url of the dependency.
635 */
636 addDependency(url: string): void;
637
638 /**
639 * Checks if the current context includes a load of the specified url.
640 * @return True if the url is being loaded in the context; false otherwise.
641 */
642 hasDependency(url: string): boolean;
643}
644
645/**
646* Specifies how a view should be compiled.
647*/
648export declare class ViewCompileInstruction {
649 targetShadowDOM: boolean;
650 compileSurrogate: boolean;
651 associatedModuleId: any;
652
653 /**
654 * The normal configuration for view compilation.
655 */
656 static normal: ViewCompileInstruction;
657
658 /**
659 * Creates an instance of ViewCompileInstruction.
660 * @param targetShadowDOM Should the compilation target the Shadow DOM.
661 * @param compileSurrogate Should the compilation also include surrogate bindings and behaviors.
662 */
663 constructor(targetShadowDOM?: boolean, compileSurrogate?: boolean);
664}
665
666/**
667* Indicates how a custom attribute or element should be instantiated in a view.
668*/
669/**
670* Indicates how a custom attribute or element should be instantiated in a view.
671*/
672export declare class BehaviorInstruction {
673 initiatedByBehavior: boolean;
674 enhance: boolean;
675 partReplacements: any;
676 viewFactory: ViewFactory;
677 originalAttrName: string;
678 skipContentProcessing: boolean;
679 contentFactory: any;
680 viewModel: Object;
681 anchorIsContainer: boolean;
682 host: Element;
683 attributes: Object;
684 type: HtmlBehaviorResource;
685 attrName: string;
686 inheritBindingContext: boolean;
687
688 /**
689 * A default behavior used in scenarios where explicit configuration isn't available.
690 */
691 static normal: BehaviorInstruction;
692
693 /**
694 * Creates an instruction for element enhancement.
695 * @return The created instruction.
696 */
697 static enhance(): BehaviorInstruction;
698
699 /**
700 * Creates an instruction for unit testing.
701 * @param type The HtmlBehaviorResource to create.
702 * @param attributes A key/value lookup of attributes for the behaior.
703 * @return The created instruction.
704 */
705 static unitTest(type: HtmlBehaviorResource, attributes: Object): BehaviorInstruction;
706
707 /**
708 * Creates a custom element instruction.
709 * @param node The node that represents the custom element.
710 * @param type The HtmlBehaviorResource to create.
711 * @return The created instruction.
712 */
713 static element(node: Node, type: HtmlBehaviorResource): BehaviorInstruction;
714
715 /**
716 * Creates a custom attribute instruction.
717 * @param attrName The name of the attribute.
718 * @param type The HtmlBehaviorResource to create.
719 * @return The created instruction.
720 */
721 static attribute(attrName: string, type?: HtmlBehaviorResource): BehaviorInstruction;
722
723 /**
724 * Creates a dynamic component instruction.
725 * @param host The element that will parent the dynamic component.
726 * @param viewModel The dynamic component's view model instance.
727 * @param viewFactory A view factory used in generating the component's view.
728 * @return The created instruction.
729 */
730 static dynamic(host: Element, viewModel: Object, viewFactory: ViewFactory): BehaviorInstruction;
731
732 /**
733 * Creates an instance of BehaviorInstruction.
734 */
735 constructor();
736}
737
738/**
739* Provides all the instructions for how a target element should be enhanced inside of a view.
740*/
741export declare class TargetInstruction {
742 injectorId: number;
743 parentInjectorId: number;
744 shadowSlot: boolean;
745 slotName: string;
746 slotFallbackFactory: any;
747 contentExpression: any;
748 expressions: Array<Object>;
749 behaviorInstructions: Array<BehaviorInstruction>;
750 providers: Array<Function>;
751 viewFactory: ViewFactory;
752 anchorIsContainer: boolean;
753 elementInstruction: BehaviorInstruction;
754 lifting: boolean;
755 values: Object;
756
757 /**
758 * An empty array used to represent a target with no binding expressions.
759 */
760 static noExpressions: any;
761
762 /**
763 * Creates an instruction that represents a shadow dom slot.
764 * @param parentInjectorId The id of the parent dependency injection container.
765 * @return The created instruction.
766 */
767 static shadowSlot(parentInjectorId: number): TargetInstruction;
768
769 /**
770 * Creates an instruction that represents a binding expression in the content of an element.
771 * @param expression The binding expression.
772 * @return The created instruction.
773 */
774 static contentExpression(expression?: any): TargetInstruction;
775
776 /**
777 * Creates an instruction that represents content that was lifted out of the DOM and into a ViewFactory.
778 * @param parentInjectorId The id of the parent dependency injection container.
779 * @param liftingInstruction The behavior instruction of the lifting behavior.
780 * @return The created instruction.
781 */
782 static lifting(parentInjectorId: number, liftingInstruction: BehaviorInstruction): TargetInstruction;
783
784 /**
785 * Creates an instruction that represents an element with behaviors and bindings.
786 * @param injectorId The id of the dependency injection container.
787 * @param parentInjectorId The id of the parent dependency injection container.
788 * @param providers The types which will provide behavior for this element.
789 * @param behaviorInstructions The instructions for creating behaviors on this element.
790 * @param expressions Bindings, listeners, triggers, etc.
791 * @param elementInstruction The element behavior for this element.
792 * @return The created instruction.
793 */
794 static normal(injectorId: number, parentInjectorId: number, providers: Array<Function>, behaviorInstructions: Array<BehaviorInstruction>, expressions: Array<Object>, elementInstruction: BehaviorInstruction): TargetInstruction;
795
796 /**
797 * Creates an instruction that represents the surrogate behaviors and bindings for an element.
798 * @param providers The types which will provide behavior for this element.
799 * @param behaviorInstructions The instructions for creating behaviors on this element.
800 * @param expressions Bindings, listeners, triggers, etc.
801 * @param values A key/value lookup of attributes to transplant.
802 * @return The created instruction.
803 */
804 static surrogate(providers: Array<Function>, behaviorInstructions: Array<BehaviorInstruction>, expressions: Array<Object>, values: Object): TargetInstruction;
805
806 /**
807 * Creates an instance of TargetInstruction.
808 */
809 constructor();
810}
811
812/**
813* Decorator: Indicates that the decorated class/object is a view strategy.
814*/
815/**
816* Decorator: Indicates that the decorated class/object is a view strategy.
817*/
818export declare const viewStrategy: Function;
819
820/**
821* A view strategy that loads a view relative to its associated view-model.
822*/
823export declare class RelativeViewStrategy {
824
825 /**
826 * Creates an instance of RelativeViewStrategy.
827 * @param path The relative path to the view.
828 */
829 constructor(path: string);
830
831 /**
832 * Loads a view factory.
833 * @param viewEngine The view engine to use during the load process.
834 * @param compileInstruction Additional instructions to use during compilation of the view.
835 * @param loadContext The loading context used for loading all resources and dependencies.
836 * @param target A class from which to extract metadata of additional resources to load.
837 * @return A promise for the view factory that is produced by this strategy.
838 */
839 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
840
841 /**
842 * Makes the view loaded by this strategy relative to the provided file path.
843 * @param file The path to load the view relative to.
844 */
845 makeRelativeTo(file: string): void;
846}
847
848/**
849* A view strategy based on naming conventions.
850*/
851export declare class ConventionalViewStrategy {
852
853 /**
854 * Creates an instance of ConventionalViewStrategy.
855 * @param viewLocator The view locator service for conventionally locating the view.
856 * @param origin The origin of the view model to conventionally load the view for.
857 */
858 constructor(viewLocator: ViewLocator, origin: Origin);
859
860 /**
861 * Loads a view factory.
862 * @param viewEngine The view engine to use during the load process.
863 * @param compileInstruction Additional instructions to use during compilation of the view.
864 * @param loadContext The loading context used for loading all resources and dependencies.
865 * @param target A class from which to extract metadata of additional resources to load.
866 * @return A promise for the view factory that is produced by this strategy.
867 */
868 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
869}
870
871/**
872* A view strategy that indicates that the component has no view that the templating engine needs to manage.
873* Typically used when the component author wishes to take over fine-grained rendering control.
874*/
875export declare class NoViewStrategy {
876
877 /**
878 * Creates an instance of NoViewStrategy.
879 * @param dependencies A list of view resource dependencies of this view.
880 * @param dependencyBaseUrl The base url for the view dependencies.
881 */
882 constructor(dependencies?: Array<string | Function | Object>, dependencyBaseUrl?: string);
883
884 /**
885 * Loads a view factory.
886 * @param viewEngine The view engine to use during the load process.
887 * @param compileInstruction Additional instructions to use during compilation of the view.
888 * @param loadContext The loading context used for loading all resources and dependencies.
889 * @param target A class from which to extract metadata of additional resources to load.
890 * @return A promise for the view factory that is produced by this strategy.
891 */
892 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
893}
894
895/**
896* A view strategy created directly from the template registry entry.
897*/
898export declare class TemplateRegistryViewStrategy {
899
900 /**
901 * Creates an instance of TemplateRegistryViewStrategy.
902 * @param moduleId The associated moduleId of the view to be loaded.
903 * @param entry The template registry entry used in loading the view factory.
904 */
905 constructor(moduleId: string, entry: TemplateRegistryEntry);
906
907 /**
908 * Loads a view factory.
909 * @param viewEngine The view engine to use during the load process.
910 * @param compileInstruction Additional instructions to use during compilation of the view.
911 * @param loadContext The loading context used for loading all resources and dependencies.
912 * @param target A class from which to extract metadata of additional resources to load.
913 * @return A promise for the view factory that is produced by this strategy.
914 */
915 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
916}
917
918/**
919* A view strategy that allows the component author to inline the html for the view.
920*/
921export declare class InlineViewStrategy {
922
923 /**
924 * Creates an instance of InlineViewStrategy.
925 * @param markup The markup for the view. Be sure to include the wrapping template tag.
926 * @param dependencies A list of view resource dependencies of this view.
927 * @param dependencyBaseUrl The base url for the view dependencies.
928 */
929 constructor(markup: string, dependencies?: Array<string | Function | Object>, dependencyBaseUrl?: string);
930
931 /**
932 * Loads a view factory.
933 * @param viewEngine The view engine to use during the load process.
934 * @param compileInstruction Additional instructions to use during compilation of the view.
935 * @param loadContext The loading context used for loading all resources and dependencies.
936 * @param target A class from which to extract metadata of additional resources to load.
937 * @return A promise for the view factory that is produced by this strategy.
938 */
939 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
940}
941export declare class StaticViewStrategy {
942
943 /**@internal */
944 template: string | HTMLTemplateElement;
945
946 /**@internal */
947 dependencies: Function[] | (() => Array<Function | Promise<Function | Record<string, Function>>>);
948 factoryIsReady: boolean;
949 factory: ViewFactory;
950 constructor(config: string | HTMLTemplateElement | IStaticViewConfig);
951
952 /**
953 * Loads a view factory.
954 * @param viewEngine The view engine to use during the load process.
955 * @param compileInstruction Additional instructions to use during compilation of the view.
956 * @param loadContext The loading context used for loading all resources and dependencies.
957 * @param target A class from which to extract metadata of additional resources to load.
958 * @return A promise for the view factory that is produced by this strategy.
959 */
960 loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext: ResourceLoadContext, target: any): Promise<ViewFactory>;
961}
962
963/**
964* Locates a view for an object.
965*/
966export declare class ViewLocator {
967
968 /**
969 * The metadata key for storing/finding view strategies associated with an class/object.
970 */
971 static viewStrategyMetadataKey: any;
972
973 /**
974 * Gets the view strategy for the value.
975 * @param value The value to locate the view strategy for.
976 * @return The located ViewStrategy instance.
977 */
978 getViewStrategy(value: any): ViewStrategy;
979
980 /**
981 * Creates a fallback View Strategy. Used when unable to locate a configured strategy.
982 * The default implementation returns and instance of ConventionalViewStrategy.
983 * @param origin The origin of the view model to return the strategy for.
984 * @return The fallback ViewStrategy.
985 */
986 createFallbackViewStrategy(origin: Origin): ViewStrategy;
987
988 /**
989 * Conventionally converts a view model origin to a view url.
990 * Used by the ConventionalViewStrategy.
991 * @param origin The origin of the view model to convert.
992 * @return The view url.
993 */
994 convertOriginToViewUrl(origin: Origin): string;
995}
996
997/**
998* An abstract base class for implementations of a binding language.
999*/
1000export declare class BindingLanguage {
1001
1002 /**
1003 * Inspects an attribute for bindings.
1004 * @param resources The ViewResources for the view being compiled.
1005 * @param elementName The element name to inspect.
1006 * @param attrName The attribute name to inspect.
1007 * @param attrValue The attribute value to inspect.
1008 * @return An info object with the results of the inspection.
1009 */
1010 inspectAttribute(resources: ViewResources, elementName: string, attrName: string, attrValue: string): Object;
1011
1012 /**
1013 * Creates an attribute behavior instruction.
1014 * @param resources The ViewResources for the view being compiled.
1015 * @param element The element that the attribute is defined on.
1016 * @param info The info object previously returned from inspectAttribute.
1017 * @param existingInstruction A previously created instruction for this attribute.
1018 * @return The instruction instance.
1019 */
1020 createAttributeInstruction(resources: ViewResources, element: Element, info: Object, existingInstruction?: Object): BehaviorInstruction;
1021
1022 /**
1023 * Parses the text for bindings.
1024 * @param resources The ViewResources for the view being compiled.
1025 * @param value The value of the text to parse.
1026 * @return A binding expression.
1027 */
1028 inspectTextContent(resources: ViewResources, value: string): Object;
1029}
1030export declare class SlotCustomAttribute {
1031 static inject(): any;
1032 constructor(element?: any);
1033 valueChanged(newValue?: any, oldValue?: any): any;
1034}
1035export declare class PassThroughSlot {
1036 constructor(anchor?: any, name?: any, destinationName?: any, fallbackFactory?: any);
1037 needsFallbackRendering: any;
1038 renderFallbackContent(view?: any, nodes?: any, projectionSource?: any, index?: any): any;
1039 passThroughTo(destinationSlot?: any): any;
1040 addNode(view?: any, node?: any, projectionSource?: any, index?: any): any;
1041 removeView(view?: any, projectionSource?: any): any;
1042 removeAll(projectionSource?: any): any;
1043 projectFrom(view?: any, projectionSource?: any): any;
1044 created(ownerView?: any): any;
1045 bind(view?: any): any;
1046 attached(): any;
1047 detached(): any;
1048 unbind(): any;
1049}
1050export declare class ShadowSlot {
1051 constructor(anchor?: any, name?: any, fallbackFactory?: any);
1052 needsFallbackRendering: any;
1053 addNode(view?: any, node?: any, projectionSource?: any, index?: any, destination?: any): any;
1054 removeView(view?: any, projectionSource?: any): any;
1055 removeAll(projectionSource?: any): any;
1056 projectTo(slots?: any): any;
1057 projectFrom(view?: any, projectionSource?: any): any;
1058 renderFallbackContent(view?: any, nodes?: any, projectionSource?: any, index?: any): any;
1059 created(ownerView?: any): any;
1060 bind(view?: any): any;
1061 attached(): any;
1062 detached(): any;
1063 unbind(): any;
1064}
1065export declare class ShadowDOM {
1066 static defaultSlotKey: any;
1067 static getSlotName(node?: any): any;
1068 static distributeView(view?: any, slots?: any, projectionSource?: any, index?: any, destinationOverride?: any): any;
1069 static undistributeView(view?: any, slots?: any, projectionSource?: any): any;
1070 static undistributeAll(slots?: any, projectionSource?: any): any;
1071 static distributeNodes(view?: any, nodes?: any, slots?: any, projectionSource?: any, index?: any, destinationOverride?: any): any;
1072}
1073export declare function validateBehaviorName(name: string, type: string): any;
1074
1075/**
1076 * Represents a collection of resources used during the compilation of a view.
1077 * Will optinally add information to an existing HtmlBehaviorResource if given
1078 */
1079export declare class ViewResources {
1080
1081 /**
1082 * Checks whether the provided class contains any resource conventions
1083 * @param target Target class to extract metadata based on convention
1084 * @param existing If supplied, all custom element / attribute metadata extracted from convention will be apply to this instance
1085 */
1086 static convention(target: Function, existing?: HtmlBehaviorResource): HtmlBehaviorResource | ValueConverterResource | BindingBehaviorResource | ViewEngineHooksResource;
1087
1088 /**
1089 * A custom binding language used in the view.
1090 */
1091 bindingLanguage: any;
1092
1093 /**
1094 * Creates an instance of ViewResources.
1095 * @param parent The parent resources. This resources can override them, but if a resource is not found, it will be looked up in the parent.
1096 * @param viewUrl The url of the view to which these resources apply.
1097 */
1098 constructor(parent?: ViewResources, viewUrl?: string);
1099
1100 /**
1101 * Registers view engine hooks for the view.
1102 * @param hooks The hooks to register.
1103 */
1104 registerViewEngineHooks(hooks: ViewEngineHooks): void;
1105
1106 /**
1107 * Gets the binding language associated with these resources, or return the provided fallback implementation.
1108 * @param bindingLanguageFallback The fallback binding language implementation to use if no binding language is configured locally.
1109 * @return The binding language.
1110 */
1111 getBindingLanguage(bindingLanguageFallback: BindingLanguage): BindingLanguage;
1112
1113 /**
1114 * Patches an immediate parent into the view resource resolution hierarchy.
1115 * @param newParent The new parent resources to patch in.
1116 */
1117 patchInParent(newParent: ViewResources): void;
1118
1119 /**
1120 * Maps a path relative to the associated view's origin.
1121 * @param path The relative path.
1122 * @return The calcualted path.
1123 */
1124 relativeToView(path: string): string;
1125
1126 /**
1127 * Registers an HTML element.
1128 * @param tagName The name of the custom element.
1129 * @param behavior The behavior of the element.
1130 */
1131 registerElement(tagName: string, behavior: HtmlBehaviorResource): void;
1132
1133 /**
1134 * Gets an HTML element behavior.
1135 * @param tagName The tag name to search for.
1136 * @return The HtmlBehaviorResource for the tag name or null.
1137 */
1138 getElement(tagName: string): HtmlBehaviorResource;
1139
1140 /**
1141 * Gets the known attribute name based on the local attribute name.
1142 * @param attribute The local attribute name to lookup.
1143 * @return The known name.
1144 */
1145 mapAttribute(attribute: string): string;
1146
1147 /**
1148 * Registers an HTML attribute.
1149 * @param attribute The name of the attribute.
1150 * @param behavior The behavior of the attribute.
1151 * @param knownAttribute The well-known name of the attribute (in lieu of the local name).
1152 */
1153 registerAttribute(attribute: string, behavior: HtmlBehaviorResource, knownAttribute: string): void;
1154
1155 /**
1156 * Gets an HTML attribute behavior.
1157 * @param attribute The name of the attribute to lookup.
1158 * @return The HtmlBehaviorResource for the attribute or null.
1159 */
1160 getAttribute(attribute: string): HtmlBehaviorResource;
1161
1162 /**
1163 * Registers a value converter.
1164 * @param name The name of the value converter.
1165 * @param valueConverter The value converter instance.
1166 */
1167 registerValueConverter(name: string, valueConverter: Object): void;
1168
1169 /**
1170 * Gets a value converter.
1171 * @param name The name of the value converter.
1172 * @return The value converter instance.
1173 */
1174 getValueConverter(name: string): Object;
1175
1176 /**
1177 * Registers a binding behavior.
1178 * @param name The name of the binding behavior.
1179 * @param bindingBehavior The binding behavior instance.
1180 */
1181 registerBindingBehavior(name: string, bindingBehavior: Object): void;
1182
1183 /**
1184 * Gets a binding behavior.
1185 * @param name The name of the binding behavior.
1186 * @return The binding behavior instance.
1187 */
1188 getBindingBehavior(name: string): Object;
1189
1190 /**
1191 * Registers a value.
1192 * @param name The name of the value.
1193 * @param value The value.
1194 */
1195 registerValue(name: string, value: any): void;
1196
1197 /**
1198 * Gets a value.
1199 * @param name The name of the value.
1200 * @return The value.
1201 */
1202 getValue(name: string): any;
1203
1204 /**
1205 * @internal
1206 * Not supported for public use. Can be changed without warning.
1207 *
1208 * Auto register a resources based on its metadata or convention
1209 * Will fallback to custom element if no metadata found and all conventions fail
1210 * @param {Container} container
1211 * @param {Function} impl
1212 * @returns {HtmlBehaviorResource | ValueConverterResource | BindingBehaviorResource | ViewEngineHooksResource}
1213 */
1214 autoRegister(container?: any, impl?: any): any;
1215}
1216export declare class View {
1217
1218 /**
1219 * The Dependency Injection Container that was used to create this View instance.
1220 */
1221 container: Container;
1222
1223 /**
1224 * The ViewFactory that built this View instance.
1225 */
1226 viewFactory: ViewFactory;
1227
1228 /**
1229 * Contains the DOM Nodes which represent this View. If the view was created via the "enhance" API, this will be an Element, otherwise it will be a DocumentFragment. If not created via "enhance" then the fragment will only contain nodes when the View is detached from the DOM.
1230 */
1231 fragment: DocumentFragment | Element;
1232
1233 /**
1234 * The primary binding context that this view is data-bound to.
1235 */
1236 bindingContext: Object;
1237
1238 /**
1239 * The override context which contains properties capable of overriding those found on the binding context.
1240 */
1241 overrideContext: Object;
1242
1243 /**
1244 * The Controller instance that owns this View.
1245 */
1246 controller: Controller;
1247
1248 /**
1249 * Creates a View instance.
1250 * @param container The container from which the view was created.
1251 * @param viewFactory The factory that created this view.
1252 * @param fragment The DOM fragement representing the view.
1253 * @param controllers The controllers inside this view.
1254 * @param bindings The bindings inside this view.
1255 * @param children The children of this view.
1256 */
1257 constructor(container: Container, viewFactory: ViewFactory, fragment: DocumentFragment, controllers: Controller[], bindings: Binding[], children: ViewNode[], slots: Object);
1258
1259 /**
1260 * Returns this view to the appropriate view cache.
1261 */
1262 returnToCache(): void;
1263
1264 /**
1265 * Triggers the created callback for this view and its children.
1266 */
1267 created(): void;
1268
1269 /**
1270 * Binds the view and it's children.
1271 * @param bindingContext The binding context to bind to.
1272 * @param overrideContext A secondary binding context that can override the standard context.
1273 */
1274 bind(bindingContext: Object, overrideContext?: Object, _systemUpdate?: boolean): void;
1275
1276 /**
1277 * Adds a binding instance to this view.
1278 * @param binding The binding instance.
1279 */
1280 addBinding(binding: Object): void;
1281
1282 /**
1283 * Unbinds the view and its children.
1284 */
1285 unbind(): void;
1286
1287 /**
1288 * Inserts this view's nodes before the specified DOM node.
1289 * @param refNode The node to insert this view's nodes before.
1290 */
1291 insertNodesBefore(refNode: Node): void;
1292
1293 /**
1294 * Appends this view's to the specified DOM node.
1295 * @param parent The parent element to append this view's nodes to.
1296 */
1297 appendNodesTo(parent: Element): void;
1298
1299 /**
1300 * Removes this view's nodes from the DOM.
1301 */
1302 removeNodes(): void;
1303
1304 /**
1305 * Triggers the attach for the view and its children.
1306 */
1307 attached(): void;
1308
1309 /**
1310 * Triggers the detach for the view and its children.
1311 */
1312 detached(): void;
1313}
1314
1315/**
1316* Represents a slot or location within the DOM to which views can be added and removed.
1317* Manages the view lifecycle for its children.
1318*/
1319export declare class ViewSlot {
1320
1321 /**
1322 * Creates an instance of ViewSlot.
1323 * @param anchor The DOM node which will server as the anchor or container for insertion.
1324 * @param anchorIsContainer Indicates whether the node is a container.
1325 * @param animator The animator that will controll enter/leave transitions for this slot.
1326 */
1327 constructor(anchor: Node, anchorIsContainer: boolean, animator?: Animator);
1328
1329 /**
1330 * Runs the animator against the first animatable element found within the view's fragment
1331 * @param view The view to use when searching for the element.
1332 * @param direction The animation direction enter|leave.
1333 * @returns An animation complete Promise or undefined if no animation was run.
1334 */
1335 animateView(view: View, direction?: string): void | Promise<any>;
1336
1337 /**
1338 * Takes the child nodes of an existing element that has been converted into a ViewSlot
1339 * and makes those nodes into a View within the slot.
1340 */
1341 transformChildNodesIntoView(): void;
1342
1343 /**
1344 * Binds the slot and it's children.
1345 * @param bindingContext The binding context to bind to.
1346 * @param overrideContext A secondary binding context that can override the standard context.
1347 */
1348 bind(bindingContext: Object, overrideContext: Object): void;
1349
1350 /**
1351 * Unbinds the slot and its children.
1352 */
1353 unbind(): void;
1354
1355 /**
1356 * Adds a view to the slot.
1357 * @param view The view to add.
1358 * @return May return a promise if the view addition triggered an animation.
1359 */
1360 add(view: View): void | Promise<any>;
1361
1362 /**
1363 * Inserts a view into the slot.
1364 * @param index The index to insert the view at.
1365 * @param view The view to insert.
1366 * @return May return a promise if the view insertion triggered an animation.
1367 */
1368 insert(index: number, view: View): void | Promise<any>;
1369
1370 /**
1371 * Moves a view across the slot.
1372 * @param sourceIndex The index the view is currently at.
1373 * @param targetIndex The index to insert the view at.
1374 */
1375 move(sourceIndex?: any, targetIndex?: any): any;
1376
1377 /**
1378 * Removes a view from the slot.
1379 * @param view The view to remove.
1380 * @param returnToCache Should the view be returned to the view cache?
1381 * @param skipAnimation Should the removal animation be skipped?
1382 * @return May return a promise if the view removal triggered an animation.
1383 */
1384 remove(view: View, returnToCache?: boolean, skipAnimation?: boolean): View | Promise<View>;
1385
1386 /**
1387 * Removes many views from the slot.
1388 * @param viewsToRemove The array of views to remove.
1389 * @param returnToCache Should the views be returned to the view cache?
1390 * @param skipAnimation Should the removal animation be skipped?
1391 * @return May return a promise if the view removal triggered an animation.
1392 */
1393 removeMany(viewsToRemove: View[], returnToCache?: boolean, skipAnimation?: boolean): void | Promise<void>;
1394
1395 /**
1396 * Removes a view an a specified index from the slot.
1397 * @param index The index to remove the view at.
1398 * @param returnToCache Should the view be returned to the view cache?
1399 * @param skipAnimation Should the removal animation be skipped?
1400 * @return May return a promise if the view removal triggered an animation.
1401 */
1402 removeAt(index: number, returnToCache?: boolean, skipAnimation?: boolean): View | Promise<View>;
1403
1404 /**
1405 * Removes all views from the slot.
1406 * @param returnToCache Should the view be returned to the view cache?
1407 * @param skipAnimation Should the removal animation be skipped?
1408 * @return May return a promise if the view removals triggered an animation.
1409 */
1410 removeAll(returnToCache?: boolean, skipAnimation?: boolean): void | Promise<any>;
1411
1412 /**
1413 * Triggers the attach for the slot and its children.
1414 */
1415 attached(): void;
1416
1417 /**
1418 * Triggers the detach for the slot and its children.
1419 */
1420 detached(): void;
1421 projectTo(slots: Object): void;
1422}
1423
1424/**
1425* A factory capable of creating View instances, bound to a location within another view hierarchy.
1426*/
1427export declare class BoundViewFactory {
1428
1429 /**
1430 * Creates an instance of BoundViewFactory.
1431 * @param parentContainer The parent DI container.
1432 * @param viewFactory The internal unbound factory.
1433 * @param partReplacements Part replacement overrides for the internal factory.
1434 */
1435 constructor(parentContainer: Container, viewFactory: ViewFactory, partReplacements?: Object);
1436
1437 /**
1438 * Creates a view or returns one from the internal cache, if available.
1439 * @return The created view.
1440 */
1441 create(): View;
1442
1443 /**
1444 * Indicates whether this factory is currently using caching.
1445 */
1446 isCaching: any;
1447
1448 /**
1449 * Sets the cache size for this factory.
1450 * @param size The number of views to cache or "*" to cache all.
1451 * @param doNotOverrideIfAlreadySet Indicates that setting the cache should not override the setting if previously set.
1452 */
1453 setCacheSize(size: number | string, doNotOverrideIfAlreadySet: boolean): void;
1454
1455 /**
1456 * Gets a cached view if available...
1457 * @return A cached view or null if one isn't available.
1458 */
1459 getCachedView(): View;
1460
1461 /**
1462 * Returns a view to the cache.
1463 * @param view The view to return to the cache if space is available.
1464 */
1465 returnViewToCache(view: View): void;
1466}
1467
1468/**
1469* A factory capable of creating View instances.
1470*/
1471export declare class ViewFactory {
1472
1473 /**
1474 * Indicates whether this factory is currently using caching.
1475 */
1476 isCaching: any;
1477
1478 /**
1479 * Creates an instance of ViewFactory.
1480 * @param template The document fragment that serves as a template for the view to be created.
1481 * @param instructions The instructions to be applied ot the template during the creation of a view.
1482 * @param resources The resources used to compile this factory.
1483 */
1484 constructor(template: DocumentFragment, instructions: Object, resources: ViewResources);
1485
1486 /**
1487 * Sets the cache size for this factory.
1488 * @param size The number of views to cache or "*" to cache all.
1489 * @param doNotOverrideIfAlreadySet Indicates that setting the cache should not override the setting if previously set.
1490 */
1491 setCacheSize(size: number | string, doNotOverrideIfAlreadySet: boolean): void;
1492
1493 /**
1494 * Gets a cached view if available...
1495 * @return A cached view or null if one isn't available.
1496 */
1497 getCachedView(): View;
1498
1499 /**
1500 * Returns a view to the cache.
1501 * @param view The view to return to the cache if space is available.
1502 */
1503 returnViewToCache(view: View): void;
1504
1505 /**
1506 * Creates a view or returns one from the internal cache, if available.
1507 * @param container The container to create the view from.
1508 * @param createInstruction The instruction used to customize view creation.
1509 * @param element The custom element that hosts the view.
1510 * @return The created view.
1511 */
1512 create(container: Container, createInstruction?: ViewCreateInstruction, element?: Element): View;
1513}
1514
1515/**
1516* Compiles html templates, dom fragments and strings into ViewFactory instances, capable of instantiating Views.
1517*/
1518export declare class ViewCompiler {
1519
1520 /**
1521 * Creates an instance of ViewCompiler.
1522 * @param bindingLanguage The default data binding language and syntax used during view compilation.
1523 * @param resources The global resources used during compilation when none are provided for compilation.
1524 */
1525 constructor(bindingLanguage: BindingLanguage, resources: ViewResources);
1526
1527 /**
1528 * Compiles an html template, dom fragment or string into ViewFactory instances, capable of instantiating Views.
1529 * @param source The template, fragment or string to compile.
1530 * @param resources The view resources used during compilation.
1531 * @param compileInstruction A set of instructions that customize how compilation occurs.
1532 * @return The compiled ViewFactory.
1533 */
1534 compile(source: Element | DocumentFragment | string, resources?: ViewResources, compileInstruction?: ViewCompileInstruction): ViewFactory;
1535}
1536
1537/**
1538* Represents a module with view resources.
1539*/
1540export declare class ResourceModule {
1541
1542 /**
1543 * Creates an instance of ResourceModule.
1544 * @param moduleId The id of the module that contains view resources.
1545 */
1546 constructor(moduleId: string);
1547
1548 /**
1549 * Initializes the resources within the module.
1550 * @param container The dependency injection container usable during resource initialization.
1551 */
1552 initialize(container: Container): void;
1553
1554 /**
1555 * Registers the resources in the module with the view resources.
1556 * @param registry The registry of view resources to regiser within.
1557 * @param name The name to use in registering the default resource.
1558 */
1559 register(registry: ViewResources, name?: string): void;
1560
1561 /**
1562 * Loads any dependencies of the resources within this module.
1563 * @param container The DI container to use during dependency resolution.
1564 * @param loadContext The loading context used for loading all resources and dependencies.
1565 * @return A promise that resolves when all loading is complete.
1566 */
1567 load(container: Container, loadContext?: ResourceLoadContext): Promise<void>;
1568}
1569
1570/**
1571* Represents a single view resource with a ResourceModule.
1572*/
1573export declare class ResourceDescription {
1574
1575 /**
1576 * Creates an instance of ResourceDescription.
1577 * @param key The key that the resource was exported as.
1578 * @param exportedValue The exported resource.
1579 * @param resourceTypeMeta The metadata located on the resource.
1580 */
1581 constructor(key: string, exportedValue: any, resourceTypeMeta?: Object);
1582
1583 /**
1584 * Initializes the resource.
1585 * @param container The dependency injection container usable during resource initialization.
1586 */
1587 initialize(container: Container): void;
1588
1589 /**
1590 * Registrers the resource with the view resources.
1591 * @param registry The registry of view resources to regiser within.
1592 * @param name The name to use in registering the resource.
1593 */
1594 register(registry: ViewResources, name?: string): void;
1595
1596 /**
1597 * Loads any dependencies of the resource.
1598 * @param container The DI container to use during dependency resolution.
1599 * @param loadContext The loading context used for loading all resources and dependencies.
1600 * @return A promise that resolves when all loading is complete.
1601 */
1602 load(container: Container, loadContext?: ResourceLoadContext): Promise<void> | void;
1603}
1604
1605/**
1606* Analyzes a module in order to discover the view resources that it exports.
1607*/
1608export declare class ModuleAnalyzer {
1609
1610 /**
1611 * Creates an instance of ModuleAnalyzer.
1612 */
1613 constructor();
1614
1615 /**
1616 * Retrieves the ResourceModule analysis for a previously analyzed module.
1617 * @param moduleId The id of the module to lookup.
1618 * @return The ResouceModule if found, undefined otherwise.
1619 */
1620 getAnalysis(moduleId: string): ResourceModule;
1621
1622 /**
1623 * Analyzes a module.
1624 * @param moduleId The id of the module to analyze.
1625 * @param moduleInstance The module instance to analyze.
1626 * @param mainResourceKey The name of the main resource.
1627 * @return The ResouceModule representing the analysis.
1628 */
1629 analyze(moduleId: string, moduleInstance: any, mainResourceKey?: string): ResourceModule;
1630}
1631
1632/**
1633* Controls the view resource loading pipeline.
1634*/
1635export declare class ViewEngine {
1636
1637 /**
1638 * The metadata key for storing requires declared in a ViewModel.
1639 */
1640 static viewModelRequireMetadataKey: any;
1641
1642 /**
1643 * Creates an instance of ViewEngine.
1644 * @param loader The module loader.
1645 * @param container The root DI container for the app.
1646 * @param viewCompiler The view compiler.
1647 * @param moduleAnalyzer The module analyzer.
1648 * @param appResources The app-level global resources.
1649 */
1650 constructor(loader: Loader, container: Container, viewCompiler: ViewCompiler, moduleAnalyzer: ModuleAnalyzer, appResources: ViewResources);
1651
1652 /**
1653 * Adds a resource plugin to the resource loading pipeline.
1654 * @param extension The file extension to match in require elements.
1655 * @param implementation The plugin implementation that handles the resource type.
1656 */
1657 addResourcePlugin(extension: string, implementation: Object): void;
1658
1659 /**
1660 * Loads and compiles a ViewFactory from a url or template registry entry.
1661 * @param urlOrRegistryEntry A url or template registry entry to generate the view factory for.
1662 * @param compileInstruction Instructions detailing how the factory should be compiled.
1663 * @param loadContext The load context if this factory load is happening within the context of a larger load operation.
1664 * @param target A class from which to extract metadata of additional resources to load.
1665 * @return A promise for the compiled view factory.
1666 */
1667 loadViewFactory(urlOrRegistryEntry: string | TemplateRegistryEntry, compileInstruction?: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewFactory>;
1668
1669 /**
1670 * Loads all the resources specified by the registry entry.
1671 * @param registryEntry The template registry entry to load the resources for.
1672 * @param compileInstruction The compile instruction associated with the load.
1673 * @param loadContext The load context if this is happening within the context of a larger load operation.
1674 * @param target A class from which to extract metadata of additional resources to load.
1675 * @return A promise of ViewResources for the registry entry.
1676 */
1677 loadTemplateResources(registryEntry: TemplateRegistryEntry, compileInstruction?: ViewCompileInstruction, loadContext?: ResourceLoadContext, target?: any): Promise<ViewResources>;
1678
1679 /**
1680 * Loads a view model as a resource.
1681 * @param moduleImport The module to import.
1682 * @param moduleMember The export from the module to generate the resource for.
1683 * @return A promise for the ResourceDescription.
1684 */
1685 importViewModelResource(moduleImport: string, moduleMember: string): Promise<ResourceDescription>;
1686
1687 /**
1688 * Imports the specified resources with the specified names into the view resources object.
1689 * @param moduleIds The modules to load.
1690 * @param names The names associated with resource modules to import.
1691 * @param resources The resources lookup to add the loaded resources to.
1692 * @param compileInstruction The compilation instruction associated with the resource imports.
1693 * @return A promise for the ViewResources.
1694 */
1695 importViewResources(moduleIds: string[], names: string[], resources: ViewResources, compileInstruction?: ViewCompileInstruction, loadContext?: ResourceLoadContext): Promise<ViewResources>;
1696}
1697
1698/**
1699* Controls a view model (and optionally its view), according to a particular behavior and by following a set of instructions.
1700*/
1701export declare class Controller {
1702
1703 /**
1704 * The HtmlBehaviorResource that provides the base behavior for this controller.
1705 */
1706 behavior: HtmlBehaviorResource;
1707
1708 /**
1709 * The developer's view model instance which provides the custom behavior for this controller.
1710 */
1711 viewModel: Object;
1712
1713 /**
1714 * The view associated with the component being controlled by this controller.
1715 * Note: Not all components will have a view, so the value may be null.
1716 */
1717 view: View;
1718
1719 /**
1720 * Creates an instance of Controller.
1721 * @param behavior The HtmlBehaviorResource that provides the base behavior for this controller.
1722 * @param instruction The instructions pertaining to the controller's behavior.
1723 * @param viewModel The developer's view model instance which provides the custom behavior for this controller.
1724 * @param container The container that the controller's view was created from.
1725 */
1726 constructor(behavior: HtmlBehaviorResource, instruction: BehaviorInstruction, viewModel: Object, container: Container);
1727
1728 /**
1729 * Invoked when the view which contains this controller is created.
1730 * @param owningView The view inside which this controller resides.
1731 */
1732 created(owningView: View): void;
1733
1734 /**
1735 * Used to automate the proper binding of this controller and its view. Used by the composition engine for dynamic component creation.
1736 * This should be considered a semi-private API and is subject to change without notice, even across minor or patch releases.
1737 * @param overrideContext An override context for binding.
1738 * @param owningView The view inside which this controller resides.
1739 */
1740 automate(overrideContext?: Object, owningView?: View): void;
1741
1742 /**
1743 * Binds the controller to the scope.
1744 * @param scope The binding scope.
1745 */
1746 bind(scope: Object): void;
1747
1748 /**
1749 * Unbinds the controller.
1750 */
1751 unbind(): void;
1752
1753 /**
1754 * Attaches the controller.
1755 */
1756 attached(): void;
1757
1758 /**
1759 * Detaches the controller.
1760 */
1761 detached(): void;
1762}
1763
1764/**
1765* An implementation of Aurelia's Observer interface that is used to back bindable properties defined on a behavior.
1766*/
1767export declare class BehaviorPropertyObserver {
1768
1769 /**
1770 * Creates an instance of BehaviorPropertyObserver.
1771 * @param taskQueue The task queue used to schedule change notifications.
1772 * @param obj The object that the property is defined on.
1773 * @param propertyName The name of the property.
1774 * @param selfSubscriber The callback function that notifies the object which defines the properties, if present.
1775 * @param initialValue The initial value of the property.
1776 */
1777 constructor(taskQueue: TaskQueue, obj: Object, propertyName: string, selfSubscriber: Function, initialValue: any);
1778
1779 /**
1780 * Gets the property's value.
1781 */
1782 getValue(): any;
1783
1784 /**
1785 * Sets the property's value.
1786 * @param newValue The new value to set.
1787 */
1788 setValue(newValue: any): void;
1789
1790 /**
1791 * Invoked by the TaskQueue to publish changes to subscribers.
1792 */
1793 call(): void;
1794
1795 /**
1796 * Subscribes to the observerable.
1797 * @param context A context object to pass along to the subscriber when it's called.
1798 * @param callable A function or object with a "call" method to be invoked for delivery of changes.
1799 */
1800 subscribe(context: any, callable: Function): void;
1801
1802 /**
1803 * Unsubscribes from the observerable.
1804 * @param context The context object originally subscribed with.
1805 * @param callable The callable that was originally subscribed with.
1806 */
1807 unsubscribe(context: any, callable: Function): void;
1808}
1809
1810/**
1811* Represents a bindable property on a behavior.
1812*/
1813export declare class BindableProperty {
1814
1815 /**
1816 * Creates an instance of BindableProperty.
1817 * @param nameOrConfig The name of the property or a cofiguration object.
1818 */
1819 constructor(nameOrConfig: string | Object);
1820
1821 /**
1822 * Registers this bindable property with particular Class and Behavior instance.
1823 * @param target The class to register this behavior with.
1824 * @param behavior The behavior instance to register this property with.
1825 * @param descriptor The property descriptor for this property.
1826 */
1827 registerWith(target: Function, behavior: HtmlBehaviorResource, descriptor?: Object): void;
1828
1829 /**
1830 * Defines this property on the specified class and behavior.
1831 * @param target The class to define the property on.
1832 * @param behavior The behavior to define the property on.
1833 */
1834 defineOn(target: Function, behavior: HtmlBehaviorResource): void;
1835
1836 /**
1837 * Creates an observer for this property.
1838 * @param viewModel The view model instance on which to create the observer.
1839 * @return The property observer.
1840 */
1841 createObserver(viewModel: Object): BehaviorPropertyObserver;
1842}
1843
1844/**
1845* Identifies a class as a resource that implements custom element or custom
1846* attribute functionality.
1847*/
1848export declare class HtmlBehaviorResource {
1849
1850 /**
1851 * Creates an instance of HtmlBehaviorResource.
1852 */
1853 constructor();
1854
1855 /**
1856 * Checks whether the provided name matches any naming conventions for HtmlBehaviorResource.
1857 * @param name The name of the potential resource.
1858 * @param existing An already existing resource that may need a convention name applied.
1859 */
1860 static convention(name: string, existing?: HtmlBehaviorResource): HtmlBehaviorResource;
1861
1862 /**
1863 * Adds a binding expression to the component created by this resource.
1864 * @param behavior The binding expression.
1865 */
1866 addChildBinding(behavior: Object): void;
1867
1868 /**
1869 * Provides an opportunity for the resource to initialize iteself.
1870 * @param container The dependency injection container from which the resource
1871 * can aquire needed services.
1872 * @param target The class to which this resource metadata is attached.
1873 */
1874 initialize(container: Container, target: Function): void;
1875
1876 /**
1877 * Allows the resource to be registered in the view resources for the particular
1878 * view into which it was required.
1879 * @param registry The view resource registry for the view that required this resource.
1880 * @param name The name provided by the end user for this resource, within the
1881 * particular view it's being used.
1882 */
1883 register(registry: ViewResources, name?: string): void;
1884
1885 /**
1886 * Enables the resource to asynchronously load additional resources.
1887 * @param container The dependency injection container from which the resource
1888 * can aquire needed services.
1889 * @param target The class to which this resource metadata is attached.
1890 * @param loadContext The loading context object provided by the view engine.
1891 * @param viewStrategy A view strategy to overload the default strategy defined by the resource.
1892 * @param transientView Indicated whether the view strategy is transient or
1893 * permanently tied to this component.
1894 */
1895 load(container: Container, target: Function, loadContext?: ResourceLoadContext, viewStrategy?: ViewStrategy, transientView?: boolean): Promise<HtmlBehaviorResource>;
1896
1897 /**
1898 * Plugs into the compiler and enables custom processing of the node on which this behavior is located.
1899 * @param compiler The compiler that is currently compiling the view that this behavior exists within.
1900 * @param resources The resources for the view that this behavior exists within.
1901 * @param node The node on which this behavior exists.
1902 * @param instruction The behavior instruction created for this behavior.
1903 * @param parentNode The parent node of the current node.
1904 * @return The current node.
1905 */
1906 compile(compiler: ViewCompiler, resources: ViewResources, node: Node, instruction: BehaviorInstruction, parentNode?: Node): Node;
1907
1908 /**
1909 * Creates an instance of this behavior.
1910 * @param container The DI container to create the instance in.
1911 * @param instruction The instruction for this behavior that was constructed during compilation.
1912 * @param element The element on which this behavior exists.
1913 * @param bindings The bindings that are associated with the view in which this behavior exists.
1914 * @return The Controller of this behavior.
1915 */
1916 create(container: Container, instruction?: BehaviorInstruction, element?: Element, bindings?: Binding[]): Controller;
1917}
1918
1919/**
1920* Creates a behavior property that references an array of immediate content child elements that matches the provided selector.
1921*/
1922export declare function children(selectorOrConfig: string | Object): any;
1923
1924/**
1925* Creates a behavior property that references an immediate content child element that matches the provided selector.
1926*/
1927export declare function child(selectorOrConfig: string | Object): any;
1928export declare const SwapStrategies: any;
1929
1930/**
1931* Used to dynamically compose components.
1932*/
1933export declare class CompositionEngine {
1934
1935 /**
1936 * Creates an instance of the CompositionEngine.
1937 * @param viewEngine The ViewEngine used during composition.
1938 */
1939 constructor(viewEngine: ViewEngine, viewLocator: ViewLocator);
1940
1941 /**
1942 * Creates a controller instance for the component described in the context.
1943 * @param context The CompositionContext that describes the component.
1944 * @return A Promise for the Controller.
1945 */
1946 createController(context: CompositionContext): Promise<Controller>;
1947
1948 /**
1949 * Ensures that the view model and its resource are loaded for this context.
1950 * @param context The CompositionContext to load the view model and its resource for.
1951 * @return A Promise for the context.
1952 */
1953 ensureViewModel(context: CompositionContext): Promise<CompositionContext>;
1954
1955 /**
1956 * Dynamically composes a component.
1957 * @param context The CompositionContext providing information on how the composition should occur.
1958 * @return A Promise for the View or the Controller that results from the dynamic composition.
1959 */
1960 compose(context: CompositionContext): Promise<View | Controller>;
1961}
1962
1963/**
1964* Identifies a class as a resource that configures the EventManager with information
1965* about how events relate to properties for the purpose of two-way data-binding
1966* to Web Components.
1967*/
1968export declare class ElementConfigResource {
1969
1970 /**
1971 * Provides an opportunity for the resource to initialize iteself.
1972 * @param container The dependency injection container from which the resource
1973 * can aquire needed services.
1974 * @param target The class to which this resource metadata is attached.
1975 */
1976 initialize(container: Container, target: Function): void;
1977
1978 /**
1979 * Allows the resource to be registered in the view resources for the particular
1980 * view into which it was required.
1981 * @param registry The view resource registry for the view that required this resource.
1982 * @param name The name provided by the end user for this resource, within the
1983 * particular view it's being used.
1984 */
1985 register(registry: ViewResources, name?: string): void;
1986
1987 /**
1988 * Enables the resource to asynchronously load additional resources.
1989 * @param container The dependency injection container from which the resource
1990 * can aquire needed services.
1991 * @param target The class to which this resource metadata is attached.
1992 */
1993 load(container: Container, target: Function): void;
1994}
1995
1996/**
1997* Decorator: Specifies a resource instance that describes the decorated class.
1998* @param instanceOrConfig The resource instance.
1999*/
2000export declare function resource(instanceOrConfig: string | object): any;
2001
2002/**
2003* Decorator: Specifies a custom HtmlBehaviorResource instance or an object that overrides various implementation details of the default HtmlBehaviorResource.
2004* @param override The customized HtmlBehaviorResource or an object to override the default with.
2005*/
2006export declare function behavior(override: HtmlBehaviorResource | Object): any;
2007
2008/**
2009* Decorator: Indicates that the decorated class is a custom element.
2010* @param name The name of the custom element.
2011*/
2012export declare function customElement(name: string): any;
2013
2014/**
2015* Decorator: Indicates that the decorated class is a custom attribute.
2016* @param name The name of the custom attribute.
2017* @param defaultBindingMode The default binding mode to use when the attribute is bound with .bind.
2018* @param aliases The array of aliases to associate to the custom attribute.
2019*/
2020export declare function customAttribute(name: string, defaultBindingMode?: number, aliases?: string[]): any;
2021
2022/**
2023* Decorator: Applied to custom attributes. Indicates that whatever element the
2024* attribute is placed on should be converted into a template and that this
2025* attribute controls the instantiation of the template.
2026*/
2027export declare function templateController(target?: any): any;
2028
2029/**
2030* Decorator: Specifies that a property is bindable through HTML.
2031* @param nameOrConfigOrTarget The name of the property, or a configuration object.
2032*/
2033export declare function bindable(nameOrConfigOrTarget?: string | Object, key?: any, descriptor?: any): any;
2034
2035/**
2036* Decorator: Specifies that the decorated custom attribute has options that
2037* are dynamic, based on their presence in HTML and not statically known.
2038*/
2039export declare function dynamicOptions(target?: any): any;
2040
2041/**
2042* Decorator: Indicates that the custom element should render its view in Shadow
2043* DOM. This decorator may change slightly when Aurelia updates to Shadow DOM v1.
2044*/
2045export declare function useShadowDOM(targetOrOptions?: any): any;
2046
2047/**
2048* Decorator: Enables custom processing of the attributes on an element before the framework inspects them.
2049* @param processor Pass a function which can provide custom processing of the content.
2050*/
2051export declare function processAttributes(processor: Function): any;
2052
2053/**
2054* Decorator: Enables custom processing of the content that is places inside the
2055* custom element by its consumer.
2056* @param processor Pass a boolean to direct the template compiler to not process
2057* the content placed inside this element. Alternatively, pass a function which
2058* can provide custom processing of the content. This function should then return
2059* a boolean indicating whether the compiler should also process the content.
2060*/
2061export declare function processContent(processor: boolean | Function): any;
2062
2063/**
2064* Decorator: Indicates that the custom element should be rendered without its
2065* element container.
2066*/
2067export declare function containerless(target?: any): any;
2068
2069/**
2070* Decorator: Associates a custom view strategy with the component.
2071* @param strategy The view strategy instance.
2072*/
2073export declare function useViewStrategy(strategy: Object): any;
2074
2075/**
2076* Decorator: Provides a relative path to a view for the component.
2077* @param path The path to the view.
2078*/
2079export declare function useView(path: string): any;
2080
2081/**
2082* Decorator: Provides a view template, directly inline, for the component. Be
2083* sure to wrap the markup in a template element.
2084* @param markup The markup for the view.
2085* @param dependencies A list of dependencies that the template has.
2086* @param dependencyBaseUrl A base url from which the dependencies will be loaded.
2087*/
2088export declare function inlineView(markup: string, dependencies?: Array<string | Function | Object>, dependencyBaseUrl?: string): any;
2089
2090/**
2091* Decorator: Indicates that the component has no view.
2092*/
2093export declare function noView(targetOrDependencies?: Function | Array<any>, dependencyBaseUrl?: string): any;
2094
2095/**
2096 * Decorator: Indicates that the element use static view
2097 */
2098/**
2099 * Decorator: Indicates that the element use static view
2100 */
2101export declare function view(templateOrConfig: string | HTMLTemplateElement | IStaticViewStrategyConfig): any;
2102
2103/**
2104* Decorator: Indicates that the decorated class provides element configuration
2105* to the EventManager for one or more Web Components.
2106*/
2107export declare function elementConfig(target?: any): any;
2108
2109/**
2110* Decorator: Provides the ability to add resources to the related View
2111* Same as: <require from="..."></require>
2112* @param resources Either: strings with moduleIds, Objects with 'src' and optionally 'as' properties or one of the classes of the module to be included.
2113*/
2114export declare function viewResources(...resources: any[]): any;
2115
2116/**
2117* A facade of the templating engine capabilties which provides a more user friendly API for common use cases.
2118*/
2119
2120/**
2121* A facade of the templating engine capabilties which provides a more user friendly API for common use cases.
2122*/
2123export declare class TemplatingEngine {
2124
2125 /**
2126 * Creates an instance of TemplatingEngine.
2127 * @param container The root DI container.
2128 * @param moduleAnalyzer The module analyzer for discovering view resources.
2129 * @param viewCompiler The view compiler for compiling views.
2130 * @param compositionEngine The composition engine used during dynamic component composition.
2131 */
2132 constructor(container: Container, moduleAnalyzer: ModuleAnalyzer, viewCompiler: ViewCompiler, compositionEngine: CompositionEngine);
2133
2134 /**
2135 * Configures the default animator.
2136 * @param animator The animator instance.
2137 */
2138 configureAnimator(animator: Animator): void;
2139
2140 /**
2141 * Dynamically composes components and views.
2142 * @param context The composition context to use.
2143 * @return A promise for the resulting Controller or View. Consumers of this API
2144 * are responsible for enforcing the Controller/View lifecycle.
2145 */
2146 compose(context: CompositionContext): Promise<View | Controller>;
2147
2148 /**
2149 * Enhances existing DOM with behaviors and bindings.
2150 * @param instruction The element to enhance or a set of instructions for the enhancement process.
2151 * @return A View representing the enhanced UI. Consumers of this API
2152 * are responsible for enforcing the View lifecycle.
2153 */
2154 enhance(instruction: Element | EnhanceInstruction): View;
2155}
\No newline at end of file