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 | declare module "module" {
|
28 | var mod: {
|
29 | config: () => any;
|
30 | id: string;
|
31 | uri: string;
|
32 | };
|
33 | export = mod;
|
34 | }
|
35 |
|
36 | interface RequireError extends Error {
|
37 | |
38 |
|
39 |
|
40 | requireType: string;
|
41 |
|
42 | |
43 |
|
44 |
|
45 | requireModules: string[] | null;
|
46 |
|
47 | |
48 |
|
49 |
|
50 | originalError: Error;
|
51 | }
|
52 |
|
53 | interface RequireShim {
|
54 | |
55 |
|
56 |
|
57 | deps?: string[] | undefined;
|
58 |
|
59 | |
60 |
|
61 |
|
62 | exports?: string | undefined;
|
63 |
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | init?: ((...dependencies: any[]) => any) | undefined;
|
73 | }
|
74 |
|
75 | interface RequireConfig {
|
76 | /**
|
77 | * The root path to use for all module lookups.
|
78 | */
|
79 | baseUrl?: string | undefined;
|
80 |
|
81 | /**
|
82 | * Path mappings for module names not found directly under
|
83 | * baseUrl.
|
84 | */
|
85 | paths?: { [key: string]: any } | undefined;
|
86 |
|
87 | /**
|
88 | * Dictionary of Shim's.
|
89 | * Can be of type RequireShim or string[] of dependencies
|
90 | */
|
91 | shim?: { [key: string]: RequireShim | string[] } | undefined;
|
92 |
|
93 | /**
|
94 | * For the given module prefix, instead of loading the
|
95 | * module with the given ID, substitude a different
|
96 | * module ID.
|
97 | *
|
98 | * @example
|
99 | * requirejs.config({
|
100 | * map: {
|
101 | * 'some/newmodule': {
|
102 | * 'foo': 'foo1.2'
|
103 | * },
|
104 | * 'some/oldmodule': {
|
105 | * 'foo': 'foo1.0'
|
106 | * }
|
107 | * }
|
108 | * });
|
109 | */
|
110 | map?: {
|
111 | [id: string]: {
|
112 | [id: string]: string;
|
113 | };
|
114 | } | undefined;
|
115 |
|
116 | /**
|
117 | * Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
|
118 | *
|
119 | * @example
|
120 | * requirejs.config({
|
121 | * bundles: {
|
122 | * 'primary': ['main', 'util', 'text', 'text!template.html'],
|
123 | * 'secondary': ['text!secondary.html']
|
124 | * }
|
125 | * });
|
126 | */
|
127 | bundles?: { [key: string]: string[] } | undefined;
|
128 |
|
129 | /**
|
130 | * AMD configurations, use module.config() to access in
|
131 | * define() functions
|
132 | */
|
133 | config?: { [id: string]: {} } | undefined;
|
134 |
|
135 | /**
|
136 | * Configures loading modules from CommonJS packages.
|
137 | */
|
138 | packages?: {} | undefined;
|
139 |
|
140 | /**
|
141 | * The number of seconds to wait before giving up on loading
|
142 | * a script. The default is 7 seconds.
|
143 | */
|
144 | waitSeconds?: number | undefined;
|
145 |
|
146 | /**
|
147 | * A name to give to a loading context. This allows require.js
|
148 | * to load multiple versions of modules in a page, as long as
|
149 | * each top-level require call specifies a unique context string.
|
150 | */
|
151 | context?: string | undefined;
|
152 |
|
153 | /**
|
154 | * An array of dependencies to load.
|
155 | */
|
156 | deps?: string[] | undefined;
|
157 |
|
158 | /**
|
159 | * A function to pass to require that should be require after
|
160 | * deps have been loaded.
|
161 | * @param modules
|
162 | */
|
163 | callback?: ((...modules: any[]) => void) | undefined;
|
164 |
|
165 | /**
|
166 | * If set to true, an error will be thrown if a script loads
|
167 | * that does not call define() or have shim exports string
|
168 | * value that can be checked.
|
169 | */
|
170 | enforceDefine?: boolean | undefined;
|
171 |
|
172 | /**
|
173 | * If set to true, document.createElementNS() will be used
|
174 | * to create script elements.
|
175 | */
|
176 | xhtml?: boolean | undefined;
|
177 |
|
178 | /**
|
179 | * Extra query string arguments appended to URLs that RequireJS
|
180 | * uses to fetch resources. Most useful to cache bust when
|
181 | * the browser or server is not configured correctly.
|
182 | *
|
183 | * As of RequireJS 2.2.0, urlArgs can be a function. If a
|
184 | * function, it will receive the module ID and the URL as
|
185 | * parameters, and it should return a string that will be added
|
186 | * to the end of the URL. Return an empty string if no args.
|
187 | * Be sure to take care of adding the '?' or '&' depending on
|
188 | * the existing state of the URL.
|
189 | *
|
190 | * @example
|
191 | *
|
192 | * urlArgs: "bust=" + (new Date()).getTime()
|
193 | *
|
194 | * @example
|
195 | *
|
196 | * requirejs.config({
|
197 | * urlArgs: function(id, url) {
|
198 | * var args = 'v=1';
|
199 | * if (url.indexOf('view.html') !== -1) {
|
200 | * args = 'v=2'
|
201 | * }
|
202 | *
|
203 | * return (url.indexOf('?') === -1 ? '?' : '&') + args;
|
204 | * }
|
205 | * });
|
206 | */
|
207 | urlArgs?: string | ((id: string, url: string) => string) | undefined;
|
208 |
|
209 | /**
|
210 | * Specify the value for the type="" attribute used for script
|
211 | * tags inserted into the document by RequireJS. Default is
|
212 | * "text/javascript". To use Firefox's JavasScript 1.8
|
213 | * features, use "text/javascript;version=1.8".
|
214 | */
|
215 | scriptType?: string | undefined;
|
216 |
|
217 | /**
|
218 | * If set to true, skips the data-main attribute scanning done
|
219 | * to start module loading. Useful if RequireJS is embedded in
|
220 | * a utility library that may interact with other RequireJS
|
221 | * library on the page, and the embedded version should not do
|
222 | * data-main loading.
|
223 | */
|
224 | skipDataMain?: boolean | undefined;
|
225 |
|
226 | /**
|
227 | * Allow extending requirejs to support Subresource Integrity
|
228 | * (SRI).
|
229 | */
|
230 | onNodeCreated?:
|
231 | | ((node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void)
|
232 | | undefined;
|
233 | }
|
234 |
|
235 | // todo: not sure what to do with this guy
|
236 | interface RequireModule {
|
237 | /** */
|
238 | config(): {};
|
239 | }
|
240 |
|
241 | /** */
|
242 | interface RequireMap {
|
243 | /** */
|
244 | prefix: string;
|
245 |
|
246 | /** */
|
247 | name: string;
|
248 |
|
249 | /** */
|
250 | parentMap: RequireMap;
|
251 |
|
252 | /** */
|
253 | url: string;
|
254 |
|
255 | /** */
|
256 | originalName: string;
|
257 |
|
258 | /** */
|
259 | fullName: string;
|
260 | }
|
261 |
|
262 | interface Require {
|
263 | /**
|
264 | * Configure require.js
|
265 | */
|
266 | config(config: RequireConfig): Require;
|
267 |
|
268 | /**
|
269 | * CommonJS require call
|
270 | * @param module Module to load
|
271 | * @return The loaded module
|
272 | */
|
273 | (module: string): any;
|
274 |
|
275 | /**
|
276 | * Start the main app logic.
|
277 | * Callback is optional.
|
278 | * Can alternatively use deps and callback.
|
279 | * @param modules Required modules to load.
|
280 | */
|
281 | (modules: string[]): void;
|
282 |
|
283 | /**
|
284 | * @see Require()
|
285 | * @param ready Called when required modules are ready.
|
286 | */
|
287 | (modules: string[], ready: Function): void;
|
288 |
|
289 | /**
|
290 | * @see http://requirejs.org/docs/api.html#errbacks
|
291 | * @param ready Called when required modules are ready.
|
292 | */
|
293 | (modules: string[], ready: Function, errback: Function): void;
|
294 |
|
295 | /**
|
296 | * Generate URLs from require module
|
297 | * @param module Module to URL
|
298 | * @return URL string
|
299 | */
|
300 | toUrl(module: string): string;
|
301 |
|
302 | /**
|
303 | * Returns true if the module has already been loaded and defined.
|
304 | * @param module Module to check
|
305 | */
|
306 | defined(module: string): boolean;
|
307 |
|
308 | /**
|
309 | * Returns true if the module has already been requested or is in the process of loading and should be available at some point.
|
310 | * @param module Module to check
|
311 | */
|
312 | specified(module: string): boolean;
|
313 |
|
314 | /**
|
315 | * On Error override
|
316 | * @param err
|
317 | */
|
318 | onError(err: RequireError, errback?: (err: RequireError) => void): void;
|
319 |
|
320 | /**
|
321 | * Undefine a module
|
322 | * @param module Module to undefine.
|
323 | */
|
324 | undef(module: string): void;
|
325 |
|
326 | /**
|
327 | * Semi-private function, overload in special instance of undef()
|
328 | */
|
329 | onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
|
330 | }
|
331 |
|
332 | interface RequireDefine {
|
333 | /**
|
334 | * Define Simple Name/Value Pairs
|
335 | * @param config Dictionary of Named/Value pairs for the config.
|
336 | */
|
337 | (config: { [key: string]: any }): void;
|
338 |
|
339 | /**
|
340 | * Define function.
|
341 | * @param func: The function module.
|
342 | */
|
343 | (func: () => any): void;
|
344 |
|
345 | /**
|
346 | * Define function with dependencies.
|
347 | * @param deps List of dependencies module IDs.
|
348 | * @param ready Callback function when the dependencies are loaded.
|
349 | * callback param deps module dependencies
|
350 | * callback return module definition
|
351 | */
|
352 | (deps: string[], ready: Function): void;
|
353 |
|
354 | /**
|
355 | * Define module with simplified CommonJS wrapper.
|
356 | * @param ready
|
357 | * callback require requirejs instance
|
358 | * callback exports exports object
|
359 | * callback module module
|
360 | * callback return module definition
|
361 | */
|
362 | (ready: (require: Require, exports: { [key: string]: any }, module: RequireModule) => any): void;
|
363 |
|
364 | /**
|
365 | * Define a module with a name and dependencies.
|
366 | * @param name The name of the module.
|
367 | * @param deps List of dependencies module IDs.
|
368 | * @param ready Callback function when the dependencies are loaded.
|
369 | * callback deps module dependencies
|
370 | * callback return module definition
|
371 | */
|
372 | (name: string, deps: string[], ready: Function): void;
|
373 |
|
374 | /**
|
375 | * Define a module with a name.
|
376 | * @param name The name of the module.
|
377 | * @param ready Callback function when the dependencies are loaded.
|
378 | * callback return module definition
|
379 | */
|
380 | (name: string, ready: Function): void;
|
381 |
|
382 | /**
|
383 | * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms
|
384 | * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.
|
385 | * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function
|
386 | * that does not conform to the AMD API.
|
387 | * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version
|
388 | * of jQuery being loaded simultaneously.
|
389 | */
|
390 | amd: Object;
|
391 | }
|
392 |
|
393 | // Ambient declarations for 'require' and 'define'
|
394 | declare var requirejs: Require;
|
395 | declare var require: Require;
|
396 | declare var define: RequireDefine;
|
397 |
|
\ | No newline at end of file |