@angular/upgrade 0.0.0-6 → 2.0.0-rc.2
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.
- package/{upgrade.umd.js → bundles/upgrade.umd.js} +165 -141
- package/bundles/upgrade.umd.min.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/src/angular_js.d.ts +1 -0
- package/esm/src/angular_js.js.map +1 -1
- package/esm/src/angular_js.metadata.json +1 -1
- package/esm/src/constants.js +1 -1
- package/esm/src/constants.js.map +1 -1
- package/esm/src/constants.metadata.json +1 -1
- package/esm/src/downgrade_ng2_adapter.d.ts +3 -5
- package/esm/src/downgrade_ng2_adapter.js +9 -9
- package/esm/src/downgrade_ng2_adapter.js.map +1 -1
- package/esm/src/metadata.js +1 -1
- package/esm/src/metadata.js.map +1 -1
- package/esm/src/upgrade_adapter.d.ts +1 -8
- package/esm/src/upgrade_adapter.js +56 -48
- package/esm/src/upgrade_adapter.js.map +1 -1
- package/esm/src/upgrade_ng1_adapter.js +39 -27
- package/esm/src/upgrade_ng1_adapter.js.map +1 -1
- package/esm/src/util.js.map +1 -1
- package/esm/src/util.metadata.json +1 -0
- package/esm/upgrade.js +4 -4
- package/esm/upgrade.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +8 -4
- package/src/angular_js.d.ts +1 -0
- package/src/angular_js.js.map +1 -1
- package/src/angular_js.metadata.json +1 -1
- package/src/constants.js +1 -1
- package/src/constants.js.map +1 -1
- package/src/constants.metadata.json +1 -1
- package/src/downgrade_ng2_adapter.d.ts +3 -5
- package/src/downgrade_ng2_adapter.js +18 -14
- package/src/downgrade_ng2_adapter.js.map +1 -1
- package/src/metadata.js +1 -1
- package/src/metadata.js.map +1 -1
- package/src/upgrade_adapter.d.ts +1 -8
- package/src/upgrade_adapter.js +58 -46
- package/src/upgrade_adapter.js.map +1 -1
- package/src/upgrade_ng1_adapter.js +40 -26
- package/src/upgrade_ng1_adapter.js.map +1 -1
- package/src/util.js.map +1 -1
- package/src/util.metadata.json +1 -0
- package/upgrade.js +4 -4
- package/upgrade.js.map +1 -1
- package/esm/upgrade.umd.js.map +0 -1
|
@@ -1,56 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license AngularJS v2.0.0-rc.2
|
|
3
|
+
* (c) 2010-2016 Google, Inc. https://angular.io/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
1
6
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/platform-browser
|
|
4
|
-
(factory((global.ng = global.ng || {}, global.ng.upgrade = global.ng.upgrade || {}), global.ng.core, global.ng.
|
|
5
|
-
}(this, function (exports, _angular_core,
|
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@angular/platform-browser-dynamic'), require('@angular/compiler')) :
|
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/compiler'], factory) :
|
|
9
|
+
(factory((global.ng = global.ng || {}, global.ng.upgrade = global.ng.upgrade || {}), global.ng.core, global.ng.platformBrowser, global.ng.platformBrowser.dynamic, global.ng.compiler));
|
|
10
|
+
}(this, function (exports, _angular_core, _angular_platformBrowser, _angular_platformBrowserDynamic, _angular_compiler) {
|
|
6
11
|
'use strict';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var directiveResolver = new _angular_compiler.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) { return letter.toUpperCase(); });
|
|
17
|
-
return {
|
|
18
|
-
type: type,
|
|
19
|
-
selector: selector,
|
|
20
|
-
inputs: parseFields(resolvedMetadata.inputs),
|
|
21
|
-
outputs: parseFields(resolvedMetadata.outputs)
|
|
22
|
-
};
|
|
12
|
+
function noNg() {
|
|
13
|
+
throw new Error('AngularJS v1.x is not loaded!');
|
|
23
14
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
bracketAttr: "[" + attr + "]",
|
|
36
|
-
parenAttr: "(" + attr + ")",
|
|
37
|
-
bracketParenAttr: "[(" + attr + ")]",
|
|
38
|
-
onAttr: "on" + capitalAttr,
|
|
39
|
-
bindAttr: "bind" + capitalAttr,
|
|
40
|
-
bindonAttr: "bindon" + capitalAttr
|
|
41
|
-
});
|
|
42
|
-
}
|
|
15
|
+
var angular = {
|
|
16
|
+
bootstrap: noNg,
|
|
17
|
+
module: noNg,
|
|
18
|
+
element: noNg,
|
|
19
|
+
version: noNg,
|
|
20
|
+
resumeBootstrap: noNg,
|
|
21
|
+
getTestability: noNg
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
if (window.hasOwnProperty('angular')) {
|
|
25
|
+
angular = window.angular;
|
|
43
26
|
}
|
|
44
|
-
return attrProps;
|
|
45
27
|
}
|
|
46
|
-
|
|
47
|
-
// TODO: (misko): We seem to not have a stack trace here!
|
|
48
|
-
console.log(e, e.stack);
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
function controllerKey(name) {
|
|
52
|
-
return '$' + name + 'Controller';
|
|
28
|
+
catch (e) {
|
|
53
29
|
}
|
|
30
|
+
var bootstrap = angular.bootstrap;
|
|
31
|
+
var module$1 = angular.module;
|
|
32
|
+
var element = angular.element;
|
|
54
33
|
var NG2_COMPILER = 'ng2.Compiler';
|
|
55
34
|
var NG2_INJECTOR = 'ng2.Injector';
|
|
56
35
|
var NG2_COMPONENT_FACTORY_REF_MAP = 'ng2.ComponentFactoryRefMap';
|
|
@@ -64,7 +43,7 @@
|
|
|
64
43
|
var NG1_PARSE = '$parse';
|
|
65
44
|
var NG1_TEMPLATE_CACHE = '$templateCache';
|
|
66
45
|
var NG1_TESTABILITY = '$$testability';
|
|
67
|
-
var REQUIRE_INJECTOR = '
|
|
46
|
+
var REQUIRE_INJECTOR = '?^' + NG2_INJECTOR;
|
|
68
47
|
var INITIAL_VALUE = {
|
|
69
48
|
__UNINITIALIZED__: true
|
|
70
49
|
};
|
|
@@ -89,10 +68,9 @@
|
|
|
89
68
|
this.childNodes = element.contents();
|
|
90
69
|
}
|
|
91
70
|
DowngradeNg2ComponentAdapter.prototype.bootstrapNg2 = function () {
|
|
92
|
-
var childInjector = _angular_core.ReflectiveInjector.resolveAndCreate([
|
|
71
|
+
var childInjector = _angular_core.ReflectiveInjector.resolveAndCreate([{ provide: NG1_SCOPE, useValue: this.componentScope }], this.parentInjector);
|
|
93
72
|
this.contentInsertionPoint = document.createComment('ng1 insertion point');
|
|
94
|
-
this.componentRef =
|
|
95
|
-
this.componentFactory.create(childInjector, [[this.contentInsertionPoint]], '#' + this.id);
|
|
73
|
+
this.componentRef = this.componentFactory.create(childInjector, [[this.contentInsertionPoint]], this.element[0]);
|
|
96
74
|
this.changeDetector = this.componentRef.changeDetectorRef;
|
|
97
75
|
this.component = this.componentRef.instance;
|
|
98
76
|
};
|
|
@@ -104,9 +82,9 @@
|
|
|
104
82
|
var input = inputs[i];
|
|
105
83
|
var expr = null;
|
|
106
84
|
if (attrs.hasOwnProperty(input.attr)) {
|
|
107
|
-
var observeFn = (function (prop) {
|
|
85
|
+
var observeFn = (function (prop /** TODO #9100 */) {
|
|
108
86
|
var prevValue = INITIAL_VALUE;
|
|
109
|
-
return function (value) {
|
|
87
|
+
return function (value /** TODO #9100 */) {
|
|
110
88
|
if (_this.inputChanges !== null) {
|
|
111
89
|
_this.inputChangeCount++;
|
|
112
90
|
_this.inputChanges[prop] =
|
|
@@ -131,7 +109,7 @@
|
|
|
131
109
|
expr = attrs[input.bracketParenAttr];
|
|
132
110
|
}
|
|
133
111
|
if (expr != null) {
|
|
134
|
-
var watchFn = (function (prop) { return function (value
|
|
112
|
+
var watchFn = (function (prop /** TODO #9100 */) { return function (value /** TODO #9100 */, prevValue /** TODO #9100 */) {
|
|
135
113
|
if (_this.inputChanges != null) {
|
|
136
114
|
_this.inputChangeCount++;
|
|
137
115
|
_this.inputChanges[prop] = new Ng1Change(prevValue, value);
|
|
@@ -197,8 +175,9 @@
|
|
|
197
175
|
var emitter = this.component[output.prop];
|
|
198
176
|
if (emitter) {
|
|
199
177
|
emitter.subscribe({
|
|
200
|
-
next: assignExpr ?
|
|
201
|
-
(function (
|
|
178
|
+
next: assignExpr ?
|
|
179
|
+
(function (setter) { return function (v /** TODO #9100 */) { return setter(_this.scope, v); }; })(setter) :
|
|
180
|
+
(function (getter) { return function (v /** TODO #9100 */) { return getter(_this.scope, { $event: v }); }; })(getter)
|
|
202
181
|
});
|
|
203
182
|
}
|
|
204
183
|
else {
|
|
@@ -224,27 +203,53 @@
|
|
|
224
203
|
Ng1Change.prototype.isFirstChange = function () { return this.previousValue === this.currentValue; };
|
|
225
204
|
return Ng1Change;
|
|
226
205
|
}());
|
|
227
|
-
|
|
228
|
-
|
|
206
|
+
var COMPONENT_SELECTOR = /^[\w|-]*$/;
|
|
207
|
+
var SKEWER_CASE = /-(\w)/g;
|
|
208
|
+
var directiveResolver = new _angular_compiler.DirectiveResolver();
|
|
209
|
+
function getComponentInfo(type) {
|
|
210
|
+
var resolvedMetadata = directiveResolver.resolve(type);
|
|
211
|
+
var selector = resolvedMetadata.selector;
|
|
212
|
+
if (!selector.match(COMPONENT_SELECTOR)) {
|
|
213
|
+
throw new Error('Only selectors matching element names are supported, got: ' + selector);
|
|
214
|
+
}
|
|
215
|
+
var selector = selector.replace(SKEWER_CASE, function (all /** TODO #9100 */, letter) { return letter.toUpperCase(); });
|
|
216
|
+
return {
|
|
217
|
+
type: type,
|
|
218
|
+
selector: selector,
|
|
219
|
+
inputs: parseFields(resolvedMetadata.inputs),
|
|
220
|
+
outputs: parseFields(resolvedMetadata.outputs)
|
|
221
|
+
};
|
|
229
222
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
223
|
+
function parseFields(names) {
|
|
224
|
+
var attrProps = [];
|
|
225
|
+
if (names) {
|
|
226
|
+
for (var i = 0; i < names.length; i++) {
|
|
227
|
+
var parts = names[i].split(':');
|
|
228
|
+
var prop = parts[0].trim();
|
|
229
|
+
var attr = (parts[1] || parts[0]).trim();
|
|
230
|
+
var capitalAttr = attr.charAt(0).toUpperCase() + attr.substr(1);
|
|
231
|
+
attrProps.push({
|
|
232
|
+
prop: prop,
|
|
233
|
+
attr: attr,
|
|
234
|
+
bracketAttr: "[" + attr + "]",
|
|
235
|
+
parenAttr: "(" + attr + ")",
|
|
236
|
+
bracketParenAttr: "[(" + attr + ")]",
|
|
237
|
+
onAttr: "on" + capitalAttr,
|
|
238
|
+
bindAttr: "bind" + capitalAttr,
|
|
239
|
+
bindonAttr: "bindon" + capitalAttr
|
|
240
|
+
});
|
|
241
|
+
}
|
|
241
242
|
}
|
|
243
|
+
return attrProps;
|
|
242
244
|
}
|
|
243
|
-
|
|
245
|
+
function onError(e) {
|
|
246
|
+
// TODO: (misko): We seem to not have a stack trace here!
|
|
247
|
+
console.log(e, e.stack);
|
|
248
|
+
throw e;
|
|
249
|
+
}
|
|
250
|
+
function controllerKey(name) {
|
|
251
|
+
return '$' + name + 'Controller';
|
|
244
252
|
}
|
|
245
|
-
var bootstrap = angular.bootstrap;
|
|
246
|
-
var module$1 = angular.module;
|
|
247
|
-
var element = angular.element;
|
|
248
253
|
var CAMEL_CASE = /([A-Z])/g;
|
|
249
254
|
var INITIAL_VALUE$1 = {
|
|
250
255
|
__UNINITIALIZED__: true
|
|
@@ -263,14 +268,13 @@
|
|
|
263
268
|
this.linkFn = null;
|
|
264
269
|
this.directive = null;
|
|
265
270
|
this.$controller = null;
|
|
266
|
-
var selector = name.replace(CAMEL_CASE, function (all
|
|
271
|
+
var selector = name.replace(CAMEL_CASE, function (all /** TODO #9100 */, next) { return '-' + next.toLowerCase(); });
|
|
267
272
|
var self = this;
|
|
268
273
|
this.type =
|
|
269
274
|
_angular_core.Directive({ selector: selector, inputs: this.inputsRename, outputs: this.outputsRename })
|
|
270
275
|
.Class({
|
|
271
276
|
constructor: [
|
|
272
|
-
new _angular_core.Inject(NG1_SCOPE),
|
|
273
|
-
_angular_core.ElementRef,
|
|
277
|
+
new _angular_core.Inject(NG1_SCOPE), _angular_core.ElementRef,
|
|
274
278
|
function (scope, elementRef) {
|
|
275
279
|
return new UpgradeNg1ComponentAdapter(self.linkFn, scope, self.directive, elementRef, self.$controller, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
|
|
276
280
|
}
|
|
@@ -348,17 +352,19 @@
|
|
|
348
352
|
UpgradeNg1ComponentAdapterBuilder.prototype.compileTemplate = function (compile, templateCache, httpBackend) {
|
|
349
353
|
var _this = this;
|
|
350
354
|
if (this.directive.template !== undefined) {
|
|
351
|
-
this.linkFn = compileHtml(this.directive.template)
|
|
355
|
+
this.linkFn = compileHtml(typeof this.directive.template === 'function' ? this.directive.template() :
|
|
356
|
+
this.directive.template);
|
|
352
357
|
}
|
|
353
358
|
else if (this.directive.templateUrl) {
|
|
354
|
-
var url = this.directive.templateUrl
|
|
359
|
+
var url = typeof this.directive.templateUrl === 'function' ? this.directive.templateUrl() :
|
|
360
|
+
this.directive.templateUrl;
|
|
355
361
|
var html = templateCache.get(url);
|
|
356
362
|
if (html !== undefined) {
|
|
357
363
|
this.linkFn = compileHtml(html);
|
|
358
364
|
}
|
|
359
365
|
else {
|
|
360
366
|
return new Promise(function (resolve, err) {
|
|
361
|
-
httpBackend('GET', url, null, function (status
|
|
367
|
+
httpBackend('GET', url, null, function (status /** TODO #9100 */, response /** TODO #9100 */) {
|
|
362
368
|
if (status == 200) {
|
|
363
369
|
resolve(_this.linkFn = compileHtml(templateCache.put(url, response)));
|
|
364
370
|
}
|
|
@@ -373,7 +379,7 @@
|
|
|
373
379
|
throw new Error("Directive '" + this.name + "' is not a component, it is missing template.");
|
|
374
380
|
}
|
|
375
381
|
return null;
|
|
376
|
-
function compileHtml(html) {
|
|
382
|
+
function compileHtml(html /** TODO #9100 */) {
|
|
377
383
|
var div = document.createElement('div');
|
|
378
384
|
div.innerHTML = html;
|
|
379
385
|
return compile(div.childNodes);
|
|
@@ -404,6 +410,7 @@
|
|
|
404
410
|
function UpgradeNg1ComponentAdapter(linkFn, scope, directive, elementRef, $controller, inputs, outputs, propOuts, checkProperties, propertyMap) {
|
|
405
411
|
this.linkFn = linkFn;
|
|
406
412
|
this.directive = directive;
|
|
413
|
+
this.$controller = $controller;
|
|
407
414
|
this.inputs = inputs;
|
|
408
415
|
this.outputs = outputs;
|
|
409
416
|
this.propOuts = propOuts;
|
|
@@ -411,33 +418,23 @@
|
|
|
411
418
|
this.propertyMap = propertyMap;
|
|
412
419
|
this.destinationObj = null;
|
|
413
420
|
this.checkLastValues = [];
|
|
421
|
+
this.$element = null;
|
|
414
422
|
this.element = elementRef.nativeElement;
|
|
415
423
|
this.componentScope = scope.$new(!!directive.scope);
|
|
416
|
-
|
|
424
|
+
this.$element = element(this.element);
|
|
417
425
|
var controllerType = directive.controller;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
var locals = { $scope: this.componentScope, $element: $element };
|
|
421
|
-
controller = $controller(controllerType, locals, null, directive.controllerAs);
|
|
422
|
-
$element.data(controllerKey(directive.name), controller);
|
|
426
|
+
if (directive.bindToController && controllerType) {
|
|
427
|
+
this.destinationObj = this.buildController(controllerType);
|
|
423
428
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
link = link.pre;
|
|
427
|
-
if (link) {
|
|
428
|
-
var attrs = NOT_SUPPORTED;
|
|
429
|
-
var transcludeFn = NOT_SUPPORTED;
|
|
430
|
-
var linkController = this.resolveRequired($element, directive.require);
|
|
431
|
-
directive.link(this.componentScope, $element, attrs, linkController, transcludeFn);
|
|
429
|
+
else {
|
|
430
|
+
this.destinationObj = this.componentScope;
|
|
432
431
|
}
|
|
433
|
-
this.destinationObj =
|
|
434
|
-
directive.bindToController && controller ? controller : this.componentScope;
|
|
435
432
|
for (var i = 0; i < inputs.length; i++) {
|
|
436
433
|
this[inputs[i]] = null;
|
|
437
434
|
}
|
|
438
435
|
for (var j = 0; j < outputs.length; j++) {
|
|
439
436
|
var emitter = this[outputs[j]] = new _angular_core.EventEmitter();
|
|
440
|
-
this.setComponentProperty(outputs[j], (function (emitter) { return function (value) { return emitter.emit(value); }; })(emitter));
|
|
437
|
+
this.setComponentProperty(outputs[j], (function (emitter /** TODO #9100 */) { return function (value /** TODO #9100 */) { return emitter.emit(value); }; })(emitter));
|
|
441
438
|
}
|
|
442
439
|
for (var k = 0; k < propOuts.length; k++) {
|
|
443
440
|
this[propOuts[k]] = new _angular_core.EventEmitter();
|
|
@@ -446,6 +443,18 @@
|
|
|
446
443
|
}
|
|
447
444
|
UpgradeNg1ComponentAdapter.prototype.ngOnInit = function () {
|
|
448
445
|
var _this = this;
|
|
446
|
+
if (!this.directive.bindToController && this.directive.controller) {
|
|
447
|
+
this.buildController(this.directive.controller);
|
|
448
|
+
}
|
|
449
|
+
var link = this.directive.link;
|
|
450
|
+
if (typeof link == 'object')
|
|
451
|
+
link = link.pre;
|
|
452
|
+
if (link) {
|
|
453
|
+
var attrs = NOT_SUPPORTED;
|
|
454
|
+
var transcludeFn = NOT_SUPPORTED;
|
|
455
|
+
var linkController = this.resolveRequired(this.$element, this.directive.require);
|
|
456
|
+
this.directive.link(this.componentScope, this.$element, attrs, linkController, transcludeFn);
|
|
457
|
+
}
|
|
449
458
|
var childNodes = [];
|
|
450
459
|
var childNode;
|
|
451
460
|
while (childNode = this.element.firstChild) {
|
|
@@ -456,7 +465,9 @@
|
|
|
456
465
|
for (var i = 0, ii = clonedElement.length; i < ii; i++) {
|
|
457
466
|
_this.element.appendChild(clonedElement[i]);
|
|
458
467
|
}
|
|
459
|
-
}, {
|
|
468
|
+
}, {
|
|
469
|
+
parentBoundTranscludeFn: function (scope /** TODO #9100 */, cloneAttach /** TODO #9100 */) { cloneAttach(childNodes); }
|
|
470
|
+
});
|
|
460
471
|
if (this.destinationObj.$onInit) {
|
|
461
472
|
this.destinationObj.$onInit();
|
|
462
473
|
}
|
|
@@ -491,6 +502,12 @@
|
|
|
491
502
|
UpgradeNg1ComponentAdapter.prototype.setComponentProperty = function (name, value) {
|
|
492
503
|
this.destinationObj[this.propertyMap[name]] = value;
|
|
493
504
|
};
|
|
505
|
+
UpgradeNg1ComponentAdapter.prototype.buildController = function (controllerType /** TODO #9100 */) {
|
|
506
|
+
var locals = { $scope: this.componentScope, $element: this.$element };
|
|
507
|
+
var controller = this.$controller(controllerType, locals, null, this.directive.controllerAs);
|
|
508
|
+
this.$element.data(controllerKey(this.directive.name), controller);
|
|
509
|
+
return controller;
|
|
510
|
+
};
|
|
494
511
|
UpgradeNg1ComponentAdapter.prototype.resolveRequired = function ($element, require) {
|
|
495
512
|
if (!require) {
|
|
496
513
|
return undefined;
|
|
@@ -792,10 +809,11 @@
|
|
|
792
809
|
var upgrade = new UpgradeAdapterRef();
|
|
793
810
|
var ng1Injector = null;
|
|
794
811
|
var platformRef = _angular_platformBrowser.browserPlatform();
|
|
795
|
-
var applicationRef = _angular_core.ReflectiveInjector
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
812
|
+
var applicationRef = _angular_core.ReflectiveInjector
|
|
813
|
+
.resolveAndCreate([
|
|
814
|
+
_angular_platformBrowser.BROWSER_APP_PROVIDERS, _angular_platformBrowserDynamic.BROWSER_APP_COMPILER_PROVIDERS,
|
|
815
|
+
{ provide: NG1_INJECTOR, useFactory: function () { return ng1Injector; } },
|
|
816
|
+
{ provide: NG1_COMPILE, useFactory: function () { return ng1Injector.get(NG1_COMPILE); } },
|
|
799
817
|
this.providers
|
|
800
818
|
], platformRef.injector)
|
|
801
819
|
.get(_angular_core.ApplicationRef);
|
|
@@ -815,52 +833,55 @@
|
|
|
815
833
|
.value(NG2_COMPILER, compiler)
|
|
816
834
|
.value(NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)
|
|
817
835
|
.config([
|
|
818
|
-
'$provide',
|
|
819
|
-
function (provide) {
|
|
836
|
+
'$provide', '$injector',
|
|
837
|
+
function (provide /** TODO #???? */, ng1Injector /** TODO #???? */) {
|
|
820
838
|
provide.decorator(NG1_ROOT_SCOPE, [
|
|
821
839
|
'$delegate',
|
|
822
840
|
function (rootScopeDelegate) {
|
|
823
841
|
rootScopePrototype = rootScopeDelegate.constructor.prototype;
|
|
824
842
|
if (rootScopePrototype.hasOwnProperty('$apply')) {
|
|
825
843
|
original$applyFn = rootScopePrototype.$apply;
|
|
826
|
-
rootScopePrototype.$apply = function (exp) { return delayApplyExps.push(exp); };
|
|
844
|
+
rootScopePrototype.$apply = function (exp /** TODO #???? */) { return delayApplyExps.push(exp); };
|
|
827
845
|
}
|
|
828
846
|
else {
|
|
829
|
-
throw new Error(
|
|
847
|
+
throw new Error('Failed to find \'$apply\' on \'$rootScope\'!');
|
|
830
848
|
}
|
|
831
849
|
return rootScope = rootScopeDelegate;
|
|
832
850
|
}
|
|
833
851
|
]);
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
852
|
+
if (ng1Injector.has(NG1_TESTABILITY)) {
|
|
853
|
+
provide.decorator(NG1_TESTABILITY, [
|
|
854
|
+
'$delegate',
|
|
855
|
+
function (testabilityDelegate) {
|
|
856
|
+
var _this = this;
|
|
857
|
+
var ng2Testability = injector.get(_angular_core.Testability);
|
|
858
|
+
var origonalWhenStable = testabilityDelegate.whenStable;
|
|
859
|
+
var newWhenStable = function (callback) {
|
|
860
|
+
var whenStableContext = _this;
|
|
861
|
+
origonalWhenStable.call(_this, function () {
|
|
862
|
+
if (ng2Testability.isStable()) {
|
|
863
|
+
callback.apply(this, arguments);
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
};
|
|
870
|
+
testabilityDelegate.whenStable = newWhenStable;
|
|
871
|
+
return testabilityDelegate;
|
|
872
|
+
}
|
|
873
|
+
]);
|
|
874
|
+
}
|
|
855
875
|
}
|
|
856
876
|
]);
|
|
857
877
|
ng1compilePromise = new Promise(function (resolve, reject) {
|
|
858
878
|
ng1Module.run([
|
|
859
|
-
'$injector',
|
|
860
|
-
'$rootScope',
|
|
879
|
+
'$injector', '$rootScope',
|
|
861
880
|
function (injector, rootScope) {
|
|
862
881
|
ng1Injector = injector;
|
|
863
|
-
ngZone.onMicrotaskEmpty.subscribe({
|
|
882
|
+
ngZone.onMicrotaskEmpty.subscribe({
|
|
883
|
+
next: function (_ /** TODO #???? */) { return ngZone.runOutsideAngular(function () { return rootScope.$evalAsync(); }); }
|
|
884
|
+
});
|
|
864
885
|
UpgradeNg1ComponentAdapterBuilder.resolve(_this.downgradedComponents, injector)
|
|
865
886
|
.then(resolve, reject);
|
|
866
887
|
}
|
|
@@ -884,9 +905,9 @@
|
|
|
884
905
|
resolve();
|
|
885
906
|
}
|
|
886
907
|
});
|
|
887
|
-
Promise
|
|
888
|
-
|
|
889
|
-
ng1BootstrapPromise,
|
|
908
|
+
Promise
|
|
909
|
+
.all([
|
|
910
|
+
this.compileNg2Components(compiler, componentFactoryRefMap), ng1BootstrapPromise,
|
|
890
911
|
ng1compilePromise
|
|
891
912
|
])
|
|
892
913
|
.then(function () {
|
|
@@ -974,10 +995,11 @@
|
|
|
974
995
|
*/
|
|
975
996
|
UpgradeAdapter.prototype.upgradeNg1Provider = function (name, options) {
|
|
976
997
|
var token = options && options.asToken || name;
|
|
977
|
-
this.providers.push(
|
|
998
|
+
this.providers.push({
|
|
999
|
+
provide: token,
|
|
978
1000
|
useFactory: function (ng1Injector) { return ng1Injector.get(name); },
|
|
979
1001
|
deps: [NG1_INJECTOR]
|
|
980
|
-
})
|
|
1002
|
+
});
|
|
981
1003
|
};
|
|
982
1004
|
/**
|
|
983
1005
|
* Allows Angular v2 service to be accessible from AngularJS v1.
|
|
@@ -1025,18 +1047,21 @@
|
|
|
1025
1047
|
return UpgradeAdapter;
|
|
1026
1048
|
}());
|
|
1027
1049
|
function ng1ComponentDirective(info, idPrefix) {
|
|
1028
|
-
directiveFactory.$inject = [NG2_COMPONENT_FACTORY_REF_MAP, NG1_PARSE];
|
|
1029
|
-
function directiveFactory(componentFactoryRefMap, parse) {
|
|
1030
|
-
var componentFactory = componentFactoryRefMap[info.selector];
|
|
1031
|
-
if (!componentFactory)
|
|
1032
|
-
throw new Error('Expecting ComponentFactory for: ' + info.selector);
|
|
1050
|
+
directiveFactory.$inject = [NG1_INJECTOR, NG2_COMPONENT_FACTORY_REF_MAP, NG1_PARSE];
|
|
1051
|
+
function directiveFactory(ng1Injector, componentFactoryRefMap, parse) {
|
|
1033
1052
|
var idCount = 0;
|
|
1034
1053
|
return {
|
|
1035
1054
|
restrict: 'E',
|
|
1036
1055
|
require: REQUIRE_INJECTOR,
|
|
1037
1056
|
link: {
|
|
1038
1057
|
post: function (scope, element, attrs, parentInjector, transclude) {
|
|
1058
|
+
var componentFactory = componentFactoryRefMap[info.selector];
|
|
1059
|
+
if (!componentFactory)
|
|
1060
|
+
throw new Error('Expecting ComponentFactory for: ' + info.selector);
|
|
1039
1061
|
var domElement = element[0];
|
|
1062
|
+
if (parentInjector === null) {
|
|
1063
|
+
parentInjector = ng1Injector.get(NG2_INJECTOR);
|
|
1064
|
+
}
|
|
1040
1065
|
var facade = new DowngradeNg2ComponentAdapter(idPrefix + (idCount++), info, element, attrs, scope, parentInjector, parse, componentFactory);
|
|
1041
1066
|
facade.setupInputs();
|
|
1042
1067
|
facade.bootstrapNg2();
|
|
@@ -1089,4 +1114,3 @@
|
|
|
1089
1114
|
exports.UpgradeAdapter = UpgradeAdapter;
|
|
1090
1115
|
exports.UpgradeAdapterRef = UpgradeAdapterRef;
|
|
1091
1116
|
}));
|
|
1092
|
-
//# sourceMappingURL=upgrade.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/platform-browser"),require("@angular/platform-browser-dynamic"),require("@angular/compiler")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/platform-browser","@angular/platform-browser-dynamic","@angular/compiler"],factory):factory((global.ng=global.ng||{},global.ng.upgrade=global.ng.upgrade||{}),global.ng.core,global.ng.platformBrowser,global.ng.platformBrowser.dynamic,global.ng.compiler)}(this,function(exports,_angular_core,_angular_platformBrowser,_angular_platformBrowserDynamic,_angular_compiler){"use strict";function noNg(){throw new Error("AngularJS v1.x is not loaded!")}function getComponentInfo(type){var resolvedMetadata=directiveResolver.resolve(type),selector=resolvedMetadata.selector;if(!selector.match(COMPONENT_SELECTOR))throw new Error("Only selectors matching element names are supported, got: "+selector);var selector=selector.replace(SKEWER_CASE,function(all,letter){return letter.toUpperCase()});return{type:type,selector:selector,inputs:parseFields(resolvedMetadata.inputs),outputs:parseFields(resolvedMetadata.outputs)}}function parseFields(names){var attrProps=[];if(names)for(var i=0;i<names.length;i++){var parts=names[i].split(":"),prop=parts[0].trim(),attr=(parts[1]||parts[0]).trim(),capitalAttr=attr.charAt(0).toUpperCase()+attr.substr(1);attrProps.push({prop:prop,attr:attr,bracketAttr:"["+attr+"]",parenAttr:"("+attr+")",bracketParenAttr:"[("+attr+")]",onAttr:"on"+capitalAttr,bindAttr:"bind"+capitalAttr,bindonAttr:"bindon"+capitalAttr})}return attrProps}function onError(e){throw console.log(e,e.stack),e}function controllerKey(name){return"$"+name+"Controller"}function ng1ComponentDirective(info,idPrefix){function directiveFactory(ng1Injector,componentFactoryRefMap,parse){var idCount=0;return{restrict:"E",require:REQUIRE_INJECTOR,link:{post:function(scope,element,attrs,parentInjector){var componentFactory=componentFactoryRefMap[info.selector];if(!componentFactory)throw new Error("Expecting ComponentFactory for: "+info.selector);element[0],null===parentInjector&&(parentInjector=ng1Injector.get(NG2_INJECTOR));var facade=new DowngradeNg2ComponentAdapter(idPrefix+idCount++,info,element,attrs,scope,parentInjector,parse,componentFactory);facade.setupInputs(),facade.bootstrapNg2(),facade.projectContent(),facade.setupOutputs(),facade.registerCleanup()}}}}return directiveFactory.$inject=[NG1_INJECTOR,NG2_COMPONENT_FACTORY_REF_MAP,NG1_PARSE],directiveFactory}var angular={bootstrap:noNg,module:noNg,element:noNg,version:noNg,resumeBootstrap:noNg,getTestability:noNg};try{window.hasOwnProperty("angular")&&(angular=window.angular)}catch(e){}var bootstrap=angular.bootstrap,module$1=angular.module,element=angular.element,NG2_COMPILER="ng2.Compiler",NG2_INJECTOR="ng2.Injector",NG2_COMPONENT_FACTORY_REF_MAP="ng2.ComponentFactoryRefMap",NG2_ZONE="ng2.NgZone",NG1_CONTROLLER="$controller",NG1_SCOPE="$scope",NG1_ROOT_SCOPE="$rootScope",NG1_COMPILE="$compile",NG1_HTTP_BACKEND="$httpBackend",NG1_INJECTOR="$injector",NG1_PARSE="$parse",NG1_TEMPLATE_CACHE="$templateCache",NG1_TESTABILITY="$$testability",REQUIRE_INJECTOR="?^"+NG2_INJECTOR,INITIAL_VALUE={__UNINITIALIZED__:!0},DowngradeNg2ComponentAdapter=function(){function DowngradeNg2ComponentAdapter(id,info,element,attrs,scope,parentInjector,parse,componentFactory){this.id=id,this.info=info,this.element=element,this.attrs=attrs,this.scope=scope,this.parentInjector=parentInjector,this.parse=parse,this.componentFactory=componentFactory,this.component=null,this.inputChangeCount=0,this.inputChanges=null,this.componentRef=null,this.changeDetector=null,this.contentInsertionPoint=null,this.element[0].id=id,this.componentScope=scope.$new(),this.childNodes=element.contents()}return DowngradeNg2ComponentAdapter.prototype.bootstrapNg2=function(){var childInjector=_angular_core.ReflectiveInjector.resolveAndCreate([{provide:NG1_SCOPE,useValue:this.componentScope}],this.parentInjector);this.contentInsertionPoint=document.createComment("ng1 insertion point"),this.componentRef=this.componentFactory.create(childInjector,[[this.contentInsertionPoint]],this.element[0]),this.changeDetector=this.componentRef.changeDetectorRef,this.component=this.componentRef.instance},DowngradeNg2ComponentAdapter.prototype.setupInputs=function(){for(var _this=this,attrs=this.attrs,inputs=this.info.inputs,i=0;i<inputs.length;i++){var input=inputs[i],expr=null;if(attrs.hasOwnProperty(input.attr)){var observeFn=function(prop){var prevValue=INITIAL_VALUE;return function(value){null!==_this.inputChanges&&(_this.inputChangeCount++,_this.inputChanges[prop]=new Ng1Change(value,prevValue===INITIAL_VALUE?value:prevValue),prevValue=value),_this.component[prop]=value}}(input.prop);attrs.$observe(input.attr,observeFn)}else attrs.hasOwnProperty(input.bindAttr)?expr=attrs[input.bindAttr]:attrs.hasOwnProperty(input.bracketAttr)?expr=attrs[input.bracketAttr]:attrs.hasOwnProperty(input.bindonAttr)?expr=attrs[input.bindonAttr]:attrs.hasOwnProperty(input.bracketParenAttr)&&(expr=attrs[input.bracketParenAttr]);if(null!=expr){var watchFn=function(prop){return function(value,prevValue){null!=_this.inputChanges&&(_this.inputChangeCount++,_this.inputChanges[prop]=new Ng1Change(prevValue,value)),_this.component[prop]=value}}(input.prop);this.componentScope.$watch(expr,watchFn)}}var prototype=this.info.type.prototype;prototype&&prototype.ngOnChanges&&(this.inputChanges={},this.componentScope.$watch(function(){return _this.inputChangeCount},function(){var inputChanges=_this.inputChanges;_this.inputChanges={},_this.component.ngOnChanges(inputChanges)})),this.componentScope.$watch(function(){return _this.changeDetector&&_this.changeDetector.detectChanges()})},DowngradeNg2ComponentAdapter.prototype.projectContent=function(){var childNodes=this.childNodes,parent=this.contentInsertionPoint.parentNode;if(parent)for(var i=0,ii=childNodes.length;ii>i;i++)parent.insertBefore(childNodes[i],this.contentInsertionPoint)},DowngradeNg2ComponentAdapter.prototype.setupOutputs=function(){for(var _this=this,attrs=this.attrs,outputs=this.info.outputs,j=0;j<outputs.length;j++){var output=outputs[j],expr=null,assignExpr=!1,bindonAttr=output.bindonAttr?output.bindonAttr.substring(0,output.bindonAttr.length-6):null,bracketParenAttr=output.bracketParenAttr?"[("+output.bracketParenAttr.substring(2,output.bracketParenAttr.length-8)+")]":null;if(attrs.hasOwnProperty(output.onAttr)?expr=attrs[output.onAttr]:attrs.hasOwnProperty(output.parenAttr)?expr=attrs[output.parenAttr]:attrs.hasOwnProperty(bindonAttr)?(expr=attrs[bindonAttr],assignExpr=!0):attrs.hasOwnProperty(bracketParenAttr)&&(expr=attrs[bracketParenAttr],assignExpr=!0),null!=expr&&null!=assignExpr){var getter=this.parse(expr),setter=getter.assign;if(assignExpr&&!setter)throw new Error("Expression '"+expr+"' is not assignable!");var emitter=this.component[output.prop];if(!emitter)throw new Error("Missing emitter '"+output.prop+"' on component '"+this.info.selector+"'!");emitter.subscribe({next:assignExpr?function(setter){return function(v){return setter(_this.scope,v)}}(setter):function(getter){return function(v){return getter(_this.scope,{$event:v})}}(getter)})}}},DowngradeNg2ComponentAdapter.prototype.registerCleanup=function(){var _this=this;this.element.bind("$destroy",function(){_this.componentScope.$destroy(),_this.componentRef.destroy()})},DowngradeNg2ComponentAdapter}(),Ng1Change=function(){function Ng1Change(previousValue,currentValue){this.previousValue=previousValue,this.currentValue=currentValue}return Ng1Change.prototype.isFirstChange=function(){return this.previousValue===this.currentValue},Ng1Change}(),COMPONENT_SELECTOR=/^[\w|-]*$/,SKEWER_CASE=/-(\w)/g,directiveResolver=new _angular_compiler.DirectiveResolver,CAMEL_CASE=/([A-Z])/g,INITIAL_VALUE$1={__UNINITIALIZED__:!0},NOT_SUPPORTED="NOT_SUPPORTED",UpgradeNg1ComponentAdapterBuilder=function(){function UpgradeNg1ComponentAdapterBuilder(name){this.name=name,this.inputs=[],this.inputsRename=[],this.outputs=[],this.outputsRename=[],this.propertyOutputs=[],this.checkProperties=[],this.propertyMap={},this.linkFn=null,this.directive=null,this.$controller=null;var selector=name.replace(CAMEL_CASE,function(all,next){return"-"+next.toLowerCase()}),self=this;this.type=_angular_core.Directive({selector:selector,inputs:this.inputsRename,outputs:this.outputsRename}).Class({constructor:[new _angular_core.Inject(NG1_SCOPE),_angular_core.ElementRef,function(scope,elementRef){return new UpgradeNg1ComponentAdapter(self.linkFn,scope,self.directive,elementRef,self.$controller,self.inputs,self.outputs,self.propertyOutputs,self.checkProperties,self.propertyMap)}],ngOnInit:function(){},ngOnChanges:function(){},ngDoCheck:function(){}})}return UpgradeNg1ComponentAdapterBuilder.prototype.extractDirective=function(injector){var directives=injector.get(this.name+"Directive");if(directives.length>1)throw new Error("Only support single directive definition for: "+this.name);var directive=directives[0];directive.replace&&this.notSupported("replace"),directive.terminal&&this.notSupported("terminal");var link=directive.link;return"object"==typeof link&&link.post&&this.notSupported("link.post"),directive},UpgradeNg1ComponentAdapterBuilder.prototype.notSupported=function(feature){throw new Error("Upgraded directive '"+this.name+"' does not support '"+feature+"'.")},UpgradeNg1ComponentAdapterBuilder.prototype.extractBindings=function(){var btcIsObject="object"==typeof this.directive.bindToController;if(btcIsObject&&Object.keys(this.directive.scope).length)throw new Error("Binding definitions on scope and controller at the same time are not supported.");var context=btcIsObject?this.directive.bindToController:this.directive.scope;if("object"==typeof context)for(var name in context)if(context.hasOwnProperty(name)){var localName=context[name],type=localName.charAt(0);localName=localName.substr(1)||name;var outputName="output_"+name,outputNameRename=outputName+": "+name,outputNameRenameChange=outputName+": "+name+"Change",inputName="input_"+name,inputNameRename=inputName+": "+name;switch(type){case"=":this.propertyOutputs.push(outputName),this.checkProperties.push(localName),this.outputs.push(outputName),this.outputsRename.push(outputNameRenameChange),this.propertyMap[outputName]=localName;case"@":case"<":this.inputs.push(inputName),this.inputsRename.push(inputNameRename),this.propertyMap[inputName]=localName;break;case"&":this.outputs.push(outputName),this.outputsRename.push(outputNameRename),this.propertyMap[outputName]=localName;break;default:var json=JSON.stringify(context);throw new Error("Unexpected mapping '"+type+"' in '"+json+"' in '"+this.name+"' directive.")}}},UpgradeNg1ComponentAdapterBuilder.prototype.compileTemplate=function(compile,templateCache,httpBackend){function compileHtml(html){var div=document.createElement("div");return div.innerHTML=html,compile(div.childNodes)}var _this=this;if(void 0!==this.directive.template)this.linkFn=compileHtml("function"==typeof this.directive.template?this.directive.template():this.directive.template);else{if(!this.directive.templateUrl)throw new Error("Directive '"+this.name+"' is not a component, it is missing template.");var url="function"==typeof this.directive.templateUrl?this.directive.templateUrl():this.directive.templateUrl,html=templateCache.get(url);if(void 0===html)return new Promise(function(resolve,err){httpBackend("GET",url,null,function(status,response){200==status?resolve(_this.linkFn=compileHtml(templateCache.put(url,response))):err("GET "+url+" returned "+status+": "+response)})});this.linkFn=compileHtml(html)}return null},UpgradeNg1ComponentAdapterBuilder.resolve=function(exportedComponents,injector){var promises=[],compile=injector.get(NG1_COMPILE),templateCache=injector.get(NG1_TEMPLATE_CACHE),httpBackend=injector.get(NG1_HTTP_BACKEND),$controller=injector.get(NG1_CONTROLLER);for(var name in exportedComponents)if(exportedComponents.hasOwnProperty(name)){var exportedComponent=exportedComponents[name];exportedComponent.directive=exportedComponent.extractDirective(injector),exportedComponent.$controller=$controller,exportedComponent.extractBindings();var promise=exportedComponent.compileTemplate(compile,templateCache,httpBackend);promise&&promises.push(promise)}return Promise.all(promises)},UpgradeNg1ComponentAdapterBuilder}(),UpgradeNg1ComponentAdapter=function(){function UpgradeNg1ComponentAdapter(linkFn,scope,directive,elementRef,$controller,inputs,outputs,propOuts,checkProperties,propertyMap){this.linkFn=linkFn,this.directive=directive,this.$controller=$controller,this.inputs=inputs,this.outputs=outputs,this.propOuts=propOuts,this.checkProperties=checkProperties,this.propertyMap=propertyMap,this.destinationObj=null,this.checkLastValues=[],this.$element=null,this.element=elementRef.nativeElement,this.componentScope=scope.$new(!!directive.scope),this.$element=element(this.element);var controllerType=directive.controller;this.destinationObj=directive.bindToController&&controllerType?this.buildController(controllerType):this.componentScope;for(var i=0;i<inputs.length;i++)this[inputs[i]]=null;for(var j=0;j<outputs.length;j++){var emitter=this[outputs[j]]=new _angular_core.EventEmitter;this.setComponentProperty(outputs[j],function(emitter){return function(value){return emitter.emit(value)}}(emitter))}for(var k=0;k<propOuts.length;k++)this[propOuts[k]]=new _angular_core.EventEmitter,this.checkLastValues.push(INITIAL_VALUE$1)}return UpgradeNg1ComponentAdapter.prototype.ngOnInit=function(){var _this=this;!this.directive.bindToController&&this.directive.controller&&this.buildController(this.directive.controller);var link=this.directive.link;if("object"==typeof link&&(link=link.pre),link){var attrs=NOT_SUPPORTED,transcludeFn=NOT_SUPPORTED,linkController=this.resolveRequired(this.$element,this.directive.require);this.directive.link(this.componentScope,this.$element,attrs,linkController,transcludeFn)}for(var childNode,childNodes=[];childNode=this.element.firstChild;)this.element.removeChild(childNode),childNodes.push(childNode);this.linkFn(this.componentScope,function(clonedElement){for(var i=0,ii=clonedElement.length;ii>i;i++)_this.element.appendChild(clonedElement[i])},{parentBoundTranscludeFn:function(scope,cloneAttach){cloneAttach(childNodes)}}),this.destinationObj.$onInit&&this.destinationObj.$onInit()},UpgradeNg1ComponentAdapter.prototype.ngOnChanges=function(changes){for(var name in changes)if(changes.hasOwnProperty(name)){var change=changes[name];this.setComponentProperty(name,change.currentValue)}},UpgradeNg1ComponentAdapter.prototype.ngDoCheck=function(){for(var count=0,destinationObj=this.destinationObj,lastValues=this.checkLastValues,checkProperties=this.checkProperties,i=0;i<checkProperties.length;i++){var value=destinationObj[checkProperties[i]],last=lastValues[i];if(value!==last)if("number"==typeof value&&isNaN(value)&&"number"==typeof last&&isNaN(last));else{var eventEmitter=this[this.propOuts[i]];eventEmitter.emit(lastValues[i]=value)}}return count},UpgradeNg1ComponentAdapter.prototype.setComponentProperty=function(name,value){this.destinationObj[this.propertyMap[name]]=value},UpgradeNg1ComponentAdapter.prototype.buildController=function(controllerType){var locals={$scope:this.componentScope,$element:this.$element},controller=this.$controller(controllerType,locals,null,this.directive.controllerAs);return this.$element.data(controllerKey(this.directive.name),controller),controller},UpgradeNg1ComponentAdapter.prototype.resolveRequired=function($element,require){if(!require)return void 0;if("string"==typeof require){var name=require,isOptional=!1,startParent=!1,searchParents=!1;"?"==name.charAt(0)&&(isOptional=!0,name=name.substr(1)),"^"==name.charAt(0)&&(searchParents=!0,name=name.substr(1)),"^"==name.charAt(0)&&(startParent=!0,name=name.substr(1));var key=controllerKey(name);startParent&&($element=$element.parent());var dep=searchParents?$element.inheritedData(key):$element.data(key);if(!dep&&!isOptional)throw new Error("Can not locate '"+require+"' in '"+this.directive.name+"'.");return dep}if(require instanceof Array){for(var deps=[],i=0;i<require.length;i++)deps.push(this.resolveRequired($element,require[i]));return deps}throw new Error("Directive '"+this.directive.name+"' require syntax unrecognized: "+this.directive.require)},UpgradeNg1ComponentAdapter}(),upgradeCount=0,UpgradeAdapter=function(){function UpgradeAdapter(){this.idPrefix="NG2_UPGRADE_"+upgradeCount++ +"_",this.upgradedComponents=[],this.downgradedComponents={},this.providers=[]}return UpgradeAdapter.prototype.downgradeNg2Component=function(type){this.upgradedComponents.push(type);var info=getComponentInfo(type);return ng1ComponentDirective(info,""+this.idPrefix+info.selector+"_c")},UpgradeAdapter.prototype.upgradeNg1Component=function(name){return this.downgradedComponents.hasOwnProperty(name)?this.downgradedComponents[name].type:(this.downgradedComponents[name]=new UpgradeNg1ComponentAdapterBuilder(name)).type},UpgradeAdapter.prototype.bootstrap=function(element$$,modules,config){var original$applyFn,rootScopePrototype,rootScope,_this=this,upgrade=new UpgradeAdapterRef,ng1Injector=null,platformRef=_angular_platformBrowser.browserPlatform(),applicationRef=_angular_core.ReflectiveInjector.resolveAndCreate([_angular_platformBrowser.BROWSER_APP_PROVIDERS,_angular_platformBrowserDynamic.BROWSER_APP_COMPILER_PROVIDERS,{provide:NG1_INJECTOR,useFactory:function(){return ng1Injector}},{provide:NG1_COMPILE,useFactory:function(){return ng1Injector.get(NG1_COMPILE)}},this.providers],platformRef.injector).get(_angular_core.ApplicationRef),injector=applicationRef.injector,ngZone=injector.get(_angular_core.NgZone),compiler=injector.get(_angular_core.ComponentResolver),delayApplyExps=[],componentFactoryRefMap={},ng1Module=module$1(this.idPrefix,modules),ng1BootstrapPromise=null,ng1compilePromise=null;ng1Module.value(NG2_INJECTOR,injector).value(NG2_ZONE,ngZone).value(NG2_COMPILER,compiler).value(NG2_COMPONENT_FACTORY_REF_MAP,componentFactoryRefMap).config(["$provide","$injector",function(provide,ng1Injector){provide.decorator(NG1_ROOT_SCOPE,["$delegate",function(rootScopeDelegate){if(rootScopePrototype=rootScopeDelegate.constructor.prototype,!rootScopePrototype.hasOwnProperty("$apply"))throw new Error("Failed to find '$apply' on '$rootScope'!");return original$applyFn=rootScopePrototype.$apply,rootScopePrototype.$apply=function(exp){return delayApplyExps.push(exp)},rootScope=rootScopeDelegate}]),ng1Injector.has(NG1_TESTABILITY)&&provide.decorator(NG1_TESTABILITY,["$delegate",function(testabilityDelegate){var _this=this,ng2Testability=injector.get(_angular_core.Testability),origonalWhenStable=testabilityDelegate.whenStable,newWhenStable=function(callback){var whenStableContext=_this;origonalWhenStable.call(_this,function(){ng2Testability.isStable()?callback.apply(this,arguments):ng2Testability.whenStable(newWhenStable.bind(whenStableContext,callback))})};return testabilityDelegate.whenStable=newWhenStable,testabilityDelegate}])}]),ng1compilePromise=new Promise(function(resolve,reject){ng1Module.run(["$injector","$rootScope",function(injector,rootScope){ng1Injector=injector,ngZone.onMicrotaskEmpty.subscribe({next:function(){return ngZone.runOutsideAngular(function(){return rootScope.$evalAsync()})}}),UpgradeNg1ComponentAdapterBuilder.resolve(_this.downgradedComponents,injector).then(resolve,reject)}])});var windowAngular=window.angular;return windowAngular.resumeBootstrap=void 0,element(element$$).data(controllerKey(NG2_INJECTOR),injector),ngZone.run(function(){bootstrap(element$$,[_this.idPrefix],config)}),ng1BootstrapPromise=new Promise(function(resolve){if(windowAngular.resumeBootstrap){var originalResumeBootstrap=windowAngular.resumeBootstrap;windowAngular.resumeBootstrap=function(){windowAngular.resumeBootstrap=originalResumeBootstrap,windowAngular.resumeBootstrap.apply(this,arguments),resolve()}}else resolve()}),Promise.all([this.compileNg2Components(compiler,componentFactoryRefMap),ng1BootstrapPromise,ng1compilePromise]).then(function(){ngZone.run(function(){if(rootScopePrototype){for(rootScopePrototype.$apply=original$applyFn;delayApplyExps.length;)rootScope.$apply(delayApplyExps.shift());upgrade._bootstrapDone(applicationRef,ng1Injector),rootScopePrototype=null}})},onError),upgrade},UpgradeAdapter.prototype.addProvider=function(provider){this.providers.push(provider)},UpgradeAdapter.prototype.upgradeNg1Provider=function(name,options){var token=options&&options.asToken||name;this.providers.push({provide:token,useFactory:function(ng1Injector){return ng1Injector.get(name)},deps:[NG1_INJECTOR]})},UpgradeAdapter.prototype.downgradeNg2Provider=function(token){var factory=function(injector){return injector.get(token)};return factory.$inject=[NG2_INJECTOR],factory},UpgradeAdapter.prototype.compileNg2Components=function(compiler,componentFactoryRefMap){for(var _this=this,promises=[],types=this.upgradedComponents,i=0;i<types.length;i++)promises.push(compiler.resolveComponent(types[i]));return Promise.all(promises).then(function(componentFactories){for(var types=_this.upgradedComponents,i=0;i<componentFactories.length;i++)componentFactoryRefMap[getComponentInfo(types[i]).selector]=componentFactories[i];return componentFactoryRefMap},onError)},UpgradeAdapter}(),UpgradeAdapterRef=function(){function UpgradeAdapterRef(){this._readyFn=null,this.ng1RootScope=null,this.ng1Injector=null,this.ng2ApplicationRef=null,this.ng2Injector=null}return UpgradeAdapterRef.prototype._bootstrapDone=function(applicationRef,ng1Injector){this.ng2ApplicationRef=applicationRef,this.ng2Injector=applicationRef.injector,this.ng1Injector=ng1Injector,this.ng1RootScope=ng1Injector.get(NG1_ROOT_SCOPE),this._readyFn&&this._readyFn(this)},UpgradeAdapterRef.prototype.ready=function(fn){this._readyFn=fn},UpgradeAdapterRef.prototype.dispose=function(){this.ng1Injector.get(NG1_ROOT_SCOPE).$destroy(),this.ng2ApplicationRef.dispose()},UpgradeAdapterRef}();exports.UpgradeAdapter=UpgradeAdapter,exports.UpgradeAdapterRef=UpgradeAdapterRef});
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/@angular/upgrade/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from './upgrade';\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
|
package/esm/src/angular_js.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular_js.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"angular_js.js","sourceRoot":"","sources":["../../../../../modules/@angular/upgrade/src/angular_js.ts"],"names":[],"mappings":"AAuHA;IACE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,OAAO,GAMF;IACP,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;CACrB,CAAC;AAGF,IAAI,CAAC;IACH,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACrC,OAAO,GAAS,MAAO,CAAC,OAAO,CAAC;IAClC,CAAC;AACH,CAAE;AAAA,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEb,CAAC;AAED,OAAO,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACnC,OAAO,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACrC,OAAO,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACrC,OAAO,IAAI,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;AACrD,OAAO,IAAI,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC","sourcesContent":["export interface IModule {\n config(fn: any): IModule;\n directive(selector: string, factory: any): IModule;\n component(selector: string, component: IComponent): IModule;\n controller(name: string, type: any): IModule;\n factory(key: string, factoryFn: any): IModule;\n value(key: string, value: any): IModule;\n run(a: any): void;\n}\nexport interface ICompileService {\n (element: Element|NodeList|string, transclude?: Function): ILinkFn;\n}\nexport interface ILinkFn {\n (scope: IScope, cloneAttachFn?: Function, options?: ILinkFnOptions): void;\n}\nexport interface ILinkFnOptions {\n parentBoundTranscludeFn?: Function;\n transcludeControllers?: {[key: string]: any};\n futureParentElement?: Node;\n}\nexport interface IRootScopeService {\n $new(isolate?: boolean): IScope;\n $id: string;\n $watch(expr: any, fn?: (a1?: any, a2?: any) => void): Function;\n $destroy(): any;\n $apply(): any;\n $apply(exp: string): any;\n $apply(exp: Function): any;\n $evalAsync(): any;\n $$childTail: IScope;\n $$childHead: IScope;\n $$nextSibling: IScope;\n}\nexport interface IScope extends IRootScopeService {}\nexport interface IAngularBootstrapConfig {}\nexport interface IDirective {\n compile?: IDirectiveCompileFn;\n controller?: any;\n controllerAs?: string;\n bindToController?: boolean|Object;\n link?: IDirectiveLinkFn|IDirectivePrePost;\n name?: string;\n priority?: number;\n replace?: boolean;\n require?: any;\n restrict?: string;\n scope?: any;\n template?: any;\n templateUrl?: any;\n terminal?: boolean;\n transclude?: any;\n}\nexport interface IDirectiveCompileFn {\n (templateElement: IAugmentedJQuery, templateAttributes: IAttributes,\n transclude: ITranscludeFunction): IDirectivePrePost;\n}\nexport interface IDirectivePrePost {\n pre?: IDirectiveLinkFn;\n post?: IDirectiveLinkFn;\n}\nexport interface IDirectiveLinkFn {\n (scope: IScope, instanceElement: IAugmentedJQuery, instanceAttributes: IAttributes,\n controller: any, transclude: ITranscludeFunction): void;\n}\nexport interface IComponent {\n bindings?: Object;\n controller?: any;\n controllerAs?: string;\n require?: any;\n template?: any;\n templateUrl?: any;\n transclude?: any;\n}\nexport interface IAttributes { $observe(attr: string, fn: (v: string) => void): void; }\nexport interface ITranscludeFunction {\n // If the scope is provided, then the cloneAttachFn must be as well.\n (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;\n // If one argument is provided, then it's assumed to be the cloneAttachFn.\n (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;\n}\nexport interface ICloneAttachFunction {\n // Let's hint but not force cloneAttachFn's signature\n (clonedElement?: IAugmentedJQuery, scope?: IScope): any;\n}\nexport interface IAugmentedJQuery {\n bind(name: string, fn: () => void): void;\n data(name: string, value?: any): any;\n inheritedData(name: string, value?: any): any;\n contents(): IAugmentedJQuery;\n parent(): IAugmentedJQuery;\n length: number;\n [index: number]: Node;\n}\nexport interface IParseService { (expression: string): ICompiledExpression; }\nexport interface ICompiledExpression { assign(context: any, value: any): any; }\nexport interface IHttpBackendService {\n (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number,\n withCredentials?: boolean): void;\n}\nexport interface ICacheObject {\n put<T>(key: string, value?: T): T;\n get(key: string): any;\n}\nexport interface ITemplateCacheService extends ICacheObject {}\nexport interface IControllerService {\n (controllerConstructor: Function, locals?: any, later?: any, ident?: any): any;\n (controllerName: string, locals?: any): any;\n}\n\nexport interface IInjectorService { get(key: string): any; }\n\nexport interface ITestabilityService {\n findBindings(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n findModels(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n getLocation(): string;\n setLocation(url: string): void;\n whenStable(callback: Function): void;\n}\n\nfunction noNg() {\n throw new Error('AngularJS v1.x is not loaded!');\n}\n\nvar angular: {\n bootstrap: (e: Element, modules: string[], config: IAngularBootstrapConfig) => void,\n module: (prefix: string, dependencies?: string[]) => IModule,\n element: (e: Element) => IAugmentedJQuery,\n version: {major: number}, resumeBootstrap?: () => void,\n getTestability: (e: Element) => ITestabilityService\n} = <any>{\n bootstrap: noNg,\n module: noNg,\n element: noNg,\n version: noNg,\n resumeBootstrap: noNg,\n getTestability: noNg\n};\n\n\ntry {\n if (window.hasOwnProperty('angular')) {\n angular = (<any>window).angular;\n }\n} catch (e) {\n // ignore in CJS mode.\n}\n\nexport var bootstrap = angular.bootstrap;\nexport var module = angular.module;\nexport var element = angular.element;\nexport var version = angular.version;\nexport var resumeBootstrap = angular.resumeBootstrap;\nexport var getTestability = angular.getTestability;\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","metadata":{"bootstrap":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"bootstrap"},"module":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"module"},"element":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"element"},"version":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"version"},"resumeBootstrap":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"resumeBootstrap"},"getTestability":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"getTestability"}}}
|
|
1
|
+
{"__symbolic":"module","version":1,"metadata":{"bootstrap":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"bootstrap"},"module":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"module"},"element":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"element"},"version":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"version"},"resumeBootstrap":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"resumeBootstrap"},"getTestability":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"angular"},"member":"getTestability"}}}
|
package/esm/src/constants.js
CHANGED
|
@@ -11,5 +11,5 @@ export const NG1_INJECTOR = '$injector';
|
|
|
11
11
|
export const NG1_PARSE = '$parse';
|
|
12
12
|
export const NG1_TEMPLATE_CACHE = '$templateCache';
|
|
13
13
|
export const NG1_TESTABILITY = '$$testability';
|
|
14
|
-
export const REQUIRE_INJECTOR = '
|
|
14
|
+
export const REQUIRE_INJECTOR = '?^' + NG2_INJECTOR;
|
|
15
15
|
//# sourceMappingURL=constants.js.map
|
package/esm/src/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../modules/@angular/upgrade/src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,OAAO,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,OAAO,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAC1E,OAAO,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,OAAO,MAAM,cAAc,GAAG,aAAa,CAAC;AAC5C,OAAO,MAAM,SAAS,GAAG,QAAQ,CAAC;AAClC,OAAO,MAAM,cAAc,GAAG,YAAY,CAAC;AAC3C,OAAO,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,OAAO,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,OAAO,MAAM,YAAY,GAAG,WAAW,CAAC;AACxC,OAAO,MAAM,SAAS,GAAG,QAAQ,CAAC;AAClC,OAAO,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,OAAO,MAAM,eAAe,GAAG,eAAe,CAAC;AAC/C,OAAO,MAAM,gBAAgB,GAAG,IAAI,GAAG,YAAY,CAAC","sourcesContent":["export const NG2_COMPILER = 'ng2.Compiler';\nexport const NG2_INJECTOR = 'ng2.Injector';\nexport const NG2_COMPONENT_FACTORY_REF_MAP = 'ng2.ComponentFactoryRefMap';\nexport const NG2_ZONE = 'ng2.NgZone';\n\nexport const NG1_CONTROLLER = '$controller';\nexport const NG1_SCOPE = '$scope';\nexport const NG1_ROOT_SCOPE = '$rootScope';\nexport const NG1_COMPILE = '$compile';\nexport const NG1_HTTP_BACKEND = '$httpBackend';\nexport const NG1_INJECTOR = '$injector';\nexport const NG1_PARSE = '$parse';\nexport const NG1_TEMPLATE_CACHE = '$templateCache';\nexport const NG1_TESTABILITY = '$$testability';\nexport const REQUIRE_INJECTOR = '?^' + NG2_INJECTOR;\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","metadata":{"NG2_COMPILER":"ng2.Compiler","NG2_INJECTOR":"ng2.Injector","NG2_COMPONENT_FACTORY_REF_MAP":"ng2.ComponentFactoryRefMap","NG2_ZONE":"ng2.NgZone","NG1_CONTROLLER":"$controller","NG1_SCOPE":"$scope","NG1_ROOT_SCOPE":"$rootScope","NG1_COMPILE":"$compile","NG1_HTTP_BACKEND":"$httpBackend","NG1_INJECTOR":"$injector","NG1_PARSE":"$parse","NG1_TEMPLATE_CACHE":"$templateCache","NG1_TESTABILITY":"$$testability","REQUIRE_INJECTOR":"
|
|
1
|
+
{"__symbolic":"module","version":1,"metadata":{"NG2_COMPILER":"ng2.Compiler","NG2_INJECTOR":"ng2.Injector","NG2_COMPONENT_FACTORY_REF_MAP":"ng2.ComponentFactoryRefMap","NG2_ZONE":"ng2.NgZone","NG1_CONTROLLER":"$controller","NG1_SCOPE":"$scope","NG1_ROOT_SCOPE":"$rootScope","NG1_COMPILE":"$compile","NG1_HTTP_BACKEND":"$httpBackend","NG1_INJECTOR":"$injector","NG1_PARSE":"$parse","NG1_TEMPLATE_CACHE":"$templateCache","NG1_TESTABILITY":"$$testability","REQUIRE_INJECTOR":"?^ng2.Injector"}}
|