stimulus_reflex 3.5.0.pre9 → 3.5.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of stimulus_reflex might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +122 -127
- data/README.md +10 -16
- data/app/assets/javascripts/stimulus_reflex.js +710 -505
- data/app/assets/javascripts/stimulus_reflex.min.js +1 -1
- data/app/assets/javascripts/stimulus_reflex.min.js.map +1 -1
- data/app/assets/javascripts/stimulus_reflex.umd.js +660 -500
- data/app/assets/javascripts/stimulus_reflex.umd.min.js +660 -500
- data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +1 -1
- data/app/channels/stimulus_reflex/channel.rb +9 -7
- data/bin/console +0 -2
- data/bin/standardize +2 -1
- data/lib/generators/stimulus_reflex/stimulus_reflex_generator.rb +72 -7
- data/lib/generators/stimulus_reflex/templates/app/controllers/examples_controller.rb.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/consumer.js.tt +6 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.importmap.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.vite.tt +1 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/cable_ready.js.tt +4 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/index.js.tt +2 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/mrujs.js.tt +9 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/config/stimulus_reflex.js.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +141 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application.js.tt +11 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +74 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.vite.tt +5 -0
- data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
- data/{test/tmp/app/reflexes/user_reflex.rb → lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt} +38 -9
- data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +27 -0
- data/lib/generators/stimulus_reflex/templates/app/views/examples/show.html.erb.tt +207 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/cable_ready.rb +22 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +18 -13
- data/lib/generators/stimulus_reflex/templates/esbuild.config.mjs.tt +94 -0
- data/lib/install/action_cable.rb +155 -0
- data/lib/install/broadcaster.rb +90 -0
- data/lib/install/bundle.rb +56 -0
- data/lib/install/compression.rb +41 -0
- data/lib/install/config.rb +87 -0
- data/lib/install/development.rb +110 -0
- data/lib/install/esbuild.rb +114 -0
- data/lib/install/example.rb +22 -0
- data/lib/install/importmap.rb +133 -0
- data/lib/install/initializers.rb +25 -0
- data/lib/install/mrujs.rb +133 -0
- data/lib/install/npm_packages.rb +25 -0
- data/lib/install/reflexes.rb +25 -0
- data/lib/install/shakapacker.rb +64 -0
- data/lib/install/spring.rb +54 -0
- data/lib/install/updatable.rb +34 -0
- data/lib/install/vite.rb +64 -0
- data/lib/install/webpacker.rb +90 -0
- data/lib/install/yarn.rb +55 -0
- data/lib/stimulus_reflex/broadcasters/broadcaster.rb +15 -8
- data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -8
- data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +10 -10
- data/lib/stimulus_reflex/broadcasters/update.rb +3 -0
- data/lib/stimulus_reflex/cable_readiness.rb +29 -0
- data/lib/stimulus_reflex/cable_ready_channels.rb +5 -5
- data/lib/stimulus_reflex/callbacks.rb +17 -1
- data/lib/stimulus_reflex/concern_enhancer.rb +6 -4
- data/lib/stimulus_reflex/configuration.rb +12 -2
- data/lib/stimulus_reflex/dataset.rb +11 -1
- data/lib/stimulus_reflex/engine.rb +20 -9
- data/lib/stimulus_reflex/html/document.rb +59 -0
- data/lib/stimulus_reflex/html/document_fragment.rb +13 -0
- data/lib/stimulus_reflex/importmap.rb +3 -0
- data/lib/stimulus_reflex/installer.rb +274 -0
- data/lib/stimulus_reflex/open_struct_fix.rb +2 -0
- data/lib/stimulus_reflex/reflex.rb +25 -25
- data/lib/stimulus_reflex/reflex_data.rb +15 -3
- data/lib/stimulus_reflex/reflex_factory.rb +4 -2
- data/lib/stimulus_reflex/request_parameters.rb +2 -0
- data/lib/stimulus_reflex/utils/logger.rb +10 -0
- data/lib/stimulus_reflex/utils/sanity_checker.rb +8 -48
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/stimulus_reflex.rb +2 -0
- data/lib/tasks/stimulus_reflex/stimulus_reflex.rake +252 -0
- data/package.json +34 -28
- data/{rollup.config.js → rollup.config.mjs} +8 -7
- data/stimulus_reflex.gemspec +16 -19
- data/yarn.lock +1320 -742
- metadata +124 -77
- data/LATEST +0 -1
- data/lib/generators/stimulus_reflex/initializer_generator.rb +0 -14
- data/test/broadcasters/broadcaster_test.rb +0 -11
- data/test/broadcasters/broadcaster_test_case.rb +0 -39
- data/test/broadcasters/nothing_broadcaster_test.rb +0 -31
- data/test/broadcasters/page_broadcaster_test.rb +0 -79
- data/test/broadcasters/selector_broadcaster_test.rb +0 -173
- data/test/callbacks_test.rb +0 -652
- data/test/concern_enhancer_test.rb +0 -54
- data/test/element_test.rb +0 -254
- data/test/generators/stimulus_reflex_generator_test.rb +0 -58
- data/test/reflex_test.rb +0 -43
- data/test/test_helper.rb +0 -71
- data/test/tmp/app/reflexes/application_reflex.rb +0 -12
- data/yarn-error.log +0 -4964
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stimulus_reflex.umd.min.js","sources":["../../../javascript/schema.js","../../../javascript/debug.js","../../../javascript/reflex_store.js","../../../javascript/log.js","../../../javascript/deprecate.js","../../../javascript/utils.js","../../../javascript/attributes.js","../../../javascript/isolation_mode.js","../../../javascript/lifecycle.js","../../../javascript/controllers.js","../../../javascript/reflexes.js","../../../javascript/reflex_data.js","../../../javascript/transports/action_cable.js","../../../javascript/callbacks.js","../../../javascript/stimulus_reflex.js","../../../javascript/index.js"],"sourcesContent":["const defaultSchema = {\n reflexAttribute: 'data-reflex',\n reflexPermanentAttribute: 'data-reflex-permanent',\n reflexRootAttribute: 'data-reflex-root',\n reflexSuppressLoggingAttribute: 'data-reflex-suppress-logging',\n reflexDatasetAttribute: 'data-reflex-dataset',\n reflexDatasetAllAttribute: 'data-reflex-dataset-all',\n reflexSerializeFormAttribute: 'data-reflex-serialize-form',\n reflexFormSelectorAttribute: 'data-reflex-form-selector',\n reflexIncludeInnerHtmlAttribute: 'data-reflex-include-inner-html',\n reflexIncludeTextContentAttribute: 'data-reflex-include-text-content'\n}\n\nlet schema = {}\n\nexport { schema, defaultSchema }\n\nexport default {\n set (application) {\n schema = { ...defaultSchema, ...application.schema }\n for (const attribute in schema) {\n Object.defineProperty(this, attribute.slice(0, -9), {\n get: () => {\n return schema[attribute]\n }\n })\n }\n }\n}\n","let debugging = false\n\nexport default {\n get enabled () {\n return debugging\n },\n get disabled () {\n return !debugging\n },\n get value () {\n return debugging\n },\n set (value) {\n debugging = !!value\n },\n set debug (value) {\n debugging = !!value\n }\n}\n","const reflexes = {}\n\nexport { reflexes }\n","import Debug from './debug'\n\nimport { reflexes } from './reflex_store'\n\nconst request = (\n reflexId,\n target,\n args,\n controller,\n element,\n controllerElement\n) => {\n const reflex = reflexes[reflexId]\n if (Debug.disabled || reflex.promise.data.suppressLogging) return\n reflex.timestamp = new Date()\n console.log(`\\u2191 stimulus \\u2191 ${target}`, {\n reflexId,\n args,\n controller,\n element,\n controllerElement\n })\n}\n\nconst success = (event, halted) => {\n const { detail } = event || {}\n const { selector, payload } = detail || {}\n const { reflexId, target, morph } = detail.stimulusReflex || {}\n const reflex = reflexes[reflexId]\n if (Debug.disabled || reflex.promise.data.suppressLogging) return\n const progress =\n reflex.totalOperations > 1\n ? ` ${reflex.completedOperations}/${reflex.totalOperations}`\n : ''\n const duration = reflex.timestamp\n ? `in ${new Date() - reflex.timestamp}ms`\n : 'CLONED'\n const operation = event.type\n .split(':')[1]\n .split('-')\n .slice(1)\n .join('_')\n console.log(\n `\\u2193 reflex \\u2193 ${target} \\u2192 ${selector ||\n '\\u221E'}${progress} ${duration}`,\n { reflexId, morph, operation, halted, payload }\n )\n}\n\nconst error = event => {\n const { detail } = event || {}\n const { reflexId, target, payload } = detail.stimulusReflex || {}\n const reflex = reflexes[reflexId]\n if (Debug.disabled || reflex.promise.data.suppressLogging) return\n const duration = reflex.timestamp\n ? `in ${new Date() - reflex.timestamp}ms`\n : 'CLONED'\n console.log(\n `\\u2193 reflex \\u2193 ${target} ${duration} %cERROR: ${event.detail.body}`,\n 'color: #f00;',\n { reflexId, payload }\n )\n}\n\nexport default { request, success, error }\n","let deprecationWarnings = true\n\nexport default {\n get enabled () {\n return deprecationWarnings\n },\n get disabled () {\n return !deprecationWarnings\n },\n get value () {\n return deprecationWarnings\n },\n set (value) {\n deprecationWarnings = !!value\n },\n set deprecate (value) {\n deprecationWarnings = !!value\n }\n}\n","// uuid4 function taken from stackoverflow\n// https://stackoverflow.com/a/2117523/554903\n\nconst uuidv4 = () => {\n const crypto = window.crypto || window.msCrypto\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16)\n )\n}\n\nconst serializeForm = (form, options = {}) => {\n if (!form) return ''\n\n const w = options.w || window\n const { element } = options\n const formData = new w.FormData(form)\n const data = Array.from(formData, e => e.map(encodeURIComponent).join('='))\n const submitButton = form.querySelector('input[type=submit]')\n if (\n element &&\n element.name &&\n element.nodeName === 'INPUT' &&\n element.type === 'submit'\n ) {\n data.push(\n `${encodeURIComponent(element.name)}=${encodeURIComponent(element.value)}`\n )\n } else if (submitButton && submitButton.name) {\n data.push(\n `${encodeURIComponent(submitButton.name)}=${encodeURIComponent(\n submitButton.value\n )}`\n )\n }\n return Array.from(data).join('&')\n}\n\nconst camelize = (value, uppercaseFirstLetter = true) => {\n if (typeof value !== 'string') return ''\n value = value\n .replace(/[\\s_](.)/g, $1 => $1.toUpperCase())\n .replace(/[\\s_]/g, '')\n .replace(/^(.)/, $1 => $1.toLowerCase())\n\n if (uppercaseFirstLetter)\n value = value.substr(0, 1).toUpperCase() + value.substr(1)\n\n return value\n}\n\nconst debounce = (callback, delay = 250) => {\n let timeoutId\n return (...args) => {\n clearTimeout(timeoutId)\n timeoutId = setTimeout(() => {\n timeoutId = null\n callback(...args)\n }, delay)\n }\n}\n\nconst extractReflexName = reflexString => {\n const match = reflexString.match(/(?:.*->)?(.*?)(?:Reflex)?#/)\n\n return match ? match[1] : ''\n}\n\nconst emitEvent = (event, detail) => {\n document.dispatchEvent(\n new CustomEvent(event, {\n bubbles: true,\n cancelable: false,\n detail\n })\n )\n if (window.jQuery) window.jQuery(document).trigger(event, detail)\n}\n\n// construct a valid xPath for an element in the DOM\nconst elementToXPath = element => {\n if (element.id !== '') return \"//*[@id='\" + element.id + \"']\"\n if (element === document.body) return '/html/body'\n\n let ix = 0\n const siblings = element?.parentNode ? element.parentNode.childNodes : []\n\n for (var i = 0; i < siblings.length; i++) {\n const sibling = siblings[i]\n if (sibling === element) {\n const computedPath = elementToXPath(element.parentNode)\n const tagName = element.tagName.toLowerCase()\n const ixInc = ix + 1\n return `${computedPath}/${tagName}[${ixInc}]`\n }\n\n if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {\n ix++\n }\n }\n}\n\nconst XPathToElement = xpath => {\n return document.evaluate(\n xpath,\n document,\n null,\n XPathResult.FIRST_ORDERED_NODE_TYPE,\n null\n ).singleNodeValue\n}\n\nconst XPathToArray = (xpath, reverse = false) => {\n const snapshotList = document.evaluate(\n xpath,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n )\n\n const snapshots = []\n\n for (let i = 0; i < snapshotList.snapshotLength; i++) {\n snapshots.push(snapshotList.snapshotItem(i))\n }\n\n return reverse ? snapshots.reverse() : snapshots\n}\n\nexport {\n uuidv4,\n serializeForm,\n camelize,\n debounce,\n extractReflexName,\n emitEvent,\n elementToXPath,\n XPathToElement,\n XPathToArray\n}\n","import Schema from './schema'\nimport Debug from './debug'\nimport Deprecate from './deprecate'\n\nimport { elementToXPath, XPathToArray } from './utils'\n\nconst multipleInstances = element => {\n if (['checkbox', 'radio'].includes(element.type)) {\n return (\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n ).length > 1\n )\n }\n return false\n}\nconst collectCheckedOptions = element => {\n return Array.from(element.querySelectorAll('option:checked'))\n .concat(\n Array.from(\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n )\n ).filter(elem => elem.checked)\n )\n .map(o => o.value)\n}\n\n// Returns a string value for the passed array.\n//\n// attributeValue(['', 'one', null, 'two', 'three ']) // 'one two three'\n//\nconst attributeValue = (values = []) => {\n const value = values\n .filter(v => v && String(v).length)\n .map(v => v.trim())\n .join(' ')\n .trim()\n return value.length ? value : null\n}\n\n// Returns an array for the passed string value by splitting on whitespace.\n//\n// attributeValues('one two three ') // ['one', 'two', 'three']\n//\nconst attributeValues = value => {\n if (!value) return []\n if (!value.length) return []\n return value.split(' ').filter(v => v.trim().length)\n}\n\n// Extracts attributes from a DOM element.\n//\nconst extractElementAttributes = element => {\n let attrs = Array.from(element.attributes).reduce((memo, attr) => {\n memo[attr.name] = attr.value\n return memo\n }, {})\n\n attrs.checked = !!element.checked\n attrs.selected = !!element.selected\n attrs.tag_name = element.tagName\n\n if (element.tagName.match(/select/i) || multipleInstances(element)) {\n const collectedOptions = collectCheckedOptions(element)\n attrs.values = collectedOptions\n attrs.value = collectedOptions.join(',')\n } else {\n attrs.value = element.value\n }\n return attrs\n}\n\n// Returns an array of elements for the provided tokens.\n// Tokens is an array of space separated string coming from the `data-reflex-dataset`\n// or `data-reflex-dataset-all` attribute.\n//\nconst getElementsFromTokens = (element, tokens) => {\n if (!tokens || tokens.length === 0) return []\n\n let elements = [element]\n\n const xPath = elementToXPath(element)\n\n tokens.forEach(token => {\n try {\n switch (token) {\n case 'combined':\n if (Deprecate.enabled)\n console.warn(\n \"In the next version of StimulusReflex, the 'combined' option to data-reflex-dataset will become 'ancestors'.\"\n )\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'ancestors':\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'parent':\n elements = [...elements, ...XPathToArray(`${xPath}/parent::*`)]\n break\n case 'siblings':\n elements = [\n ...elements,\n ...XPathToArray(\n `${xPath}/preceding-sibling::*|${xPath}/following-sibling::*`\n )\n ]\n break\n case 'children':\n elements = [...elements, ...XPathToArray(`${xPath}/child::*`)]\n break\n case 'descendants':\n elements = [...elements, ...XPathToArray(`${xPath}/descendant::*`)]\n break\n default:\n elements = [...elements, ...document.querySelectorAll(token)]\n }\n } catch (error) {\n if (Debug.enabled) console.error(error)\n }\n })\n\n return elements\n}\n\n// Extracts the dataset of an element and combines it with the data attributes from all specified tokens\n//\nconst extractElementDataset = element => {\n const dataset = element.attributes[Schema.reflexDataset]\n const allDataset = element.attributes[Schema.reflexDatasetAll]\n\n const tokens = (dataset && dataset.value.split(' ')) || []\n const allTokens = (allDataset && allDataset.value.split(' ')) || []\n\n const datasetElements = getElementsFromTokens(element, tokens)\n const datasetAllElements = getElementsFromTokens(element, allTokens)\n\n const datasetAttributes = datasetElements.reduce((acc, ele) => {\n return { ...extractDataAttributes(ele), ...acc }\n }, {})\n\n const reflexElementAttributes = extractDataAttributes(element)\n\n const elementDataset = {\n dataset: { ...reflexElementAttributes, ...datasetAttributes },\n datasetAll: {}\n }\n\n datasetAllElements.forEach(element => {\n const elementAttributes = extractDataAttributes(element)\n\n Object.keys(elementAttributes).forEach(key => {\n const value = elementAttributes[key]\n\n if (\n elementDataset.datasetAll[key] &&\n Array.isArray(elementDataset.datasetAll[key])\n ) {\n elementDataset.datasetAll[key].push(value)\n } else {\n elementDataset.datasetAll[key] = [value]\n }\n })\n })\n\n return elementDataset\n}\n\n// Extracts all data attributes from a DOM element.\n//\nconst extractDataAttributes = element => {\n let attrs = {}\n\n if (element && element.attributes) {\n Array.from(element.attributes).forEach(attr => {\n if (attr.name.startsWith('data-')) {\n attrs[attr.name] = attr.value\n }\n })\n }\n\n return attrs\n}\n\nexport {\n attributeValue,\n attributeValues,\n extractElementAttributes,\n extractElementDataset,\n extractDataAttributes\n}\n","let isolationMode = false\n\nexport default {\n get disabled () {\n return !isolationMode\n },\n set (value) {\n isolationMode = value\n }\n}\n","import Debug from './debug'\n\nimport { camelize } from './utils'\nimport { reflexes } from './reflex_store'\n\n// Invokes a lifecycle method on a StimulusReflex controller.\n//\n// - stage - the lifecycle stage\n// * before\n// * success\n// * error\n// * halted\n// * after\n// * finalize\n//\n// - reflexElement - the element that triggered the Reflex (not necessarily the StimulusReflex Controller Element)\n// - controllerElement - the element holding the StimulusReflex Controller\n// - reflexId - the UUIDv4 which uniquely identifies the Reflex\n// - payload - the optional \"return value\" from the Reflex method\n//\nconst invokeLifecycleMethod = (\n stage,\n reflexElement,\n controllerElement,\n reflexId,\n payload\n) => {\n if (!controllerElement || !controllerElement.reflexData[reflexId]) return\n\n const controller = controllerElement.reflexController[reflexId]\n const reflex = controllerElement.reflexData[reflexId].target\n const reflexMethodName = reflex.split('#')[1]\n\n const specificLifecycleMethodName = ['before', 'after', 'finalize'].includes(\n stage\n )\n ? `${stage}${camelize(reflexMethodName)}`\n : `${camelize(reflexMethodName, false)}${camelize(stage)}`\n const specificLifecycleMethod = controller[specificLifecycleMethodName]\n\n const genericLifecycleMethodName = ['before', 'after', 'finalize'].includes(\n stage\n )\n ? `${stage}Reflex`\n : `reflex${camelize(stage)}`\n const genericLifecycleMethod = controller[genericLifecycleMethodName]\n\n if (typeof specificLifecycleMethod === 'function') {\n specificLifecycleMethod.call(\n controller,\n reflexElement,\n reflex,\n controllerElement.reflexError[reflexId],\n reflexId,\n payload\n )\n }\n\n if (typeof genericLifecycleMethod === 'function') {\n genericLifecycleMethod.call(\n controller,\n reflexElement,\n reflex,\n controllerElement.reflexError[reflexId],\n reflexId,\n payload\n )\n }\n\n if (reflexes[reflexId] && stage === reflexes[reflexId].finalStage) {\n Reflect.deleteProperty(controllerElement.reflexController, reflexId)\n Reflect.deleteProperty(controllerElement.reflexData, reflexId)\n Reflect.deleteProperty(controllerElement.reflexError, reflexId)\n // Removing this on a trial basis\n // 1. Prevents race condition with CR broadcasts\n // 2. Planning to remove it for v4 as part of queueing refactor\n // 3. Removing reflexes shouldn't be the responsibility of the lifecycle subsystem\n // Reflect.deleteProperty(reflexes, reflexId)\n }\n}\n\ndocument.addEventListener(\n 'stimulus-reflex:before',\n event =>\n invokeLifecycleMethod(\n 'before',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n ),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:success',\n event => {\n invokeLifecycleMethod(\n 'success',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n )\n dispatchLifecycleEvent(\n 'after',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n )\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:nothing',\n event => {\n dispatchLifecycleEvent(\n 'success',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n )\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:error',\n event => {\n invokeLifecycleMethod(\n 'error',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n )\n dispatchLifecycleEvent(\n 'after',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n )\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:halted',\n event =>\n invokeLifecycleMethod(\n 'halted',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n ),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:after',\n event =>\n invokeLifecycleMethod(\n 'after',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n ),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:finalize',\n event =>\n invokeLifecycleMethod(\n 'finalize',\n event.detail.element,\n event.detail.controller.element,\n event.detail.reflexId,\n event.detail.payload\n ),\n true\n)\n\n// Dispatches a lifecycle event on document\n//\n// - stage - the lifecycle stage\n// * before\n// * success\n// * error\n// * halted\n// * after\n// * finalize\n//\n// - reflexElement - the element that triggered the Reflex (not necessarily the StimulusReflex Controller Element)\n//\n// - controllerElement - the element holding the StimulusReflex Controller\n//\n// - reflexId - the UUIDv4 which uniquely identifies the Reflex\n//\n// - payload - optional Reflex return value\n//\nconst dispatchLifecycleEvent = (\n stage,\n reflexElement,\n controllerElement,\n reflexId,\n payload\n) => {\n if (!controllerElement) {\n if (Debug.enabled && !reflexes[reflexId].warned) {\n console.warn(\n `StimulusReflex was not able execute callbacks or emit events for \"${stage}\" or later life-cycle stages for this Reflex. The StimulusReflex Controller Element is no longer present in the DOM. Could you move the StimulusReflex Controller to an element higher in your DOM?`\n )\n reflexes[reflexId].warned = true\n }\n return\n }\n\n if (\n !controllerElement.reflexController ||\n (controllerElement.reflexController &&\n !controllerElement.reflexController[reflexId])\n ) {\n if (Debug.enabled && !reflexes[reflexId].warned) {\n console.warn(\n `StimulusReflex detected that the StimulusReflex Controller responsible for this Reflex has been replaced with a new instance. Callbacks and events for \"${stage}\" or later life-cycle stages cannot be executed.`\n )\n reflexes[reflexId].warned = true\n }\n return\n }\n\n const { target } = controllerElement.reflexData[reflexId] || {}\n const controller = controllerElement.reflexController[reflexId] || {}\n const event = `stimulus-reflex:${stage}`\n const action = `${event}:${target.split('#')[1]}`\n const detail = {\n reflex: target,\n controller,\n reflexId,\n element: reflexElement,\n payload\n }\n const options = { bubbles: true, cancelable: false, detail }\n\n controllerElement.dispatchEvent(new CustomEvent(event, options))\n controllerElement.dispatchEvent(new CustomEvent(action, options))\n\n if (window.jQuery) {\n window.jQuery(controllerElement).trigger(event, detail)\n window.jQuery(controllerElement).trigger(action, detail)\n }\n}\n\nexport { dispatchLifecycleEvent }\n","import Schema from './schema'\n\nimport { attributeValues } from './attributes'\nimport { extractReflexName } from './utils'\n\n// Returns StimulusReflex controllers local to the passed element based on the data-controller attribute.\n//\nconst localReflexControllers = (app, element) => {\n return attributeValues(element.getAttribute(Schema.controller)).reduce(\n (memo, name) => {\n const controller = app.getControllerForElementAndIdentifier(element, name)\n if (controller && controller.StimulusReflex) memo.push(controller)\n return memo\n },\n []\n )\n}\n\n// Returns all StimulusReflex controllers for the passed element.\n// Traverses DOM ancestors starting with element.\n//\nconst allReflexControllers = (app, element) => {\n let controllers = []\n while (element) {\n controllers = controllers.concat(localReflexControllers(app, element))\n element = element.parentElement\n }\n return controllers\n}\n\n// Given a reflex string such as 'click->TestReflex#create' and a list of\n// controllers. It will find the matching controller based on the controller's\n// identifier. e.g. Given these controller identifiers ['foo', 'bar', 'test'],\n// it would select the 'test' controller.\nconst findControllerByReflexName = (reflexName, controllers) => {\n const controller = controllers.find(controller => {\n if (!controller.identifier) return\n\n return (\n extractReflexName(reflexName)\n .replace(/([a-z0–9])([A-Z])/g, '$1-$2')\n .replace(/(::)/g, '--')\n .toLowerCase() === controller.identifier\n )\n })\n\n return controller || controllers[0]\n}\n\nexport { allReflexControllers, findControllerByReflexName }\n","import CableReady from 'cable_ready'\n\nimport Debug from './debug'\nimport Schema from './schema'\nimport IsolationMode from './isolation_mode'\n\nimport { reflexes } from './reflex_store'\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { XPathToElement, debounce, emitEvent } from './utils'\nimport { allReflexControllers, findControllerByReflexName } from './controllers'\nimport { attributeValue, attributeValues } from './attributes'\n\nconst received = data => {\n if (!data.cableReady) return\n\n if (data.version.replace('.pre', '-pre') !== CableReady.version) {\n if (Debug.enabled)\n console.error(\n `Reflex failed due to cable_ready gem/NPM package version mismatch. Package versions must match exactly.\\nNote that if you are using pre-release builds, gems use the \"x.y.z.preN\" version format, while NPM packages use \"x.y.z-preN\".\\n\\ncable_ready gem: ${data.version}\\ncable_ready NPM: ${CableReady.version}`\n )\n return\n }\n\n let reflexOperations = []\n\n for (let i = data.operations.length - 1; i >= 0; i--) {\n if (data.operations[i].stimulusReflex) {\n reflexOperations.push(data.operations[i])\n data.operations.splice(i, 1)\n }\n }\n\n if (\n reflexOperations.some(\n operation => operation.stimulusReflex.url !== location.href\n )\n ) {\n return\n }\n\n let reflexData\n\n if (reflexOperations.length) {\n reflexData = reflexOperations[0].stimulusReflex\n reflexData.payload = reflexOperations[0].payload\n }\n\n if (reflexData) {\n const { reflexId, payload } = reflexData\n\n if (!reflexes[reflexId] && IsolationMode.disabled) {\n const controllerElement = XPathToElement(reflexData.xpathController)\n const reflexElement = XPathToElement(reflexData.xpathElement)\n\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n controllerElement.reflexController[\n reflexId\n ] = reflexes.app.getControllerForElementAndIdentifier(\n controllerElement,\n reflexData.reflexController\n )\n\n controllerElement.reflexData[reflexId] = reflexData\n\n dispatchLifecycleEvent(\n 'before',\n reflexElement,\n controllerElement,\n reflexId,\n payload\n )\n\n registerReflex(reflexData)\n }\n\n if (reflexes[reflexId]) {\n reflexes[reflexId].totalOperations = reflexOperations.length\n reflexes[reflexId].pendingOperations = reflexOperations.length\n reflexes[reflexId].completedOperations = 0\n reflexes[reflexId].piggybackOperations = data.operations\n CableReady.perform(reflexOperations)\n }\n } else {\n if (data.operations.length && reflexes[data.operations[0].reflexId]) {\n CableReady.perform(data.operations)\n }\n }\n}\n\nconst registerReflex = data => {\n const { reflexId } = data\n reflexes[reflexId] = { finalStage: 'finalize' }\n\n const promise = new Promise((resolve, reject) => {\n reflexes[reflexId].promise = {\n resolve,\n reject,\n data\n }\n })\n\n promise.reflexId = reflexId\n\n if (Debug.enabled) promise.catch(() => {})\n\n return promise\n}\n\n// compute the DOM element(s) which will be the morph root\n// use the data-reflex-root attribute on the reflex or the controller\n// optional value is a CSS selector(s); comma-separated list\n// order of preference is data-reflex, data-controller, document body (default)\nconst getReflexRoots = element => {\n let list = []\n while (list.length === 0 && element) {\n let reflexRoot = element.getAttribute(Schema.reflexRoot)\n if (reflexRoot) {\n if (reflexRoot.length === 0 && element.id) reflexRoot = `#${element.id}`\n const selectors = reflexRoot.split(',').filter(s => s.trim().length)\n if (Debug.enabled && selectors.length === 0) {\n console.error(\n `No value found for ${Schema.reflexRoot}. Add an #id to the element or provide a value for ${Schema.reflexRoot}.`,\n element\n )\n }\n list = list.concat(selectors.filter(s => document.querySelector(s)))\n }\n element = element.parentElement\n ? element.parentElement.closest(`[${Schema.reflexRoot}]`)\n : null\n }\n return list\n}\n\n// Sets up declarative reflex behavior.\n// Any elements that define data-reflex will automatically be wired up with the default StimulusReflexController.\n//\nconst setupDeclarativeReflexes = debounce(() => {\n document.querySelectorAll(`[${Schema.reflex}]`).forEach(element => {\n const controllers = attributeValues(element.getAttribute(Schema.controller))\n const reflexAttributeNames = attributeValues(\n element.getAttribute(Schema.reflex)\n )\n const actions = attributeValues(element.getAttribute(Schema.action))\n reflexAttributeNames.forEach(reflexName => {\n const controller = findControllerByReflexName(\n reflexName,\n allReflexControllers(reflexes.app, element)\n )\n let action\n if (controller) {\n action = `${reflexName.split('->')[0]}->${\n controller.identifier\n }#__perform`\n if (!actions.includes(action)) actions.push(action)\n } else {\n action = `${reflexName.split('->')[0]}->stimulus-reflex#__perform`\n if (!controllers.includes('stimulus-reflex')) {\n controllers.push('stimulus-reflex')\n }\n if (!actions.includes(action)) actions.push(action)\n }\n })\n const controllerValue = attributeValue(controllers)\n const actionValue = attributeValue(actions)\n if (\n controllerValue &&\n element.getAttribute(Schema.controller) != controllerValue\n ) {\n element.setAttribute(Schema.controller, controllerValue)\n }\n if (actionValue && element.getAttribute(Schema.action) != actionValue)\n element.setAttribute(Schema.action, actionValue)\n })\n emitEvent('stimulus-reflex:ready')\n}, 20)\n\nexport { received, registerReflex, getReflexRoots, setupDeclarativeReflexes }\n","import Schema from './schema'\n\nimport { extractElementAttributes, extractElementDataset } from './attributes'\nimport { getReflexRoots } from './reflexes'\nimport { uuidv4 } from './utils'\nimport { elementToXPath } from './utils'\n\nimport { version } from '../package.json'\n\nexport default class ReflexData {\n constructor (\n options,\n reflexElement,\n controllerElement,\n reflexController,\n permanentAttributeName,\n target,\n args,\n url,\n tabId\n ) {\n this.options = options\n this.reflexElement = reflexElement\n this.controllerElement = controllerElement\n this.reflexController = reflexController\n this.permanentAttributeName = permanentAttributeName\n this.target = target\n this.args = args\n this.url = url\n this.tabId = tabId\n }\n\n get attrs () {\n this._attrs =\n this._attrs ||\n this.options['attrs'] ||\n extractElementAttributes(this.reflexElement)\n\n return this._attrs\n }\n\n get reflexId () {\n this._reflexId = this._reflexId || this.options['reflexId'] || uuidv4()\n return this._reflexId\n }\n\n get selectors () {\n this._selectors =\n this._selectors ||\n this.options['selectors'] ||\n getReflexRoots(this.reflexElement)\n\n return typeof this._selectors === 'string'\n ? [this._selectors]\n : this._selectors\n }\n\n get resolveLate () {\n return this.options['resolveLate'] || false\n }\n\n get dataset () {\n this._dataset = this._dataset || extractElementDataset(this.reflexElement)\n return this._dataset\n }\n\n get innerHTML () {\n return this.includeInnerHtml ? this.reflexElement.innerHTML : ''\n }\n\n get textContent () {\n return this.includeTextContent ? this.reflexElement.textContent : ''\n }\n\n get xpathController () {\n return elementToXPath(this.controllerElement)\n }\n\n get xpathElement () {\n return elementToXPath(this.reflexElement)\n }\n\n get formSelector () {\n const attr = this.reflexElement.attributes[Schema.reflexFormSelector]\n ? this.reflexElement.attributes[Schema.reflexFormSelector].value\n : undefined\n return this.options['formSelector'] || attr\n }\n\n get includeInnerHtml () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeInnerHtml] || false\n return this.options['includeInnerHTML'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get includeTextContent () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeTextContent] || false\n return this.options['includeTextContent'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get suppressLogging () {\n return (\n this.options['suppressLogging'] ||\n this.reflexElement.attributes[Schema.reflexSuppressLogging] ||\n false\n )\n }\n\n valueOf () {\n return {\n attrs: this.attrs,\n dataset: this.dataset,\n selectors: this.selectors,\n reflexId: this.reflexId,\n resolveLate: this.resolveLate,\n suppressLogging: this.suppressLogging,\n xpathController: this.xpathController,\n xpathElement: this.xpathElement,\n inner_html: this.innerHTML,\n text_content: this.textContent,\n formSelector: this.formSelector,\n reflexController: this.reflexController,\n permanentAttributeName: this.permanentAttributeName,\n target: this.target,\n args: this.args,\n url: this.url,\n tabId: this.tabId,\n version\n }\n }\n}\n","import { createConsumer } from '@rails/actioncable'\nimport { received } from '../reflexes'\nimport { emitEvent } from '../utils'\n\nlet consumer\nlet params\nlet subscriptionActive\n\nconst createSubscription = controller => {\n consumer = consumer || controller.application.consumer || createConsumer()\n const { channel } = controller.StimulusReflex\n const subscription = { channel, ...params }\n const identifier = JSON.stringify(subscription)\n\n controller.StimulusReflex.subscription =\n consumer.subscriptions.findAll(identifier)[0] ||\n consumer.subscriptions.create(subscription, {\n received,\n connected,\n rejected,\n disconnected\n })\n}\n\nconst connected = () => {\n subscriptionActive = true\n document.body.classList.replace(\n 'stimulus-reflex-disconnected',\n 'stimulus-reflex-connected'\n )\n emitEvent('stimulus-reflex:connected')\n emitEvent('stimulus-reflex:action-cable:connected')\n}\n\nconst rejected = () => {\n subscriptionActive = false\n document.body.classList.replace(\n 'stimulus-reflex-connected',\n 'stimulus-reflex-disconnected'\n )\n emitEvent('stimulus-reflex:rejected')\n emitEvent('stimulus-reflex:action-cable:rejected')\n if (Debug.enabled) console.warn('Channel subscription was rejected.')\n}\n\nconst disconnected = willAttemptReconnect => {\n subscriptionActive = false\n document.body.classList.replace(\n 'stimulus-reflex-connected',\n 'stimulus-reflex-disconnected'\n )\n emitEvent('stimulus-reflex:disconnected', willAttemptReconnect)\n emitEvent('stimulus-reflex:action-cable:disconnected', willAttemptReconnect)\n}\n\nexport default {\n consumer,\n params,\n get subscriptionActive () {\n return subscriptionActive\n },\n createSubscription,\n connected,\n rejected,\n disconnected,\n set (consumerValue, paramsValue) {\n consumer = consumerValue\n params = paramsValue\n }\n}\n","import CableReady from 'cable_ready'\n\nimport Log from './log'\n\nimport { reflexes } from './reflex_store'\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { XPathToElement } from './utils'\n\nconst beforeDOMUpdate = event => {\n const { stimulusReflex, payload } = event.detail || {}\n if (!stimulusReflex) return\n const { reflexId, xpathElement, xpathController } = stimulusReflex\n const controllerElement = XPathToElement(xpathController)\n const reflexElement = XPathToElement(xpathElement)\n const reflex = reflexes[reflexId]\n const { promise } = reflex\n\n reflex.pendingOperations--\n\n if (reflex.pendingOperations > 0) return\n\n if (!stimulusReflex.resolveLate)\n setTimeout(() =>\n promise.resolve({\n element: reflexElement,\n event,\n data: promise.data,\n payload,\n reflexId,\n toString: () => ''\n })\n )\n\n setTimeout(() =>\n dispatchLifecycleEvent(\n 'success',\n reflexElement,\n controllerElement,\n reflexId,\n payload\n )\n )\n}\n\nconst afterDOMUpdate = event => {\n const { stimulusReflex, payload } = event.detail || {}\n if (!stimulusReflex) return\n const { reflexId, xpathElement, xpathController } = stimulusReflex\n const controllerElement = XPathToElement(xpathController)\n const reflexElement = XPathToElement(xpathElement)\n const reflex = reflexes[reflexId]\n const { promise } = reflex\n\n reflex.completedOperations++\n\n Log.success(event, false)\n\n if (reflex.completedOperations < reflex.totalOperations) return\n\n if (stimulusReflex.resolveLate)\n setTimeout(() =>\n promise.resolve({\n element: reflexElement,\n event,\n data: promise.data,\n payload,\n reflexId,\n toString: () => ''\n })\n )\n\n setTimeout(() =>\n dispatchLifecycleEvent(\n 'finalize',\n reflexElement,\n controllerElement,\n reflexId,\n payload\n )\n )\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst routeReflexEvent = event => {\n const { stimulusReflex, payload, name, body } = event.detail || {}\n const eventType = name.split('-')[2]\n if (!stimulusReflex || !['nothing', 'halted', 'error'].includes(eventType))\n return\n\n const { reflexId, xpathElement, xpathController } = stimulusReflex\n const reflexElement = XPathToElement(xpathElement)\n const controllerElement = XPathToElement(xpathController)\n const reflex = reflexes[reflexId]\n const { promise } = reflex\n\n if (controllerElement) {\n controllerElement.reflexError = controllerElement.reflexError || {}\n if (eventType === 'error') controllerElement.reflexError[reflexId] = body\n }\n\n switch (eventType) {\n case 'nothing':\n nothing(event, payload, promise, reflex, reflexElement)\n break\n case 'error':\n error(event, payload, promise, reflex, reflexElement)\n break\n case 'halted':\n halted(event, payload, promise, reflex, reflexElement)\n break\n }\n\n setTimeout(() =>\n dispatchLifecycleEvent(\n eventType,\n reflexElement,\n controllerElement,\n reflexId,\n payload\n )\n )\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst nothing = (event, payload, promise, reflex, reflexElement) => {\n reflex.finalStage = 'after'\n\n Log.success(event, false)\n\n setTimeout(() =>\n promise.resolve({\n data: promise.data,\n element: reflexElement,\n event,\n payload,\n reflexId: promise.data.reflexId,\n toString: () => ''\n })\n )\n}\n\nconst halted = (event, payload, promise, reflex, reflexElement) => {\n reflex.finalStage = 'halted'\n\n Log.success(event, true)\n\n setTimeout(() =>\n promise.resolve({\n data: promise.data,\n element: reflexElement,\n event,\n payload,\n reflexId: promise.data.reflexId,\n toString: () => ''\n })\n )\n}\n\nconst error = (event, payload, promise, reflex, reflexElement) => {\n reflex.finalStage = 'after'\n\n Log.error(event)\n\n setTimeout(() =>\n promise.reject({\n data: promise.data,\n element: reflexElement,\n event,\n payload,\n reflexId: promise.data.reflexId,\n error: event.detail.body,\n toString: () => event.detail.body\n })\n )\n}\n\nexport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent }\n","import { Controller } from '@hotwired/stimulus'\n\nimport Schema from './schema'\nimport Log from './log'\nimport Debug from './debug'\nimport Deprecate from './deprecate'\nimport ReflexData from './reflex_data'\nimport IsolationMode from './isolation_mode'\nimport ActionCableTransport from './transports/action_cable'\n\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { uuidv4, serializeForm } from './utils'\nimport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent } from './callbacks'\nimport { registerReflex, setupDeclarativeReflexes } from './reflexes'\nimport { reflexes } from './reflex_store'\nimport { attributeValues } from './attributes'\n\n// Default StimulusReflexController that is implicitly wired up as data-controller for any DOM elements\n// that have configured data-reflex. Note that this default can be overridden when initializing the application.\n// i.e. StimulusReflex.initialize(myStimulusApplication, MyCustomDefaultController);\n//\nclass StimulusReflexController extends Controller {\n constructor (...args) {\n super(...args)\n register(this)\n }\n}\n\n// Initializes StimulusReflex by registering the default Stimulus controller with the passed Stimulus application.\n//\n// - application - the Stimulus application\n// - options\n// * controller - [optional] the default StimulusReflexController\n// * consumer - [optional] the ActionCable consumer\n// * debug - [false] log all Reflexes to the console\n// * params - [{}] key/value parameters to send during channel subscription\n// * isolate - [false] restrict Reflex playback to the tab which initiated it\n// * deprecate - [true] show warnings regarding upcoming changes to the library\n//\nconst initialize = (\n application,\n { controller, consumer, debug, params, isolate, deprecate } = {}\n) => {\n ActionCableTransport.set(consumer, params)\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n document.body.classList.remove('stimulus-reflex-connected')\n document.body.classList.add('stimulus-reflex-disconnected')\n if (Deprecate.enabled && consumer)\n console.warn(\n \"Deprecation warning: the next version of StimulusReflex will obtain a reference to consumer via the Stimulus application object.\\nPlease add 'application.consumer = consumer' to your index.js after your Stimulus application has been established, and remove the consumer key from your StimulusReflex initialize() options object.\"\n )\n if (Deprecate.enabled && IsolationMode.disabled)\n console.warn(\n 'Deprecation warning: the next version of StimulusReflex will standardize isolation mode, and the isolate option will be removed.\\nPlease update your applications to assume that every tab will be isolated.'\n )\n },\n { once: true }\n )\n IsolationMode.set(!!isolate)\n reflexes.app = application\n Schema.set(application)\n reflexes.app.register(\n 'stimulus-reflex',\n controller || StimulusReflexController\n )\n Debug.set(!!debug)\n if (typeof deprecate !== 'undefined') Deprecate.set(deprecate)\n const observer = new MutationObserver(setupDeclarativeReflexes)\n observer.observe(document.documentElement, {\n attributeFilter: [Schema.reflex, Schema.action],\n childList: true,\n subtree: true\n })\n}\n\n// Registers a Stimulus controller and extends it with StimulusReflex behavior\n//\n// controller - the Stimulus controller\n// options - [optional] configuration\n//\nconst register = (controller, options = {}) => {\n const channel = 'StimulusReflex::Channel'\n controller.StimulusReflex = { ...options, channel }\n ActionCableTransport.createSubscription(controller)\n Object.assign(controller, {\n // Indicates if the ActionCable web socket connection is open.\n // The connection must be open before calling stimulate.\n //\n isActionCableConnectionOpen () {\n return this.StimulusReflex.subscription.consumer.connection.isOpen()\n },\n\n // Invokes a server side reflex method.\n //\n // - target - the reflex target (full name of the server side reflex) i.e. 'ReflexClassName#method'\n // - reflexElement - [optional] the element that triggered the reflex, defaults to this.element\n // - options - [optional] an object that contains at least one of attrs, reflexId, selectors, resolveLate, serializeForm\n // - *args - remaining arguments are forwarded to the server side reflex method\n //\n stimulate () {\n const url = location.href\n const args = Array.from(arguments)\n const target = args.shift() || 'StimulusReflex::Reflex#default_reflex'\n const controllerElement = this.element\n const reflexElement =\n args[0] && args[0].nodeType === Node.ELEMENT_NODE\n ? args.shift()\n : controllerElement\n if (\n reflexElement.type === 'number' &&\n reflexElement.validity &&\n reflexElement.validity.badInput\n ) {\n if (Debug.enabled) console.warn('Reflex aborted: invalid numeric input')\n return\n }\n const options = {}\n if (\n args[0] &&\n typeof args[0] === 'object' &&\n Object.keys(args[0]).filter(key =>\n [\n 'attrs',\n 'selectors',\n 'reflexId',\n 'resolveLate',\n 'serializeForm',\n 'suppressLogging',\n 'includeInnerHTML',\n 'includeTextContent'\n ].includes(key)\n ).length\n ) {\n const opts = args.shift()\n Object.keys(opts).forEach(o => (options[o] = opts[o]))\n }\n\n const reflexData = new ReflexData(\n options,\n reflexElement,\n controllerElement,\n this.identifier,\n Schema.reflexPermanent,\n target,\n args,\n url,\n tabId\n )\n\n const reflexId = reflexData.reflexId\n\n if (!this.isActionCableConnectionOpen())\n throw 'The ActionCable connection is not open! `this.isActionCableConnectionOpen()` must return true before calling `this.stimulate()`'\n\n if (!ActionCableTransport.subscriptionActive)\n throw 'The ActionCable channel subscription for StimulusReflex was rejected.'\n\n // lifecycle setup\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n controllerElement.reflexController[reflexId] = this\n controllerElement.reflexData[reflexId] = reflexData.valueOf()\n\n dispatchLifecycleEvent(\n 'before',\n reflexElement,\n controllerElement,\n reflexId\n )\n\n setTimeout(() => {\n const { params } = controllerElement.reflexData[reflexId] || {}\n const check = reflexElement.attributes[Schema.reflexSerializeForm]\n if (check) {\n // not needed after v4 because this is only here for the deprecation warning\n options['serializeForm'] = check.value !== 'false'\n }\n\n const form =\n reflexElement.closest(reflexData.formSelector) ||\n document.querySelector(reflexData.formSelector) ||\n reflexElement.closest('form')\n\n if (Deprecate.enabled && options['serializeForm'] === undefined && form)\n console.warn(\n `Deprecation warning: the next version of StimulusReflex will not serialize forms by default.\\nPlease set ${Schema.reflexSerializeForm}=\\\"true\\\" on your Reflex Controller Element or pass { serializeForm: true } as an option to stimulate.`\n )\n const formData =\n options['serializeForm'] === false\n ? ''\n : serializeForm(form, {\n element: reflexElement\n })\n\n controllerElement.reflexData[reflexId] = {\n ...reflexData.valueOf(),\n params,\n formData\n }\n\n this.StimulusReflex.subscription.send(\n controllerElement.reflexData[reflexId]\n )\n })\n\n const promise = registerReflex(reflexData.valueOf())\n\n Log.request(\n reflexId,\n target,\n args,\n this.context.scope.identifier,\n reflexElement,\n controllerElement\n )\n\n return promise\n },\n\n // Wraps the call to stimulate for any data-reflex elements.\n // This is internal and should not be invoked directly.\n __perform (event) {\n let element = event.target\n let reflex\n\n while (element && !reflex) {\n reflex = element.getAttribute(Schema.reflex)\n if (!reflex || !reflex.trim().length) element = element.parentElement\n }\n\n const match = attributeValues(reflex).find(\n reflex => reflex.split('->')[0] === event.type\n )\n\n if (match) {\n event.preventDefault()\n event.stopPropagation()\n this.stimulate(match.split('->')[1], element)\n }\n }\n })\n}\n\n// Uniquely identify this browser tab in each Reflex\nconst tabId = uuidv4()\n\nconst useReflex = (controller, options = {}) => {\n register(controller, options)\n}\n\ndocument.addEventListener('cable-ready:after-dispatch-event', routeReflexEvent)\ndocument.addEventListener('cable-ready:before-inner-html', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:before-morph', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:after-inner-html', afterDOMUpdate)\ndocument.addEventListener('cable-ready:after-morph', afterDOMUpdate)\nwindow.addEventListener('load', setupDeclarativeReflexes)\n\nexport {\n initialize,\n register,\n useReflex\n}\n","export * from './stimulus_reflex'\n\nimport * as StimulusReflex from './stimulus_reflex'\n\nimport Debug from './debug'\nimport Deprecate from './deprecate'\n\nconst global = {\n ...StimulusReflex,\n get debug () {\n return Debug.value\n },\n set debug (value) {\n Debug.set(!!value)\n },\n get deprecate () {\n return Deprecate.value\n },\n set deprecate (value) {\n Deprecate.set(!!value)\n }\n}\n\nwindow.StimulusReflex = global\n\nexport default global\n"],"names":["defaultSchema","reflexAttribute","reflexPermanentAttribute","reflexRootAttribute","reflexSuppressLoggingAttribute","reflexDatasetAttribute","reflexDatasetAllAttribute","reflexSerializeFormAttribute","reflexFormSelectorAttribute","reflexIncludeInnerHtmlAttribute","reflexIncludeTextContentAttribute","schema","Schema","set","application","attribute","Object","defineProperty","this","slice","get","debugging","Debug$1","enabled","disabled","value","debug","reflexes","request","reflexId","target","args","controller","element","controllerElement","reflex","Debug","promise","data","suppressLogging","timestamp","Date","console","log","success","event","halted","detail","selector","payload","morph","stimulusReflex","progress","totalOperations","completedOperations","duration","operation","type","split","join","error","body","Log","deprecationWarnings","Deprecate","deprecate","uuidv4","crypto","window","msCrypto","replace","c","getRandomValues","Uint8Array","toString","serializeForm","form","options","w","formData","FormData","Array","from","e","map","encodeURIComponent","submitButton","querySelector","name","nodeName","push","camelize","uppercaseFirstLetter","$1","toUpperCase","toLowerCase","substr","debounce","callback","delay","timeoutId","clearTimeout","setTimeout","extractReflexName","reflexString","match","emitEvent","document","dispatchEvent","CustomEvent","bubbles","cancelable","jQuery","trigger","elementToXPath","id","ix","siblings","parentNode","childNodes","i","length","sibling","computedPath","tagName","ixInc","nodeType","XPathToElement","xpath","evaluate","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","XPathToArray","reverse","snapshotList","ORDERED_NODE_SNAPSHOT_TYPE","snapshots","snapshotLength","snapshotItem","multipleInstances","includes","querySelectorAll","collectCheckedOptions","concat","filter","elem","checked","o","attributeValue","values","v","String","trim","attributeValues","extractElementAttributes","attrs","attributes","reduce","memo","attr","selected","tag_name","collectedOptions","getElementsFromTokens","tokens","elements","xPath","forEach","token","warn","extractElementDataset","dataset","reflexDataset","allDataset","reflexDatasetAll","allTokens","datasetElements","datasetAllElements","datasetAttributes","acc","ele","extractDataAttributes","reflexElementAttributes","elementDataset","datasetAll","elementAttributes","keys","key","isArray","startsWith","isolationMode","IsolationMode","invokeLifecycleMethod","stage","reflexElement","reflexData","reflexController","reflexMethodName","specificLifecycleMethodName","specificLifecycleMethod","genericLifecycleMethodName","genericLifecycleMethod","call","reflexError","finalStage","Reflect","deleteProperty","addEventListener","dispatchLifecycleEvent","warned","action","localReflexControllers","app","getAttribute","getControllerForElementAndIdentifier","StimulusReflex","allReflexControllers","controllers","parentElement","findControllerByReflexName","reflexName","find","identifier","received","cableReady","version","CableReady","reflexOperations","operations","splice","some","url","location","href","xpathController","xpathElement","registerReflex","pendingOperations","piggybackOperations","perform","Promise","resolve","reject","catch","getReflexRoots","list","reflexRoot","selectors","s","closest","setupDeclarativeReflexes","reflexAttributeNames","actions","controllerValue","actionValue","setAttribute","ReflexData","constructor","permanentAttributeName","tabId","_attrs","_reflexId","_selectors","resolveLate","_dataset","innerHTML","includeInnerHtml","textContent","includeTextContent","formSelector","reflexFormSelector","undefined","reflexIncludeInnerHtml","reflexIncludeTextContent","reflexSuppressLogging","valueOf","inner_html","text_content","consumer","params","subscriptionActive","createSubscription","createConsumer","channel","subscription","JSON","stringify","subscriptions","findAll","create","connected","rejected","disconnected","classList","willAttemptReconnect","ActionCableTransport","consumerValue","paramsValue","beforeDOMUpdate","afterDOMUpdate","routeReflexEvent","eventType","nothing","StimulusReflexController","Controller","super","register","initialize","isolate","remove","add","once","observer","MutationObserver","observe","documentElement","attributeFilter","childList","subtree","assign","isActionCableConnectionOpen","connection","isOpen","stimulate","arguments","shift","Node","ELEMENT_NODE","validity","badInput","opts","reflexPermanent","check","reflexSerializeForm","send","context","scope","__perform","preventDefault","stopPropagation","useReflex","global"],"mappings":";;;;;;;;;;;EAAA,MAAMA,gBAAgB;IACpBC,iBAAiB;IACjBC,0BAA0B;IAC1BC,qBAAqB;IACrBC,gCAAgC;IAChCC,wBAAwB;IACxBC,2BAA2B;IAC3BC,8BAA8B;IAC9BC,6BAA6B;IAC7BC,iCAAiC;IACjCC,mCAAmC;;EAG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AAWgF;QAE1CtN,IAAIlC,QACFC,UACAC,QACAC,MACAb,KAAK8T,QAAQC,MAAMlH,YACnB5B,eACAjK;QAGF,OAAOG;;MAKT6S,UAAWrS;QACT,IAAIZ,UAAUY,MAAMf;QACpB,IAAIK;QAEJ,OAAOF,YAAYE,QAAQ;UACzBA,SAASF,QAAQqL,aAAa1M,OAAOuB;UACrC,KAAKA,WAAWA,OAAOsH,OAAOhC,QAAQxF,UAAUA,QAAQ0L;;QAG1D,MAAMlH,QAAQiD,gBAAgBvH,QAAQ2L,MACpC3L,UAAUA,OAAOuB,MAAM,MAAM,OAAOb,MAAMY;QAG5C,IAAIgD,OAAO;UACT5D,MAAMsS;UACNtS,MAAMuS;UACNlU,KAAKkT,UAAU3N,MAAM/C,MAAM,MAAM,IAAIzB;;;;;EAO7C,MAAMmO,QAAQlM;EAER,MAAAmR,YAAY,CAACrT,YAAY6C,UAAU;IACvCsO,SAASnR,YAAY6C;;EAGvB8B,SAASqG,iBAAiB,oCAAoC6F;EAC9DlM,SAASqG,iBAAiB,iCAAiC2F;EAC3DhM,SAASqG,iBAAiB,4BAA4B2F;EACtDhM,SAASqG,iBAAiB,gCAAgC4F;EAC1DjM,SAASqG,iBAAiB,2BAA2B4F;EACrDxO,OAAO4I,iBAAiB,QAAQ2C;;;;;;;EC7P3B,MAAC2F,SAAS;OACV9H;IACC9L;MACF,OAAOU,QAAMX;;IAEXC,UAAOD;MACTW,QAAMvB,MAAMY;;IAEVwC;MACF,OAAOD,UAAUvC;;IAEfwC,cAAWxC;MACbuC,UAAUnD,MAAMY;;;EAIpB2C,OAAOoJ,iBAAiB8H;;;;;;"}
|
1
|
+
{"version":3,"file":"stimulus_reflex.umd.min.js","sources":["../../../javascript/deprecate.js","../../../javascript/debug.js","../../../javascript/schema.js","../../../javascript/utils.js","../../../javascript/reflexes.js","../../../javascript/lifecycle.js","../../../javascript/app.js","../../../javascript/isolation_mode.js","../../../javascript/reflex.js","../../../javascript/process.js","../../../javascript/transports/action_cable.js","../../../javascript/log.js","../../../javascript/attributes.js","../../../javascript/reflex_data.js","../../../javascript/transport.js","../../../javascript/callbacks.js","../../../javascript/controllers.js","../../../javascript/scanner.js","../../../javascript/stimulus_reflex.js","../../../javascript/index.js"],"sourcesContent":["let deprecationWarnings = true\n\nexport default {\n get enabled () {\n return deprecationWarnings\n },\n get disabled () {\n return !deprecationWarnings\n },\n get value () {\n return deprecationWarnings\n },\n set (value) {\n deprecationWarnings = !!value\n },\n set deprecate (value) {\n deprecationWarnings = !!value\n }\n}\n","let debugging = false\n\nexport default {\n get enabled () {\n return debugging\n },\n get disabled () {\n return !debugging\n },\n get value () {\n return debugging\n },\n set (value) {\n debugging = !!value\n },\n set debug (value) {\n debugging = !!value\n }\n}\n","const defaultSchema = {\n reflexAttribute: 'data-reflex',\n reflexPermanentAttribute: 'data-reflex-permanent',\n reflexRootAttribute: 'data-reflex-root',\n reflexSuppressLoggingAttribute: 'data-reflex-suppress-logging',\n reflexDatasetAttribute: 'data-reflex-dataset',\n reflexDatasetAllAttribute: 'data-reflex-dataset-all',\n reflexSerializeFormAttribute: 'data-reflex-serialize-form',\n reflexFormSelectorAttribute: 'data-reflex-form-selector',\n reflexIncludeInnerHtmlAttribute: 'data-reflex-include-inner-html',\n reflexIncludeTextContentAttribute: 'data-reflex-include-text-content'\n}\n\nlet schema = {}\n\nexport { schema, defaultSchema }\n\nexport default {\n set (application) {\n schema = { ...defaultSchema, ...application.schema }\n for (const attribute in schema) {\n const attributeName = attribute.slice(0, -9)\n\n Object.defineProperty(this, attributeName, {\n get: () => {\n return schema[attribute]\n },\n configurable: true\n })\n }\n }\n}\n","import Debug from './debug'\nimport Deprecate from './deprecate'\nimport Schema from './schema'\n\nimport { Utils } from 'cable_ready'\n\nconst { debounce, dispatch, xpathToElement, xpathToElementArray } = Utils\n\n// uuid4 function taken from stackoverflow\n// https://stackoverflow.com/a/2117523/554903\n\nconst uuidv4 = () => {\n const crypto = window.crypto || window.msCrypto\n return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>\n (\n c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))\n ).toString(16)\n )\n}\n\nconst serializeForm = (form, options = {}) => {\n if (!form) return ''\n\n const w = options.w || window\n const { element } = options\n const formData = new w.FormData(form)\n const data = Array.from(formData, e => e.map(encodeURIComponent).join('='))\n const submitButton = form.querySelector('input[type=submit]')\n if (\n element &&\n element.name &&\n element.nodeName === 'INPUT' &&\n element.type === 'submit'\n ) {\n data.push(\n `${encodeURIComponent(element.name)}=${encodeURIComponent(element.value)}`\n )\n } else if (submitButton && submitButton.name) {\n data.push(\n `${encodeURIComponent(submitButton.name)}=${encodeURIComponent(\n submitButton.value\n )}`\n )\n }\n return Array.from(data).join('&')\n}\n\nconst camelize = (value, uppercaseFirstLetter = true) => {\n if (typeof value !== 'string') return ''\n value = value\n .replace(/[\\s_](.)/g, $1 => $1.toUpperCase())\n .replace(/[\\s_]/g, '')\n .replace(/^(.)/, $1 => $1.toLowerCase())\n\n if (uppercaseFirstLetter)\n value = value.substr(0, 1).toUpperCase() + value.substr(1)\n\n return value\n}\n\n// TODO: remove this in v4 (potentially!)\nconst XPathToElement = xpathToElement\nconst XPathToArray = xpathToElementArray\nconst emitEvent = (name, detail = {}) => dispatch(document, name, detail)\n\nconst extractReflexName = reflexString => {\n const match = reflexString.match(/(?:.*->)?(.*?)(?:Reflex)?#/)\n\n return match ? match[1] : ''\n}\n\n// construct a valid xPath for an element in the DOM\nconst elementToXPath = element => {\n if (element.id !== '') return \"//*[@id='\" + element.id + \"']\"\n if (element === document.body) return '/html/body'\n if (element.nodeName === 'HTML') return '/html'\n\n let ix = 0\n const siblings =\n element && element.parentNode ? element.parentNode.childNodes : []\n\n for (var i = 0; i < siblings.length; i++) {\n const sibling = siblings[i]\n if (sibling === element) {\n const computedPath = elementToXPath(element.parentNode)\n const tagName = element.tagName.toLowerCase()\n const ixInc = ix + 1\n return `${computedPath}/${tagName}[${ixInc}]`\n }\n\n if (sibling.nodeType === 1 && sibling.tagName === element.tagName) {\n ix++\n }\n }\n}\n\nconst elementInvalid = element => {\n return (\n element.type === 'number' && element.validity && element.validity.badInput\n )\n}\n\nconst getReflexElement = (args, element) => {\n return args[0] && args[0].nodeType === Node.ELEMENT_NODE\n ? args.shift()\n : element\n}\n\nconst getReflexOptions = args => {\n const options = {}\n // TODO: remove reflexId in v4\n if (\n args[0] &&\n typeof args[0] === 'object' &&\n Object.keys(args[0]).filter(key =>\n [\n 'id',\n 'attrs',\n 'selectors',\n 'reflexId',\n 'resolveLate',\n 'serializeForm',\n 'suppressLogging',\n 'includeInnerHTML',\n 'includeTextContent'\n ].includes(key)\n ).length\n ) {\n const opts = args.shift()\n // TODO: in v4, all promises resolve during finalize stage\n // if they specify resolveLate, console.warn to say that the option will be ignored\n // deprecation warning in 3.5 is not required as it's still required until v4\n Object.keys(opts).forEach(o => {\n // TODO: no need to check for reflexId in v4\n if (o === 'reflexId') {\n if (Deprecate.enabled)\n console.warn('reflexId option will be removed in v4. Use id instead.')\n options['id'] = opts['reflexId']\n } else options[o] = opts[o]\n })\n }\n return options\n}\n\n// compute the DOM element(s) which will be the morph root\n// use the data-reflex-root attribute on the reflex or the controller\n// optional value is a CSS selector(s); comma-separated list\n// order of preference is data-reflex, data-controller, document body (default)\nconst getReflexRoots = element => {\n let list = []\n while (list.length === 0 && element) {\n let reflexRoot = element.getAttribute(Schema.reflexRoot)\n if (reflexRoot) {\n if (reflexRoot.length === 0 && element.id) reflexRoot = `#${element.id}`\n const selectors = reflexRoot.split(',').filter(s => s.trim().length)\n if (Debug.enabled && selectors.length === 0) {\n console.error(\n `No value found for ${Schema.reflexRoot}. Add an #id to the element or provide a value for ${Schema.reflexRoot}.`,\n element\n )\n }\n list = list.concat(selectors.filter(s => document.querySelector(s)))\n }\n element = element.parentElement\n ? element.parentElement.closest(`[${Schema.reflexRoot}]`)\n : null\n }\n return list\n}\n\nexport {\n uuidv4,\n serializeForm,\n camelize,\n debounce,\n dispatch,\n extractReflexName,\n emitEvent,\n elementToXPath,\n XPathToElement,\n XPathToArray,\n elementInvalid,\n getReflexElement,\n getReflexOptions,\n getReflexRoots\n}\n","const stages = [\n 'created',\n 'before',\n 'delivered',\n 'queued',\n 'after',\n 'finalized',\n 'success',\n 'error',\n 'halted',\n 'forbidden'\n]\nlet lastReflex\n\nexport const reflexes = new Proxy(\n {}, // You are standing in an open field west of a white house, with a boarded front door.\n {\n get: function (target, prop) {\n if (stages.includes(prop))\n return Object.fromEntries(\n Object.entries(target).filter(([_, reflex]) => reflex.stage === prop)\n )\n else if (prop === 'last') return lastReflex\n else if (prop === 'all') return target\n return Reflect.get(...arguments)\n },\n set: function (target, prop, value) {\n target[prop] = value\n lastReflex = value\n return true\n }\n }\n)\n","import Debug from './debug'\n\nimport { camelize } from './utils'\nimport { reflexes } from './reflexes'\n\n// lifecycle stages\n// * created (at initialization)\n// * before\n// * delivered\n// * queued\n// * success\n// * error\n// * halted\n// * forbidden\n// * after\n// * finalize\n\n// Invokes a lifecycle method on a StimulusReflex controller.\n// - reflex - the Reflex object\n// - stage - the lifecycle stage\n//\nconst invokeLifecycleMethod = (reflex, stage) => {\n // TODO: v4 reevaluate benefit of naming complexity vs semantic payoff\n const specificLifecycleMethod =\n reflex.controller[\n ['before', 'after', 'finalize'].includes(stage)\n ? `${stage}${camelize(reflex.action)}`\n : `${camelize(reflex.action, false)}${camelize(stage)}`\n ]\n\n const genericLifecycleMethod =\n reflex.controller[\n ['before', 'after', 'finalize'].includes(stage)\n ? `${stage}Reflex`\n : `reflex${camelize(stage)}`\n ]\n\n // TODO: v4 just pass reflex into the lifecycle method\n if (typeof specificLifecycleMethod === 'function') {\n specificLifecycleMethod.call(\n reflex.controller,\n reflex.element,\n reflex.target,\n reflex.error,\n reflex.id,\n reflex.payload\n )\n }\n\n // TODO: v4 just pass reflex into the lifecycle method\n if (typeof genericLifecycleMethod === 'function') {\n genericLifecycleMethod.call(\n reflex.controller,\n reflex.element,\n reflex.target,\n reflex.error,\n reflex.id,\n reflex.payload\n )\n }\n}\n\n// Dispatches a lifecycle event on document\n// - reflex - the Reflex object\n// - stage - the lifecycle stage\n//\nconst dispatchLifecycleEvent = (reflex, stage) => {\n if (!reflex.controller.element.parentElement) {\n if (Debug.enabled && !reflex.warned) {\n console.warn(\n `StimulusReflex was not able execute callbacks or emit events for \"${stage}\" or later life-cycle stages for this Reflex. The StimulusReflex Controller Element is no longer present in the DOM. Could you move the StimulusReflex Controller to an element higher in your DOM?`\n )\n reflex.warned = true\n }\n return\n }\n\n reflex.stage = stage\n reflex.lifecycle.push(stage)\n\n const event = `stimulus-reflex:${stage}`\n const action = `${event}:${reflex.action}`\n // TODO: v4 detail = reflex\n const detail = {\n reflex: reflex.target,\n controller: reflex.controller,\n id: reflex.id,\n element: reflex.element,\n payload: reflex.payload\n }\n const options = { bubbles: true, cancelable: false, detail }\n\n reflex.controller.element.dispatchEvent(new CustomEvent(event, options))\n reflex.controller.element.dispatchEvent(new CustomEvent(action, options))\n\n if (window.jQuery) {\n window.jQuery(reflex.controller.element).trigger(event, detail)\n window.jQuery(reflex.controller.element).trigger(action, detail)\n }\n}\n\ndocument.addEventListener(\n 'stimulus-reflex:before',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'before'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:queued',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'queued'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:delivered',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'delivered'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:success',\n event => {\n const reflex = reflexes[event.detail.id]\n invokeLifecycleMethod(reflex, 'success')\n dispatchLifecycleEvent(reflex, 'after')\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:nothing',\n event => dispatchLifecycleEvent(reflexes[event.detail.id], 'success'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:error',\n event => {\n const reflex = reflexes[event.detail.id]\n invokeLifecycleMethod(reflex, 'error')\n // TODO: v4 remove after events on error; behave like halted and forbidden\n dispatchLifecycleEvent(reflex, 'after')\n },\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:halted',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'halted'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:forbidden',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'forbidden'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:after',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'after'),\n true\n)\n\ndocument.addEventListener(\n 'stimulus-reflex:finalize',\n event => invokeLifecycleMethod(reflexes[event.detail.id], 'finalize'),\n true\n)\n\nexport { dispatchLifecycleEvent }\n","let app = {}\n\nexport default {\n get app () {\n return app\n },\n set (application) {\n app = application\n }\n}\n","import Deprecate from './deprecate'\n\nlet isolationMode = false\n\nexport default {\n get disabled () {\n return !isolationMode\n },\n set (value) {\n isolationMode = value\n if (Deprecate.enabled && !isolationMode) {\n document.addEventListener(\n 'DOMContentLoaded',\n () =>\n console.warn(\n 'Deprecation warning: the next version of StimulusReflex will standardize isolation mode, and the isolate option will be removed.\\nPlease update your applications to assume that every tab will be isolated. Use CableReady operations to broadcast updates to other tabs and users.'\n ),\n { once: true }\n )\n }\n }\n}\n","import Debug from './debug'\nimport Deprecate from './deprecate'\n\nexport default class Reflex {\n constructor (data, controller) {\n this.data = data.valueOf()\n this.controller = controller\n this.element = data.reflexElement\n this.id = data.id\n this.error = null\n this.payload = null\n this.stage = 'created'\n this.lifecycle = ['created']\n this.warned = false\n this.target = data.target\n this.action = data.target.split('#')[1]\n this.selector = null\n this.morph = null\n this.operation = null\n this.timestamp = new Date()\n this.cloned = false // TODO: v4 remove\n }\n\n get getPromise () {\n const promise = new Promise((resolve, reject) => {\n this.promise = {\n resolve,\n reject,\n data: this.data\n }\n })\n promise.id = this.id\n // TODO: v4 remove\n Object.defineProperty(promise, 'reflexId', {\n get () {\n if (Deprecate.enabled)\n console.warn(\n 'reflexId is deprecated and will be removed from v4. Use id instead.'\n )\n return this.id\n }\n })\n // END TODO: v4 remove\n promise.reflex = this\n if (Debug.enabled) promise.catch(() => {})\n return promise\n }\n}\n","import CableReady from 'cable_ready'\n\nimport App from './app'\nimport Debug from './debug'\nimport IsolationMode from './isolation_mode'\nimport Reflex from './reflex'\n\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { reflexes } from './reflexes'\nimport { XPathToElement } from './utils'\n\nexport const received = data => {\n if (!data.cableReady) return\n\n if (data.version.replace('.pre', '-pre') !== CableReady.version) {\n if (Debug.enabled)\n console.error(\n `Reflex failed due to cable_ready gem/NPM package version mismatch. Package versions must match exactly.\\nNote that if you are using pre-release builds, gems use the \"x.y.z.preN\" version format, while NPM packages use \"x.y.z-preN\".\\n\\ncable_ready gem: ${data.version}\\ncable_ready NPM: ${CableReady.version}`\n )\n return\n }\n\n let reflexOperations = []\n\n for (let i = data.operations.length - 1; i >= 0; i--) {\n if (data.operations[i].stimulusReflex) {\n reflexOperations.push(data.operations[i])\n data.operations.splice(i, 1)\n }\n }\n\n if (\n reflexOperations.some(\n operation => operation.stimulusReflex.url !== location.href\n )\n ) {\n if (Debug.enabled) {\n console.error('Reflex failed due to mismatched URL.')\n return\n }\n }\n\n let reflexData\n\n if (reflexOperations.length) {\n reflexData = reflexOperations[0].stimulusReflex\n reflexData.payload = reflexOperations[0].payload\n }\n\n if (reflexData) {\n const { id, payload } = reflexData\n let reflex\n\n // TODO: remove this in v4\n if (!reflexes[id] && IsolationMode.disabled) {\n const controllerElement = XPathToElement(reflexData.xpathController)\n const reflexElement = XPathToElement(reflexData.xpathElement)\n\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n const controller = App.app.getControllerForElementAndIdentifier(\n controllerElement,\n reflexData.reflexController\n )\n\n controllerElement.reflexController[id] = controller\n controllerElement.reflexData[id] = reflexData\n\n reflex = new Reflex(reflexData, controller)\n reflexes[id] = reflex\n reflex.cloned = true\n reflex.element = reflexElement\n controller.lastReflex = reflex\n\n dispatchLifecycleEvent(reflex, 'before')\n reflex.getPromise\n } else {\n // v4 keep this, make it a const\n reflex = reflexes[id]\n }\n // END TODO: remove\n\n if (reflex) {\n reflex.payload = payload\n reflex.totalOperations = reflexOperations.length\n reflex.pendingOperations = reflexOperations.length\n reflex.completedOperations = 0\n reflex.piggybackOperations = data.operations\n CableReady.perform(reflexOperations)\n }\n } else {\n if (data.operations.length && reflexes[data.operations[0].reflexId]) {\n CableReady.perform(data.operations)\n }\n }\n}\n","import Deprecate from '../deprecate'\n\nimport { createConsumer } from '@rails/actioncable'\nimport { dispatchLifecycleEvent } from '../lifecycle'\nimport { emitEvent } from '../utils'\nimport { received } from '../process'\nimport { reflexes } from '../reflexes'\n\nlet consumer\nlet params\nlet subscription\nlet active\n\nconst initialize = (consumerValue, paramsValue) => {\n consumer = consumerValue\n params = paramsValue\n document.addEventListener('DOMContentLoaded', () => {\n active = false\n connectionStatusClass()\n if (Deprecate.enabled && consumerValue)\n console.warn(\n \"Deprecation warning: the next version of StimulusReflex will obtain a reference to consumer via the Stimulus application object.\\nPlease add 'application.consumer = consumer' to your index.js after your Stimulus application has been established, and remove the consumer key from your StimulusReflex initialize() options object.\"\n )\n })\n document.addEventListener('turbolinks:load', connectionStatusClass)\n document.addEventListener('turbo:load', connectionStatusClass)\n}\n\nconst subscribe = controller => {\n if (subscription) return\n consumer = consumer || controller.application.consumer || createConsumer()\n const { channel } = controller.StimulusReflex\n const request = { channel, ...params }\n const identifier = JSON.stringify(request)\n\n subscription =\n consumer.subscriptions.findAll(identifier)[0] ||\n consumer.subscriptions.create(request, {\n received,\n connected,\n rejected,\n disconnected\n })\n}\n\nconst connected = () => {\n active = true\n connectionStatusClass()\n emitEvent('stimulus-reflex:connected')\n Object.values(reflexes.queued).forEach(reflex => {\n subscription.send(reflex.data)\n dispatchLifecycleEvent(reflex, 'delivered')\n })\n}\n\nconst rejected = () => {\n active = false\n connectionStatusClass()\n emitEvent('stimulus-reflex:rejected')\n if (Debug.enabled) console.warn('Channel subscription was rejected.')\n}\n\nconst disconnected = willAttemptReconnect => {\n active = false\n connectionStatusClass()\n emitEvent('stimulus-reflex:disconnected', willAttemptReconnect)\n}\n\nconst deliver = reflex => {\n if (active) {\n subscription.send(reflex.data)\n dispatchLifecycleEvent(reflex, 'delivered')\n } else dispatchLifecycleEvent(reflex, 'queued')\n}\n\nconst connectionStatusClass = () => {\n const list = document.body.classList\n if (\n !(\n list.contains('stimulus-reflex-connected') ||\n list.contains('stimulus-reflex-disconnected')\n )\n ) {\n list.add(\n active ? 'stimulus-reflex-connected' : 'stimulus-reflex-disconnected'\n )\n return\n }\n if (active) {\n list.replace('stimulus-reflex-disconnected', 'stimulus-reflex-connected')\n } else {\n list.replace('stimulus-reflex-connected', 'stimulus-reflex-disconnected')\n }\n}\n\nexport default {\n subscribe,\n deliver,\n initialize\n}\n","import Debug from './debug'\n\nconst request = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(`\\u2191 stimulus \\u2191 ${reflex.target}`, {\n id: reflex.id,\n args: reflex.data.args,\n controller: reflex.controller.identifier,\n element: reflex.element,\n controllerElement: reflex.controller.element\n })\n}\n\nconst success = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n const output = {\n id: reflex.id,\n morph: reflex.morph,\n payload: reflex.payload\n }\n if (reflex.operation !== 'dispatch_event') output.operation = reflex.operation\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} \\u2192 ${reflex.selector ||\n '\\u221E'}${progress(reflex)} ${duration(reflex)}`,\n output\n )\n}\n\nconst halted = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cHALTED`,\n 'color: #ffa500;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst forbidden = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cFORBIDDEN`,\n 'color: #BF40BF;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst error = reflex => {\n if (Debug.disabled || reflex.data.suppressLogging) return\n console.log(\n `\\u2193 reflex \\u2193 ${reflex.target} ${duration(reflex)} %cERROR: ${\n reflex.error\n }`,\n 'color: #f00;',\n { id: reflex.id, payload: reflex.payload }\n )\n}\n\nconst duration = reflex => {\n return !reflex.cloned ? `in ${new Date() - reflex.timestamp}ms` : 'CLONED'\n}\n\nconst progress = reflex => {\n return reflex.totalOperations > 1\n ? ` ${reflex.completedOperations}/${reflex.totalOperations}`\n : ''\n}\n\nexport default { request, success, halted, forbidden, error }\n","import Debug from './debug'\nimport Deprecate from './deprecate'\nimport Schema from './schema'\n\nimport { elementToXPath, XPathToArray } from './utils'\n\nconst multipleInstances = element => {\n if (['checkbox', 'radio'].includes(element.type)) {\n return (\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n ).length > 1\n )\n }\n return false\n}\nconst collectCheckedOptions = element => {\n return Array.from(element.querySelectorAll('option:checked'))\n .concat(\n Array.from(\n document.querySelectorAll(\n `input[type=\"${element.type}\"][name=\"${element.name}\"]`\n )\n ).filter(elem => elem.checked)\n )\n .map(o => o.value)\n}\n\n// Returns a string value for the passed array.\n//\n// attributeValue(['', 'one', null, 'two', 'three ']) // 'one two three'\n//\nconst attributeValue = (values = []) => {\n const value = Array.from(\n new Set(\n values\n .filter(v => v && String(v).length)\n .map(v => v.trim())\n )\n ).join(' ').trim()\n\n return value.length > 0 ? value : null\n}\n\n// Returns an array for the passed string value by splitting on whitespace.\n//\n// attributeValues('one two three ') // ['one', 'two', 'three']\n//\nconst attributeValues = value => {\n if (!value) return []\n if (!value.length) return []\n return value.split(' ').filter(v => v.trim().length)\n}\n\n// Extracts attributes from a DOM element.\n//\nconst extractElementAttributes = element => {\n let attrs = Array.from(element.attributes).reduce((memo, attr) => {\n memo[attr.name] = attr.value\n return memo\n }, {})\n\n attrs.checked = !!element.checked\n attrs.selected = !!element.selected\n attrs.tag_name = element.tagName\n\n if (element.tagName.match(/select/i) || multipleInstances(element)) {\n const collectedOptions = collectCheckedOptions(element)\n attrs.values = collectedOptions\n attrs.value = collectedOptions.join(',')\n } else {\n attrs.value = element.value\n }\n return attrs\n}\n\n// Returns an array of elements for the provided tokens.\n// Tokens is an array of space separated string coming from the `data-reflex-dataset`\n// or `data-reflex-dataset-all` attribute.\n//\nconst getElementsFromTokens = (element, tokens) => {\n if (!tokens || tokens.length === 0) return []\n\n let elements = [element]\n\n const xPath = elementToXPath(element)\n\n tokens.forEach(token => {\n try {\n switch (token) {\n case 'combined':\n if (Deprecate.enabled)\n console.warn(\n \"In the next version of StimulusReflex, the 'combined' option to data-reflex-dataset will become 'ancestors'.\"\n )\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'ancestors':\n elements = [\n ...elements,\n ...XPathToArray(`${xPath}/ancestor::*`, true)\n ]\n break\n case 'parent':\n elements = [...elements, ...XPathToArray(`${xPath}/parent::*`)]\n break\n case 'siblings':\n elements = [\n ...elements,\n ...XPathToArray(\n `${xPath}/preceding-sibling::*|${xPath}/following-sibling::*`\n )\n ]\n break\n case 'children':\n elements = [...elements, ...XPathToArray(`${xPath}/child::*`)]\n break\n case 'descendants':\n elements = [...elements, ...XPathToArray(`${xPath}/descendant::*`)]\n break\n default:\n elements = [...elements, ...document.querySelectorAll(token)]\n }\n } catch (error) {\n if (Debug.enabled) console.error(error)\n }\n })\n\n return elements\n}\n\n// Extracts the dataset of an element and combines it with the data attributes from all specified tokens\n//\nconst extractElementDataset = element => {\n const dataset = element.attributes[Schema.reflexDataset]\n const allDataset = element.attributes[Schema.reflexDatasetAll]\n\n const tokens = (dataset && dataset.value.split(' ')) || []\n const allTokens = (allDataset && allDataset.value.split(' ')) || []\n\n const datasetElements = getElementsFromTokens(element, tokens)\n const datasetAllElements = getElementsFromTokens(element, allTokens)\n\n const datasetAttributes = datasetElements.reduce((acc, ele) => {\n return { ...extractDataAttributes(ele), ...acc }\n }, {})\n\n const reflexElementAttributes = extractDataAttributes(element)\n\n const elementDataset = {\n dataset: { ...reflexElementAttributes, ...datasetAttributes },\n datasetAll: {}\n }\n\n datasetAllElements.forEach(element => {\n const elementAttributes = extractDataAttributes(element)\n\n Object.keys(elementAttributes).forEach(key => {\n const value = elementAttributes[key]\n\n if (\n elementDataset.datasetAll[key] &&\n Array.isArray(elementDataset.datasetAll[key])\n ) {\n elementDataset.datasetAll[key].push(value)\n } else {\n elementDataset.datasetAll[key] = [value]\n }\n })\n })\n\n return elementDataset\n}\n\n// Extracts all data attributes from a DOM element.\n//\nconst extractDataAttributes = element => {\n let attrs = {}\n\n if (element && element.attributes) {\n Array.from(element.attributes).forEach(attr => {\n if (attr.name.startsWith('data-')) {\n attrs[attr.name] = attr.value\n }\n })\n }\n\n return attrs\n}\n\nexport {\n attributeValue,\n attributeValues,\n extractElementAttributes,\n extractElementDataset,\n extractDataAttributes\n}\n","import Schema from './schema'\n\nimport { extractElementAttributes, extractElementDataset } from './attributes'\nimport { uuidv4, getReflexRoots, elementToXPath } from './utils'\n\nimport packageInfo from '../package.json'\n\nexport default class ReflexData {\n constructor (\n options,\n reflexElement,\n controllerElement,\n reflexController,\n permanentAttributeName,\n target,\n args,\n url,\n tabId\n ) {\n this.options = options\n this.reflexElement = reflexElement\n this.controllerElement = controllerElement\n this.reflexController = reflexController\n this.permanentAttributeName = permanentAttributeName\n this.target = target\n this.args = args\n this.url = url\n this.tabId = tabId\n }\n\n get attrs () {\n this._attrs =\n this._attrs ||\n this.options['attrs'] ||\n extractElementAttributes(this.reflexElement)\n\n return this._attrs\n }\n\n get id () {\n this._id = this._id || this.options['id'] || uuidv4()\n return this._id\n }\n\n get selectors () {\n this._selectors =\n this._selectors ||\n this.options['selectors'] ||\n getReflexRoots(this.reflexElement)\n\n return typeof this._selectors === 'string'\n ? [this._selectors]\n : this._selectors\n }\n\n // TODO: v4 always resolve late\n get resolveLate () {\n return this.options['resolveLate'] || false\n }\n\n get dataset () {\n this._dataset = this._dataset || extractElementDataset(this.reflexElement)\n return this._dataset\n }\n\n get innerHTML () {\n return this.includeInnerHtml ? this.reflexElement.innerHTML : ''\n }\n\n get textContent () {\n return this.includeTextContent ? this.reflexElement.textContent : ''\n }\n\n // TODO: remove this in v4\n get xpathController () {\n return elementToXPath(this.controllerElement)\n }\n\n get xpathElement () {\n return elementToXPath(this.reflexElement)\n }\n // END TODO remove\n\n get formSelector () {\n const attr = this.reflexElement.attributes[Schema.reflexFormSelector]\n ? this.reflexElement.attributes[Schema.reflexFormSelector].value\n : undefined\n return this.options['formSelector'] || attr\n }\n\n get includeInnerHtml () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeInnerHtml] || false\n return this.options['includeInnerHTML'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get includeTextContent () {\n const attr =\n this.reflexElement.attributes[Schema.reflexIncludeTextContent] || false\n return this.options['includeTextContent'] || attr\n ? attr.value !== 'false'\n : false\n }\n\n get suppressLogging () {\n return (\n this.options['suppressLogging'] ||\n this.reflexElement.attributes[Schema.reflexSuppressLogging] ||\n false\n )\n }\n\n valueOf () {\n return {\n attrs: this.attrs,\n dataset: this.dataset,\n selectors: this.selectors,\n id: this.id,\n resolveLate: this.resolveLate,\n suppressLogging: this.suppressLogging,\n xpathController: this.xpathController,\n xpathElement: this.xpathElement,\n inner_html: this.innerHTML,\n text_content: this.textContent,\n formSelector: this.formSelector,\n reflexController: this.reflexController,\n permanentAttributeName: this.permanentAttributeName,\n target: this.target,\n args: this.args,\n url: this.url,\n tabId: this.tabId,\n version: packageInfo.version\n }\n }\n}\n","let transport = {}\n\nexport default {\n get plugin () {\n return transport\n },\n set (newTransport) {\n transport = newTransport\n }\n}\n","import CableReady from 'cable_ready'\n\nimport Log from './log'\n\nimport { reflexes } from './reflexes'\nimport { dispatchLifecycleEvent } from './lifecycle'\n\nconst beforeDOMUpdate = event => {\n const { stimulusReflex } = event.detail || {}\n if (!stimulusReflex) return\n const reflex = reflexes[stimulusReflex.id]\n\n reflex.pendingOperations--\n\n if (reflex.pendingOperations > 0) return\n\n // TODO: remove in v4 - always resolve late\n if (!stimulusReflex.resolveLate)\n setTimeout(() =>\n reflex.promise.resolve({\n element: reflex.element,\n event,\n data: reflex.data,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n // END TODO: remove\n\n setTimeout(() => dispatchLifecycleEvent(reflex, 'success'))\n}\n\nconst afterDOMUpdate = event => {\n const { stimulusReflex } = event.detail || {}\n if (!stimulusReflex) return\n const reflex = reflexes[stimulusReflex.id]\n\n reflex.completedOperations++\n reflex.selector = event.detail.selector\n reflex.morph = event.detail.stimulusReflex.morph\n reflex.operation = event.type\n .split(':')[1]\n .split('-')\n .slice(1)\n .join('_')\n\n Log.success(reflex)\n\n if (reflex.completedOperations < reflex.totalOperations) return\n\n // TODO: v4 always resolve late (remove if)\n // TODO: v4 simplify to {reflex, toString}\n if (stimulusReflex.resolveLate)\n setTimeout(() =>\n reflex.promise.resolve({\n element: reflex.element,\n event,\n data: reflex.data,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n\n setTimeout(() => dispatchLifecycleEvent(reflex, 'finalize'))\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst routeReflexEvent = event => {\n const { stimulusReflex, name } = event.detail || {}\n const eventType = name.split('-')[2]\n\n const eventTypes = { nothing, halted, forbidden, error }\n\n if (!stimulusReflex || !Object.keys(eventTypes).includes(eventType)) return\n\n const reflex = reflexes[stimulusReflex.id]\n reflex.completedOperations++\n reflex.pendingOperations--\n reflex.selector = event.detail.selector\n reflex.morph = event.detail.stimulusReflex.morph\n reflex.operation = event.type\n .split(':')[1]\n .split('-')\n .slice(1)\n .join('_')\n if (eventType === 'error') reflex.error = event.detail.error\n\n eventTypes[eventType](reflex, event)\n\n setTimeout(() => dispatchLifecycleEvent(reflex, eventType))\n\n if (reflex.piggybackOperations.length)\n CableReady.perform(reflex.piggybackOperations)\n}\n\nconst nothing = (reflex, event) => {\n Log.success(reflex)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst halted = (reflex, event) => {\n Log.halted(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst forbidden = (reflex, event) => {\n Log.forbidden(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n setTimeout(() =>\n reflex.promise.resolve({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n toString: () => ''\n })\n )\n}\n\nconst error = (reflex, event) => {\n Log.error(reflex, event)\n\n // TODO: v4 simplify to {reflex, toString}\n // TODO: v4 convert to resolve?\n setTimeout(() =>\n reflex.promise.reject({\n data: reflex.data,\n element: reflex.element,\n event,\n payload: reflex.payload,\n id: reflex.id,\n error: reflex.error,\n toString: () => reflex.error\n })\n )\n}\n\nexport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent }\n","import App from './app'\nimport Schema from './schema'\n\nimport { attributeValues } from './attributes'\nimport { extractReflexName } from './utils'\n\n// Returns StimulusReflex controllers local to the passed element based on the data-controller attribute.\n//\nconst localReflexControllers = element => {\n return attributeValues(element.getAttribute(Schema.controller)).reduce(\n (memo, name) => {\n const controller = App.app.getControllerForElementAndIdentifier(\n element,\n name\n )\n if (controller && controller.StimulusReflex) memo.push(controller)\n return memo\n },\n []\n )\n}\n\n// Returns all StimulusReflex controllers for the passed element.\n// Traverses DOM ancestors starting with element.\n//\nconst allReflexControllers = element => {\n let controllers = []\n while (element) {\n controllers = controllers.concat(localReflexControllers(element))\n element = element.parentElement\n }\n return controllers\n}\n\n// Given a reflex string such as 'click->TestReflex#create' and a list of\n// controllers. It will find the matching controller based on the controller's\n// identifier. e.g. Given these controller identifiers ['foo', 'bar', 'test'],\n// it would select the 'test' controller.\nconst findControllerByReflexName = (reflexName, controllers) => {\n const controller = controllers.find(controller => {\n if (!controller.identifier) return\n\n return (\n extractReflexName(reflexName)\n .replace(/([a-z0–9])([A-Z])/g, '$1-$2')\n .replace(/(::)/g, '--')\n .toLowerCase() === controller.identifier\n )\n })\n\n return controller || controllers[0]\n}\n\nexport { allReflexControllers, findControllerByReflexName }\n","import Schema from './schema'\n\nimport { attributeValues, attributeValue } from './attributes'\nimport { debounce, dispatch } from './utils'\nimport { findControllerByReflexName, allReflexControllers } from './controllers'\nimport { reflexes } from './reflexes'\n\n// Sets up declarative reflex behavior.\n// Any elements that define data-reflex will automatically be wired up with the default StimulusReflexController.\n//\nconst scanForReflexes = debounce(() => {\n const reflexElements = document.querySelectorAll(`[${Schema.reflex}]`)\n reflexElements.forEach(element => scanForReflexesOnElement(element))\n}, 20)\n\nconst scanForReflexesOnElement = element => {\n const controllerAttribute = element.getAttribute(Schema.controller)\n const controllers = attributeValues(controllerAttribute)\n\n const reflexAttribute = element.getAttribute(Schema.reflex)\n const reflexAttributeNames = attributeValues(reflexAttribute)\n\n const actionAttribute = element.getAttribute(Schema.action)\n const actions = attributeValues(actionAttribute).filter(\n action => !action.includes('#__perform')\n )\n\n reflexAttributeNames.forEach(reflexName => {\n const controller = findControllerByReflexName(\n reflexName,\n allReflexControllers(element)\n )\n const controllerName = controller\n ? controller.identifier\n : 'stimulus-reflex'\n\n actions.push(`${reflexName.split('->')[0]}->${controllerName}#__perform`)\n controllers.push(controllerName)\n })\n\n const controllerValue = attributeValue(controllers)\n const actionValue = attributeValue(actions)\n\n let emitReadyEvent = false\n\n if (\n controllerValue &&\n element.getAttribute(Schema.controller) != controllerValue\n ) {\n element.setAttribute(Schema.controller, controllerValue)\n emitReadyEvent = true\n }\n\n if (actionValue && element.getAttribute(Schema.action) != actionValue) {\n element.setAttribute(Schema.action, actionValue)\n emitReadyEvent = true\n }\n\n if (emitReadyEvent) {\n dispatch(element, 'stimulus-reflex:ready', {\n reflex: reflexAttribute,\n controller: controllerValue,\n action: actionValue,\n element\n })\n }\n}\nexport { scanForReflexes, scanForReflexesOnElement }\n","import { Controller } from '@hotwired/stimulus'\n\nimport ActionCableTransport from './transports/action_cable'\nimport App from './app'\nimport Debug from './debug'\nimport Deprecate from './deprecate'\nimport IsolationMode from './isolation_mode'\nimport Log from './log'\nimport Reflex from './reflex'\nimport ReflexData from './reflex_data'\nimport Schema from './schema'\nimport Transport from './transport'\n\nimport { attributeValues } from './attributes'\nimport { beforeDOMUpdate, afterDOMUpdate, routeReflexEvent } from './callbacks'\nimport { dispatchLifecycleEvent } from './lifecycle'\nimport { reflexes } from './reflexes'\nimport { scanForReflexes, scanForReflexesOnElement } from './scanner'\n\nimport {\n uuidv4,\n serializeForm,\n elementInvalid,\n getReflexElement,\n getReflexOptions,\n emitEvent\n} from './utils'\n\n// Default StimulusReflexController that is implicitly wired up as data-controller for any DOM elements\n// that have configured data-reflex. Note that this default can be overridden when initializing the application.\n// i.e. StimulusReflex.initialize(myStimulusApplication, MyCustomDefaultController)\n//\nclass StimulusReflexController extends Controller {\n constructor (...args) {\n super(...args)\n register(this)\n }\n}\n\n// Uniquely identify this browser tab in each Reflex\nconst tabId = uuidv4()\n\n// Initializes StimulusReflex by registering the default Stimulus controller with the passed Stimulus application.\n//\n// - application - the Stimulus application\n// - options\n// * controller - [optional] the default StimulusReflexController\n// * consumer - [optional] the ActionCable consumer\n// * debug - [false] log all Reflexes to the console\n// * params - [{}] key/value parameters to send during channel subscription\n// * isolate - [false] restrict Reflex playback to the tab which initiated it\n// * deprecate - [true] show warnings regarding upcoming changes to the library\n// * transport - [optional] defaults to ActionCableTransport\n//\nconst initialize = (\n application,\n { controller, consumer, debug, params, isolate, deprecate, transport } = {}\n) => {\n Transport.set(transport || ActionCableTransport)\n Transport.plugin.initialize(consumer, params)\n IsolationMode.set(!!isolate)\n App.set(application)\n Schema.set(application)\n App.app.register(\n 'stimulus-reflex',\n controller || StimulusReflexController\n )\n Debug.set(!!debug)\n if (typeof deprecate !== 'undefined') Deprecate.set(deprecate)\n const observer = new MutationObserver(scanForReflexes)\n observer.observe(document.documentElement, {\n attributeFilter: [Schema.reflex, Schema.action],\n childList: true,\n subtree: true\n })\n emitEvent('stimulus-reflex:initialized')\n}\n\n// Registers a Stimulus controller and extends it with StimulusReflex behavior\n//\n// controller - the Stimulus controller\n// options - [optional] configuration\n//\nconst register = (controller, options = {}) => {\n const channel = 'StimulusReflex::Channel'\n controller.StimulusReflex = { ...options, channel }\n Transport.plugin.subscribe(controller)\n Object.assign(controller, {\n // Invokes a server side reflex method.\n //\n // - target - the reflex target (full name of the server side reflex) i.e. 'ReflexClassName#method'\n // - reflexElement - [optional] the element that triggered the reflex, defaults to this.element\n // - options - [optional] an object that contains at least one of attrs, id, selectors, resolveLate, serializeForm\n // - *args - remaining arguments are forwarded to the server side reflex method\n //\n stimulate () {\n const url = location.href\n const controllerElement = this.element\n const args = Array.from(arguments)\n const target = args.shift() || 'StimulusReflex::Reflex#default_reflex'\n const reflexElement = getReflexElement(args, controllerElement)\n\n if (elementInvalid(reflexElement)) {\n if (Debug.enabled) console.warn('Reflex aborted: invalid numeric input')\n return\n }\n\n const options = getReflexOptions(args)\n\n const reflexData = new ReflexData(\n options,\n reflexElement,\n controllerElement,\n this.identifier,\n Schema.reflexPermanent,\n target,\n args,\n url,\n tabId\n )\n\n const id = reflexData.id\n\n // TODO: remove this in v4\n controllerElement.reflexController =\n controllerElement.reflexController || {}\n controllerElement.reflexData = controllerElement.reflexData || {}\n controllerElement.reflexError = controllerElement.reflexError || {}\n\n controllerElement.reflexController[id] = this\n controllerElement.reflexData[id] = reflexData.valueOf()\n // END TODO: remove\n\n const reflex = new Reflex(reflexData, this)\n reflexes[id] = reflex\n this.lastReflex = reflex\n\n dispatchLifecycleEvent(reflex, 'before')\n\n setTimeout(() => {\n // TODO: in v4, params will be set on the reflex.data object\n const { params } = controllerElement.reflexData[id] || {}\n\n const check = reflexElement.attributes[Schema.reflexSerializeForm]\n if (check) {\n options['serializeForm'] = check.value !== 'false'\n }\n\n const form =\n reflexElement.closest(reflexData.formSelector) ||\n document.querySelector(reflexData.formSelector) ||\n reflexElement.closest('form')\n\n // TODO: remove this in v4\n if (Deprecate.enabled && options['serializeForm'] === undefined && form)\n console.warn(\n `Deprecation warning: the next version of StimulusReflex will not serialize forms by default.\\nPlease set ${Schema.reflexSerializeForm}=\\\"true\\\" on your Reflex Controller Element or pass { serializeForm: true } as an option to stimulate.`\n )\n // END TODO: remove\n\n const formData =\n options['serializeForm'] === false\n ? ''\n : serializeForm(form, {\n element: reflexElement\n })\n\n reflex.data = {\n ...reflexData.valueOf(),\n params,\n formData\n }\n\n // TODO: remove this in v4\n controllerElement.reflexData[id] = reflex.data\n // END TODO: remove\n\n Transport.plugin.deliver(reflex)\n })\n\n Log.request(reflex)\n\n return reflex.getPromise\n },\n\n // Wraps the call to stimulate for any data-reflex elements.\n // This is internal and should not be invoked directly.\n __perform (event) {\n let element = event.target\n let reflex\n\n while (element && !reflex) {\n reflex = element.getAttribute(Schema.reflex)\n if (!reflex || !reflex.trim().length) element = element.parentElement\n }\n\n const match = attributeValues(reflex).find(\n reflex => reflex.split('->')[0] === event.type\n )\n\n if (match) {\n event.preventDefault()\n event.stopPropagation()\n this.stimulate(match.split('->')[1], element)\n }\n }\n })\n\n // Access the reflexes created by the current controller instance\n // reflexes is a Proxy to an object, keyed by id\n // this.reflexes.all and this.reflexes.last are scoped to this controller instance\n // Reflexes can also be scoped by stage eg. this.reflexes.queued\n if (!controller.reflexes)\n Object.defineProperty(controller, 'reflexes', {\n get () {\n return new Proxy(reflexes, {\n get: function (target, prop) {\n if (prop === 'last') return this.lastReflex\n return Object.fromEntries(\n Object.entries(target[prop]).filter(\n ([_, reflex]) => reflex.controller === this\n )\n )\n }.bind(this)\n })\n }\n })\n\n scanForReflexesOnElement(controller.element)\n\n emitEvent('stimulus-reflex:controller-registered', { detail: { controller } })\n}\n\nconst useReflex = (controller, options = {}) => {\n register(controller, options)\n}\n\ndocument.addEventListener('cable-ready:after-dispatch-event', routeReflexEvent)\ndocument.addEventListener('cable-ready:before-inner-html', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:before-morph', beforeDOMUpdate)\ndocument.addEventListener('cable-ready:after-inner-html', afterDOMUpdate)\ndocument.addEventListener('cable-ready:after-morph', afterDOMUpdate)\ndocument.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n scanForReflexes()\n }\n})\n\nexport {\n initialize,\n register,\n useReflex,\n reflexes,\n scanForReflexes,\n scanForReflexesOnElement\n}\n","export * from './stimulus_reflex'\n\nimport * as StimulusReflex from './stimulus_reflex'\n\nimport Debug from './debug'\nimport Deprecate from './deprecate'\n\nimport packageInfo from '../package.json'\n\nconst global = {\n version: packageInfo.version,\n ...StimulusReflex,\n get debug () {\n return Debug.value\n },\n set debug (value) {\n Debug.set(!!value)\n },\n get deprecate () {\n return Deprecate.value\n },\n set deprecate (value) {\n Deprecate.set(!!value)\n }\n}\n\nwindow.StimulusReflex = global\n\nexport default global\n"],"names":["deprecationWarnings","Deprecate","enabled","disabled","value","set","deprecate","debugging","Debug$1","debug","defaultSchema","reflexAttribute","reflexPermanentAttribute","reflexRootAttribute","reflexSuppressLoggingAttribute","reflexDatasetAttribute","reflexDatasetAllAttribute","reflexSerializeFormAttribute","reflexFormSelectorAttribute","reflexIncludeInnerHtmlAttribute","reflexIncludeTextContentAttribute","schema","Schema","application","attribute","attributeName","slice","Object","defineProperty","this","get","configurable","debounce","dispatch","xpathToElement","xpathToElementArray","Utils","uuidv4","crypto","window","msCrypto","replace","c","getRandomValues","Uint8Array","toString","serializeForm","form","options","w","element","formData","FormData","data","Array","from","e","map","encodeURIComponent","join","submitButton","querySelector","name","nodeName","type","push","camelize","uppercaseFirstLetter","$1","toUpperCase","toLowerCase","substr","XPathToElement","XPathToArray","emitEvent","detail","document","extractReflexName","reflexString","match","elementToXPath","id","body","ix","siblings","parentNode","childNodes","i","length","sibling","computedPath","tagName","ixInc","nodeType","elementInvalid","validity","badInput","getReflexElement","args","Node","ELEMENT_NODE","shift","getReflexOptions","keys","filter","key","includes","opts","forEach","o","console","warn","getReflexRoots","list","reflexRoot","getAttribute","selectors","split","s","trim","Debug","error","concat","parentElement","closest","stages","lastReflex","reflexes","Proxy","target","prop","fromEntries","entries","_","reflex","stage","Reflect","arguments","invokeLifecycleMethod","specificLifecycleMethod","controller","action","genericLifecycleMethod","call","payload","dispatchLifecycleEvent","warned","lifecycle","event","bubbles","cancelable","dispatchEvent","CustomEvent","jQuery","trigger","addEventListener","app","App","isolationMode","IsolationMode","once","Reflex","constructor","valueOf","reflexElement","selector","morph","operation","timestamp","Date","cloned","getPromise","promise","Promise","resolve","reject","catch","received","cableReady","version","CableReady","reflexOperations","operations","stimulusReflex","splice","some","url","location","href","reflexData","controllerElement","xpathController","xpathElement","reflexController","reflexError","getControllerForElementAndIdentifier","totalOperations","pendingOperations","completedOperations","piggybackOperations","perform","reflexId","consumer","params","subscription","active","initialize","consumerValue","paramsValue","connectionStatusClass","subscribe","createConsumer","channel","StimulusReflex","request","identifier","JSON","stringify","subscriptions","findAll","create","connected","rejected","disconnected","values","queued","send","willAttemptReconnect","deliver","classList","contains","add","ActionCableTransport","suppressLogging","log","success","output","progress","duration","halted","forbidden","Log","multipleInstances","querySelectorAll","collectCheckedOptions","elem","checked","attributeValue","Set","v","String","attributeValues","extractElementAttributes","attrs","attributes","reduce","memo","attr","selected","tag_name","collectedOptions","getElementsFromTokens","tokens","elements","xPath","token","extractElementDataset","dataset","reflexDataset","allDataset","reflexDatasetAll","allTokens","datasetElements","datasetAllElements","datasetAttributes","acc","ele","extractDataAttributes","reflexElementAttributes","elementDataset","datasetAll","elementAttributes","isArray","startsWith","ReflexData","permanentAttributeName","tabId","_attrs","_id","_selectors","resolveLate","_dataset","innerHTML","includeInnerHtml","textContent","includeTextContent","formSelector","reflexFormSelector","undefined","reflexIncludeInnerHtml","reflexIncludeTextContent","reflexSuppressLogging","inner_html","text_content","packageInfo","transport","Transport","plugin","newTransport","beforeDOMUpdate","setTimeout","afterDOMUpdate","routeReflexEvent","eventType","eventTypes","nothing","localReflexControllers","allReflexControllers","controllers","findControllerByReflexName","reflexName","find","scanForReflexes","reflexElements","scanForReflexesOnElement","controllerAttribute","reflexAttributeNames","actionAttribute","actions","controllerName","controllerValue","actionValue","emitReadyEvent","setAttribute","StimulusReflexController","Controller","super","register","isolate","observer","MutationObserver","observe","documentElement","attributeFilter","childList","subtree","assign","stimulate","reflexPermanent","check","reflexSerializeForm","__perform","preventDefault","stopPropagation","bind","useReflex","readyState","global"],"mappings":";;;;;EAAA,IAAIA,sBAAsB;EAEX,IAAAC,YAAA;IACTC;MACF,OAAOF;AACR;IACGG;MACF,QAAQH;AACT;IACGI;MACF,OAAOJ;AACR;IACDK,IAAKD;MACHJ,wBAAwBI;AACzB;IACGE,cAAWF;MACbJ,wBAAwBI;AACzB;;ECjBH,IAAIG,YAAY;EAED,IAAAC,UAAA;IACTN;MACF,OAAOK;AACR;IACGJ;MACF,QAAQI;AACT;IACGH;MACF,OAAOG;AACR;IACDF,IAAKD;MACHG,cAAcH;AACf;IACGK,UAAOL;MACTG,cAAcH;AACf;;ECjBH,MAAMM,gBAAgB;IACpBC,iBAAiB;IACjBC,0BAA0B;IAC1BC,qBAAqB;IACrBC,gCAAgC;IAChCC,wBAAwB;IACxBC,2BAA2B;IAC3BC,8BAA8B;IAC9BC,6BAA6B;IAC7BC,iCAAiC;IACjCC,mCAAmC;;EAGrC,IAAIC,SAAS,CAAE;EAIA,IAAAC,SAAA;IACbjB,IAAKkB;MACHF,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,UAAUG;AAClB;IACGE,cAAWF;MACbH,UAAUI,MAAMD;AACjB;;EAGHmC,OAAO8K,iBAAiBgJ;;;;;;;;;;;"}
|
@@ -4,7 +4,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
4
4
|
attr_reader :reflex_data
|
5
5
|
|
6
6
|
def stream_name
|
7
|
-
[params[:channel], connection.connection_identifier].join(":")
|
7
|
+
[params[:channel], connection.connection_identifier].reject(&:blank?).join(":")
|
8
8
|
end
|
9
9
|
|
10
10
|
def subscribed
|
@@ -25,7 +25,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
25
25
|
if reflex
|
26
26
|
reflex.rescue_with_handler(exception)
|
27
27
|
reflex.logger&.error error_message
|
28
|
-
reflex.
|
28
|
+
reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
|
29
29
|
else
|
30
30
|
if exception.is_a? StimulusReflex::Reflex::VersionMismatchError
|
31
31
|
mismatch = "Reflex failed due to stimulus_reflex gem/NPM package version mismatch. Package versions must match exactly.\nNote that if you are using pre-release builds, gems use the \"x.y.z.preN\" version format, while NPM packages use \"x.y.z-preN\".\n\nstimulus_reflex gem: #{StimulusReflex::VERSION}\nstimulus_reflex NPM: #{data["version"]}"
|
@@ -36,7 +36,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
36
36
|
CableReady::Channels.instance[stream_name].console_log(
|
37
37
|
message: mismatch,
|
38
38
|
level: "error",
|
39
|
-
|
39
|
+
id: data["id"]
|
40
40
|
).broadcast
|
41
41
|
end
|
42
42
|
|
@@ -48,7 +48,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
48
48
|
StimulusReflex.config.logger.error error_message
|
49
49
|
end
|
50
50
|
|
51
|
-
if
|
51
|
+
if error_message.to_s.include? "No route matches"
|
52
52
|
initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb")
|
53
53
|
|
54
54
|
StimulusReflex.config.logger.warn <<~NOTE
|
@@ -73,14 +73,16 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
73
73
|
end
|
74
74
|
|
75
75
|
if reflex.halted?
|
76
|
-
reflex.
|
76
|
+
reflex.broadcast_halt data: data
|
77
|
+
elsif reflex.forbidden?
|
78
|
+
reflex.broadcast_forbid data: data
|
77
79
|
else
|
78
80
|
begin
|
79
81
|
reflex.broadcast(reflex_data.selectors, data)
|
80
82
|
rescue => exception
|
81
83
|
reflex.rescue_with_handler(exception)
|
82
84
|
error = exception_with_backtrace(exception)
|
83
|
-
reflex.
|
85
|
+
reflex.broadcast_error data: data, error: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}"
|
84
86
|
reflex.logger&.error "\e[31mReflex failed to re-render: #{error[:message]} [#{reflex_data.url}]\e[0m\n#{error[:stack]}"
|
85
87
|
end
|
86
88
|
end
|
@@ -112,7 +114,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
|
|
112
114
|
end
|
113
115
|
|
114
116
|
def commit_session(reflex)
|
115
|
-
store = reflex.request.session.instance_variable_get(
|
117
|
+
store = reflex.request.session.instance_variable_get(:@by)
|
116
118
|
store.commit_session reflex.request, reflex.controller.response
|
117
119
|
rescue => exception
|
118
120
|
error = exception_with_backtrace(exception)
|
data/bin/console
CHANGED
data/bin/standardize
CHANGED
@@ -1,27 +1,92 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
|
+
require "stimulus_reflex/version"
|
4
5
|
|
5
6
|
class StimulusReflexGenerator < Rails::Generators::NamedBase
|
6
7
|
source_root File.expand_path("templates", __dir__)
|
7
8
|
|
8
9
|
argument :name, type: :string, required: true, banner: "NAME"
|
9
10
|
argument :actions, type: :array, default: [], banner: "action action"
|
10
|
-
class_options skip_stimulus: false,
|
11
|
+
class_options skip_stimulus: false, skip_reflex: false
|
11
12
|
|
12
13
|
def execute
|
13
14
|
actions.map!(&:underscore)
|
14
15
|
|
15
|
-
|
16
|
+
cached_entrypoint = Rails.root.join("tmp/stimulus_reflex_installer/entrypoint")
|
17
|
+
if cached_entrypoint.exist?
|
18
|
+
entrypoint = File.read(cached_entrypoint)
|
19
|
+
else
|
20
|
+
entrypoint = [
|
21
|
+
Rails.root.join("app/javascript"),
|
22
|
+
Rails.root.join("app/frontend")
|
23
|
+
].find(&:exist?) || "app/javascript"
|
24
|
+
puts "Where do JavaScript files live in your app? Our best guess is: \e[1#{entrypoint}\e[22m 🤔"
|
25
|
+
puts "Press enter to accept this, or type a different path."
|
26
|
+
print "> "
|
27
|
+
input = Rails.env.test? ? "tmp/app/javascript" : $stdin.gets.chomp
|
28
|
+
entrypoint = input unless input.blank?
|
29
|
+
end
|
16
30
|
|
17
|
-
|
18
|
-
|
31
|
+
if !options[:skip_stimulus] && entrypoint.blank?
|
32
|
+
puts "❌ You must specify a valid JavaScript entrypoint."
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
reflex_entrypoint = Rails.env.test? ? "tmp/app/reflexes" : "app/reflexes"
|
37
|
+
reflex_src = fetch("/app/reflexes/%file_name%_reflex.rb.tt")
|
38
|
+
reflex_path = Rails.root.join(reflex_entrypoint, "#{file_name}_reflex.rb")
|
39
|
+
stimulus_controller_src = fetch("/app/javascript/controllers/%file_name%_controller.js.tt")
|
40
|
+
stimulus_controller_path = Rails.root.join(entrypoint, "controllers/#{file_name}_controller.js")
|
41
|
+
|
42
|
+
template(reflex_src, reflex_path) unless options[:skip_reflex]
|
43
|
+
template(stimulus_controller_src, stimulus_controller_path) unless options[:skip_stimulus]
|
44
|
+
|
45
|
+
if file_name == "example"
|
46
|
+
controller_src = fetch("/app/controllers/examples_controller.rb.tt")
|
47
|
+
controller_path = Rails.root.join("app/controllers/examples_controller.rb")
|
48
|
+
template(controller_src, controller_path)
|
49
|
+
|
50
|
+
view_src = fetch("/app/views/examples/show.html.erb.tt")
|
51
|
+
view_path = Rails.root.join("app/views/examples/show.html.erb")
|
52
|
+
template(view_src, view_path)
|
53
|
+
|
54
|
+
example_path = Rails.root.join("app/views/examples")
|
55
|
+
FileUtils.remove_dir(example_path) if behavior == :revoke && example_path.exist? && Dir.empty?(example_path)
|
56
|
+
|
57
|
+
route "resource :example, constraints: -> { Rails.env.development? }"
|
58
|
+
|
59
|
+
importmap_path = Rails.root.join("config/importmap.rb")
|
60
|
+
|
61
|
+
if importmap_path.exist?
|
62
|
+
importmap = importmap_path.read
|
63
|
+
|
64
|
+
if behavior == :revoke
|
65
|
+
if importmap.include?("pin \"fireworks-js\"")
|
66
|
+
importmap_path.write importmap_path.readlines.reject { |line| line.include?("pin \"fireworks-js\"") }.join
|
67
|
+
say "✅ unpin fireworks-js"
|
68
|
+
else
|
69
|
+
say "⏩ fireworks-js not pinned. Skipping."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if behavior == :invoke
|
74
|
+
if importmap.include?("pin \"fireworks-js\"")
|
75
|
+
say "⏩ fireworks-js already pinnned. Skipping."
|
76
|
+
else
|
77
|
+
append_file(importmap_path, <<~RUBY, verbose: false)
|
78
|
+
pin "fireworks-js", to: "https://ga.jspm.io/npm:fireworks-js@2.10.0/dist/index.es.js"
|
79
|
+
RUBY
|
80
|
+
say "✅ pin fireworks-js"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
19
85
|
end
|
20
86
|
|
21
87
|
private
|
22
88
|
|
23
|
-
def
|
24
|
-
|
25
|
-
template "app/javascript/controllers/application_controller.js" unless options[:skip_app_controller]
|
89
|
+
def fetch(file)
|
90
|
+
source_paths.first + file
|
26
91
|
end
|
27
92
|
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
|
3
|
+
|
4
|
+
import { createConsumer } from '@rails/actioncable'
|
5
|
+
|
6
|
+
export default createConsumer()
|