| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @param {string} moduleName | 240 * @param {string} moduleName |
| 241 */ | 241 */ |
| 242 _registerModule: function(moduleName) | 242 _registerModule: function(moduleName) |
| 243 { | 243 { |
| 244 if (!this._descriptorsMap[moduleName]) { | 244 if (!this._descriptorsMap[moduleName]) { |
| 245 var content; | 245 var content; |
| 246 // FIXME: This is a temp workaround to avoid core module loading att
empts in the release mode. | 246 // FIXME: This is a temp workaround to avoid core module loading att
empts in the release mode. |
| 247 // It should be removed when the new application loader is implement
ed. | 247 // It should be removed when the new application loader is implement
ed. |
| 248 if (!this._coreModules.hasOwnProperty(moduleName)) | 248 if (moduleName === "main" || !this._coreModules.hasOwnProperty(modul
eName)) |
| 249 content = loadResource(moduleName + "/module.json"); | 249 content = loadResource(moduleName + "/module.json"); |
| 250 else | 250 else |
| 251 content = "{}"; | 251 content = "{}"; |
| 252 | 252 |
| 253 if (!content) | 253 if (!content) |
| 254 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); | 254 throw new Error("Module is not defined: " + moduleName + " " + n
ew Error().stack); |
| 255 | 255 |
| 256 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); | 256 var module = /** @type {!Runtime.ModuleDescriptor} */ (self.eval("("
+ content + ")")); |
| 257 module["name"] = moduleName; | 257 module["name"] = moduleName; |
| 258 this._descriptorsMap[moduleName] = module; | 258 this._descriptorsMap[moduleName] = module; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 */ | 517 */ |
| 518 Runtime.Module = function(manager, descriptor) | 518 Runtime.Module = function(manager, descriptor) |
| 519 { | 519 { |
| 520 this._manager = manager; | 520 this._manager = manager; |
| 521 this._descriptor = descriptor; | 521 this._descriptor = descriptor; |
| 522 this._name = descriptor.name; | 522 this._name = descriptor.name; |
| 523 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>}*/ (descri
ptor.extensions); | 523 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>}*/ (descri
ptor.extensions); |
| 524 for (var i = 0; extensions && i < extensions.length; ++i) | 524 for (var i = 0; extensions && i < extensions.length; ++i) |
| 525 this._manager._extensions.push(new Runtime.Extension(this, extensions[i]
)); | 525 this._manager._extensions.push(new Runtime.Extension(this, extensions[i]
)); |
| 526 this._loaded = false; | 526 this._loaded = false; |
| 527 |
| 528 // FIXME: This is a temp workaround to avoid core module loading attempts in
the release mode. |
| 529 // It should be removed when the new application loader is implemented. |
| 530 if (this._manager._coreModules.hasOwnProperty(this._name)) |
| 531 this._loaded = true; |
| 527 } | 532 } |
| 528 | 533 |
| 529 Runtime.Module.prototype = { | 534 Runtime.Module.prototype = { |
| 530 /** | 535 /** |
| 531 * @return {string} | 536 * @return {string} |
| 532 */ | 537 */ |
| 533 name: function() | 538 name: function() |
| 534 { | 539 { |
| 535 return this._name; | 540 return this._name; |
| 536 }, | 541 }, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 547 Error.stackTraceLimit = oldStackTraceLimit; | 552 Error.stackTraceLimit = oldStackTraceLimit; |
| 548 return; | 553 return; |
| 549 } | 554 } |
| 550 | 555 |
| 551 this._isLoading = true; | 556 this._isLoading = true; |
| 552 var dependencies = this._descriptor.dependencies; | 557 var dependencies = this._descriptor.dependencies; |
| 553 for (var i = 0; dependencies && i < dependencies.length; ++i) | 558 for (var i = 0; dependencies && i < dependencies.length; ++i) |
| 554 this._manager.loadModule(dependencies[i]); | 559 this._manager.loadModule(dependencies[i]); |
| 555 if (this._descriptor.scripts) { | 560 if (this._descriptor.scripts) { |
| 556 if (Runtime.isReleaseMode()) { | 561 if (Runtime.isReleaseMode()) { |
| 557 // FIXME: This is a temp workaround to avoid core module loading
attempts in the release mode. | 562 loadScript(this._name + ".js"); |
| 558 // It should be removed when the new application loader is imple
mented. | |
| 559 if (!this._manager._coreModules.hasOwnProperty(this._name)) | |
| 560 loadScript(this._name + ".js"); | |
| 561 } else { | 563 } else { |
| 562 var scripts = this._descriptor.scripts; | 564 var scripts = this._descriptor.scripts; |
| 563 for (var i = 0; i < scripts.length; ++i) | 565 for (var i = 0; i < scripts.length; ++i) |
| 564 loadScript(this._name + "/" + scripts[i]); | 566 loadScript(this._name + "/" + scripts[i]); |
| 565 } | 567 } |
| 566 } | 568 } |
| 567 this._isLoading = false; | 569 this._isLoading = false; |
| 568 this._loaded = true; | 570 this._loaded = true; |
| 569 } | 571 } |
| 570 } | 572 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 this._instance = new constructorFunction(); | 644 this._instance = new constructorFunction(); |
| 643 } | 645 } |
| 644 return this._instance; | 646 return this._instance; |
| 645 } | 647 } |
| 646 } | 648 } |
| 647 | 649 |
| 648 /** | 650 /** |
| 649 * @type {!Runtime} | 651 * @type {!Runtime} |
| 650 */ | 652 */ |
| 651 var runtime; | 653 var runtime; |
| OLD | NEW |