<commit_before>import Scene from './scene';

export var LeafletLayer = L.GridLayer.extend({

    initialize: function (options) {
        L.setOptions(this, options);
        this.createScene();
        this.hooks = {};
    },

    createScene: function () {
        this.scene = new Scene(
            this.options.vectorTileSource,
            this.options.vectorLayers,
            this.options.vectorStyles,
            {
                numWorkers: this.options.numWorkers,
                preRender: this.options.preRender,
                postRender: this.options.postRender,
                logLevel: this.options.logLevel,
                // advanced option, app will have to manually called scene.render() per frame
                disableRenderLoop: this.options.disableRenderLoop
            }
        );
    },

    // Finish initializing scene and setup events when layer is added to map
    onAdd: function () {
        if (!this.scene) {
            this.createScene();
        }

        L.GridLayer.prototype.onAdd.apply(this, arguments);

        this.hooks.tileunload = (event) => {
            var tile = event.tile;
            var key = tile.getAttribute('data-tile-key');
            this.scene.removeTile(key);
        };
        this.on('tileunload', this.hooks.tileunload);

        this.hooks.resize = () => {
            var size = this._map.getSize();
            this.scene.resizeMap(size.x, size.y);
            this.updateBounds();
        };
        this._map.on('resize', this.hooks.resize);

        this.hooks.move = () => {
            var center = this._map.getCenter();
            this.scene.setCenter(center.lng, center.lat);
            this.updateBounds();
        };
        this._map.on('move', this.hooks.move);

        this.hooks.zoomstart = () => {
            this.scene.startZoom();
        };
        this._map.on('zoomstart', this.hooks.zoomstart);

        this.hooks.zoomend = () => {
            this.scene.setZoom(this._map.getZoom());
            this.updateBounds();
        };
        this._map.on('zoomend', this.hooks.zoomend);
<commit_msg>leaflet unloadInvisibleTiles doesn't seem to be behaving as aspected in current master, this is a stopgap<commit_after>import Scene from './scene';

export var LeafletLayer = L.GridLayer.extend({

    initialize: function (options) {
        L.setOptions(this, options);
        this.createScene();
        this.hooks = {};
    },

    createScene: function () {
        this.scene = new Scene(
            this.options.vectorTileSource,
            this.options.vectorLayers,
            this.options.vectorStyles,
            {
                numWorkers: this.options.numWorkers,
                preRender: this.options.preRender,
                postRender: this.options.postRender,
                logLevel: this.options.logLevel,
                // advanced option, app will have to manually called scene.render() per frame
                disableRenderLoop: this.options.disableRenderLoop
            }
        );
    },

    // Finish initializing scene and setup events when layer is added to map
    onAdd: function () {
        if (!this.scene) {
            this.createScene();
        }

        L.GridLayer.prototype.onAdd.apply(this, arguments);

        this.hooks.tileunload = (event) => {
            // TODO: not expecting leaflet to fire this event for tiles that simply pan
            // out of bounds when 'unloadInvisibleTiles' option is set, but it's firing
            // since upgrading to latest master branch - force-checking for now
            if (this.options.unloadInvisibleTiles) {
                var tile = event.tile;
                var key = tile.getAttribute('data-tile-key');
                this.scene.removeTile(key);
            }
        };
        this.on('tileunload', this.hooks.tileunload);

        this.hooks.resize = () => {
            var size = this._map.getSize();
            this.scene.resizeMap(size.x, size.y);
            this.updateBounds();
        };
        this._map.on('resize', this.hooks.resize);

        this.hooks.move = () => {
            var center = this._map.getCenter();
            this.scene.setCenter(center.lng, center.lat);
            this.updateBounds();
        };
        this._map.on('move', this.hooks.move);

        this.hooks.zoomstart = () => {
            this.scene.startZoom();
        };
        this._map.on('zoomstart', this.hooks.zoomstart);

        this.hooks.zoomend = () => {
            this.scene.setZoom(this._map.getZoom());
            this.updateBounds();
        };
        this._map.on('zoomend', this.hooks.zoomend);

{'fraction_non_alphanumeric': 0.12281459097776819, 'fraction_numerical': 0.0, 'mean_word_length': 1.7665671641791045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5246571', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1266, 'n_words': 252}