├── ANGULAR_PACKAGE ├── BUILD_INFO ├── LICENSE ├── README.md ├── angular1.d-C3xPg7Lm.d.ts ├── fesm2022 ├── constants-nqBIph3y.mjs ├── constants-nqBIph3y.mjs.map ├── static.mjs ├── static.mjs.map ├── static │ ├── testing.mjs │ └── testing.mjs.map ├── upgrade.mjs ├── upgrade.mjs.map ├── upgrade_helper-C850j0tg.mjs └── upgrade_helper-C850j0tg.mjs.map ├── index.d.ts ├── package.json └── static ├── index.d.ts └── testing └── index.d.ts /ANGULAR_PACKAGE: -------------------------------------------------------------------------------- 1 | This file is used by the npm/yarn_install rule to detect APF. See https://github.com/bazelbuild/rules_nodejs/issues/927 2 | -------------------------------------------------------------------------------- /BUILD_INFO: -------------------------------------------------------------------------------- 1 | Fri Jun 6 22:27:46 UTC 2025 2 | 21fc93bf4b2183114d7703dbea4e57c30b54c66e 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2025 Google LLC. https://angular.dev/license 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Angular 2 | ======= 3 | 4 | The sources for this package are in the main [Angular](https://github.com/angular/angular) repo. Please file issues and pull requests against that repo. 5 | 6 | Usage information and reference details can be found in [Angular documentation](https://angular.dev/overview). 7 | 8 | License: MIT 9 | -------------------------------------------------------------------------------- /angular1.d-C3xPg7Lm.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { Version } from '@angular/core'; 8 | 9 | /** 10 | * @module 11 | * @description 12 | * Entry point for all public APIs of the upgrade package. 13 | */ 14 | 15 | /** 16 | * @publicApi 17 | */ 18 | declare const VERSION: Version; 19 | 20 | type Ng1Token = string; 21 | type Ng1Expression = string | Function; 22 | interface IAnnotatedFunction extends Function { 23 | $inject?: Function extends { 24 | $inject?: string[]; 25 | } ? Ng1Token[] : ReadonlyArray; 26 | } 27 | type IInjectable = (Ng1Token | Function)[] | IAnnotatedFunction; 28 | type SingleOrListOrMap = T | T[] | { 29 | [key: string]: T; 30 | }; 31 | interface IModule { 32 | name: string; 33 | requires: (string | IInjectable)[]; 34 | config(fn: IInjectable): IModule; 35 | directive(selector: string, factory: IInjectable): IModule; 36 | component(selector: string, component: IComponent): IModule; 37 | controller(name: string, type: IInjectable): IModule; 38 | factory(key: Ng1Token, factoryFn: IInjectable): IModule; 39 | value(key: Ng1Token, value: any): IModule; 40 | constant(token: Ng1Token, value: any): IModule; 41 | run(a: IInjectable): IModule; 42 | } 43 | interface ICompileService { 44 | (element: Element | NodeList | Node[] | string, transclude?: Function): ILinkFn; 45 | } 46 | interface ILinkFn { 47 | (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ILinkFnOptions): IAugmentedJQuery; 48 | $$slots?: { 49 | [slotName: string]: ILinkFn; 50 | }; 51 | } 52 | interface ILinkFnOptions { 53 | parentBoundTranscludeFn?: Function; 54 | transcludeControllers?: { 55 | [key: string]: any; 56 | }; 57 | futureParentElement?: Node; 58 | } 59 | interface IRootScopeService { 60 | $new(isolate?: boolean): IScope; 61 | $id: string; 62 | $parent: IScope; 63 | $root: IScope; 64 | $watch(exp: Ng1Expression, fn?: (a1?: any, a2?: any) => void): Function; 65 | $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; 66 | $destroy(): any; 67 | $apply(exp?: Ng1Expression): any; 68 | $digest(): any; 69 | $evalAsync(exp: Ng1Expression, locals?: any): void; 70 | $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; 71 | $$childTail: IScope; 72 | $$childHead: IScope; 73 | $$nextSibling: IScope; 74 | $$phase: any; 75 | [key: string]: any; 76 | } 77 | interface IScope extends IRootScopeService { 78 | } 79 | interface IAngularBootstrapConfig { 80 | strictDi?: boolean; 81 | } 82 | interface IDirective { 83 | compile?: IDirectiveCompileFn; 84 | controller?: IController; 85 | controllerAs?: string; 86 | bindToController?: boolean | { 87 | [key: string]: string; 88 | }; 89 | link?: IDirectiveLinkFn | IDirectivePrePost; 90 | name?: string; 91 | priority?: number; 92 | replace?: boolean; 93 | require?: DirectiveRequireProperty; 94 | restrict?: string; 95 | scope?: boolean | { 96 | [key: string]: string; 97 | }; 98 | template?: string | Function; 99 | templateUrl?: string | Function; 100 | templateNamespace?: string; 101 | terminal?: boolean; 102 | transclude?: DirectiveTranscludeProperty; 103 | } 104 | type DirectiveRequireProperty = SingleOrListOrMap; 105 | type DirectiveTranscludeProperty = boolean | 'element' | { 106 | [key: string]: string; 107 | }; 108 | interface IDirectiveCompileFn { 109 | (templateElement: IAugmentedJQuery, templateAttributes: IAttributes, transclude: ITranscludeFunction): IDirectivePrePost; 110 | } 111 | interface IDirectivePrePost { 112 | pre?: IDirectiveLinkFn; 113 | post?: IDirectiveLinkFn; 114 | } 115 | interface IDirectiveLinkFn { 116 | (scope: IScope, instanceElement: IAugmentedJQuery, instanceAttributes: IAttributes, controller: any, transclude: ITranscludeFunction): void; 117 | } 118 | interface IComponent { 119 | bindings?: { 120 | [key: string]: string; 121 | }; 122 | controller?: string | IInjectable; 123 | controllerAs?: string; 124 | require?: DirectiveRequireProperty; 125 | template?: string | Function; 126 | templateUrl?: string | Function; 127 | transclude?: DirectiveTranscludeProperty; 128 | } 129 | interface IAttributes { 130 | $observe(attr: string, fn: (v: string) => void): void; 131 | [key: string]: any; 132 | } 133 | interface ITranscludeFunction { 134 | (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; 135 | (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; 136 | } 137 | interface ICloneAttachFunction { 138 | (clonedElement: IAugmentedJQuery, scope: IScope): any; 139 | } 140 | type IAugmentedJQuery = Node[] & { 141 | on?: (name: string, fn: () => void) => void; 142 | data?: (name: string, value?: any) => any; 143 | text?: () => string; 144 | inheritedData?: (name: string, value?: any) => any; 145 | children?: () => IAugmentedJQuery; 146 | contents?: () => IAugmentedJQuery; 147 | parent?: () => IAugmentedJQuery; 148 | empty?: () => void; 149 | append?: (content: IAugmentedJQuery | string) => IAugmentedJQuery; 150 | controller?: (name: string) => any; 151 | isolateScope?: () => IScope; 152 | injector?: () => IInjectorService; 153 | triggerHandler?: (eventTypeOrObject: string | Event, extraParameters?: any[]) => IAugmentedJQuery; 154 | remove?: () => void; 155 | removeData?: () => void; 156 | }; 157 | interface IProvider { 158 | $get: IInjectable; 159 | } 160 | interface IProvideService { 161 | provider(token: Ng1Token, provider: IProvider): IProvider; 162 | factory(token: Ng1Token, factory: IInjectable): IProvider; 163 | service(token: Ng1Token, type: IInjectable): IProvider; 164 | value(token: Ng1Token, value: any): IProvider; 165 | constant(token: Ng1Token, value: any): void; 166 | decorator(token: Ng1Token, factory: IInjectable): void; 167 | } 168 | interface IParseService { 169 | (expression: string): ICompiledExpression; 170 | } 171 | interface ICompiledExpression { 172 | (context: any, locals: any): any; 173 | assign?: (context: any, value: any) => any; 174 | } 175 | interface IHttpBackendService { 176 | (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; 177 | } 178 | interface ICacheObject { 179 | put(key: string, value?: T): T; 180 | get(key: string): any; 181 | } 182 | interface ITemplateCacheService extends ICacheObject { 183 | } 184 | type IController = string | IInjectable; 185 | interface IControllerService { 186 | (controllerConstructor: IController, locals?: any, later?: any, ident?: any): any; 187 | (controllerName: string, locals?: any): any; 188 | } 189 | interface IInjectorService { 190 | get(key: string): any; 191 | has(key: string): boolean; 192 | } 193 | interface IIntervalService { 194 | (func: Function, delay: number, count?: number, invokeApply?: boolean, ...args: any[]): Promise; 195 | cancel(promise: Promise): boolean; 196 | } 197 | interface ITestabilityService { 198 | findBindings(element: Element, expression: string, opt_exactMatch?: boolean): Element[]; 199 | findModels(element: Element, expression: string, opt_exactMatch?: boolean): Element[]; 200 | getLocation(): string; 201 | setLocation(url: string): void; 202 | whenStable(callback: Function): void; 203 | } 204 | interface INgModelController { 205 | $render(): void; 206 | $isEmpty(value: any): boolean; 207 | $setValidity(validationErrorKey: string, isValid: boolean): void; 208 | $setPristine(): void; 209 | $setDirty(): void; 210 | $setUntouched(): void; 211 | $setTouched(): void; 212 | $rollbackViewValue(): void; 213 | $validate(): void; 214 | $commitViewValue(): void; 215 | $setViewValue(value: any, trigger: string): void; 216 | $viewValue: any; 217 | $modelValue: any; 218 | $parsers: Function[]; 219 | $formatters: Function[]; 220 | $validators: { 221 | [key: string]: Function; 222 | }; 223 | $asyncValidators: { 224 | [key: string]: Function; 225 | }; 226 | $viewChangeListeners: Function[]; 227 | $error: Object; 228 | $pending: Object; 229 | $untouched: boolean; 230 | $touched: boolean; 231 | $pristine: boolean; 232 | $dirty: boolean; 233 | $valid: boolean; 234 | $invalid: boolean; 235 | $name: string; 236 | } 237 | declare let angular: { 238 | bootstrap: (e: Element, modules: (string | IInjectable)[], config?: IAngularBootstrapConfig) => IInjectorService; 239 | module: (prefix: string, dependencies?: string[]) => IModule; 240 | element: { 241 | (e: string | Element | Document | IAugmentedJQuery): IAugmentedJQuery; 242 | cleanData: (nodes: Node[] | NodeList) => void; 243 | }; 244 | injector: (modules: Array, strictDi?: boolean) => IInjectorService; 245 | version: { 246 | major: number; 247 | }; 248 | resumeBootstrap: () => void; 249 | getTestability: (e: Element) => ITestabilityService; 250 | }; 251 | /** 252 | * @deprecated Use `setAngularJSGlobal` instead. 253 | * 254 | * @publicApi 255 | */ 256 | declare function setAngularLib(ng: any): void; 257 | /** 258 | * @deprecated Use `getAngularJSGlobal` instead. 259 | * 260 | * @publicApi 261 | */ 262 | declare function getAngularLib(): any; 263 | /** 264 | * Resets the AngularJS global. 265 | * 266 | * Used when AngularJS is loaded lazily, and not available on `window`. 267 | * 268 | * @publicApi 269 | */ 270 | declare function setAngularJSGlobal(ng: any): void; 271 | /** 272 | * Returns the current AngularJS global. 273 | * 274 | * @publicApi 275 | */ 276 | declare function getAngularJSGlobal(): any; 277 | declare const bootstrap: typeof angular.bootstrap; 278 | declare const module_: typeof angular.module; 279 | declare const element: typeof angular.element; 280 | declare const injector: typeof angular.injector; 281 | declare const resumeBootstrap: typeof angular.resumeBootstrap; 282 | declare const getTestability: typeof angular.getTestability; 283 | 284 | type angular1_d_DirectiveRequireProperty = DirectiveRequireProperty; 285 | type angular1_d_DirectiveTranscludeProperty = DirectiveTranscludeProperty; 286 | type angular1_d_IAngularBootstrapConfig = IAngularBootstrapConfig; 287 | type angular1_d_IAnnotatedFunction = IAnnotatedFunction; 288 | type angular1_d_IAttributes = IAttributes; 289 | type angular1_d_IAugmentedJQuery = IAugmentedJQuery; 290 | type angular1_d_ICacheObject = ICacheObject; 291 | type angular1_d_ICloneAttachFunction = ICloneAttachFunction; 292 | type angular1_d_ICompileService = ICompileService; 293 | type angular1_d_ICompiledExpression = ICompiledExpression; 294 | type angular1_d_IComponent = IComponent; 295 | type angular1_d_IController = IController; 296 | type angular1_d_IControllerService = IControllerService; 297 | type angular1_d_IDirective = IDirective; 298 | type angular1_d_IDirectiveCompileFn = IDirectiveCompileFn; 299 | type angular1_d_IDirectiveLinkFn = IDirectiveLinkFn; 300 | type angular1_d_IDirectivePrePost = IDirectivePrePost; 301 | type angular1_d_IHttpBackendService = IHttpBackendService; 302 | type angular1_d_IInjectable = IInjectable; 303 | type angular1_d_IInjectorService = IInjectorService; 304 | type angular1_d_IIntervalService = IIntervalService; 305 | type angular1_d_ILinkFn = ILinkFn; 306 | type angular1_d_ILinkFnOptions = ILinkFnOptions; 307 | type angular1_d_IModule = IModule; 308 | type angular1_d_INgModelController = INgModelController; 309 | type angular1_d_IParseService = IParseService; 310 | type angular1_d_IProvideService = IProvideService; 311 | type angular1_d_IProvider = IProvider; 312 | type angular1_d_IRootScopeService = IRootScopeService; 313 | type angular1_d_IScope = IScope; 314 | type angular1_d_ITemplateCacheService = ITemplateCacheService; 315 | type angular1_d_ITestabilityService = ITestabilityService; 316 | type angular1_d_ITranscludeFunction = ITranscludeFunction; 317 | type angular1_d_Ng1Expression = Ng1Expression; 318 | type angular1_d_Ng1Token = Ng1Token; 319 | type angular1_d_SingleOrListOrMap = SingleOrListOrMap; 320 | declare const angular1_d_bootstrap: typeof bootstrap; 321 | declare const angular1_d_element: typeof element; 322 | declare const angular1_d_getAngularJSGlobal: typeof getAngularJSGlobal; 323 | declare const angular1_d_getAngularLib: typeof getAngularLib; 324 | declare const angular1_d_getTestability: typeof getTestability; 325 | declare const angular1_d_injector: typeof injector; 326 | declare const angular1_d_module_: typeof module_; 327 | declare const angular1_d_resumeBootstrap: typeof resumeBootstrap; 328 | declare const angular1_d_setAngularJSGlobal: typeof setAngularJSGlobal; 329 | declare const angular1_d_setAngularLib: typeof setAngularLib; 330 | declare namespace angular1_d { 331 | export { angular1_d_bootstrap as bootstrap, angular1_d_element as element, angular1_d_getAngularJSGlobal as getAngularJSGlobal, angular1_d_getAngularLib as getAngularLib, angular1_d_getTestability as getTestability, angular1_d_injector as injector, angular1_d_module_ as module_, angular1_d_resumeBootstrap as resumeBootstrap, angular1_d_setAngularJSGlobal as setAngularJSGlobal, angular1_d_setAngularLib as setAngularLib }; 332 | export type { angular1_d_DirectiveRequireProperty as DirectiveRequireProperty, angular1_d_DirectiveTranscludeProperty as DirectiveTranscludeProperty, angular1_d_IAngularBootstrapConfig as IAngularBootstrapConfig, angular1_d_IAnnotatedFunction as IAnnotatedFunction, angular1_d_IAttributes as IAttributes, angular1_d_IAugmentedJQuery as IAugmentedJQuery, angular1_d_ICacheObject as ICacheObject, angular1_d_ICloneAttachFunction as ICloneAttachFunction, angular1_d_ICompileService as ICompileService, angular1_d_ICompiledExpression as ICompiledExpression, angular1_d_IComponent as IComponent, angular1_d_IController as IController, angular1_d_IControllerService as IControllerService, angular1_d_IDirective as IDirective, angular1_d_IDirectiveCompileFn as IDirectiveCompileFn, angular1_d_IDirectiveLinkFn as IDirectiveLinkFn, angular1_d_IDirectivePrePost as IDirectivePrePost, angular1_d_IHttpBackendService as IHttpBackendService, angular1_d_IInjectable as IInjectable, angular1_d_IInjectorService as IInjectorService, angular1_d_IIntervalService as IIntervalService, angular1_d_ILinkFn as ILinkFn, angular1_d_ILinkFnOptions as ILinkFnOptions, angular1_d_IModule as IModule, angular1_d_INgModelController as INgModelController, angular1_d_IParseService as IParseService, angular1_d_IProvideService as IProvideService, angular1_d_IProvider as IProvider, angular1_d_IRootScopeService as IRootScopeService, angular1_d_IScope as IScope, angular1_d_ITemplateCacheService as ITemplateCacheService, angular1_d_ITestabilityService as ITestabilityService, angular1_d_ITranscludeFunction as ITranscludeFunction, angular1_d_Ng1Expression as Ng1Expression, angular1_d_Ng1Token as Ng1Token, angular1_d_SingleOrListOrMap as SingleOrListOrMap }; 333 | } 334 | 335 | export { VERSION, angular1_d, getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib }; 336 | export type { IAngularBootstrapConfig, IAugmentedJQuery, IController, IDirective, IInjectorService, ILinkFn, INgModelController, IRootScopeService, IScope, SingleOrListOrMap }; 337 | -------------------------------------------------------------------------------- /fesm2022/constants-nqBIph3y.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | function noNg() { 8 | throw new Error('AngularJS v1.x is not loaded!'); 9 | } 10 | const noNgElement = (() => noNg()); 11 | noNgElement.cleanData = noNg; 12 | let angular = { 13 | bootstrap: noNg, 14 | module: noNg, 15 | element: noNgElement, 16 | injector: noNg, 17 | version: undefined, 18 | resumeBootstrap: noNg, 19 | getTestability: noNg, 20 | }; 21 | try { 22 | if (window.hasOwnProperty('angular')) { 23 | angular = window.angular; 24 | } 25 | } 26 | catch { 27 | // ignore in CJS mode. 28 | } 29 | /** 30 | * @deprecated Use `setAngularJSGlobal` instead. 31 | * 32 | * @publicApi 33 | */ 34 | function setAngularLib(ng) { 35 | setAngularJSGlobal(ng); 36 | } 37 | /** 38 | * @deprecated Use `getAngularJSGlobal` instead. 39 | * 40 | * @publicApi 41 | */ 42 | function getAngularLib() { 43 | return getAngularJSGlobal(); 44 | } 45 | /** 46 | * Resets the AngularJS global. 47 | * 48 | * Used when AngularJS is loaded lazily, and not available on `window`. 49 | * 50 | * @publicApi 51 | */ 52 | function setAngularJSGlobal(ng) { 53 | angular = ng; 54 | } 55 | /** 56 | * Returns the current AngularJS global. 57 | * 58 | * @publicApi 59 | */ 60 | function getAngularJSGlobal() { 61 | return angular; 62 | } 63 | const bootstrap = (e, modules, config) => angular.bootstrap(e, modules, config); 64 | // Do not declare as `module` to avoid webpack bug 65 | // (see https://github.com/angular/angular/issues/30050). 66 | const module_ = (prefix, dependencies) => angular.module(prefix, dependencies); 67 | const element = ((e) => angular.element(e)); 68 | element.cleanData = (nodes) => angular.element.cleanData(nodes); 69 | const injector = (modules, strictDi) => angular.injector(modules, strictDi); 70 | const resumeBootstrap = () => angular.resumeBootstrap(); 71 | const getTestability = (e) => angular.getTestability(e); 72 | 73 | var angular1 = /*#__PURE__*/Object.freeze({ 74 | __proto__: null, 75 | bootstrap: bootstrap, 76 | element: element, 77 | getAngularJSGlobal: getAngularJSGlobal, 78 | getAngularLib: getAngularLib, 79 | getTestability: getTestability, 80 | injector: injector, 81 | module_: module_, 82 | resumeBootstrap: resumeBootstrap, 83 | setAngularJSGlobal: setAngularJSGlobal, 84 | setAngularLib: setAngularLib 85 | }); 86 | 87 | const $COMPILE = '$compile'; 88 | const $CONTROLLER = '$controller'; 89 | const $DELEGATE = '$delegate'; 90 | const $EXCEPTION_HANDLER = '$exceptionHandler'; 91 | const $HTTP_BACKEND = '$httpBackend'; 92 | const $INJECTOR = '$injector'; 93 | const $INTERVAL = '$interval'; 94 | const $PARSE = '$parse'; 95 | const $PROVIDE = '$provide'; 96 | const $ROOT_ELEMENT = '$rootElement'; 97 | const $ROOT_SCOPE = '$rootScope'; 98 | const $SCOPE = '$scope'; 99 | const $TEMPLATE_CACHE = '$templateCache'; 100 | const $TEMPLATE_REQUEST = '$templateRequest'; 101 | const $$TESTABILITY = '$$testability'; 102 | const COMPILER_KEY = '$$angularCompiler'; 103 | const DOWNGRADED_MODULE_COUNT_KEY = '$$angularDowngradedModuleCount'; 104 | const GROUP_PROJECTABLE_NODES_KEY = '$$angularGroupProjectableNodes'; 105 | const INJECTOR_KEY = '$$angularInjector'; 106 | const LAZY_MODULE_REF = '$$angularLazyModuleRef'; 107 | const NG_ZONE_KEY = '$$angularNgZone'; 108 | const UPGRADE_APP_TYPE_KEY = '$$angularUpgradeAppType'; 109 | const REQUIRE_INJECTOR = '?^^' + INJECTOR_KEY; 110 | const REQUIRE_NG_MODEL = '?ngModel'; 111 | const UPGRADE_MODULE_NAME = '$$UpgradeModule'; 112 | 113 | var constants = /*#__PURE__*/Object.freeze({ 114 | __proto__: null, 115 | $$TESTABILITY: $$TESTABILITY, 116 | $COMPILE: $COMPILE, 117 | $CONTROLLER: $CONTROLLER, 118 | $DELEGATE: $DELEGATE, 119 | $EXCEPTION_HANDLER: $EXCEPTION_HANDLER, 120 | $HTTP_BACKEND: $HTTP_BACKEND, 121 | $INJECTOR: $INJECTOR, 122 | $INTERVAL: $INTERVAL, 123 | $PARSE: $PARSE, 124 | $PROVIDE: $PROVIDE, 125 | $ROOT_ELEMENT: $ROOT_ELEMENT, 126 | $ROOT_SCOPE: $ROOT_SCOPE, 127 | $SCOPE: $SCOPE, 128 | $TEMPLATE_CACHE: $TEMPLATE_CACHE, 129 | $TEMPLATE_REQUEST: $TEMPLATE_REQUEST, 130 | COMPILER_KEY: COMPILER_KEY, 131 | DOWNGRADED_MODULE_COUNT_KEY: DOWNGRADED_MODULE_COUNT_KEY, 132 | GROUP_PROJECTABLE_NODES_KEY: GROUP_PROJECTABLE_NODES_KEY, 133 | INJECTOR_KEY: INJECTOR_KEY, 134 | LAZY_MODULE_REF: LAZY_MODULE_REF, 135 | NG_ZONE_KEY: NG_ZONE_KEY, 136 | REQUIRE_INJECTOR: REQUIRE_INJECTOR, 137 | REQUIRE_NG_MODEL: REQUIRE_NG_MODEL, 138 | UPGRADE_APP_TYPE_KEY: UPGRADE_APP_TYPE_KEY, 139 | UPGRADE_MODULE_NAME: UPGRADE_MODULE_NAME 140 | }); 141 | 142 | export { $$TESTABILITY, $COMPILE, $CONTROLLER, $DELEGATE, $HTTP_BACKEND, $INJECTOR, $INTERVAL, $PARSE, $PROVIDE, $ROOT_ELEMENT, $ROOT_SCOPE, $SCOPE, $TEMPLATE_CACHE, COMPILER_KEY, DOWNGRADED_MODULE_COUNT_KEY, INJECTOR_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, REQUIRE_INJECTOR, REQUIRE_NG_MODEL, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME, angular1, bootstrap, constants, element, getAngularJSGlobal, getAngularLib, injector, module_, setAngularJSGlobal, setAngularLib }; 143 | //# sourceMappingURL=constants-nqBIph3y.mjs.map 144 | -------------------------------------------------------------------------------- /fesm2022/constants-nqBIph3y.mjs.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"constants-nqBIph3y.mjs","sources":["../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/upgrade/src/common/src/angular1.ts","../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/upgrade/src/common/src/constants.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\nexport type Ng1Token = string;\n\nexport type Ng1Expression = string | Function;\n\nexport interface IAnnotatedFunction extends Function {\n // Older versions of `@types/angular` typings extend the global `Function` interface with\n // `$inject?: string[]`, which is not compatible with `$inject?: ReadonlyArray` (used in\n // latest versions).\n $inject?: Function extends {$inject?: string[]} ? Ng1Token[] : ReadonlyArray;\n}\n\nexport type IInjectable = (Ng1Token | Function)[] | IAnnotatedFunction;\n\nexport type SingleOrListOrMap = T | T[] | {[key: string]: T};\n\nexport interface IModule {\n name: string;\n requires: (string | IInjectable)[];\n config(fn: IInjectable): IModule;\n directive(selector: string, factory: IInjectable): IModule;\n component(selector: string, component: IComponent): IModule;\n controller(name: string, type: IInjectable): IModule;\n factory(key: Ng1Token, factoryFn: IInjectable): IModule;\n value(key: Ng1Token, value: any): IModule;\n constant(token: Ng1Token, value: any): IModule;\n run(a: IInjectable): IModule;\n}\nexport interface ICompileService {\n (element: Element | NodeList | Node[] | string, transclude?: Function): ILinkFn;\n}\nexport interface ILinkFn {\n (scope: IScope, cloneAttachFn?: ICloneAttachFunction, options?: ILinkFnOptions): IAugmentedJQuery;\n $$slots?: {[slotName: string]: ILinkFn};\n}\nexport interface ILinkFnOptions {\n parentBoundTranscludeFn?: Function;\n transcludeControllers?: {[key: string]: any};\n futureParentElement?: Node;\n}\nexport interface IRootScopeService {\n $new(isolate?: boolean): IScope;\n $id: string;\n $parent: IScope;\n $root: IScope;\n $watch(exp: Ng1Expression, fn?: (a1?: any, a2?: any) => void): Function;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $destroy(): any;\n $apply(exp?: Ng1Expression): any;\n $digest(): any;\n $evalAsync(exp: Ng1Expression, locals?: any): void;\n $on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;\n $$childTail: IScope;\n $$childHead: IScope;\n $$nextSibling: IScope;\n $$phase: any;\n [key: string]: any;\n}\nexport interface IScope extends IRootScopeService {}\n\nexport interface IAngularBootstrapConfig {\n strictDi?: boolean;\n}\nexport interface IDirective {\n compile?: IDirectiveCompileFn;\n controller?: IController;\n controllerAs?: string;\n bindToController?: boolean | {[key: string]: string};\n link?: IDirectiveLinkFn | IDirectivePrePost;\n name?: string;\n priority?: number;\n replace?: boolean;\n require?: DirectiveRequireProperty;\n restrict?: string;\n scope?: boolean | {[key: string]: string};\n template?: string | Function;\n templateUrl?: string | Function;\n templateNamespace?: string;\n terminal?: boolean;\n transclude?: DirectiveTranscludeProperty;\n}\nexport type DirectiveRequireProperty = SingleOrListOrMap;\nexport type DirectiveTranscludeProperty = boolean | 'element' | {[key: string]: string};\nexport interface IDirectiveCompileFn {\n (\n templateElement: IAugmentedJQuery,\n templateAttributes: IAttributes,\n transclude: ITranscludeFunction,\n ): IDirectivePrePost;\n}\nexport interface IDirectivePrePost {\n pre?: IDirectiveLinkFn;\n post?: IDirectiveLinkFn;\n}\nexport interface IDirectiveLinkFn {\n (\n scope: IScope,\n instanceElement: IAugmentedJQuery,\n instanceAttributes: IAttributes,\n controller: any,\n transclude: ITranscludeFunction,\n ): void;\n}\nexport interface IComponent {\n bindings?: {[key: string]: string};\n controller?: string | IInjectable;\n controllerAs?: string;\n require?: DirectiveRequireProperty;\n template?: string | Function;\n templateUrl?: string | Function;\n transclude?: DirectiveTranscludeProperty;\n}\nexport interface IAttributes {\n $observe(attr: string, fn: (v: string) => void): void;\n [key: string]: any;\n}\nexport interface ITranscludeFunction {\n // If the scope is provided, then the cloneAttachFn must be as well.\n (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;\n // If one argument is provided, then it's assumed to be the cloneAttachFn.\n (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;\n}\nexport interface ICloneAttachFunction {\n (clonedElement: IAugmentedJQuery, scope: IScope): any;\n}\nexport type IAugmentedJQuery = Node[] & {\n on?: (name: string, fn: () => void) => void;\n data?: (name: string, value?: any) => any;\n text?: () => string;\n inheritedData?: (name: string, value?: any) => any;\n children?: () => IAugmentedJQuery;\n contents?: () => IAugmentedJQuery;\n parent?: () => IAugmentedJQuery;\n empty?: () => void;\n append?: (content: IAugmentedJQuery | string) => IAugmentedJQuery;\n controller?: (name: string) => any;\n isolateScope?: () => IScope;\n injector?: () => IInjectorService;\n triggerHandler?: (eventTypeOrObject: string | Event, extraParameters?: any[]) => IAugmentedJQuery;\n remove?: () => void;\n removeData?: () => void;\n};\nexport interface IProvider {\n $get: IInjectable;\n}\nexport interface IProvideService {\n provider(token: Ng1Token, provider: IProvider): IProvider;\n factory(token: Ng1Token, factory: IInjectable): IProvider;\n service(token: Ng1Token, type: IInjectable): IProvider;\n value(token: Ng1Token, value: any): IProvider;\n constant(token: Ng1Token, value: any): void;\n decorator(token: Ng1Token, factory: IInjectable): void;\n}\nexport interface IParseService {\n (expression: string): ICompiledExpression;\n}\nexport interface ICompiledExpression {\n (context: any, locals: any): any;\n assign?: (context: any, value: any) => any;\n}\nexport interface IHttpBackendService {\n (\n method: string,\n url: string,\n post?: any,\n callback?: Function,\n headers?: any,\n timeout?: number,\n withCredentials?: boolean,\n ): void;\n}\nexport interface ICacheObject {\n put(key: string, value?: T): T;\n get(key: string): any;\n}\nexport interface ITemplateCacheService extends ICacheObject {}\nexport type IController = string | IInjectable;\nexport interface IControllerService {\n (controllerConstructor: IController, locals?: any, later?: any, ident?: any): any;\n (controllerName: string, locals?: any): any;\n}\n\nexport interface IInjectorService {\n get(key: string): any;\n has(key: string): boolean;\n}\n\nexport interface IIntervalService {\n (\n func: Function,\n delay: number,\n count?: number,\n invokeApply?: boolean,\n ...args: any[]\n ): Promise;\n cancel(promise: Promise): boolean;\n}\n\nexport interface ITestabilityService {\n findBindings(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n findModels(element: Element, expression: string, opt_exactMatch?: boolean): Element[];\n getLocation(): string;\n setLocation(url: string): void;\n whenStable(callback: Function): void;\n}\n\nexport interface INgModelController {\n $render(): void;\n $isEmpty(value: any): boolean;\n $setValidity(validationErrorKey: string, isValid: boolean): void;\n $setPristine(): void;\n $setDirty(): void;\n $setUntouched(): void;\n $setTouched(): void;\n $rollbackViewValue(): void;\n $validate(): void;\n $commitViewValue(): void;\n $setViewValue(value: any, trigger: string): void;\n\n $viewValue: any;\n $modelValue: any;\n $parsers: Function[];\n $formatters: Function[];\n $validators: {[key: string]: Function};\n $asyncValidators: {[key: string]: Function};\n $viewChangeListeners: Function[];\n $error: Object;\n $pending: Object;\n $untouched: boolean;\n $touched: boolean;\n $pristine: boolean;\n $dirty: boolean;\n $valid: boolean;\n $invalid: boolean;\n $name: string;\n}\n\nfunction noNg(): never {\n throw new Error('AngularJS v1.x is not loaded!');\n}\n\nconst noNgElement: typeof angular.element = (() => noNg()) as any;\nnoNgElement.cleanData = noNg;\n\nlet angular: {\n bootstrap: (\n e: Element,\n modules: (string | IInjectable)[],\n config?: IAngularBootstrapConfig,\n ) => IInjectorService;\n module: (prefix: string, dependencies?: string[]) => IModule;\n element: {\n (e: string | Element | Document | IAugmentedJQuery): IAugmentedJQuery;\n cleanData: (nodes: Node[] | NodeList) => void;\n };\n injector: (modules: Array, strictDi?: boolean) => IInjectorService;\n version: {major: number};\n resumeBootstrap: () => void;\n getTestability: (e: Element) => ITestabilityService;\n} = {\n bootstrap: noNg,\n module: noNg,\n element: noNgElement,\n injector: noNg,\n version: undefined as any,\n resumeBootstrap: noNg,\n getTestability: noNg,\n};\n\ntry {\n if (window.hasOwnProperty('angular')) {\n angular = (window).angular;\n }\n} catch {\n // ignore in CJS mode.\n}\n\n/**\n * @deprecated Use `setAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function setAngularLib(ng: any): void {\n setAngularJSGlobal(ng);\n}\n\n/**\n * @deprecated Use `getAngularJSGlobal` instead.\n *\n * @publicApi\n */\nexport function getAngularLib(): any {\n return getAngularJSGlobal();\n}\n\n/**\n * Resets the AngularJS global.\n *\n * Used when AngularJS is loaded lazily, and not available on `window`.\n *\n * @publicApi\n */\nexport function setAngularJSGlobal(ng: any): void {\n angular = ng;\n}\n\n/**\n * Returns the current AngularJS global.\n *\n * @publicApi\n */\nexport function getAngularJSGlobal(): any {\n return angular;\n}\n\nexport const bootstrap: typeof angular.bootstrap = (e, modules, config?) =>\n angular.bootstrap(e, modules, config);\n\n// Do not declare as `module` to avoid webpack bug\n// (see https://github.com/angular/angular/issues/30050).\nexport const module_: typeof angular.module = (prefix, dependencies?) =>\n angular.module(prefix, dependencies);\n\nexport const element: typeof angular.element = ((e) =>\n angular.element(e)) as typeof angular.element;\nelement.cleanData = (nodes) => angular.element.cleanData(nodes);\n\nexport const injector: typeof angular.injector = (\n modules: Array,\n strictDi?: boolean,\n) => angular.injector(modules, strictDi);\n\nexport const resumeBootstrap: typeof angular.resumeBootstrap = () => angular.resumeBootstrap();\n\nexport const getTestability: typeof angular.getTestability = (e) => angular.getTestability(e);\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\nexport const $COMPILE = '$compile';\nexport const $CONTROLLER = '$controller';\nexport const $DELEGATE = '$delegate';\nexport const $EXCEPTION_HANDLER = '$exceptionHandler';\nexport const $HTTP_BACKEND = '$httpBackend';\nexport const $INJECTOR = '$injector';\nexport const $INTERVAL = '$interval';\nexport const $PARSE = '$parse';\nexport const $PROVIDE = '$provide';\nexport const $ROOT_ELEMENT = '$rootElement';\nexport const $ROOT_SCOPE = '$rootScope';\nexport const $SCOPE = '$scope';\nexport const $TEMPLATE_CACHE = '$templateCache';\nexport const $TEMPLATE_REQUEST = '$templateRequest';\n\nexport const $$TESTABILITY = '$$testability';\n\nexport const COMPILER_KEY = '$$angularCompiler';\nexport const DOWNGRADED_MODULE_COUNT_KEY = '$$angularDowngradedModuleCount';\nexport const GROUP_PROJECTABLE_NODES_KEY = '$$angularGroupProjectableNodes';\nexport const INJECTOR_KEY = '$$angularInjector';\nexport const LAZY_MODULE_REF = '$$angularLazyModuleRef';\nexport const NG_ZONE_KEY = '$$angularNgZone';\nexport const UPGRADE_APP_TYPE_KEY = '$$angularUpgradeAppType';\n\nexport const REQUIRE_INJECTOR = '?^^' + INJECTOR_KEY;\nexport const REQUIRE_NG_MODEL = '?ngModel';\n\nexport const UPGRADE_MODULE_NAME = '$$UpgradeModule';\n"],"names":[],"mappings":";;;;;;AAoPA,SAAS,IAAI,GAAA;AACX,IAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;AAClD;AAEA,MAAM,WAAW,IAA4B,MAAM,IAAI,EAAE,CAAQ;AACjE,WAAW,CAAC,SAAS,GAAG,IAAI;AAE5B,IAAI,OAAO,GAeP;AACF,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,OAAO,EAAE,SAAgB;AACzB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,cAAc,EAAE,IAAI;CACrB;AAED,IAAI;AACF,IAAA,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;AACpC,QAAA,OAAO,GAAS,MAAO,CAAC,OAAO;;AAEnC;AAAE,MAAM;;AAER;AAEA;;;;AAIG;AACG,SAAU,aAAa,CAAC,EAAO,EAAA;IACnC,kBAAkB,CAAC,EAAE,CAAC;AACxB;AAEA;;;;AAIG;SACa,aAAa,GAAA;IAC3B,OAAO,kBAAkB,EAAE;AAC7B;AAEA;;;;;;AAMG;AACG,SAAU,kBAAkB,CAAC,EAAO,EAAA;IACxC,OAAO,GAAG,EAAE;AACd;AAEA;;;;AAIG;SACa,kBAAkB,GAAA;AAChC,IAAA,OAAO,OAAO;AAChB;MAEa,SAAS,GAA6B,CAAC,CAAC,EAAE,OAAO,EAAE,MAAO,KACrE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM;AAEtC;AACA;AACa,MAAA,OAAO,GAA0B,CAAC,MAAM,EAAE,YAAa,KAClE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY;AAExB,MAAA,OAAO,IAA4B,CAAC,CAAC,KAChD,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACpB,OAAO,CAAC,SAAS,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC;AAElD,MAAA,QAAQ,GAA4B,CAC/C,OAAoC,EACpC,QAAkB,KACf,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ;AAEhC,MAAM,eAAe,GAAmC,MAAM,OAAO,CAAC,eAAe,EAAE;AAEvF,MAAM,cAAc,GAAkC,CAAC,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;AC7UtF,MAAM,QAAQ,GAAG;AACjB,MAAM,WAAW,GAAG;AACpB,MAAM,SAAS,GAAG;AAClB,MAAM,kBAAkB,GAAG,mBAAmB;AAC9C,MAAM,aAAa,GAAG;AACtB,MAAM,SAAS,GAAG;AAClB,MAAM,SAAS,GAAG;AAClB,MAAM,MAAM,GAAG;AACf,MAAM,QAAQ,GAAG;AACjB,MAAM,aAAa,GAAG;AACtB,MAAM,WAAW,GAAG;AACpB,MAAM,MAAM,GAAG;AACf,MAAM,eAAe,GAAG;AACxB,MAAM,iBAAiB,GAAG,kBAAkB;AAE5C,MAAM,aAAa,GAAG;AAEtB,MAAM,YAAY,GAAG;AACrB,MAAM,2BAA2B,GAAG;AACpC,MAAM,2BAA2B,GAAG,gCAAgC;AACpE,MAAM,YAAY,GAAG;AACrB,MAAM,eAAe,GAAG;AACxB,MAAM,WAAW,GAAG;AACpB,MAAM,oBAAoB,GAAG;AAEvB,MAAA,gBAAgB,GAAG,KAAK,GAAG;AACjC,MAAM,gBAAgB,GAAG;AAEzB,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} -------------------------------------------------------------------------------- /fesm2022/static.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { module_, UPGRADE_APP_TYPE_KEY, INJECTOR_KEY, LAZY_MODULE_REF, $INJECTOR, $PROVIDE, DOWNGRADED_MODULE_COUNT_KEY, UPGRADE_MODULE_NAME, $SCOPE, $$TESTABILITY, $DELEGATE, $INTERVAL, element, bootstrap } from './constants-nqBIph3y.mjs'; 8 | export { getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib, angular1 as ɵangular1, constants as ɵconstants } from './constants-nqBIph3y.mjs'; 9 | import { destroyApp, getDowngradedModuleCount, isNgModuleType, isFunction, UpgradeHelper, controllerKey } from './upgrade_helper-C850j0tg.mjs'; 10 | export { VERSION, downgradeComponent, downgradeInjectable, upgrade_helper as ɵupgradeHelper, util as ɵutil } from './upgrade_helper-C850j0tg.mjs'; 11 | import * as i0 from '@angular/core'; 12 | import { ɵNOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as _NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR, PlatformRef, EventEmitter, Directive, NgModule, Testability } from '@angular/core'; 13 | import { platformBrowser } from '@angular/platform-browser'; 14 | 15 | // We have to do a little dance to get the ng1 injector into the module injector. 16 | // We store the ng1 injector so that the provider in the module injector can access it 17 | // Then we "get" the ng1 injector from the module injector, which triggers the provider to read 18 | // the stored injector and release the reference to it. 19 | let tempInjectorRef = null; 20 | function setTempInjectorRef(injector) { 21 | tempInjectorRef = injector; 22 | } 23 | function injectorFactory() { 24 | if (!tempInjectorRef) { 25 | throw new Error('Trying to get the AngularJS injector before it being set.'); 26 | } 27 | const injector = tempInjectorRef; 28 | tempInjectorRef = null; // clear the value to prevent memory leaks 29 | return injector; 30 | } 31 | function rootScopeFactory(i) { 32 | return i.get('$rootScope'); 33 | } 34 | function compileFactory(i) { 35 | return i.get('$compile'); 36 | } 37 | function parseFactory(i) { 38 | return i.get('$parse'); 39 | } 40 | const angular1Providers = [ 41 | // We must use exported named functions for the ng2 factories to keep the compiler happy: 42 | // > Metadata collected contains an error that will be reported at runtime: 43 | // > Function calls are not supported. 44 | // > Consider replacing the function or lambda with a reference to an exported function 45 | { provide: '$injector', useFactory: injectorFactory, deps: [] }, 46 | { provide: '$rootScope', useFactory: rootScopeFactory, deps: ['$injector'] }, 47 | { provide: '$compile', useFactory: compileFactory, deps: ['$injector'] }, 48 | { provide: '$parse', useFactory: parseFactory, deps: ['$injector'] }, 49 | ]; 50 | 51 | class NgAdapterInjector { 52 | modInjector; 53 | constructor(modInjector) { 54 | this.modInjector = modInjector; 55 | } 56 | // When Angular locate a service in the component injector tree, the not found value is set to 57 | // `NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR`. In such a case we should not walk up to the module 58 | // injector. 59 | // AngularJS only supports a single tree and should always check the module injector. 60 | get(token, notFoundValue) { 61 | if (notFoundValue === _NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) { 62 | return notFoundValue; 63 | } 64 | return this.modInjector.get(token, notFoundValue); 65 | } 66 | } 67 | 68 | let moduleUid = 0; 69 | /** 70 | * @description 71 | * 72 | * A helper function for creating an AngularJS module that can bootstrap an Angular module 73 | * "on-demand" (possibly lazily) when a {@link downgradeComponent downgraded component} needs to be 74 | * instantiated. 75 | * 76 | * *Part of the [upgrade/static](api?query=upgrade/static) library for hybrid upgrade apps that 77 | * support AOT compilation.* 78 | * 79 | * It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to 80 | * pay the cost up-front. For example, you can have an AngularJS application that uses Angular for 81 | * specific routes and only instantiate the Angular modules if/when the user visits one of these 82 | * routes. 83 | * 84 | * The Angular module will be bootstrapped once (when requested for the first time) and the same 85 | * reference will be used from that point onwards. 86 | * 87 | * `downgradeModule()` requires either an `NgModuleFactory`, `NgModule` class or a function: 88 | * - `NgModuleFactory`: If you pass an `NgModuleFactory`, it will be used to instantiate a module 89 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModuleFactory bootstrapModuleFactory()}. 90 | * NOTE: this type of the argument is deprecated. Please either provide an `NgModule` class or a 91 | * bootstrap function instead. 92 | * - `NgModule` class: If you pass an NgModule class, it will be used to instantiate a module 93 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModule bootstrapModule()}. 94 | * - `Function`: If you pass a function, it is expected to return a promise resolving to an 95 | * `NgModuleRef`. The function is called with an array of extra {@link StaticProvider Providers} 96 | * that are expected to be available from the returned `NgModuleRef`'s `Injector`. 97 | * 98 | * `downgradeModule()` returns the name of the created AngularJS wrapper module. You can use it to 99 | * declare a dependency in your main AngularJS module. 100 | * 101 | * {@example upgrade/static/ts/lite/module.ts region="basic-how-to"} 102 | * 103 | * For more details on how to use `downgradeModule()` see 104 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 105 | * 106 | * @usageNotes 107 | * 108 | * Apart from `UpgradeModule`, you can use the rest of the `upgrade/static` helpers as usual to 109 | * build a hybrid application. Note that the Angular pieces (e.g. downgraded services) will not be 110 | * available until the downgraded module has been bootstrapped, i.e. by instantiating a downgraded 111 | * component. 112 | * 113 | *
114 | * 115 | * You cannot use `downgradeModule()` and `UpgradeModule` in the same hybrid application.
116 | * Use one or the other. 117 | * 118 | *
119 | * 120 | * ### Differences with `UpgradeModule` 121 | * 122 | * Besides their different API, there are two important internal differences between 123 | * `downgradeModule()` and `UpgradeModule` that affect the behavior of hybrid applications: 124 | * 125 | * 1. Unlike `UpgradeModule`, `downgradeModule()` does not bootstrap the main AngularJS module 126 | * inside the {@link NgZone Angular zone}. 127 | * 2. Unlike `UpgradeModule`, `downgradeModule()` does not automatically run a 128 | * [$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) when changes are 129 | * detected in the Angular part of the application. 130 | * 131 | * What this means is that applications using `UpgradeModule` will run change detection more 132 | * frequently in order to ensure that both frameworks are properly notified about possible changes. 133 | * This will inevitably result in more change detection runs than necessary. 134 | * 135 | * `downgradeModule()`, on the other side, does not try to tie the two change detection systems as 136 | * tightly, restricting the explicit change detection runs only to cases where it knows it is 137 | * necessary (e.g. when the inputs of a downgraded component change). This improves performance, 138 | * especially in change-detection-heavy applications, but leaves it up to the developer to manually 139 | * notify each framework as needed. 140 | * 141 | * For a more detailed discussion of the differences and their implications, see 142 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 143 | * 144 | *
145 | * 146 | * You can manually trigger a change detection run in AngularJS using 147 | * [scope.$apply(...)](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$apply) or 148 | * [$rootScope.$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest). 149 | * 150 | * You can manually trigger a change detection run in Angular using {@link NgZone#run 151 | * ngZone.run(...)}. 152 | * 153 | *
154 | * 155 | * ### Downgrading multiple modules 156 | * 157 | * It is possible to downgrade multiple modules and include them in an AngularJS application. In 158 | * that case, each downgraded module will be bootstrapped when an associated downgraded component or 159 | * injectable needs to be instantiated. 160 | * 161 | * Things to keep in mind, when downgrading multiple modules: 162 | * 163 | * - Each downgraded component/injectable needs to be explicitly associated with a downgraded 164 | * module. See `downgradeComponent()` and `downgradeInjectable()` for more details. 165 | * 166 | * - If you want some injectables to be shared among all downgraded modules, you can provide them as 167 | * `StaticProvider`s, when creating the `PlatformRef` (e.g. via `platformBrowser` or 168 | * `platformBrowserDynamic`). 169 | * 170 | * - When using {@link PlatformRef#bootstrapmodule `bootstrapModule()`} or 171 | * {@link PlatformRef#bootstrapmodulefactory `bootstrapModuleFactory()`} to bootstrap the 172 | * downgraded modules, each one is considered a "root" module. As a consequence, a new instance 173 | * will be created for every injectable provided in `"root"` (via 174 | * {@link /api/core/Injectable#providedIn providedIn} 175 | * If this is not your intention, you can have a shared module (that will act as act as the "root" 176 | * module) and create all downgraded modules using that module's injector: 177 | * 178 | * {@example upgrade/static/ts/lite-multi-shared/module.ts region="shared-root-module"} 179 | * 180 | * @publicApi 181 | */ 182 | function downgradeModule(moduleOrBootstrapFn) { 183 | const lazyModuleName = `${UPGRADE_MODULE_NAME}.lazy${++moduleUid}`; 184 | const lazyModuleRefKey = `${LAZY_MODULE_REF}${lazyModuleName}`; 185 | const lazyInjectorKey = `${INJECTOR_KEY}${lazyModuleName}`; 186 | let bootstrapFn; 187 | if (isNgModuleType(moduleOrBootstrapFn)) { 188 | // NgModule class 189 | bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModule(moduleOrBootstrapFn); 190 | } 191 | else if (!isFunction(moduleOrBootstrapFn)) { 192 | // NgModule factory 193 | bootstrapFn = (extraProviders) => platformBrowser(extraProviders).bootstrapModuleFactory(moduleOrBootstrapFn); 194 | } 195 | else { 196 | // bootstrap function 197 | bootstrapFn = moduleOrBootstrapFn; 198 | } 199 | let injector; 200 | // Create an ng1 module to bootstrap. 201 | module_(lazyModuleName, []) 202 | .constant(UPGRADE_APP_TYPE_KEY, 3 /* ɵutil.UpgradeAppType.Lite */) 203 | .factory(INJECTOR_KEY, [lazyInjectorKey, identity]) 204 | .factory(lazyInjectorKey, () => { 205 | if (!injector) { 206 | throw new Error('Trying to get the Angular injector before bootstrapping the corresponding ' + 207 | 'Angular module.'); 208 | } 209 | return injector; 210 | }) 211 | .factory(LAZY_MODULE_REF, [lazyModuleRefKey, identity]) 212 | .factory(lazyModuleRefKey, [ 213 | $INJECTOR, 214 | ($injector) => { 215 | setTempInjectorRef($injector); 216 | const result = { 217 | promise: bootstrapFn(angular1Providers).then((ref) => { 218 | injector = result.injector = new NgAdapterInjector(ref.injector); 219 | injector.get($INJECTOR); 220 | // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed. 221 | // This does not happen in a typical SPA scenario, but it might be useful for 222 | // other use-cases where disposing of an Angular/AngularJS app is necessary 223 | // (such as Hot Module Replacement (HMR)). 224 | // See https://github.com/angular/angular/issues/39935. 225 | injector.get(PlatformRef).onDestroy(() => destroyApp($injector)); 226 | return injector; 227 | }), 228 | }; 229 | return result; 230 | }, 231 | ]) 232 | .config([ 233 | $INJECTOR, 234 | $PROVIDE, 235 | ($injector, $provide) => { 236 | $provide.constant(DOWNGRADED_MODULE_COUNT_KEY, getDowngradedModuleCount($injector) + 1); 237 | }, 238 | ]); 239 | return lazyModuleName; 240 | } 241 | function identity(x) { 242 | return x; 243 | } 244 | 245 | const NOT_SUPPORTED = 'NOT_SUPPORTED'; 246 | const INITIAL_VALUE = { 247 | __UNINITIALIZED__: true, 248 | }; 249 | class Bindings { 250 | twoWayBoundProperties = []; 251 | twoWayBoundLastValues = []; 252 | expressionBoundProperties = []; 253 | propertyToOutputMap = {}; 254 | } 255 | /** 256 | * @description 257 | * 258 | * A helper class that allows an AngularJS component to be used from Angular. 259 | * 260 | * *Part of the [upgrade/static](api?query=upgrade%2Fstatic) 261 | * library for hybrid upgrade apps that support AOT compilation.* 262 | * 263 | * This helper class should be used as a base class for creating Angular directives 264 | * that wrap AngularJS components that need to be "upgraded". 265 | * 266 | * @usageNotes 267 | * ### Examples 268 | * 269 | * Let's assume that you have an AngularJS component called `ng1Hero` that needs 270 | * to be made available in Angular templates. 271 | * 272 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero"} 273 | * 274 | * We must create a `Directive` that will make this AngularJS component 275 | * available inside Angular templates. 276 | * 277 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero-wrapper"} 278 | * 279 | * In this example you can see that we must derive from the `UpgradeComponent` 280 | * base class but also provide an {@link Directive `@Directive`} decorator. This is 281 | * because the AOT compiler requires that this information is statically available at 282 | * compile time. 283 | * 284 | * Note that we must do the following: 285 | * * specify the directive's selector (`ng1-hero`) 286 | * * specify all inputs and outputs that the AngularJS component expects 287 | * * derive from `UpgradeComponent` 288 | * * call the base class from the constructor, passing 289 | * * the AngularJS name of the component (`ng1Hero`) 290 | * * the `ElementRef` and `Injector` for the component wrapper 291 | * 292 | * @publicApi 293 | * @extensible 294 | */ 295 | class UpgradeComponent { 296 | helper; 297 | $element; 298 | $componentScope; 299 | directive; 300 | bindings; 301 | controllerInstance; 302 | bindingDestination; 303 | // We will be instantiating the controller in the `ngOnInit` hook, when the 304 | // first `ngOnChanges` will have been already triggered. We store the 305 | // `SimpleChanges` and "play them back" later. 306 | pendingChanges = null; 307 | unregisterDoCheckWatcher; 308 | /** 309 | * Create a new `UpgradeComponent` instance. You should not normally need to do this. 310 | * Instead you should derive a new class from this one and call the super constructor 311 | * from the base class. 312 | * 313 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero-wrapper" } 314 | * 315 | * * The `name` parameter should be the name of the AngularJS directive. 316 | * * The `elementRef` and `injector` parameters should be acquired from Angular by dependency 317 | * injection into the base class constructor. 318 | */ 319 | constructor(name, elementRef, injector) { 320 | this.helper = new UpgradeHelper(injector, name, elementRef); 321 | this.$element = this.helper.$element; 322 | this.directive = this.helper.directive; 323 | this.bindings = this.initializeBindings(this.directive, name); 324 | // We ask for the AngularJS scope from the Angular injector, since 325 | // we will put the new component scope onto the new injector for each component 326 | const $parentScope = injector.get($SCOPE); 327 | // QUESTION 1: Should we create an isolated scope if the scope is only true? 328 | // QUESTION 2: Should we make the scope accessible through `$element.scope()/isolateScope()`? 329 | this.$componentScope = $parentScope.$new(!!this.directive.scope); 330 | this.initializeOutputs(); 331 | } 332 | /** @docs-private */ 333 | ngOnInit() { 334 | // Collect contents, insert and compile template 335 | const attachChildNodes = this.helper.prepareTransclusion(); 336 | const linkFn = this.helper.compileTemplate(); 337 | // Instantiate controller 338 | const controllerType = this.directive.controller; 339 | const bindToController = this.directive.bindToController; 340 | let controllerInstance = controllerType 341 | ? this.helper.buildController(controllerType, this.$componentScope) 342 | : undefined; 343 | let bindingDestination; 344 | if (!bindToController) { 345 | bindingDestination = this.$componentScope; 346 | } 347 | else if (controllerType && controllerInstance) { 348 | bindingDestination = controllerInstance; 349 | } 350 | else { 351 | throw new Error(`Upgraded directive '${this.directive.name}' specifies 'bindToController' but no controller.`); 352 | } 353 | this.controllerInstance = controllerInstance; 354 | this.bindingDestination = bindingDestination; 355 | // Set up outputs 356 | this.bindOutputs(bindingDestination); 357 | // Require other controllers 358 | const requiredControllers = this.helper.resolveAndBindRequiredControllers(controllerInstance); 359 | // Hook: $onChanges 360 | if (this.pendingChanges) { 361 | this.forwardChanges(this.pendingChanges, bindingDestination); 362 | this.pendingChanges = null; 363 | } 364 | // Hook: $onInit 365 | if (this.controllerInstance && isFunction(this.controllerInstance.$onInit)) { 366 | this.controllerInstance.$onInit(); 367 | } 368 | // Hook: $doCheck 369 | if (controllerInstance && isFunction(controllerInstance.$doCheck)) { 370 | const callDoCheck = () => controllerInstance?.$doCheck?.(); 371 | this.unregisterDoCheckWatcher = this.$componentScope.$parent.$watch(callDoCheck); 372 | callDoCheck(); 373 | } 374 | // Linking 375 | const link = this.directive.link; 376 | const preLink = typeof link == 'object' && link.pre; 377 | const postLink = typeof link == 'object' ? link.post : link; 378 | const attrs = NOT_SUPPORTED; 379 | const transcludeFn = NOT_SUPPORTED; 380 | if (preLink) { 381 | preLink(this.$componentScope, this.$element, attrs, requiredControllers, transcludeFn); 382 | } 383 | linkFn(this.$componentScope, null, { parentBoundTranscludeFn: attachChildNodes }); 384 | if (postLink) { 385 | postLink(this.$componentScope, this.$element, attrs, requiredControllers, transcludeFn); 386 | } 387 | // Hook: $postLink 388 | if (this.controllerInstance && isFunction(this.controllerInstance.$postLink)) { 389 | this.controllerInstance.$postLink(); 390 | } 391 | } 392 | /** @docs-private */ 393 | ngOnChanges(changes) { 394 | if (!this.bindingDestination) { 395 | this.pendingChanges = changes; 396 | } 397 | else { 398 | this.forwardChanges(changes, this.bindingDestination); 399 | } 400 | } 401 | /** @docs-private */ 402 | ngDoCheck() { 403 | const twoWayBoundProperties = this.bindings.twoWayBoundProperties; 404 | const twoWayBoundLastValues = this.bindings.twoWayBoundLastValues; 405 | const propertyToOutputMap = this.bindings.propertyToOutputMap; 406 | twoWayBoundProperties.forEach((propName, idx) => { 407 | const newValue = this.bindingDestination?.[propName]; 408 | const oldValue = twoWayBoundLastValues[idx]; 409 | if (!Object.is(newValue, oldValue)) { 410 | const outputName = propertyToOutputMap[propName]; 411 | const eventEmitter = this[outputName]; 412 | eventEmitter.emit(newValue); 413 | twoWayBoundLastValues[idx] = newValue; 414 | } 415 | }); 416 | } 417 | /** @docs-private */ 418 | ngOnDestroy() { 419 | if (isFunction(this.unregisterDoCheckWatcher)) { 420 | this.unregisterDoCheckWatcher(); 421 | } 422 | this.helper.onDestroy(this.$componentScope, this.controllerInstance); 423 | } 424 | initializeBindings(directive, name) { 425 | const btcIsObject = typeof directive.bindToController === 'object'; 426 | if (btcIsObject && Object.keys(directive.scope).length) { 427 | throw new Error(`Binding definitions on scope and controller at the same time is not supported.`); 428 | } 429 | const context = btcIsObject ? directive.bindToController : directive.scope; 430 | const bindings = new Bindings(); 431 | if (typeof context == 'object') { 432 | Object.keys(context).forEach((propName) => { 433 | const definition = context[propName]; 434 | const bindingType = definition.charAt(0); 435 | // QUESTION: What about `=*`? Ignore? Throw? Support? 436 | switch (bindingType) { 437 | case '@': 438 | case '<': 439 | // We don't need to do anything special. They will be defined as inputs on the 440 | // upgraded component facade and the change propagation will be handled by 441 | // `ngOnChanges()`. 442 | break; 443 | case '=': 444 | bindings.twoWayBoundProperties.push(propName); 445 | bindings.twoWayBoundLastValues.push(INITIAL_VALUE); 446 | bindings.propertyToOutputMap[propName] = propName + 'Change'; 447 | break; 448 | case '&': 449 | bindings.expressionBoundProperties.push(propName); 450 | bindings.propertyToOutputMap[propName] = propName; 451 | break; 452 | default: 453 | let json = JSON.stringify(context); 454 | throw new Error(`Unexpected mapping '${bindingType}' in '${json}' in '${name}' directive.`); 455 | } 456 | }); 457 | } 458 | return bindings; 459 | } 460 | initializeOutputs() { 461 | // Initialize the outputs for `=` and `&` bindings 462 | this.bindings.twoWayBoundProperties 463 | .concat(this.bindings.expressionBoundProperties) 464 | .forEach((propName) => { 465 | const outputName = this.bindings.propertyToOutputMap[propName]; 466 | this[outputName] = new EventEmitter(); 467 | }); 468 | } 469 | bindOutputs(bindingDestination) { 470 | // Bind `&` bindings to the corresponding outputs 471 | this.bindings.expressionBoundProperties.forEach((propName) => { 472 | const outputName = this.bindings.propertyToOutputMap[propName]; 473 | const emitter = this[outputName]; 474 | bindingDestination[propName] = (value) => emitter.emit(value); 475 | }); 476 | } 477 | forwardChanges(changes, bindingDestination) { 478 | // Forward input changes to `bindingDestination` 479 | Object.keys(changes).forEach((propName) => (bindingDestination[propName] = changes[propName].currentValue)); 480 | if (isFunction(bindingDestination.$onChanges)) { 481 | bindingDestination.$onChanges(changes); 482 | } 483 | } 484 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); 485 | static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0-next.0+sha-21fc93b", type: UpgradeComponent, isStandalone: true, usesOnChanges: true, ngImport: i0 }); 486 | } 487 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeComponent, decorators: [{ 488 | type: Directive 489 | }], ctorParameters: () => [{ type: undefined }, { type: i0.ElementRef }, { type: i0.Injector }] }); 490 | 491 | /** 492 | * @description 493 | * 494 | * An `NgModule`, which you import to provide AngularJS core services, 495 | * and has an instance method used to bootstrap the hybrid upgrade application. 496 | * 497 | * *Part of the [upgrade/static](api?query=upgrade/static) 498 | * library for hybrid upgrade apps that support AOT compilation* 499 | * 500 | * The `upgrade/static` package contains helpers that allow AngularJS and Angular components 501 | * to be used together inside a hybrid upgrade application, which supports AOT compilation. 502 | * 503 | * Specifically, the classes and functions in the `upgrade/static` module allow the following: 504 | * 505 | * 1. Creation of an Angular directive that wraps and exposes an AngularJS component so 506 | * that it can be used in an Angular template. See `UpgradeComponent`. 507 | * 2. Creation of an AngularJS directive that wraps and exposes an Angular component so 508 | * that it can be used in an AngularJS template. See `downgradeComponent`. 509 | * 3. Creation of an Angular root injector provider that wraps and exposes an AngularJS 510 | * service so that it can be injected into an Angular context. See 511 | * {@link UpgradeModule#upgrading-an-angular-1-service Upgrading an AngularJS service} below. 512 | * 4. Creation of an AngularJS service that wraps and exposes an Angular injectable 513 | * so that it can be injected into an AngularJS context. See `downgradeInjectable`. 514 | * 5. Bootstrapping of a hybrid Angular application which contains both of the frameworks 515 | * coexisting in a single application. 516 | * 517 | * @usageNotes 518 | * 519 | * ```ts 520 | * import {UpgradeModule} from '@angular/upgrade/static'; 521 | * ``` 522 | * 523 | * See also the {@link UpgradeModule#examples examples} below. 524 | * 525 | * ### Mental Model 526 | * 527 | * When reasoning about how a hybrid application works it is useful to have a mental model which 528 | * describes what is happening and explains what is happening at the lowest level. 529 | * 530 | * 1. There are two independent frameworks running in a single application, each framework treats 531 | * the other as a black box. 532 | * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework 533 | * instantiated the element is the owner. Each framework only updates/interacts with its own 534 | * DOM elements and ignores others. 535 | * 3. AngularJS directives always execute inside the AngularJS framework codebase regardless of 536 | * where they are instantiated. 537 | * 4. Angular components always execute inside the Angular framework codebase regardless of 538 | * where they are instantiated. 539 | * 5. An AngularJS component can be "upgraded"" to an Angular component. This is achieved by 540 | * defining an Angular directive, which bootstraps the AngularJS component at its location 541 | * in the DOM. See `UpgradeComponent`. 542 | * 6. An Angular component can be "downgraded" to an AngularJS component. This is achieved by 543 | * defining an AngularJS directive, which bootstraps the Angular component at its location 544 | * in the DOM. See `downgradeComponent`. 545 | * 7. Whenever an "upgraded"/"downgraded" component is instantiated the host element is owned by 546 | * the framework doing the instantiation. The other framework then instantiates and owns the 547 | * view for that component. 548 | * 1. This implies that the component bindings will always follow the semantics of the 549 | * instantiation framework. 550 | * 2. The DOM attributes are parsed by the framework that owns the current template. So 551 | * attributes in AngularJS templates must use kebab-case, while AngularJS templates must use 552 | * camelCase. 553 | * 3. However the template binding syntax will always use the Angular style, e.g. square 554 | * brackets (`[...]`) for property binding. 555 | * 8. Angular is bootstrapped first; AngularJS is bootstrapped second. AngularJS always owns the 556 | * root component of the application. 557 | * 9. The new application is running in an Angular zone, and therefore it no longer needs calls to 558 | * `$apply()`. 559 | * 560 | * ### The `UpgradeModule` class 561 | * 562 | * This class is an `NgModule`, which you import to provide AngularJS core services, 563 | * and has an instance method used to bootstrap the hybrid upgrade application. 564 | * 565 | * * Core AngularJS services
566 | * Importing this `NgModule` will add providers for the core 567 | * [AngularJS services](https://docs.angularjs.org/api/ng/service) to the root injector. 568 | * 569 | * * Bootstrap
570 | * The runtime instance of this class contains a {@link UpgradeModule#bootstrap `bootstrap()`} 571 | * method, which you use to bootstrap the top level AngularJS module onto an element in the 572 | * DOM for the hybrid upgrade app. 573 | * 574 | * It also contains properties to access the {@link UpgradeModule#injector root injector}, the 575 | * bootstrap `NgZone` and the 576 | * [AngularJS $injector](https://docs.angularjs.org/api/auto/service/$injector). 577 | * 578 | * ### Examples 579 | * 580 | * Import the `UpgradeModule` into your top level Angular {@link NgModule NgModule}. 581 | * 582 | * {@example upgrade/static/ts/full/module.ts region='ng2-module'} 583 | * 584 | * Then inject `UpgradeModule` into your Angular `NgModule` and use it to bootstrap the top level 585 | * [AngularJS module](https://docs.angularjs.org/api/ng/type/angular.Module) in the 586 | * `ngDoBootstrap()` method. 587 | * 588 | * {@example upgrade/static/ts/full/module.ts region='bootstrap-ng1'} 589 | * 590 | * Finally, kick off the whole process, by bootstrapping your top level Angular `NgModule`. 591 | * 592 | * {@example upgrade/static/ts/full/module.ts region='bootstrap-ng2'} 593 | * 594 | * ### Upgrading an AngularJS service 595 | * 596 | * There is no specific API for upgrading an AngularJS service. Instead you should just follow the 597 | * following recipe: 598 | * 599 | * Let's say you have an AngularJS service: 600 | * 601 | * {@example upgrade/static/ts/full/module.ts region="ng1-text-formatter-service"} 602 | * 603 | * Then you should define an Angular provider to be included in your `NgModule` `providers` 604 | * property. 605 | * 606 | * {@example upgrade/static/ts/full/module.ts region="upgrade-ng1-service"} 607 | * 608 | * Then you can use the "upgraded" AngularJS service by injecting it into an Angular component 609 | * or service. 610 | * 611 | * {@example upgrade/static/ts/full/module.ts region="use-ng1-upgraded-service"} 612 | * 613 | * @publicApi 614 | */ 615 | class UpgradeModule { 616 | ngZone; 617 | platformRef; 618 | /** 619 | * The AngularJS `$injector` for the upgrade application. 620 | */ 621 | $injector; 622 | /** The Angular Injector **/ 623 | injector; 624 | constructor( 625 | /** The root `Injector` for the upgrade application. */ 626 | injector, 627 | /** The bootstrap zone for the upgrade application */ 628 | ngZone, 629 | /** 630 | * The owning `NgModuleRef`s `PlatformRef` instance. 631 | * This is used to tie the lifecycle of the bootstrapped AngularJS apps to that of the Angular 632 | * `PlatformRef`. 633 | */ 634 | platformRef) { 635 | this.ngZone = ngZone; 636 | this.platformRef = platformRef; 637 | this.injector = new NgAdapterInjector(injector); 638 | } 639 | /** 640 | * Bootstrap an AngularJS application from this NgModule 641 | * @param element the element on which to bootstrap the AngularJS application 642 | * @param [modules] the AngularJS modules to bootstrap for this application 643 | * @param [config] optional extra AngularJS bootstrap configuration 644 | * @return The value returned by 645 | * [angular.bootstrap()](https://docs.angularjs.org/api/ng/function/angular.bootstrap). 646 | */ 647 | bootstrap(element$1, modules = [], config /*angular.IAngularBootstrapConfig*/) { 648 | const INIT_MODULE_NAME = UPGRADE_MODULE_NAME + '.init'; 649 | // Create an ng1 module to bootstrap 650 | module_(INIT_MODULE_NAME, []) 651 | .constant(UPGRADE_APP_TYPE_KEY, 2 /* ɵutil.UpgradeAppType.Static */) 652 | .value(INJECTOR_KEY, this.injector) 653 | .factory(LAZY_MODULE_REF, [ 654 | INJECTOR_KEY, 655 | (injector) => ({ injector }), 656 | ]) 657 | .config([ 658 | $PROVIDE, 659 | $INJECTOR, 660 | ($provide, $injector) => { 661 | if ($injector.has($$TESTABILITY)) { 662 | $provide.decorator($$TESTABILITY, [ 663 | $DELEGATE, 664 | (testabilityDelegate) => { 665 | const originalWhenStable = testabilityDelegate.whenStable; 666 | const injector = this.injector; 667 | // Cannot use arrow function below because we need the context 668 | const newWhenStable = function (callback) { 669 | originalWhenStable.call(testabilityDelegate, function () { 670 | const ng2Testability = injector.get(Testability); 671 | if (ng2Testability.isStable()) { 672 | callback(); 673 | } 674 | else { 675 | ng2Testability.whenStable(newWhenStable.bind(testabilityDelegate, callback)); 676 | } 677 | }); 678 | }; 679 | testabilityDelegate.whenStable = newWhenStable; 680 | return testabilityDelegate; 681 | }, 682 | ]); 683 | } 684 | if ($injector.has($INTERVAL)) { 685 | $provide.decorator($INTERVAL, [ 686 | $DELEGATE, 687 | (intervalDelegate) => { 688 | // Wrap the $interval service so that setInterval is called outside NgZone, 689 | // but the callback is still invoked within it. This is so that $interval 690 | // won't block stability, which preserves the behavior from AngularJS. 691 | let wrappedInterval = (fn, delay, count, invokeApply, ...pass) => { 692 | return this.ngZone.runOutsideAngular(() => { 693 | return intervalDelegate((...args) => { 694 | // Run callback in the next VM turn - $interval calls 695 | // $rootScope.$apply, and running the callback in NgZone will 696 | // cause a '$digest already in progress' error if it's in the 697 | // same vm turn. 698 | setTimeout(() => { 699 | this.ngZone.run(() => fn(...args)); 700 | }); 701 | }, delay, count, invokeApply, ...pass); 702 | }); 703 | }; 704 | Object.keys(intervalDelegate).forEach((prop) => (wrappedInterval[prop] = intervalDelegate[prop])); 705 | // the `flush` method will be present when ngMocks is used 706 | if (intervalDelegate.hasOwnProperty('flush')) { 707 | wrappedInterval['flush'] = () => { 708 | intervalDelegate['flush'](); 709 | return wrappedInterval; 710 | }; 711 | } 712 | return wrappedInterval; 713 | }, 714 | ]); 715 | } 716 | }, 717 | ]) 718 | .run([ 719 | $INJECTOR, 720 | ($injector) => { 721 | this.$injector = $injector; 722 | const $rootScope = $injector.get('$rootScope'); 723 | // Initialize the ng1 $injector provider 724 | setTempInjectorRef($injector); 725 | this.injector.get($INJECTOR); 726 | // Put the injector on the DOM, so that it can be "required" 727 | element(element$1).data(controllerKey(INJECTOR_KEY), this.injector); 728 | // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed. 729 | // This does not happen in a typical SPA scenario, but it might be useful for 730 | // other use-cases where disposing of an Angular/AngularJS app is necessary 731 | // (such as Hot Module Replacement (HMR)). 732 | // See https://github.com/angular/angular/issues/39935. 733 | this.platformRef.onDestroy(() => destroyApp($injector)); 734 | // Wire up the ng1 rootScope to run a digest cycle whenever the zone settles 735 | // We need to do this in the next tick so that we don't prevent the bootup stabilizing 736 | setTimeout(() => { 737 | const subscription = this.ngZone.onMicrotaskEmpty.subscribe(() => { 738 | if ($rootScope.$$phase) { 739 | if (typeof ngDevMode === 'undefined' || ngDevMode) { 740 | console.warn('A digest was triggered while one was already in progress. This may mean that something is triggering digests outside the Angular zone.'); 741 | } 742 | return $rootScope.$evalAsync(); 743 | } 744 | return $rootScope.$digest(); 745 | }); 746 | $rootScope.$on('$destroy', () => { 747 | subscription.unsubscribe(); 748 | }); 749 | }, 0); 750 | }, 751 | ]); 752 | const upgradeModule = module_(UPGRADE_MODULE_NAME, [INIT_MODULE_NAME].concat(modules)); 753 | // Make sure resumeBootstrap() only exists if the current bootstrap is deferred 754 | const windowAngular = window['angular']; 755 | windowAngular.resumeBootstrap = undefined; 756 | // Bootstrap the AngularJS application inside our zone 757 | const returnValue = this.ngZone.run(() => bootstrap(element$1, [upgradeModule.name], config)); 758 | // Patch resumeBootstrap() to run inside the ngZone 759 | if (windowAngular.resumeBootstrap) { 760 | const originalResumeBootstrap = windowAngular.resumeBootstrap; 761 | const ngZone = this.ngZone; 762 | windowAngular.resumeBootstrap = function () { 763 | let args = arguments; 764 | windowAngular.resumeBootstrap = originalResumeBootstrap; 765 | return ngZone.run(() => windowAngular.resumeBootstrap.apply(this, args)); 766 | }; 767 | } 768 | return returnValue; 769 | } 770 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); 771 | static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeModule }); 772 | static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); 773 | } 774 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeModule, decorators: [{ 775 | type: NgModule, 776 | args: [{ providers: [angular1Providers] }] 777 | }], ctorParameters: () => [{ type: i0.Injector }, { type: i0.NgZone }, { type: i0.PlatformRef }] }); 778 | 779 | export { UpgradeComponent, UpgradeModule, downgradeModule }; 780 | //# sourceMappingURL=static.mjs.map 781 | -------------------------------------------------------------------------------- /fesm2022/static/testing.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import * as i0 from '@angular/core'; 8 | import { NgModule, Injector } from '@angular/core'; 9 | import { $INJECTOR, module_, UPGRADE_APP_TYPE_KEY, INJECTOR_KEY, injector as injector$1 } from '../constants-nqBIph3y.mjs'; 10 | import { TestBed } from '@angular/core/testing'; 11 | 12 | let $injector = null; 13 | let injector; 14 | function $injectorFactory() { 15 | return $injector; 16 | } 17 | class AngularTestingModule { 18 | constructor(i) { 19 | injector = i; 20 | } 21 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: AngularTestingModule, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); 22 | static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: AngularTestingModule }); 23 | static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: AngularTestingModule, providers: [{ provide: $INJECTOR, useFactory: $injectorFactory }] }); 24 | } 25 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: AngularTestingModule, decorators: [{ 26 | type: NgModule, 27 | args: [{ providers: [{ provide: $INJECTOR, useFactory: $injectorFactory }] }] 28 | }], ctorParameters: () => [{ type: i0.Injector }] }); 29 | /** 30 | * A helper function to use when unit testing Angular services that depend upon upgraded AngularJS 31 | * services. 32 | * 33 | * This function returns an `NgModule` decorated class that is configured to wire up the Angular 34 | * and AngularJS injectors without the need to actually bootstrap a hybrid application. 35 | * This makes it simpler and faster to unit test services. 36 | * 37 | * Use the returned class as an "import" when configuring the `TestBed`. 38 | * 39 | * In the following code snippet, we are configuring the TestBed with two imports. 40 | * The `Ng2AppModule` is the Angular part of our hybrid application and the `ng1AppModule` is the 41 | * AngularJS part. 42 | * 43 | * {@example upgrade/static/ts/full/module.spec.ts region='angular-setup'} 44 | * 45 | * Once this is done we can get hold of services via the Angular `Injector` as normal. 46 | * Services that are (or have dependencies on) an upgraded AngularJS service, will be instantiated 47 | * as needed by the AngularJS `$injector`. 48 | * 49 | * In the following code snippet, `HeroesService` is an Angular service that depends upon an 50 | * AngularJS service, `titleCase`. 51 | * 52 | * {@example upgrade/static/ts/full/module.spec.ts region='angular-spec'} 53 | * 54 | *
55 | * 56 | * This helper is for testing services not Components. 57 | * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or 58 | * `downgradeModule` for more information. 59 | * 60 | *
61 | * 62 | *
63 | * 64 | * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the 65 | * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger 66 | * AngularJS handlers of async events from Angular. 67 | * 68 | *
69 | * 70 | *
71 | * 72 | * The helper sets up global variables to hold the shared Angular and AngularJS injectors. 73 | * 74 | * * Only call this helper once per spec. 75 | * * Do not use `createAngularTestingModule` in the same spec as `createAngularJSTestingModule`. 76 | * 77 | *
78 | * 79 | * Here is the example application and its unit tests that use `createAngularTestingModule` 80 | * and `createAngularJSTestingModule`. 81 | * 82 | * 83 | * 84 | * 85 | * 86 | * 87 | * 88 | * @param angularJSModules a collection of the names of AngularJS modules to include in the 89 | * configuration. 90 | * @param [strictDi] whether the AngularJS injector should have `strictDI` enabled. 91 | * 92 | * @publicApi 93 | */ 94 | function createAngularTestingModule(angularJSModules, strictDi) { 95 | module_('$$angularJSTestingModule', angularJSModules) 96 | .constant(UPGRADE_APP_TYPE_KEY, 2 /* UpgradeAppType.Static */) 97 | .factory(INJECTOR_KEY, () => injector); 98 | $injector = injector$1(['ng', '$$angularJSTestingModule'], strictDi); 99 | return AngularTestingModule; 100 | } 101 | 102 | /** 103 | * A helper function to use when unit testing AngularJS services that depend upon downgraded Angular 104 | * services. 105 | * 106 | * This function returns an AngularJS module that is configured to wire up the AngularJS and Angular 107 | * injectors without the need to actually bootstrap a hybrid application. 108 | * This makes it simpler and faster to unit test services. 109 | * 110 | * Use the returned AngularJS module in a call to 111 | * [`angular.mocks.module`](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) to 112 | * include this module in the unit test injector. 113 | * 114 | * In the following code snippet, we are configuring the `$injector` with two modules: 115 | * The AngularJS `ng1AppModule`, which is the AngularJS part of our hybrid application and the 116 | * `Ng2AppModule`, which is the Angular part. 117 | * 118 | * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-setup'} 119 | * 120 | * Once this is done we can get hold of services via the AngularJS `$injector` as normal. 121 | * Services that are (or have dependencies on) a downgraded Angular service, will be instantiated as 122 | * needed by the Angular root `Injector`. 123 | * 124 | * In the following code snippet, `heroesService` is a downgraded Angular service that we are 125 | * accessing from AngularJS. 126 | * 127 | * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-spec'} 128 | * 129 | *
130 | * 131 | * This helper is for testing services not components. 132 | * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or 133 | * `downgradeModule` for more information. 134 | * 135 | *
136 | * 137 | *
138 | * 139 | * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the 140 | * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger 141 | * AngularJS handlers of async events from Angular. 142 | * 143 | *
144 | * 145 | *
146 | * 147 | * The helper sets up global variables to hold the shared Angular and AngularJS injectors. 148 | * 149 | * * Only call this helper once per spec. 150 | * * Do not use `createAngularJSTestingModule` in the same spec as `createAngularTestingModule`. 151 | * 152 | *
153 | * 154 | * Here is the example application and its unit tests that use `createAngularTestingModule` 155 | * and `createAngularJSTestingModule`. 156 | * 157 | * 158 | * 159 | * 160 | * 161 | * 162 | * 163 | * @param angularModules a collection of Angular modules to include in the configuration. 164 | * 165 | * @publicApi 166 | */ 167 | function createAngularJSTestingModule(angularModules) { 168 | return module_('$$angularJSTestingModule', []) 169 | .constant(UPGRADE_APP_TYPE_KEY, 2 /* UpgradeAppType.Static */) 170 | .factory(INJECTOR_KEY, [ 171 | $INJECTOR, 172 | ($injector) => { 173 | TestBed.configureTestingModule({ 174 | imports: angularModules, 175 | providers: [{ provide: $INJECTOR, useValue: $injector }], 176 | }); 177 | return TestBed.inject(Injector); 178 | }, 179 | ]).name; 180 | } 181 | 182 | export { createAngularJSTestingModule, createAngularTestingModule }; 183 | //# sourceMappingURL=testing.mjs.map 184 | -------------------------------------------------------------------------------- /fesm2022/static/testing.mjs.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"testing.mjs","sources":["../../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/upgrade/static/testing/src/create_angular_testing_module.ts","../../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/upgrade/static/testing/src/create_angularjs_testing_module.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 {Injector, NgModule, Type} from '@angular/core';\nimport {ɵangular1 as angular, ɵconstants} from '../../../static';\n\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\nlet $injector: angular.IInjectorService | null = null;\nlet injector: Injector;\n\nexport function $injectorFactory() {\n return $injector;\n}\n\n@NgModule({providers: [{provide: ɵconstants.$INJECTOR, useFactory: $injectorFactory}]})\nexport class AngularTestingModule {\n constructor(i: Injector) {\n injector = i;\n }\n}\n\n/**\n * A helper function to use when unit testing Angular services that depend upon upgraded AngularJS\n * services.\n *\n * This function returns an `NgModule` decorated class that is configured to wire up the Angular\n * and AngularJS injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned class as an \"import\" when configuring the `TestBed`.\n *\n * In the following code snippet, we are configuring the TestBed with two imports.\n * The `Ng2AppModule` is the Angular part of our hybrid application and the `ng1AppModule` is the\n * AngularJS part.\n *\n * {@example upgrade/static/ts/full/module.spec.ts region='angular-setup'}\n *\n * Once this is done we can get hold of services via the Angular `Injector` as normal.\n * Services that are (or have dependencies on) an upgraded AngularJS service, will be instantiated\n * as needed by the AngularJS `$injector`.\n *\n * In the following code snippet, `HeroesService` is an Angular service that depends upon an\n * AngularJS service, `titleCase`.\n *\n * {@example upgrade/static/ts/full/module.spec.ts region='angular-spec'}\n *\n *
\n *\n * This helper is for testing services not Components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n *
\n *\n *
\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n *
\n *\n *
\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularTestingModule` in the same spec as `createAngularJSTestingModule`.\n *\n *
\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * \n * \n * \n * \n *\n *\n * @param angularJSModules a collection of the names of AngularJS modules to include in the\n * configuration.\n * @param [strictDi] whether the AngularJS injector should have `strictDI` enabled.\n *\n * @publicApi\n */\nexport function createAngularTestingModule(\n angularJSModules: string[],\n strictDi?: boolean,\n): Type {\n angular\n .module_('$$angularJSTestingModule', angularJSModules)\n .constant(ɵconstants.UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(ɵconstants.INJECTOR_KEY, () => injector);\n $injector = angular.injector(['ng', '$$angularJSTestingModule'], strictDi);\n return AngularTestingModule;\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 {Injector} from '@angular/core';\nimport {TestBed} from '@angular/core/testing';\nimport {ɵangular1 as ng, ɵconstants} from '../../../static';\n\nimport {UpgradeAppType} from '../../../src/common/src/util';\n\n/**\n * A helper function to use when unit testing AngularJS services that depend upon downgraded Angular\n * services.\n *\n * This function returns an AngularJS module that is configured to wire up the AngularJS and Angular\n * injectors without the need to actually bootstrap a hybrid application.\n * This makes it simpler and faster to unit test services.\n *\n * Use the returned AngularJS module in a call to\n * [`angular.mocks.module`](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) to\n * include this module in the unit test injector.\n *\n * In the following code snippet, we are configuring the `$injector` with two modules:\n * The AngularJS `ng1AppModule`, which is the AngularJS part of our hybrid application and the\n * `Ng2AppModule`, which is the Angular part.\n *\n * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-setup'}\n *\n * Once this is done we can get hold of services via the AngularJS `$injector` as normal.\n * Services that are (or have dependencies on) a downgraded Angular service, will be instantiated as\n * needed by the Angular root `Injector`.\n *\n * In the following code snippet, `heroesService` is a downgraded Angular service that we are\n * accessing from AngularJS.\n *\n * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-spec'}\n *\n *
\n *\n * This helper is for testing services not components.\n * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or\n * `downgradeModule` for more information.\n *\n *
\n *\n *
\n *\n * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the\n * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger\n * AngularJS handlers of async events from Angular.\n *\n *
\n *\n *
\n *\n * The helper sets up global variables to hold the shared Angular and AngularJS injectors.\n *\n * * Only call this helper once per spec.\n * * Do not use `createAngularJSTestingModule` in the same spec as `createAngularTestingModule`.\n *\n *
\n *\n * Here is the example application and its unit tests that use `createAngularTestingModule`\n * and `createAngularJSTestingModule`.\n *\n * \n * \n * \n * \n *\n *\n * @param angularModules a collection of Angular modules to include in the configuration.\n *\n * @publicApi\n */\nexport function createAngularJSTestingModule(angularModules: any[]): string {\n return ng\n .module_('$$angularJSTestingModule', [])\n .constant(ɵconstants.UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)\n .factory(ɵconstants.INJECTOR_KEY, [\n ɵconstants.$INJECTOR,\n ($injector: ng.IInjectorService) => {\n TestBed.configureTestingModule({\n imports: angularModules,\n providers: [{provide: ɵconstants.$INJECTOR, useValue: $injector}],\n });\n return TestBed.inject(Injector);\n },\n ]).name;\n}\n"],"names":["ɵconstants.$INJECTOR","angular\n .module_","ɵconstants.UPGRADE_APP_TYPE_KEY","ɵconstants.INJECTOR_KEY","angular.injector","ng\n .module_"],"mappings":";;;;;;;;;;;AAaA,IAAI,SAAS,GAAoC,IAAI;AACrD,IAAI,QAAkB;SAEN,gBAAgB,GAAA;AAC9B,IAAA,OAAO,SAAS;AAClB;MAGa,oBAAoB,CAAA;AAC/B,IAAA,WAAA,CAAY,CAAW,EAAA;QACrB,QAAQ,GAAG,CAAC;;kHAFH,oBAAoB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,QAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;mHAApB,oBAAoB,EAAA,CAAA;AAApB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,EADX,SAAA,EAAA,CAAC,EAAC,OAAO,EAAEA,SAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC,EAAA,CAAA;;sGACxE,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,SAAS,EAAE,CAAC,EAAC,OAAO,EAAEA,SAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAC,CAAC,EAAC;;AAOtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEG;AACa,SAAA,0BAA0B,CACxC,gBAA0B,EAC1B,QAAkB,EAAA;IAElBC,OACU,CAAC,0BAA0B,EAAE,gBAAgB;AACpD,SAAA,QAAQ,CAACC,oBAA+B,EAAwB,CAAA;SAChE,OAAO,CAACC,YAAuB,EAAE,MAAM,QAAQ,CAAC;AACnD,IAAA,SAAS,GAAGC,UAAgB,CAAC,CAAC,IAAI,EAAE,0BAA0B,CAAC,EAAE,QAAQ,CAAC;AAC1E,IAAA,OAAO,oBAAoB;AAC7B;;ACxFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEG;AACG,SAAU,4BAA4B,CAAC,cAAqB,EAAA;AAChE,IAAA,OAAOC,OACG,CAAC,0BAA0B,EAAE,EAAE;AACtC,SAAA,QAAQ,CAACH,oBAA+B,EAAwB,CAAA;AAChE,SAAA,OAAO,CAACC,YAAuB,EAAE;AAChC,QAAAH,SAAoB;QACpB,CAAC,SAA8B,KAAI;YACjC,OAAO,CAAC,sBAAsB,CAAC;AAC7B,gBAAA,OAAO,EAAE,cAAc;AACvB,gBAAA,SAAS,EAAE,CAAC,EAAC,OAAO,EAAEA,SAAoB,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC;AAClE,aAAA,CAAC;AACF,YAAA,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;SAChC;KACF,CAAC,CAAC,IAAI;AACX;;;;"} -------------------------------------------------------------------------------- /fesm2022/upgrade.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { UpgradeHelper, trustedHTMLFromLegacyTemplate, isFunction, strictEquals, downgradeComponent, onError, controllerKey, downgradeInjectable, Deferred, destroyApp } from './upgrade_helper-C850j0tg.mjs'; 8 | export { VERSION } from './upgrade_helper-C850j0tg.mjs'; 9 | import { __decorate, __metadata } from 'tslib'; 10 | import * as i0 from '@angular/core'; 11 | import { Inject, Injector, ElementRef, Directive, EventEmitter, NgZone, Compiler, NgModule, resolveForwardRef, Testability } from '@angular/core'; 12 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 13 | import { $SCOPE, bootstrap, element, INJECTOR_KEY, $INJECTOR, module_, UPGRADE_APP_TYPE_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, COMPILER_KEY, $ROOT_SCOPE, $$TESTABILITY, $COMPILE } from './constants-nqBIph3y.mjs'; 14 | 15 | const CAMEL_CASE = /([A-Z])/g; 16 | const INITIAL_VALUE = { 17 | __UNINITIALIZED__: true, 18 | }; 19 | const NOT_SUPPORTED = 'NOT_SUPPORTED'; 20 | function getInputPropertyMapName(name) { 21 | return `input_${name}`; 22 | } 23 | function getOutputPropertyMapName(name) { 24 | return `output_${name}`; 25 | } 26 | class UpgradeNg1ComponentAdapterBuilder { 27 | name; 28 | type; 29 | inputs = []; 30 | inputsRename = []; 31 | outputs = []; 32 | outputsRename = []; 33 | propertyOutputs = []; 34 | checkProperties = []; 35 | propertyMap = {}; 36 | directive = null; 37 | template; 38 | constructor(name) { 39 | this.name = name; 40 | const selector = name.replace(CAMEL_CASE, (all, next) => '-' + next.toLowerCase()); 41 | const self = this; 42 | let MyClass = class MyClass extends UpgradeNg1ComponentAdapter { 43 | constructor(scope, injector, elementRef) { 44 | super(new UpgradeHelper(injector, name, elementRef, self.directive || undefined), scope, self.template, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap); 45 | } 46 | static ctorParameters = () => [ 47 | { type: undefined, decorators: [{ type: Inject, args: [$SCOPE,] }] }, 48 | { type: Injector }, 49 | { type: ElementRef } 50 | ]; 51 | }; 52 | MyClass = __decorate([ 53 | Directive({ 54 | jit: true, 55 | selector: selector, 56 | inputs: this.inputsRename, 57 | outputs: this.outputsRename, 58 | standalone: false, 59 | }), 60 | __metadata("design:paramtypes", [Object, Injector, ElementRef]) 61 | ], MyClass); 62 | this.type = MyClass; 63 | } 64 | extractBindings() { 65 | const btcIsObject = typeof this.directive.bindToController === 'object'; 66 | if (btcIsObject && Object.keys(this.directive.scope).length) { 67 | throw new Error(`Binding definitions on scope and controller at the same time are not supported.`); 68 | } 69 | const context = btcIsObject ? this.directive.bindToController : this.directive.scope; 70 | if (typeof context == 'object') { 71 | Object.keys(context).forEach((propName) => { 72 | const definition = context[propName]; 73 | const bindingType = definition.charAt(0); 74 | const bindingOptions = definition.charAt(1); 75 | const attrName = definition.substring(bindingOptions === '?' ? 2 : 1) || propName; 76 | // QUESTION: What about `=*`? Ignore? Throw? Support? 77 | const inputName = getInputPropertyMapName(attrName); 78 | const inputNameRename = `${inputName}: ${attrName}`; 79 | const outputName = getOutputPropertyMapName(attrName); 80 | const outputNameRename = `${outputName}: ${attrName}`; 81 | const outputNameRenameChange = `${outputNameRename}Change`; 82 | switch (bindingType) { 83 | case '@': 84 | case '<': 85 | this.inputs.push(inputName); 86 | this.inputsRename.push(inputNameRename); 87 | this.propertyMap[inputName] = propName; 88 | break; 89 | case '=': 90 | this.inputs.push(inputName); 91 | this.inputsRename.push(inputNameRename); 92 | this.propertyMap[inputName] = propName; 93 | this.outputs.push(outputName); 94 | this.outputsRename.push(outputNameRenameChange); 95 | this.propertyMap[outputName] = propName; 96 | this.checkProperties.push(propName); 97 | this.propertyOutputs.push(outputName); 98 | break; 99 | case '&': 100 | this.outputs.push(outputName); 101 | this.outputsRename.push(outputNameRename); 102 | this.propertyMap[outputName] = propName; 103 | break; 104 | default: 105 | let json = JSON.stringify(context); 106 | throw new Error(`Unexpected mapping '${bindingType}' in '${json}' in '${this.name}' directive.`); 107 | } 108 | }); 109 | } 110 | } 111 | /** 112 | * Upgrade ng1 components into Angular. 113 | */ 114 | static resolve(exportedComponents, $injector) { 115 | const promises = Object.entries(exportedComponents).map(([name, exportedComponent]) => { 116 | exportedComponent.directive = UpgradeHelper.getDirective($injector, name); 117 | exportedComponent.extractBindings(); 118 | return Promise.resolve(UpgradeHelper.getTemplate($injector, exportedComponent.directive, true)).then((template) => (exportedComponent.template = template)); 119 | }); 120 | return Promise.all(promises); 121 | } 122 | } 123 | class UpgradeNg1ComponentAdapter { 124 | helper; 125 | template; 126 | inputs; 127 | outputs; 128 | propOuts; 129 | checkProperties; 130 | propertyMap; 131 | controllerInstance = null; 132 | destinationObj = null; 133 | checkLastValues = []; 134 | directive; 135 | element; 136 | $element = null; 137 | componentScope; 138 | constructor(helper, scope, template, inputs, outputs, propOuts, checkProperties, propertyMap) { 139 | this.helper = helper; 140 | this.template = template; 141 | this.inputs = inputs; 142 | this.outputs = outputs; 143 | this.propOuts = propOuts; 144 | this.checkProperties = checkProperties; 145 | this.propertyMap = propertyMap; 146 | this.directive = helper.directive; 147 | this.element = helper.element; 148 | this.$element = helper.$element; 149 | this.componentScope = scope.$new(!!this.directive.scope); 150 | const controllerType = this.directive.controller; 151 | if (this.directive.bindToController && controllerType) { 152 | this.controllerInstance = this.helper.buildController(controllerType, this.componentScope); 153 | this.destinationObj = this.controllerInstance; 154 | } 155 | else { 156 | this.destinationObj = this.componentScope; 157 | } 158 | for (const input of this.inputs) { 159 | this[input] = null; 160 | } 161 | for (const output of this.outputs) { 162 | const emitter = (this[output] = new EventEmitter()); 163 | if (this.propOuts.indexOf(output) === -1) { 164 | this.setComponentProperty(output, ((emitter) => (value) => emitter.emit(value))(emitter)); 165 | } 166 | } 167 | this.checkLastValues.push(...Array(propOuts.length).fill(INITIAL_VALUE)); 168 | } 169 | ngOnInit() { 170 | // Collect contents, insert and compile template 171 | const attachChildNodes = this.helper.prepareTransclusion(); 172 | const linkFn = this.helper.compileTemplate(trustedHTMLFromLegacyTemplate(this.template)); 173 | // Instantiate controller (if not already done so) 174 | const controllerType = this.directive.controller; 175 | const bindToController = this.directive.bindToController; 176 | if (controllerType && !bindToController) { 177 | this.controllerInstance = this.helper.buildController(controllerType, this.componentScope); 178 | } 179 | // Require other controllers 180 | const requiredControllers = this.helper.resolveAndBindRequiredControllers(this.controllerInstance); 181 | // Hook: $onInit 182 | if (this.controllerInstance && isFunction(this.controllerInstance.$onInit)) { 183 | this.controllerInstance.$onInit(); 184 | } 185 | // Linking 186 | const link = this.directive.link; 187 | const preLink = typeof link == 'object' && link.pre; 188 | const postLink = typeof link == 'object' ? link.post : link; 189 | const attrs = NOT_SUPPORTED; 190 | const transcludeFn = NOT_SUPPORTED; 191 | if (preLink) { 192 | preLink(this.componentScope, this.$element, attrs, requiredControllers, transcludeFn); 193 | } 194 | linkFn(this.componentScope, null, { parentBoundTranscludeFn: attachChildNodes }); 195 | if (postLink) { 196 | postLink(this.componentScope, this.$element, attrs, requiredControllers, transcludeFn); 197 | } 198 | // Hook: $postLink 199 | if (this.controllerInstance && isFunction(this.controllerInstance.$postLink)) { 200 | this.controllerInstance.$postLink(); 201 | } 202 | } 203 | ngOnChanges(changes) { 204 | const ng1Changes = {}; 205 | Object.keys(changes).forEach((propertyMapName) => { 206 | const change = changes[propertyMapName]; 207 | this.setComponentProperty(propertyMapName, change.currentValue); 208 | ng1Changes[this.propertyMap[propertyMapName]] = change; 209 | }); 210 | if (isFunction(this.destinationObj.$onChanges)) { 211 | this.destinationObj.$onChanges(ng1Changes); 212 | } 213 | } 214 | ngDoCheck() { 215 | const destinationObj = this.destinationObj; 216 | const lastValues = this.checkLastValues; 217 | const checkProperties = this.checkProperties; 218 | const propOuts = this.propOuts; 219 | checkProperties.forEach((propName, i) => { 220 | const value = destinationObj[propName]; 221 | const last = lastValues[i]; 222 | if (!strictEquals(last, value)) { 223 | const eventEmitter = this[propOuts[i]]; 224 | eventEmitter.emit((lastValues[i] = value)); 225 | } 226 | }); 227 | if (this.controllerInstance && isFunction(this.controllerInstance.$doCheck)) { 228 | this.controllerInstance.$doCheck(); 229 | } 230 | } 231 | ngOnDestroy() { 232 | this.helper.onDestroy(this.componentScope, this.controllerInstance); 233 | } 234 | setComponentProperty(name, value) { 235 | this.destinationObj[this.propertyMap[name]] = value; 236 | } 237 | static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); 238 | static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0-next.0+sha-21fc93b", type: UpgradeNg1ComponentAdapter, isStandalone: true, usesOnChanges: true, ngImport: i0 }); 239 | } 240 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0-next.0+sha-21fc93b", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{ 241 | type: Directive 242 | }], ctorParameters: () => [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }] }); 243 | 244 | let upgradeCount = 0; 245 | /** 246 | * Use `UpgradeAdapter` to allow AngularJS and Angular to coexist in a single application. 247 | * 248 | * The `UpgradeAdapter` allows: 249 | * 1. creation of Angular component from AngularJS component directive 250 | * (See {@link UpgradeAdapter#upgradeNg1Component}) 251 | * 2. creation of AngularJS directive from Angular component. 252 | * (See {@link UpgradeAdapter#downgradeNg2Component}) 253 | * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks 254 | * coexisting in a single application. 255 | * 256 | * @usageNotes 257 | * ### Mental Model 258 | * 259 | * When reasoning about how a hybrid application works it is useful to have a mental model which 260 | * describes what is happening and explains what is happening at the lowest level. 261 | * 262 | * 1. There are two independent frameworks running in a single application, each framework treats 263 | * the other as a black box. 264 | * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework 265 | * instantiated the element is the owner. Each framework only updates/interacts with its own 266 | * DOM elements and ignores others. 267 | * 3. AngularJS directives always execute inside AngularJS framework codebase regardless of 268 | * where they are instantiated. 269 | * 4. Angular components always execute inside Angular framework codebase regardless of 270 | * where they are instantiated. 271 | * 5. An AngularJS component can be upgraded to an Angular component. This creates an 272 | * Angular directive, which bootstraps the AngularJS component directive in that location. 273 | * 6. An Angular component can be downgraded to an AngularJS component directive. This creates 274 | * an AngularJS directive, which bootstraps the Angular component in that location. 275 | * 7. Whenever an adapter component is instantiated the host element is owned by the framework 276 | * doing the instantiation. The other framework then instantiates and owns the view for that 277 | * component. This implies that component bindings will always follow the semantics of the 278 | * instantiation framework. The syntax is always that of Angular syntax. 279 | * 8. AngularJS is always bootstrapped first and owns the bottom most view. 280 | * 9. The new application is running in Angular zone, and therefore it no longer needs calls to 281 | * `$apply()`. 282 | * 283 | * ### Example 284 | * 285 | * ```ts 286 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module), myCompilerOptions); 287 | * const module = angular.module('myExample', []); 288 | * module.directive('ng2Comp', adapter.downgradeNg2Component(Ng2Component)); 289 | * 290 | * module.directive('ng1Hello', function() { 291 | * return { 292 | * scope: { title: '=' }, 293 | * template: 'ng1[Hello {{title}}!]()' 294 | * }; 295 | * }); 296 | * 297 | * 298 | * @Component({ 299 | * selector: 'ng2-comp', 300 | * inputs: ['name'], 301 | * template: 'ng2[transclude]()', 302 | * directives: 303 | * }) 304 | * class Ng2Component { 305 | * } 306 | * 307 | * @NgModule({ 308 | * declarations: [Ng2Component, adapter.upgradeNg1Component('ng1Hello')], 309 | * imports: [BrowserModule] 310 | * }) 311 | * class MyNg2Module {} 312 | * 313 | * 314 | * document.body.innerHTML = 'project'; 315 | * 316 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 317 | * expect(document.body.textContent).toEqual( 318 | * "ng2[ng1[Hello World!](transclude)](project)"); 319 | * }); 320 | * 321 | * ``` 322 | * 323 | * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports 324 | * [Ahead-of-Time compilation](tools/cli/aot-compiler). 325 | * @publicApi 326 | */ 327 | class UpgradeAdapter { 328 | ng2AppModule; 329 | compilerOptions; 330 | idPrefix = `NG2_UPGRADE_${upgradeCount++}_`; 331 | downgradedComponents = []; 332 | /** 333 | * An internal map of ng1 components which need to up upgraded to ng2. 334 | * 335 | * We can't upgrade until injector is instantiated and we can retrieve the component metadata. 336 | * For this reason we keep a list of components to upgrade until ng1 injector is bootstrapped. 337 | * 338 | * @internal 339 | */ 340 | ng1ComponentsToBeUpgraded = {}; 341 | upgradedProviders = []; 342 | moduleRef = null; 343 | constructor(ng2AppModule, compilerOptions) { 344 | this.ng2AppModule = ng2AppModule; 345 | this.compilerOptions = compilerOptions; 346 | if (!ng2AppModule) { 347 | throw new Error('UpgradeAdapter cannot be instantiated without an NgModule of the Angular app.'); 348 | } 349 | } 350 | /** 351 | * Allows Angular Component to be used from AngularJS. 352 | * 353 | * Use `downgradeNg2Component` to create an AngularJS Directive Definition Factory from 354 | * Angular Component. The adapter will bootstrap Angular component from within the 355 | * AngularJS template. 356 | * 357 | * @usageNotes 358 | * ### Mental Model 359 | * 360 | * 1. The component is instantiated by being listed in AngularJS template. This means that the 361 | * host element is controlled by AngularJS, but the component's view will be controlled by 362 | * Angular. 363 | * 2. Even thought the component is instantiated in AngularJS, it will be using Angular 364 | * syntax. This has to be done, this way because we must follow Angular components do not 365 | * declare how the attributes should be interpreted. 366 | * 3. `ng-model` is controlled by AngularJS and communicates with the downgraded Angular component 367 | * by way of the `ControlValueAccessor` interface from @angular/forms. Only components that 368 | * implement this interface are eligible. 369 | * 370 | * ### Supported Features 371 | * 372 | * - Bindings: 373 | * - Attribute: `` 374 | * - Interpolation: `` 375 | * - Expression: `` 376 | * - Event: `` 377 | * - ng-model: `` 378 | * - Content projection: yes 379 | * 380 | * ### Example 381 | * 382 | * ```angular-ts 383 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module)); 384 | * const module = angular.module('myExample', []); 385 | * module.directive('greet', adapter.downgradeNg2Component(Greeter)); 386 | * 387 | * @Component({ 388 | * selector: 'greet', 389 | * template: '{{salutation()}} {{name()}}! - ' 390 | * }) 391 | * class Greeter { 392 | * salutation = input.required(); 393 | * name: input.required(); 394 | * } 395 | * 396 | * @NgModule({ 397 | * declarations: [Greeter], 398 | * imports: [BrowserModule] 399 | * }) 400 | * class MyNg2Module {} 401 | * 402 | * document.body.innerHTML = 403 | * 'ng1 template: text'; 404 | * 405 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 406 | * expect(document.body.textContent).toEqual("ng1 template: Hello world! - text"); 407 | * }); 408 | * ``` 409 | */ 410 | downgradeNg2Component(component) { 411 | this.downgradedComponents.push(component); 412 | return downgradeComponent({ component }); 413 | } 414 | /** 415 | * Allows AngularJS Component to be used from Angular. 416 | * 417 | * Use `upgradeNg1Component` to create an Angular component from AngularJS Component 418 | * directive. The adapter will bootstrap AngularJS component from within the Angular 419 | * template. 420 | * 421 | * @usageNotes 422 | * ### Mental Model 423 | * 424 | * 1. The component is instantiated by being listed in Angular template. This means that the 425 | * host element is controlled by Angular, but the component's view will be controlled by 426 | * AngularJS. 427 | * 428 | * ### Supported Features 429 | * 430 | * - Bindings: 431 | * - Attribute: `` 432 | * - Interpolation: `` 433 | * - Expression: `` 434 | * - Event: `` 435 | * - Transclusion: yes 436 | * - Only some of the features of 437 | * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are 438 | * supported: 439 | * - `compile`: not supported because the host element is owned by Angular, which does 440 | * not allow modifying DOM structure during compilation. 441 | * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.) 442 | * - `controllerAs`: supported. 443 | * - `bindToController`: supported. 444 | * - `link`: supported. (NOTE: only pre-link function is supported.) 445 | * - `name`: supported. 446 | * - `priority`: ignored. 447 | * - `replace`: not supported. 448 | * - `require`: supported. 449 | * - `restrict`: must be set to 'E'. 450 | * - `scope`: supported. 451 | * - `template`: supported. 452 | * - `templateUrl`: supported. 453 | * - `terminal`: ignored. 454 | * - `transclude`: supported. 455 | * 456 | * 457 | * ### Example 458 | * 459 | * ```angular-ts 460 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module)); 461 | * const module = angular.module('myExample', []); 462 | * 463 | * module.directive('greet', function() { 464 | * return { 465 | * scope: {salutation: '=', name: '=' }, 466 | * template: '{{salutation}} {{name}}! - ' 467 | * }; 468 | * }); 469 | * 470 | * module.directive('ng2', adapter.downgradeNg2Component(Ng2Component)); 471 | * 472 | * @Component({ 473 | * selector: 'ng2', 474 | * template: 'ng2 template: text' 475 | * }) 476 | * class Ng2Component { 477 | * } 478 | * 479 | * @NgModule({ 480 | * declarations: [Ng2Component, adapter.upgradeNg1Component('greet')], 481 | * imports: [BrowserModule] 482 | * }) 483 | * class MyNg2Module {} 484 | * 485 | * document.body.innerHTML = ''; 486 | * 487 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 488 | * expect(document.body.textContent).toEqual("ng2 template: Hello world! - text"); 489 | * }); 490 | * ``` 491 | */ 492 | upgradeNg1Component(name) { 493 | if (this.ng1ComponentsToBeUpgraded.hasOwnProperty(name)) { 494 | return this.ng1ComponentsToBeUpgraded[name].type; 495 | } 496 | else { 497 | return (this.ng1ComponentsToBeUpgraded[name] = new UpgradeNg1ComponentAdapterBuilder(name)) 498 | .type; 499 | } 500 | } 501 | /** 502 | * Registers the adapter's AngularJS upgrade module for unit testing in AngularJS. 503 | * Use this instead of `angular.mock.module()` to load the upgrade module into 504 | * the AngularJS testing injector. 505 | * 506 | * @usageNotes 507 | * ### Example 508 | * 509 | * ```ts 510 | * const upgradeAdapter = new UpgradeAdapter(MyNg2Module); 511 | * 512 | * // configure the adapter with upgrade/downgrade components and services 513 | * upgradeAdapter.downgradeNg2Component(MyComponent); 514 | * 515 | * let upgradeAdapterRef: UpgradeAdapterRef; 516 | * let $compile, $rootScope; 517 | * 518 | * // We must register the adapter before any calls to `inject()` 519 | * beforeEach(() => { 520 | * upgradeAdapterRef = upgradeAdapter.registerForNg1Tests(['heroApp']); 521 | * }); 522 | * 523 | * beforeEach(inject((_$compile_, _$rootScope_) => { 524 | * $compile = _$compile_; 525 | * $rootScope = _$rootScope_; 526 | * })); 527 | * 528 | * it("says hello", (done) => { 529 | * upgradeAdapterRef.ready(() => { 530 | * const element = $compile("")($rootScope); 531 | * $rootScope.$apply(); 532 | * expect(element.html()).toContain("Hello World"); 533 | * done(); 534 | * }) 535 | * }); 536 | * 537 | * ``` 538 | * 539 | * @param modules any AngularJS modules that the upgrade module should depend upon 540 | * @returns an `UpgradeAdapterRef`, which lets you register a `ready()` callback to 541 | * run assertions once the Angular components are ready to test through AngularJS. 542 | */ 543 | registerForNg1Tests(modules) { 544 | const windowNgMock = window['angular'].mock; 545 | if (!windowNgMock || !windowNgMock.module) { 546 | throw new Error("Failed to find 'angular.mock.module'."); 547 | } 548 | const { ng1Module, ng2BootstrapDeferred } = this.declareNg1Module(modules); 549 | windowNgMock.module(ng1Module.name); 550 | const upgrade = new UpgradeAdapterRef(); 551 | ng2BootstrapDeferred.promise.then((ng1Injector) => { 552 | // @ts-expect-error 553 | upgrade._bootstrapDone(this.moduleRef, ng1Injector); 554 | }, onError); 555 | return upgrade; 556 | } 557 | /** 558 | * Bootstrap a hybrid AngularJS / Angular application. 559 | * 560 | * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS 561 | * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike 562 | * AngularJS, this bootstrap is asynchronous. 563 | * 564 | * @usageNotes 565 | * ### Example 566 | * 567 | * ```angular-ts 568 | * const adapter = new UpgradeAdapter(MyNg2Module); 569 | * const module = angular.module('myExample', []); 570 | * module.directive('ng2', adapter.downgradeNg2Component(Ng2)); 571 | * 572 | * module.directive('ng1', function() { 573 | * return { 574 | * scope: { title: '=' }, 575 | * template: 'ng1[Hello {{title}}!]()' 576 | * }; 577 | * }); 578 | * 579 | * 580 | * @Component({ 581 | * selector: 'ng2', 582 | * inputs: ['name'], 583 | * template: 'ng2[transclude]()' 584 | * }) 585 | * class Ng2 { 586 | * } 587 | * 588 | * @NgModule({ 589 | * declarations: [Ng2, adapter.upgradeNg1Component('ng1')], 590 | * imports: [BrowserModule] 591 | * }) 592 | * class MyNg2Module {} 593 | * 594 | * document.body.innerHTML = 'project'; 595 | * 596 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 597 | * expect(document.body.textContent).toEqual( 598 | * "ng2[ng1[Hello World!](transclude)](project)"); 599 | * }); 600 | * ``` 601 | */ 602 | bootstrap(element$1, modules, config) { 603 | const { ng1Module, ng2BootstrapDeferred, ngZone } = this.declareNg1Module(modules); 604 | const upgrade = new UpgradeAdapterRef(); 605 | // Make sure resumeBootstrap() only exists if the current bootstrap is deferred 606 | const windowAngular = window['angular']; 607 | windowAngular.resumeBootstrap = undefined; 608 | ngZone.run(() => { 609 | bootstrap(element$1, [ng1Module.name], config); 610 | }); 611 | const ng1BootstrapPromise = new Promise((resolve) => { 612 | if (windowAngular.resumeBootstrap) { 613 | const originalResumeBootstrap = windowAngular.resumeBootstrap; 614 | windowAngular.resumeBootstrap = function () { 615 | windowAngular.resumeBootstrap = originalResumeBootstrap; 616 | const r = windowAngular.resumeBootstrap.apply(this, arguments); 617 | resolve(); 618 | return r; 619 | }; 620 | } 621 | else { 622 | resolve(); 623 | } 624 | }); 625 | Promise.all([ng2BootstrapDeferred.promise, ng1BootstrapPromise]).then(([ng1Injector]) => { 626 | element(element$1).data(controllerKey(INJECTOR_KEY), this.moduleRef.injector); 627 | this.moduleRef.injector.get(NgZone).run(() => { 628 | // @ts-expect-error 629 | upgrade._bootstrapDone(this.moduleRef, ng1Injector); 630 | }); 631 | }, onError); 632 | return upgrade; 633 | } 634 | /** 635 | * Allows AngularJS service to be accessible from Angular. 636 | * 637 | * @usageNotes 638 | * ### Example 639 | * 640 | * ```ts 641 | * class Login { ... } 642 | * class Server { ... } 643 | * 644 | * @Injectable() 645 | * class Example { 646 | * constructor(@Inject('server') server, login: Login) { 647 | * ... 648 | * } 649 | * } 650 | * 651 | * const module = angular.module('myExample', []); 652 | * module.service('server', Server); 653 | * module.service('login', Login); 654 | * 655 | * const adapter = new UpgradeAdapter(MyNg2Module); 656 | * adapter.upgradeNg1Provider('server'); 657 | * adapter.upgradeNg1Provider('login', {asToken: Login}); 658 | * 659 | * adapter.bootstrap(document.body, ['myExample']).ready((ref) => { 660 | * const example: Example = ref.ng2Injector.get(Example); 661 | * }); 662 | * 663 | * ``` 664 | */ 665 | upgradeNg1Provider(name, options) { 666 | const token = (options && options.asToken) || name; 667 | this.upgradedProviders.push({ 668 | provide: token, 669 | useFactory: ($injector) => $injector.get(name), 670 | deps: [$INJECTOR], 671 | }); 672 | } 673 | /** 674 | * Allows Angular service to be accessible from AngularJS. 675 | * 676 | * @usageNotes 677 | * ### Example 678 | * 679 | * ```ts 680 | * class Example { 681 | * } 682 | * 683 | * const adapter = new UpgradeAdapter(MyNg2Module); 684 | * 685 | * const module = angular.module('myExample', []); 686 | * module.factory('example', adapter.downgradeNg2Provider(Example)); 687 | * 688 | * adapter.bootstrap(document.body, ['myExample']).ready((ref) => { 689 | * const example: Example = ref.ng1Injector.get('example'); 690 | * }); 691 | * 692 | * ``` 693 | */ 694 | downgradeNg2Provider(token) { 695 | return downgradeInjectable(token); 696 | } 697 | /** 698 | * Declare the AngularJS upgrade module for this adapter without bootstrapping the whole 699 | * hybrid application. 700 | * 701 | * This method is automatically called by `bootstrap()` and `registerForNg1Tests()`. 702 | * 703 | * @param modules The AngularJS modules that this upgrade module should depend upon. 704 | * @returns The AngularJS upgrade module that is declared by this method 705 | * 706 | * @usageNotes 707 | * ### Example 708 | * 709 | * ```ts 710 | * const upgradeAdapter = new UpgradeAdapter(MyNg2Module); 711 | * upgradeAdapter.declareNg1Module(['heroApp']); 712 | * ``` 713 | */ 714 | declareNg1Module(modules = []) { 715 | const delayApplyExps = []; 716 | let original$applyFn; 717 | let rootScopePrototype; 718 | const upgradeAdapter = this; 719 | const ng1Module = module_(this.idPrefix, modules); 720 | const platformRef = platformBrowserDynamic(); 721 | const ngZone = new NgZone({ 722 | enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec'), 723 | }); 724 | const ng2BootstrapDeferred = new Deferred(); 725 | ng1Module 726 | .constant(UPGRADE_APP_TYPE_KEY, 1 /* UpgradeAppType.Dynamic */) 727 | .factory(INJECTOR_KEY, () => this.moduleRef.injector.get(Injector)) 728 | .factory(LAZY_MODULE_REF, [ 729 | INJECTOR_KEY, 730 | (injector) => ({ injector }), 731 | ]) 732 | .constant(NG_ZONE_KEY, ngZone) 733 | .factory(COMPILER_KEY, () => this.moduleRef.injector.get(Compiler)) 734 | .config([ 735 | '$provide', 736 | '$injector', 737 | (provide, ng1Injector) => { 738 | provide.decorator($ROOT_SCOPE, [ 739 | '$delegate', 740 | function (rootScopeDelegate) { 741 | // Capture the root apply so that we can delay first call to $apply until we 742 | // bootstrap Angular and then we replay and restore the $apply. 743 | rootScopePrototype = rootScopeDelegate.constructor.prototype; 744 | if (rootScopePrototype.hasOwnProperty('$apply')) { 745 | original$applyFn = rootScopePrototype.$apply; 746 | rootScopePrototype.$apply = (exp) => delayApplyExps.push(exp); 747 | } 748 | else { 749 | throw new Error("Failed to find '$apply' on '$rootScope'!"); 750 | } 751 | return rootScopeDelegate; 752 | }, 753 | ]); 754 | if (ng1Injector.has($$TESTABILITY)) { 755 | provide.decorator($$TESTABILITY, [ 756 | '$delegate', 757 | function (testabilityDelegate) { 758 | const originalWhenStable = testabilityDelegate.whenStable; 759 | // Cannot use arrow function below because we need the context 760 | const newWhenStable = function (callback) { 761 | originalWhenStable.call(this, function () { 762 | const ng2Testability = upgradeAdapter.moduleRef.injector.get(Testability); 763 | if (ng2Testability.isStable()) { 764 | callback.apply(this, arguments); 765 | } 766 | else { 767 | ng2Testability.whenStable(newWhenStable.bind(this, callback)); 768 | } 769 | }); 770 | }; 771 | testabilityDelegate.whenStable = newWhenStable; 772 | return testabilityDelegate; 773 | }, 774 | ]); 775 | } 776 | }, 777 | ]); 778 | ng1Module.run([ 779 | '$injector', 780 | '$rootScope', 781 | (ng1Injector, rootScope) => { 782 | UpgradeNg1ComponentAdapterBuilder.resolve(this.ng1ComponentsToBeUpgraded, ng1Injector) 783 | .then(() => { 784 | // At this point we have ng1 injector and we have prepared 785 | // ng1 components to be upgraded, we now can bootstrap ng2. 786 | let DynamicNgUpgradeModule = class DynamicNgUpgradeModule { 787 | ngDoBootstrap() { } 788 | }; 789 | DynamicNgUpgradeModule = __decorate([ 790 | NgModule({ 791 | jit: true, 792 | providers: [ 793 | { provide: $INJECTOR, useFactory: () => ng1Injector }, 794 | { provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE) }, 795 | this.upgradedProviders, 796 | ], 797 | imports: [resolveForwardRef(this.ng2AppModule)], 798 | }) 799 | ], DynamicNgUpgradeModule); 800 | platformRef 801 | .bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone }]) 802 | .then((ref) => { 803 | this.moduleRef = ref; 804 | ngZone.run(() => { 805 | if (rootScopePrototype) { 806 | rootScopePrototype.$apply = original$applyFn; // restore original $apply 807 | while (delayApplyExps.length) { 808 | rootScope.$apply(delayApplyExps.shift()); 809 | } 810 | rootScopePrototype = null; 811 | } 812 | }); 813 | }) 814 | .then(() => ng2BootstrapDeferred.resolve(ng1Injector), onError) 815 | .then(() => { 816 | let subscription = ngZone.onMicrotaskEmpty.subscribe({ 817 | next: () => { 818 | if (rootScope.$$phase) { 819 | if (typeof ngDevMode === 'undefined' || ngDevMode) { 820 | console.warn('A digest was triggered while one was already in progress. This may mean that something is triggering digests outside the Angular zone.'); 821 | } 822 | return rootScope.$evalAsync(() => { }); 823 | } 824 | return rootScope.$digest(); 825 | }, 826 | }); 827 | rootScope.$on('$destroy', () => { 828 | subscription.unsubscribe(); 829 | }); 830 | // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed. 831 | // This does not happen in a typical SPA scenario, but it might be useful for 832 | // other use-cases where disposing of an Angular/AngularJS app is necessary 833 | // (such as Hot Module Replacement (HMR)). 834 | // See https://github.com/angular/angular/issues/39935. 835 | platformRef.onDestroy(() => destroyApp(ng1Injector)); 836 | }); 837 | }) 838 | .catch((e) => ng2BootstrapDeferred.reject(e)); 839 | }, 840 | ]); 841 | return { ng1Module, ng2BootstrapDeferred, ngZone }; 842 | } 843 | } 844 | /** 845 | * Use `UpgradeAdapterRef` to control a hybrid AngularJS / Angular application. 846 | * 847 | * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports 848 | * [Ahead-of-Time compilation](tools/cli/aot-compiler). 849 | * @publicApi 850 | */ 851 | class UpgradeAdapterRef { 852 | /* @internal */ 853 | _readyFn = null; 854 | ng1RootScope = null; 855 | ng1Injector = null; 856 | ng2ModuleRef = null; 857 | ng2Injector = null; 858 | /* @internal */ 859 | _bootstrapDone(ngModuleRef, ng1Injector) { 860 | this.ng2ModuleRef = ngModuleRef; 861 | this.ng2Injector = ngModuleRef.injector; 862 | this.ng1Injector = ng1Injector; 863 | this.ng1RootScope = ng1Injector.get($ROOT_SCOPE); 864 | this._readyFn && this._readyFn(this); 865 | } 866 | /** 867 | * Register a callback function which is notified upon successful hybrid AngularJS / Angular 868 | * application has been bootstrapped. 869 | * 870 | * The `ready` callback function is invoked inside the Angular zone, therefore it does not 871 | * require a call to `$apply()`. 872 | */ 873 | ready(fn) { 874 | this._readyFn = fn; 875 | } 876 | /** 877 | * Dispose of running hybrid AngularJS / Angular application. 878 | */ 879 | dispose() { 880 | this.ng1Injector.get($ROOT_SCOPE).$destroy(); 881 | this.ng2ModuleRef.destroy(); 882 | } 883 | } 884 | 885 | export { UpgradeAdapter, UpgradeAdapterRef }; 886 | //# sourceMappingURL=upgrade.mjs.map 887 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { IAngularBootstrapConfig, IRootScopeService, IInjectorService } from './angular1.d-C3xPg7Lm.js'; 8 | export { VERSION } from './angular1.d-C3xPg7Lm.js'; 9 | import { Type, CompilerOptions, NgModuleRef, Injector } from '@angular/core'; 10 | 11 | /** 12 | * Use `UpgradeAdapter` to allow AngularJS and Angular to coexist in a single application. 13 | * 14 | * The `UpgradeAdapter` allows: 15 | * 1. creation of Angular component from AngularJS component directive 16 | * (See {@link UpgradeAdapter#upgradeNg1Component}) 17 | * 2. creation of AngularJS directive from Angular component. 18 | * (See {@link UpgradeAdapter#downgradeNg2Component}) 19 | * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks 20 | * coexisting in a single application. 21 | * 22 | * @usageNotes 23 | * ### Mental Model 24 | * 25 | * When reasoning about how a hybrid application works it is useful to have a mental model which 26 | * describes what is happening and explains what is happening at the lowest level. 27 | * 28 | * 1. There are two independent frameworks running in a single application, each framework treats 29 | * the other as a black box. 30 | * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework 31 | * instantiated the element is the owner. Each framework only updates/interacts with its own 32 | * DOM elements and ignores others. 33 | * 3. AngularJS directives always execute inside AngularJS framework codebase regardless of 34 | * where they are instantiated. 35 | * 4. Angular components always execute inside Angular framework codebase regardless of 36 | * where they are instantiated. 37 | * 5. An AngularJS component can be upgraded to an Angular component. This creates an 38 | * Angular directive, which bootstraps the AngularJS component directive in that location. 39 | * 6. An Angular component can be downgraded to an AngularJS component directive. This creates 40 | * an AngularJS directive, which bootstraps the Angular component in that location. 41 | * 7. Whenever an adapter component is instantiated the host element is owned by the framework 42 | * doing the instantiation. The other framework then instantiates and owns the view for that 43 | * component. This implies that component bindings will always follow the semantics of the 44 | * instantiation framework. The syntax is always that of Angular syntax. 45 | * 8. AngularJS is always bootstrapped first and owns the bottom most view. 46 | * 9. The new application is running in Angular zone, and therefore it no longer needs calls to 47 | * `$apply()`. 48 | * 49 | * ### Example 50 | * 51 | * ```ts 52 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module), myCompilerOptions); 53 | * const module = angular.module('myExample', []); 54 | * module.directive('ng2Comp', adapter.downgradeNg2Component(Ng2Component)); 55 | * 56 | * module.directive('ng1Hello', function() { 57 | * return { 58 | * scope: { title: '=' }, 59 | * template: 'ng1[Hello {{title}}!]()' 60 | * }; 61 | * }); 62 | * 63 | * 64 | * @Component({ 65 | * selector: 'ng2-comp', 66 | * inputs: ['name'], 67 | * template: 'ng2[transclude]()', 68 | * directives: 69 | * }) 70 | * class Ng2Component { 71 | * } 72 | * 73 | * @NgModule({ 74 | * declarations: [Ng2Component, adapter.upgradeNg1Component('ng1Hello')], 75 | * imports: [BrowserModule] 76 | * }) 77 | * class MyNg2Module {} 78 | * 79 | * 80 | * document.body.innerHTML = 'project'; 81 | * 82 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 83 | * expect(document.body.textContent).toEqual( 84 | * "ng2[ng1[Hello World!](transclude)](project)"); 85 | * }); 86 | * 87 | * ``` 88 | * 89 | * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports 90 | * [Ahead-of-Time compilation](tools/cli/aot-compiler). 91 | * @publicApi 92 | */ 93 | declare class UpgradeAdapter { 94 | private ng2AppModule; 95 | private compilerOptions?; 96 | private idPrefix; 97 | private downgradedComponents; 98 | private upgradedProviders; 99 | private moduleRef; 100 | constructor(ng2AppModule: Type, compilerOptions?: CompilerOptions | undefined); 101 | /** 102 | * Allows Angular Component to be used from AngularJS. 103 | * 104 | * Use `downgradeNg2Component` to create an AngularJS Directive Definition Factory from 105 | * Angular Component. The adapter will bootstrap Angular component from within the 106 | * AngularJS template. 107 | * 108 | * @usageNotes 109 | * ### Mental Model 110 | * 111 | * 1. The component is instantiated by being listed in AngularJS template. This means that the 112 | * host element is controlled by AngularJS, but the component's view will be controlled by 113 | * Angular. 114 | * 2. Even thought the component is instantiated in AngularJS, it will be using Angular 115 | * syntax. This has to be done, this way because we must follow Angular components do not 116 | * declare how the attributes should be interpreted. 117 | * 3. `ng-model` is controlled by AngularJS and communicates with the downgraded Angular component 118 | * by way of the `ControlValueAccessor` interface from @angular/forms. Only components that 119 | * implement this interface are eligible. 120 | * 121 | * ### Supported Features 122 | * 123 | * - Bindings: 124 | * - Attribute: `` 125 | * - Interpolation: `` 126 | * - Expression: `` 127 | * - Event: `` 128 | * - ng-model: `` 129 | * - Content projection: yes 130 | * 131 | * ### Example 132 | * 133 | * ```angular-ts 134 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module)); 135 | * const module = angular.module('myExample', []); 136 | * module.directive('greet', adapter.downgradeNg2Component(Greeter)); 137 | * 138 | * @Component({ 139 | * selector: 'greet', 140 | * template: '{{salutation()}} {{name()}}! - ' 141 | * }) 142 | * class Greeter { 143 | * salutation = input.required(); 144 | * name: input.required(); 145 | * } 146 | * 147 | * @NgModule({ 148 | * declarations: [Greeter], 149 | * imports: [BrowserModule] 150 | * }) 151 | * class MyNg2Module {} 152 | * 153 | * document.body.innerHTML = 154 | * 'ng1 template: text'; 155 | * 156 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 157 | * expect(document.body.textContent).toEqual("ng1 template: Hello world! - text"); 158 | * }); 159 | * ``` 160 | */ 161 | downgradeNg2Component(component: Type): Function; 162 | /** 163 | * Allows AngularJS Component to be used from Angular. 164 | * 165 | * Use `upgradeNg1Component` to create an Angular component from AngularJS Component 166 | * directive. The adapter will bootstrap AngularJS component from within the Angular 167 | * template. 168 | * 169 | * @usageNotes 170 | * ### Mental Model 171 | * 172 | * 1. The component is instantiated by being listed in Angular template. This means that the 173 | * host element is controlled by Angular, but the component's view will be controlled by 174 | * AngularJS. 175 | * 176 | * ### Supported Features 177 | * 178 | * - Bindings: 179 | * - Attribute: `` 180 | * - Interpolation: `` 181 | * - Expression: `` 182 | * - Event: `` 183 | * - Transclusion: yes 184 | * - Only some of the features of 185 | * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are 186 | * supported: 187 | * - `compile`: not supported because the host element is owned by Angular, which does 188 | * not allow modifying DOM structure during compilation. 189 | * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.) 190 | * - `controllerAs`: supported. 191 | * - `bindToController`: supported. 192 | * - `link`: supported. (NOTE: only pre-link function is supported.) 193 | * - `name`: supported. 194 | * - `priority`: ignored. 195 | * - `replace`: not supported. 196 | * - `require`: supported. 197 | * - `restrict`: must be set to 'E'. 198 | * - `scope`: supported. 199 | * - `template`: supported. 200 | * - `templateUrl`: supported. 201 | * - `terminal`: ignored. 202 | * - `transclude`: supported. 203 | * 204 | * 205 | * ### Example 206 | * 207 | * ```angular-ts 208 | * const adapter = new UpgradeAdapter(forwardRef(() => MyNg2Module)); 209 | * const module = angular.module('myExample', []); 210 | * 211 | * module.directive('greet', function() { 212 | * return { 213 | * scope: {salutation: '=', name: '=' }, 214 | * template: '{{salutation}} {{name}}! - ' 215 | * }; 216 | * }); 217 | * 218 | * module.directive('ng2', adapter.downgradeNg2Component(Ng2Component)); 219 | * 220 | * @Component({ 221 | * selector: 'ng2', 222 | * template: 'ng2 template: text' 223 | * }) 224 | * class Ng2Component { 225 | * } 226 | * 227 | * @NgModule({ 228 | * declarations: [Ng2Component, adapter.upgradeNg1Component('greet')], 229 | * imports: [BrowserModule] 230 | * }) 231 | * class MyNg2Module {} 232 | * 233 | * document.body.innerHTML = ''; 234 | * 235 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 236 | * expect(document.body.textContent).toEqual("ng2 template: Hello world! - text"); 237 | * }); 238 | * ``` 239 | */ 240 | upgradeNg1Component(name: string): Type; 241 | /** 242 | * Registers the adapter's AngularJS upgrade module for unit testing in AngularJS. 243 | * Use this instead of `angular.mock.module()` to load the upgrade module into 244 | * the AngularJS testing injector. 245 | * 246 | * @usageNotes 247 | * ### Example 248 | * 249 | * ```ts 250 | * const upgradeAdapter = new UpgradeAdapter(MyNg2Module); 251 | * 252 | * // configure the adapter with upgrade/downgrade components and services 253 | * upgradeAdapter.downgradeNg2Component(MyComponent); 254 | * 255 | * let upgradeAdapterRef: UpgradeAdapterRef; 256 | * let $compile, $rootScope; 257 | * 258 | * // We must register the adapter before any calls to `inject()` 259 | * beforeEach(() => { 260 | * upgradeAdapterRef = upgradeAdapter.registerForNg1Tests(['heroApp']); 261 | * }); 262 | * 263 | * beforeEach(inject((_$compile_, _$rootScope_) => { 264 | * $compile = _$compile_; 265 | * $rootScope = _$rootScope_; 266 | * })); 267 | * 268 | * it("says hello", (done) => { 269 | * upgradeAdapterRef.ready(() => { 270 | * const element = $compile("")($rootScope); 271 | * $rootScope.$apply(); 272 | * expect(element.html()).toContain("Hello World"); 273 | * done(); 274 | * }) 275 | * }); 276 | * 277 | * ``` 278 | * 279 | * @param modules any AngularJS modules that the upgrade module should depend upon 280 | * @returns an `UpgradeAdapterRef`, which lets you register a `ready()` callback to 281 | * run assertions once the Angular components are ready to test through AngularJS. 282 | */ 283 | registerForNg1Tests(modules?: string[]): UpgradeAdapterRef; 284 | /** 285 | * Bootstrap a hybrid AngularJS / Angular application. 286 | * 287 | * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS 288 | * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike 289 | * AngularJS, this bootstrap is asynchronous. 290 | * 291 | * @usageNotes 292 | * ### Example 293 | * 294 | * ```angular-ts 295 | * const adapter = new UpgradeAdapter(MyNg2Module); 296 | * const module = angular.module('myExample', []); 297 | * module.directive('ng2', adapter.downgradeNg2Component(Ng2)); 298 | * 299 | * module.directive('ng1', function() { 300 | * return { 301 | * scope: { title: '=' }, 302 | * template: 'ng1[Hello {{title}}!]()' 303 | * }; 304 | * }); 305 | * 306 | * 307 | * @Component({ 308 | * selector: 'ng2', 309 | * inputs: ['name'], 310 | * template: 'ng2[transclude]()' 311 | * }) 312 | * class Ng2 { 313 | * } 314 | * 315 | * @NgModule({ 316 | * declarations: [Ng2, adapter.upgradeNg1Component('ng1')], 317 | * imports: [BrowserModule] 318 | * }) 319 | * class MyNg2Module {} 320 | * 321 | * document.body.innerHTML = 'project'; 322 | * 323 | * adapter.bootstrap(document.body, ['myExample']).ready(function() { 324 | * expect(document.body.textContent).toEqual( 325 | * "ng2[ng1[Hello World!](transclude)](project)"); 326 | * }); 327 | * ``` 328 | */ 329 | bootstrap(element: Element, modules?: any[], config?: IAngularBootstrapConfig): UpgradeAdapterRef; 330 | /** 331 | * Allows AngularJS service to be accessible from Angular. 332 | * 333 | * @usageNotes 334 | * ### Example 335 | * 336 | * ```ts 337 | * class Login { ... } 338 | * class Server { ... } 339 | * 340 | * @Injectable() 341 | * class Example { 342 | * constructor(@Inject('server') server, login: Login) { 343 | * ... 344 | * } 345 | * } 346 | * 347 | * const module = angular.module('myExample', []); 348 | * module.service('server', Server); 349 | * module.service('login', Login); 350 | * 351 | * const adapter = new UpgradeAdapter(MyNg2Module); 352 | * adapter.upgradeNg1Provider('server'); 353 | * adapter.upgradeNg1Provider('login', {asToken: Login}); 354 | * 355 | * adapter.bootstrap(document.body, ['myExample']).ready((ref) => { 356 | * const example: Example = ref.ng2Injector.get(Example); 357 | * }); 358 | * 359 | * ``` 360 | */ 361 | upgradeNg1Provider(name: string, options?: { 362 | asToken: any; 363 | }): void; 364 | /** 365 | * Allows Angular service to be accessible from AngularJS. 366 | * 367 | * @usageNotes 368 | * ### Example 369 | * 370 | * ```ts 371 | * class Example { 372 | * } 373 | * 374 | * const adapter = new UpgradeAdapter(MyNg2Module); 375 | * 376 | * const module = angular.module('myExample', []); 377 | * module.factory('example', adapter.downgradeNg2Provider(Example)); 378 | * 379 | * adapter.bootstrap(document.body, ['myExample']).ready((ref) => { 380 | * const example: Example = ref.ng1Injector.get('example'); 381 | * }); 382 | * 383 | * ``` 384 | */ 385 | downgradeNg2Provider(token: any): Function; 386 | /** 387 | * Declare the AngularJS upgrade module for this adapter without bootstrapping the whole 388 | * hybrid application. 389 | * 390 | * This method is automatically called by `bootstrap()` and `registerForNg1Tests()`. 391 | * 392 | * @param modules The AngularJS modules that this upgrade module should depend upon. 393 | * @returns The AngularJS upgrade module that is declared by this method 394 | * 395 | * @usageNotes 396 | * ### Example 397 | * 398 | * ```ts 399 | * const upgradeAdapter = new UpgradeAdapter(MyNg2Module); 400 | * upgradeAdapter.declareNg1Module(['heroApp']); 401 | * ``` 402 | */ 403 | private declareNg1Module; 404 | } 405 | /** 406 | * Use `UpgradeAdapterRef` to control a hybrid AngularJS / Angular application. 407 | * 408 | * @deprecated Deprecated since v5. Use `upgrade/static` instead, which also supports 409 | * [Ahead-of-Time compilation](tools/cli/aot-compiler). 410 | * @publicApi 411 | */ 412 | declare class UpgradeAdapterRef { 413 | ng1RootScope: IRootScopeService; 414 | ng1Injector: IInjectorService; 415 | ng2ModuleRef: NgModuleRef; 416 | ng2Injector: Injector; 417 | /** 418 | * Register a callback function which is notified upon successful hybrid AngularJS / Angular 419 | * application has been bootstrapped. 420 | * 421 | * The `ready` callback function is invoked inside the Angular zone, therefore it does not 422 | * require a call to `$apply()`. 423 | */ 424 | ready(fn: (upgradeAdapterRef: UpgradeAdapterRef) => void): void; 425 | /** 426 | * Dispose of running hybrid AngularJS / Angular application. 427 | */ 428 | dispose(): void; 429 | } 430 | 431 | export { UpgradeAdapter, UpgradeAdapterRef }; 432 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@angular/upgrade", 3 | "version": "20.1.0-next.0+sha-21fc93b", 4 | "description": "Angular - the library for easing update from v1 to v2", 5 | "author": "angular", 6 | "license": "MIT", 7 | "engines": { 8 | "node": "^20.19.0 || ^22.12.0 || >=24.0.0" 9 | }, 10 | "dependencies": { 11 | "tslib": "^2.3.0" 12 | }, 13 | "peerDependencies": { 14 | "@angular/core": "20.1.0-next.0+sha-21fc93b", 15 | "@angular/compiler": "20.1.0-next.0+sha-21fc93b", 16 | "@angular/platform-browser": "20.1.0-next.0+sha-21fc93b", 17 | "@angular/platform-browser-dynamic": "20.1.0-next.0+sha-21fc93b" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/angular/angular.git", 22 | "directory": "packages/upgrade" 23 | }, 24 | "ng-update": { 25 | "packageGroup": [ 26 | "@angular/core", 27 | "@angular/bazel", 28 | "@angular/common", 29 | "@angular/compiler", 30 | "@angular/compiler-cli", 31 | "@angular/animations", 32 | "@angular/elements", 33 | "@angular/platform-browser", 34 | "@angular/platform-browser-dynamic", 35 | "@angular/forms", 36 | "@angular/platform-server", 37 | "@angular/upgrade", 38 | "@angular/router", 39 | "@angular/language-service", 40 | "@angular/localize", 41 | "@angular/service-worker" 42 | ] 43 | }, 44 | "sideEffects": false, 45 | "module": "./fesm2022/upgrade.mjs", 46 | "typings": "./index.d.ts", 47 | "type": "module", 48 | "exports": { 49 | "./package.json": { 50 | "default": "./package.json" 51 | }, 52 | ".": { 53 | "types": "./index.d.ts", 54 | "default": "./fesm2022/upgrade.mjs" 55 | }, 56 | "./static": { 57 | "types": "./static/index.d.ts", 58 | "default": "./fesm2022/static.mjs" 59 | }, 60 | "./static/testing": { 61 | "types": "./static/testing/index.d.ts", 62 | "default": "./fesm2022/static/testing.mjs" 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /static/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { IInjectorService, IAugmentedJQuery, IDirective, IController, IScope, ILinkFn, SingleOrListOrMap, INgModelController } from '../angular1.d-C3xPg7Lm.js'; 8 | export { VERSION, getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib, angular1_d as ɵangular1 } from '../angular1.d-C3xPg7Lm.js'; 9 | import * as i0 from '@angular/core'; 10 | import { Type, StaticProvider, NgModuleRef, NgModuleFactory, OnInit, OnChanges, DoCheck, OnDestroy, ElementRef, Injector, SimpleChanges, NgZone, PlatformRef } from '@angular/core'; 11 | 12 | /** 13 | * @description 14 | * 15 | * A helper function that allows an Angular component to be used from AngularJS. 16 | * 17 | * *Part of the [upgrade/static](api?query=upgrade%2Fstatic) 18 | * library for hybrid upgrade apps that support AOT compilation* 19 | * 20 | * This helper function returns a factory function to be used for registering 21 | * an AngularJS wrapper directive for "downgrading" an Angular component. 22 | * 23 | * @usageNotes 24 | * ### Examples 25 | * 26 | * Let's assume that you have an Angular component called `ng2Heroes` that needs 27 | * to be made available in AngularJS templates. 28 | * 29 | * {@example upgrade/static/ts/full/module.ts region="ng2-heroes"} 30 | * 31 | * We must create an AngularJS [directive](https://docs.angularjs.org/guide/directive) 32 | * that will make this Angular component available inside AngularJS templates. 33 | * The `downgradeComponent()` function returns a factory function that we 34 | * can use to define the AngularJS directive that wraps the "downgraded" component. 35 | * 36 | * {@example upgrade/static/ts/full/module.ts region="ng2-heroes-wrapper"} 37 | * 38 | * For more details and examples on downgrading Angular components to AngularJS components please 39 | * visit the [Upgrade guide](https://angular.io/guide/upgrade#using-angular-components-from-angularjs-code). 40 | * 41 | * @param info contains information about the Component that is being downgraded: 42 | * 43 | * - `component: Type`: The type of the Component that will be downgraded 44 | * - `downgradedModule?: string`: The name of the downgraded module (if any) that the component 45 | * "belongs to", as returned by a call to `downgradeModule()`. It is the module, whose 46 | * corresponding Angular module will be bootstrapped, when the component needs to be instantiated. 47 | *
48 | * (This option is only necessary when using `downgradeModule()` to downgrade more than one 49 | * Angular module.) 50 | * - `propagateDigest?: boolean`: Whether to perform {@link /api/core/ChangeDetectorRef#detectChanges detectChanges} on the 51 | * component on every {@link https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest $digest}. 52 | * If set to `false`, change detection will still be performed when any of the component's inputs changes. 53 | * (Default: true) 54 | * 55 | * @returns a factory function that can be used to register the component in an 56 | * AngularJS module. 57 | * 58 | * @publicApi 59 | */ 60 | declare function downgradeComponent(info: { 61 | component: Type; 62 | downgradedModule?: string; 63 | propagateDigest?: boolean; 64 | /** @deprecated since v4. This parameter is no longer used */ 65 | inputs?: string[]; 66 | /** @deprecated since v4. This parameter is no longer used */ 67 | outputs?: string[]; 68 | /** @deprecated since v4. This parameter is no longer used */ 69 | selectors?: string[]; 70 | }): any; 71 | 72 | /** 73 | * @description 74 | * 75 | * A helper function to allow an Angular service to be accessible from AngularJS. 76 | * 77 | * *Part of the [upgrade/static](api?query=upgrade%2Fstatic) 78 | * library for hybrid upgrade apps that support AOT compilation* 79 | * 80 | * This helper function returns a factory function that provides access to the Angular 81 | * service identified by the `token` parameter. 82 | * 83 | * @usageNotes 84 | * ### Examples 85 | * 86 | * First ensure that the service to be downgraded is provided in an `NgModule` 87 | * that will be part of the upgrade application. For example, let's assume we have 88 | * defined `HeroesService` 89 | * 90 | * {@example upgrade/static/ts/full/module.ts region="ng2-heroes-service"} 91 | * 92 | * and that we have included this in our upgrade app `NgModule` 93 | * 94 | * {@example upgrade/static/ts/full/module.ts region="ng2-module"} 95 | * 96 | * Now we can register the `downgradeInjectable` factory function for the service 97 | * on an AngularJS module. 98 | * 99 | * {@example upgrade/static/ts/full/module.ts region="downgrade-ng2-heroes-service"} 100 | * 101 | * Inside an AngularJS component's controller we can get hold of the 102 | * downgraded service via the name we gave when downgrading. 103 | * 104 | * {@example upgrade/static/ts/full/module.ts region="example-app"} 105 | * 106 | *
107 | * 108 | * When using `downgradeModule()`, downgraded injectables will not be available until the Angular 109 | * module that provides them is instantiated. In order to be safe, you need to ensure that the 110 | * downgraded injectables are not used anywhere _outside_ the part of the app where it is 111 | * guaranteed that their module has been instantiated. 112 | * 113 | * For example, it is _OK_ to use a downgraded service in an upgraded component that is only used 114 | * from a downgraded Angular component provided by the same Angular module as the injectable, but 115 | * it is _not OK_ to use it in an AngularJS component that may be used independently of Angular or 116 | * use it in a downgraded Angular component from a different module. 117 | * 118 | *
119 | * 120 | * @param token an `InjectionToken` that identifies a service provided from Angular. 121 | * @param downgradedModule the name of the downgraded module (if any) that the injectable 122 | * "belongs to", as returned by a call to `downgradeModule()`. It is the module, whose injector will 123 | * be used for instantiating the injectable.
124 | * (This option is only necessary when using `downgradeModule()` to downgrade more than one Angular 125 | * module.) 126 | * 127 | * @returns a [factory function](https://docs.angularjs.org/guide/di) that can be 128 | * used to register the service on an AngularJS module. 129 | * 130 | * @publicApi 131 | */ 132 | declare function downgradeInjectable(token: any, downgradedModule?: string): Function; 133 | 134 | /** 135 | * @description 136 | * 137 | * A helper function for creating an AngularJS module that can bootstrap an Angular module 138 | * "on-demand" (possibly lazily) when a {@link downgradeComponent downgraded component} needs to be 139 | * instantiated. 140 | * 141 | * *Part of the [upgrade/static](api?query=upgrade/static) library for hybrid upgrade apps that 142 | * support AOT compilation.* 143 | * 144 | * It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to 145 | * pay the cost up-front. For example, you can have an AngularJS application that uses Angular for 146 | * specific routes and only instantiate the Angular modules if/when the user visits one of these 147 | * routes. 148 | * 149 | * The Angular module will be bootstrapped once (when requested for the first time) and the same 150 | * reference will be used from that point onwards. 151 | * 152 | * `downgradeModule()` requires either an `NgModuleFactory`, `NgModule` class or a function: 153 | * - `NgModuleFactory`: If you pass an `NgModuleFactory`, it will be used to instantiate a module 154 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModuleFactory bootstrapModuleFactory()}. 155 | * NOTE: this type of the argument is deprecated. Please either provide an `NgModule` class or a 156 | * bootstrap function instead. 157 | * - `NgModule` class: If you pass an NgModule class, it will be used to instantiate a module 158 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModule bootstrapModule()}. 159 | * - `Function`: If you pass a function, it is expected to return a promise resolving to an 160 | * `NgModuleRef`. The function is called with an array of extra {@link StaticProvider Providers} 161 | * that are expected to be available from the returned `NgModuleRef`'s `Injector`. 162 | * 163 | * `downgradeModule()` returns the name of the created AngularJS wrapper module. You can use it to 164 | * declare a dependency in your main AngularJS module. 165 | * 166 | * {@example upgrade/static/ts/lite/module.ts region="basic-how-to"} 167 | * 168 | * For more details on how to use `downgradeModule()` see 169 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 170 | * 171 | * @usageNotes 172 | * 173 | * Apart from `UpgradeModule`, you can use the rest of the `upgrade/static` helpers as usual to 174 | * build a hybrid application. Note that the Angular pieces (e.g. downgraded services) will not be 175 | * available until the downgraded module has been bootstrapped, i.e. by instantiating a downgraded 176 | * component. 177 | * 178 | *
179 | * 180 | * You cannot use `downgradeModule()` and `UpgradeModule` in the same hybrid application.
181 | * Use one or the other. 182 | * 183 | *
184 | * 185 | * ### Differences with `UpgradeModule` 186 | * 187 | * Besides their different API, there are two important internal differences between 188 | * `downgradeModule()` and `UpgradeModule` that affect the behavior of hybrid applications: 189 | * 190 | * 1. Unlike `UpgradeModule`, `downgradeModule()` does not bootstrap the main AngularJS module 191 | * inside the {@link NgZone Angular zone}. 192 | * 2. Unlike `UpgradeModule`, `downgradeModule()` does not automatically run a 193 | * [$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) when changes are 194 | * detected in the Angular part of the application. 195 | * 196 | * What this means is that applications using `UpgradeModule` will run change detection more 197 | * frequently in order to ensure that both frameworks are properly notified about possible changes. 198 | * This will inevitably result in more change detection runs than necessary. 199 | * 200 | * `downgradeModule()`, on the other side, does not try to tie the two change detection systems as 201 | * tightly, restricting the explicit change detection runs only to cases where it knows it is 202 | * necessary (e.g. when the inputs of a downgraded component change). This improves performance, 203 | * especially in change-detection-heavy applications, but leaves it up to the developer to manually 204 | * notify each framework as needed. 205 | * 206 | * For a more detailed discussion of the differences and their implications, see 207 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 208 | * 209 | *
210 | * 211 | * You can manually trigger a change detection run in AngularJS using 212 | * [scope.$apply(...)](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$apply) or 213 | * [$rootScope.$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest). 214 | * 215 | * You can manually trigger a change detection run in Angular using {@link NgZone#run 216 | * ngZone.run(...)}. 217 | * 218 | *
219 | * 220 | * ### Downgrading multiple modules 221 | * 222 | * It is possible to downgrade multiple modules and include them in an AngularJS application. In 223 | * that case, each downgraded module will be bootstrapped when an associated downgraded component or 224 | * injectable needs to be instantiated. 225 | * 226 | * Things to keep in mind, when downgrading multiple modules: 227 | * 228 | * - Each downgraded component/injectable needs to be explicitly associated with a downgraded 229 | * module. See `downgradeComponent()` and `downgradeInjectable()` for more details. 230 | * 231 | * - If you want some injectables to be shared among all downgraded modules, you can provide them as 232 | * `StaticProvider`s, when creating the `PlatformRef` (e.g. via `platformBrowser` or 233 | * `platformBrowserDynamic`). 234 | * 235 | * - When using {@link PlatformRef#bootstrapmodule `bootstrapModule()`} or 236 | * {@link PlatformRef#bootstrapmodulefactory `bootstrapModuleFactory()`} to bootstrap the 237 | * downgraded modules, each one is considered a "root" module. As a consequence, a new instance 238 | * will be created for every injectable provided in `"root"` (via 239 | * {@link /api/core/Injectable#providedIn providedIn} 240 | * If this is not your intention, you can have a shared module (that will act as act as the "root" 241 | * module) and create all downgraded modules using that module's injector: 242 | * 243 | * {@example upgrade/static/ts/lite-multi-shared/module.ts region="shared-root-module"} 244 | * 245 | * @publicApi 246 | */ 247 | declare function downgradeModule(moduleOrBootstrapFn: Type | ((extraProviders: StaticProvider[]) => Promise>)): string; 248 | /** 249 | * @description 250 | * 251 | * A helper function for creating an AngularJS module that can bootstrap an Angular module 252 | * "on-demand" (possibly lazily) when a {@link downgradeComponent downgraded component} needs to be 253 | * instantiated. 254 | * 255 | * *Part of the [upgrade/static](api?query=upgrade/static) library for hybrid upgrade apps that 256 | * support AOT compilation.* 257 | * 258 | * It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to 259 | * pay the cost up-front. For example, you can have an AngularJS application that uses Angular for 260 | * specific routes and only instantiate the Angular modules if/when the user visits one of these 261 | * routes. 262 | * 263 | * The Angular module will be bootstrapped once (when requested for the first time) and the same 264 | * reference will be used from that point onwards. 265 | * 266 | * `downgradeModule()` requires either an `NgModuleFactory`, `NgModule` class or a function: 267 | * - `NgModuleFactory`: If you pass an `NgModuleFactory`, it will be used to instantiate a module 268 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModuleFactory bootstrapModuleFactory()}. 269 | * NOTE: this type of the argument is deprecated. Please either provide an `NgModule` class or a 270 | * bootstrap function instead. 271 | * - `NgModule` class: If you pass an NgModule class, it will be used to instantiate a module 272 | * using `platformBrowser`'s {@link PlatformRef#bootstrapModule bootstrapModule()}. 273 | * - `Function`: If you pass a function, it is expected to return a promise resolving to an 274 | * `NgModuleRef`. The function is called with an array of extra {@link StaticProvider Providers} 275 | * that are expected to be available from the returned `NgModuleRef`'s `Injector`. 276 | * 277 | * `downgradeModule()` returns the name of the created AngularJS wrapper module. You can use it to 278 | * declare a dependency in your main AngularJS module. 279 | * 280 | * {@example upgrade/static/ts/lite/module.ts region="basic-how-to"} 281 | * 282 | * For more details on how to use `downgradeModule()` see 283 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 284 | * 285 | * @usageNotes 286 | * 287 | * Apart from `UpgradeModule`, you can use the rest of the `upgrade/static` helpers as usual to 288 | * build a hybrid application. Note that the Angular pieces (e.g. downgraded services) will not be 289 | * available until the downgraded module has been bootstrapped, i.e. by instantiating a downgraded 290 | * component. 291 | * 292 | *
293 | * 294 | * You cannot use `downgradeModule()` and `UpgradeModule` in the same hybrid application.
295 | * Use one or the other. 296 | * 297 | *
298 | * 299 | * ### Differences with `UpgradeModule` 300 | * 301 | * Besides their different API, there are two important internal differences between 302 | * `downgradeModule()` and `UpgradeModule` that affect the behavior of hybrid applications: 303 | * 304 | * 1. Unlike `UpgradeModule`, `downgradeModule()` does not bootstrap the main AngularJS module 305 | * inside the {@link NgZone Angular zone}. 306 | * 2. Unlike `UpgradeModule`, `downgradeModule()` does not automatically run a 307 | * [$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest) when changes are 308 | * detected in the Angular part of the application. 309 | * 310 | * What this means is that applications using `UpgradeModule` will run change detection more 311 | * frequently in order to ensure that both frameworks are properly notified about possible changes. 312 | * This will inevitably result in more change detection runs than necessary. 313 | * 314 | * `downgradeModule()`, on the other side, does not try to tie the two change detection systems as 315 | * tightly, restricting the explicit change detection runs only to cases where it knows it is 316 | * necessary (e.g. when the inputs of a downgraded component change). This improves performance, 317 | * especially in change-detection-heavy applications, but leaves it up to the developer to manually 318 | * notify each framework as needed. 319 | * 320 | * For a more detailed discussion of the differences and their implications, see 321 | * [Upgrading for Performance](https://angular.io/guide/upgrade). 322 | * 323 | *
324 | * 325 | * You can manually trigger a change detection run in AngularJS using 326 | * [scope.$apply(...)](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$apply) or 327 | * [$rootScope.$digest()](https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest). 328 | * 329 | * You can manually trigger a change detection run in Angular using {@link NgZone#run 330 | * ngZone.run(...)}. 331 | * 332 | *
333 | * 334 | * ### Downgrading multiple modules 335 | * 336 | * It is possible to downgrade multiple modules and include them in an AngularJS application. In 337 | * that case, each downgraded module will be bootstrapped when an associated downgraded component or 338 | * injectable needs to be instantiated. 339 | * 340 | * Things to keep in mind, when downgrading multiple modules: 341 | * 342 | * - Each downgraded component/injectable needs to be explicitly associated with a downgraded 343 | * module. See `downgradeComponent()` and `downgradeInjectable()` for more details. 344 | * 345 | * - If you want some injectables to be shared among all downgraded modules, you can provide them as 346 | * `StaticProvider`s, when creating the `PlatformRef` (e.g. via `platformBrowser` or 347 | * `platformBrowserDynamic`). 348 | * 349 | * - When using {@link PlatformRef#bootstrapmodule `bootstrapModule()`} or 350 | * {@link PlatformRef#bootstrapmodulefactory `bootstrapModuleFactory()`} to bootstrap the 351 | * downgraded modules, each one is considered a "root" module. As a consequence, a new instance 352 | * will be created for every injectable provided in `"root"` (via 353 | * {@link /api/core/Injectable#providedIn providedIn} 354 | * If this is not your intention, you can have a shared module (that will act as act as the "root" 355 | * module) and create all downgraded modules using that module's injector: 356 | * 357 | * {@example upgrade/static/ts/lite-multi-shared/module.ts region="shared-root-module"} 358 | * 359 | * @publicApi 360 | * 361 | * @deprecated Passing `NgModuleFactory` as the `downgradeModule` function argument is deprecated, 362 | * please pass an NgModule class reference instead. 363 | */ 364 | declare function downgradeModule(moduleOrBootstrapFn: NgModuleFactory): string; 365 | 366 | /** 367 | * @description 368 | * 369 | * A helper class that allows an AngularJS component to be used from Angular. 370 | * 371 | * *Part of the [upgrade/static](api?query=upgrade%2Fstatic) 372 | * library for hybrid upgrade apps that support AOT compilation.* 373 | * 374 | * This helper class should be used as a base class for creating Angular directives 375 | * that wrap AngularJS components that need to be "upgraded". 376 | * 377 | * @usageNotes 378 | * ### Examples 379 | * 380 | * Let's assume that you have an AngularJS component called `ng1Hero` that needs 381 | * to be made available in Angular templates. 382 | * 383 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero"} 384 | * 385 | * We must create a `Directive` that will make this AngularJS component 386 | * available inside Angular templates. 387 | * 388 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero-wrapper"} 389 | * 390 | * In this example you can see that we must derive from the `UpgradeComponent` 391 | * base class but also provide an {@link Directive `@Directive`} decorator. This is 392 | * because the AOT compiler requires that this information is statically available at 393 | * compile time. 394 | * 395 | * Note that we must do the following: 396 | * * specify the directive's selector (`ng1-hero`) 397 | * * specify all inputs and outputs that the AngularJS component expects 398 | * * derive from `UpgradeComponent` 399 | * * call the base class from the constructor, passing 400 | * * the AngularJS name of the component (`ng1Hero`) 401 | * * the `ElementRef` and `Injector` for the component wrapper 402 | * 403 | * @publicApi 404 | * @extensible 405 | */ 406 | declare class UpgradeComponent implements OnInit, OnChanges, DoCheck, OnDestroy { 407 | private helper; 408 | private $element; 409 | private $componentScope; 410 | private directive; 411 | private bindings; 412 | private controllerInstance?; 413 | private bindingDestination?; 414 | private pendingChanges; 415 | private unregisterDoCheckWatcher?; 416 | /** 417 | * Create a new `UpgradeComponent` instance. You should not normally need to do this. 418 | * Instead you should derive a new class from this one and call the super constructor 419 | * from the base class. 420 | * 421 | * {@example upgrade/static/ts/full/module.ts region="ng1-hero-wrapper" } 422 | * 423 | * * The `name` parameter should be the name of the AngularJS directive. 424 | * * The `elementRef` and `injector` parameters should be acquired from Angular by dependency 425 | * injection into the base class constructor. 426 | */ 427 | constructor(name: string, elementRef: ElementRef, injector: Injector); 428 | /** @docs-private */ 429 | ngOnInit(): void; 430 | /** @docs-private */ 431 | ngOnChanges(changes: SimpleChanges): void; 432 | /** @docs-private */ 433 | ngDoCheck(): void; 434 | /** @docs-private */ 435 | ngOnDestroy(): void; 436 | private initializeBindings; 437 | private initializeOutputs; 438 | private bindOutputs; 439 | private forwardChanges; 440 | static ɵfac: i0.ɵɵFactoryDeclaration; 441 | static ɵdir: i0.ɵɵDirectiveDeclaration; 442 | } 443 | 444 | /** 445 | * @description 446 | * 447 | * An `NgModule`, which you import to provide AngularJS core services, 448 | * and has an instance method used to bootstrap the hybrid upgrade application. 449 | * 450 | * *Part of the [upgrade/static](api?query=upgrade/static) 451 | * library for hybrid upgrade apps that support AOT compilation* 452 | * 453 | * The `upgrade/static` package contains helpers that allow AngularJS and Angular components 454 | * to be used together inside a hybrid upgrade application, which supports AOT compilation. 455 | * 456 | * Specifically, the classes and functions in the `upgrade/static` module allow the following: 457 | * 458 | * 1. Creation of an Angular directive that wraps and exposes an AngularJS component so 459 | * that it can be used in an Angular template. See `UpgradeComponent`. 460 | * 2. Creation of an AngularJS directive that wraps and exposes an Angular component so 461 | * that it can be used in an AngularJS template. See `downgradeComponent`. 462 | * 3. Creation of an Angular root injector provider that wraps and exposes an AngularJS 463 | * service so that it can be injected into an Angular context. See 464 | * {@link UpgradeModule#upgrading-an-angular-1-service Upgrading an AngularJS service} below. 465 | * 4. Creation of an AngularJS service that wraps and exposes an Angular injectable 466 | * so that it can be injected into an AngularJS context. See `downgradeInjectable`. 467 | * 5. Bootstrapping of a hybrid Angular application which contains both of the frameworks 468 | * coexisting in a single application. 469 | * 470 | * @usageNotes 471 | * 472 | * ```ts 473 | * import {UpgradeModule} from '@angular/upgrade/static'; 474 | * ``` 475 | * 476 | * See also the {@link UpgradeModule#examples examples} below. 477 | * 478 | * ### Mental Model 479 | * 480 | * When reasoning about how a hybrid application works it is useful to have a mental model which 481 | * describes what is happening and explains what is happening at the lowest level. 482 | * 483 | * 1. There are two independent frameworks running in a single application, each framework treats 484 | * the other as a black box. 485 | * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework 486 | * instantiated the element is the owner. Each framework only updates/interacts with its own 487 | * DOM elements and ignores others. 488 | * 3. AngularJS directives always execute inside the AngularJS framework codebase regardless of 489 | * where they are instantiated. 490 | * 4. Angular components always execute inside the Angular framework codebase regardless of 491 | * where they are instantiated. 492 | * 5. An AngularJS component can be "upgraded"" to an Angular component. This is achieved by 493 | * defining an Angular directive, which bootstraps the AngularJS component at its location 494 | * in the DOM. See `UpgradeComponent`. 495 | * 6. An Angular component can be "downgraded" to an AngularJS component. This is achieved by 496 | * defining an AngularJS directive, which bootstraps the Angular component at its location 497 | * in the DOM. See `downgradeComponent`. 498 | * 7. Whenever an "upgraded"/"downgraded" component is instantiated the host element is owned by 499 | * the framework doing the instantiation. The other framework then instantiates and owns the 500 | * view for that component. 501 | * 1. This implies that the component bindings will always follow the semantics of the 502 | * instantiation framework. 503 | * 2. The DOM attributes are parsed by the framework that owns the current template. So 504 | * attributes in AngularJS templates must use kebab-case, while AngularJS templates must use 505 | * camelCase. 506 | * 3. However the template binding syntax will always use the Angular style, e.g. square 507 | * brackets (`[...]`) for property binding. 508 | * 8. Angular is bootstrapped first; AngularJS is bootstrapped second. AngularJS always owns the 509 | * root component of the application. 510 | * 9. The new application is running in an Angular zone, and therefore it no longer needs calls to 511 | * `$apply()`. 512 | * 513 | * ### The `UpgradeModule` class 514 | * 515 | * This class is an `NgModule`, which you import to provide AngularJS core services, 516 | * and has an instance method used to bootstrap the hybrid upgrade application. 517 | * 518 | * * Core AngularJS services
519 | * Importing this `NgModule` will add providers for the core 520 | * [AngularJS services](https://docs.angularjs.org/api/ng/service) to the root injector. 521 | * 522 | * * Bootstrap
523 | * The runtime instance of this class contains a {@link UpgradeModule#bootstrap `bootstrap()`} 524 | * method, which you use to bootstrap the top level AngularJS module onto an element in the 525 | * DOM for the hybrid upgrade app. 526 | * 527 | * It also contains properties to access the {@link UpgradeModule#injector root injector}, the 528 | * bootstrap `NgZone` and the 529 | * [AngularJS $injector](https://docs.angularjs.org/api/auto/service/$injector). 530 | * 531 | * ### Examples 532 | * 533 | * Import the `UpgradeModule` into your top level Angular {@link NgModule NgModule}. 534 | * 535 | * {@example upgrade/static/ts/full/module.ts region='ng2-module'} 536 | * 537 | * Then inject `UpgradeModule` into your Angular `NgModule` and use it to bootstrap the top level 538 | * [AngularJS module](https://docs.angularjs.org/api/ng/type/angular.Module) in the 539 | * `ngDoBootstrap()` method. 540 | * 541 | * {@example upgrade/static/ts/full/module.ts region='bootstrap-ng1'} 542 | * 543 | * Finally, kick off the whole process, by bootstrapping your top level Angular `NgModule`. 544 | * 545 | * {@example upgrade/static/ts/full/module.ts region='bootstrap-ng2'} 546 | * 547 | * ### Upgrading an AngularJS service 548 | * 549 | * There is no specific API for upgrading an AngularJS service. Instead you should just follow the 550 | * following recipe: 551 | * 552 | * Let's say you have an AngularJS service: 553 | * 554 | * {@example upgrade/static/ts/full/module.ts region="ng1-text-formatter-service"} 555 | * 556 | * Then you should define an Angular provider to be included in your `NgModule` `providers` 557 | * property. 558 | * 559 | * {@example upgrade/static/ts/full/module.ts region="upgrade-ng1-service"} 560 | * 561 | * Then you can use the "upgraded" AngularJS service by injecting it into an Angular component 562 | * or service. 563 | * 564 | * {@example upgrade/static/ts/full/module.ts region="use-ng1-upgraded-service"} 565 | * 566 | * @publicApi 567 | */ 568 | declare class UpgradeModule { 569 | /** The bootstrap zone for the upgrade application */ 570 | ngZone: NgZone; 571 | /** 572 | * The owning `NgModuleRef`s `PlatformRef` instance. 573 | * This is used to tie the lifecycle of the bootstrapped AngularJS apps to that of the Angular 574 | * `PlatformRef`. 575 | */ 576 | private platformRef; 577 | /** 578 | * The AngularJS `$injector` for the upgrade application. 579 | */ 580 | $injector: any; 581 | /** The Angular Injector **/ 582 | injector: Injector; 583 | constructor( 584 | /** The root `Injector` for the upgrade application. */ 585 | injector: Injector, 586 | /** The bootstrap zone for the upgrade application */ 587 | ngZone: NgZone, 588 | /** 589 | * The owning `NgModuleRef`s `PlatformRef` instance. 590 | * This is used to tie the lifecycle of the bootstrapped AngularJS apps to that of the Angular 591 | * `PlatformRef`. 592 | */ 593 | platformRef: PlatformRef); 594 | /** 595 | * Bootstrap an AngularJS application from this NgModule 596 | * @param element the element on which to bootstrap the AngularJS application 597 | * @param [modules] the AngularJS modules to bootstrap for this application 598 | * @param [config] optional extra AngularJS bootstrap configuration 599 | * @return The value returned by 600 | * [angular.bootstrap()](https://docs.angularjs.org/api/ng/function/angular.bootstrap). 601 | */ 602 | bootstrap(element: Element, modules?: string[], config?: any): any; 603 | static ɵfac: i0.ɵɵFactoryDeclaration; 604 | static ɵmod: i0.ɵɵNgModuleDeclaration; 605 | static ɵinj: i0.ɵɵInjectorDeclaration; 606 | } 607 | 608 | declare const $COMPILE = "$compile"; 609 | declare const $CONTROLLER = "$controller"; 610 | declare const $DELEGATE = "$delegate"; 611 | declare const $EXCEPTION_HANDLER = "$exceptionHandler"; 612 | declare const $HTTP_BACKEND = "$httpBackend"; 613 | declare const $INJECTOR = "$injector"; 614 | declare const $INTERVAL = "$interval"; 615 | declare const $PARSE = "$parse"; 616 | declare const $PROVIDE = "$provide"; 617 | declare const $ROOT_ELEMENT = "$rootElement"; 618 | declare const $ROOT_SCOPE = "$rootScope"; 619 | declare const $SCOPE = "$scope"; 620 | declare const $TEMPLATE_CACHE = "$templateCache"; 621 | declare const $TEMPLATE_REQUEST = "$templateRequest"; 622 | declare const $$TESTABILITY = "$$testability"; 623 | declare const COMPILER_KEY = "$$angularCompiler"; 624 | declare const DOWNGRADED_MODULE_COUNT_KEY = "$$angularDowngradedModuleCount"; 625 | declare const GROUP_PROJECTABLE_NODES_KEY = "$$angularGroupProjectableNodes"; 626 | declare const INJECTOR_KEY = "$$angularInjector"; 627 | declare const LAZY_MODULE_REF = "$$angularLazyModuleRef"; 628 | declare const NG_ZONE_KEY = "$$angularNgZone"; 629 | declare const UPGRADE_APP_TYPE_KEY = "$$angularUpgradeAppType"; 630 | declare const REQUIRE_INJECTOR: string; 631 | declare const REQUIRE_NG_MODEL = "?ngModel"; 632 | declare const UPGRADE_MODULE_NAME = "$$UpgradeModule"; 633 | 634 | declare const constants_d_$$TESTABILITY: typeof $$TESTABILITY; 635 | declare const constants_d_$COMPILE: typeof $COMPILE; 636 | declare const constants_d_$CONTROLLER: typeof $CONTROLLER; 637 | declare const constants_d_$DELEGATE: typeof $DELEGATE; 638 | declare const constants_d_$EXCEPTION_HANDLER: typeof $EXCEPTION_HANDLER; 639 | declare const constants_d_$HTTP_BACKEND: typeof $HTTP_BACKEND; 640 | declare const constants_d_$INJECTOR: typeof $INJECTOR; 641 | declare const constants_d_$INTERVAL: typeof $INTERVAL; 642 | declare const constants_d_$PARSE: typeof $PARSE; 643 | declare const constants_d_$PROVIDE: typeof $PROVIDE; 644 | declare const constants_d_$ROOT_ELEMENT: typeof $ROOT_ELEMENT; 645 | declare const constants_d_$ROOT_SCOPE: typeof $ROOT_SCOPE; 646 | declare const constants_d_$SCOPE: typeof $SCOPE; 647 | declare const constants_d_$TEMPLATE_CACHE: typeof $TEMPLATE_CACHE; 648 | declare const constants_d_$TEMPLATE_REQUEST: typeof $TEMPLATE_REQUEST; 649 | declare const constants_d_COMPILER_KEY: typeof COMPILER_KEY; 650 | declare const constants_d_DOWNGRADED_MODULE_COUNT_KEY: typeof DOWNGRADED_MODULE_COUNT_KEY; 651 | declare const constants_d_GROUP_PROJECTABLE_NODES_KEY: typeof GROUP_PROJECTABLE_NODES_KEY; 652 | declare const constants_d_INJECTOR_KEY: typeof INJECTOR_KEY; 653 | declare const constants_d_LAZY_MODULE_REF: typeof LAZY_MODULE_REF; 654 | declare const constants_d_NG_ZONE_KEY: typeof NG_ZONE_KEY; 655 | declare const constants_d_REQUIRE_INJECTOR: typeof REQUIRE_INJECTOR; 656 | declare const constants_d_REQUIRE_NG_MODEL: typeof REQUIRE_NG_MODEL; 657 | declare const constants_d_UPGRADE_APP_TYPE_KEY: typeof UPGRADE_APP_TYPE_KEY; 658 | declare const constants_d_UPGRADE_MODULE_NAME: typeof UPGRADE_MODULE_NAME; 659 | declare namespace constants_d { 660 | export { 661 | constants_d_$$TESTABILITY as $$TESTABILITY, 662 | constants_d_$COMPILE as $COMPILE, 663 | constants_d_$CONTROLLER as $CONTROLLER, 664 | constants_d_$DELEGATE as $DELEGATE, 665 | constants_d_$EXCEPTION_HANDLER as $EXCEPTION_HANDLER, 666 | constants_d_$HTTP_BACKEND as $HTTP_BACKEND, 667 | constants_d_$INJECTOR as $INJECTOR, 668 | constants_d_$INTERVAL as $INTERVAL, 669 | constants_d_$PARSE as $PARSE, 670 | constants_d_$PROVIDE as $PROVIDE, 671 | constants_d_$ROOT_ELEMENT as $ROOT_ELEMENT, 672 | constants_d_$ROOT_SCOPE as $ROOT_SCOPE, 673 | constants_d_$SCOPE as $SCOPE, 674 | constants_d_$TEMPLATE_CACHE as $TEMPLATE_CACHE, 675 | constants_d_$TEMPLATE_REQUEST as $TEMPLATE_REQUEST, 676 | constants_d_COMPILER_KEY as COMPILER_KEY, 677 | constants_d_DOWNGRADED_MODULE_COUNT_KEY as DOWNGRADED_MODULE_COUNT_KEY, 678 | constants_d_GROUP_PROJECTABLE_NODES_KEY as GROUP_PROJECTABLE_NODES_KEY, 679 | constants_d_INJECTOR_KEY as INJECTOR_KEY, 680 | constants_d_LAZY_MODULE_REF as LAZY_MODULE_REF, 681 | constants_d_NG_ZONE_KEY as NG_ZONE_KEY, 682 | constants_d_REQUIRE_INJECTOR as REQUIRE_INJECTOR, 683 | constants_d_REQUIRE_NG_MODEL as REQUIRE_NG_MODEL, 684 | constants_d_UPGRADE_APP_TYPE_KEY as UPGRADE_APP_TYPE_KEY, 685 | constants_d_UPGRADE_MODULE_NAME as UPGRADE_MODULE_NAME, 686 | }; 687 | } 688 | 689 | /** 690 | * @fileoverview 691 | * While Angular only uses Trusted Types internally for the time being, 692 | * references to Trusted Types could leak into our public API, which would force 693 | * anyone compiling against @angular/upgrade to provide the @types/trusted-types 694 | * package in their compilation unit. 695 | * 696 | * Until https://github.com/microsoft/TypeScript/issues/30024 is resolved, we 697 | * will keep Angular's public API surface free of references to Trusted Types. 698 | * For internal and semi-private APIs that need to reference Trusted Types, the 699 | * minimal type definitions for the Trusted Types API provided by this module 700 | * should be used instead. They are marked as "declare" to prevent them from 701 | * being renamed by compiler optimization. 702 | * 703 | * Adapted from 704 | * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/trusted-types/index.d.ts 705 | * but restricted to the API surface used within Angular, mimicking the approach 706 | * in packages/core/src/util/security/trusted_type_defs.ts. 707 | */ 708 | type TrustedHTML = string & { 709 | __brand__: 'TrustedHTML'; 710 | }; 711 | 712 | interface IBindingDestination { 713 | [key: string]: any; 714 | $onChanges?: (changes: SimpleChanges) => void; 715 | } 716 | interface IControllerInstance extends IBindingDestination { 717 | $doCheck?: () => void; 718 | $onDestroy?: () => void; 719 | $onInit?: () => void; 720 | $postLink?: () => void; 721 | } 722 | declare class UpgradeHelper { 723 | private name; 724 | readonly $injector: IInjectorService; 725 | readonly element: Element; 726 | readonly $element: IAugmentedJQuery; 727 | readonly directive: IDirective; 728 | private readonly $compile; 729 | private readonly $controller; 730 | constructor(injector: Injector, name: string, elementRef: ElementRef, directive?: IDirective); 731 | static getDirective($injector: IInjectorService, name: string): IDirective; 732 | static getTemplate($injector: IInjectorService, directive: IDirective, fetchRemoteTemplate?: boolean, $element?: IAugmentedJQuery): string | TrustedHTML | Promise; 733 | buildController(controllerType: IController, $scope: IScope): any; 734 | compileTemplate(template?: string | TrustedHTML): ILinkFn; 735 | onDestroy($scope: IScope, controllerInstance?: any): void; 736 | prepareTransclusion(): ILinkFn | undefined; 737 | resolveAndBindRequiredControllers(controllerInstance: IControllerInstance | null): SingleOrListOrMap | null; 738 | private compileHtml; 739 | private extractChildNodes; 740 | private getDirectiveRequire; 741 | private resolveRequire; 742 | } 743 | 744 | type upgrade_helper_d_IBindingDestination = IBindingDestination; 745 | type upgrade_helper_d_IControllerInstance = IControllerInstance; 746 | type upgrade_helper_d_UpgradeHelper = UpgradeHelper; 747 | declare const upgrade_helper_d_UpgradeHelper: typeof UpgradeHelper; 748 | declare namespace upgrade_helper_d { 749 | export { upgrade_helper_d_UpgradeHelper as UpgradeHelper }; 750 | export type { upgrade_helper_d_IBindingDestination as IBindingDestination, upgrade_helper_d_IControllerInstance as IControllerInstance }; 751 | } 752 | 753 | declare function onError(e: any): void; 754 | /** 755 | * Clean the jqLite/jQuery data on the element and all its descendants. 756 | * Equivalent to how jqLite/jQuery invoke `cleanData()` on an Element when removed: 757 | * https://github.com/angular/angular.js/blob/2e72ea13fa98bebf6ed4b5e3c45eaf5f990ed16f/src/jqLite.js#L349-L355 758 | * https://github.com/jquery/jquery/blob/6984d1747623dbc5e87fd6c261a5b6b1628c107c/src/manipulation.js#L182 759 | * 760 | * NOTE: 761 | * `cleanData()` will also invoke the AngularJS `$destroy` DOM event on the element: 762 | * https://github.com/angular/angular.js/blob/2e72ea13fa98bebf6ed4b5e3c45eaf5f990ed16f/src/Angular.js#L1932-L1945 763 | * 764 | * @param node The DOM node whose data needs to be cleaned. 765 | */ 766 | declare function cleanData(node: Node): void; 767 | declare function controllerKey(name: string): string; 768 | /** 769 | * Destroy an AngularJS app given the app `$injector`. 770 | * 771 | * NOTE: Destroying an app is not officially supported by AngularJS, but try to do our best by 772 | * destroying `$rootScope` and clean the jqLite/jQuery data on `$rootElement` and all 773 | * descendants. 774 | * 775 | * @param $injector The `$injector` of the AngularJS app to destroy. 776 | */ 777 | declare function destroyApp($injector: IInjectorService): void; 778 | declare function directiveNormalize(name: string): string; 779 | declare function getTypeName(type: Type): string; 780 | declare function getDowngradedModuleCount($injector: IInjectorService): number; 781 | declare function getUpgradeAppType($injector: IInjectorService): UpgradeAppType; 782 | declare function isFunction(value: any): value is Function; 783 | declare function isNgModuleType(value: any): value is Type; 784 | declare function validateInjectionKey($injector: IInjectorService, downgradedModule: string, injectionKey: string, attemptedAction: string): void; 785 | declare class Deferred { 786 | promise: Promise; 787 | resolve: (value: R | PromiseLike) => void; 788 | reject: (error?: any) => void; 789 | constructor(); 790 | } 791 | interface LazyModuleRef { 792 | injector?: Injector; 793 | promise?: Promise; 794 | } 795 | declare const enum UpgradeAppType { 796 | None = 0, 797 | Dynamic = 1, 798 | Static = 2, 799 | Lite = 3 800 | } 801 | /** 802 | * Glue the AngularJS `NgModelController` (if it exists) to the component 803 | * (if it implements the needed subset of the `ControlValueAccessor` interface). 804 | */ 805 | declare function hookupNgModel(ngModel: INgModelController, component: any): void; 806 | /** 807 | * Test two values for strict equality, accounting for the fact that `NaN !== NaN`. 808 | */ 809 | declare function strictEquals(val1: any, val2: any): boolean; 810 | 811 | type util_d_Deferred = Deferred; 812 | declare const util_d_Deferred: typeof Deferred; 813 | type util_d_LazyModuleRef = LazyModuleRef; 814 | type util_d_UpgradeAppType = UpgradeAppType; 815 | declare const util_d_UpgradeAppType: typeof UpgradeAppType; 816 | declare const util_d_cleanData: typeof cleanData; 817 | declare const util_d_controllerKey: typeof controllerKey; 818 | declare const util_d_destroyApp: typeof destroyApp; 819 | declare const util_d_directiveNormalize: typeof directiveNormalize; 820 | declare const util_d_getDowngradedModuleCount: typeof getDowngradedModuleCount; 821 | declare const util_d_getTypeName: typeof getTypeName; 822 | declare const util_d_getUpgradeAppType: typeof getUpgradeAppType; 823 | declare const util_d_hookupNgModel: typeof hookupNgModel; 824 | declare const util_d_isFunction: typeof isFunction; 825 | declare const util_d_isNgModuleType: typeof isNgModuleType; 826 | declare const util_d_onError: typeof onError; 827 | declare const util_d_strictEquals: typeof strictEquals; 828 | declare const util_d_validateInjectionKey: typeof validateInjectionKey; 829 | declare namespace util_d { 830 | export { util_d_Deferred as Deferred, util_d_UpgradeAppType as UpgradeAppType, util_d_cleanData as cleanData, util_d_controllerKey as controllerKey, util_d_destroyApp as destroyApp, util_d_directiveNormalize as directiveNormalize, util_d_getDowngradedModuleCount as getDowngradedModuleCount, util_d_getTypeName as getTypeName, util_d_getUpgradeAppType as getUpgradeAppType, util_d_hookupNgModel as hookupNgModel, util_d_isFunction as isFunction, util_d_isNgModuleType as isNgModuleType, util_d_onError as onError, util_d_strictEquals as strictEquals, util_d_validateInjectionKey as validateInjectionKey }; 831 | export type { util_d_LazyModuleRef as LazyModuleRef }; 832 | } 833 | 834 | export { UpgradeComponent, UpgradeModule, downgradeComponent, downgradeInjectable, downgradeModule, constants_d as ɵconstants, upgrade_helper_d as ɵupgradeHelper, util_d as ɵutil }; 835 | -------------------------------------------------------------------------------- /static/testing/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Angular v20.1.0-next.0+sha-21fc93b 3 | * (c) 2010-2025 Google LLC. https://angular.io/ 4 | * License: MIT 5 | */ 6 | 7 | import { Type } from '@angular/core'; 8 | 9 | /** 10 | * A helper function to use when unit testing Angular services that depend upon upgraded AngularJS 11 | * services. 12 | * 13 | * This function returns an `NgModule` decorated class that is configured to wire up the Angular 14 | * and AngularJS injectors without the need to actually bootstrap a hybrid application. 15 | * This makes it simpler and faster to unit test services. 16 | * 17 | * Use the returned class as an "import" when configuring the `TestBed`. 18 | * 19 | * In the following code snippet, we are configuring the TestBed with two imports. 20 | * The `Ng2AppModule` is the Angular part of our hybrid application and the `ng1AppModule` is the 21 | * AngularJS part. 22 | * 23 | * {@example upgrade/static/ts/full/module.spec.ts region='angular-setup'} 24 | * 25 | * Once this is done we can get hold of services via the Angular `Injector` as normal. 26 | * Services that are (or have dependencies on) an upgraded AngularJS service, will be instantiated 27 | * as needed by the AngularJS `$injector`. 28 | * 29 | * In the following code snippet, `HeroesService` is an Angular service that depends upon an 30 | * AngularJS service, `titleCase`. 31 | * 32 | * {@example upgrade/static/ts/full/module.spec.ts region='angular-spec'} 33 | * 34 | *
35 | * 36 | * This helper is for testing services not Components. 37 | * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or 38 | * `downgradeModule` for more information. 39 | * 40 | *
41 | * 42 | *
43 | * 44 | * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the 45 | * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger 46 | * AngularJS handlers of async events from Angular. 47 | * 48 | *
49 | * 50 | *
51 | * 52 | * The helper sets up global variables to hold the shared Angular and AngularJS injectors. 53 | * 54 | * * Only call this helper once per spec. 55 | * * Do not use `createAngularTestingModule` in the same spec as `createAngularJSTestingModule`. 56 | * 57 | *
58 | * 59 | * Here is the example application and its unit tests that use `createAngularTestingModule` 60 | * and `createAngularJSTestingModule`. 61 | * 62 | * 63 | * 64 | * 65 | * 66 | * 67 | * 68 | * @param angularJSModules a collection of the names of AngularJS modules to include in the 69 | * configuration. 70 | * @param [strictDi] whether the AngularJS injector should have `strictDI` enabled. 71 | * 72 | * @publicApi 73 | */ 74 | declare function createAngularTestingModule(angularJSModules: string[], strictDi?: boolean): Type; 75 | 76 | /** 77 | * A helper function to use when unit testing AngularJS services that depend upon downgraded Angular 78 | * services. 79 | * 80 | * This function returns an AngularJS module that is configured to wire up the AngularJS and Angular 81 | * injectors without the need to actually bootstrap a hybrid application. 82 | * This makes it simpler and faster to unit test services. 83 | * 84 | * Use the returned AngularJS module in a call to 85 | * [`angular.mocks.module`](https://docs.angularjs.org/api/ngMock/function/angular.mock.module) to 86 | * include this module in the unit test injector. 87 | * 88 | * In the following code snippet, we are configuring the `$injector` with two modules: 89 | * The AngularJS `ng1AppModule`, which is the AngularJS part of our hybrid application and the 90 | * `Ng2AppModule`, which is the Angular part. 91 | * 92 | * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-setup'} 93 | * 94 | * Once this is done we can get hold of services via the AngularJS `$injector` as normal. 95 | * Services that are (or have dependencies on) a downgraded Angular service, will be instantiated as 96 | * needed by the Angular root `Injector`. 97 | * 98 | * In the following code snippet, `heroesService` is a downgraded Angular service that we are 99 | * accessing from AngularJS. 100 | * 101 | * {@example upgrade/static/ts/full/module.spec.ts region='angularjs-spec'} 102 | * 103 | *
104 | * 105 | * This helper is for testing services not components. 106 | * For Component testing you must still bootstrap a hybrid app. See `UpgradeModule` or 107 | * `downgradeModule` for more information. 108 | * 109 | *
110 | * 111 | *
112 | * 113 | * The resulting configuration does not wire up AngularJS digests to Zone hooks. It is the 114 | * responsibility of the test writer to call `$rootScope.$apply`, as necessary, to trigger 115 | * AngularJS handlers of async events from Angular. 116 | * 117 | *
118 | * 119 | *
120 | * 121 | * The helper sets up global variables to hold the shared Angular and AngularJS injectors. 122 | * 123 | * * Only call this helper once per spec. 124 | * * Do not use `createAngularJSTestingModule` in the same spec as `createAngularTestingModule`. 125 | * 126 | *
127 | * 128 | * Here is the example application and its unit tests that use `createAngularTestingModule` 129 | * and `createAngularJSTestingModule`. 130 | * 131 | * 132 | * 133 | * 134 | * 135 | * 136 | * 137 | * @param angularModules a collection of Angular modules to include in the configuration. 138 | * 139 | * @publicApi 140 | */ 141 | declare function createAngularJSTestingModule(angularModules: any[]): string; 142 | 143 | export { createAngularJSTestingModule, createAngularTestingModule }; 144 | --------------------------------------------------------------------------------