diff options
author | Valerio Virgillito | 2012-06-17 22:31:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-17 22:31:44 -0700 |
commit | 8fe92b94ce5e1e2857d088752d94e19db7e3d8a8 (patch) | |
tree | d84807aae0b974b5200050972dd94da6066e363b /node_modules/montage/require/require.js | |
parent | e570fc8518cf03dd03c15982edcf17c5ba0a293d (diff) | |
download | ninja-8fe92b94ce5e1e2857d088752d94e19db7e3d8a8.tar.gz |
montage v11 merge into ninja
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/require/require.js')
-rwxr-xr-x | node_modules/montage/require/require.js | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/node_modules/montage/require/require.js b/node_modules/montage/require/require.js index eaa2d9fc..36372053 100755 --- a/node_modules/montage/require/require.js +++ b/node_modules/montage/require/require.js | |||
@@ -8,12 +8,24 @@ | |||
8 | 8 | ||
9 | // Boostrapping Browser | 9 | // Boostrapping Browser |
10 | if (typeof bootstrap !== "undefined") { | 10 | if (typeof bootstrap !== "undefined") { |
11 | bootstrap("require/require", function (require, exports) { | 11 | |
12 | var Promise = require("core/promise").Promise; | 12 | // Window |
13 | var URL = require("core/mini-url"); | 13 | if (typeof window !== "undefined") { |
14 | definition(exports, Promise, URL); | 14 | bootstrap("require/require", function (require, exports) { |
15 | require("require/browser"); | 15 | var Promise = require("core/promise").Promise; |
16 | }); | 16 | var URL = require("core/mini-url"); |
17 | definition(exports, Promise, URL); | ||
18 | require("require/browser"); | ||
19 | }); | ||
20 | |||
21 | // Worker | ||
22 | } else { | ||
23 | bootstrap("require/require", function (require, exports) { | ||
24 | var Promise = require("core/promise").Promise; | ||
25 | var URL = require("core/url"); | ||
26 | definition(exports, Promise, URL); | ||
27 | }); | ||
28 | } | ||
17 | 29 | ||
18 | // Node Server | 30 | // Node Server |
19 | } else if (typeof process !== "undefined") { | 31 | } else if (typeof process !== "undefined") { |
@@ -183,8 +195,8 @@ | |||
183 | // Modules should never have a return value. | 195 | // Modules should never have a return value. |
184 | if (returnValue !== void 0) { | 196 | if (returnValue !== void 0) { |
185 | console.warn( | 197 | console.warn( |
186 | 'require: module ' + JSON.stringify(topId) + | 198 | "require: module " + JSON.stringify(topId) + |
187 | ' returned a value.' | 199 | " returned a value." |
188 | ); | 200 | ); |
189 | } | 201 | } |
190 | 202 | ||
@@ -258,6 +270,8 @@ | |||
258 | return resolve(id, viaId); | 270 | return resolve(id, viaId); |
259 | }; | 271 | }; |
260 | 272 | ||
273 | require.getModule = getModule; | ||
274 | |||
261 | require.load = load; | 275 | require.load = load; |
262 | require.deepLoad = deepLoad; | 276 | require.deepLoad = deepLoad; |
263 | 277 | ||
@@ -269,10 +283,18 @@ | |||
269 | } | 283 | } |
270 | }; | 284 | }; |
271 | 285 | ||
286 | require.getPackage = function (dependency) { | ||
287 | return config.getPackage(dependency, config); | ||
288 | }; | ||
289 | |||
272 | require.injectPackageDescription = function (location, description) { | 290 | require.injectPackageDescription = function (location, description) { |
273 | Require.injectPackageDescription(location, description, config); | 291 | Require.injectPackageDescription(location, description, config); |
274 | }; | 292 | }; |
275 | 293 | ||
294 | require.injectPackageDescriptionLocation = function (location, descriptionLocation) { | ||
295 | Require.injectPackageDescriptionLocation(location, descriptionLocation, config); | ||
296 | }; | ||
297 | |||
276 | require.identify = identify; | 298 | require.identify = identify; |
277 | require.inject = inject; | 299 | require.inject = inject; |
278 | require.progress = Require.progress; | 300 | require.progress = Require.progress; |
@@ -283,6 +305,8 @@ | |||
283 | 305 | ||
284 | require.config = config; | 306 | require.config = config; |
285 | 307 | ||
308 | require.read = Require.read; | ||
309 | |||
286 | return require; | 310 | return require; |
287 | } | 311 | } |
288 | 312 | ||
@@ -297,17 +321,35 @@ | |||
297 | }; | 321 | }; |
298 | 322 | ||
299 | Require.injectPackageDescription = function (location, description, config) { | 323 | Require.injectPackageDescription = function (location, description, config) { |
300 | var descriptions = config.descriptions = config.descriptions || {}; | 324 | var descriptions = |
325 | config.descriptions = | ||
326 | config.descriptions || {}; | ||
301 | descriptions[location] = Promise.call(function () { | 327 | descriptions[location] = Promise.call(function () { |
302 | return description; | 328 | return description; |
303 | }); | 329 | }); |
304 | }; | 330 | }; |
305 | 331 | ||
332 | Require.injectPackageDescriptionLocation = function (location, descriptionLocation, config) { | ||
333 | var descriptionLocations = | ||
334 | config.descriptionLocations = | ||
335 | config.descriptionLocations || {}; | ||
336 | descriptionLocations[location] = descriptionLocation; | ||
337 | }; | ||
338 | |||
306 | Require.loadPackageDescription = function (location, config) { | 339 | Require.loadPackageDescription = function (location, config) { |
307 | var descriptions = config.descriptions = config.descriptions || {}; | 340 | var descriptions = |
341 | config.descriptions = | ||
342 | config.descriptions || {}; | ||
308 | if (descriptions[location] === void 0) { | 343 | if (descriptions[location] === void 0) { |
309 | var jsonPath = URL.resolve(location, 'package.json'); | 344 | var descriptionLocations = |
310 | descriptions[location] = Require.read(jsonPath) | 345 | config.descriptionLocations = |
346 | config.descriptionLocations || {}; | ||
347 | if (descriptionLocations[location]) { | ||
348 | descriptionLocation = descriptionLocations[location]; | ||
349 | } else { | ||
350 | descriptionLocation = URL.resolve(location, "package.json"); | ||
351 | } | ||
352 | descriptions[location] = Require.read(descriptionLocation) | ||
311 | .then(function (json) { | 353 | .then(function (json) { |
312 | try { | 354 | try { |
313 | return JSON.parse(json); | 355 | return JSON.parse(json); |
@@ -447,6 +489,7 @@ | |||
447 | 489 | ||
448 | // overlay | 490 | // overlay |
449 | var overlay = description.overlay || {}; | 491 | var overlay = description.overlay || {}; |
492 | var layer; | ||
450 | Require.overlays.forEach(function (engine) { | 493 | Require.overlays.forEach(function (engine) { |
451 | if (overlay[engine]) { | 494 | if (overlay[engine]) { |
452 | var layer = overlay[engine]; | 495 | var layer = overlay[engine]; |