diff options
author | Jose Antonio Marquez | 2012-02-16 11:30:33 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-16 11:30:33 -0800 |
commit | 9fe5d98bf469036c856e28d71ad4160d630b4af4 (patch) | |
tree | 930a334bcda0c26ca02eaa33a1506d147e8691e1 /node_modules/montage/require | |
parent | 89b5e793ea88ef235b54b6e1d1c379698d3e612b (diff) | |
parent | 71619045b692015b0889a4f5c381c1dee9c056cd (diff) | |
download | ninja-9fe5d98bf469036c856e28d71ad4160d630b4af4.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
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"); |