@angular/upgrade
Version:
Angular - the library for easing update from v1 to v2
1 lines • 52.9 kB
Source Map (JSON)
{"version":3,"file":"upgrade.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/upgrade/src/dynamic/src/upgrade_ng1_adapter.ts","../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/upgrade/src/dynamic/src/upgrade_adapter.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Directive,\n DoCheck,\n ElementRef,\n EventEmitter,\n Inject,\n Injector,\n OnChanges,\n OnDestroy,\n OnInit,\n SimpleChange,\n SimpleChanges,\n Type,\n} from '@angular/core';\n\nimport {\n IAttributes,\n IDirective,\n IInjectorService,\n ILinkFn,\n IScope,\n ITranscludeFunction,\n} from '../../common/src/angular1';\nimport {$SCOPE} from '../../common/src/constants';\nimport {\n IBindingDestination,\n IControllerInstance,\n UpgradeHelper,\n} from '../../common/src/upgrade_helper';\nimport {isFunction, strictEquals} from '../../common/src/util';\nimport {trustedHTMLFromLegacyTemplate} from '../../common/src/security/trusted_types';\n\nconst CAMEL_CASE = /([A-Z])/g;\nconst INITIAL_VALUE = {\n __UNINITIALIZED__: true,\n};\nconst NOT_SUPPORTED: any = 'NOT_SUPPORTED';\n\nfunction getInputPropertyMapName(name: string): string {\n return `input_${name}`;\n}\n\nfunction getOutputPropertyMapName(name: string): string {\n return `output_${name}`;\n}\n\nexport class UpgradeNg1ComponentAdapterBuilder {\n type: Type<any>;\n inputs: string[] = [];\n inputsRename: string[] = [];\n outputs: string[] = [];\n outputsRename: string[] = [];\n propertyOutputs: string[] = [];\n checkProperties: string[] = [];\n propertyMap: {[name: string]: string} = {};\n directive: IDirective | null = null;\n template!: string;\n\n constructor(public name: string) {\n const selector = name.replace(\n CAMEL_CASE,\n (all: string, next: string) => '-' + next.toLowerCase(),\n );\n const self = this;\n\n @Directive({\n jit: true,\n selector: selector,\n inputs: this.inputsRename,\n outputs: this.outputsRename,\n standalone: false,\n })\n class MyClass\n extends UpgradeNg1ComponentAdapter\n implements OnInit, OnChanges, DoCheck, OnDestroy\n {\n constructor(@Inject($SCOPE) scope: IScope, injector: Injector, elementRef: ElementRef) {\n super(\n new UpgradeHelper(injector, name, elementRef, self.directive || undefined),\n scope,\n self.template,\n self.inputs,\n self.outputs,\n self.propertyOutputs,\n self.checkProperties,\n self.propertyMap,\n ) as any;\n }\n }\n this.type = MyClass;\n }\n\n extractBindings() {\n const btcIsObject = typeof this.directive!.bindToController === 'object';\n if (btcIsObject && Object.keys(this.directive!.scope!).length) {\n throw new Error(\n `Binding definitions on scope and controller at the same time are not supported.`,\n );\n }\n\n const context = btcIsObject ? this.directive!.bindToController : this.directive!.scope;\n\n if (typeof context == 'object') {\n Object.keys(context).forEach((propName) => {\n const definition = context[propName];\n const bindingType = definition.charAt(0);\n const bindingOptions = definition.charAt(1);\n const attrName = definition.substring(bindingOptions === '?' ? 2 : 1) || propName;\n\n // QUESTION: What about `=*`? Ignore? Throw? Support?\n\n const inputName = getInputPropertyMapName(attrName);\n const inputNameRename = `${inputName}: ${attrName}`;\n const outputName = getOutputPropertyMapName(attrName);\n const outputNameRename = `${outputName}: ${attrName}`;\n const outputNameRenameChange = `${outputNameRename}Change`;\n\n switch (bindingType) {\n case '@':\n case '<':\n this.inputs.push(inputName);\n this.inputsRename.push(inputNameRename);\n this.propertyMap[inputName] = propName;\n break;\n case '=':\n this.inputs.push(inputName);\n this.inputsRename.push(inputNameRename);\n this.propertyMap[inputName] = propName;\n\n this.outputs.push(outputName);\n this.outputsRename.push(outputNameRenameChange);\n this.propertyMap[outputName] = propName;\n\n this.checkProperties.push(propName);\n this.propertyOutputs.push(outputName);\n break;\n case '&':\n this.outputs.push(outputName);\n this.outputsRename.push(outputNameRename);\n this.propertyMap[outputName] = propName;\n break;\n default:\n let json = JSON.stringify(context);\n throw new Error(\n `Unexpected mapping '${bindingType}' in '${json}' in '${this.name}' directive.`,\n );\n }\n });\n }\n }\n\n /**\n * Upgrade ng1 components into Angular.\n */\n static resolve(\n exportedComponents: {[name: string]: UpgradeNg1ComponentAdapterBuilder},\n $injector: IInjectorService,\n ): Promise<string[]> {\n const promises = Object.entries(exportedComponents).map(([name, exportedComponent]) => {\n exportedComponent.directive = UpgradeHelper.getDirective($injector, name);\n exportedComponent.extractBindings();\n\n return Promise.resolve(\n UpgradeHelper.getTemplate($injector, exportedComponent.directive, true),\n ).then((template) => (exportedComponent.template = template));\n });\n\n return Promise.all(promises);\n }\n}\n\n@Directive()\nclass UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck {\n private controllerInstance: IControllerInstance | null = null;\n destinationObj: IBindingDestination | null = null;\n checkLastValues: any[] = [];\n directive: IDirective;\n element: Element;\n $element: any = null;\n componentScope: IScope;\n\n constructor(\n private helper: UpgradeHelper,\n scope: IScope,\n private template: string,\n private inputs: string[],\n private outputs: string[],\n private propOuts: string[],\n private checkProperties: string[],\n private propertyMap: {[key: string]: string},\n ) {\n this.directive = helper.directive;\n this.element = helper.element;\n this.$element = helper.$element;\n this.componentScope = scope.$new(!!this.directive.scope);\n\n const controllerType = this.directive.controller;\n\n if (this.directive.bindToController && controllerType) {\n this.controllerInstance = this.helper.buildController(controllerType, this.componentScope);\n this.destinationObj = this.controllerInstance;\n } else {\n this.destinationObj = this.componentScope;\n }\n\n for (const input of this.inputs) {\n (this as any)[input] = null;\n }\n for (const output of this.outputs) {\n const emitter = ((this as any)[output] = new EventEmitter());\n if (this.propOuts.indexOf(output) === -1) {\n this.setComponentProperty(\n output,\n (\n (emitter) => (value: any) =>\n emitter.emit(value)\n )(emitter),\n );\n }\n }\n this.checkLastValues.push(...Array(propOuts.length).fill(INITIAL_VALUE));\n }\n\n ngOnInit() {\n // Collect contents, insert and compile template\n const attachChildNodes: ILinkFn | undefined = this.helper.prepareTransclusion();\n const linkFn = this.helper.compileTemplate(trustedHTMLFromLegacyTemplate(this.template));\n\n // Instantiate controller (if not already done so)\n const controllerType = this.directive.controller;\n const bindToController = this.directive.bindToController;\n if (controllerType && !bindToController) {\n this.controllerInstance = this.helper.buildController(controllerType, this.componentScope);\n }\n\n // Require other controllers\n const requiredControllers = this.helper.resolveAndBindRequiredControllers(\n this.controllerInstance,\n );\n\n // Hook: $onInit\n if (this.controllerInstance && isFunction(this.controllerInstance.$onInit)) {\n this.controllerInstance.$onInit();\n }\n\n // Linking\n const link = this.directive.link;\n const preLink = typeof link == 'object' && link.pre;\n const postLink = typeof link == 'object' ? link.post : link;\n const attrs: IAttributes = NOT_SUPPORTED;\n const transcludeFn: ITranscludeFunction = NOT_SUPPORTED;\n if (preLink) {\n preLink(this.componentScope, this.$element, attrs, requiredControllers, transcludeFn);\n }\n\n linkFn(this.componentScope, null!, {parentBoundTranscludeFn: attachChildNodes});\n\n if (postLink) {\n postLink(this.componentScope, this.$element, attrs, requiredControllers, transcludeFn);\n }\n\n // Hook: $postLink\n if (this.controllerInstance && isFunction(this.controllerInstance.$postLink)) {\n this.controllerInstance.$postLink();\n }\n }\n\n ngOnChanges(changes: SimpleChanges) {\n const ng1Changes: any = {};\n Object.keys(changes).forEach((propertyMapName) => {\n const change: SimpleChange = changes[propertyMapName];\n this.setComponentProperty(propertyMapName, change.currentValue);\n ng1Changes[this.propertyMap[propertyMapName]] = change;\n });\n\n if (isFunction(this.destinationObj!.$onChanges)) {\n this.destinationObj!.$onChanges!(ng1Changes);\n }\n }\n\n ngDoCheck() {\n const destinationObj = this.destinationObj;\n const lastValues = this.checkLastValues;\n const checkProperties = this.checkProperties;\n const propOuts = this.propOuts;\n checkProperties.forEach((propName, i) => {\n const value = destinationObj![propName];\n const last = lastValues[i];\n if (!strictEquals(last, value)) {\n const eventEmitter: EventEmitter<any> = (this as any)[propOuts[i]];\n eventEmitter.emit((lastValues[i] = value));\n }\n });\n\n if (this.controllerInstance && isFunction(this.controllerInstance.$doCheck)) {\n this.controllerInstance.$doCheck();\n }\n }\n\n ngOnDestroy() {\n this.helper.onDestroy(this.componentScope, this.controllerInstance);\n }\n\n setComponentProperty(name: string, value: any) {\n this.destinationObj![this.propertyMap[name]] = value;\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Compiler,\n CompilerOptions,\n Injector,\n NgModule,\n NgModuleRef,\n NgZone,\n resolveForwardRef,\n StaticProvider,\n Testability,\n Type,\n} from '@angular/core';\nimport {platformBrowserDynamic} from '@angular/platform-browser-dynamic';\n\nimport {\n bootstrap,\n element as angularElement,\n IAngularBootstrapConfig,\n IAugmentedJQuery,\n IInjectorService,\n IModule,\n IProvideService,\n IRootScopeService,\n ITestabilityService,\n module_ as angularModule,\n} from '../../common/src/angular1';\nimport {\n $$TESTABILITY,\n $COMPILE,\n $INJECTOR,\n $ROOT_SCOPE,\n COMPILER_KEY,\n INJECTOR_KEY,\n LAZY_MODULE_REF,\n NG_ZONE_KEY,\n UPGRADE_APP_TYPE_KEY,\n} from '../../common/src/constants';\nimport {downgradeComponent} from '../../common/src/downgrade_component';\nimport {downgradeInjectable} from '../../common/src/downgrade_injectable';\nimport {\n controllerKey,\n Deferred,\n destroyApp,\n LazyModuleRef,\n onError,\n UpgradeAppType,\n} from '../../common/src/util';\n\nimport {UpgradeNg1ComponentAdapterBuilder} from './upgrade_ng1_adapter';\n\n// Needed for the global `Zone` ambient types to be available.\nimport type {} from 'zone.js';\n\nlet upgradeCount: number = 0;\n\n/**\n * Use `UpgradeAdapter` to allow AngularJS and Angular to coexist in a single application.\n *\n * The `UpgradeAdapter` allows:\n * 1. creation of Angular component from AngularJS component directive\n * (See {@link UpgradeAdapter#upgradeNg1Component})\n * 2. creation of AngularJS directive from Angular component.\n * (See {@link UpgradeAdapter#downgradeNg2Component})\n * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks\n * coexisting in a single application.\n *\n * @usageNotes\n * ### Mental Model\n *\n * When reasoning about how a hybrid application works it is useful to have a mental model which\n * describes what is happening and explains what is happening at the lowest level.\n *\n * 1. There are two independent frameworks running in a single application, each framework treats\n * the other as a black box.\n * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework\n * instantiated the element is the owner. Each framework only updates/interacts with its own\n * DOM elements and ignores others.\n * 3. AngularJS directives always execute inside AngularJS framework codebase regardless of\n * where they are instantiated.\n * 4. Angular components always execute inside Angular framework codebase regardless of\n * where they are instantiated.\n * 5. An AngularJS component can be upgraded to an Angular component. This creates an\n * Angular directive, which bootstraps the AngularJS component directive in that location.\n * 6. An Angular component can be downgraded to an AngularJS component directive. This creates\n * an AngularJS directive, which bootstraps the Angular component in that location.\n * 7. Whenever an adapter component is instantiated the host element is owned by the framework\n * doing the instantiation. The other framework then instantiates and owns the view for that\n * component. This implies that component bindings will always follow the semantics of the\n * instantiation framework. The syntax is always that of Angular syntax.\n * 8. AngularJS is always bootstrapped first and owns the bottom most view.\n * 9. The new application is running in Angular zone, and therefore it no longer needs calls to\n * `$apply()`.\n *\n * ### Example\n *\n * ```ts\n * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module), myCompilerOptions);\n * const module = angular.module('myExample', []);\n * module.directive('ng2Comp', adapter.downgradeNg2Component(Ng2Component));\n *\n * module.directive('ng1Hello', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2-comp',\n * inputs: ['name'],\n * template: 'ng2[<ng1-hello [title]=\"name\">transclude</ng1-hello>](<ng-content></ng-content>)',\n * directives:\n * })\n * class Ng2Component {\n * }\n *\n * @NgModule({\n * declarations: [Ng2Component, adapter.upgradeNg1Component('ng1Hello')],\n * imports: [BrowserModule]\n * })\n * class MyNg2Module {}\n *\n *\n * document.body.innerHTML = '<ng2-comp name=\"World\">project</ng2-comp>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n *\n * ```\n *\n * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports\n * [Ahead-of-Time compilation](tools/cli/aot-compiler).\n * @publicApi\n */\nexport class UpgradeAdapter {\n private idPrefix: string = `NG2_UPGRADE_${upgradeCount++}_`;\n private downgradedComponents: Type<any>[] = [];\n /**\n * An internal map of ng1 components which need to up upgraded to ng2.\n *\n * We can't upgrade until injector is instantiated and we can retrieve the component metadata.\n * For this reason we keep a list of components to upgrade until ng1 injector is bootstrapped.\n *\n * @internal\n */\n private ng1ComponentsToBeUpgraded: {[name: string]: UpgradeNg1ComponentAdapterBuilder} = {};\n private upgradedProviders: StaticProvider[] = [];\n private moduleRef: NgModuleRef<any> | null = null;\n\n constructor(\n private ng2AppModule: Type<any>,\n private compilerOptions?: CompilerOptions,\n ) {\n if (!ng2AppModule) {\n throw new Error(\n 'UpgradeAdapter cannot be instantiated without an NgModule of the Angular app.',\n );\n }\n }\n\n /**\n * Allows Angular Component to be used from AngularJS.\n *\n * Use `downgradeNg2Component` to create an AngularJS Directive Definition Factory from\n * Angular Component. The adapter will bootstrap Angular component from within the\n * AngularJS template.\n *\n * @usageNotes\n * ### Mental Model\n *\n * 1. The component is instantiated by being listed in AngularJS template. This means that the\n * host element is controlled by AngularJS, but the component's view will be controlled by\n * Angular.\n * 2. Even thought the component is instantiated in AngularJS, it will be using Angular\n * syntax. This has to be done, this way because we must follow Angular components do not\n * declare how the attributes should be interpreted.\n * 3. `ng-model` is controlled by AngularJS and communicates with the downgraded Angular component\n * by way of the `ControlValueAccessor` interface from @angular/forms. Only components that\n * implement this interface are eligible.\n *\n * ### Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - ng-model: `<comp ng-model=\"name\">`\n * - Content projection: yes\n *\n * ### Example\n *\n * ```angular-ts\n * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module));\n * const module = angular.module('myExample', []);\n * module.directive('greet', adapter.downgradeNg2Component(Greeter));\n *\n * @Component({\n * selector: 'greet',\n * template: '{{salutation()}} {{name()}}! - <ng-content></ng-content>'\n * })\n * class Greeter {\n * salutation = input.required<string>();\n * name: input.required<string>();\n * }\n *\n * @NgModule({\n * declarations: [Greeter],\n * imports: [BrowserModule]\n * })\n * class MyNg2Module {}\n *\n * document.body.innerHTML =\n * 'ng1 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng1 template: Hello world! - text\");\n * });\n * ```\n */\n downgradeNg2Component(component: Type<any>): Function {\n this.downgradedComponents.push(component);\n\n return downgradeComponent({component});\n }\n\n /**\n * Allows AngularJS Component to be used from Angular.\n *\n * Use `upgradeNg1Component` to create an Angular component from AngularJS Component\n * directive. The adapter will bootstrap AngularJS component from within the Angular\n * template.\n *\n * @usageNotes\n * ### Mental Model\n *\n * 1. The component is instantiated by being listed in Angular template. This means that the\n * host element is controlled by Angular, but the component's view will be controlled by\n * AngularJS.\n *\n * ### Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - Transclusion: yes\n * - Only some of the features of\n * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are\n * supported:\n * - `compile`: not supported because the host element is owned by Angular, which does\n * not allow modifying DOM structure during compilation.\n * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.)\n * - `controllerAs`: supported.\n * - `bindToController`: supported.\n * - `link`: supported. (NOTE: only pre-link function is supported.)\n * - `name`: supported.\n * - `priority`: ignored.\n * - `replace`: not supported.\n * - `require`: supported.\n * - `restrict`: must be set to 'E'.\n * - `scope`: supported.\n * - `template`: supported.\n * - `templateUrl`: supported.\n * - `terminal`: ignored.\n * - `transclude`: supported.\n *\n *\n * ### Example\n *\n * ```angular-ts\n * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module));\n * const module = angular.module('myExample', []);\n *\n * module.directive('greet', function() {\n * return {\n * scope: {salutation: '=', name: '=' },\n * template: '{{salutation}} {{name}}! - <span ng-transclude></span>'\n * };\n * });\n *\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2Component));\n *\n * @Component({\n * selector: 'ng2',\n * template: 'ng2 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>'\n * })\n * class Ng2Component {\n * }\n *\n * @NgModule({\n * declarations: [Ng2Component, adapter.upgradeNg1Component('greet')],\n * imports: [BrowserModule]\n * })\n * class MyNg2Module {}\n *\n * document.body.innerHTML = '<ng2></ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng2 template: Hello world! - text\");\n * });\n * ```\n */\n upgradeNg1Component(name: string): Type<any> {\n if (this.ng1ComponentsToBeUpgraded.hasOwnProperty(name)) {\n return this.ng1ComponentsToBeUpgraded[name].type;\n } else {\n return (this.ng1ComponentsToBeUpgraded[name] = new UpgradeNg1ComponentAdapterBuilder(name))\n .type;\n }\n }\n\n /**\n * Registers the adapter's AngularJS upgrade module for unit testing in AngularJS.\n * Use this instead of `angular.mock.module()` to load the upgrade module into\n * the AngularJS testing injector.\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * const upgradeAdapter = new UpgradeAdapter(MyNg2Module);\n *\n * // configure the adapter with upgrade/downgrade components and services\n * upgradeAdapter.downgradeNg2Component(MyComponent);\n *\n * let upgradeAdapterRef: UpgradeAdapterRef;\n * let $compile, $rootScope;\n *\n * // We must register the adapter before any calls to `inject()`\n * beforeEach(() => {\n * upgradeAdapterRef = upgradeAdapter.registerForNg1Tests(['heroApp']);\n * });\n *\n * beforeEach(inject((_$compile_, _$rootScope_) => {\n * $compile = _$compile_;\n * $rootScope = _$rootScope_;\n * }));\n *\n * it(\"says hello\", (done) => {\n * upgradeAdapterRef.ready(() => {\n * const element = $compile(\"<my-component></my-component>\")($rootScope);\n * $rootScope.$apply();\n * expect(element.html()).toContain(\"Hello World\");\n * done();\n * })\n * });\n *\n * ```\n *\n * @param modules any AngularJS modules that the upgrade module should depend upon\n * @returns an `UpgradeAdapterRef`, which lets you register a `ready()` callback to\n * run assertions once the Angular components are ready to test through AngularJS.\n */\n registerForNg1Tests(modules?: string[]): UpgradeAdapterRef {\n const windowNgMock = (window as any)['angular'].mock;\n if (!windowNgMock || !windowNgMock.module) {\n throw new Error(\"Failed to find 'angular.mock.module'.\");\n }\n const {ng1Module, ng2BootstrapDeferred} = this.declareNg1Module(modules);\n windowNgMock.module(ng1Module.name);\n const upgrade = new UpgradeAdapterRef();\n ng2BootstrapDeferred.promise.then((ng1Injector) => {\n // @ts-expect-error\n upgrade._bootstrapDone(this.moduleRef!, ng1Injector);\n }, onError);\n return upgrade;\n }\n\n /**\n * Bootstrap a hybrid AngularJS / Angular application.\n *\n * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS\n * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike\n * AngularJS, this bootstrap is asynchronous.\n *\n * @usageNotes\n * ### Example\n *\n * ```angular-ts\n * const adapter = new UpgradeAdapter(MyNg2Module);\n * const module = angular.module('myExample', []);\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * module.directive('ng1', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2',\n * inputs: ['name'],\n * template: 'ng2[<ng1 [title]=\"name\">transclude</ng1>](<ng-content></ng-content>)'\n * })\n * class Ng2 {\n * }\n *\n * @NgModule({\n * declarations: [Ng2, adapter.upgradeNg1Component('ng1')],\n * imports: [BrowserModule]\n * })\n * class MyNg2Module {}\n *\n * document.body.innerHTML = '<ng2 name=\"World\">project</ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n * ```\n */\n bootstrap(\n element: Element,\n modules?: any[],\n config?: IAngularBootstrapConfig,\n ): UpgradeAdapterRef {\n const {ng1Module, ng2BootstrapDeferred, ngZone} = this.declareNg1Module(modules);\n\n const upgrade = new UpgradeAdapterRef();\n\n // Make sure resumeBootstrap() only exists if the current bootstrap is deferred\n const windowAngular = (window as any)['angular'];\n windowAngular.resumeBootstrap = undefined;\n\n ngZone.run(() => {\n bootstrap(element, [ng1Module.name], config!);\n });\n const ng1BootstrapPromise = new Promise<void>((resolve) => {\n if (windowAngular.resumeBootstrap) {\n const originalResumeBootstrap: () => void = windowAngular.resumeBootstrap;\n windowAngular.resumeBootstrap = function () {\n windowAngular.resumeBootstrap = originalResumeBootstrap;\n const r = windowAngular.resumeBootstrap.apply(this, arguments);\n resolve();\n return r;\n };\n } else {\n resolve();\n }\n });\n\n Promise.all([ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => {\n angularElement(element).data!(controllerKey(INJECTOR_KEY), this.moduleRef!.injector);\n this.moduleRef!.injector.get<NgZone>(NgZone).run(() => {\n // @ts-expect-error\n upgrade._bootstrapDone(this.moduleRef, ng1Injector);\n });\n }, onError);\n return upgrade;\n }\n\n /**\n * Allows AngularJS service to be accessible from Angular.\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * class Login { ... }\n * class Server { ... }\n *\n * @Injectable()\n * class Example {\n * constructor(@Inject('server') server, login: Login) {\n * ...\n * }\n * }\n *\n * const module = angular.module('myExample', []);\n * module.service('server', Server);\n * module.service('login', Login);\n *\n * const adapter = new UpgradeAdapter(MyNg2Module);\n * adapter.upgradeNg1Provider('server');\n * adapter.upgradeNg1Provider('login', {asToken: Login});\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * const example: Example = ref.ng2Injector.get(Example);\n * });\n *\n * ```\n */\n upgradeNg1Provider(name: string, options?: {asToken: any}) {\n const token = (options && options.asToken) || name;\n this.upgradedProviders.push({\n provide: token,\n useFactory: ($injector: IInjectorService) => $injector.get(name),\n deps: [$INJECTOR],\n });\n }\n\n /**\n * Allows Angular service to be accessible from AngularJS.\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * class Example {\n * }\n *\n * const adapter = new UpgradeAdapter(MyNg2Module);\n *\n * const module = angular.module('myExample', []);\n * module.factory('example', adapter.downgradeNg2Provider(Example));\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * const example: Example = ref.ng1Injector.get('example');\n * });\n *\n * ```\n */\n downgradeNg2Provider(token: any): Function {\n return downgradeInjectable(token);\n }\n\n /**\n * Declare the AngularJS upgrade module for this adapter without bootstrapping the whole\n * hybrid application.\n *\n * This method is automatically called by `bootstrap()` and `registerForNg1Tests()`.\n *\n * @param modules The AngularJS modules that this upgrade module should depend upon.\n * @returns The AngularJS upgrade module that is declared by this method\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * const upgradeAdapter = new UpgradeAdapter(MyNg2Module);\n * upgradeAdapter.declareNg1Module(['heroApp']);\n * ```\n */\n private declareNg1Module(modules: string[] = []): {\n ng1Module: IModule;\n ng2BootstrapDeferred: Deferred<IInjectorService>;\n ngZone: NgZone;\n } {\n const delayApplyExps: Function[] = [];\n let original$applyFn: Function;\n let rootScopePrototype: any;\n const upgradeAdapter = this;\n const ng1Module = angularModule(this.idPrefix, modules);\n const platformRef = platformBrowserDynamic();\n\n const ngZone = new NgZone({\n enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec'),\n });\n const ng2BootstrapDeferred = new Deferred<IInjectorService>();\n ng1Module\n .constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Dynamic)\n .factory(INJECTOR_KEY, () => this.moduleRef!.injector.get(Injector))\n .factory(LAZY_MODULE_REF, [\n INJECTOR_KEY,\n (injector: Injector) => ({injector}) as LazyModuleRef,\n ])\n .constant(NG_ZONE_KEY, ngZone)\n .factory(COMPILER_KEY, () => this.moduleRef!.injector.get(Compiler))\n .config([\n '$provide',\n '$injector',\n (provide: IProvideService, ng1Injector: IInjectorService) => {\n provide.decorator($ROOT_SCOPE, [\n '$delegate',\n function (rootScopeDelegate: IRootScopeService) {\n // Capture the root apply so that we can delay first call to $apply until we\n // bootstrap Angular and then we replay and restore the $apply.\n rootScopePrototype = rootScopeDelegate.constructor.prototype;\n if (rootScopePrototype.hasOwnProperty('$apply')) {\n original$applyFn = rootScopePrototype.$apply;\n rootScopePrototype.$apply = (exp: any) => delayApplyExps.push(exp);\n } else {\n throw new Error(\"Failed to find '$apply' on '$rootScope'!\");\n }\n return rootScopeDelegate;\n },\n ]);\n if (ng1Injector.has($$TESTABILITY)) {\n provide.decorator($$TESTABILITY, [\n '$delegate',\n function (testabilityDelegate: ITestabilityService) {\n const originalWhenStable: Function = testabilityDelegate.whenStable;\n // Cannot use arrow function below because we need the context\n const newWhenStable = function (this: unknown, callback: Function) {\n originalWhenStable.call(this, function (this: unknown) {\n const ng2Testability: Testability =\n upgradeAdapter.moduleRef!.injector.get(Testability);\n if (ng2Testability.isStable()) {\n callback.apply(this, arguments);\n } else {\n ng2Testability.whenStable(newWhenStable.bind(this, callback));\n }\n });\n };\n\n testabilityDelegate.whenStable = newWhenStable;\n return testabilityDelegate;\n },\n ]);\n }\n },\n ]);\n\n ng1Module.run([\n '$injector',\n '$rootScope',\n (ng1Injector: IInjectorService, rootScope: IRootScopeService) => {\n UpgradeNg1ComponentAdapterBuilder.resolve(this.ng1ComponentsToBeUpgraded, ng1Injector)\n .then(() => {\n // At this point we have ng1 injector and we have prepared\n // ng1 components to be upgraded, we now can bootstrap ng2.\n @NgModule({\n jit: true,\n providers: [\n {provide: $INJECTOR, useFactory: () => ng1Injector},\n {provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE)},\n this.upgradedProviders,\n ],\n imports: [resolveForwardRef(this.ng2AppModule)],\n })\n class DynamicNgUpgradeModule {\n ngDoBootstrap() {}\n }\n platformRef\n .bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions!, {ngZone}])\n .then((ref: NgModuleRef<any>) => {\n this.moduleRef = ref;\n ngZone.run(() => {\n if (rootScopePrototype) {\n rootScopePrototype.$apply = original$applyFn; // restore original $apply\n while (delayApplyExps.length) {\n rootScope.$apply(delayApplyExps.shift());\n }\n rootScopePrototype = null;\n }\n });\n })\n .then(() => ng2BootstrapDeferred.resolve(ng1Injector), onError)\n .then(() => {\n let subscription = ngZone.onMicrotaskEmpty.subscribe({\n next: () => {\n if (rootScope.$$phase) {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n console.warn(\n 'A digest was triggered while one was already in progress. This may mean that something is triggering digests outside the Angular zone.',\n );\n }\n\n return rootScope.$evalAsync(() => {});\n }\n\n return rootScope.$digest();\n },\n });\n rootScope.$on('$destroy', () => {\n subscription.unsubscribe();\n });\n\n // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.\n // This does not happen in a typical SPA scenario, but it might be useful for\n // other use-cases where disposing of an Angular/AngularJS app is necessary\n // (such as Hot Module Replacement (HMR)).\n // See https://github.com/angular/angular/issues/39935.\n platformRef.onDestroy(() => destroyApp(ng1Injector));\n });\n })\n .catch((e) => ng2BootstrapDeferred.reject(e));\n },\n ]);\n\n return {ng1Module, ng2BootstrapDeferred, ngZone};\n }\n}\n\n/**\n * Use `UpgradeAdapterRef` to control a hybrid AngularJS / Angular application.\n *\n * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports\n * [Ahead-of-Time compilation](tools/cli/aot-compiler).\n * @publicApi\n */\nexport class UpgradeAdapterRef {\n /* @internal */\n private _readyFn: ((upgradeAdapterRef: UpgradeAdapterRef) => void) | null = null;\n\n public ng1RootScope: IRootScopeService = null!;\n public ng1Injector: IInjectorService = null!;\n public ng2ModuleRef: NgModuleRef<any> = null!;\n public ng2Injector: Injector = null!;\n\n /* @internal */\n private _bootstrapDone(ngModuleRef: NgModuleRef<any>, ng1Injector: IInjectorService) {\n this.ng2ModuleRef = ngModuleRef;\n this.ng2Injector = ngModuleRef.injector;\n this.ng1Injector = ng1Injector;\n this.ng1RootScope = ng1Injector.get($ROOT_SCOPE);\n this._readyFn && this._readyFn(this);\n }\n\n /**\n * Register a callback function which is notified upon successful hybrid AngularJS / Angular\n * application has been bootstrapped.\n *\n * The `ready` callback function is invoked inside the Angular zone, therefore it does not\n * require a call to `$apply()`.\n */\n public ready(fn: (upgradeAdapterRef: UpgradeAdapterRef) => void) {\n this._readyFn = fn;\n }\n\n /**\n * Dispose of running hybrid AngularJS / Angular application.\n */\n public dispose() {\n this.ng1Injector!.get($ROOT_SCOPE).$destroy();\n this.ng2ModuleRef!.destroy();\n }\n}\n"],"names":["element","angularElement","angularModule"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,UAAU,GAAG,UAAU;AAC7B,MAAM,aAAa,GAAG;AACpB,IAAA,iBAAiB,EAAE,IAAI;CACxB;AACD,MAAM,aAAa,GAAQ,eAAe;AAE1C,SAAS,uBAAuB,CAAC,IAAY,EAAA;IAC3C,OAAO,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE;AACxB;AAEA,SAAS,wBAAwB,CAAC,IAAY,EAAA;IAC5C,OAAO,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE;AACzB;MAEa,iCAAiC,CAAA;AAYzB,IAAA,IAAA;AAXnB,IAAA,IAAI;IACJ,MAAM,GAAa,EAAE;IACrB,YAAY,GAAa,EAAE;IAC3B,OAAO,GAAa,EAAE;IACtB,aAAa,GAAa,EAAE;IAC5B,eAAe,GAAa,EAAE;IAC9B,eAAe,GAAa,EAAE;IAC9B,WAAW,GAA6B,EAAE;IAC1C,SAAS,GAAsB,IAAI;AACnC,IAAA,QAAQ;AAER,IAAA,WAAA,CAAmB,IAAY,EAAA;QAAZ,IAAI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