@angular/upgrade 15.2.0-next.2 → 15.2.0-next.4

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.2.0-next.2
2
+ * @license Angular v15.2.0-next.4
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.2.0-next.2');
20
+ const VERSION = new Version('15.2.0-next.4');
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,13 @@ 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
+ const elProto = Element.prototype;
533
+ return el.nodeType === Node.ELEMENT_NODE
534
+ // matches is supported by all browsers from 2014 onwards except non-chromium edge
535
+ ?
536
+ (elProto.matches ?? elProto.msMatchesSelector).call(el, selector) :
537
+ false;
545
538
  }
546
539
 
547
540
  function isThenable(obj) {
@@ -676,7 +669,7 @@ function downgradeComponent(info) {
676
669
  const attemptedAction = `instantiating component '${getTypeName(info.component)}'`;
677
670
  validateInjectionKey($injector, downgradedModule, lazyModuleRefKey, attemptedAction);
678
671
  const lazyModuleRef = $injector.get(lazyModuleRefKey);
679
- moduleInjector = lazyModuleRef.injector || lazyModuleRef.promise;
672
+ moduleInjector = lazyModuleRef.injector ?? lazyModuleRef.promise;
680
673
  }
681
674
  // Notes:
682
675
  //
@@ -724,14 +717,11 @@ function downgradeComponent(info) {
724
717
  if (!componentFactory) {
725
718
  throw new Error(`Expecting ComponentFactory for: ${getTypeName(info.component)}`);
726
719
  }
727
- const injectorPromise = new ParentInjectorPromise$1(element);
720
+ const injectorPromise = new ParentInjectorPromise(element);
728
721
  const facade = new DowngradeComponentAdapter(element, attrs, scope, ngModel, injector, $compile, $parse, componentFactory, wrapCallback);
729
722
  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());
723
+ const componentRef = facade.createComponentAndSetup(projectableNodes, isNgUpgradeLite, info.propagateDigest);
724
+ injectorPromise.resolve(componentRef.injector);
735
725
  if (ranAsync) {
736
726
  // If this is run async, it is possible that it is not run inside a
737
727
  // digest and initial input values will not be detected.
@@ -762,7 +752,7 @@ function downgradeComponent(info) {
762
752
  * Synchronous promise-like object to wrap parent injectors,
763
753
  * to preserve the synchronous nature of AngularJS's `$compile`.
764
754
  */
765
- class ParentInjectorPromise$1 extends SyncPromise {
755
+ class ParentInjectorPromise extends SyncPromise {
766
756
  constructor(element) {
767
757
  super();
768
758
  this.element = element;
@@ -869,7 +859,7 @@ class UpgradeHelper {
869
859
  this.$controller = this.$injector.get($CONTROLLER);
870
860
  this.element = elementRef.nativeElement;
871
861
  this.$element = element(this.element);
872
- this.directive = directive || UpgradeHelper.getDirective(this.$injector, name);
862
+ this.directive = directive ?? UpgradeHelper.getDirective(this.$injector, name);
873
863
  }
874
864
  static getDirective($injector, name) {
875
865
  const directives = $injector.get(name + 'Directive');
@@ -922,7 +912,7 @@ class UpgradeHelper {
922
912
  // Quoted properties below so that this code can be optimized with Closure Compiler.
923
913
  const locals = { '$scope': $scope, '$element': this.$element };
924
914
  const controller = this.$controller(controllerType, locals, null, this.directive.controllerAs);
925
- this.$element.data(controllerKey(this.directive.name), controller);
915
+ this.$element.data?.(controllerKey(this.directive.name), controller);
926
916
  return controller;
927
917
  }
928
918
  compileTemplate(template) {
@@ -1038,8 +1028,7 @@ class UpgradeHelper {
1038
1028
  getDirectiveRequire() {
1039
1029
  const require = this.directive.require || (this.directive.controller && this.directive.name);
1040
1030
  if (isMap(require)) {
1041
- Object.keys(require).forEach(key => {
1042
- const value = require[key];
1031
+ Object.entries(require).forEach(([key, value]) => {
1043
1032
  const match = value.match(REQUIRE_PREFIX_RE);
1044
1033
  const name = value.substring(match[0].length);
1045
1034
  if (!name) {
@@ -1049,7 +1038,7 @@ class UpgradeHelper {
1049
1038
  }
1050
1039
  return require;
1051
1040
  }
1052
- resolveRequire(require, controllerInstance) {
1041
+ resolveRequire(require) {
1053
1042
  if (!require) {
1054
1043
  return null;
1055
1044
  }
@@ -1116,17 +1105,13 @@ class UpgradeNg1ComponentAdapterBuilder {
1116
1105
  this.directive = null;
1117
1106
  const selector = name.replace(CAMEL_CASE, (all, next) => '-' + next.toLowerCase());
1118
1107
  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
1108
  let MyClass = class MyClass extends UpgradeNg1ComponentAdapter {
1124
1109
  constructor(scope, injector, elementRef) {
1125
1110
  super(new UpgradeHelper(injector, name, elementRef, self.directive || undefined), scope, self.template, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
1126
1111
  }
1127
1112
  };
1128
1113
  MyClass = __decorate([
1129
- Directive({ jit: true, ...directive }),
1114
+ Directive({ jit: true, selector: selector, inputs: this.inputsRename, outputs: this.outputsRename }),
1130
1115
  __param(0, Inject($SCOPE)),
1131
1116
  __metadata("design:paramtypes", [Object, Injector, ElementRef])
1132
1117
  ], MyClass);
@@ -1183,8 +1168,7 @@ class UpgradeNg1ComponentAdapterBuilder {
1183
1168
  * Upgrade ng1 components into Angular.
1184
1169
  */
1185
1170
  static resolve(exportedComponents, $injector) {
1186
- const promises = Object.keys(exportedComponents).map(name => {
1187
- const exportedComponent = exportedComponents[name];
1171
+ const promises = Object.entries(exportedComponents).map(([name, exportedComponent]) => {
1188
1172
  exportedComponent.directive = UpgradeHelper.getDirective($injector, name);
1189
1173
  exportedComponent.extractBindings();
1190
1174
  return Promise
@@ -1219,18 +1203,16 @@ class UpgradeNg1ComponentAdapter {
1219
1203
  else {
1220
1204
  this.destinationObj = this.componentScope;
1221
1205
  }
1222
- for (let i = 0; i < inputs.length; i++) {
1223
- this[inputs[i]] = null;
1206
+ for (const input of this.inputs) {
1207
+ this[input] = null;
1224
1208
  }
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));
1209
+ for (const output of this.outputs) {
1210
+ const emitter = this[output] = new EventEmitter();
1211
+ if (this.propOuts.indexOf(output) === -1) {
1212
+ this.setComponentProperty(output, (emitter => (value) => emitter.emit(value))(emitter));
1229
1213
  }
1230
1214
  }
1231
- for (let k = 0; k < propOuts.length; k++) {
1232
- this.checkLastValues.push(INITIAL_VALUE);
1233
- }
1215
+ this.checkLastValues.push(...Array(propOuts.length).fill(INITIAL_VALUE));
1234
1216
  }
1235
1217
  ngOnInit() {
1236
1218
  // Collect contents, insert and compile template
@@ -1302,9 +1284,9 @@ class UpgradeNg1ComponentAdapter {
1302
1284
  this.destinationObj[this.propertyMap[name]] = value;
1303
1285
  }
1304
1286
  }
1305
- UpgradeNg1ComponentAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0-next.2", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1306
- UpgradeNg1ComponentAdapter.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0-next.2", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 });
1307
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0-next.2", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1287
+ UpgradeNg1ComponentAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0-next.4", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
1288
+ UpgradeNg1ComponentAdapter.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0-next.4", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 });
1289
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0-next.4", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
1308
1290
  type: Directive
1309
1291
  }], ctorParameters: function () { return [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }]; } });
1310
1292
 
@@ -1610,10 +1592,11 @@ class UpgradeAdapter {
1610
1592
  if (!windowNgMock || !windowNgMock.module) {
1611
1593
  throw new Error('Failed to find \'angular.mock.module\'.');
1612
1594
  }
1613
- this.declareNg1Module(modules);
1614
- windowNgMock.module(this.ng1Module.name);
1595
+ const { ng1Module, ng2BootstrapDeferred } = this.declareNg1Module(modules);
1596
+ windowNgMock.module(ng1Module.name);
1615
1597
  const upgrade = new UpgradeAdapterRef();
1616
- this.ng2BootstrapDeferred.promise.then((ng1Injector) => {
1598
+ ng2BootstrapDeferred.promise.then((ng1Injector) => {
1599
+ // @ts-expect-error
1617
1600
  upgrade._bootstrapDone(this.moduleRef, ng1Injector);
1618
1601
  }, onError);
1619
1602
  return upgrade;
@@ -1664,13 +1647,13 @@ class UpgradeAdapter {
1664
1647
  * ```
1665
1648
  */
1666
1649
  bootstrap(element$1, modules, config) {
1667
- this.declareNg1Module(modules);
1650
+ const { ng1Module, ng2BootstrapDeferred, ngZone } = this.declareNg1Module(modules);
1668
1651
  const upgrade = new UpgradeAdapterRef();
1669
1652
  // Make sure resumeBootstrap() only exists if the current bootstrap is deferred
1670
- const windowAngular = window /** TODO #???? */['angular'];
1653
+ const windowAngular = window['angular'];
1671
1654
  windowAngular.resumeBootstrap = undefined;
1672
- this.ngZone.run(() => {
1673
- bootstrap(element$1, [this.ng1Module.name], config);
1655
+ ngZone.run(() => {
1656
+ bootstrap(element$1, [ng1Module.name], config);
1674
1657
  });
1675
1658
  const ng1BootstrapPromise = new Promise((resolve) => {
1676
1659
  if (windowAngular.resumeBootstrap) {
@@ -1686,9 +1669,10 @@ class UpgradeAdapter {
1686
1669
  resolve();
1687
1670
  }
1688
1671
  });
1689
- Promise.all([this.ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => {
1672
+ Promise.all([ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => {
1690
1673
  element(element$1).data(controllerKey(INJECTOR_KEY), this.moduleRef.injector);
1691
1674
  this.moduleRef.injector.get(NgZone).run(() => {
1675
+ // @ts-expect-error
1692
1676
  upgrade._bootstrapDone(this.moduleRef, ng1Injector);
1693
1677
  });
1694
1678
  }, onError);
@@ -1779,14 +1763,14 @@ class UpgradeAdapter {
1779
1763
  let original$applyFn;
1780
1764
  let rootScopePrototype;
1781
1765
  const upgradeAdapter = this;
1782
- const ng1Module = this.ng1Module = module_(this.idPrefix, modules);
1766
+ const ng1Module = module_(this.idPrefix, modules);
1783
1767
  const platformRef = platformBrowserDynamic();
1784
- this.ngZone = new NgZone({ enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec') });
1785
- this.ng2BootstrapDeferred = new Deferred();
1768
+ const ngZone = new NgZone({ enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec') });
1769
+ const ng2BootstrapDeferred = new Deferred();
1786
1770
  ng1Module.constant(UPGRADE_APP_TYPE_KEY, 1 /* UpgradeAppType.Dynamic */)
1787
1771
  .factory(INJECTOR_KEY, () => this.moduleRef.injector.get(Injector))
1788
1772
  .factory(LAZY_MODULE_REF, [INJECTOR_KEY, (injector) => ({ injector })])
1789
- .constant(NG_ZONE_KEY, this.ngZone)
1773
+ .constant(NG_ZONE_KEY, ngZone)
1790
1774
  .factory(COMPILER_KEY, () => this.moduleRef.injector.get(Compiler))
1791
1775
  .config([
1792
1776
  '$provide', '$injector',
@@ -1836,33 +1820,27 @@ class UpgradeAdapter {
1836
1820
  (ng1Injector, rootScope) => {
1837
1821
  UpgradeNg1ComponentAdapterBuilder.resolve(this.ng1ComponentsToBeUpgraded, ng1Injector)
1838
1822
  .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
1823
  // At this point we have ng1 injector and we have prepared
1852
1824
  // ng1 components to be upgraded, we now can bootstrap ng2.
1853
1825
  let DynamicNgUpgradeModule = class DynamicNgUpgradeModule {
1854
- constructor() { }
1855
1826
  ngDoBootstrap() { }
1856
1827
  };
1857
1828
  DynamicNgUpgradeModule = __decorate([
1858
- NgModule({ jit: true, ...ngModule }),
1859
- __metadata("design:paramtypes", [])
1829
+ NgModule({
1830
+ jit: true,
1831
+ providers: [
1832
+ { provide: $INJECTOR, useFactory: () => ng1Injector },
1833
+ { provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE) },
1834
+ this.upgradedProviders
1835
+ ],
1836
+ imports: [resolveForwardRef(this.ng2AppModule)],
1837
+ entryComponents: this.downgradedComponents
1838
+ })
1860
1839
  ], DynamicNgUpgradeModule);
1861
- platformRef
1862
- .bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone: this.ngZone }])
1840
+ platformRef.bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone }])
1863
1841
  .then((ref) => {
1864
1842
  this.moduleRef = ref;
1865
- this.ngZone.run(() => {
1843
+ ngZone.run(() => {
1866
1844
  if (rootScopePrototype) {
1867
1845
  rootScopePrototype.$apply = original$applyFn; // restore original $apply
1868
1846
  while (delayApplyExps.length) {
@@ -1872,9 +1850,9 @@ class UpgradeAdapter {
1872
1850
  }
1873
1851
  });
1874
1852
  })
1875
- .then(() => this.ng2BootstrapDeferred.resolve(ng1Injector), onError)
1853
+ .then(() => ng2BootstrapDeferred.resolve(ng1Injector), onError)
1876
1854
  .then(() => {
1877
- let subscription = this.ngZone.onMicrotaskEmpty.subscribe({
1855
+ let subscription = ngZone.onMicrotaskEmpty.subscribe({
1878
1856
  next: () => {
1879
1857
  if (rootScope.$$phase) {
1880
1858
  if (typeof ngDevMode === 'undefined' || ngDevMode) {
@@ -1896,40 +1874,10 @@ class UpgradeAdapter {
1896
1874
  platformRef.onDestroy(() => destroyApp(ng1Injector));
1897
1875
  });
1898
1876
  })
1899
- .catch((e) => this.ng2BootstrapDeferred.reject(e));
1877
+ .catch((e) => ng2BootstrapDeferred.reject(e));
1900
1878
  }
1901
1879
  ]);
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;
1880
+ return { ng1Module, ng2BootstrapDeferred, ngZone };
1933
1881
  }
1934
1882
  }
1935
1883
  /**