(
appId: string,
doc: Document,
eventTypesToReplay: {regular: Set<string>; capture: Set<string>},
nonce: string | null,
)
| 155 | } |
| 156 | |
| 157 | function insertEventRecordScript( |
| 158 | appId: string, |
| 159 | doc: Document, |
| 160 | eventTypesToReplay: {regular: Set<string>; capture: Set<string>}, |
| 161 | nonce: string | null, |
| 162 | ): void { |
| 163 | const measuringLabel = 'insertEventRecordScript'; |
| 164 | startMeasuring(measuringLabel); |
| 165 | const {regular, capture} = eventTypesToReplay; |
| 166 | const eventDispatchScript = findEventDispatchScript(doc); |
| 167 | |
| 168 | // Note: this is only true when build with the CLI tooling, which inserts the script in the HTML |
| 169 | if (eventDispatchScript) { |
| 170 | // This is defined in packages/core/primitives/event-dispatch/contract_binary.ts |
| 171 | const replayScriptContents = |
| 172 | `window.__jsaction_bootstrap(` + |
| 173 | `document.body,` + |
| 174 | `"${appId}",` + |
| 175 | `${JSON.stringify(Array.from(regular))},` + |
| 176 | `${JSON.stringify(Array.from(capture))}` + |
| 177 | `);`; |
| 178 | |
| 179 | const replayScript = createScript(doc, replayScriptContents, nonce); |
| 180 | |
| 181 | // Insert replay script right after inlined event dispatch script, since it |
| 182 | // relies on `__jsaction_bootstrap` to be defined in the global scope. |
| 183 | eventDispatchScript.after(replayScript); |
| 184 | } |
| 185 | stopMeasuring(measuringLabel); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Renders an Angular application to a string. |
no test coverage detected
searching dependent graphs…