(injector: Injector)
| 22 | * @returns The transfer state data as an object, or empty object if not available |
| 23 | */ |
| 24 | export function getTransferState(injector: Injector): Record<string, unknown> { |
| 25 | const doc = injector.get(DOCUMENT); |
| 26 | const appId = injector.get(APP_ID); |
| 27 | |
| 28 | const transferState = retrieveTransferredState(doc, appId); |
| 29 | |
| 30 | // Strip internal keys. Keys are taken verbatim from the serialized state, so they can name |
| 31 | // `Object.prototype` properties like `__proto__`; a dictionary keeps them as ordinary entries. |
| 32 | const filteredEntries = createDictionary<unknown>(); |
| 33 | for (const [key, value] of Object.entries(transferState)) { |
| 34 | if (!isInternalHydrationTransferStateKey(key)) { |
| 35 | filteredEntries[key] = value; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | return filteredEntries; |
| 40 | } |
no test coverage detected