MCPcopy
hub / github.com/angular/angular / insertEventRecordScript

Function insertEventRecordScript

packages/platform-server/src/utils.ts:157–186  ·  view source on GitHub ↗
(
  appId: string,
  doc: Document,
  eventTypesToReplay: {regular: Set<string>; capture: Set<string>},
  nonce: string | null,
)

Source from the content-addressed store, hash-verified

155}
156
157function 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.

Callers 1

prepareForHydrationFunction · 0.85

Calls 4

createScriptFunction · 0.90
startMeasuringFunction · 0.85
findEventDispatchScriptFunction · 0.85
stopMeasuringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…