rails-angularjs2 2.0.0.pre.alpha.32 → 2.0.0.pre.beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/rails-angularjs2/version.rb +1 -1
  4. data/vendor/assets/javascripts/Rx.js +11615 -0
  5. data/vendor/assets/javascripts/Rx.min.js +417 -0
  6. data/vendor/assets/javascripts/Rx.min.js.map +1 -0
  7. data/vendor/assets/javascripts/Rx.umd.js +10274 -0
  8. data/vendor/assets/javascripts/Rx.umd.min.js +748 -0
  9. data/vendor/assets/javascripts/Rx.umd.min.js.map +8 -0
  10. data/vendor/assets/javascripts/angular2-all-testing.umd.dev.js +39335 -0
  11. data/vendor/assets/javascripts/angular2-all.umd.dev.js +37160 -0
  12. data/vendor/assets/javascripts/angular2-all.umd.js +37159 -0
  13. data/vendor/assets/javascripts/angular2-all.umd.min.js +19 -0
  14. data/vendor/assets/javascripts/angular2-polyfills.js +3324 -0
  15. data/vendor/assets/javascripts/angular2-polyfills.min.js +1 -0
  16. data/vendor/assets/javascripts/angular2.dev.js +23937 -29580
  17. data/vendor/assets/javascripts/angular2.js +24021 -29105
  18. data/vendor/assets/javascripts/angular2.min.js +18 -24
  19. data/vendor/assets/javascripts/http.dev.js +1091 -0
  20. data/vendor/assets/javascripts/http.js +1091 -0
  21. data/vendor/assets/javascripts/http.min.js +1 -0
  22. data/vendor/assets/javascripts/router.dev.js +2946 -1894
  23. data/vendor/assets/javascripts/router.js +3107 -0
  24. data/vendor/assets/javascripts/router.min.js +3 -0
  25. data/vendor/assets/javascripts/testing.dev.js +2105 -0
  26. data/vendor/assets/javascripts/testing.dev.js.map +1 -0
  27. data/vendor/assets/javascripts/upgrade.dev.js +777 -0
  28. data/vendor/assets/javascripts/upgrade.js +777 -0
  29. data/vendor/assets/javascripts/upgrade.min.js +1 -0
  30. metadata +25 -9
  31. data/vendor/assets/javascripts/angular2.sfx.dev.js +0 -36368
  32. data/vendor/assets/javascripts/mock.dev.js +0 -337
  33. data/vendor/assets/javascripts/mock.dev.js.map +0 -1
  34. data/vendor/assets/javascripts/router.dev.js.map +0 -1
  35. data/vendor/assets/javascripts/test_lib.dev.js +0 -1510
  36. data/vendor/assets/javascripts/test_lib.dev.js.map +0 -1
@@ -0,0 +1,777 @@
1
+ "format register";
2
+ System.register("angular2/src/upgrade/metadata", ["angular2/core"], true, function(require, exports, module) {
3
+ var global = System.global,
4
+ __define = global.define;
5
+ global.define = undefined;
6
+ var core_1 = require("angular2/core");
7
+ var COMPONENT_SELECTOR = /^[\w|-]*$/;
8
+ var SKEWER_CASE = /-(\w)/g;
9
+ var directiveResolver = new core_1.DirectiveResolver();
10
+ function getComponentInfo(type) {
11
+ var resolvedMetadata = directiveResolver.resolve(type);
12
+ var selector = resolvedMetadata.selector;
13
+ if (!selector.match(COMPONENT_SELECTOR)) {
14
+ throw new Error('Only selectors matching element names are supported, got: ' + selector);
15
+ }
16
+ var selector = selector.replace(SKEWER_CASE, function(all, letter) {
17
+ return letter.toUpperCase();
18
+ });
19
+ return {
20
+ type: type,
21
+ selector: selector,
22
+ inputs: parseFields(resolvedMetadata.inputs),
23
+ outputs: parseFields(resolvedMetadata.outputs)
24
+ };
25
+ }
26
+ exports.getComponentInfo = getComponentInfo;
27
+ function parseFields(names) {
28
+ var attrProps = [];
29
+ if (names) {
30
+ for (var i = 0; i < names.length; i++) {
31
+ var parts = names[i].split(':');
32
+ var prop = parts[0].trim();
33
+ var attr = (parts[1] || parts[0]).trim();
34
+ var capitalAttr = attr.charAt(0).toUpperCase() + attr.substr(1);
35
+ attrProps.push({
36
+ prop: prop,
37
+ attr: attr,
38
+ bracketAttr: "[" + attr + "]",
39
+ parenAttr: "(" + attr + ")",
40
+ bracketParenAttr: "[(" + attr + ")]",
41
+ onAttr: "on" + capitalAttr,
42
+ bindAttr: "bind" + capitalAttr,
43
+ bindonAttr: "bindon" + capitalAttr
44
+ });
45
+ }
46
+ }
47
+ return attrProps;
48
+ }
49
+ exports.parseFields = parseFields;
50
+ global.define = __define;
51
+ return module.exports;
52
+ });
53
+
54
+ System.register("angular2/src/upgrade/util", [], true, function(require, exports, module) {
55
+ var global = System.global,
56
+ __define = global.define;
57
+ global.define = undefined;
58
+ function stringify(obj) {
59
+ if (typeof obj == 'function')
60
+ return obj.name || obj.toString();
61
+ return '' + obj;
62
+ }
63
+ exports.stringify = stringify;
64
+ function onError(e) {
65
+ console.log(e, e.stack);
66
+ throw e;
67
+ }
68
+ exports.onError = onError;
69
+ function controllerKey(name) {
70
+ return '$' + name + 'Controller';
71
+ }
72
+ exports.controllerKey = controllerKey;
73
+ global.define = __define;
74
+ return module.exports;
75
+ });
76
+
77
+ System.register("angular2/src/upgrade/constants", [], true, function(require, exports, module) {
78
+ var global = System.global,
79
+ __define = global.define;
80
+ global.define = undefined;
81
+ exports.NG2_APP_VIEW_MANAGER = 'ng2.AppViewManager';
82
+ exports.NG2_COMPILER = 'ng2.Compiler';
83
+ exports.NG2_INJECTOR = 'ng2.Injector';
84
+ exports.NG2_HOST_VIEW_FACTORY_REF_MAP = 'ng2.HostViewFactoryRefMap';
85
+ exports.NG2_ZONE = 'ng2.NgZone';
86
+ exports.NG1_CONTROLLER = '$controller';
87
+ exports.NG1_SCOPE = '$scope';
88
+ exports.NG1_ROOT_SCOPE = '$rootScope';
89
+ exports.NG1_COMPILE = '$compile';
90
+ exports.NG1_HTTP_BACKEND = '$httpBackend';
91
+ exports.NG1_INJECTOR = '$injector';
92
+ exports.NG1_PARSE = '$parse';
93
+ exports.NG1_TEMPLATE_CACHE = '$templateCache';
94
+ exports.REQUIRE_INJECTOR = '^' + exports.NG2_INJECTOR;
95
+ global.define = __define;
96
+ return module.exports;
97
+ });
98
+
99
+ System.register("angular2/src/upgrade/downgrade_ng2_adapter", ["angular2/core", "angular2/src/upgrade/constants"], true, function(require, exports, module) {
100
+ var global = System.global,
101
+ __define = global.define;
102
+ global.define = undefined;
103
+ var core_1 = require("angular2/core");
104
+ var constants_1 = require("angular2/src/upgrade/constants");
105
+ var INITIAL_VALUE = {__UNINITIALIZED__: true};
106
+ var DowngradeNg2ComponentAdapter = (function() {
107
+ function DowngradeNg2ComponentAdapter(id, info, element, attrs, scope, parentInjector, parse, viewManager, hostViewFactory) {
108
+ this.id = id;
109
+ this.info = info;
110
+ this.element = element;
111
+ this.attrs = attrs;
112
+ this.scope = scope;
113
+ this.parentInjector = parentInjector;
114
+ this.parse = parse;
115
+ this.viewManager = viewManager;
116
+ this.hostViewFactory = hostViewFactory;
117
+ this.component = null;
118
+ this.inputChangeCount = 0;
119
+ this.inputChanges = null;
120
+ this.hostViewRef = null;
121
+ this.changeDetector = null;
122
+ this.contentInsertionPoint = null;
123
+ this.element[0].id = id;
124
+ this.componentScope = scope.$new();
125
+ this.childNodes = element.contents();
126
+ }
127
+ DowngradeNg2ComponentAdapter.prototype.bootstrapNg2 = function() {
128
+ var childInjector = this.parentInjector.resolveAndCreateChild([core_1.provide(constants_1.NG1_SCOPE, {useValue: this.componentScope})]);
129
+ this.contentInsertionPoint = document.createComment('ng1 insertion point');
130
+ this.hostViewRef = this.viewManager.createRootHostView(this.hostViewFactory, '#' + this.id, childInjector, [[this.contentInsertionPoint]]);
131
+ var hostElement = this.viewManager.getHostElement(this.hostViewRef);
132
+ this.changeDetector = this.hostViewRef.changeDetectorRef;
133
+ this.component = this.viewManager.getComponent(hostElement);
134
+ };
135
+ DowngradeNg2ComponentAdapter.prototype.setupInputs = function() {
136
+ var _this = this;
137
+ var attrs = this.attrs;
138
+ var inputs = this.info.inputs;
139
+ for (var i = 0; i < inputs.length; i++) {
140
+ var input = inputs[i];
141
+ var expr = null;
142
+ if (attrs.hasOwnProperty(input.attr)) {
143
+ var observeFn = (function(prop) {
144
+ var prevValue = INITIAL_VALUE;
145
+ return function(value) {
146
+ if (_this.inputChanges !== null) {
147
+ _this.inputChangeCount++;
148
+ _this.inputChanges[prop] = new Ng1Change(value, prevValue === INITIAL_VALUE ? value : prevValue);
149
+ prevValue = value;
150
+ }
151
+ _this.component[prop] = value;
152
+ };
153
+ })(input.prop);
154
+ attrs.$observe(input.attr, observeFn);
155
+ } else if (attrs.hasOwnProperty(input.bindAttr)) {
156
+ expr = attrs[input.bindAttr];
157
+ } else if (attrs.hasOwnProperty(input.bracketAttr)) {
158
+ expr = attrs[input.bracketAttr];
159
+ } else if (attrs.hasOwnProperty(input.bindonAttr)) {
160
+ expr = attrs[input.bindonAttr];
161
+ } else if (attrs.hasOwnProperty(input.bracketParenAttr)) {
162
+ expr = attrs[input.bracketParenAttr];
163
+ }
164
+ if (expr != null) {
165
+ var watchFn = (function(prop) {
166
+ return function(value, prevValue) {
167
+ if (_this.inputChanges != null) {
168
+ _this.inputChangeCount++;
169
+ _this.inputChanges[prop] = new Ng1Change(prevValue, value);
170
+ }
171
+ _this.component[prop] = value;
172
+ };
173
+ })(input.prop);
174
+ this.componentScope.$watch(expr, watchFn);
175
+ }
176
+ }
177
+ var prototype = this.info.type.prototype;
178
+ if (prototype && prototype.ngOnChanges) {
179
+ this.inputChanges = {};
180
+ this.componentScope.$watch(function() {
181
+ return _this.inputChangeCount;
182
+ }, function() {
183
+ var inputChanges = _this.inputChanges;
184
+ _this.inputChanges = {};
185
+ _this.component.ngOnChanges(inputChanges);
186
+ });
187
+ }
188
+ this.componentScope.$watch(function() {
189
+ return _this.changeDetector && _this.changeDetector.detectChanges();
190
+ });
191
+ };
192
+ DowngradeNg2ComponentAdapter.prototype.projectContent = function() {
193
+ var childNodes = this.childNodes;
194
+ var parent = this.contentInsertionPoint.parentNode;
195
+ if (parent) {
196
+ for (var i = 0,
197
+ ii = childNodes.length; i < ii; i++) {
198
+ parent.insertBefore(childNodes[i], this.contentInsertionPoint);
199
+ }
200
+ }
201
+ };
202
+ DowngradeNg2ComponentAdapter.prototype.setupOutputs = function() {
203
+ var _this = this;
204
+ var attrs = this.attrs;
205
+ var outputs = this.info.outputs;
206
+ for (var j = 0; j < outputs.length; j++) {
207
+ var output = outputs[j];
208
+ var expr = null;
209
+ var assignExpr = false;
210
+ var bindonAttr = output.bindonAttr ? output.bindonAttr.substring(0, output.bindonAttr.length - 6) : null;
211
+ var bracketParenAttr = output.bracketParenAttr ? "[(" + output.bracketParenAttr.substring(2, output.bracketParenAttr.length - 8) + ")]" : null;
212
+ if (attrs.hasOwnProperty(output.onAttr)) {
213
+ expr = attrs[output.onAttr];
214
+ } else if (attrs.hasOwnProperty(output.parenAttr)) {
215
+ expr = attrs[output.parenAttr];
216
+ } else if (attrs.hasOwnProperty(bindonAttr)) {
217
+ expr = attrs[bindonAttr];
218
+ assignExpr = true;
219
+ } else if (attrs.hasOwnProperty(bracketParenAttr)) {
220
+ expr = attrs[bracketParenAttr];
221
+ assignExpr = true;
222
+ }
223
+ if (expr != null && assignExpr != null) {
224
+ var getter = this.parse(expr);
225
+ var setter = getter.assign;
226
+ if (assignExpr && !setter) {
227
+ throw new Error("Expression '" + expr + "' is not assignable!");
228
+ }
229
+ var emitter = this.component[output.prop];
230
+ if (emitter) {
231
+ emitter.subscribe({next: assignExpr ? (function(setter) {
232
+ return function(value) {
233
+ return setter(_this.scope, value);
234
+ };
235
+ })(setter) : (function(getter) {
236
+ return function(value) {
237
+ return getter(_this.scope, {$event: value});
238
+ };
239
+ })(getter)});
240
+ } else {
241
+ throw new Error("Missing emitter '" + output.prop + "' on component '" + this.info.selector + "'!");
242
+ }
243
+ }
244
+ }
245
+ };
246
+ DowngradeNg2ComponentAdapter.prototype.registerCleanup = function() {
247
+ var _this = this;
248
+ this.element.bind('$remove', function() {
249
+ return _this.viewManager.destroyRootHostView(_this.hostViewRef);
250
+ });
251
+ };
252
+ return DowngradeNg2ComponentAdapter;
253
+ })();
254
+ exports.DowngradeNg2ComponentAdapter = DowngradeNg2ComponentAdapter;
255
+ var Ng1Change = (function() {
256
+ function Ng1Change(previousValue, currentValue) {
257
+ this.previousValue = previousValue;
258
+ this.currentValue = currentValue;
259
+ }
260
+ Ng1Change.prototype.isFirstChange = function() {
261
+ return this.previousValue === this.currentValue;
262
+ };
263
+ return Ng1Change;
264
+ })();
265
+ global.define = __define;
266
+ return module.exports;
267
+ });
268
+
269
+ System.register("angular2/src/upgrade/angular_js", [], true, function(require, exports, module) {
270
+ var global = System.global,
271
+ __define = global.define;
272
+ global.define = undefined;
273
+ function noNg() {
274
+ throw new Error('AngularJS v1.x is not loaded!');
275
+ }
276
+ var angular = {
277
+ bootstrap: noNg,
278
+ module: noNg,
279
+ element: noNg,
280
+ version: noNg
281
+ };
282
+ try {
283
+ if (window.hasOwnProperty('angular')) {
284
+ angular = window.angular;
285
+ }
286
+ } catch (e) {}
287
+ exports.bootstrap = angular.bootstrap;
288
+ exports.module = angular.module;
289
+ exports.element = angular.element;
290
+ exports.version = angular.version;
291
+ global.define = __define;
292
+ return module.exports;
293
+ });
294
+
295
+ System.register("angular2/src/upgrade/upgrade_ng1_adapter", ["angular2/core", "angular2/src/upgrade/constants", "angular2/src/upgrade/util", "angular2/src/upgrade/angular_js"], true, function(require, exports, module) {
296
+ var global = System.global,
297
+ __define = global.define;
298
+ global.define = undefined;
299
+ var core_1 = require("angular2/core");
300
+ var constants_1 = require("angular2/src/upgrade/constants");
301
+ var util_1 = require("angular2/src/upgrade/util");
302
+ var angular = require("angular2/src/upgrade/angular_js");
303
+ var CAMEL_CASE = /([A-Z])/g;
304
+ var INITIAL_VALUE = {__UNINITIALIZED__: true};
305
+ var NOT_SUPPORTED = 'NOT_SUPPORTED';
306
+ var UpgradeNg1ComponentAdapterBuilder = (function() {
307
+ function UpgradeNg1ComponentAdapterBuilder(name) {
308
+ this.name = name;
309
+ this.inputs = [];
310
+ this.inputsRename = [];
311
+ this.outputs = [];
312
+ this.outputsRename = [];
313
+ this.propertyOutputs = [];
314
+ this.checkProperties = [];
315
+ this.propertyMap = {};
316
+ this.linkFn = null;
317
+ this.directive = null;
318
+ this.$controller = null;
319
+ var selector = name.replace(CAMEL_CASE, function(all, next) {
320
+ return '-' + next.toLowerCase();
321
+ });
322
+ var self = this;
323
+ this.type = core_1.Directive({
324
+ selector: selector,
325
+ inputs: this.inputsRename,
326
+ outputs: this.outputsRename
327
+ }).Class({
328
+ constructor: [new core_1.Inject(constants_1.NG1_SCOPE), core_1.ElementRef, function(scope, elementRef) {
329
+ return new UpgradeNg1ComponentAdapter(self.linkFn, scope, self.directive, elementRef, self.$controller, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
330
+ }],
331
+ ngOnChanges: function() {},
332
+ ngDoCheck: function() {}
333
+ });
334
+ }
335
+ UpgradeNg1ComponentAdapterBuilder.prototype.extractDirective = function(injector) {
336
+ var directives = injector.get(this.name + 'Directive');
337
+ if (directives.length > 1) {
338
+ throw new Error('Only support single directive definition for: ' + this.name);
339
+ }
340
+ var directive = directives[0];
341
+ if (directive.replace)
342
+ this.notSupported('replace');
343
+ if (directive.terminal)
344
+ this.notSupported('terminal');
345
+ var link = directive.link;
346
+ if (typeof link == 'object') {
347
+ if (link.post)
348
+ this.notSupported('link.post');
349
+ }
350
+ return directive;
351
+ };
352
+ UpgradeNg1ComponentAdapterBuilder.prototype.notSupported = function(feature) {
353
+ throw new Error("Upgraded directive '" + this.name + "' does not support '" + feature + "'.");
354
+ };
355
+ UpgradeNg1ComponentAdapterBuilder.prototype.extractBindings = function() {
356
+ var btcIsObject = typeof this.directive.bindToController === 'object';
357
+ if (btcIsObject && Object.keys(this.directive.scope).length) {
358
+ throw new Error("Binding definitions on scope and controller at the same time are not supported.");
359
+ }
360
+ var context = (btcIsObject) ? this.directive.bindToController : this.directive.scope;
361
+ if (typeof context == 'object') {
362
+ for (var name in context) {
363
+ if (context.hasOwnProperty(name)) {
364
+ var localName = context[name];
365
+ var type = localName.charAt(0);
366
+ localName = localName.substr(1) || name;
367
+ var outputName = 'output_' + name;
368
+ var outputNameRename = outputName + ': ' + name;
369
+ var outputNameRenameChange = outputName + ': ' + name + 'Change';
370
+ var inputName = 'input_' + name;
371
+ var inputNameRename = inputName + ': ' + name;
372
+ switch (type) {
373
+ case '=':
374
+ this.propertyOutputs.push(outputName);
375
+ this.checkProperties.push(localName);
376
+ this.outputs.push(outputName);
377
+ this.outputsRename.push(outputNameRenameChange);
378
+ this.propertyMap[outputName] = localName;
379
+ case '@':
380
+ this.inputs.push(inputName);
381
+ this.inputsRename.push(inputNameRename);
382
+ this.propertyMap[inputName] = localName;
383
+ break;
384
+ case '&':
385
+ this.outputs.push(outputName);
386
+ this.outputsRename.push(outputNameRename);
387
+ this.propertyMap[outputName] = localName;
388
+ break;
389
+ default:
390
+ var json = JSON.stringify(context);
391
+ throw new Error("Unexpected mapping '" + type + "' in '" + json + "' in '" + this.name + "' directive.");
392
+ }
393
+ }
394
+ }
395
+ }
396
+ };
397
+ UpgradeNg1ComponentAdapterBuilder.prototype.compileTemplate = function(compile, templateCache, httpBackend) {
398
+ var _this = this;
399
+ if (this.directive.template !== undefined) {
400
+ this.linkFn = compileHtml(this.directive.template);
401
+ } else if (this.directive.templateUrl) {
402
+ var url = this.directive.templateUrl;
403
+ var html = templateCache.get(url);
404
+ if (html !== undefined) {
405
+ this.linkFn = compileHtml(html);
406
+ } else {
407
+ return new Promise(function(resolve, err) {
408
+ httpBackend('GET', url, null, function(status, response) {
409
+ if (status == 200) {
410
+ resolve(_this.linkFn = compileHtml(templateCache.put(url, response)));
411
+ } else {
412
+ err("GET " + url + " returned " + status + ": " + response);
413
+ }
414
+ });
415
+ });
416
+ }
417
+ } else {
418
+ throw new Error("Directive '" + this.name + "' is not a component, it is missing template.");
419
+ }
420
+ return null;
421
+ function compileHtml(html) {
422
+ var div = document.createElement('div');
423
+ div.innerHTML = html;
424
+ return compile(div.childNodes);
425
+ }
426
+ };
427
+ UpgradeNg1ComponentAdapterBuilder.resolve = function(exportedComponents, injector) {
428
+ var promises = [];
429
+ var compile = injector.get(constants_1.NG1_COMPILE);
430
+ var templateCache = injector.get(constants_1.NG1_TEMPLATE_CACHE);
431
+ var httpBackend = injector.get(constants_1.NG1_HTTP_BACKEND);
432
+ var $controller = injector.get(constants_1.NG1_CONTROLLER);
433
+ for (var name in exportedComponents) {
434
+ if (exportedComponents.hasOwnProperty(name)) {
435
+ var exportedComponent = exportedComponents[name];
436
+ exportedComponent.directive = exportedComponent.extractDirective(injector);
437
+ exportedComponent.$controller = $controller;
438
+ exportedComponent.extractBindings();
439
+ var promise = exportedComponent.compileTemplate(compile, templateCache, httpBackend);
440
+ if (promise)
441
+ promises.push(promise);
442
+ }
443
+ }
444
+ return Promise.all(promises);
445
+ };
446
+ return UpgradeNg1ComponentAdapterBuilder;
447
+ })();
448
+ exports.UpgradeNg1ComponentAdapterBuilder = UpgradeNg1ComponentAdapterBuilder;
449
+ var UpgradeNg1ComponentAdapter = (function() {
450
+ function UpgradeNg1ComponentAdapter(linkFn, scope, directive, elementRef, $controller, inputs, outputs, propOuts, checkProperties, propertyMap) {
451
+ this.directive = directive;
452
+ this.inputs = inputs;
453
+ this.outputs = outputs;
454
+ this.propOuts = propOuts;
455
+ this.checkProperties = checkProperties;
456
+ this.propertyMap = propertyMap;
457
+ this.destinationObj = null;
458
+ this.checkLastValues = [];
459
+ var element = elementRef.nativeElement;
460
+ var childNodes = [];
461
+ var childNode;
462
+ while (childNode = element.firstChild) {
463
+ element.removeChild(childNode);
464
+ childNodes.push(childNode);
465
+ }
466
+ var componentScope = scope.$new(!!directive.scope);
467
+ var $element = angular.element(element);
468
+ var controllerType = directive.controller;
469
+ var controller = null;
470
+ if (controllerType) {
471
+ var locals = {
472
+ $scope: componentScope,
473
+ $element: $element
474
+ };
475
+ controller = $controller(controllerType, locals, null, directive.controllerAs);
476
+ $element.data(util_1.controllerKey(directive.name), controller);
477
+ }
478
+ var link = directive.link;
479
+ if (typeof link == 'object')
480
+ link = link.pre;
481
+ if (link) {
482
+ var attrs = NOT_SUPPORTED;
483
+ var transcludeFn = NOT_SUPPORTED;
484
+ var linkController = this.resolveRequired($element, directive.require);
485
+ directive.link(componentScope, $element, attrs, linkController, transcludeFn);
486
+ }
487
+ this.destinationObj = directive.bindToController && controller ? controller : componentScope;
488
+ linkFn(componentScope, function(clonedElement, scope) {
489
+ for (var i = 0,
490
+ ii = clonedElement.length; i < ii; i++) {
491
+ element.appendChild(clonedElement[i]);
492
+ }
493
+ }, {parentBoundTranscludeFn: function(scope, cloneAttach) {
494
+ cloneAttach(childNodes);
495
+ }});
496
+ for (var i = 0; i < inputs.length; i++) {
497
+ this[inputs[i]] = null;
498
+ }
499
+ for (var j = 0; j < outputs.length; j++) {
500
+ var emitter = this[outputs[j]] = new core_1.EventEmitter();
501
+ this.setComponentProperty(outputs[j], (function(emitter) {
502
+ return function(value) {
503
+ return emitter.emit(value);
504
+ };
505
+ })(emitter));
506
+ }
507
+ for (var k = 0; k < propOuts.length; k++) {
508
+ this[propOuts[k]] = new core_1.EventEmitter();
509
+ this.checkLastValues.push(INITIAL_VALUE);
510
+ }
511
+ }
512
+ UpgradeNg1ComponentAdapter.prototype.ngOnChanges = function(changes) {
513
+ for (var name in changes) {
514
+ if (changes.hasOwnProperty(name)) {
515
+ var change = changes[name];
516
+ this.setComponentProperty(name, change.currentValue);
517
+ }
518
+ }
519
+ };
520
+ UpgradeNg1ComponentAdapter.prototype.ngDoCheck = function() {
521
+ var count = 0;
522
+ var destinationObj = this.destinationObj;
523
+ var lastValues = this.checkLastValues;
524
+ var checkProperties = this.checkProperties;
525
+ for (var i = 0; i < checkProperties.length; i++) {
526
+ var value = destinationObj[checkProperties[i]];
527
+ var last = lastValues[i];
528
+ if (value !== last) {
529
+ if (typeof value == 'number' && isNaN(value) && typeof last == 'number' && isNaN(last)) {} else {
530
+ var eventEmitter = this[this.propOuts[i]];
531
+ eventEmitter.emit(lastValues[i] = value);
532
+ }
533
+ }
534
+ }
535
+ return count;
536
+ };
537
+ UpgradeNg1ComponentAdapter.prototype.setComponentProperty = function(name, value) {
538
+ this.destinationObj[this.propertyMap[name]] = value;
539
+ };
540
+ UpgradeNg1ComponentAdapter.prototype.resolveRequired = function($element, require) {
541
+ if (!require) {
542
+ return undefined;
543
+ } else if (typeof require == 'string') {
544
+ var name = require;
545
+ var isOptional = false;
546
+ var startParent = false;
547
+ var searchParents = false;
548
+ var ch;
549
+ if (name.charAt(0) == '?') {
550
+ isOptional = true;
551
+ name = name.substr(1);
552
+ }
553
+ if (name.charAt(0) == '^') {
554
+ searchParents = true;
555
+ name = name.substr(1);
556
+ }
557
+ if (name.charAt(0) == '^') {
558
+ startParent = true;
559
+ name = name.substr(1);
560
+ }
561
+ var key = util_1.controllerKey(name);
562
+ if (startParent)
563
+ $element = $element.parent();
564
+ var dep = searchParents ? $element.inheritedData(key) : $element.data(key);
565
+ if (!dep && !isOptional) {
566
+ throw new Error("Can not locate '" + require + "' in '" + this.directive.name + "'.");
567
+ }
568
+ return dep;
569
+ } else if (require instanceof Array) {
570
+ var deps = [];
571
+ for (var i = 0; i < require.length; i++) {
572
+ deps.push(this.resolveRequired($element, require[i]));
573
+ }
574
+ return deps;
575
+ }
576
+ throw new Error("Directive '" + this.directive.name + "' require syntax unrecognized: " + this.directive.require);
577
+ };
578
+ return UpgradeNg1ComponentAdapter;
579
+ })();
580
+ global.define = __define;
581
+ return module.exports;
582
+ });
583
+
584
+ System.register("angular2/src/upgrade/upgrade_adapter", ["angular2/core", "angular2/src/facade/async", "angular2/platform/browser", "angular2/src/upgrade/metadata", "angular2/src/upgrade/util", "angular2/src/upgrade/constants", "angular2/src/upgrade/downgrade_ng2_adapter", "angular2/src/upgrade/upgrade_ng1_adapter", "angular2/src/upgrade/angular_js"], true, function(require, exports, module) {
585
+ var global = System.global,
586
+ __define = global.define;
587
+ global.define = undefined;
588
+ var core_1 = require("angular2/core");
589
+ var async_1 = require("angular2/src/facade/async");
590
+ var browser_1 = require("angular2/platform/browser");
591
+ var metadata_1 = require("angular2/src/upgrade/metadata");
592
+ var util_1 = require("angular2/src/upgrade/util");
593
+ var constants_1 = require("angular2/src/upgrade/constants");
594
+ var downgrade_ng2_adapter_1 = require("angular2/src/upgrade/downgrade_ng2_adapter");
595
+ var upgrade_ng1_adapter_1 = require("angular2/src/upgrade/upgrade_ng1_adapter");
596
+ var angular = require("angular2/src/upgrade/angular_js");
597
+ var upgradeCount = 0;
598
+ var UpgradeAdapter = (function() {
599
+ function UpgradeAdapter() {
600
+ this.idPrefix = "NG2_UPGRADE_" + upgradeCount++ + "_";
601
+ this.upgradedComponents = [];
602
+ this.downgradedComponents = {};
603
+ this.providers = [];
604
+ }
605
+ UpgradeAdapter.prototype.downgradeNg2Component = function(type) {
606
+ this.upgradedComponents.push(type);
607
+ var info = metadata_1.getComponentInfo(type);
608
+ return ng1ComponentDirective(info, "" + this.idPrefix + info.selector + "_c");
609
+ };
610
+ UpgradeAdapter.prototype.upgradeNg1Component = function(name) {
611
+ if (this.downgradedComponents.hasOwnProperty(name)) {
612
+ return this.downgradedComponents[name].type;
613
+ } else {
614
+ return (this.downgradedComponents[name] = new upgrade_ng1_adapter_1.UpgradeNg1ComponentAdapterBuilder(name)).type;
615
+ }
616
+ };
617
+ UpgradeAdapter.prototype.bootstrap = function(element, modules, config) {
618
+ var _this = this;
619
+ var upgrade = new UpgradeAdapterRef();
620
+ var ng1Injector = null;
621
+ var platformRef = core_1.platform(browser_1.BROWSER_PROVIDERS);
622
+ var applicationRef = platformRef.application([browser_1.BROWSER_APP_PROVIDERS, core_1.provide(constants_1.NG1_INJECTOR, {useFactory: function() {
623
+ return ng1Injector;
624
+ }}), core_1.provide(constants_1.NG1_COMPILE, {useFactory: function() {
625
+ return ng1Injector.get(constants_1.NG1_COMPILE);
626
+ }}), this.providers]);
627
+ var injector = applicationRef.injector;
628
+ var ngZone = injector.get(core_1.NgZone);
629
+ var compiler = injector.get(core_1.Compiler);
630
+ var delayApplyExps = [];
631
+ var original$applyFn;
632
+ var rootScopePrototype;
633
+ var rootScope;
634
+ var hostViewFactoryRefMap = {};
635
+ var ng1Module = angular.module(this.idPrefix, modules);
636
+ var ng1compilePromise = null;
637
+ ng1Module.value(constants_1.NG2_INJECTOR, injector).value(constants_1.NG2_ZONE, ngZone).value(constants_1.NG2_COMPILER, compiler).value(constants_1.NG2_HOST_VIEW_FACTORY_REF_MAP, hostViewFactoryRefMap).value(constants_1.NG2_APP_VIEW_MANAGER, injector.get(core_1.AppViewManager)).config(['$provide', function(provide) {
638
+ provide.decorator(constants_1.NG1_ROOT_SCOPE, ['$delegate', function(rootScopeDelegate) {
639
+ rootScopePrototype = rootScopeDelegate.constructor.prototype;
640
+ if (rootScopePrototype.hasOwnProperty('$apply')) {
641
+ original$applyFn = rootScopePrototype.$apply;
642
+ rootScopePrototype.$apply = function(exp) {
643
+ return delayApplyExps.push(exp);
644
+ };
645
+ } else {
646
+ throw new Error("Failed to find '$apply' on '$rootScope'!");
647
+ }
648
+ return rootScope = rootScopeDelegate;
649
+ }]);
650
+ }]).run(['$injector', '$rootScope', function(injector, rootScope) {
651
+ ng1Injector = injector;
652
+ async_1.ObservableWrapper.subscribe(ngZone.onTurnDone, function(_) {
653
+ return ngZone.runOutsideAngular(function() {
654
+ return rootScope.$apply();
655
+ });
656
+ });
657
+ ng1compilePromise = upgrade_ng1_adapter_1.UpgradeNg1ComponentAdapterBuilder.resolve(_this.downgradedComponents, injector);
658
+ }]);
659
+ angular.element(element).data(util_1.controllerKey(constants_1.NG2_INJECTOR), injector);
660
+ ngZone.run(function() {
661
+ angular.bootstrap(element, [_this.idPrefix], config);
662
+ });
663
+ Promise.all([this.compileNg2Components(compiler, hostViewFactoryRefMap), ng1compilePromise]).then(function() {
664
+ ngZone.run(function() {
665
+ if (rootScopePrototype) {
666
+ rootScopePrototype.$apply = original$applyFn;
667
+ while (delayApplyExps.length) {
668
+ rootScope.$apply(delayApplyExps.shift());
669
+ }
670
+ upgrade._bootstrapDone(applicationRef, ng1Injector);
671
+ rootScopePrototype = null;
672
+ }
673
+ });
674
+ }, util_1.onError);
675
+ return upgrade;
676
+ };
677
+ UpgradeAdapter.prototype.addProvider = function(provider) {
678
+ this.providers.push(provider);
679
+ };
680
+ UpgradeAdapter.prototype.upgradeNg1Provider = function(name, options) {
681
+ var token = options && options.asToken || name;
682
+ this.providers.push(core_1.provide(token, {
683
+ useFactory: function(ng1Injector) {
684
+ return ng1Injector.get(name);
685
+ },
686
+ deps: [constants_1.NG1_INJECTOR]
687
+ }));
688
+ };
689
+ UpgradeAdapter.prototype.downgradeNg2Provider = function(token) {
690
+ var factory = function(injector) {
691
+ return injector.get(token);
692
+ };
693
+ factory.$inject = [constants_1.NG2_INJECTOR];
694
+ return factory;
695
+ };
696
+ UpgradeAdapter.prototype.compileNg2Components = function(compiler, hostViewFactoryRefMap) {
697
+ var _this = this;
698
+ var promises = [];
699
+ var types = this.upgradedComponents;
700
+ for (var i = 0; i < types.length; i++) {
701
+ promises.push(compiler.compileInHost(types[i]));
702
+ }
703
+ return Promise.all(promises).then(function(hostViewFactories) {
704
+ var types = _this.upgradedComponents;
705
+ for (var i = 0; i < hostViewFactories.length; i++) {
706
+ hostViewFactoryRefMap[metadata_1.getComponentInfo(types[i]).selector] = hostViewFactories[i];
707
+ }
708
+ return hostViewFactoryRefMap;
709
+ }, util_1.onError);
710
+ };
711
+ return UpgradeAdapter;
712
+ })();
713
+ exports.UpgradeAdapter = UpgradeAdapter;
714
+ function ng1ComponentDirective(info, idPrefix) {
715
+ directiveFactory.$inject = [constants_1.NG2_HOST_VIEW_FACTORY_REF_MAP, constants_1.NG2_APP_VIEW_MANAGER, constants_1.NG1_PARSE];
716
+ function directiveFactory(hostViewFactoryRefMap, viewManager, parse) {
717
+ var hostViewFactory = hostViewFactoryRefMap[info.selector];
718
+ if (!hostViewFactory)
719
+ throw new Error('Expecting HostViewFactoryRef for: ' + info.selector);
720
+ var idCount = 0;
721
+ return {
722
+ restrict: 'E',
723
+ require: constants_1.REQUIRE_INJECTOR,
724
+ link: {post: function(scope, element, attrs, parentInjector, transclude) {
725
+ var domElement = element[0];
726
+ var facade = new downgrade_ng2_adapter_1.DowngradeNg2ComponentAdapter(idPrefix + (idCount++), info, element, attrs, scope, parentInjector, parse, viewManager, hostViewFactory);
727
+ facade.setupInputs();
728
+ facade.bootstrapNg2();
729
+ facade.projectContent();
730
+ facade.setupOutputs();
731
+ facade.registerCleanup();
732
+ }}
733
+ };
734
+ }
735
+ return directiveFactory;
736
+ }
737
+ var UpgradeAdapterRef = (function() {
738
+ function UpgradeAdapterRef() {
739
+ this._readyFn = null;
740
+ this.ng1RootScope = null;
741
+ this.ng1Injector = null;
742
+ this.ng2ApplicationRef = null;
743
+ this.ng2Injector = null;
744
+ }
745
+ UpgradeAdapterRef.prototype._bootstrapDone = function(applicationRef, ng1Injector) {
746
+ this.ng2ApplicationRef = applicationRef;
747
+ this.ng2Injector = applicationRef.injector;
748
+ this.ng1Injector = ng1Injector;
749
+ this.ng1RootScope = ng1Injector.get(constants_1.NG1_ROOT_SCOPE);
750
+ this._readyFn && this._readyFn(this);
751
+ };
752
+ UpgradeAdapterRef.prototype.ready = function(fn) {
753
+ this._readyFn = fn;
754
+ };
755
+ UpgradeAdapterRef.prototype.dispose = function() {
756
+ this.ng1Injector.get(constants_1.NG1_ROOT_SCOPE).$destroy();
757
+ this.ng2ApplicationRef.dispose();
758
+ };
759
+ return UpgradeAdapterRef;
760
+ })();
761
+ exports.UpgradeAdapterRef = UpgradeAdapterRef;
762
+ global.define = __define;
763
+ return module.exports;
764
+ });
765
+
766
+ System.register("angular2/upgrade", ["angular2/src/upgrade/upgrade_adapter"], true, function(require, exports, module) {
767
+ var global = System.global,
768
+ __define = global.define;
769
+ global.define = undefined;
770
+ var upgrade_adapter_1 = require("angular2/src/upgrade/upgrade_adapter");
771
+ exports.UpgradeAdapter = upgrade_adapter_1.UpgradeAdapter;
772
+ exports.UpgradeAdapterRef = upgrade_adapter_1.UpgradeAdapterRef;
773
+ global.define = __define;
774
+ return module.exports;
775
+ });
776
+
777
+ //# sourceMappingURLDisabled=upgrade.js.map