From d52aca45e0357b5597e13d9b74998abb75fabea5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 16 Feb 2012 10:54:48 -0800 Subject: integrating the latest montage fixes for v0.6 into master Signed-off-by: Valerio Virgillito --- node_modules/montage/require/browser.js | 28 ++++++++++++++++++---------- node_modules/montage/require/node.js | 5 +++++ 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'node_modules/montage/require') 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 @@ */ bootstrap("require/browser", function (require) { -var Require = require("require/require"); -var Promise = require("core/promise").Promise; -var URL = require("core/mini-url"); - -var global = typeof global !== "undefined" ? global : window; +var Require = require("require/require"), + Promise = require("core/promise").Promise, + URL = require("core/mini-url"), + GET = "GET", + APPLICATION_JAVASCRIPT_MIMETYPE = "application/javascript", + FILE_PROTOCOL = "file:", + global = typeof global !== "undefined" ? global : window; Require.getLocation = function() { return URL.resolve(window.location, "."); @@ -24,7 +26,7 @@ Require.overlays = ["browser", "montage"]; // http://dl.dropbox.com/u/131998/yui/misc/get/browser-capabilities.html Require.read = function (url) { - if (URL.resolve(window.location, url).indexOf("file:") === 0) { + if (URL.resolve(window.location, url).indexOf(FILE_PROTOCOL) === 0) { throw new Error("XHR does not function for file: protocol"); } @@ -44,8 +46,8 @@ Require.read = function (url) { } try { - request.open("GET", url, true); - request.overrideMimeType("application/javascript"); + request.open(GET, url, true); + request.overrideMimeType(APPLICATION_JAVASCRIPT_MIMETYPE); request.onreadystatechange = function () { if (request.readyState === 4) { onload(); @@ -77,6 +79,12 @@ if (global.navigator && global.navigator.userAgent.indexOf("Firefox") >= 0) { globalEval = new Function("evalString", "return eval(evalString)"); } +var __FILE__String = "__FILE__", + DoubleUnderscoreString = "__" + globalEvalConstantA = "(function ", + globalEvalConstantB = "(require, exports, module) {", + globalEvalConstantC = "//*/\n})\n//@ sourceURL="; + Require.Compiler = function (config) { return function(module) { if (module.factory || module.text === void 0) @@ -91,10 +99,10 @@ Require.Compiler = function (config) { // TODO: investigate why this isn't working in Firebug. // 3. set displayName property on the factory function (Safari, Chrome) - var displayName = "__FILE__"+module.location.replace(/\.\w+$|\W/g, "__"); + var displayName = __FILE__String+module.location.replace(/\.\w+$|\W/g, DoubleUnderscoreString); try { - module.factory = globalEval("(function "+displayName+"(require, exports, module) {"+module.text+"//*/\n})"+"\n//@ sourceURL="+module.location); + module.factory = globalEval(globalEvalConstantA+displayName+globalEvalConstantB+module.text+globalEvalConstantC+module.location); } catch (exception) { throw new SyntaxError("in " + module.location + ": " + exception.message); } 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 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ var Require = require("./require"); var URL = require("../core/url"); -- cgit v1.2.3