<commit_before>"use strict";

module.exports = function defaultTemplate(cfg) {
    const data = cfg.data;
    const head = cfg.head;
    const html = cfg.html;

    const wildcatConfig = cfg.wildcatConfig;
    const clientSettings = wildcatConfig.clientSettings;
    const generalSettings = wildcatConfig.generalSettings;

    const entry = clientSettings.entry;
    const renderHandler = clientSettings.renderHandler;
    const reactRootElementID = clientSettings.reactRootElementID;
    const staticUrl = generalSettings.staticUrl;

    const __DEV__ = (typeof process !== "undefined") && (process.env.NODE_ENV === "development");

    return `
<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        ${head.title.toString()}
        ${head.meta.toString()}
        ${head.link.toString()}
    </head>
    <body>
        <div id="${reactRootElementID}">${html}</div>

        <script>
            __INITIAL_DATA__ = ${JSON.stringify(data)};
            __REACT_ROOT_ID__ = "${reactRootElementID}";
        </script>

        <script src="${staticUrl}/jspm_packages/system.js"></script>

        <script>
            System.config({
                baseURL: "${staticUrl}"
            });
        </script>

        <script>
            // FIXME: Possibly not needed in jspm 0.17
            // store the old normalization function
            var systemNormalize = System.normalize;

            // override the normalization function
            System.normalize = function (name, parentName, parentAddress) {
                return systemNormalize.call(this, name, parentName, parentAddress).then(function (url) {
                    if ((/\.(?:css|eot|gif|jpe?g|json|otf|png|swf|svg|ttf|woff)\.js$/).test(url)) {
                        return url.replace(/\.js$/, "");
                    }

                    return url;
                });
            };
        </script>

        <script src="${staticUrl}/system.config.js"></script>

        <script>
            Promise.all([
                System.import("${entry}"),
                System.import("${renderHandler}")
            ])
                .then(function (responses) {
                    // First response is a hash of project options
                    var clientOptions = responses[0];

                    // Second response is the handoff to the client
                    var client = responses[1];

                    // Pass options to server
                    return client(clientOptions);
                })
                ${__DEV__ ? `.then(function () {
                    var socket = new WebSocket("${staticUrl.replace("http", "ws")}");

                    socket.addEventListener("message", function (message) {
                        message = JSON.parse(message.data);
                        var modulePath = message.data;

                        switch (message.event) {
                            case "filechange":
                                try {
                                    if (System.has(modulePath)) {
                                        System.delete(modulePath);
                                        System.import(modulePath);
                                    }
                                } catch (e) {
                                    console.error(e);
                                }
                                break;
                        }
                    });
                })` : ``}
                .catch(function (err) {
                    console.error(err);
                });
        </script>
    </body>
</html>
`.trim();
};
<commit_msg>fix(react-wildcat-handoff): escape regex character<commit_after>"use strict";

module.exports = function defaultTemplate(cfg) {
    const data = cfg.data;
    const head = cfg.head;
    const html = cfg.html;

    const wildcatConfig = cfg.wildcatConfig;
    const clientSettings = wildcatConfig.clientSettings;
    const generalSettings = wildcatConfig.generalSettings;

    const entry = clientSettings.entry;
    const renderHandler = clientSettings.renderHandler;
    const reactRootElementID = clientSettings.reactRootElementID;
    const staticUrl = generalSettings.staticUrl;

    const __DEV__ = (typeof process !== "undefined") && (process.env.NODE_ENV === "development");

    return `
<!doctype html>
<html>
    <head>
        <meta charset="utf-8" />
        ${head.title.toString()}
        ${head.meta.toString()}
        ${head.link.toString()}
    </head>
    <body>
        <div id="${reactRootElementID}">${html}</div>

        <script>
            __INITIAL_DATA__ = ${JSON.stringify(data)};
            __REACT_ROOT_ID__ = "${reactRootElementID}";
        </script>

        <script src="${staticUrl}/jspm_packages/system.js"></script>

        <script>
            System.config({
                baseURL: "${staticUrl}"
            });
        </script>

        <script>
            // FIXME: Possibly not needed in jspm 0.17
            // store the old normalization function
            var systemNormalize = System.normalize;

            // override the normalization function
            System.normalize = function (name, parentName, parentAddress) {
                return systemNormalize.call(this, name, parentName, parentAddress).then(function (url) {
                    if ((/\\.(?:css|eot|gif|jpe?g|json|otf|png|swf|svg|ttf|woff)\.js$/).test(url)) {
                        return url.replace(/\.js$/, "");
                    }

                    return url;
                });
            };
        </script>

        <script src="${staticUrl}/system.config.js"></script>

        <script>
            Promise.all([
                System.import("${entry}"),
                System.import("${renderHandler}")
            ])
                .then(function (responses) {
                    // First response is a hash of project options
                    var clientOptions = responses[0];

                    // Second response is the handoff to the client
                    var client = responses[1];

                    // Pass options to server
                    return client(clientOptions);
                })
                ${__DEV__ ? `.then(function () {
                    var socket = new WebSocket("${staticUrl.replace("http", "ws")}");

                    socket.addEventListener("message", function (message) {
                        message = JSON.parse(message.data);
                        var modulePath = message.data;

                        switch (message.event) {
                            case "filechange":
                                try {
                                    if (System.has(modulePath)) {
                                        System.delete(modulePath);
                                        System.import(modulePath);
                                    }
                                } catch (e) {
                                    console.error(e);
                                }
                                break;
                        }
                    });
                })` : ``}
                .catch(function (err) {
                    console.error(err);
                });
        </script>
    </body>
</html>
`.trim();
};

{'fraction_non_alphanumeric': 0.117937465715853, 'fraction_numerical': 0.0016456390565002743, 'mean_word_length': 1.314503332275468, 'pattern_counts': {'":': 2, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2889877', 'n_tokens_mistral': 1827, 'n_tokens_neox': 1713, 'n_words': 359}