1
+ /// <reference path="require.js" />
2
+
3
+ ! function ( window ) {
4
+ var defines = [ ] ,
5
+ moduleUrls = [ ] ,
6
+ oldDefine = window . define ,
7
+ oldRequire = window . require ,
8
+ oldLoad = requirejs . load ;
9
+
10
+ var loadEvent = document . createEvent ( "event" ) ;
11
+ loadEvent . type = "load" ;
12
+
13
+ // Ensure that we're only patching require/define
14
+ // if RequireJS is the current AMD implementation
15
+ if ( window . require !== window . requirejs )
16
+ return ;
17
+
18
+ intellisense . annotate ( window , {
19
+ define : function ( ) {
20
+ /// <signature>
21
+ /// <summary>Defines a named module, with optional dependencies, whose value is determined by executing a callback.</summary>
22
+ /// <param name="name" type="String">The name of the module</param>
23
+ /// <param name="deps" type="Array" elementType="String" optional="true">An array of modules that this module depends on</param>
24
+ /// <param name="callback" type="Function">The callback that will be called when your module is asked to produce a value</param>
25
+ /// </signature>
26
+ /// <signature>
27
+ /// <summary>Defines an anonymous module, with no dependencies, whose value is determined by executing a callback.</summary>
28
+ /// <param name="callback" type="Function">The callback that will be called when your module is asked to produce a value</param>
29
+ /// </signature>
30
+ /// <signature>
31
+ /// <summary>Defines an anonymous module, with no dependencies, whose value is an object literal.</summary>
32
+ /// <param name="value" type="Object">The object literal that represents the value of this module</param>
33
+ /// </signature>
34
+ } ,
35
+ require : function ( ) {
36
+ /// <signature>
37
+ /// <summary>Defines a callback function that will be triggered after a set of dependency modules have been evaluated</summary>
38
+ /// <param name="deps" type="Array" elementType="String"></param>
39
+ /// <param name="callback" type="Function"></param>
40
+ /// </signature>
41
+ }
42
+ } ) ;
43
+
44
+ requirejs . load = function ( context , moduleName , url ) {
45
+ moduleUrls . push ( url ) ;
46
+ oldLoad . call ( requirejs , context , moduleName , url ) ;
47
+ }
48
+
49
+ window . define = function ( name , deps , callback ) {
50
+ defines . push ( [ deps , callback ] ) ;
51
+ }
52
+
53
+ window . define . amd = {
54
+ multiversion : true ,
55
+ plugins : true ,
56
+ jQuery : true
57
+ } ;
58
+
59
+ window . require = function ( deps , callback ) {
60
+ setTimeout ( function ( ) {
61
+ // #1. Call the original require
62
+ oldRequire . call ( window , deps , callback ) ;
63
+
64
+ defines . forEach ( function ( define , index ) {
65
+ oldDefine . apply ( window , define ) ;
66
+
67
+ var scriptElements = document . getElementsByTagName ( "script" ) ;
68
+
69
+ for ( var i = 0 ; i < scriptElements . length ; i ++ ) {
70
+ var script = scriptElements [ i ] ;
71
+ if ( script . src == moduleUrls [ index ] ) {
72
+ loadEvent . currentTarget = script ;
73
+ requirejs . onScriptLoad ( loadEvent ) ;
74
+ }
75
+ }
76
+ } ) ;
77
+ } , 0 ) ;
78
+ }
79
+
80
+ // Redirect all of the patched methods back to their originals
81
+ intellisense . redirectDefinition ( requirejs . load , oldLoad ) ;
82
+ intellisense . redirectDefinition ( window . define , oldDefine ) ;
83
+ intellisense . redirectDefinition ( window . require , oldRequire ) ;
84
+ } ( this ) ;
0 commit comments