function init()

in Extensions/Optimizely/Src/UIContribution/lib/VSS.SDK.js [839:895]


    function init(options) {
        initOptions = options || {};
        usingPlatformScripts = initOptions.usePlatformScripts;
        usingPlatformStyles = initOptions.usePlatformStyles;
        // Run this after current execution path is complete - allows objects to get initialized
        window.setTimeout(function () {
            var appHandshakeData = {
                notifyLoadSucceeded: !initOptions.explicitNotifyLoaded,
                extensionReusedCallback: initOptions.extensionReusedCallback,
                vssSDKVersion: VSS.VssSDKVersion
            };
            parentChannel.invokeRemoteMethod("initialHandshake", "VSS.HostControl", [appHandshakeData]).then(function (handshakeData) {
                hostPageContext = handshakeData.pageContext;
                webContext = hostPageContext.webContext;
                initialConfiguration = handshakeData.initialConfig || {};
                initialContribution = handshakeData.contribution;
                extensionContext = handshakeData.extensionContext;
                if (handshakeData.sandboxedStorage) {
                    var updateNeeded = false;
                    if (shimmedLocalStorage) {
                        if (handshakeData.sandboxedStorage.localStorage) {
                            // Merge host data in with any values already set.
                            var newData = handshakeData.sandboxedStorage.localStorage;
                            // Check for any properties written prior to the initial handshake
                            for (var _i = 0, _a = Object.keys(shimmedLocalStorage); _i < _a.length; _i++) {
                                var key = _a[_i];
                                var value = shimmedLocalStorage.getItem(key);
                                if (value !== newData[key]) {
                                    newData[key] = value;
                                    updateNeeded = true;
                                }
                            }
                            // Update the stored values
                            for (var _b = 0, _c = Object.keys(newData); _b < _c.length; _b++) {
                                var key = _c[_b];
                                shimmedLocalStorage.setItem(key, newData[key]);
                            }
                        }
                        else if (shimmedLocalStorage.length > 0) {
                            updateNeeded = true;
                        }
                    }
                    hostReadyForShimUpdates = true;
                    if (updateNeeded) {
                        // Talk to host frame to issue update
                        updateHostSandboxedStorage();
                    }
                }
                if (usingPlatformScripts || usingPlatformStyles) {
                    setupAmdLoader();
                }
                else {
                    triggerReady();
                }
            });
        }, 0);
    }