|
9 | 9 | import {Type} from '../interface/type'; |
10 | 10 | import {assertDefined} from '../util/assert'; |
11 | 11 | import {assertLView} from './assert'; |
12 | | -import {ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefineNgModule, ɵɵdefinePipe} from './definition'; |
13 | 12 | import {getComponentDef} from './def_getters'; |
14 | 13 | import {assertComponentDef} from './errors'; |
15 | 14 | import {refreshView} from './instructions/change_detection'; |
@@ -42,74 +41,29 @@ import { |
42 | 41 | import {assertTNodeType} from './node_assert'; |
43 | 42 | import {destroyLView, removeViewFromDOM} from './node_manipulation'; |
44 | 43 |
|
45 | | -import * as iframe_attrs_validation from '../sanitization/iframe_attrs_validation'; |
46 | | -import * as sanitization from '../sanitization/sanitization'; |
47 | | -import * as r3 from './instructions/all'; |
48 | | -import { |
49 | | - ɵɵdefineInjectable, |
50 | | - ɵɵdefineInjector, |
51 | | - ɵɵinject, |
52 | | - ɵɵinvalidFactoryDep, |
53 | | - forwardRef, |
54 | | - resolveForwardRef, |
55 | | -} from '../di'; |
56 | | -import {registerNgModuleType} from '../linker/ng_module_registration'; |
57 | | -import {ɵɵgetInheritedFactory} from './di'; |
58 | | -import {ɵɵgetComponentDepsFactory} from './local_compilation'; |
59 | | -import {ɵɵpipeBind1, ɵɵpipeBind2, ɵɵpipeBind3, ɵɵpipeBind4, ɵɵpipeBindV, ɵɵpipe} from './pipe'; |
60 | | -import { |
61 | | - ɵɵpureFunction0, |
62 | | - ɵɵpureFunction1, |
63 | | - ɵɵpureFunction2, |
64 | | - ɵɵpureFunction3, |
65 | | - ɵɵpureFunction4, |
66 | | - ɵɵpureFunction5, |
67 | | - ɵɵpureFunction6, |
68 | | - ɵɵpureFunction7, |
69 | | - ɵɵpureFunction8, |
70 | | - ɵɵpureFunctionV, |
71 | | -} from './pure_function'; |
72 | | -import {ɵɵsetComponentScope, ɵɵsetNgModuleScope} from './scope'; |
73 | | -import {ɵɵresetView, ɵɵenableBindings, ɵɵdisableBindings, ɵɵrestoreView} from './state'; |
74 | | -import {ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound'; |
75 | | -import {ɵɵHostDirectivesFeature} from './features/host_directives_feature'; |
76 | | -import {ɵɵNgOnChangesFeature} from './features/ng_onchanges_feature'; |
77 | | -import {ɵɵProvidersFeature} from './features/providers_feature'; |
78 | | -import {ɵɵCopyDefinitionFeature} from './features/copy_definition_feature'; |
79 | | -import {ɵɵInheritDefinitionFeature} from './features/inherit_definition_feature'; |
80 | | -import {ɵɵInputTransformsFeature} from './features/input_transforms_feature'; |
81 | | -import {ɵɵExternalStylesFeature} from './features/external_styles_feature'; |
82 | | -import {ɵɵresolveBody, ɵɵresolveDocument, ɵɵresolveWindow} from './util/misc_utils'; |
83 | | -import {ɵsetClassDebugInfo} from './debug/set_debug_info'; |
84 | | - |
85 | | -/** Cached environment for all HMR calls. */ |
86 | | -let hmrEnvironment: Record<string, unknown> | null = null; |
87 | | - |
88 | 44 | /** |
89 | 45 | * Replaces the metadata of a component type and re-renders all live instances of the component. |
90 | 46 | * @param type Class whose metadata will be replaced. |
91 | 47 | * @param applyMetadata Callback that will apply a new set of metadata on the `type` when invoked. |
| 48 | + * @param environment Core runtime environment to use when applying the HMR update. |
92 | 49 | * @param locals Local symbols from the source location that have to be exposed to the callback. |
93 | 50 | * @codeGenApi |
94 | 51 | */ |
95 | 52 | export function ɵɵreplaceMetadata( |
96 | 53 | type: Type<unknown>, |
97 | 54 | applyMetadata: (...args: [Type<unknown>, Record<string, unknown>, ...unknown[]]) => void, |
| 55 | + environment: Record<string, unknown>, |
98 | 56 | locals: unknown[], |
99 | 57 | ) { |
100 | 58 | ngDevMode && assertComponentDef(type); |
101 | 59 | const oldDef = getComponentDef(type)!; |
102 | 60 |
|
103 | | - if (hmrEnvironment === null) { |
104 | | - hmrEnvironment = getHmrEnv(); |
105 | | - } |
106 | | - |
107 | 61 | // The reason `applyMetadata` is a callback that is invoked (almost) immediately is because |
108 | 62 | // the compiler usually produces more code than just the component definition, e.g. there |
109 | 63 | // can be functions for embedded views, the variables for the constant pool and `setClassMetadata` |
110 | 64 | // calls. The callback allows us to keep them isolate from the rest of the app and to invoke |
111 | 65 | // them at the right time. |
112 | | - applyMetadata.apply(null, [type, hmrEnvironment, ...locals]); |
| 66 | + applyMetadata.apply(null, [type, environment, ...locals]); |
113 | 67 |
|
114 | 68 | // If a `tView` hasn't been created yet, it means that this component hasn't been instantianted |
115 | 69 | // before. In this case there's nothing left for us to do aside from patching it in. |
@@ -278,211 +232,3 @@ function resetProjectionState(tNode: TElementNode): void { |
278 | 232 | tNode.projection = null; |
279 | 233 | } |
280 | 234 | } |
281 | | - |
282 | | -/** |
283 | | - * The HMR replacement function needs access to all of `core`. This is similar to the |
284 | | - * `angularCoreEnv`, but without `replaceMetadata` to avoid circular dependencies. Furthermore, |
285 | | - * we can't something like a `nonHmrEnv` that is then combined with `replaceMetadata` to form the |
286 | | - * full environment, because it seems to break tree shaking internally. |
287 | | - * |
288 | | - * TODO(crisbeto): this is a temporary solution, we should be able to pass this in directly. |
289 | | - */ |
290 | | -function getHmrEnv(): Record<string, unknown> { |
291 | | - return { |
292 | | - 'ɵɵattribute': r3.ɵɵattribute, |
293 | | - 'ɵɵattributeInterpolate1': r3.ɵɵattributeInterpolate1, |
294 | | - 'ɵɵattributeInterpolate2': r3.ɵɵattributeInterpolate2, |
295 | | - 'ɵɵattributeInterpolate3': r3.ɵɵattributeInterpolate3, |
296 | | - 'ɵɵattributeInterpolate4': r3.ɵɵattributeInterpolate4, |
297 | | - 'ɵɵattributeInterpolate5': r3.ɵɵattributeInterpolate5, |
298 | | - 'ɵɵattributeInterpolate6': r3.ɵɵattributeInterpolate6, |
299 | | - 'ɵɵattributeInterpolate7': r3.ɵɵattributeInterpolate7, |
300 | | - 'ɵɵattributeInterpolate8': r3.ɵɵattributeInterpolate8, |
301 | | - 'ɵɵattributeInterpolateV': r3.ɵɵattributeInterpolateV, |
302 | | - 'ɵɵdefineComponent': ɵɵdefineComponent, |
303 | | - 'ɵɵdefineDirective': ɵɵdefineDirective, |
304 | | - 'ɵɵdefineInjectable': ɵɵdefineInjectable, |
305 | | - 'ɵɵdefineInjector': ɵɵdefineInjector, |
306 | | - 'ɵɵdefineNgModule': ɵɵdefineNgModule, |
307 | | - 'ɵɵdefinePipe': ɵɵdefinePipe, |
308 | | - 'ɵɵdirectiveInject': r3.ɵɵdirectiveInject, |
309 | | - 'ɵɵgetInheritedFactory': ɵɵgetInheritedFactory, |
310 | | - 'ɵɵinject': ɵɵinject, |
311 | | - 'ɵɵinjectAttribute': r3.ɵɵinjectAttribute, |
312 | | - 'ɵɵinvalidFactory': r3.ɵɵinvalidFactory, |
313 | | - 'ɵɵinvalidFactoryDep': ɵɵinvalidFactoryDep, |
314 | | - 'ɵɵtemplateRefExtractor': ɵɵtemplateRefExtractor, |
315 | | - 'ɵɵresetView': ɵɵresetView, |
316 | | - 'ɵɵHostDirectivesFeature': ɵɵHostDirectivesFeature, |
317 | | - 'ɵɵNgOnChangesFeature': ɵɵNgOnChangesFeature, |
318 | | - 'ɵɵProvidersFeature': ɵɵProvidersFeature, |
319 | | - 'ɵɵCopyDefinitionFeature': ɵɵCopyDefinitionFeature, |
320 | | - 'ɵɵInheritDefinitionFeature': ɵɵInheritDefinitionFeature, |
321 | | - 'ɵɵInputTransformsFeature': ɵɵInputTransformsFeature, |
322 | | - 'ɵɵExternalStylesFeature': ɵɵExternalStylesFeature, |
323 | | - 'ɵɵnextContext': r3.ɵɵnextContext, |
324 | | - 'ɵɵnamespaceHTML': r3.ɵɵnamespaceHTML, |
325 | | - 'ɵɵnamespaceMathML': r3.ɵɵnamespaceMathML, |
326 | | - 'ɵɵnamespaceSVG': r3.ɵɵnamespaceSVG, |
327 | | - 'ɵɵenableBindings': ɵɵenableBindings, |
328 | | - 'ɵɵdisableBindings': ɵɵdisableBindings, |
329 | | - 'ɵɵelementStart': r3.ɵɵelementStart, |
330 | | - 'ɵɵelementEnd': r3.ɵɵelementEnd, |
331 | | - 'ɵɵelement': r3.ɵɵelement, |
332 | | - 'ɵɵelementContainerStart': r3.ɵɵelementContainerStart, |
333 | | - 'ɵɵelementContainerEnd': r3.ɵɵelementContainerEnd, |
334 | | - 'ɵɵelementContainer': r3.ɵɵelementContainer, |
335 | | - 'ɵɵpureFunction0': ɵɵpureFunction0, |
336 | | - 'ɵɵpureFunction1': ɵɵpureFunction1, |
337 | | - 'ɵɵpureFunction2': ɵɵpureFunction2, |
338 | | - 'ɵɵpureFunction3': ɵɵpureFunction3, |
339 | | - 'ɵɵpureFunction4': ɵɵpureFunction4, |
340 | | - 'ɵɵpureFunction5': ɵɵpureFunction5, |
341 | | - 'ɵɵpureFunction6': ɵɵpureFunction6, |
342 | | - 'ɵɵpureFunction7': ɵɵpureFunction7, |
343 | | - 'ɵɵpureFunction8': ɵɵpureFunction8, |
344 | | - 'ɵɵpureFunctionV': ɵɵpureFunctionV, |
345 | | - 'ɵɵgetCurrentView': r3.ɵɵgetCurrentView, |
346 | | - 'ɵɵrestoreView': ɵɵrestoreView, |
347 | | - 'ɵɵlistener': r3.ɵɵlistener, |
348 | | - 'ɵɵprojection': r3.ɵɵprojection, |
349 | | - 'ɵɵsyntheticHostProperty': r3.ɵɵsyntheticHostProperty, |
350 | | - 'ɵɵsyntheticHostListener': r3.ɵɵsyntheticHostListener, |
351 | | - 'ɵɵpipeBind1': ɵɵpipeBind1, |
352 | | - 'ɵɵpipeBind2': ɵɵpipeBind2, |
353 | | - 'ɵɵpipeBind3': ɵɵpipeBind3, |
354 | | - 'ɵɵpipeBind4': ɵɵpipeBind4, |
355 | | - 'ɵɵpipeBindV': ɵɵpipeBindV, |
356 | | - 'ɵɵprojectionDef': r3.ɵɵprojectionDef, |
357 | | - 'ɵɵhostProperty': r3.ɵɵhostProperty, |
358 | | - 'ɵɵproperty': r3.ɵɵproperty, |
359 | | - 'ɵɵpropertyInterpolate': r3.ɵɵpropertyInterpolate, |
360 | | - 'ɵɵpropertyInterpolate1': r3.ɵɵpropertyInterpolate1, |
361 | | - 'ɵɵpropertyInterpolate2': r3.ɵɵpropertyInterpolate2, |
362 | | - 'ɵɵpropertyInterpolate3': r3.ɵɵpropertyInterpolate3, |
363 | | - 'ɵɵpropertyInterpolate4': r3.ɵɵpropertyInterpolate4, |
364 | | - 'ɵɵpropertyInterpolate5': r3.ɵɵpropertyInterpolate5, |
365 | | - 'ɵɵpropertyInterpolate6': r3.ɵɵpropertyInterpolate6, |
366 | | - 'ɵɵpropertyInterpolate7': r3.ɵɵpropertyInterpolate7, |
367 | | - 'ɵɵpropertyInterpolate8': r3.ɵɵpropertyInterpolate8, |
368 | | - 'ɵɵpropertyInterpolateV': r3.ɵɵpropertyInterpolateV, |
369 | | - 'ɵɵpipe': ɵɵpipe, |
370 | | - 'ɵɵqueryRefresh': r3.ɵɵqueryRefresh, |
371 | | - 'ɵɵqueryAdvance': r3.ɵɵqueryAdvance, |
372 | | - 'ɵɵviewQuery': r3.ɵɵviewQuery, |
373 | | - 'ɵɵviewQuerySignal': r3.ɵɵviewQuerySignal, |
374 | | - 'ɵɵloadQuery': r3.ɵɵloadQuery, |
375 | | - 'ɵɵcontentQuery': r3.ɵɵcontentQuery, |
376 | | - 'ɵɵcontentQuerySignal': r3.ɵɵcontentQuerySignal, |
377 | | - 'ɵɵreference': r3.ɵɵreference, |
378 | | - 'ɵɵclassMap': r3.ɵɵclassMap, |
379 | | - 'ɵɵclassMapInterpolate1': r3.ɵɵclassMapInterpolate1, |
380 | | - 'ɵɵclassMapInterpolate2': r3.ɵɵclassMapInterpolate2, |
381 | | - 'ɵɵclassMapInterpolate3': r3.ɵɵclassMapInterpolate3, |
382 | | - 'ɵɵclassMapInterpolate4': r3.ɵɵclassMapInterpolate4, |
383 | | - 'ɵɵclassMapInterpolate5': r3.ɵɵclassMapInterpolate5, |
384 | | - 'ɵɵclassMapInterpolate6': r3.ɵɵclassMapInterpolate6, |
385 | | - 'ɵɵclassMapInterpolate7': r3.ɵɵclassMapInterpolate7, |
386 | | - 'ɵɵclassMapInterpolate8': r3.ɵɵclassMapInterpolate8, |
387 | | - 'ɵɵclassMapInterpolateV': r3.ɵɵclassMapInterpolateV, |
388 | | - 'ɵɵstyleMap': r3.ɵɵstyleMap, |
389 | | - 'ɵɵstyleMapInterpolate1': r3.ɵɵstyleMapInterpolate1, |
390 | | - 'ɵɵstyleMapInterpolate2': r3.ɵɵstyleMapInterpolate2, |
391 | | - 'ɵɵstyleMapInterpolate3': r3.ɵɵstyleMapInterpolate3, |
392 | | - 'ɵɵstyleMapInterpolate4': r3.ɵɵstyleMapInterpolate4, |
393 | | - 'ɵɵstyleMapInterpolate5': r3.ɵɵstyleMapInterpolate5, |
394 | | - 'ɵɵstyleMapInterpolate6': r3.ɵɵstyleMapInterpolate6, |
395 | | - 'ɵɵstyleMapInterpolate7': r3.ɵɵstyleMapInterpolate7, |
396 | | - 'ɵɵstyleMapInterpolate8': r3.ɵɵstyleMapInterpolate8, |
397 | | - 'ɵɵstyleMapInterpolateV': r3.ɵɵstyleMapInterpolateV, |
398 | | - 'ɵɵstyleProp': r3.ɵɵstyleProp, |
399 | | - 'ɵɵstylePropInterpolate1': r3.ɵɵstylePropInterpolate1, |
400 | | - 'ɵɵstylePropInterpolate2': r3.ɵɵstylePropInterpolate2, |
401 | | - 'ɵɵstylePropInterpolate3': r3.ɵɵstylePropInterpolate3, |
402 | | - 'ɵɵstylePropInterpolate4': r3.ɵɵstylePropInterpolate4, |
403 | | - 'ɵɵstylePropInterpolate5': r3.ɵɵstylePropInterpolate5, |
404 | | - 'ɵɵstylePropInterpolate6': r3.ɵɵstylePropInterpolate6, |
405 | | - 'ɵɵstylePropInterpolate7': r3.ɵɵstylePropInterpolate7, |
406 | | - 'ɵɵstylePropInterpolate8': r3.ɵɵstylePropInterpolate8, |
407 | | - 'ɵɵstylePropInterpolateV': r3.ɵɵstylePropInterpolateV, |
408 | | - 'ɵɵclassProp': r3.ɵɵclassProp, |
409 | | - 'ɵɵadvance': r3.ɵɵadvance, |
410 | | - 'ɵɵtemplate': r3.ɵɵtemplate, |
411 | | - 'ɵɵconditional': r3.ɵɵconditional, |
412 | | - 'ɵɵdefer': r3.ɵɵdefer, |
413 | | - 'ɵɵdeferWhen': r3.ɵɵdeferWhen, |
414 | | - 'ɵɵdeferOnIdle': r3.ɵɵdeferOnIdle, |
415 | | - 'ɵɵdeferOnImmediate': r3.ɵɵdeferOnImmediate, |
416 | | - 'ɵɵdeferOnTimer': r3.ɵɵdeferOnTimer, |
417 | | - 'ɵɵdeferOnHover': r3.ɵɵdeferOnHover, |
418 | | - 'ɵɵdeferOnInteraction': r3.ɵɵdeferOnInteraction, |
419 | | - 'ɵɵdeferOnViewport': r3.ɵɵdeferOnViewport, |
420 | | - 'ɵɵdeferPrefetchWhen': r3.ɵɵdeferPrefetchWhen, |
421 | | - 'ɵɵdeferPrefetchOnIdle': r3.ɵɵdeferPrefetchOnIdle, |
422 | | - 'ɵɵdeferPrefetchOnImmediate': r3.ɵɵdeferPrefetchOnImmediate, |
423 | | - 'ɵɵdeferPrefetchOnTimer': r3.ɵɵdeferPrefetchOnTimer, |
424 | | - 'ɵɵdeferPrefetchOnHover': r3.ɵɵdeferPrefetchOnHover, |
425 | | - 'ɵɵdeferPrefetchOnInteraction': r3.ɵɵdeferPrefetchOnInteraction, |
426 | | - 'ɵɵdeferPrefetchOnViewport': r3.ɵɵdeferPrefetchOnViewport, |
427 | | - 'ɵɵdeferHydrateWhen': r3.ɵɵdeferHydrateWhen, |
428 | | - 'ɵɵdeferHydrateNever': r3.ɵɵdeferHydrateNever, |
429 | | - 'ɵɵdeferHydrateOnIdle': r3.ɵɵdeferHydrateOnIdle, |
430 | | - 'ɵɵdeferHydrateOnImmediate': r3.ɵɵdeferHydrateOnImmediate, |
431 | | - 'ɵɵdeferHydrateOnTimer': r3.ɵɵdeferHydrateOnTimer, |
432 | | - 'ɵɵdeferHydrateOnHover': r3.ɵɵdeferHydrateOnHover, |
433 | | - 'ɵɵdeferHydrateOnInteraction': r3.ɵɵdeferHydrateOnInteraction, |
434 | | - 'ɵɵdeferHydrateOnViewport': r3.ɵɵdeferHydrateOnViewport, |
435 | | - 'ɵɵdeferEnableTimerScheduling': r3.ɵɵdeferEnableTimerScheduling, |
436 | | - 'ɵɵrepeater': r3.ɵɵrepeater, |
437 | | - 'ɵɵrepeaterCreate': r3.ɵɵrepeaterCreate, |
438 | | - 'ɵɵrepeaterTrackByIndex': r3.ɵɵrepeaterTrackByIndex, |
439 | | - 'ɵɵrepeaterTrackByIdentity': r3.ɵɵrepeaterTrackByIdentity, |
440 | | - 'ɵɵcomponentInstance': r3.ɵɵcomponentInstance, |
441 | | - 'ɵɵtext': r3.ɵɵtext, |
442 | | - 'ɵɵtextInterpolate': r3.ɵɵtextInterpolate, |
443 | | - 'ɵɵtextInterpolate1': r3.ɵɵtextInterpolate1, |
444 | | - 'ɵɵtextInterpolate2': r3.ɵɵtextInterpolate2, |
445 | | - 'ɵɵtextInterpolate3': r3.ɵɵtextInterpolate3, |
446 | | - 'ɵɵtextInterpolate4': r3.ɵɵtextInterpolate4, |
447 | | - 'ɵɵtextInterpolate5': r3.ɵɵtextInterpolate5, |
448 | | - 'ɵɵtextInterpolate6': r3.ɵɵtextInterpolate6, |
449 | | - 'ɵɵtextInterpolate7': r3.ɵɵtextInterpolate7, |
450 | | - 'ɵɵtextInterpolate8': r3.ɵɵtextInterpolate8, |
451 | | - 'ɵɵtextInterpolateV': r3.ɵɵtextInterpolateV, |
452 | | - 'ɵɵi18n': r3.ɵɵi18n, |
453 | | - 'ɵɵi18nAttributes': r3.ɵɵi18nAttributes, |
454 | | - 'ɵɵi18nExp': r3.ɵɵi18nExp, |
455 | | - 'ɵɵi18nStart': r3.ɵɵi18nStart, |
456 | | - 'ɵɵi18nEnd': r3.ɵɵi18nEnd, |
457 | | - 'ɵɵi18nApply': r3.ɵɵi18nApply, |
458 | | - 'ɵɵi18nPostprocess': r3.ɵɵi18nPostprocess, |
459 | | - 'ɵɵresolveWindow': ɵɵresolveWindow, |
460 | | - 'ɵɵresolveDocument': ɵɵresolveDocument, |
461 | | - 'ɵɵresolveBody': ɵɵresolveBody, |
462 | | - 'ɵɵsetComponentScope': ɵɵsetComponentScope, |
463 | | - 'ɵɵsetNgModuleScope': ɵɵsetNgModuleScope, |
464 | | - 'ɵɵregisterNgModuleType': registerNgModuleType, |
465 | | - 'ɵɵgetComponentDepsFactory': ɵɵgetComponentDepsFactory, |
466 | | - 'ɵsetClassDebugInfo': ɵsetClassDebugInfo, |
467 | | - 'ɵɵdeclareLet': r3.ɵɵdeclareLet, |
468 | | - 'ɵɵstoreLet': r3.ɵɵstoreLet, |
469 | | - 'ɵɵreadContextLet': r3.ɵɵreadContextLet, |
470 | | - |
471 | | - 'ɵɵsanitizeHtml': sanitization.ɵɵsanitizeHtml, |
472 | | - 'ɵɵsanitizeStyle': sanitization.ɵɵsanitizeStyle, |
473 | | - 'ɵɵsanitizeResourceUrl': sanitization.ɵɵsanitizeResourceUrl, |
474 | | - 'ɵɵsanitizeScript': sanitization.ɵɵsanitizeScript, |
475 | | - 'ɵɵsanitizeUrl': sanitization.ɵɵsanitizeUrl, |
476 | | - 'ɵɵsanitizeUrlOrResourceUrl': sanitization.ɵɵsanitizeUrlOrResourceUrl, |
477 | | - 'ɵɵtrustConstantHtml': sanitization.ɵɵtrustConstantHtml, |
478 | | - 'ɵɵtrustConstantResourceUrl': sanitization.ɵɵtrustConstantResourceUrl, |
479 | | - 'ɵɵvalidateIframeAttribute': iframe_attrs_validation.ɵɵvalidateIframeAttribute, |
480 | | - |
481 | | - 'forwardRef': forwardRef, |
482 | | - 'resolveForwardRef': resolveForwardRef, |
483 | | - |
484 | | - 'ɵɵtwoWayProperty': r3.ɵɵtwoWayProperty, |
485 | | - 'ɵɵtwoWayBindingSet': r3.ɵɵtwoWayBindingSet, |
486 | | - 'ɵɵtwoWayListener': r3.ɵɵtwoWayListener, |
487 | | - }; |
488 | | -} |
0 commit comments