<commit_before>const cache = {};

export function getComponentFromGist ( id ) {
	let cancelled = false;

	if ( !cache[ id ] ) {
		cache[ id ] = new Promise( ( resolve, reject ) => {
			const request = new XMLHttpRequest();
			request.open( 'GET', `https://api.github.com/gists/${id}` );
			request.onload = () => resolve( request );
			request.onerror = () => reject( new TypeError('Network request failed') );
			request.send();
		} )
			.then( r => JSON.parse(r.responseText) )
			.then( gist => {
				const components = [];

				const componentFiles = Object.keys( gist.files ).filter( file => /\.html$/.test( file ) );

				if ( componentFiles.length === 1 && componentFiles[0] === 'component.html' ) {
					// legacy
					components.push({
						name: 'App',
						source: gist.files[ 'component.html' ].content
					});
				} else {
					componentFiles.forEach( file => {
						const name = file.slice( 0, -5 );
						const source = gist.files[ file ].content;

						components.push({ name, source });
					});
				}

				const jsonFile = gist.files[ 'data.json' ];
				const json = jsonFile && jsonFile.content || '{}';

				return { components, json };
			})
			.catch( err => {
				cache[ id ] = null;
				throw err;
			});
	}

	const promise = cache[ id ].then( component => {
		if ( cancelled ) throw new Error( `Request was cancelled` );<commit_msg>repl: mark App.html as the entry component when loading from a gist<commit_after>const cache = {};

export function getComponentFromGist ( id ) {
	let cancelled = false;

	if ( !cache[ id ] ) {
		cache[ id ] = new Promise( ( resolve, reject ) => {
			const request = new XMLHttpRequest();
			request.open( 'GET', `https://api.github.com/gists/${id}` );
			request.onload = () => resolve( request );
			request.onerror = () => reject( new TypeError('Network request failed') );
			request.send();
		} )
			.then( r => JSON.parse(r.responseText) )
			.then( gist => {
				const components = [];

				const componentFiles = Object.keys( gist.files ).filter( file => /\.html$/.test( file ) );

				if ( componentFiles.length === 1 && componentFiles[0] === 'component.html' ) {
					// legacy
					components.push({
						name: 'App',
						entry: true,
						source: gist.files[ 'component.html' ].content
					});
				} else {
					componentFiles.forEach( file => {
						const name = file.slice( 0, -5 );
						const source = gist.files[ file ].content;

						components.push({ name, entry: name === 'App', source });
					});
				}

				const jsonFile = gist.files[ 'data.json' ];
				const json = jsonFile && jsonFile.content || '{}';

				return { components, json };
			})
			.catch( err => {
				cache[ id ] = null;
				throw err;
			});
	}

	const promise = cache[ id ].then( component => {
		if ( cancelled ) throw new Error( `Request was cancelled` );
{'fraction_non_alphanumeric': 0.1726950354609929, 'fraction_numerical': 0.0028368794326241137, 'mean_word_length': 2.6779661016949152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '7637710', 'n_tokens_mistral': 1095, 'n_tokens_neox': 879, 'n_words': 238}