lpw
2 days ago 625be7754ff305f1d74a684b30db91c52041d428
frameworks/Didomi.xcframework/xros-arm64_x86_64-simulator/Didomi.framework/web_sdk_utilities.js
@@ -1,7 +1,9 @@
/** Script allowing to use the Web SDK from a WebView */
// Check if SDK is still initializing and should not display the notice yet
var initializationInProgress = true;
// Check if notice was initially displayed
var noticeReady = false;
var noticeDisplayed = false;
/**
 * Initialize the SDK with the specified configuration
@@ -11,6 +13,10 @@
    // Set the global window configuration to the config object
    window.didomiConfig = prepareConfigFromMobile(config, languageCode, isUnderage);
    // Set the location properties
    window.didomiCountry = extractCountryFromMobileConfig(config);
    window.didomiRegion = extractRegionFromMobileConfig(config);
    // If app, vendors, and iab exist, set the vendorList property
    if (
      window.didomiConfig.app &&
@@ -63,18 +69,23 @@
 * Open the notice screen
 */
function openNotice(userStatus, options) {
  var hasDeepLink = options != null && options.deepLinkView != null
  if (!hasDeepLink) {
      initializationInProgress = false
  }
  handleWebSDKEvents();
  window.didomiOnReady = window.didomiOnReady || [];
  window.didomiOnReady.push(function (Didomi) {
    Didomi.setUserStatus(userStatus);
    if (options != null && options.deepLinkView != null) {
    if (hasDeepLink) {
      initializationInProgress = false;
      Didomi.preferences.show(
        options.deepLinkView == 0 ? "purposes" : "vendors"
      );
    } else {
      Didomi.notice.show();
    }
    noticeReady = true;
    noticeDisplayed = true;
  });
}
@@ -153,7 +164,7 @@
      {
        event: 'notice.hidden',
        listener: function () {
          if (noticeReady && !Didomi.preferences.isVisible()) {
          if (noticeDisplayed && !Didomi.preferences.isVisible()) {
            if (isIOS()) {
              window.webkit.messageHandlers.noticeHidden.postMessage("");
            } else {
@@ -165,7 +176,10 @@
      {
        event: 'notice.shown',
        listener: function () {
          if (isIOS()) {
          if (initializationInProgress) {
            // Make sure the notice is not displayed if initialization is still in progress
            Didomi.notice.hide();
          } else if (isIOS()) {
            window.webkit.messageHandlers.noticeShown.postMessage("");
          } else {
            androidInterface.onNoticeShown();
@@ -412,13 +426,12 @@
/**
 * Fix unescaped quotes.
 * Note: lookbehinds (`(?<=...)` or `(?<!...)`) are only supported from safari 17+
 * @param {string} text
 * @returns the sanitized text
 */
function sanitizeText(text) {
  return text
    // Escape unescaped quotes
    .replace(/(?<!\\)(['"])/g, '\$1');
  return text.replace(/(^|[^\\])(['"])/g, '$1\$2');
}
/**
@@ -491,6 +504,24 @@
}
/**
 * Extract the country from the mobile config.
 * @param {*} configFromMobile
 * @returns the country or null if not defined.
 */
function extractCountryFromMobileConfig(configFromMobile) {
  return configFromMobile.user ? configFromMobile.user.country : null;
}
/**
 * Extract the region from the mobile config.
 * @param {*} configFromMobile
 * @returns the region or null if not defined.
 */
function extractRegionFromMobileConfig(configFromMobile) {
  return configFromMobile.user ? configFromMobile.user.region : null;
}
/**
 * Prepare config file to be consumed by the Web SDK, by disabling the features already handled by Mobile SDKs.
 * @param {*} configFromMobile Config provided by mobile.
 * @param {string} languageCode language code to be set in the Config.