<commit_before>REACT_CACHE = Object.create(null)

Lanes.lib.HotReload =

    remember: (klass) ->
        # return klass # unless klass::FILE
        path = klass::FILE.path.join("/") + ".js"
        if REACT_CACHE[path]
            return klass
        else
            REACT_CACHE[path] = Lanes.Vendor.ReactProxy(klass)
            return REACT_CACHE[path].get()

    replaceCss: (asset) ->
        styles = document.head.querySelectorAll("link[rel='stylesheet'][href*='#{asset.path}']")
        for link in _.toArray(styles)[0..-2]
            link.parentElement.removeChild(link)

    replaceProps: (asset) ->
        klass = Lanes.u.objectForPath(asset.path)
        if klass and REACT_CACHE[asset.path]
            REACT_CACHE[asset.path].update(klass)
            for viewport in Lanes.React.Viewport.all()
                Lanes.Vendor.deepForceUpdate(viewport.reactRoot)

    initiate: (assets) ->
        Lanes.lib.RequestAssets (_.map(assets, 'path'))...
            .then (a) =>
                for asset in assets
                    if asset.type == "css"
                        this.replaceCss(asset)<commit_msg>Ensure FILE is set<commit_after>REACT_CACHE = Object.create(null)

Lanes.lib.HotReload =

    remember: (klass) ->
        return unless klass::FILE
        path = klass::FILE.path.join("/") + ".js"
        if REACT_CACHE[path]
            return klass
        else
            REACT_CACHE[path] = Lanes.Vendor.ReactProxy(klass)
            return REACT_CACHE[path].get()

    replaceCss: (asset) ->
        styles = document.head.querySelectorAll("link[rel='stylesheet'][href*='#{asset.path}']")
        for link in _.toArray(styles)[0..-2]
            link.parentElement.removeChild(link)

    replaceProps: (asset) ->
        klass = Lanes.u.objectForPath(asset.path)
        if klass and REACT_CACHE[asset.path]
            REACT_CACHE[asset.path].update(klass)
            for viewport in Lanes.React.Viewport.all()
                Lanes.Vendor.deepForceUpdate(viewport.reactRoot)

    initiate: (assets) ->
        Lanes.lib.RequestAssets (_.map(assets, 'path'))...
            .then (a) =>
                for asset in assets
                    if asset.type == "css"
                        this.replaceCss(asset)
{'fraction_non_alphanumeric': 0.1298354824366385, 'fraction_numerical': 0.0017785682525566918, 'mean_word_length': 2.0364372469635628, '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': '6518963', 'n_tokens_mistral': 682, 'n_tokens_neox': 692, 'n_words': 119}