<commit_before><?php

namespace extpoint\yii2\base;

use yii\base\Widget as BaseWidget;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\View;

class Widget extends BaseWidget
{
    public function renderReact($props)
    {
        $jsArgs = [
            Json::encode($this->id),
            Json::encode(get_class($this)),
            !empty($props) ? Json::encode($props) : '{}',
        ];
        $this->view->registerJs('__appWidget.render(' . implode(', ', $jsArgs) . ')', View::POS_END, $this->id);

        $widgetName = substr(strrchr(__CLASS__, "\\"), 1);
        $this->view->registerJsFile("@static/assets/bundle-$widgetName.js", ['position' => View::POS_END]);

        return Html::tag('span', '', ['id' => $this->id]);
    }
}<commit_msg>update bundle name for widgets<commit_after><?php

namespace extpoint\yii2\base;

use yii\base\Widget as BaseWidget;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\View;

class Widget extends BaseWidget
{
    public function renderReact($props)
    {
        // Generate bundle name alias extpoint/yii2-frontend npm package
        $bundleName = implode('-', array_filter(array_slice(preg_split('/\\/', __CLASS__), -1), function($name) {
            return preg_match('/[a-z0-9_-]+/', $name) && !in_array($name, ['app', 'widgets']);
        }));

        $jsArgs = [
            Json::encode($this->id),
            Json::encode(get_class($this)),
            !empty($props) ? Json::encode($props) : '{}',
        ];
        $this->view->registerJs('__appWidget.render(' . implode(', ', $jsArgs) . ')', View::POS_END, $this->id);
        $this->view->registerJsFile("@static/assets/bundle-$bundleName.js", ['position' => View::POS_END]);

        return Html::tag('span', '', ['id' => $this->id]);
    }
}
{'fraction_non_alphanumeric': 0.20056338028169013, 'fraction_numerical': 0.003943661971830986, 'mean_word_length': 3.0827586206896553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6090758', 'n_tokens_mistral': 587, 'n_tokens_neox': 588, 'n_words': 100}