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webpack://react-webpack-rails-tutorial/./client/app/controllers/ sync \\.js$","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/components/Footer/Footer.jsx","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/components/NavigationBar/CommentsCount.jsx","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/constants/paths.js","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/components/NavigationBar/NavigationBar.jsx","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/containers/NavigationBarContainer.jsx","webpack://react-webpack-rails-tutorial/./client/app/bundles/comments/startup/NavigationBarApp.jsx","webpack://react-webpack-rails-tutorial/./client/app/controllers/comments_controller.js","webpack://react-webpack-rails-tutorial/./client/app/controllers/index.js","webpack://react-webpack-rails-tutorial/./client/app/libs/components/BaseComponent.jsx","webpack://react-webpack-rails-tutorial/./client/app/packs/stimulus-bundle.js"],"sourcesContent":["var map = {\n\t\"./comments_controller.js\": 5210,\n\t\"./index.js\": 8308,\n\t\"controllers/comments_controller.js\": 5210,\n\t\"controllers/index.js\": 8308\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 3181;","import React from 'react';\nimport BaseComponent from 'libs/components/BaseComponent';\n\nexport default class Footer extends BaseComponent {\n render() {\n return (\n \n );\n }\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst href =\n 'https://github.com/shakacode/react_on_rails/blob/master/README.md#multiple-react-' +\n 'components-on-a-page-with-one-store';\nfunction CommentsCount(props) {\n const { commentsCount } = props;\n return (\n
  • \n \n Comments: {commentsCount}\n \n
  • \n );\n}\n\nCommentsCount.propTypes = {\n commentsCount: PropTypes.number.isRequired,\n};\n\nexport default CommentsCount;\n","export const ROUTER_PATH = '/';\nexport const REACT_ROUTER_PATH = '/react-router';\nexport const NO_ROUTER_PATH = '/no-router';\nexport const RESCRIPT_PATH = '/rescript';\nexport const SIMPLE_REACT_PATH = '/simple';\nexport const STIMULUS_PATH = '/stimulus';\nexport const RAILS_PATH = '/comments';\n","// https://github.com/eslint/eslint/issues/6876\n// eslint-disable new-cap\n\nimport classNames from 'classnames';\nimport _ from 'lodash';\nimport React, { useState } from 'react';\nimport PropTypes from 'prop-types';\n\nimport CommentsCount from './CommentsCount.jsx';\nimport * as paths from '../../constants/paths';\n\nfunction NavigationBar(props) {\n const { commentsCount, pathname } = props;\n\n const [isOpen, setIsOpen] = useState(false);\n\n const menuWrapperClasses = 'flex flex-col lg:flex-row flex-wrap lg:items-center lg:visible';\n\n return (\n \n );\n}\n\nNavigationBar.propTypes = {\n commentsCount: PropTypes.number,\n pathname: PropTypes.string.isRequired,\n};\n\nexport default NavigationBar;\n","import { connect } from 'react-redux';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport BaseComponent from '../../../libs/components/BaseComponent.jsx';\n\nimport NavigationBar from '../components/NavigationBar/NavigationBar.jsx';\n\nfunction stateToProps(state) {\n // Which part of the Redux global state does our component want to receive as props?\n if (state.$$commentsStore) {\n return {\n commentsCount: state.$$commentsStore.get('$$comments').size,\n pathname: state.railsContext.pathname,\n };\n }\n return {};\n}\n\nclass NavigationBarContainer extends BaseComponent {\n static propTypes = {\n commentsCount: PropTypes.number.isRequired,\n pathname: PropTypes.string.isRequired,\n };\n\n render() {\n const { commentsCount, pathname } = this.props;\n\n return ;\n }\n}\n\n// Don't forget to actually use connect!\nexport default connect(stateToProps)(NavigationBarContainer);\n","// Top level component for client side.\n// Compare this to the ./ServerApp.jsx file which is used for server side rendering.\n\nimport { Provider } from 'react-redux';\nimport React from 'react';\nimport ReactOnRails from 'react-on-rails';\n\nimport NavigationBar from '../components/NavigationBar/NavigationBar.jsx';\nimport NavigationBarContainer from '../containers/NavigationBarContainer.jsx';\nimport * as paths from '../constants/paths';\n\n/*\n * Export a function that returns a ReactComponent, depending on a store named SharedReduxStore.\n * This is used for the client rendering hook after the page html is rendered.\n * React will see that the state is the same and not do anything.\n */\nfunction NavigationBarAppFactory(_props, railsContext) {\n // This is where we get the existing store.\n const { pathname } = railsContext;\n let store;\n if (pathname === paths.ROUTER_PATH) {\n store = ReactOnRails.getStore('routerCommentsStore', false);\n } else if (pathname === paths.NO_ROUTER_PATH) {\n store = ReactOnRails.getStore('commentsStore', false);\n } else {\n return function NavigationBarApp() {\n return ;\n };\n }\n\n // eslint interprets the return as a new component definition, which is not the case\n // eslint-disable-next-line react/display-name, react/no-unstable-nested-components\n return function NavigationBarApp() {\n return (\n \n \n \n );\n };\n}\n\nexport default NavigationBarAppFactory;\n","import { Controller } from '@hotwired/stimulus';\nimport * as ActionCable from '@rails/actioncable';\nimport * as marked from 'marked';\nimport { gfmHeadingId } from 'marked-gfm-heading-id';\nimport { mangle } from 'marked-mangle';\n\nmarked.use(gfmHeadingId());\nmarked.use(mangle());\n\nexport default class extends Controller {\n static targets = ['commentList', 'commentAuthor', 'commentText', 'commentRefresh', 'alertDiv', 'errorList'];\n\n resetText() {\n const inputAuthor = this.commentAuthorTarget;\n const inputText = this.commentTextTarget;\n const alertDiv = this.alertDivTarget;\n const errorList = this.errorListTarget;\n\n const errors = [];\n\n if (!inputAuthor.value || !inputText.value) {\n errorList.innerHTML = '';\n if (!inputAuthor.value) {\n errors.push('Author');\n } else if (!inputText.value) {\n errors.push('Text');\n } else {\n errors.push('Author');\n errors.push('Text');\n }\n errors.forEach((error) => {\n const errorString = `
  • ${error}: can't be blank
  • `;\n errorList.insertAdjacentHTML('afterbegin', errorString);\n });\n alertDiv.classList.remove('hidden');\n } else {\n alertDiv.classList.add('hidden');\n errorList.innerHTML = '';\n inputText.value = '';\n }\n }\n\n refreshCommentList() {\n const refreshBtn = this.commentRefreshTarget;\n refreshBtn.click();\n }\n\n connect() {\n console.log('connected to Stimulus comments_controller');\n\n const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';\n const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`;\n\n this.cable = ActionCable.createConsumer(cableUrl);\n\n this.cable.subscriptions.create('CommentsChannel', {\n connected: () => {\n console.log('connected to comments channel using Stimulus controller');\n },\n disconnected: () => {\n console.log('disconnected from comments channel via Stimulus');\n },\n received: (comment) => {\n const htmlText = marked.parse(comment.text);\n const htmlComment = `

    ${comment.author}

    ${htmlText}
    `;\n this.commentListTarget.insertAdjacentHTML('afterbegin', htmlComment);\n },\n });\n }\n}\n","import { Application } from '@hotwired/stimulus';\nimport { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers';\n\nconst application = Application.start();\nconst context = require.context('.', true, /\\.js$/);\napplication.load(definitionsFromContext(context));\n","import React from 'react';\n\n/* eslint-disable react/prefer-stateless-function */\nexport default class BaseComponent extends React.PureComponent {}\n","import ReactOnRails from 'react-on-rails';\nimport 'jquery-ujs';\nimport { Turbo } from '@hotwired/turbo-rails';\n\n// eslint-disable-next-line no-unused-vars\nimport controllers from '../controllers';\n\nimport NavigationBarApp from '../bundles/comments/startup/NavigationBarApp';\nimport Footer from '../bundles/comments/components/Footer/Footer';\n\nimport '../assets/styles/application';\n\nTurbo.session.drive = false;\n\nReactOnRails.setOptions({\n // traceTurbolinks: process.env.TRACE_TURBOLINKS, // eslint-disable-line no-undef\n // process.env.TRACE_TURBOLINKS -> error: development is not defined\n traceTurbolinks: true,\n});\n\nReactOnRails.register({\n NavigationBarApp,\n Footer,\n});\n"],"names":["map","webpackContext","req","id","webpackContextResolve","__webpack_require__","o","e","Error","code","keys","Object","resolve","module","exports","Footer","_BaseComponent","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","key","value","React","className","href","BaseComponent","props","commentsCount","NO_ROUTER_PATH","RESCRIPT_PATH","SIMPLE_REACT_PATH","STIMULUS_PATH","RAILS_PATH","pathname","_useState2","_slicedToArray","useState","isOpen","setIsOpen","type","onClick","xmlns","fill","viewBox","stroke","strokeLinecap","strokeLinejoin","strokeWidth","d","concat","classNames","paths","_","CommentsCount","NavigationBarContainer","_this$props","this","NavigationBar","PropTypes","isRequired","connect","state","$$commentsStore","get","size","railsContext","_props","store","ReactOnRails","Provider","marked","gfmHeadingId","mangle","_default","_Controller","inputAuthor","commentAuthorTarget","inputText","commentTextTarget","alertDiv","alertDivTarget","errorList","errorListTarget","errors","classList","add","innerHTML","push","forEach","error","errorString","insertAdjacentHTML","remove","commentRefreshTarget","click","_this","console","log","protocol","window","location","cableUrl","hostname","port","cable","ActionCable","subscriptions","create","connected","disconnected","received","comment","htmlText","text","htmlComment","author","commentListTarget","Controller","application","Application","start","context","require","load","definitionsFromContext","_React$PureComponent","Turbo","drive","traceTurbolinks","NavigationBarApp"],"sourceRoot":""}