<commit_before>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// -- Namespaces ------------------------------------------------------------
// #include aura.AuraNamespaces

// -- Aura Bootstrap ------------------------------------------------------------
Aura.time = window.performance && window.performance.now ? window.performance.now.bind(performance) : function(){return Date.now();};
Aura["bootstrap"] = Aura["bootstrap"] || {};
Aura["bootstrap"]["visibilityStateStart"] = document.visibilityState;
Aura.bootstrapMark = function (mark, value) {
    //#if {"excludeModes" : ["PRODUCTION"]}
    if (window.console&&window.console.timeStamp) {
        window.console.timeStamp(mark);
    }
    //#end
    this["bootstrap"][mark] = value || this.time();
};


// bootstrap robustness:
// - all files required for bootstrap are loaded with sync <script> tags
// - DOMContentLoaded is fired after DOM is ready, which includes executing all sync <script> tags
// - to detect errors we wait for DOMContentLoaded then check for all bootstrap file markers
// NOTE: if Aura is injected into the page (Lightning Out or AIS) then DOMContentLoaded is fired
// before aura.js is loaded/executed, so verifyBootstrap() is never invoked.
//#if {"excludeModes" : ["DOC","TESTING","AUTOTESTING", "TESTINGDEBUG", "AUTOTESTINGDEBUG"]}
(function bootstrapRobustness() {
    function verifyBootstrap() {
        document.removeEventListener('DOMContentLoaded', verifyBootstrap);

        // now that all <script> are loaded can update network bootstrap.js load status
        $A.clientService.setAppBootstrapStatus();

        var state = $A.clientService.getBootstrapState();

        // wait for bootstrap to load from storage:
        // 1. wait for $A.initAsync()'s AuraContext callback to be invoked: gvpsFromStorage gets assigned true/false
        // 2. if gvpsFromStorage is true then wait for bootstrap from storage (if false then bootstrap is not loaded from storage)
        //
        // wait for "in progress" app cache
        // 1.state['appcache'] is appCache progress indicator, if it's undefined or 0 (not in progress), then we don't wait
        // 2.If < 0 then considered an error; if >=100 then considered done, so we wait for < 100.
        //
        // inline.js will always be set to true as long as inline.js was actually loaded and didn't 404 or 5XX
        //  if inline.js failed to load, we're really screwed and we'll need to attempt a reload.
        if (state["inline.js"] && ($A.clientService.gvpsFromStorage === undefined || ($A.clientService.gvpsFromStorage && Aura["appBootstrapCacheStatus"] === undefined)) ||
            (state["appcache"] && state["appcache"] < 100)) {
            setTimeout(verifyBootstrap, 1000);
            return;
        }

        var allFilesLoaded = Object.keys(state).reduce(function(prev, curr) {
            return prev && state[curr];
        }, true);
        if (!allFilesLoaded) {
            $A.clientService.dumpCachesAndReload(true);
        }
    }

    document.addEventListener('DOMContentLoaded', verifyBootstrap);<commit_msg>only not wait for app cache when progress is undefined<commit_after>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// -- Namespaces ------------------------------------------------------------
// #include aura.AuraNamespaces

// -- Aura Bootstrap ------------------------------------------------------------
Aura.time = window.performance && window.performance.now ? window.performance.now.bind(performance) : function(){return Date.now();};
Aura["bootstrap"] = Aura["bootstrap"] || {};
Aura["bootstrap"]["visibilityStateStart"] = document.visibilityState;
Aura.bootstrapMark = function (mark, value) {
    //#if {"excludeModes" : ["PRODUCTION"]}
    if (window.console&&window.console.timeStamp) {
        window.console.timeStamp(mark);
    }
    //#end
    this["bootstrap"][mark] = value || this.time();
};


// bootstrap robustness:
// - all files required for bootstrap are loaded with sync <script> tags
// - DOMContentLoaded is fired after DOM is ready, which includes executing all sync <script> tags
// - to detect errors we wait for DOMContentLoaded then check for all bootstrap file markers
// NOTE: if Aura is injected into the page (Lightning Out or AIS) then DOMContentLoaded is fired
// before aura.js is loaded/executed, so verifyBootstrap() is never invoked.
//#if {"excludeModes" : ["DOC","TESTING","AUTOTESTING", "TESTINGDEBUG", "AUTOTESTINGDEBUG"]}
(function bootstrapRobustness() {
    function verifyBootstrap() {
        document.removeEventListener('DOMContentLoaded', verifyBootstrap);

        // now that all <script> are loaded can update network bootstrap.js load status
        $A.clientService.setAppBootstrapStatus();

        var state = $A.clientService.getBootstrapState();

        // wait for bootstrap to load from storage:
        // 1. wait for $A.initAsync()'s AuraContext callback to be invoked: gvpsFromStorage gets assigned true/false
        // 2. if gvpsFromStorage is true then wait for bootstrap from storage (if false then bootstrap is not loaded from storage)
        //
        // wait for "in progress" app cache
        // 1.state['appcache'] is appCache progress indicator, if it's undefined, then we don't wait
        // 2.when offline is disabled, progress = 0 when page initially loads
        //  if progress < 0 then considered an error; 
        //  if progress >=100 then considered done, so we wait for < 100.
        //
        // inline.js will always be set to true as long as inline.js was actually loaded and didn't 404 or 5XX
        //  if inline.js failed to load, we're really screwed and we'll need to attempt a reload.
        if (state["inline.js"] && ($A.clientService.gvpsFromStorage === undefined || ($A.clientService.gvpsFromStorage && Aura["appBootstrapCacheStatus"] === undefined)) ||
            (typeof state["appcache"] !== "undefined" && state["appcache"] < 100)) {
            setTimeout(verifyBootstrap, 1000);
            return;
        }

        var allFilesLoaded = Object.keys(state).reduce(function(prev, curr) {
            return prev && state[curr];
        }, true);
        if (!allFilesLoaded) {
            $A.clientService.dumpCachesAndReload(true);
        }
    }

    document.addEventListener('DOMContentLoaded', verifyBootstrap);
{'fraction_non_alphanumeric': 0.1404049886013142, 'fraction_numerical': 0.008314335523669036, 'mean_word_length': 2.8246153846153845, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4216637', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1890, 'n_words': 707}