* Serialize all the ancestors of the given injector and return * its serialized version. * * @param injector The environment injector to start from. * @returns The serialized form of the input Injector.
(injector: Injector)
| 166 | * @returns The serialized form of the input {@link Injector}. |
| 167 | */ |
| 168 | function serializeAncestors(injector: Injector): SerializedInjector { |
| 169 | const existing = serializedEnvInjectorMap.get(injector); |
| 170 | if (existing) return existing; |
| 171 | |
| 172 | const serialized = serializeInjector(injector); |
| 173 | serializedEnvInjectorMap.set(injector, serialized); |
| 174 | |
| 175 | const parentInjector = getParentEnvInjector(injector); |
| 176 | if (parentInjector) { |
| 177 | // Recursively process the parent and attach ourselves as a child. |
| 178 | const parentSerialized = serializeAncestors(parentInjector); |
| 179 | parentSerialized.children.push(serialized); |
| 180 | } else { |
| 181 | // If there is no parent, this is a root environment injector. |
| 182 | if (!rootEnvInjector) { |
| 183 | rootEnvInjector = serialized; |
| 184 | } else if (rootEnvInjector !== serialized) { |
| 185 | throw new Error('Expected only one root environment injector, but found multiple.', { |
| 186 | cause: {firstRoot: rootEnvInjector, secondRoot: serialized}, |
| 187 | }); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return serialized; |
| 192 | } |
| 193 | |
| 194 | // Process all descendant environment injectors. |
| 195 | for (const rootLView of rootLViews) { |
no test coverage detected
searching dependent graphs…