<commit_before>// asset/importer/image-builtin - Browser built-in image importer
// Part of Stardazed
// (c) 2015-2017 by <NAME> - @zenmumbler
// https://github.com/stardazed/stardazed

/// <reference path="../importer.ts" />

namespace sd.asset.importer {

	function importBuiltInImage(data: Blob, _uri: string, metadata: any) {
		const blobURL = URL.createObjectURL(data);

		// let colourSpace = image.ColourSpace.sRGB;
		// if ()

		return new Promise<image.PixelDataProvider>((resolve, reject) => {
			const builtin = new Image();
			builtin.onload = () => {
				resolve(new HTMLImageDataProvider(builtin));
			};
			builtin.onerror = () => {
				reject(`The image at '${blobURL}' is not supported`);
			};

			// Always enable CORS as GL will not allow tainted data to be loaded so if it fails
			// we can't use the image anyway and enabling it for local resources does no harm.
			builtin.crossOrigin = "anonymous";
			builtin.src = blobURL;
		}).then(provider => {
			URL.revokeObjectURL(blobURL);
			return {
				image: {
					kind: "image",
					item: provider
				}
			};
		});
	}

	registerImporter(importBuiltInImage, "image/bmp", ["bm", "bmp"]);
	registerImporter(importBuiltInImage, "image/jpeg", ["jpg", "jpe", "jpeg"]);
	registerImporter(importBuiltInImage, "image/png", "png");

	function parseColourSpace(cs: string | undefined) {
		if (cs === "linear") {
			return image.ColourSpace.Linear;
		}
		if (cs === "srgb") {
			return image.ColourSpace.sRGB;
		}
		if (cs !== void 0) {
			console.warn(`Image importer: ignoring invalid colourSpace`, cs);
		}
		return image.ColourSpace.sRGB;
	}

	export class HTMLImageDataProvider implements image.PixelDataProvider {
		private colourSpace_: image.ColourSpace;
		private pixelFormat_: image.PixelFormat;
		readonly dim: image.PixelDimensions;
		readonly mipMapCount = 1;

		constructor(private image_: HTMLImageElement) {
			this.colourSpace = image.ColourSpace.sRGB;
			this.dim = image.makePixelDimensions(image_.width, image_.height);
		}
<commit_msg>chore: remove non-building temp code before fork<commit_after>// asset/importer/image-builtin - Browser built-in image importer
// Part of Stardazed
// (c) 2015-2017 by <NAME> - @zenmumbler
// https://github.com/stardazed/stardazed

/// <reference path="../importer.ts" />

namespace sd.asset.importer {

	function importBuiltInImage(data: Blob, _uri: string) {
		const blobURL = URL.createObjectURL(data);

		return new Promise<image.PixelDataProvider>((resolve, reject) => {
			const builtin = new Image();
			builtin.onload = () => {
				resolve(new HTMLImageDataProvider(builtin));
			};
			builtin.onerror = () => {
				reject(`The image at '${blobURL}' is not supported`);
			};

			// Always enable CORS as GL will not allow tainted data to be loaded so if it fails
			// we can't use the image anyway and enabling it for local resources does no harm.
			builtin.crossOrigin = "anonymous";
			builtin.src = blobURL;
		}).then(provider => {
			URL.revokeObjectURL(blobURL);
			return {
				image: {
					kind: "image",
					item: provider
				}
			};
		});
	}

	registerImporter(importBuiltInImage, "image/bmp", ["bm", "bmp"]);
	registerImporter(importBuiltInImage, "image/jpeg", ["jpg", "jpe", "jpeg"]);
	registerImporter(importBuiltInImage, "image/png", "png");

	export class HTMLImageDataProvider implements image.PixelDataProvider {
		private colourSpace_: image.ColourSpace;
		private pixelFormat_: image.PixelFormat;
		readonly dim: image.PixelDimensions;
		readonly mipMapCount = 1;

		constructor(private image_: HTMLImageElement) {
			this.colourSpace = image.ColourSpace.sRGB;
			this.dim = image.makePixelDimensions(image_.width, image_.height);
		}

{'fraction_non_alphanumeric': 0.13506916192026036, 'fraction_numerical': 0.005153241117439653, 'mean_word_length': 3.8912466843501328, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '5091392', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1161, 'n_words': 292}