forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oclazyload.d.ts
149 lines (126 loc) · 5.56 KB
/
oclazyload.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Type definitions for oc.LazyLoad
// Project: https://github.com/ocombe/ocLazyLoad
// Definitions by: Roland Zwaga <https://github.com/rolandzwaga>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare namespace oc {
interface ILazyLoad {
/**
* Loads a module or a list of modules into Angular.
*
* @param module The name of a predefined module config object, or a module config object, or an array of either
* @param config Options to be used when loading the modules
*/
load(module: string|ITypedModuleConfig|IModuleConfig|(string|ITypedModuleConfig|IModuleConfig)[], config?: IOptionsConfig): ng.IPromise<any>;
/**
* Defines a module config object.
* @param config The module config object
* @returns The module config object that was passed in
*/
setModuleConfig(config: IModuleConfig): IModuleConfig;
/**
* Gets the specified module config object.
* @param name The name of the module config object to get
*/
getModuleConfig(name: string): IModuleConfig;
/**
* Gets the list of loaded module names.
*/
getModules(): string[];
/**
* Checks if a module name, or list of modules names, has been previously loaded into Angular.
*/
isLoaded(moduleName: string|string[]): boolean;
/**
* Injects a module with the associated name into Angular. Useful for manual injection when loading through RequireJS, SystemJS, etc. Useful in
* conjunction with the toggleWatch() method.
*/
inject(moduleName: string|string[]): ng.IPromise<any>;
/**
* Enables or disables watching Angular for new modules. Useful in conjunction with the inject() method. Make sure to not keep the watch enabled
* indefinitely, or unexpected results may occur.
*/
toggleWatch(watch: boolean): void;
}
interface ITypedModuleConfig extends IOptionsConfig {
/**
* The file extension, without the period. For example, 'html'.
*/
type: string;
/**
* The file path, including file name.
*/
path: string;
}
interface IModuleConfig extends IOptionsConfig {
/**
* The name of the module for easy retrieval later.
*/
name?: string;
/**
* The list of files to be loaded for this module.
*/
files: string[];
}
interface IOptionsConfig extends ng.IRequestShortcutConfig {
/**
* If true, bypasses browser cache by appending a timestamp to URLs. Defaults to true.
*/
cache?: boolean;
/**
* If true, a module config will be invoked each time the module is reloaded. Use with caution, as re-invoking configs can lead to unexpected results.
* Defaults to false.
*/
reconfig?: boolean;
/**
* If true, a module run block will be invoked each time the module is reloaded. Use with caution, as re-invoking run blocks can lead to unexpected results.
* Defaults to false.
*/
rerun?: boolean;
/**
* If true, will load files in a series, instead of in parallel. Defaults to false.
*/
serie?: boolean;
/**
* If set, will insert files immediately before the provided CSS selector, instead of the default behavior of inserting files immediately before the
* last child of the <head> element. Defaults to undefined.
*/
insertBefore?: string;
}
interface ILazyLoadProvider {
/**
* Configures the main service provider.
* @param config The configuration settings to use
*/
config(config: IProviderConfig): void;
}
interface IProviderConfig {
/**
* If true, all errors will be logged to the console, in addition to rejecting a promise. Defaults to false.
*/
debug?: boolean;
/**
* If true, an event will be broadcast whenever a module, component or file is loaded. Events that can be broadcast are: ocLazyLoad.moduleLoaded,
* ocLazyLoad.moduleReloaded, ocLazyLoad.componentLoaded, ocLazyLoad.fileLoaded. Defaults to false.
*/
events?: boolean;
/**
* Predefines a set of module configurations for later use. A name must be provided for each module so that it can be retrieved later.
*/
modules?: IModuleConfig[];
}
}
declare namespace angular {
interface IAngularStatic {
/**
* The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
*
* When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved.
*
* @param name The name of the module to create or retrieve.
* @param requires The names of modules this module depends on, and/or ocLazyLoad module configurations. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
* @param configFn Optional configuration function for the module.
*/
module(name: string, requires?: (string|oc.IModuleConfig)[], configFn?: Function): IModule;
}
}