|
Lines 1830-1835
Link Here
|
| 1830 |
return node; |
1830 |
return node; |
| 1831 |
}; |
1831 |
}; |
| 1832 |
|
1832 |
|
|
|
1833 |
function _asBlobURL(url, cb) { |
| 1834 |
var xhr = new XMLHttpRequest(); |
| 1835 |
xhr.open('GET', url, true); |
| 1836 |
xhr.responseType = 'blob'; |
| 1837 |
|
| 1838 |
xhr.onload = function(e) { |
| 1839 |
if (this.status == 200) { |
| 1840 |
// Note: .response instead of .responseText |
| 1841 |
var blob = new Blob([this.response], {type: 'text/javascript'}); |
| 1842 |
var blobURL = URL.createObjectURL(blob); |
| 1843 |
cb(blobURL); |
| 1844 |
URL.revokeObjectURL(blobURL); |
| 1845 |
} |
| 1846 |
}; |
| 1847 |
xhr.send(); |
| 1848 |
} |
| 1849 |
|
| 1850 |
|
| 1833 |
/** |
1851 |
/** |
| 1834 |
* Does the request to load a module for the browser case. |
1852 |
* Does the request to load a module for the browser case. |
| 1835 |
* Make this a separate function to allow other environments |
1853 |
* Make this a separate function to allow other environments |
|
Lines 1906-1929
Link Here
|
| 1906 |
|
1924 |
|
| 1907 |
return node; |
1925 |
return node; |
| 1908 |
} else if (isWebWorker) { |
1926 |
} else if (isWebWorker) { |
| 1909 |
try { |
1927 |
_asBlobURL(url, function(url) { |
| 1910 |
//In a web worker, use importScripts. This is not a very |
1928 |
try { |
| 1911 |
//efficient use of importScripts, importScripts will block until |
1929 |
//In a web worker, use importScripts. This is not a very |
| 1912 |
//its script is downloaded and evaluated. However, if web workers |
1930 |
//efficient use of importScripts, importScripts will block until |
| 1913 |
//are in play, the expectation that a build has been done so that |
1931 |
//its script is downloaded and evaluated. However, if web workers |
| 1914 |
//only one script needs to be loaded anyway. This may need to be |
1932 |
//are in play, the expectation that a build has been done so that |
| 1915 |
//reevaluated if other use cases become common. |
1933 |
//only one script needs to be loaded anyway. This may need to be |
| 1916 |
importScripts(url); |
1934 |
//reevaluated if other use cases become common. |
| 1917 |
|
1935 |
importScripts(url); |
| 1918 |
//Account for anonymous modules |
1936 |
|
| 1919 |
context.completeLoad(moduleName); |
1937 |
//Account for anonymous modules |
| 1920 |
} catch (e) { |
1938 |
context.completeLoad(moduleName); |
| 1921 |
context.onError(makeError('importscripts', |
1939 |
|
| 1922 |
'importScripts failed for ' + |
1940 |
} catch (e) { |
| 1923 |
moduleName + ' at ' + url, |
1941 |
context.onError(makeError('importscripts', |
| 1924 |
e, |
1942 |
'importScripts failed for ' + |
| 1925 |
[moduleName])); |
1943 |
moduleName + ' at ' + url, |
| 1926 |
} |
1944 |
e, |
|
|
1945 |
[moduleName])); |
| 1946 |
} |
| 1947 |
}); |
| 1927 |
} |
1948 |
} |
| 1928 |
}; |
1949 |
}; |
| 1929 |
|
1950 |
|