- if (url.startsWith(".")) {searchString = searchString.substring(2);}const templateId = Object.keys(code).find((key) => key.includes(searchString));let template = code[templateId];if (!template) {console.log(template);debugger;}return Promise.resolve(template);};}function createNewHosts(cmps) {const components = Array.prototype.map.call(cmps, function (componentNode) {const newNode = document.createElement(componentNode.tagName);if (!componentNode.parentNode) {document.body.append(componentNode);}const parentNode = componentNode.parentNode;const currentDisplay = newNode.style.display;newNode.style.display = 'none';parentNode.insertBefore(newNode, componentNode);function removeOldHost() {newNode.style.display = currentDisplay;try {parentNode.removeChild(componentNode);} catch (e) {}}return removeOldHost;});return function removeOldHosts() {components.forEach(function (removeOldHost) {return removeOldHost();});};}export const hmrBootstrap = (ngModule: NgModuleRef<any>) => {const appRef: ApplicationRef = ngModule.injector.get(ApplicationRef);const elements = appRef.components.map((c) => c.location.nativeElement);const makeVisible = createNewHosts(elements);ngModule.destroy();makeVisible();};if (window['ref']) {hmrBootstrap(window['ref']);window['ref'] = null;}
0 commit comments