preprocessSource static method
This is where the magic happens.
Depending on the params passed to it, this function embeds ("burns") javascript functions inside the HTML source, wraps it and/or URI-encodes it.
Implementation
static String preprocessSource(
String src, {
Set<EmbeddedJsContent> jsContent = const {},
bool forWeb = false,
bool encodeHtml = false,
String? windowDisambiguator,
}) {
var _src = src;
if (!isFullHtmlPage(_src)) {
_src = wrapHtml(_src, windowDisambiguator);
}
if (forWeb) {
_src = embedWebIframeJsConnector(_src, windowDisambiguator!);
}
if (jsContent.isNotEmpty) {
final jsContentStrings = <String>{};
for (final jsToEmbed in jsContent) {
if (jsToEmbed.js != null) {
jsContentStrings.add(jsToEmbed.js!);
} else {
if (forWeb && jsToEmbed.webJs != null) {
jsContentStrings.add(jsToEmbed.webJs!);
} else {
jsContentStrings.add(jsToEmbed.mobileJs!);
}
}
}
_src = embedJsInHtmlSource(_src, jsContentStrings);
}
if (encodeHtml) {
_src = encodeHtmlToURI(_src);
}
return _src;
}