<commit_before>import requestAnimationFrame from 'raf';
import {
	RenderingContext2D
} from './types';
import {
	compressSpaces,
	toNumbers
} from './util';
import Property from './Property';
import ViewPort from './ViewPort';
import Mouse from './Mouse';
import Document, {
	Element,
	AnimateElement
} from './Document';

export interface IScreenOptions {
	/**
	 * Window object.
	 */
	window?: Window;
	/**
	 * WHATWG-compatible `fetch` function.
	 */
	fetch?: typeof fetch;
}

export interface IScreenStartOptions {
	/**
	 * Whether enable the redraw.
	 */
	enableRedraw?: boolean;
	/**
	 * Ignore mouse events.
	 */
	ignoreMouse?: boolean;
	/**
	 * Ignore animations.
	 */
	ignoreAnimation?: boolean;
	/**
	 * Does not try to resize canvas.
	 */
	ignoreDimensions?: boolean;
	/**
	 * Does not clear canvas.
	 */
	ignoreClear?: boolean;
	/**
	 * Scales horizontally to width.
	 */
	scaleWidth?: number;
	/**
	 * Scales vertically to height.
	 */
	scaleHeight?: number;
	/**
	 * Draws at a x offset.
	 */
	offsetX?: number;
	/**
	 * Draws at a y offset.
	 */
	offsetY?: number;
	/**
	 * Will call the function on every frame, if it returns true, will redraw.
	 */
	forceRedraw?(): boolean;
}

export interface IScreenViewBoxConfig {
	document: Document;
	ctx: RenderingContext2D;
	aspectRatio: string;
	width: number;
	desiredWidth: number;
	height: number;
	desiredHeight: number;
	minX?: number;
	minY?: number;
	refX?: number;
	refY?: number;
	clip?: boolean;
	clipX?: number;
	clipY?: number;
}

const defaultWindow = typeof window !== 'undefined'
	? window
	: null;
const defaultFetch: typeof fetch = typeof fetch !== 'undefined'
	// tslint:disable-next-line: no-unnecessary-callback-wrapper
	? (...args) => fetch(...args) // `fetch` depends on context: `someObject.fetch(...)` will throw error.
	: null;

export default class Screen {

	static readonly defaultWindow = defaultWindow;
	static readonly defaultFetch = defaultFetch;

	FRAMERATE = 30;
	MAX_VIRTUAL_PIXELS = 30000;
	CLIENT_WIDTH = 800;
	CLIENT_HEIGHT = 600;
	readonly window?: Window;
	readonly fetch: typeof defaultFetch;
	readonly viewPort = new ViewPort();<commit_msg>use bind to undefined<commit_after>import requestAnimationFrame from 'raf';
import {
	RenderingContext2D
} from './types';
import {
	compressSpaces,
	toNumbers
} from './util';
import Property from './Property';
import ViewPort from './ViewPort';
import Mouse from './Mouse';
import Document, {
	Element,
	AnimateElement
} from './Document';

export interface IScreenOptions {
	/**
	 * Window object.
	 */
	window?: Window;
	/**
	 * WHATWG-compatible `fetch` function.
	 */
	fetch?: typeof fetch;
}

export interface IScreenStartOptions {
	/**
	 * Whether enable the redraw.
	 */
	enableRedraw?: boolean;
	/**
	 * Ignore mouse events.
	 */
	ignoreMouse?: boolean;
	/**
	 * Ignore animations.
	 */
	ignoreAnimation?: boolean;
	/**
	 * Does not try to resize canvas.
	 */
	ignoreDimensions?: boolean;
	/**
	 * Does not clear canvas.
	 */
	ignoreClear?: boolean;
	/**
	 * Scales horizontally to width.
	 */
	scaleWidth?: number;
	/**
	 * Scales vertically to height.
	 */
	scaleHeight?: number;
	/**
	 * Draws at a x offset.
	 */
	offsetX?: number;
	/**
	 * Draws at a y offset.
	 */
	offsetY?: number;
	/**
	 * Will call the function on every frame, if it returns true, will redraw.
	 */
	forceRedraw?(): boolean;
}

export interface IScreenViewBoxConfig {
	document: Document;
	ctx: RenderingContext2D;
	aspectRatio: string;
	width: number;
	desiredWidth: number;
	height: number;
	desiredHeight: number;
	minX?: number;
	minY?: number;
	refX?: number;
	refY?: number;
	clip?: boolean;
	clipX?: number;
	clipY?: number;
}

const defaultWindow = typeof window !== 'undefined'
	? window
	: null;
const defaultFetch: typeof fetch = typeof fetch !== 'undefined'
	? fetch.bind(void 0) // `fetch` depends on context: `someObject.fetch(...)` will throw error.
	: null;

export default class Screen {

	static readonly defaultWindow = defaultWindow;
	static readonly defaultFetch = defaultFetch;

	FRAMERATE = 30;
	MAX_VIRTUAL_PIXELS = 30000;
	CLIENT_WIDTH = 800;
	CLIENT_HEIGHT = 600;
	readonly window?: Window;
	readonly fetch: typeof defaultFetch;
	readonly viewPort = new ViewPort();
{'fraction_non_alphanumeric': 0.13273287508888362, 'fraction_numerical': 0.007347712728134629, 'mean_word_length': 3.7256438969764836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4388455', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1323, 'n_words': 412}