<commit_before>import { TypedEvent } from '../../../../common/events';
import { kill } from '../../../utils/treeKill';
import { getPort } from '../../../utils/getPort';

const workerPrefix = `[DEMO-REACT]`;

export namespace WorkerImplementation {
    export let currentFilePath = '';
    export const clearLiveDemo = new TypedEvent<{}>();
    export const liveDemoData = new TypedEvent<{ data: string }>();

    export const enableLiveDemo = ({filePath}: { filePath: string }) => {
        console.log(workerPrefix, `Started on filePath: ${filePath}`);
        // if (executor) {
        //     executor.dispose();
        // }
        clearLiveDemo.emit({});
        // executor = new FileExecutor(filePath, (data) => {
        //     liveDemoData.emit({ data });
        // });
        currentFilePath = filePath;
        return Promise.resolve({})
    };
    export const disableLiveDemo = () => {
        // if (executor) {
        //     clearLiveDemo.emit({});
        //     executor.dispose();
        //     executor = undefined;
        //     currentFilePath = '';
        // }
        return Promise.resolve({})
    }
}<commit_msg>closer<commit_after>import { TypedEvent } from '../../../../common/events';
import { kill } from '../../../utils/treeKill';
import { getPort } from '../../../utils/getPort';

const workerPrefix = `[DEMO-REACT]`;

export namespace WorkerImplementation {
    export let currentFilePath = '';
    let demoPort: number = 4000;
    export const reloadReactDemo = new TypedEvent<{port: number}>();

    export const enableLiveDemo = ({filePath}: { filePath: string }) => {
        console.log(workerPrefix, `Started on filePath: ${filePath}`);
        currentFilePath = filePath;
        return getPort(demoPort).then(res => {
            reloadReactDemo.emit({ port: res });
        });
    };
    export const disableLiveDemo = () => {
        // if (executor) {
        //     clearLiveDemo.emit({});
        //     executor.dispose();
        //     executor = undefined;
        //     currentFilePath = '';
        // }
        return Promise.resolve({})
    }
}
{'fraction_non_alphanumeric': 0.1728395061728395, 'fraction_numerical': 0.001899335232668566, 'mean_word_length': 2.116863905325444, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5009341', 'n_tokens_mistral': 606, 'n_tokens_neox': 592, 'n_words': 131}