diff options
author | Jose Antonio Marquez | 2012-04-24 10:06:53 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-24 10:06:53 -0700 |
commit | 4c15e77bdb7f4e0558f3749994a8a37b207b97ae (patch) | |
tree | 593ab4917fb5cc3ef8ee36822b56c6edd30c33a5 /node_modules/montage/montage.js | |
parent | 36d50b6599ab98559c76e1fe57b1bb131c4433da (diff) | |
parent | 55e6d621b9555abac06ab4adff44dfe29a78ec4e (diff) | |
download | ninja-4c15e77bdb7f4e0558f3749994a8a37b207b97ae.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'node_modules/montage/montage.js')
-rwxr-xr-x | node_modules/montage/montage.js | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/node_modules/montage/montage.js b/node_modules/montage/montage.js index e9e9b455..05e1a52a 100755 --- a/node_modules/montage/montage.js +++ b/node_modules/montage/montage.js | |||
@@ -48,9 +48,8 @@ if (typeof window !== "undefined") { | |||
48 | })(); | 48 | })(); |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Initializes Montage and creates the application singleton if necessary. | 51 | * Initializes Montage and creates the application singleton if |
52 | * @param options | 52 | * necessary. |
53 | * @param callback | ||
54 | */ | 53 | */ |
55 | exports.initMontage = function () { | 54 | exports.initMontage = function () { |
56 | var platform = exports.getPlatform(); | 55 | var platform = exports.getPlatform(); |
@@ -106,6 +105,14 @@ if (typeof window !== "undefined") { | |||
106 | }); | 105 | }); |
107 | }; | 106 | }; |
108 | 107 | ||
108 | if ('autoPackage' in params) { | ||
109 | montageRequire.injectPackageDescription(location, { | ||
110 | mappings: { | ||
111 | montage: "@" | ||
112 | } | ||
113 | }); | ||
114 | } | ||
115 | |||
109 | return montageRequire.loadPackage(location) | 116 | return montageRequire.loadPackage(location) |
110 | .then(function (applicationRequire) { | 117 | .then(function (applicationRequire) { |
111 | global.require = applicationRequire; | 118 | global.require = applicationRequire; |
@@ -126,6 +133,8 @@ if (typeof window !== "undefined") { | |||
126 | @param config | 133 | @param config |
127 | @param compiler | 134 | @param compiler |
128 | */ | 135 | */ |
136 | var reverseReelExpression = /((.*)\.reel)\/\2$/; | ||
137 | var reverseReelFunction = function ($0, $1) { return $1 }; | ||
129 | exports.SerializationCompiler = function(config, compile) { | 138 | exports.SerializationCompiler = function(config, compile) { |
130 | return function(module) { | 139 | return function(module) { |
131 | compile(module); | 140 | compile(module); |
@@ -134,22 +143,30 @@ if (typeof window !== "undefined") { | |||
134 | var defaultFactory = module.factory; | 143 | var defaultFactory = module.factory; |
135 | module.factory = function(require, exports, module) { | 144 | module.factory = function(require, exports, module) { |
136 | defaultFactory.call(this, require, exports, module); | 145 | defaultFactory.call(this, require, exports, module); |
137 | for (var symbol in exports) { | 146 | for (var name in exports) { |
138 | var object = exports[symbol]; | 147 | var object = exports[name]; |
148 | // avoid attempting to initialize a non-object | ||
149 | if (!(object instanceof Object)) { | ||
139 | // avoid attempting to reinitialize an aliased property | 150 | // avoid attempting to reinitialize an aliased property |
140 | if (object.hasOwnProperty("_montage_metadata")) { | 151 | } else if (object.hasOwnProperty("_montage_metadata")) { |
141 | object._montage_metadata.aliases.push(symbol); | 152 | object._montage_metadata.aliases.push(name); |
142 | object._montage_metadata.objectName = symbol; | 153 | object._montage_metadata.objectName = name; |
143 | } else if (!Object.isSealed(object)) { | 154 | } else if (!Object.isSealed(object)) { |
155 | var id = module.id.replace( | ||
156 | reverseReelExpression, | ||
157 | reverseReelFunction | ||
158 | ); | ||
144 | Object.defineProperty( | 159 | Object.defineProperty( |
145 | object, | 160 | object, |
146 | "_montage_metadata", | 161 | "_montage_metadata", |
147 | { | 162 | { |
148 | value: { | 163 | value: { |
149 | require: require, | 164 | require: require, |
150 | moduleId: module.id, | 165 | module: id, |
151 | objectName: symbol, | 166 | moduleId: id, // deprecated |
152 | aliases: [symbol], | 167 | property: name, |
168 | objectName: name, // deprecated | ||
169 | aliases: [name], | ||
153 | isInstance: false | 170 | isInstance: false |
154 | } | 171 | } |
155 | } | 172 | } |
@@ -380,10 +397,10 @@ if (typeof window !== "undefined") { | |||
380 | 397 | ||
381 | }, | 398 | }, |
382 | 399 | ||
383 | initMontage: function (montageRequire, applicationRequire, options) { | 400 | initMontage: function (montageRequire, applicationRequire, params) { |
384 | // If a module was specified in the config then we initialize it now | 401 | // If a module was specified in the config then we initialize it now |
385 | if (options.module) { | 402 | if (params.module) { |
386 | applicationRequire.async(options.module) | 403 | applicationRequire.async(params.module) |
387 | .end(); | 404 | .end(); |
388 | } else { | 405 | } else { |
389 | // otherwise we load the application | 406 | // otherwise we load the application |