diff options
Diffstat (limited to 'node_modules/montage/core')
-rwxr-xr-x | node_modules/montage/core/deserializer.js | 352 | ||||
-rwxr-xr-x | node_modules/montage/core/event/action-event-listener.js | 4 | ||||
-rwxr-xr-x | node_modules/montage/core/event/binding.js | 48 | ||||
-rwxr-xr-x | node_modules/montage/core/event/event-manager.js | 14 | ||||
-rwxr-xr-x | node_modules/montage/core/logger.js | 1 | ||||
-rw-r--r-- | node_modules/montage/core/promise-connection.js | 285 | ||||
-rw-r--r-- | node_modules/montage/core/promise-queue.js | 65 | ||||
-rwxr-xr-x | node_modules/montage/core/promise.js | 48 | ||||
-rwxr-xr-x | node_modules/montage/core/serializer.js | 328 | ||||
-rw-r--r-- | node_modules/montage/core/undo-manager.js | 12 |
10 files changed, 981 insertions, 176 deletions
diff --git a/node_modules/montage/core/deserializer.js b/node_modules/montage/core/deserializer.js index 7e812235..b8ed5618 100755 --- a/node_modules/montage/core/deserializer.js +++ b/node_modules/montage/core/deserializer.js | |||
@@ -98,6 +98,26 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
98 | }}, | 98 | }}, |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Initializes the deserializer with a string | ||
102 | @param {String|Object} serialization A string or JSON-style object | ||
103 | describing the serialized objects. | ||
104 | @param {Function} require The module loader for the containing package. | ||
105 | @param {String} origin Usually a file name. | ||
106 | */ | ||
107 | init: { | ||
108 | value: function (serialization, require, origin) { | ||
109 | if (typeof serialization !== "string") { | ||
110 | serialization = JSON.stringify(serialization); | ||
111 | } | ||
112 | this._reset(); | ||
113 | this._serializationString = serialization; | ||
114 | this._require = require; | ||
115 | this._origin = origin; | ||
116 | return this; | ||
117 | } | ||
118 | }, | ||
119 | |||
120 | /** | ||
101 | Initializes the deserializer with a string of serialized objects. | 121 | Initializes the deserializer with a string of serialized objects. |
102 | @function | 122 | @function |
103 | @param {String} string A string of serialized objects. | 123 | @param {String} string A string of serialized objects. |
@@ -122,6 +142,14 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
122 | return this; | 142 | return this; |
123 | }}, | 143 | }}, |
124 | 144 | ||
145 | initWithObjectAndRequire: {value: function(string, require, origin) { | ||
146 | this._reset(); | ||
147 | this._serializationString = JSON.stringify(object); | ||
148 | this._require = require; | ||
149 | this._origin = origin; | ||
150 | return this; | ||
151 | }}, | ||
152 | |||
125 | /** | 153 | /** |
126 | Initializes the deserializer object with a serialization string and the require object used to load the modules containing the object's prototypes. | 154 | Initializes the deserializer object with a serialization string and the require object used to load the modules containing the object's prototypes. |
127 | @function | 155 | @function |
@@ -168,8 +196,37 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
168 | 196 | ||
169 | return objectsArray; | 197 | return objectsArray; |
170 | }}, | 198 | }}, |
199 | |||
200 | chainDeserializer: { | ||
201 | value: function(deserializer) { | ||
202 | var chainedSerializations = this._chainedSerializations, | ||
203 | optimizedIds, chainedOptimizedIds; | ||
204 | |||
205 | if (!chainedSerializations) { | ||
206 | this._chainedSerializations = chainedSerializations = []; | ||
207 | } | ||
208 | |||
209 | chainedSerializations.push({ | ||
210 | string: deserializer._serializationString, | ||
211 | compiledFunction: deserializer._compiledDeserializationFunction, | ||
212 | compiledFunctionString: deserializer._compiledDeserializationFunctionString | ||
213 | }); | ||
214 | |||
215 | // need to copy the optimized ids too, ideally all chained templates are optimized for the same document | ||
216 | chainedOptimizedIds = deserializer._optimizedIds; | ||
217 | if (chainedOptimizedIds) { | ||
218 | if (!optimizedIds) { | ||
219 | this._optimizedIds = optimizedIds = {}; | ||
220 | } | ||
221 | for (var id in chainedOptimizedIds) { | ||
222 | optimizedIds[id] = chainedOptimizedIds[id]; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | }, | ||
227 | |||
171 | /** | 228 | /** |
172 | This function is to be used in the context of deserializeSelf delegate used for custom object deserializations. | 229 | This function is to be used in the context of deserializeProperties delegate used for custom object deserializations. |
173 | It reads an entry from the "properties" serialization unit of the object being deserialized. | 230 | It reads an entry from the "properties" serialization unit of the object being deserialized. |
174 | @function | 231 | @function |
175 | @param {string} name The name of the entry to be read. | 232 | @param {string} name The name of the entry to be read. |
@@ -182,8 +239,93 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
182 | return stack[ix][name]; | 239 | return stack[ix][name]; |
183 | }}, | 240 | }}, |
184 | 241 | ||
242 | deserializeProperties: { | ||
243 | value: function() { | ||
244 | var stack = this._objectStack, | ||
245 | ix = stack.length - 1, | ||
246 | object = stack[ix-1], | ||
247 | desc = stack[ix]; | ||
248 | |||
249 | this._deserializeProperties(object, desc.properties); | ||
250 | } | ||
251 | }, | ||
252 | |||
253 | getProperty: { | ||
254 | value: function(name) { | ||
255 | var stack = this._objectStack, | ||
256 | ix = stack.length - 1, | ||
257 | desc = stack[ix]; | ||
258 | |||
259 | return desc.properties[name]; | ||
260 | } | ||
261 | }, | ||
262 | |||
263 | deserializeUnits: { | ||
264 | value: function() { | ||
265 | var stack = this._objectStack, | ||
266 | ix = stack.length - 1, | ||
267 | desc = stack[ix]; | ||
268 | |||
269 | desc._units = this._indexedDeserializationUnits; | ||
270 | } | ||
271 | }, | ||
272 | |||
273 | deserializeUnit: { | ||
274 | value: function(name) { | ||
275 | var stack = this._objectStack, | ||
276 | ix = stack.length - 1, | ||
277 | desc = stack[ix], | ||
278 | units; | ||
279 | |||
280 | if (desc._units) { | ||
281 | units = desc._units; | ||
282 | } else { | ||
283 | desc._units = units = {}; | ||
284 | } | ||
285 | |||
286 | units[name] = this._indexedDeserializationUnits[name]; | ||
287 | } | ||
288 | }, | ||
289 | |||
290 | getType: { | ||
291 | value: function() { | ||
292 | var stack = this._objectStack, | ||
293 | ix = stack.length - 1, | ||
294 | desc = stack[ix]; | ||
295 | |||
296 | return "object" in desc ? "object" : ("prototype" in desc ? "prototype" : null); | ||
297 | } | ||
298 | }, | ||
299 | |||
300 | getTypeValue: { | ||
301 | value: function() { | ||
302 | var stack = this._objectStack, | ||
303 | ix = stack.length - 1, | ||
304 | desc = stack[ix]; | ||
305 | |||
306 | return desc.object || desc.prototype; | ||
307 | } | ||
308 | }, | ||
309 | |||
310 | getObjectByLabel: { | ||
311 | value: function(label) { | ||
312 | return this._objects[label] || this._objectLabels[label]; | ||
313 | } | ||
314 | }, | ||
315 | |||
316 | _customDeserialization: { | ||
317 | enumerable: false, | ||
318 | value: function(object, desc) { | ||
319 | this._pushContextObject(object); | ||
320 | this._pushContextObject(desc); | ||
321 | object.deserializeSelf(this); | ||
322 | this._popContextObject(); | ||
323 | this._popContextObject(); | ||
324 | } | ||
325 | }, | ||
326 | |||
185 | /** | 327 | /** |
186 | This function is to be used in the context of deserializeSelf delegate used for custom object deserializations. | 328 | This function is to be used in the context of deserializeProperties delegate used for custom object deserializations. |
187 | It deserializes all the named properties of a serialized object into the object given. | 329 | It deserializes all the named properties of a serialized object into the object given. |
188 | @function | 330 | @function |
189 | @param {Object} object The target of the properties. | 331 | @param {Object} object The target of the properties. |
@@ -383,7 +525,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
383 | var serialization = this._serialization, | 525 | var serialization = this._serialization, |
384 | moduleIds = this._requiredModuleIds = [], | 526 | moduleIds = this._requiredModuleIds = [], |
385 | modules = this._modules, | 527 | modules = this._modules, |
386 | desc, moduleId; | 528 | desc, moduleId, name, objectLocation; |
387 | 529 | ||
388 | for (var label in serialization) { | 530 | for (var label in serialization) { |
389 | desc = serialization[label]; | 531 | desc = serialization[label]; |
@@ -391,7 +533,8 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
391 | 533 | ||
392 | if ("module" in desc) { | 534 | if ("module" in desc) { |
393 | moduleId = desc.module; | 535 | moduleId = desc.module; |
394 | } else if (name = /*assignment*/(desc.prototype || desc.object)) { | 536 | } else if ("prototype" in desc || "object" in desc) { |
537 | name = desc.prototype || desc.object | ||
395 | objectLocation = name.split("["); | 538 | objectLocation = name.split("["); |
396 | moduleId = objectLocation[0]; | 539 |