@angular/upgrade 15.1.1 → 15.1.3

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v15.1.1
2
+ * @license Angular v15.1.3
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { Version, ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, NgZone, ComponentFactoryResolver, Directive, Inject, ElementRef, EventEmitter, Compiler, resolveForwardRef, NgModule } from '@angular/core';
8
+ import { Version, ɵNG_MOD_DEF, Injector, ChangeDetectorRef, Testability, TestabilityRegistry, ApplicationRef, SimpleChange, NgZone, ComponentFactoryResolver, Directive, Inject, ElementRef, EventEmitter, Compiler, NgModule, resolveForwardRef } from '@angular/core';
9
9
  import { __decorate, __param, __metadata } from 'tslib';
10
10
  import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
11
11
 
@@ -17,7 +17,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
17
17
  /**
18
18
  * @publicApi
19
19
  */
20
- const VERSION = new Version('15.1.1');
20
+ const VERSION = new Version('15.1.3');
21
21
 
22
22
  function noNg() {
23
23
  throw new Error('AngularJS v1.x is not loaded!');
@@ -121,9 +121,6 @@ class PropertyBinding {
121
121
  constructor(prop, attr) {
122
122
  this.prop = prop;
123
123
  this.attr = attr;
124
- this.parseBinding();
125
- }
126
- parseBinding() {
127
124
  this.bracketAttr = `[${this.attr}]`;
128
125
  this.parenAttr = `(${this.attr})`;
129
126
  this.bracketParenAttr = `[(${this.attr})]`;
@@ -138,13 +135,7 @@ const DIRECTIVE_PREFIX_REGEXP = /^(?:x|data)[:\-_]/i;
138
135
  const DIRECTIVE_SPECIAL_CHARS_REGEXP = /[:\-_]+(.)/g;
139
136
  function onError(e) {
140
137
  // TODO: (misko): We seem to not have a stack trace here!
141
- if (console.error) {
142
- console.error(e, e.stack);
143
- }
144
- else {
145
- // tslint:disable-next-line:no-console
146
- console.log(e, e.stack);
147
- }
138
+ console.error(e, e.stack);
148
139
  throw e;
149
140
  }
150
141
  /**
@@ -311,32 +302,38 @@ class DowngradeComponentAdapter {
311
302
  });
312
303
  return compiledProjectableNodes;
313
304
  }
305
+ createComponentAndSetup(projectableNodes, manuallyAttachView = false, propagateDigest = true) {
306
+ const component = this.createComponent(projectableNodes);
307
+ this.setupInputs(manuallyAttachView, propagateDigest, component);
308
+ this.setupOutputs(component.componentRef);
309
+ this.registerCleanup(component.componentRef);
310
+ return component.componentRef;
311
+ }
314
312
  createComponent(projectableNodes) {
315
313
  const providers = [{ provide: $SCOPE, useValue: this.componentScope }];
316
314
  const childInjector = Injector.create({ providers: providers, parent: this.parentInjector, name: 'DowngradeComponentAdapter' });
317
- this.componentRef =
318
- this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
319
- this.viewChangeDetector = this.componentRef.injector.get(ChangeDetectorRef);
320
- this.changeDetector = this.componentRef.changeDetectorRef;
321
- this.component = this.componentRef.instance;
315
+ const componentRef = this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
316
+ const viewChangeDetector = componentRef.injector.get(ChangeDetectorRef);
317
+ const changeDetector = componentRef.changeDetectorRef;
322
318
  // testability hook is commonly added during component bootstrap in
323
319
  // packages/core/src/application_ref.bootstrap()
324
320
  // in downgraded application, component creation will take place here as well as adding the
325
321
  // testability hook.
326
- const testability = this.componentRef.injector.get(Testability, null);
322
+ const testability = componentRef.injector.get(Testability, null);
327
323
  if (testability) {
328
- this.componentRef.injector.get(TestabilityRegistry)
329
- .registerApplication(this.componentRef.location.nativeElement, testability);
324
+ componentRef.injector.get(TestabilityRegistry)
325
+ .registerApplication(componentRef.location.nativeElement, testability);
330
326
  }
331
- hookupNgModel(this.ngModel, this.component);
327
+ hookupNgModel(this.ngModel, componentRef.instance);
328
+ return { viewChangeDetector, componentRef, changeDetector };
332
329
  }
333
- setupInputs(manuallyAttachView, propagateDigest = true) {
330
+ setupInputs(manuallyAttachView, propagateDigest = true, { componentRef, changeDetector, viewChangeDetector }) {
334
331
  const attrs = this.attrs;
335
332
  const inputs = this.componentFactory.inputs || [];
336
- for (let i = 0; i < inputs.length; i++) {
337
- const input = new PropertyBinding(inputs[i].propName, inputs[i].templateName);
333
+ for (const input of inputs) {
334
+ const inputBinding = new PropertyBinding(input.propName, input.templateName);
338
335
  let expr = null;
339
- if (attrs.hasOwnProperty(input.attr)) {
336
+ if (attrs.hasOwnProperty(inputBinding.attr)) {
340
337
  const observeFn = (prop => {
341
338
  let prevValue = INITIAL_VALUE$1;
342
339
  return (currValue) => {
@@ -345,40 +342,40 @@ class DowngradeComponentAdapter {
345
342
  if (prevValue === INITIAL_VALUE$1) {
346
343
  prevValue = currValue;
347
344
  }
348
- this.updateInput(prop, prevValue, currValue);
345
+ this.updateInput(componentRef, prop, prevValue, currValue);
349
346
  prevValue = currValue;
350
347
  }
351
348
  };
352
- })(input.prop);
353
- attrs.$observe(input.attr, observeFn);
349
+ })(inputBinding.prop);
350
+ attrs.$observe(inputBinding.attr, observeFn);
354
351
  // Use `$watch()` (in addition to `$observe()`) in order to initialize the input in time
355
352
  // for `ngOnChanges()`. This is necessary if we are already in a `$digest`, which means that
356
353
  // `ngOnChanges()` (which is called by a watcher) will run before the `$observe()` callback.
357
354
  let unwatch = this.componentScope.$watch(() => {
358
355
  unwatch();
359
356
  unwatch = null;
360
- observeFn(attrs[input.attr]);
357
+ observeFn(attrs[inputBinding.attr]);
361
358
  });
362
359
  }
363
- else if (attrs.hasOwnProperty(input.bindAttr)) {
364
- expr = attrs[input.bindAttr];
360
+ else if (attrs.hasOwnProperty(inputBinding.bindAttr)) {
361
+ expr = attrs[inputBinding.bindAttr];
365
362
  }
366
- else if (attrs.hasOwnProperty(input.bracketAttr)) {
367
- expr = attrs[input.bracketAttr];
363
+ else if (attrs.hasOwnProperty(inputBinding.bracketAttr)) {
364
+ expr = attrs[inputBinding.bracketAttr];
368
365
  }
369
- else if (attrs.hasOwnProperty(input.bindonAttr)) {
370
- expr = attrs[input.bindonAttr];
366
+ else if (attrs.hasOwnProperty(inputBinding.bindonAttr)) {
367
+ expr = attrs[inputBinding.bindonAttr];
371
368
  }
372
- else if (attrs.hasOwnProperty(input.bracketParenAttr)) {
373
- expr = attrs[input.bracketParenAttr];
369
+ else if (attrs.hasOwnProperty(inputBinding.bracketParenAttr)) {
370
+ expr = attrs[inputBinding.bracketParenAttr];
374
371
  }
375
372
  if (expr != null) {
376
- const watchFn = (prop => (currValue, prevValue) => this.updateInput(prop, prevValue, currValue))(input.prop);
373
+ const watchFn = ((prop) => (currValue, prevValue) => this.updateInput(componentRef, prop, prevValue, currValue))(inputBinding.prop);
377
374
  this.componentScope.$watch(expr, watchFn);
378
375
  }
379
376
  }
380
377
  // Invoke `ngOnChanges()` and Change Detection (when necessary)
381
- const detectChanges = () => this.changeDetector.detectChanges();
378
+ const detectChanges = () => changeDetector.detectChanges();
382
379
  const prototype = this.componentFactory.componentType.prototype;
383
380
  this.implementsOnChanges = !!(prototype && prototype.ngOnChanges);
384
381
  this.componentScope.$watch(() => this.inputChangeCount, this.wrapCallback(() => {
@@ -386,9 +383,9 @@ class DowngradeComponentAdapter {
386
383
  if (this.implementsOnChanges) {
387
384
  const inputChanges = this.inputChanges;
388
385
  this.inputChanges = {};
389
- this.component.ngOnChanges(inputChanges);
386
+ componentRef.instance.ngOnChanges(inputChanges);
390
387
  }
391
- this.viewChangeDetector.markForCheck();
388
+ viewChangeDetector.markForCheck();
392
389
  // If opted out of propagating digests, invoke change detection when inputs change.
393
390
  if (!propagateDigest) {
394
391
  detectChanges();
@@ -405,39 +402,39 @@ class DowngradeComponentAdapter {
405
402
  unwatch();
406
403
  unwatch = null;
407
404
  const appRef = this.parentInjector.get(ApplicationRef);
408
- appRef.attachView(this.componentRef.hostView);
405
+ appRef.attachView(componentRef.hostView);
409
406
  });
410
407
  }
411
408
  }
412
- setupOutputs() {
409
+ setupOutputs(componentRef) {
413
410
  const attrs = this.attrs;
414
411
  const outputs = this.componentFactory.outputs || [];
415
- for (let j = 0; j < outputs.length; j++) {
416
- const output = new PropertyBinding(outputs[j].propName, outputs[j].templateName);
417
- const bindonAttr = output.bindonAttr.substring(0, output.bindonAttr.length - 6);
418
- const bracketParenAttr = `[(${output.bracketParenAttr.substring(2, output.bracketParenAttr.length - 8)})]`;
412
+ for (const output of outputs) {
413
+ const outputBindings = new PropertyBinding(output.propName, output.templateName);
414
+ const bindonAttr = outputBindings.bindonAttr.substring(0, outputBindings.bindonAttr.length - 6);
415
+ const bracketParenAttr = `[(${outputBindings.bracketParenAttr.substring(2, outputBindings.bracketParenAttr.length - 8)})]`;
419
416
  // order below is important - first update bindings then evaluate expressions
420
417
  if (attrs.hasOwnProperty(bindonAttr)) {
421
- this.subscribeToOutput(output, attrs[bindonAttr], true);
418
+ this.subscribeToOutput(componentRef, outputBindings, attrs[bindonAttr], true);
422
419
  }
423
420
  if (attrs.hasOwnProperty(bracketParenAttr)) {
424
- this.subscribeToOutput(output, attrs[bracketParenAttr], true);
421
+ this.subscribeToOutput(componentRef, outputBindings, attrs[bracketParenAttr], true);
425
422
  }
426
- if (attrs.hasOwnProperty(output.onAttr)) {
427
- this.subscribeToOutput(output, attrs[output.onAttr]);
423
+ if (attrs.hasOwnProperty(outputBindings.onAttr)) {
424
+ this.subscribeToOutput(componentRef, outputBindings, attrs[outputBindings.onAttr]);
428
425
  }
429
- if (attrs.hasOwnProperty(output.parenAttr)) {
430
- this.subscribeToOutput(output, attrs[output.parenAttr]);
426
+ if (attrs.hasOwnProperty(outputBindings.parenAttr)) {
427
+ this.subscribeToOutput(componentRef, outputBindings, attrs[outputBindings.parenAttr]);
431
428
  }
432
429
  }
433
430
  }
434
- subscribeToOutput(output, expr, isAssignment = false) {
431
+ subscribeToOutput(componentRef, output, expr, isAssignment = false) {
435
432
  const getter = this.$parse(expr);
436
433
  const setter = getter.assign;
437
434
  if (isAssignment && !setter) {
438
435
  throw new Error(`Expression '${expr}' is not assignable!`);
439
436
  }
440
- const emitter = this.component[output.prop];
437
+ const emitter = componentRef.instance[output.prop];
441
438
  if (emitter) {
442
439
  emitter.subscribe({
443
440
  next: isAssignment ? (v) => setter(this.scope, v) :
@@ -448,9 +445,9 @@ class DowngradeComponentAdapter {
448
445
  throw new Error(`Missing emitter '${output.prop}' on component '${getTypeName(this.componentFactory.componentType)}'!`);
449
446
  }
450
447
  }
451
- registerCleanup() {
452
- const testabilityRegistry = this.componentRef.injector.get(TestabilityRegistry);
453
- const destroyComponentRef = this.wrapCallback(() => this.componentRef.destroy());
448
+ registerCleanup(componentRef) {
449
+ const testabilityRegistry = componentRef.injector.get(TestabilityRegistry);
450
+ const destroyComponentRef = this.wrapCallback(() => componentRef.destroy());
454
451
  let destroyed = false;
455
452
  this.element.on('$destroy', () => {
456
453
  // The `$destroy` event may have been triggered by the `cleanData()` call in the
@@ -462,7 +459,7 @@ class DowngradeComponentAdapter {
462
459
  this.componentScope.$on('$destroy', () => {
463
460
  if (!destroyed) {
464
461
  destroyed = true;
465
- testabilityRegistry.unregisterApplication(this.componentRef.location.nativeElement);
462
+ testabilityRegistry.unregisterApplication(componentRef.location.nativeElement);
466
463
  // The `componentScope` might be getting destroyed, because an ancestor element is being
467
464
  // removed/destroyed. If that is the case, jqLite/jQuery would normally invoke `cleanData()`
468
465
  // on the removed element and all descendants.
@@ -482,15 +479,12 @@ class DowngradeComponentAdapter {
482
479
  }
483
480
  });
484
481
  }
485
- getInjector() {
486
- return this.componentRef.injector;
487
- }
488
- updateInput(prop, prevValue, currValue) {
482
+ updateInput(componentRef, prop, prevValue, currValue) {
489
483
  if (this.implementsOnChanges) {
490
484
  this.inputChanges[prop] = new SimpleChange(prevValue, currValue, prevValue === currValue);
491
485
  }
492
486
  this.inputChangeCount++;
493
- this.component[prop] = currValue;
487
+ componentRef.instance[prop] = currValue;
494
488
  }
495
489
  groupProjectableNodes() {
496
490
  let ngContentSelectors = this.componentFactory.ngContentSelectors;
@@ -534,14 +528,14 @@ function findMatchingNgContentIndex(element, ngContentSelectors) {
534
528
  }
535
529
  return ngContentIndices.length ? ngContentIndices[0] : null;
536
530
  }
537
- let _matches;
538
531
  function matchesSelector(el, selector) {
539
- if (!_matches) {
540
- const elProto = Element.prototype;
541
- _matches = elProto.matches || elProto.matchesSelector || elProto.mozMatchesSelector ||
542
- elProto.msMatchesSelector || elProto.oMatchesSelector || elProto.webkitMatchesSelector;
543
- }
544
- return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;
532
+ var _a;
533
+ const elProto = Element.prototype;
534
+ return el.nodeType === Node.ELEMENT_NODE
535
+ // matches is supported by all browsers from 2014 onwards except non-chromium edge
536
+ ?
537
+ ((_a = elProto.matches) !== null && _a !== void 0 ? _a : elProto.msMatchesSelector).call(el, selector) :
538
+ false;
545
539
  }
546
540
 
547
541
  function isThenable(obj) {
@@ -663,6 +657,7 @@ function downgradeComponent(info) {
663
657
  terminal: true,
664
658
  require: [REQUIRE_INJECTOR, REQUIRE_NG_MODEL],
665
659
  link: (scope, element, attrs, required) => {
660
+ var _a;
666
661
  // We might have to compile the contents asynchronously, because this might have been
667
662
  // triggered by `UpgradeNg1ComponentAdapterBuilder`, before the Angular templates have
668
663
  // been compiled.
@@ -676,7 +671,7 @@ function downgradeComponent(info) {
676
671
  const attemptedAction = `instantiating component '${getTypeName(info.component)}'`;
677
672
  validateInjectionKey($injector, downgradedModule, lazyModuleRefKey, attemptedAction);
678
673
  const lazyModuleRef = $injector.get(lazyModuleRefKey);
679
- moduleInjector = lazyModuleRef.injector || lazyModuleRef.promise;
674
+ moduleInjector = (_a = lazyModuleRef.injector) !== null && _a !== void 0 ? _a : lazyModuleRef.promise;
680
675
  }
681
676
  // Notes:
682
677
  //
@@ -724,14 +719,11 @@ function downgradeComponent(info) {
724
719
  if (!componentFactory) {
725
720
  throw new Error(`Expecting ComponentFactory for: ${getTypeName(info.component)}`);
726
721
  }
727
- const injectorPromise = new ParentInjectorPromise$1(element);
722
+ const injectorPromise = new ParentInjectorPromise(element);
728
723
  const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback);
729
724
  const projectableNodes = facade.compileContents();
730
- facade.createComponent(projectableNodes);
731
- facade.setupInputs(isNgUpgradeLite, info.propagateDigest);
732
- facade.setupOutputs();
733
- facade.registerCleanup();
734
- injectorPromise.resolve(facade.getInjector());
725
+ const componentRef = facade.createComponentAndSetup(projectableNodes, isNgUpgradeLite, info.propagateDigest);
726
+ injectorPromise.resolve(componentRef.injector);
735
727
  if (ranAsync) {
736
728
  // If this is run async, it is possible that it is not run inside a
737
729
  // digest and initial input values will not be detected.
@@ -762,7 +754,7 @@ function downgradeComponent(info) {
762
754
  * Synchronous promise-like object to wrap parent injectors,
763
755
  * to preserve the synchronous nature of AngularJS's `$compile`.
764
756
  */
765
- class ParentInjectorPromise$1 extends SyncPromise {
757
+ class ParentInjectorPromise extends SyncPromise {
766
758
  constructor(element) {
767
759
  super();
768
760
  this.element = element;
@@ -869,7 +861,7 @@ class UpgradeHelper {
869
861
  this.$controller = this.$injector.get($CONTROLLER);
870
862
  this.element = elementRef.nativeElement;
871
863
  this.$element = element(this.element);
872
- this.directive = directive || UpgradeHelper.getDirective(this.$injector, name);
864
+ this.directive = directive !== null && directive !== void 0 ? directive : UpgradeHelper.getDirective(this.$injector, name);
873
865
  }
874
866
  static getDirective($injector, name) {
875
867
  const directives = $injector.get(name + 'Directive');
@@ -918,11 +910,12 @@ class UpgradeHelper {
918
910
  }
919
911
  }
920
912
  buildController(controllerType, $scope) {
913
+ var _a, _b;
921
914
  // TODO: Document that we do not pre-assign bindings on the controller instance.
922
915
  // Quoted properties below so that this code can be optimized with Closure Compiler.
923
916
  const locals = { '$scope': $scope, '$element': this.$element };
924
917
  const controller = this.$controller(controllerType, locals, null, this.directive.controllerAs);
925
- this.$element.data(controllerKey(this.directive.name), controller);
918
+ (_b = (_a = this.$element).data) === null || _b === void 0 ? void 0 : _b.call(_a, controllerKey(this.directive.name), controller);
926
919
  return controller;
927
920
  }
928
921
  compileTemplate(template) {
@@ -1038,8 +1031,7 @@ class UpgradeHelper {
1038
1031
  getDirectiveRequire() {
1039
1032
  const require = this.directive.require || (this.directive.controller && this.directive.name);
1040
1033
  if (isMap(require)) {
1041
- Object.keys(require).forEach(key => {
1042
- const value = require[key];
1034
+ Object.entries(require).forEach(([key, value]) => {
1043
1035
  const match = value.match(REQUIRE_PREFIX_RE);
1044
1036
  const name = value.substring(match[0].length);
1045
1037
  if (!name) {
@@ -1049,7 +1041,7 @@ class UpgradeHelper {
1049
1041
  }
1050
1042
  return require;
1051
1043
  }
1052
- resolveRequire(require, controllerInstance) {
1044
+ resolveRequire(require) {
1053
1045
  if (!require) {
1054
1046
  return null;
1055
1047
  }
@@ -1116,17 +1108,13 @@ class UpgradeNg1ComponentAdapterBuilder {
1116
1108
  this.directive = null;
1117
1109
  const selector = name.replace(CAMEL_CASE, (all, next) => '-' + next.toLowerCase());
1118
1110
  const self = this;
1119
- // Note: There is a bug in TS 2.4 that prevents us from
1120
- // inlining this into @Directive
1121
- // TODO(tbosch): find or file a bug against TypeScript for this.
1122
- const directive = { selector: selector, inputs: this.inputsRename, outputs: this.outputsRename };
1123
1111
  let MyClass = class MyClass extends UpgradeNg1ComponentAdapter {
1124
1112
  constructor(scope, injector, elementRef) {
1125
1113
  super(new UpgradeHelper(injector, name, elementRef, self.directive || undefined), scope, self.template, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
1126
1114
  }
1127
1115
  };
1128
1116
  MyClass = __decorate([
1129
- Directive(Object.assign({ jit: true }, directive)),
1117
+ Directive({ jit: true, selector: selector, inputs: this.inputsRename, outputs: this.outputsRename }),
1130
1118
  __param(0, Inject($SCOPE)),
1131
1119
  __metadata("design:paramtypes", [Object, Injector, ElementRef])
1132
1120
  ], MyClass);
@@ -1183,8 +1171,7 @@ class UpgradeNg1ComponentAdapterBuilder {
1183
1171
  * Upgrade ng1 components into Angular.
1184
1172
  */
1185
1173
  static resolve(exportedComponents, $injector) {
1186
- const promises = Object.keys(exportedComponents).map(name => {
1187
- const exportedComponent = exportedComponents[name];
1174
+ const promises = Object.entries(exportedComponents).map(([name, exportedComponent]) => {
1188
1175
  exportedComponent.directive = UpgradeHelper.getDirective($injector, name);
1189
1176
  exportedComponent.extractBindings();
1190
1177
  return Promise
@@ -1219,18 +1206,16 @@ class UpgradeNg1ComponentAdapter {
1219
1206
  else {
1220
1207
  this.destinationObj = this.componentScope;
1221
1208
  }
1222
- for (let i = 0; i < inputs.length; i++) {
1223
- this[inputs[i]] = null;
1209
+ for (const input of this.inputs) {
1210
+ this[input] = null;
1224
1211
  }
1225
- for (let j = 0; j < outputs.length; j++) {
1226
- const emitter = this[outputs[j]] = new EventEmitter();
1227
- if (this.propOuts.indexOf(outputs[j]) === -1) {
1228
- this.setComponentProperty(outputs[j], (emitter => (value) => emitter.emit(value))(emitter));
1212
+ for (const output of this.outputs) {
1213
+ const emitter = this[output] = new EventEmitter();
1214
+ if (this.propOuts.indexOf(output) === -1) {
1215
+ this.setComponentProperty(output, (emitter => (value) => emitter.emit(value))(emitter));
1229
1216
  }
1230
1217
  }
1231
- for (let k = 0; k < propOuts.length; k++) {
1232
- this.checkLastValues.push(INITIAL_VALUE);
1233
- }
1218
+ this.checkLastValues.push(...Array(propOuts.length).fill(INITIAL_VALUE));
1234
1219
  }
1235
1220
  ngOnInit() {
1236
1221
  // Collect contents, insert and compile template
@@ -1302,9 +1287,9 @@ class UpgradeNg1ComponentAdapter {
1302
1287
  this.destinationObj[this.propertyMap[name]] = value;
1303
1288
  }
1304
1289
  }
1305
- UpgradeNg1ComponentAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1306
- UpgradeNg1ComponentAdapter.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.1", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 });
1307
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.1", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1290
+ UpgradeNg1ComponentAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1291
+ UpgradeNg1ComponentAdapter.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 });
1292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1308
1293
  type: Directive
1309
1294
  }], ctorParameters: function () { return [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }]; } });
1310
1295
 
@@ -1610,10 +1595,11 @@ class UpgradeAdapter {
1610
1595
  if (!windowNgMock || !windowNgMock.module) {
1611
1596
  throw new Error('Failed to find \'angular.mock.module\'.');
1612
1597
  }
1613
- this.declareNg1Module(modules);
1614
- windowNgMock.module(this.ng1Module.name);
1598
+ const { ng1Module, ng2BootstrapDeferred } = this.declareNg1Module(modules);
1599
+ windowNgMock.module(ng1Module.name);
1615
1600
  const upgrade = new UpgradeAdapterRef();
1616
- this.ng2BootstrapDeferred.promise.then((ng1Injector) => {
1601
+ ng2BootstrapDeferred.promise.then((ng1Injector) => {
1602
+ // @ts-expect-error
1617
1603
  upgrade._bootstrapDone(this.moduleRef, ng1Injector);
1618
1604
  }, onError);
1619
1605
  return upgrade;
@@ -1664,13 +1650,13 @@ class UpgradeAdapter {
1664
1650
  * ```
1665
1651
  */
1666
1652
  bootstrap(element$1, modules, config) {
1667
- this.declareNg1Module(modules);
1653
+ const { ng1Module, ng2BootstrapDeferred, ngZone } = this.declareNg1Module(modules);
1668
1654
  const upgrade = new UpgradeAdapterRef();
1669
1655
  // Make sure resumeBootstrap() only exists if the current bootstrap is deferred
1670
- const windowAngular = window /** TODO #???? */['angular'];
1656
+ const windowAngular = window['angular'];
1671
1657
  windowAngular.resumeBootstrap = undefined;
1672
- this.ngZone.run(() => {
1673
- bootstrap(element$1, [this.ng1Module.name], config);
1658
+ ngZone.run(() => {
1659
+ bootstrap(element$1, [ng1Module.name], config);
1674
1660
  });
1675
1661
  const ng1BootstrapPromise = new Promise((resolve) => {
1676
1662
  if (windowAngular.resumeBootstrap) {
@@ -1686,9 +1672,10 @@ class UpgradeAdapter {
1686
1672
  resolve();
1687
1673
  }
1688
1674
  });
1689
- Promise.all([this.ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => {
1675
+ Promise.all([ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => {
1690
1676
  element(element$1).data(controllerKey(INJECTOR_KEY), this.moduleRef.injector);
1691
1677
  this.moduleRef.injector.get(NgZone).run(() => {
1678
+ // @ts-expect-error
1692
1679
  upgrade._bootstrapDone(this.moduleRef, ng1Injector);
1693
1680
  });
1694
1681
  }, onError);
@@ -1779,14 +1766,14 @@ class UpgradeAdapter {
1779
1766
  let original$applyFn;
1780
1767
  let rootScopePrototype;
1781
1768
  const upgradeAdapter = this;
1782
- const ng1Module = this.ng1Module = module_(this.idPrefix, modules);
1769
+ const ng1Module = module_(this.idPrefix, modules);
1783
1770
  const platformRef = platformBrowserDynamic();
1784
- this.ngZone = new NgZone({ enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec') });
1785
- this.ng2BootstrapDeferred = new Deferred();
1771
+ const ngZone = new NgZone({ enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec') });
1772
+ const ng2BootstrapDeferred = new Deferred();
1786
1773
  ng1Module.constant(UPGRADE_APP_TYPE_KEY, 1 /* UpgradeAppType.Dynamic */)
1787
1774
  .factory(INJECTOR_KEY, () => this.moduleRef.injector.get(Injector))
1788
1775
  .factory(LAZY_MODULE_REF, [INJECTOR_KEY, (injector) => ({ injector })])
1789
- .constant(NG_ZONE_KEY, this.ngZone)
1776
+ .constant(NG_ZONE_KEY, ngZone)
1790
1777
  .factory(COMPILER_KEY, () => this.moduleRef.injector.get(Compiler))
1791
1778
  .config([
1792
1779
  '$provide', '$injector',
@@ -1836,33 +1823,27 @@ class UpgradeAdapter {
1836
1823
  (ng1Injector, rootScope) => {
1837
1824
  UpgradeNg1ComponentAdapterBuilder.resolve(this.ng1ComponentsToBeUpgraded, ng1Injector)
1838
1825
  .then(() => {
1839
- // Note: There is a bug in TS 2.4 that prevents us from
1840
- // inlining this into @NgModule
1841
- // TODO(tbosch): find or file a bug against TypeScript for this.
1842
- const ngModule = {
1843
- providers: [
1844
- { provide: $INJECTOR, useFactory: () => ng1Injector },
1845
- { provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE) },
1846
- this.upgradedProviders
1847
- ],
1848
- imports: [resolveForwardRef(this.ng2AppModule)],
1849
- entryComponents: this.downgradedComponents
1850
- };
1851
1826
  // At this point we have ng1 injector and we have prepared
1852
1827
  // ng1 components to be upgraded, we now can bootstrap ng2.
1853
1828
  let DynamicNgUpgradeModule = class DynamicNgUpgradeModule {
1854
- constructor() { }
1855
1829
  ngDoBootstrap() { }
1856
1830
  };
1857
1831
  DynamicNgUpgradeModule = __decorate([
1858
- NgModule(Object.assign({ jit: true }, ngModule)),
1859
- __metadata("design:paramtypes", [])
1832
+ NgModule({
1833
+ jit: true,
1834
+ providers: [
1835
+ { provide: $INJECTOR, useFactory: () => ng1Injector },
1836
+ { provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE) },
1837
+ this.upgradedProviders
1838
+ ],
1839
+ imports: [resolveForwardRef(this.ng2AppModule)],
1840
+ entryComponents: this.downgradedComponents
1841
+ })
1860
1842
  ], DynamicNgUpgradeModule);
1861
- platformRef
1862
- .bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone: this.ngZone }])
1843
+ platformRef.bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone }])
1863
1844
  .then((ref) => {
1864
1845
  this.moduleRef = ref;
1865
- this.ngZone.run(() => {
1846
+ ngZone.run(() => {
1866
1847
  if (rootScopePrototype) {
1867
1848
  rootScopePrototype.$apply = original$applyFn; // restore original $apply
1868
1849
  while (delayApplyExps.length) {
@@ -1872,9 +1853,9 @@ class UpgradeAdapter {
1872
1853
  }
1873
1854
  });
1874
1855
  })
1875
- .then(() => this.ng2BootstrapDeferred.resolve(ng1Injector), onError)
1856
+ .then(() => ng2BootstrapDeferred.resolve(ng1Injector), onError)
1876
1857
  .then(() => {
1877
- let subscription = this.ngZone.onMicrotaskEmpty.subscribe({
1858
+ let subscription = ngZone.onMicrotaskEmpty.subscribe({
1878
1859
  next: () => {
1879
1860
  if (rootScope.$$phase) {
1880
1861
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
@@ -1896,40 +1877,10 @@ class UpgradeAdapter {
1896
1877
  platformRef.onDestroy(() => destroyApp(ng1Injector));
1897
1878
  });
1898
1879
  })
1899
- .catch((e) => this.ng2BootstrapDeferred.reject(e));
1880
+ .catch((e) => ng2BootstrapDeferred.reject(e));
1900
1881
  }
1901
1882
  ]);
1902
- return ng1Module;
1903
- }
1904
- }
1905
- /**
1906
- * Synchronous promise-like object to wrap parent injectors,
1907
- * to preserve the synchronous nature of AngularJS's $compile.
1908
- */
1909
- class ParentInjectorPromise {
1910
- constructor(element) {
1911
- this.element = element;
1912
- this.callbacks = [];
1913
- // store the promise on the element
1914
- element.data(controllerKey(INJECTOR_KEY), this);
1915
- }
1916
- then(callback) {
1917
- if (this.injector) {
1918
- callback(this.injector);
1919
- }
1920
- else {
1921
- this.callbacks.push(callback);
1922
- }
1923
- }
1924
- resolve(injector) {
1925
- this.injector = injector;
1926
- // reset the element data to point to the real injector
1927
- this.element.data(controllerKey(INJECTOR_KEY), injector);
1928
- // clean out the element to prevent memory leaks
1929
- this.element = null;
1930
- // run all the queued callbacks
1931
- this.callbacks.forEach((callback) => callback(injector));
1932
- this.callbacks.length = 0;
1883
+ return { ng1Module, ng2BootstrapDeferred, ngZone };
1933
1884
  }
1934
1885
  }
1935
1886
  /**