stimulus_reflex 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eafcc20ac3e52f7df87a43ace490956ff04c6573d29cf33c04d6128202e873d1
4
- data.tar.gz: d49badd9f76377e244cca6a0d8213d88b0d6579f8395c4b0d67b2f68e475175b
3
+ metadata.gz: e0e5a4e0d71636f235fdc87871ffd54abf12c64ef3d605c5ec017897aeaba7e0
4
+ data.tar.gz: e586d0ea4343c7f51515be03057b1cc79957d74a78bf4fafd25c7ecc4a681f90
5
5
  SHA512:
6
- metadata.gz: f961b93069bfd17769e653dc97c17911f96783e425518de6b1f11fe7d9e153e931814150e26bad112654292a8f9688d12afd7ff0607652f389c4bf780ef6cf45
7
- data.tar.gz: ee757e45a4156352db7065fdc0ee9e6eec4571730affcce66c7977ece227dcd753185b95e017a112e95d87808ef035192fb9cec60a1f9e62fb9fd7979aecdaaf
6
+ metadata.gz: b4502921913aa6cb4f6c1965eb7c4bc46a679ec05f7f6bb335a614dff35b7146adafc8a8bec5849e4c90a55f743f89800b2b5e3fd606968af9994dc1ea65354d
7
+ data.tar.gz: c2ae02d43868739ec914960e22adec6d33ce301ebc1423eedaffc2a50810415e0432b65ae80ea3252b69cce9653739a20fde49b704c51d360e19b5fb2b54c3b9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (0.1.1)
4
+ stimulus_reflex (0.1.2)
5
5
  actioncable (>= 5.2.1)
6
6
  actionpack (>= 5.2.1)
7
7
  cable_ready (>= 2.0.5)
@@ -34,7 +34,7 @@ GEM
34
34
  minitest (~> 5.1)
35
35
  tzinfo (~> 1.1)
36
36
  builder (3.2.3)
37
- cable_ready (2.0.5)
37
+ cable_ready (2.0.6)
38
38
  activesupport (>= 5.0.0)
39
39
  concurrent-ruby (1.0.5)
40
40
  crass (1.0.4)
data/README.md CHANGED
@@ -1,7 +1,14 @@
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-128-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
+
1
3
  # StimulusReflex
2
4
 
3
5
  #### Server side reactive behavior for Stimulus controllers
4
6
 
7
+ ## TODO
8
+
9
+ - [ ] Allow Ruby channels to override the stream_name
10
+ - [ ] Support send without render
11
+
5
12
  ## Usage
6
13
 
7
14
  ```ruby
@@ -15,7 +22,20 @@ gem "stimulus_reflex"
15
22
  //= require stimulus_reflex
16
23
  ```
17
24
 
25
+ ```javascript
26
+ // javascript/controllers/example.js
27
+ import { Controller } from "stimulus"
18
28
 
29
+ export default class extends Controller {
30
+ initialize() {
31
+ StimulusReflex.register(this);
32
+ }
33
+
34
+ doStuff() {
35
+ send('Example#do_stuff', arg1, arg2, ...);
36
+ }
37
+ }
38
+ ```
19
39
 
20
40
 
21
41
  ## JavaScript Development
@@ -3,4 +3,8 @@ require "stimulus_reflex/controller"
3
3
  require "stimulus_reflex/channel"
4
4
 
5
5
  module StimulusReflex
6
+ module Rails
7
+ class Engine < ::Rails::Engine
8
+ end
9
+ end
6
10
  end
@@ -10,7 +10,10 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
10
10
  include CableReady::Broadcaster
11
11
 
12
12
  def stream_name
13
- "#{channel_name}_#{person.id}"
13
+ ids = connection.identifiers.map do |identifier|
14
+ send(identifier).try(:id)
15
+ end
16
+ "#{channel_name}#{ids.join ":"}"
14
17
  end
15
18
 
16
19
  def subscribed
@@ -1,3 +1,3 @@
1
1
  module StimulusReflex
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1 +1 @@
1
- window.StimulusReflex=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){(function(t){var n="Expected a function",r=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,p=f||l||Function("return this")(),h=Object.prototype.toString,d=Math.max,y=Math.min,m=function(){return p.Date.now()};function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&h.call(e)==o}(e))return r;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=s.test(e);return n||u.test(e)?a(e.slice(2),n?2:8):c.test(e)?r:+e}e.exports=function(e,t,r){var o,i,c,s,u,a,f=0,l=!1,p=!1,h=!0;if("function"!=typeof e)throw new TypeError(n);function v(t){var n=o,r=i;return o=i=void 0,f=t,s=e.apply(r,n)}function O(e){var n=e-a;return void 0===a||n>=t||n<0||p&&e-f>=c}function E(){var e=m();if(O(e))return w(e);u=setTimeout(E,function(e){var n=t-(e-a);return p?y(n,c-(e-f)):n}(e))}function w(e){return u=void 0,h&&o?v(e):(o=i=void 0,s)}function A(){var e=m(),n=O(e);if(o=arguments,i=this,a=e,n){if(void 0===u)return function(e){return f=e,u=setTimeout(E,t),l?v(e):s}(a);if(p)return u=setTimeout(E,t),v(a)}return void 0===u&&(u=setTimeout(E,t)),s}return t=g(t)||0,b(r)&&(l=!!r.leading,c=(p="maxWait"in r)?d(g(r.maxWait)||0,t):c,h="trailing"in r?!!r.trailing:h),A.cancel=function(){void 0!==u&&clearTimeout(u),f=0,o=a=i=u=void 0},A.flush=function(){return void 0===u?s:w(m())},A}}).call(this,n(1))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);var r=function(){function e(e,t){this.eventTarget=e,this.eventName=t,this.unorderedBindings=new Set}return e.prototype.connect=function(){this.eventTarget.addEventListener(this.eventName,this,!1)},e.prototype.disconnect=function(){this.eventTarget.removeEventListener(this.eventName,this,!1)},e.prototype.bindingConnected=function(e){this.unorderedBindings.add(e)},e.prototype.bindingDisconnected=function(e){this.unorderedBindings.delete(e)},e.prototype.handleEvent=function(e){for(var t=function(e){if("immediatePropagationStopped"in e)return e;var t=e.stopImmediatePropagation;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation:function(){this.immediatePropagationStopped=!0,t.call(this)}})}(e),n=0,r=this.bindings;n<r.length;n++){var o=r[n];if(t.immediatePropagationStopped)break;o.handleEvent(t)}},Object.defineProperty(e.prototype,"bindings",{get:function(){return Array.from(this.unorderedBindings).sort(function(e,t){var n=e.index,r=t.index;return n<r?-1:n>r?1:0})},enumerable:!0,configurable:!0}),e}();var o=function(){function e(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}return e.prototype.start=function(){this.started||(this.started=!0,this.eventListeners.forEach(function(e){return e.connect()}))},e.prototype.stop=function(){this.started&&(this.started=!1,this.eventListeners.forEach(function(e){return e.disconnect()}))},Object.defineProperty(e.prototype,"eventListeners",{get:function(){return Array.from(this.eventListenerMaps.values()).reduce(function(e,t){return e.concat(Array.from(t.values()))},[])},enumerable:!0,configurable:!0}),e.prototype.bindingConnected=function(e){this.fetchEventListenerForBinding(e).bindingConnected(e)},e.prototype.bindingDisconnected=function(e){this.fetchEventListenerForBinding(e).bindingDisconnected(e)},e.prototype.handleError=function(e,t,n){void 0===n&&(n={}),this.application.handleError(e,"Error "+t,n)},e.prototype.fetchEventListenerForBinding=function(e){var t=e.eventTarget,n=e.eventName;return this.fetchEventListener(t,n)},e.prototype.fetchEventListener=function(e,t){var n=this.fetchEventListenerMapForEventTarget(e),r=n.get(t);return r||(r=this.createEventListener(e,t),n.set(t,r)),r},e.prototype.createEventListener=function(e,t){var n=new r(e,t);return this.started&&n.connect(),n},e.prototype.fetchEventListenerMapForEventTarget=function(e){var t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t},e}(),i=/^((.+?)(@(window|document))?->)?(.+?)(#(.+))?$/;function c(e){var t=e.trim().match(i)||[];return{eventTarget:function(e){if("window"==e)return window;if("document"==e)return document}(t[4]),eventName:t[2],identifier:t[5],methodName:t[7]}}var s=function(){function e(e,t,n){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){var t=e.tagName.toLowerCase();if(t in u)return u[t](e)}(e)||a("missing event name"),this.identifier=n.identifier||a("missing identifier"),this.methodName=n.methodName||a("missing method name")}return e.forToken=function(e){return new this(e.element,e.index,c(e.content))},e.prototype.toString=function(){var e=this.eventTargetName?"@"+this.eventTargetName:"";return""+this.eventName+e+"->"+this.identifier+"#"+this.methodName},Object.defineProperty(e.prototype,"eventTargetName",{get:function(){return function(e){return e==window?"window":e==document?"document":void 0}(this.eventTarget)},enumerable:!0,configurable:!0}),e}(),u={a:function(e){return"click"},button:function(e){return"click"},form:function(e){return"submit"},input:function(e){return"submit"==e.getAttribute("type")?"click":"change"},select:function(e){return"change"},textarea:function(e){return"change"}};function a(e){throw new Error(e)}var f=function(){function e(e,t){this.context=e,this.action=t}return Object.defineProperty(e.prototype,"index",{get:function(){return this.action.index},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventTarget",{get:function(){return this.action.eventTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.context.identifier},enumerable:!0,configurable:!0}),e.prototype.handleEvent=function(e){this.willBeInvokedByEvent(e)&&this.invokeWithEvent(e)},Object.defineProperty(e.prototype,"eventName",{get:function(){return this.action.eventName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){var e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error('Action "'+this.action+'" references undefined method "'+this.methodName+'"')},enumerable:!0,configurable:!0}),e.prototype.invokeWithEvent=function(e){try{this.method.call(this.controller,e)}catch(n){var t={identifier:this.identifier,controller:this.controller,element:this.element,index:this.index,event:e};this.context.handleError(n,'invoking action "'+this.action+'"',t)}},e.prototype.willBeInvokedByEvent=function(e){var t=e.target;return this.element===t||(!(t instanceof Element&&this.element.contains(t))||this.scope.containsElement(t))},Object.defineProperty(e.prototype,"controller",{get:function(){return this.context.controller},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"methodName",{get:function(){return this.action.methodName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scope",{get:function(){return this.context.scope},enumerable:!0,configurable:!0}),e}(),l=function(){function e(e,t){var n=this;this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(function(e){return n.processMutations(e)})}return e.prototype.start=function(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,childList:!0,subtree:!0}),this.refresh())},e.prototype.stop=function(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)},e.prototype.refresh=function(){if(this.started){for(var e=new Set(this.matchElementsInTree()),t=0,n=Array.from(this.elements);t<n.length;t++){var r=n[t];e.has(r)||this.removeElement(r)}for(var o=0,i=Array.from(e);o<i.length;o++){r=i[o];this.addElement(r)}}},e.prototype.processMutations=function(e){if(this.started)for(var t=0,n=e;t<n.length;t++){var r=n[t];this.processMutation(r)}},e.prototype.processMutation=function(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))},e.prototype.processAttributeChange=function(e,t){var n=e;this.elements.has(n)?this.delegate.elementAttributeChanged&&this.matchElement(n)?this.delegate.elementAttributeChanged(n,t):this.removeElement(n):this.matchElement(n)&&this.addElement(n)},e.prototype.processRemovedNodes=function(e){for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t],o=this.elementFromNode(r);o&&this.processTree(o,this.removeElement)}},e.prototype.processAddedNodes=function(e){for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t],o=this.elementFromNode(r);o&&this.elementIsActive(o)&&this.processTree(o,this.addElement)}},e.prototype.matchElement=function(e){return this.delegate.matchElement(e)},e.prototype.matchElementsInTree=function(e){return void 0===e&&(e=this.element),this.delegate.matchElementsInTree(e)},e.prototype.processTree=function(e,t){for(var n=0,r=this.matchElementsInTree(e);n<r.length;n++){var o=r[n];t.call(this,o)}},e.prototype.elementFromNode=function(e){if(e.nodeType==Node.ELEMENT_NODE)return e},e.prototype.elementIsActive=function(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)},e.prototype.addElement=function(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))},e.prototype.removeElement=function(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))},e}(),p=function(){function e(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new l(e,this)}return Object.defineProperty(e.prototype,"element",{get:function(){return this.elementObserver.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selector",{get:function(){return"["+this.attributeName+"]"},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.elementObserver.start()},e.prototype.stop=function(){this.elementObserver.stop()},e.prototype.refresh=function(){this.elementObserver.refresh()},Object.defineProperty(e.prototype,"started",{get:function(){return this.elementObserver.started},enumerable:!0,configurable:!0}),e.prototype.matchElement=function(e){return e.hasAttribute(this.attributeName)},e.prototype.matchElementsInTree=function(e){var t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)},e.prototype.elementMatched=function(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)},e.prototype.elementUnmatched=function(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)},e.prototype.elementAttributeChanged=function(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)},e}();function h(e,t,n){y(e,t).add(n)}function d(e,t,n){y(e,t).delete(n),function(e,t){var n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}function y(e,t){var n=e.get(t);return n||(n=new Set,e.set(t,n)),n}var m=function(){function e(){this.valuesByKey=new Map}return Object.defineProperty(e.prototype,"values",{get:function(){return Array.from(this.valuesByKey.values()).reduce(function(e,t){return e.concat(Array.from(t))},[])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return Array.from(this.valuesByKey.values()).reduce(function(e,t){return e+t.size},0)},enumerable:!0,configurable:!0}),e.prototype.add=function(e,t){h(this.valuesByKey,e,t)},e.prototype.delete=function(e,t){d(this.valuesByKey,e,t)},e.prototype.has=function(e,t){var n=this.valuesByKey.get(e);return null!=n&&n.has(t)},e.prototype.hasKey=function(e){return this.valuesByKey.has(e)},e.prototype.hasValue=function(e){return Array.from(this.valuesByKey.values()).some(function(t){return t.has(e)})},e.prototype.getValuesForKey=function(e){var t=this.valuesByKey.get(e);return t?Array.from(t):[]},e.prototype.getKeysForValue=function(e){return Array.from(this.valuesByKey).filter(function(t){t[0];return t[1].has(e)}).map(function(e){var t=e[0];e[1];return t})},e}(),b=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),g=(function(e){function t(){var t=e.call(this)||this;return t.keysByValue=new Map,t}b(t,e),Object.defineProperty(t.prototype,"values",{get:function(){return Array.from(this.keysByValue.keys())},enumerable:!0,configurable:!0}),t.prototype.add=function(t,n){e.prototype.add.call(this,t,n),h(this.keysByValue,n,t)},t.prototype.delete=function(t,n){e.prototype.delete.call(this,t,n),d(this.keysByValue,n,t)},t.prototype.hasValue=function(e){return this.keysByValue.has(e)},t.prototype.getKeysForValue=function(e){var t=this.keysByValue.get(e);return t?Array.from(t):[]}}(m),function(){function e(e,t,n){this.attributeObserver=new p(e,t,this),this.delegate=n,this.tokensByElement=new m}return Object.defineProperty(e.prototype,"started",{get:function(){return this.attributeObserver.started},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.attributeObserver.start()},e.prototype.stop=function(){this.attributeObserver.stop()},e.prototype.refresh=function(){this.attributeObserver.refresh()},Object.defineProperty(e.prototype,"element",{get:function(){return this.attributeObserver.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"attributeName",{get:function(){return this.attributeObserver.attributeName},enumerable:!0,configurable:!0}),e.prototype.elementMatchedAttribute=function(e){this.tokensMatched(this.readTokensForElement(e))},e.prototype.elementAttributeValueChanged=function(e){var t=this.refreshTokensForElement(e),n=t[0],r=t[1];this.tokensUnmatched(n),this.tokensMatched(r)},e.prototype.elementUnmatchedAttribute=function(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))},e.prototype.tokensMatched=function(e){var t=this;e.forEach(function(e){return t.tokenMatched(e)})},e.prototype.tokensUnmatched=function(e){var t=this;e.forEach(function(e){return t.tokenUnmatched(e)})},e.prototype.tokenMatched=function(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)},e.prototype.tokenUnmatched=function(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)},e.prototype.refreshTokensForElement=function(e){var t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){var n=Math.max(e.length,t.length);return Array.from({length:n},function(n,r){return[e[r],t[r]]})}(t,n).findIndex(function(e){return!function(e,t){return e&&t&&e.index==t.index&&e.content==t.content}(e[0],e[1])});return-1==r?[[],[]]:[t.slice(r),n.slice(r)]},e.prototype.readTokensForElement=function(e){var t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter(function(e){return e.length}).map(function(e,r){return{element:t,attributeName:n,content:e,index:r}})}(e.getAttribute(t)||"",e,t)},e}());var v=function(){function e(e,t,n){this.tokenListObserver=new g(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}return Object.defineProperty(e.prototype,"started",{get:function(){return this.tokenListObserver.started},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.tokenListObserver.start()},e.prototype.stop=function(){this.tokenListObserver.stop()},e.prototype.refresh=function(){this.tokenListObserver.refresh()},Object.defineProperty(e.prototype,"element",{get:function(){return this.tokenListObserver.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"attributeName",{get:function(){return this.tokenListObserver.attributeName},enumerable:!0,configurable:!0}),e.prototype.tokenMatched=function(e){var t=e.element,n=this.fetchParseResultForToken(e).value;n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))},e.prototype.tokenUnmatched=function(e){var t=e.element,n=this.fetchParseResultForToken(e).value;n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))},e.prototype.fetchParseResultForToken=function(e){var t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t},e.prototype.fetchValuesByTokenForElement=function(e){var t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t},e.prototype.parseToken=function(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}},e}(),O=function(){function e(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}return e.prototype.start=function(){this.valueListObserver||(this.valueListObserver=new v(this.element,this.actionAttribute,this),this.valueListObserver.start())},e.prototype.stop=function(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())},Object.defineProperty(e.prototype,"element",{get:function(){return this.context.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.context.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"actionAttribute",{get:function(){return this.schema.actionAttribute},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this.context.schema},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bindings",{get:function(){return Array.from(this.bindingsByAction.values())},enumerable:!0,configurable:!0}),e.prototype.connectAction=function(e){var t=new f(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)},e.prototype.disconnectAction=function(e){var t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))},e.prototype.disconnectAllActions=function(){var e=this;this.bindings.forEach(function(t){return e.delegate.bindingDisconnected(t)}),this.bindingsByAction.clear()},e.prototype.parseValueForToken=function(e){var t=s.forToken(e);if(t.identifier==this.identifier)return t},e.prototype.elementMatchedValue=function(e,t){this.connectAction(t)},e.prototype.elementUnmatchedValue=function(e,t){this.disconnectAction(t)},e}(),E=function(){function e(e,t){this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new O(this,this.dispatcher);try{this.controller.initialize()}catch(e){this.handleError(e,"initializing controller")}}return e.prototype.connect=function(){this.bindingObserver.start();try{this.controller.connect()}catch(e){this.handleError(e,"connecting controller")}},e.prototype.disconnect=function(){try{this.controller.disconnect()}catch(e){this.handleError(e,"disconnecting controller")}this.bindingObserver.stop()},Object.defineProperty(e.prototype,"application",{get:function(){return this.module.application},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.module.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this.application.schema},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dispatcher",{get:function(){return this.application.dispatcher},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parentElement",{get:function(){return this.element.parentElement},enumerable:!0,configurable:!0}),e.prototype.handleError=function(e,t,n){void 0===n&&(n={});var r=this.identifier,o=this.controller,i=this.element;n=Object.assign({identifier:r,controller:o,element:i},n),this.application.handleError(e,"Error "+t,n)},e}(),w=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();function A(e){return{identifier:e.identifier,controllerConstructor:function(e){var t=j(e);return t.bless(),t}(e.controllerConstructor)}}var j=function(){function e(e){function t(){var n=this&&this instanceof t?this.constructor:void 0;return Reflect.construct(e,arguments,n)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){var t=e(function(){this.a.call(this)});t.prototype.a=function(){},new t}(),e}catch(e){return function(e){return function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return w(t,e),t}(e)}}}(),P=function(){function e(e,t){this.application=e,this.definition=A(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this.definition.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controllerConstructor",{get:function(){return this.definition.controllerConstructor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contexts",{get:function(){return Array.from(this.connectedContexts)},enumerable:!0,configurable:!0}),e.prototype.connectContextForScope=function(e){var t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()},e.prototype.disconnectContextForScope=function(e){var t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())},e.prototype.fetchContextForScope=function(e){var t=this.contextsByScope.get(e);return t||(t=new E(this,e),this.contextsByScope.set(e,t)),t},e}(),k=function(){function e(e){this.scope=e}return Object.defineProperty(e.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),e.prototype.get=function(e){return e=this.getFormattedKey(e),this.element.getAttribute(e)},e.prototype.set=function(e,t){return e=this.getFormattedKey(e),this.element.setAttribute(e,t),this.get(e)},e.prototype.has=function(e){return e=this.getFormattedKey(e),this.element.hasAttribute(e)},e.prototype.delete=function(e){return!!this.has(e)&&(e=this.getFormattedKey(e),this.element.removeAttribute(e),!0)},e.prototype.getFormattedKey=function(e){return"data-"+this.identifier+"-"+function(e){return e.replace(/([A-Z])/g,function(e,t){return"-"+t.toLowerCase()})}(e)},e}();function B(e,t){return"["+e+'~="'+t+'"]'}var x=function(){function e(e){this.scope=e}return Object.defineProperty(e.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this.scope.schema},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return null!=this.find(e)},e.prototype.find=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this.getSelectorForTargetNames(e);return this.scope.findElement(n)},e.prototype.findAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this.getSelectorForTargetNames(e);return this.scope.findAllElements(n)},e.prototype.getSelectorForTargetNames=function(e){var t=this;return e.map(function(e){return t.getSelectorForTargetName(e)}).join(", ")},e.prototype.getSelectorForTargetName=function(e){var t=this.identifier+"."+e;return B(this.schema.targetAttribute,t)},e}(),T=function(){function e(e,t,n){this.schema=e,this.identifier=t,this.element=n,this.targets=new x(this),this.data=new k(this)}return e.prototype.findElement=function(e){return this.findAllElements(e)[0]},e.prototype.findAllElements=function(e){var t=this.element.matches(e)?[this.element]:[],n=this.filterElements(Array.from(this.element.querySelectorAll(e)));return t.concat(n)},e.prototype.filterElements=function(e){var t=this;return e.filter(function(e){return t.containsElement(e)})},e.prototype.containsElement=function(e){return e.closest(this.controllerSelector)===this.element},Object.defineProperty(e.prototype,"controllerSelector",{get:function(){return B(this.schema.controllerAttribute,this.identifier)},enumerable:!0,configurable:!0}),e}(),F=function(){function e(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new v(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}return e.prototype.start=function(){this.valueListObserver.start()},e.prototype.stop=function(){this.valueListObserver.stop()},Object.defineProperty(e.prototype,"controllerAttribute",{get:function(){return this.schema.controllerAttribute},enumerable:!0,configurable:!0}),e.prototype.parseValueForToken=function(e){var t=e.element,n=e.content,r=this.fetchScopesByIdentifierForElement(t),o=r.get(n);return o||(o=new T(this.schema,n,t),r.set(n,o)),o},e.prototype.elementMatchedValue=function(e,t){var n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)},e.prototype.elementUnmatchedValue=function(e,t){var n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))},e.prototype.fetchScopesByIdentifierForElement=function(e){var t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t},e}(),M=function(){function e(e){this.application=e,this.scopeObserver=new F(this.element,this.schema,this),this.scopesByIdentifier=new m,this.modulesByIdentifier=new Map}return Object.defineProperty(e.prototype,"element",{get:function(){return this.application.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"schema",{get:function(){return this.application.schema},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controllerAttribute",{get:function(){return this.schema.controllerAttribute},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"modules",{get:function(){return Array.from(this.modulesByIdentifier.values())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contexts",{get:function(){return this.modules.reduce(function(e,t){return e.concat(t.contexts)},[])},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.scopeObserver.start()},e.prototype.stop=function(){this.scopeObserver.stop()},e.prototype.loadDefinition=function(e){this.unloadIdentifier(e.identifier);var t=new P(this.application,e);this.connectModule(t)},e.prototype.unloadIdentifier=function(e){var t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)},e.prototype.getContextForElementAndIdentifier=function(e,t){var n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find(function(t){return t.element==e})},e.prototype.handleError=function(e,t,n){this.application.handleError(e,t,n)},e.prototype.scopeConnected=function(e){this.scopesByIdentifier.add(e.identifier,e);var t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)},e.prototype.scopeDisconnected=function(e){this.scopesByIdentifier.delete(e.identifier,e);var t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)},e.prototype.connectModule=function(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(function(t){return e.connectContextForScope(t)})},e.prototype.disconnectModule=function(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(function(t){return e.disconnectContextForScope(t)})},e}(),N={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target"},S=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function c(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(c,s)}u((r=r.apply(e,t||[])).next())})},C=function(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[0,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};!function(){function e(e,t){void 0===e&&(e=document.documentElement),void 0===t&&(t=N),this.element=e,this.schema=t,this.dispatcher=new o(this),this.router=new M(this)}e.start=function(t,n){var r=new e(t,n);return r.start(),r},e.prototype.start=function(){return S(this,void 0,void 0,function(){return C(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e){"loading"==document.readyState?document.addEventListener("DOMContentLoaded",e):e()})];case 1:return e.sent(),this.router.start(),this.dispatcher.start(),[2]}})})},e.prototype.stop=function(){this.router.stop(),this.dispatcher.stop()},e.prototype.register=function(e,t){this.load({identifier:e,controllerConstructor:t})},e.prototype.load=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(Array.isArray(e)?e:[e].concat(n)).forEach(function(e){return t.router.loadDefinition(e)})},e.prototype.unload=function(e){for(var t=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(Array.isArray(e)?e:[e].concat(n)).forEach(function(e){return t.router.unloadIdentifier(e)})},Object.defineProperty(e.prototype,"controllers",{get:function(){return this.router.contexts.map(function(e){return e.controller})},enumerable:!0,configurable:!0}),e.prototype.getControllerForElementAndIdentifier=function(e,t){var n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null},e.prototype.handleError=function(e,t,n){console.error("%s\n\n%o\n\n%o",t,e,n)}}();function L(e){var t=e.prototype;(function(e){var t=function(e){var t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t}(e);return Array.from(t.reduce(function(e,t){return function(e){var t=e.targets;return Array.isArray(t)?t:[]}(t).forEach(function(t){return e.add(t)}),e},new Set))})(e).forEach(function(e){var n;return function(e,t){Object.keys(t).forEach(function(n){if(!(n in e)){var r=t[n];Object.defineProperty(e,n,r)}})}(t,((n={})[e+"Target"]={get:function(){var t=this.targets.find(e);if(t)return t;throw new Error('Missing target element "'+this.identifier+"."+e+'"')}},n[e+"Targets"]={get:function(){return this.targets.findAll(e)}},n["has"+function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(e)+"Target"]={get:function(){return this.targets.has(e)}},n))})}var I=function(){function e(e){this.context=e}return e.bless=function(){L(this)},Object.defineProperty(e.prototype,"application",{get:function(){return this.context.application},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scope",{get:function(){return this.context.scope},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this.scope.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return this.scope.identifier},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targets",{get:function(){return this.scope.targets},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.scope.data},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.connect=function(){},e.prototype.disconnect=function(){},e.targets=[],e}(),_=n(0),V=n.n(_),K=window.App=window.App||{};K.cable=K.cable||ActionCable.createConsumer();var R=K;function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function D(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function W(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t){return($=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var q=V()(function(e){return R.stimulus.send(e)},250,{}),G=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),W(this,z(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&$(e,t)}(t,I),function(e,t,n){t&&D(e.prototype,t),n&&D(e,n)}(t,[{key:"send",value:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();q({url:location.href,target:t,args:e})}}]),t}();t.default={ReactiveController:G}}]);
1
+ window.StimulusReflex=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){(function(e){var n="Expected a function",r=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,c=/^0o[0-7]+$/i,a=parseInt,l="object"==typeof e&&e&&e.Object===Object&&e,s="object"==typeof self&&self&&self.Object===Object&&self,p=l||s||Function("return this")(),d=Object.prototype.toString,v=Math.max,b=Math.min,y=function(){return p.Date.now()};function m(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function j(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&d.call(t)==i}(t))return r;if(m(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=m(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(o,"");var n=f.test(t);return n||c.test(t)?a(t.slice(2),n?2:8):u.test(t)?r:+t}t.exports=function(t,e,r){var i,o,u,f,c,a,l=0,s=!1,p=!1,d=!0;if("function"!=typeof t)throw new TypeError(n);function x(e){var n=i,r=o;return i=o=void 0,l=e,f=t.apply(r,n)}function g(t){var n=t-a;return void 0===a||n>=e||n<0||p&&t-l>=u}function h(){var t=y();if(g(t))return O(t);c=setTimeout(h,function(t){var n=e-(t-a);return p?b(n,u-(t-l)):n}(t))}function O(t){return c=void 0,d&&i?x(t):(i=o=void 0,f)}function w(){var t=y(),n=g(t);if(i=arguments,o=this,a=t,n){if(void 0===c)return function(t){return l=t,c=setTimeout(h,e),s?x(t):f}(a);if(p)return c=setTimeout(h,e),x(a)}return void 0===c&&(c=setTimeout(h,e)),f}return e=j(e)||0,m(r)&&(s=!!r.leading,u=(p="maxWait"in r)?v(j(r.maxWait)||0,e):u,d="trailing"in r?!!r.trailing:d),w.cancel=function(){void 0!==c&&clearTimeout(c),l=0,i=a=o=c=void 0},w.flush=function(){return void 0===c?f:O(y())},w}}).call(this,n(1))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e);var r=n(0),i=n.n(r);window.App=App||{},App.cable=App.cable||ActionCable.createConsumer(),App.stimulusReflex=App.stimulusReflex||App.cable.subscriptions.create("StimulusReflex::Channel",{received:function(t){t.cableReady&&u(t.operations)}});var o=i()(function(t){return App.stimulusReflex.send(t)},250,{}),u=i()(function(t){CableReady.perform(t),document.dispatchEvent(new Event("turbolinks:load"))},200,{}),f={send:function(){var t=Array.prototype.slice.call(arguments),e=t.shift();o({url:location.href,target:e,args:t})}};n.d(e,"controllers",function(){return c}),n.d(e,"register",function(){return a});var c={},a=function(t){return c[t.identifier]||(Object.assign(t,f),c[t.identifier]=t),t}}]);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins