diff options
author | Valerio Virgillito | 2012-02-16 10:54:48 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-16 10:54:48 -0800 |
commit | d52aca45e0357b5597e13d9b74998abb75fabea5 (patch) | |
tree | ffd4a0c060b00611953b7e3ed0b3955bf02ac6e7 /node_modules/montage/require | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-d52aca45e0357b5597e13d9b74998abb75fabea5.tar.gz |
integrating the latest montage fixes for v0.6 into master
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/require')
-rwxr-xr-x | node_modules/montage/require/browser.js | 28 | ||||
-rw-r--r-- | node_modules/montage/require/node.js | 5 |
2 files changed, 23 insertions, 10 deletions
diff --git a/node_modules/montage/require/browser.js b/node_modules/montage/require/browser.js index e249d355..3fdd58d4 100755 --- a/node_modules/montage/require/browser.js +++ b/node_modules/montage/require/browser.js | |||
@@ -5,11 +5,13 @@ | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | bootstrap("require/browser", function (require) { | 6 | bootstrap("require/browser", function (require) { |
7 | 7 | ||
8 | var Require = require("require/require"); | 8 | var Require = require("require/require"), |
9 | var Promise = require("core/promise").Promise; | 9 | Promise = require("core/promise").Promise, |
10 | var URL = require("core/mini-url"); | 10 | URL = require("core/mini-url"), |
11 | 11 | GET = "GET", | |
12 | var global = typeof global !== "undefined" ? global : window; | 12 | APPLICATION_JAVASCRIPT_MIMETYPE = "application/javascript", |
13 | FILE_PROTOCOL = "file:", | ||
14 | global = typeof global !== "undefined" ? global : window; | ||
13 | 15 | ||
14 | Require.getLocation = function() { | 16 | Require.getLocation = function() { |
15 | return URL.resolve(window.location, "."); | 17 | return URL.resolve(window.location, "."); |
@@ -24,7 +26,7 @@ Require.overlays = ["browser", "montage"]; | |||
24 | // http://dl.dropbox.com/u/131998/yui/misc/get/browser-capabilities.html | 26 | // http://dl.dropbox.com/u/131998/yui/misc/get/browser-capabilities.html |
25 | Require.read = function (url) { | 27 | Require.read = function (url) { |
26 | 28 | ||
27 | if (URL.resolve(window.location, url).indexOf("file:") === 0) { | 29 | if (URL.resolve(window.location, url).indexOf(FILE_PROTOCOL) === 0) { |
28 | throw new Error("XHR does not function for file: protocol"); | 30 | throw new Error("XHR does not function for file: protocol"); |
29 | } | 31 | } |
30 | 32 | ||
@@ -44,8 +46,8 @@ Require.read = function (url) { | |||
44 | } | 46 | } |
45 | 47 | ||
46 | try { | 48 | try { |
47 | request.open("GET", url, true); | 49 | request.open(GET, url, true); |
48 | request.overrideMimeType("application/javascript"); | 50 | request.overrideMimeType(APPLICATION_JAVASCRIPT_MIMETYPE); |
49 | request.onreadystatechange = function () { | 51 | request.onreadystatechange = function () { |
50 | if (request.readyState === 4) { | 52 | if (request.readyState === 4) { |
51 | onload(); | 53 | onload(); |
@@ -77,6 +79,12 @@ if (global.navigator && global.navigator.userAgent.indexOf("Firefox") >= 0) { | |||
77 | globalEval = new Function("evalString", "return eval(evalString)"); | 79 | globalEval = new Function("evalString", "return eval(evalString)"); |
78 | } | 80 | } |
79 | 81 | ||
82 | var __FILE__String = "__FILE__", | ||
83 | DoubleUnderscoreString = "__" | ||
84 | globalEvalConstantA = "(function ", | ||
85 | globalEvalConstantB = "(require, exports, module) {", | ||
86 | globalEvalConstantC = "//*/\n})\n//@ sourceURL="; | ||
87 | |||
80 | Require.Compiler = function (config) { | 88 | Require.Compiler = function (config) { |
81 | return function(module) { | 89 | return function(module) { |
82 | if (module.factory || module.text === void 0) | 90 | if (module.factory || module.text === void 0) |
@@ -91,10 +99,10 @@ Require.Compiler = function (config) { | |||
91 | // TODO: investigate why this isn't working in Firebug. | 99 | // TODO: investigate why this isn't working in Firebug. |
92 | // 3. set displayName property on the factory function (Safari, Chrome) | 100 | // 3. set displayName property on the factory function (Safari, Chrome) |
93 | 101 | ||
94 | var displayName = "__FILE__"+module.location.replace(/\.\w+$|\W/g, "__"); | 102 | var displayName = __FILE__String+module.location.replace(/\.\w+$|\W/g, DoubleUnderscoreString); |
95 | 103 | ||
96 | try { | 104 | try { |
97 | module.factory = globalEval("(function "+displayName+"(require, exports, module) {"+module.text+"//*/\n})"+"\n//@ sourceURL="+module.location); | 105 | module.factory = globalEval(globalEvalConstantA+displayName+globalEvalConstantB+module.text+globalEvalConstantC+module.location); |
98 | } catch (exception) { | 106 | } catch (exception) { |
99 | throw new SyntaxError("in " + module.location + ": " + exception.message); | 107 | throw new SyntaxError("in " + module.location + ": " + exception.message); |
100 | } | 108 | } |
diff --git a/node_modules/montage/require/node.js b/node_modules/montage/require/node.js index 568410cf..9fcea3f5 100644 --- a/node_modules/montage/require/node.js +++ b/node_modules/montage/require/node.js | |||
@@ -1,3 +1,8 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
1 | 6 | ||
2 | var Require = require("./require"); | 7 | var Require = require("./require"); |
3 | var URL = require("../core/url"); | 8 | var URL = require("../core/url"); |