ruby_event_store-browser 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/ruby_event_store/browser/app.rb +190 -86
  4. data/lib/ruby_event_store/browser/extension_context.rb +22 -0
  5. data/lib/ruby_event_store/browser/get_events_from_stream.rb +50 -93
  6. data/lib/ruby_event_store/browser/get_events_from_streams.rb +98 -0
  7. data/lib/ruby_event_store/browser/layout.rb +55 -0
  8. data/lib/ruby_event_store/browser/renderer.rb +64 -0
  9. data/lib/ruby_event_store/browser/urls.rb +35 -39
  10. data/lib/ruby_event_store/browser/version.rb +1 -1
  11. data/lib/ruby_event_store/browser/views/_clipboard_icon.html.erb +1 -0
  12. data/lib/ruby_event_store/browser/views/_clock_icon.html.erb +1 -0
  13. data/lib/ruby_event_store/browser/views/_json_tree.html.erb +1 -0
  14. data/lib/ruby_event_store/browser/views/_raw_section.html.erb +9 -0
  15. data/lib/ruby_event_store/browser/views/_timestamp.html.erb +7 -0
  16. data/lib/ruby_event_store/browser/views/events/show.html.erb +85 -0
  17. data/lib/ruby_event_store/browser/views/layout.html.erb +72 -0
  18. data/lib/ruby_event_store/browser/views/not_found.html.erb +3 -0
  19. data/lib/ruby_event_store/browser/views/streams/show.html.erb +74 -0
  20. data/lib/ruby_event_store/browser/views/swimlane/_rows.html.erb +20 -0
  21. data/lib/ruby_event_store/browser/views/swimlane/show.html.erb +55 -0
  22. data/lib/ruby_event_store/browser.rb +17 -5
  23. data/public/ruby_event_store_browser.css +2 -1
  24. data/public/ruby_event_store_browser.js +287 -1
  25. data/public/stimulus-3.2.2.js +11 -0
  26. metadata +21 -11
  27. data/lib/ruby_event_store/browser/gem_source.rb +0 -32
  28. data/lib/ruby_event_store/browser/get_event.rb +0 -37
  29. data/lib/ruby_event_store/browser/get_stream.rb +0 -29
  30. data/lib/ruby_event_store/browser/json_api_event.rb +0 -66
  31. data/lib/ruby_event_store/browser/json_api_stream.rb +0 -34
  32. data/public/bootstrap.js +0 -30
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.
3
+ * Original file: /npm/@hotwired/stimulus@3.2.2/dist/stimulus.js
4
+ *
5
+ * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6
+ */
7
+ class G{constructor(e,t,s){this.eventTarget=e,this.eventName=t,this.eventOptions=s,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=H(e);for(const s of this.bindings){if(t.immediatePropagationStopped)break;s.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{const s=e.index,n=t.index;return s<n?-1:s>n?1:0})}}function H(r){if("immediatePropagationStopped"in r)return r;{const{stopImmediatePropagation:e}=r;return Object.assign(r,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}class Z{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(e=>e.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,s={}){this.application.handleError(e,`Error ${t}`,s)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:s,eventOptions:n}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(s,n);i.delete(o),i.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:s,eventOptions:n}=e;return this.fetchEventListener(t,s,n)}fetchEventListener(e,t,s){const n=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,s);let o=n.get(i);return o||(o=this.createEventListener(e,t,s),n.set(i,o)),o}createEventListener(e,t,s){const n=new G(e,t,s);return this.started&&n.connect(),n}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const s=[e];return Object.keys(t).sort().forEach(n=>{s.push(`${t[n]?"":"!"}${n}`)}),s.join(":")}}const Q={stop({event:r,value:e}){return e&&r.stopPropagation(),!0},prevent({event:r,value:e}){return e&&r.preventDefault(),!0},self({event:r,value:e,element:t}){return e?t===r.target:!0}},X=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function Y(r){const t=r.trim().match(X)||[];let s=t[2],n=t[3];return n&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${n}`,n=""),{eventTarget:ee(t[4]),eventName:s,eventOptions:t[7]?te(t[7]):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||n}}function ee(r){if(r=="window")return window;if(r=="document")return document}function te(r){return r.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function se(r){if(r==window)return"window";if(r==document)return"document"}function v(r){return r.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function y(r){return v(r.replace(/--/g,"-").replace(/__/g,"_"))}function u(r){return r.charAt(0).toUpperCase()+r.slice(1)}function N(r){return r.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function re(r){return r.match(/[^\s]+/g)||[]}function S(r){return r!=null}function O(r,e){return Object.prototype.hasOwnProperty.call(r,e)}const D=["meta","ctrl","alt","shift"];class ne{constructor(e,t,s,n){this.element=e,this.index=t,this.eventTarget=s.eventTarget||e,this.eventName=s.eventName||ie(e)||p("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||p("missing identifier"),this.methodName=s.methodName||p("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=n}static forToken(e,t){return new this(e.element,e.index,Y(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const s=t.filter(n=>!D.includes(n))[0];return s?(O(this.keyMappings,s)||p(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[s].toLowerCase()!==e.key.toLowerCase()):!1}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:s,value:n}of Array.from(this.element.attributes)){const i=s.match(t),o=i&&i[1];o&&(e[v(o)]=oe(n))}return e}get eventTargetName(){return se(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[s,n,i,o]=D.map(a=>t.includes(a));return e.metaKey!==s||e.ctrlKey!==n||e.altKey!==i||e.shiftKey!==o}}const $={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:r=>r.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function ie(r){const e=r.tagName.toLowerCase();if(e in $)return $[e](r)}function p(r){throw new Error(r)}function oe(r){try{return JSON.parse(r)}catch{return r}}class ae{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if(typeof e=="function")return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:s}=this.context.application,{controller:n}=this.context;let i=!0;for(const[o,a]of Object.entries(this.eventOptions))if(o in s){const c=s[o];i=i&&c({name:o,value:a,event:e,element:t,controller:n})}else continue;return i}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:s}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:s,action:this.methodName})}catch(n){const{identifier:i,controller:o,element:a,index:c}=this,h={identifier:i,controller:o,element:a,index:c,event:e};this.context.handleError(n,`invoking action "${this.action}"`,h)}}willBeInvokedByEvent(e){const t=e.target;return e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e)||e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e)?!1:this.element===t?!0:t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class E{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){e.type=="attributes"?this.processAttributeChange(e.target,e.attributeName):e.type=="childList"&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const s=this.elementFromNode(t);s&&this.processTree(s,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const s=this.elementFromNode(t);s&&this.elementIsActive(s)&&this.processTree(s,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const s of this.matchElementsInTree(e))t.call(this,s)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected!=this.element.isConnected?!1:this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class A{constructor(e,t,s){this.attributeName=t,this.delegate=s,this.elementObserver=new E(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],s=Array.from(e.querySelectorAll(this.selector));return t.concat(s)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function w(r,e,t){F(r,e).add(t)}function M(r,e,t){F(r,e).delete(t),x(r,e)}function F(r,e){let t=r.get(e);return t||(t=new Set,r.set(e,t)),t}function x(r,e){const t=r.get(e);t!=null&&t.size==0&&r.delete(e)}class l{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t.concat(Array.from(s)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t+s.size,0)}add(e,t){w(this.valuesByKey,e,t)}delete(e,t){M(this.valuesByKey,e,t)}has(e,t){const s=this.valuesByKey.get(e);return s!=null&&s.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(s=>s.has(e))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,s])=>s.has(e)).map(([t,s])=>t)}}class ce extends l{constructor(){super(),this.keysByValue=new Map}get values(){return Array.from(this.keysByValue.keys())}add(e,t){super.add(e,t),w(this.keysByValue,t,e)}delete(e,t){super.delete(e,t),M(this.keysByValue,t,e)}hasValue(e){return this.keysByValue.has(e)}getKeysForValue(e){const t=this.keysByValue.get(e);return t?Array.from(t):[]}}class L{constructor(e,t,s,n){this._selector=t,this.details=n,this.elementObserver=new E(e,this),this.delegate=s,this.matchesByElement=new l}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const s=e.matches(t);return this.delegate.selectorMatchElement?s&&this.delegate.selectorMatchElement(e,this.details):s}else return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const s=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(t)).filter(i=>this.matchElement(i));return s.concat(n)}else return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const s of t)this.selectorUnmatched(e,s)}elementAttributeChanged(e,t){const{selector:s}=this;if(s){const n=this.matchElement(e),i=this.matchesByElement.has(s,e);n&&!i?this.selectorMatched(e,s):!n&&i&&this.selectorUnmatched(e,s)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class V{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const s=this.delegate.getStringMapKeyForAttribute(e);if(s!=null){this.stringMap.has(e)||this.stringMapKeyAdded(s,e);const n=this.element.getAttribute(e);if(this.stringMap.get(e)!=n&&this.stringMapValueChanged(n,s,t),n==null){const i=this.stringMap.get(e);this.stringMap.delete(e),i&&this.stringMapKeyRemoved(s,e,i)}else this.stringMap.set(e,n)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,s){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,s)}stringMapKeyRemoved(e,t,s){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,s)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(e=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class k{constructor(e,t,s){this.attributeObserver=new A(e,t,this),this.delegate=s,this.tokensByElement=new l}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,s]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(s)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach(t=>this.tokenMatched(t))}tokensUnmatched(e){e.forEach(t=>this.tokenUnmatched(t))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),s=this.readTokensForElement(e),n=he(t,s).findIndex(([i,o])=>!ue(i,o));return n==-1?[[],[]]:[t.slice(n),s.slice(n)]}readTokensForElement(e){const t=this.attributeName,s=e.getAttribute(t)||"";return le(s,e,t)}}function le(r,e,t){return r.trim().split(/\s+/).filter(s=>s.length).map((s,n)=>({element:e,attributeName:t,content:s,index:n}))}function he(r,e){const t=Math.max(r.length,e.length);return Array.from({length:t},(s,n)=>[r[n],e[n]])}function ue(r,e){return r&&e&&r.index==e.index&&r.content==e.content}class B{constructor(e,t,s){this.tokenListObserver=new k(e,t,this),this.delegate=s,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:s}=this.fetchParseResultForToken(e);s&&(this.fetchValuesByTokenForElement(t).set(e,s),this.delegate.elementMatchedValue(t,s))}tokenUnmatched(e){const{element:t}=e,{value:s}=this.fetchParseResultForToken(e);s&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,s))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(t){return{error:t}}}}class de{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new B(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new ae(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach(e=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){const t=ne.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class fe{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new V(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const s=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,s.writer(this.receiver[e]),s.writer(s.defaultValue))}stringMapValueChanged(e,t,s){const n=this.valueDescriptorNameMap[t];e!==null&&(s===null&&(s=n.writer(n.defaultValue)),this.invokeChangedCallback(t,e,s))}stringMapKeyRemoved(e,t,s){const n=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,n.writer(this.receiver[e]),s):this.invokeChangedCallback(e,n.writer(n.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:s,writer:n}of this.valueDescriptors)s!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,n(s),void 0)}invokeChangedCallback(e,t,s){const n=`${e}Changed`,i=this.receiver[n];if(typeof i=="function"){const o=this.valueDescriptorNameMap[e];try{const a=o.reader(t);let c=s;s&&(c=o.reader(s)),i.call(this.receiver,a,c)}catch(a){throw a instanceof TypeError&&(a.message=`Stimulus Value "${this.context.identifier}.${o.name}" - ${a.message}`),a}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{const s=this.valueDescriptorMap[t];e[s.name]=s}),e}hasValue(e){const t=this.valueDescriptorNameMap[e],s=`has${u(t.name)}`;return this.receiver[s]}}class ge{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new l}start(){this.tokenListObserver||(this.tokenListObserver=new k(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var s;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var s;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function d(r,e){const t=K(r);return Array.from(t.reduce((s,n)=>(me(n,e).forEach(i=>s.add(i)),s),new Set))}function pe(r,e){return K(r).reduce((s,n)=>(s.push(...be(n,e)),s),[])}function K(r){const e=[];for(;r;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function me(r,e){const t=r[e];return Array.isArray(t)?t:[]}function be(r,e){const t=r[e];return t?Object.keys(t).map(s=>[s,t[s]]):[]}class ve{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new l,this.outletElementsByName=new l,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach(e=>e.refresh()))}refresh(){this.selectorObserverMap.forEach(e=>e.refresh()),this.attributeObserverMap.forEach(e=>e.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:s}){const n=this.getOutlet(e,s);n&&this.connectOutlet(n,e,s)}selectorUnmatched(e,t,{outletName:s}){const n=this.getOutletFromMap(e,s);n&&this.disconnectOutlet(n,e,s)}selectorMatchElement(e,{outletName:t}){const s=this.selector(t),n=this.hasOutlet(e,t),i=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return s?n&&i&&e.matches(s):!1}elementMatchedAttribute(e,t){const s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(e,t){const s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(e,t){const s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}connectOutlet(e,t,s){var n;this.outletElementsByName.has(s,t)||(this.outletsByName.add(s,e),this.outletElementsByName.add(s,t),(n=this.selectorObserverMap.get(s))===null||n===void 0||n.pause(()=>this.delegate.outletConnected(e,t,s)))}disconnectOutlet(e,t,s){var n;this.outletElementsByName.has(s,t)&&(this.outletsByName.delete(s,e),this.outletElementsByName.delete(s,t),(n=this.selectorObserverMap.get(s))===null||n===void 0||n.pause(()=>this.delegate.outletDisconnected(e,t,s)))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const s of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(s,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),s=new L(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,s),s.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),s=new A(this.scope.element,t,this);this.attributeObserverMap.set(e,s),s.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find(t=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){const e=new l;return this.router.modules.forEach(t=>{const s=t.definition.controllerConstructor;d(s,"outlets").forEach(i=>e.add(i,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter(t=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find(s=>s.element===e)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class I{constructor(e,t){this.logDebugActivity=(s,n={})=>{const{identifier:i,controller:o,element:a}=this;n=Object.assign({identifier:i,controller:o,element:a},n),this.application.logDebugActivity(this.identifier,s,n)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new de(this,this.dispatcher),this.valueObserver=new fe(this,this.controller),this.targetObserver=new ge(this,this),this.outletObserver=new ve(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(s){this.handleError(s,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,s={}){const{identifier:n,controller:i,element:o}=this;s=Object.assign({identifier:n,controller:i,element:o},s),this.application.handleError(e,`Error ${t}`,s)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,s){this.invokeControllerMethod(`${y(s)}OutletConnected`,e,t)}outletDisconnected(e,t,s){this.invokeControllerMethod(`${y(s)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const s=this.controller;typeof s[e]=="function"&&s[e](...t)}}function ye(r){return Oe(r,Ee(r))}function Oe(r,e){const t=Fe(r),s=Ae(r.prototype,e);return Object.defineProperties(t.prototype,s),t}function Ee(r){return d(r,"blessings").reduce((t,s)=>{const n=s(r);for(const i in n){const o=t[i]||{};t[i]=Object.assign(o,n[i])}return t},{})}function Ae(r,e){return Me(e).reduce((t,s)=>{const n=we(r,e,s);return n&&Object.assign(t,{[s]:n}),t},{})}function we(r,e,t){const s=Object.getOwnPropertyDescriptor(r,t);if(!(s&&"value"in s)){const i=Object.getOwnPropertyDescriptor(e,t).value;return s&&(i.get=s.get||i.get,i.set=s.set||i.set),i}}const Me=typeof Object.getOwnPropertySymbols=="function"?r=>[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]:Object.getOwnPropertyNames,Fe=(()=>{function r(t){function s(){return Reflect.construct(t,arguments,new.target)}return s.prototype=Object.create(t.prototype,{constructor:{value:s}}),Reflect.setPrototypeOf(s,t),s}function e(){const s=r(function(){this.a.call(this)});return s.prototype.a=function(){},new s}try{return e(),r}catch{return s=>class extends s{}}})();function ke(r){return{identifier:r.identifier,controllerConstructor:ye(r.controllerConstructor)}}class Be{constructor(e,t){this.application=e,this.definition=ke(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new I(this,e),this.contextsByScope.set(e,t)),t}}class Ce{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){const t=this.data.get(this.getDataKey(e))||"";return re(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class Te{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const s=this.getAttributeNameForKey(e);return this.element.setAttribute(s,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}else return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${N(e)}`}}class Ne{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,s){let n=this.warnedKeysByObject.get(e);n||(n=new Set,this.warnedKeysByObject.set(e,n)),n.has(t)||(n.add(t),this.logger.warn(s,e))}}function C(r,e){return`[${r}~="${e}"]`}class Se{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findTarget(s)||this.findLegacyTarget(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllTargets(s),...this.findAllLegacyTargets(s)],[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){const t=this.schema.targetAttributeForScope(this.identifier);return C(t,e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(s=>this.deprecate(s,e))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return C(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:s}=this,n=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(s);this.guide.warn(e,`target:${t}`,`Please replace ${n}="${s}.${t}" with ${i}="${t}". The ${n} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class De{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findOutlet(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllOutlets(s)],[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))}matchesElement(e,t,s){const n=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&n.split(" ").includes(s)}}class T{constructor(e,t,s,n){this.targets=new Se(this),this.classes=new Ce(this),this.data=new Te(this),this.containsElement=i=>i.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=s,this.guide=new Ne(n),this.outlets=new De(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return C(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new T(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class $e{constructor(e,t,s){this.element=e,this.schema=t,this.delegate=s,this.valueListObserver=new B(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:s}=e;return this.parseValueForElementAndIdentifier(t,s)}parseValueForElementAndIdentifier(e,t){const s=this.fetchScopesByIdentifierForElement(e);let n=s.get(t);return n||(n=this.delegate.createScopeForElementAndIdentifier(e,t),s.set(t,n)),n}elementMatchedValue(e,t){const s=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,s),s==1&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const s=this.scopeReferenceCounts.get(t);s&&(this.scopeReferenceCounts.set(t,s-1),s==1&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class xe{constructor(e){this.application=e,this.scopeObserver=new $e(this.element,this.schema,this),this.scopesByIdentifier=new l,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new Be(this.application,e);this.connectModule(t);const s=e.controllerConstructor.afterLoad;s&&s.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const s=this.modulesByIdentifier.get(t);if(s)return s.contexts.find(n=>n.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){const s=this.scopeObserver.parseValueForElementAndIdentifier(e,t);s?this.scopeObserver.elementMatchedValue(s.element,s):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,s){this.application.handleError(e,t,s)}createScopeForElementAndIdentifier(e,t){return new T(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(s=>e.connectContextForScope(s))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(s=>e.disconnectContextForScope(s))}}const j={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:r=>`data-${r}-target`,outletAttributeForScope:(r,e)=>`data-${r}-${e}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},P("abcdefghijklmnopqrstuvwxyz".split("").map(r=>[r,r]))),P("0123456789".split("").map(r=>[r,r])))};function P(r){return r.reduce((e,[t,s])=>Object.assign(Object.assign({},e),{[t]:s}),{})}class Le{constructor(e=document.documentElement,t=j){this.logger=console,this.debug=!1,this.logDebugActivity=(s,n,i={})=>{this.debug&&this.logFormattedMessage(s,n,i)},this.element=e,this.schema=t,this.dispatcher=new Z(this),this.router=new xe(this),this.actionDescriptorFilters=Object.assign({},Q)}static start(e,t){const s=new this(e,t);return s.start(),s}async start(){await Ve(),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>{n.controllerConstructor.shouldLoad&&this.router.loadDefinition(n)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>this.router.unloadIdentifier(n))}get controllers(){return this.router.contexts.map(e=>e.controller)}getControllerForElementAndIdentifier(e,t){const s=this.router.getContextForElementAndIdentifier(e,t);return s?s.controller:null}handleError(e,t,s){var n;this.logger.error(`%s
8
+
9
+ %o
10
+
11
+ %o`,t,e,s),(n=window.onerror)===null||n===void 0||n.call(window,t,"",0,0,e)}logFormattedMessage(e,t,s={}){s=Object.assign({application:this},s),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},s)),this.logger.groupEnd()}}function Ve(){return new Promise(r=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>r()):r()})}function Ke(r){return d(r,"classes").reduce((t,s)=>Object.assign(t,Ie(s)),{})}function Ie(r){return{[`${r}Class`]:{get(){const{classes:e}=this;if(e.has(r))return e.get(r);{const t=e.getAttributeName(r);throw new Error(`Missing attribute "${t}"`)}}},[`${r}Classes`]:{get(){return this.classes.getAll(r)}},[`has${u(r)}Class`]:{get(){return this.classes.has(r)}}}}function je(r){return d(r,"outlets").reduce((t,s)=>Object.assign(t,Pe(s)),{})}function R(r,e,t){return r.application.getControllerForElementAndIdentifier(e,t)}function U(r,e,t){let s=R(r,e,t);if(s||(r.application.router.proposeToConnectScopeForElementAndIdentifier(e,t),s=R(r,e,t),s))return s}function Pe(r){const e=y(r);return{[`${e}Outlet`]:{get(){const t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t){const n=U(this,t,r);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}Outlets`]:{get(){const t=this.outlets.findAll(r);return t.length>0?t.map(s=>{const n=U(this,s,r);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${e}OutletElement`]:{get(){const t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t)return t;throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(r)}},[`has${u(e)}Outlet`]:{get(){return this.outlets.has(r)}}}}function Re(r){return d(r,"targets").reduce((t,s)=>Object.assign(t,Ue(s)),{})}function Ue(r){return{[`${r}Target`]:{get(){const e=this.targets.find(r);if(e)return e;throw new Error(`Missing target element "${r}" for "${this.identifier}" controller`)}},[`${r}Targets`]:{get(){return this.targets.findAll(r)}},[`has${u(r)}Target`]:{get(){return this.targets.has(r)}}}}function _e(r){const e=pe(r,"values"),t={valueDescriptorMap:{get(){return e.reduce((s,n)=>{const i=_(n,this.identifier),o=this.data.getAttributeNameForKey(i.key);return Object.assign(s,{[o]:i})},{})}}};return e.reduce((s,n)=>Object.assign(s,ze(n)),t)}function ze(r,e){const t=_(r,e),{key:s,name:n,reader:i,writer:o}=t;return{[n]:{get(){const a=this.data.get(s);return a!==null?i(a):t.defaultValue},set(a){a===void 0?this.data.delete(s):this.data.set(s,o(a))}},[`has${u(n)}`]:{get(){return this.data.has(s)||t.hasCustomDefaultValue}}}}function _([r,e],t){return Ge({controller:t,token:r,typeDefinition:e})}function m(r){switch(r){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function f(r){switch(typeof r){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(r))return"array";if(Object.prototype.toString.call(r)==="[object Object]")return"object"}function qe(r){const{controller:e,token:t,typeObject:s}=r,n=S(s.type),i=S(s.default),o=n&&i,a=n&&!i,c=!n&&i,h=m(s.type),b=f(r.typeObject.default);if(a)return h;if(c)return b;if(h!==b){const J=e?`${e}.${t}`:t;throw new Error(`The specified default value for the Stimulus Value "${J}" must match the defined type "${h}". The provided default value of "${s.default}" is of type "${b}".`)}if(o)return h}function We(r){const{controller:e,token:t,typeDefinition:s}=r,i=qe({controller:e,token:t,typeObject:s}),o=f(s),a=m(s),c=i||o||a;if(c)return c;const h=e?`${e}.${s}`:t;throw new Error(`Unknown value type "${h}" for "${t}" value`)}function Je(r){const e=m(r);if(e)return z[e];const t=O(r,"default"),s=O(r,"type"),n=r;if(t)return n.default;if(s){const{type:i}=n,o=m(i);if(o)return z[o]}return r}function Ge(r){const{token:e,typeDefinition:t}=r,s=`${N(e)}-value`,n=We(r);return{type:n,key:s,name:v(s),get defaultValue(){return Je(t)},get hasCustomDefaultValue(){return f(t)!==void 0},reader:He[n],writer:q[n]||q.default}}const z={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},He={array(r){const e=JSON.parse(r);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${r}" of type "${f(e)}"`);return e},boolean(r){return!(r=="0"||String(r).toLowerCase()=="false")},number(r){return Number(r.replace(/_/g,""))},object(r){const e=JSON.parse(r);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${r}" of type "${f(e)}"`);return e},string(r){return r}},q={default:Ze,array:W,object:W};function W(r){return JSON.stringify(r)}function Ze(r){return`${r}`}class g{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:s={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){const a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:s,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}}g.blessings=[Ke,Re,_e,je],g.targets=[],g.outlets=[],g.values={};export{Le as Application,A as AttributeObserver,I as Context,g as Controller,E as ElementObserver,ce as IndexedMultimap,l as Multimap,L as SelectorObserver,V as StringMapObserver,k as TokenListObserver,B as ValueListObserver,w as add,j as defaultSchema,M as del,F as fetch,x as prune};
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 3.0.0
18
+ version: 3.1.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 3.0.0
25
+ version: 3.1.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rack
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -48,19 +48,28 @@ files:
48
48
  - README.md
49
49
  - lib/ruby_event_store/browser.rb
50
50
  - lib/ruby_event_store/browser/app.rb
51
- - lib/ruby_event_store/browser/gem_source.rb
52
- - lib/ruby_event_store/browser/get_event.rb
51
+ - lib/ruby_event_store/browser/extension_context.rb
53
52
  - lib/ruby_event_store/browser/get_events_from_stream.rb
54
- - lib/ruby_event_store/browser/get_stream.rb
55
- - lib/ruby_event_store/browser/json_api_event.rb
56
- - lib/ruby_event_store/browser/json_api_stream.rb
53
+ - lib/ruby_event_store/browser/get_events_from_streams.rb
54
+ - lib/ruby_event_store/browser/layout.rb
55
+ - lib/ruby_event_store/browser/renderer.rb
57
56
  - lib/ruby_event_store/browser/router.rb
58
57
  - lib/ruby_event_store/browser/urls.rb
59
58
  - lib/ruby_event_store/browser/version.rb
59
+ - lib/ruby_event_store/browser/views/_clipboard_icon.html.erb
60
+ - lib/ruby_event_store/browser/views/_clock_icon.html.erb
61
+ - lib/ruby_event_store/browser/views/_json_tree.html.erb
62
+ - lib/ruby_event_store/browser/views/_raw_section.html.erb
63
+ - lib/ruby_event_store/browser/views/_timestamp.html.erb
64
+ - lib/ruby_event_store/browser/views/events/show.html.erb
65
+ - lib/ruby_event_store/browser/views/layout.html.erb
66
+ - lib/ruby_event_store/browser/views/not_found.html.erb
67
+ - lib/ruby_event_store/browser/views/streams/show.html.erb
68
+ - lib/ruby_event_store/browser/views/swimlane/_rows.html.erb
69
+ - lib/ruby_event_store/browser/views/swimlane/show.html.erb
60
70
  - public/android-chrome-192x192.png
61
71
  - public/android-chrome-512x512.png
62
72
  - public/apple-touch-icon.png
63
- - public/bootstrap.js
64
73
  - public/favicon-16x16.png
65
74
  - public/favicon-32x32.png
66
75
  - public/favicon.ico
@@ -72,6 +81,7 @@ files:
72
81
  - public/ruby_event_store_browser.css
73
82
  - public/ruby_event_store_browser.js
74
83
  - public/safari-pinned-tab.svg
84
+ - public/stimulus-3.2.2.js
75
85
  homepage: https://railseventstore.org
76
86
  licenses:
77
87
  - MIT
@@ -88,14 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
98
  requirements:
89
99
  - - ">="
90
100
  - !ruby/object:Gem::Version
91
- version: '2.7'
101
+ version: '3.3'
92
102
  required_rubygems_version: !ruby/object:Gem::Requirement
93
103
  requirements:
94
104
  - - ">="
95
105
  - !ruby/object:Gem::Version
96
106
  version: '0'
97
107
  requirements: []
98
- rubygems_version: 3.7.1
108
+ rubygems_version: 3.6.9
99
109
  specification_version: 4
100
110
  summary: Event browser companion application for RubyEventStore
101
111
  test_files: []
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyEventStore
4
- module Browser
5
- class GemSource
6
- attr_reader :path
7
-
8
- def initialize(load_path)
9
- @path =
10
- load_path
11
- .select { |entry| String === entry }
12
- .find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z} }
13
- end
14
-
15
- def version
16
- if from_rubygems?
17
- path.split("/").fetch(-2).split("-").last
18
- elsif from_git?
19
- path.split("/").fetch(-3).split("-").last
20
- end
21
- end
22
-
23
- def from_rubygems?
24
- path.match? %r{/gems/ruby_event_store-browser-\d+\.\d+\.\d+/lib\z}
25
- end
26
-
27
- def from_git?
28
- path.match? %r{/bundler/gems/rails_event_store-[a-z0-9]{12}/ruby_event_store-browser/lib\z}
29
- end
30
- end
31
- end
32
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyEventStore
4
- module Browser
5
- class GetEvent
6
- def initialize(event_store:, event_id:)
7
- @event_store = event_store
8
- @event_id = event_id
9
- end
10
-
11
- def to_h
12
- {
13
- data: [
14
- JsonApiEvent.new(event, parent_event_id).to_h,
15
- { relationships: { streams: { data: streams } } },
16
- ].reduce(&:merge),
17
- }
18
- end
19
-
20
- private
21
-
22
- def streams
23
- event_store.streams_of(event_id).map { |stream| { "id" => stream.name, "type" => "streams" } }
24
- end
25
-
26
- attr_reader :event_store, :event_id
27
-
28
- def event
29
- @event ||= event_store.read.event!(event_id)
30
- end
31
-
32
- def parent_event_id
33
- event_store.read.event(event.metadata.fetch(:causation_id))&.event_id if event.metadata.has_key?(:causation_id)
34
- end
35
- end
36
- end
37
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyEventStore
4
- module Browser
5
- class GetStream
6
- def initialize(routing:, stream_name:, related_streams_query:)
7
- @routing = routing
8
- @stream_name = stream_name
9
- @related_streams_query = related_streams_query
10
- end
11
-
12
- def to_h
13
- { data: JsonApiStream.new(stream_name, events_from_stream_url, related_streams).to_h }
14
- end
15
-
16
- private
17
-
18
- attr_reader :stream_name, :routing, :related_streams_query
19
-
20
- def events_from_stream_url
21
- routing.paginated_events_from_stream_url(id: stream_name)
22
- end
23
-
24
- def related_streams
25
- related_streams_query.call(stream_name) unless related_streams_query.equal?(DEFAULT_RELATED_STREAMS_QUERY)
26
- end
27
- end
28
- end
29
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyEventStore
4
- module Browser
5
- class JsonApiEvent
6
- def initialize(event, parent_event_id)
7
- @event = event
8
- @parent_event_id = parent_event_id
9
- end
10
-
11
- def to_h
12
- {
13
- id: event.event_id,
14
- type: "events",
15
- attributes: {
16
- event_type: event.event_type,
17
- data: sanitize_infinity_values(event.data),
18
- metadata: metadata,
19
- correlation_stream_name: correlation_stream_name,
20
- causation_stream_name: causation_stream_name,
21
- type_stream_name: type_stream_name,
22
- parent_event_id: parent_event_id,
23
- },
24
- }
25
- end
26
-
27
- private
28
-
29
- attr_reader :event, :parent_event_id
30
-
31
- def sanitize_infinity_values(value)
32
- case value
33
- in Hash => hash
34
- hash.transform_values { |v| sanitize_infinity_values(v) }
35
- in Array => array
36
- array.map { |v| sanitize_infinity_values(v) }
37
- in Float => f if f.infinite?
38
- f.positive? ? "Infinity" : "-Infinity"
39
- in Float => f if f.nan?
40
- "NaN"
41
- else
42
- value
43
- end
44
- end
45
-
46
- def metadata
47
- event.metadata.to_h.tap do |m|
48
- m[:timestamp] = event.metadata.fetch(:timestamp).iso8601(TIMESTAMP_PRECISION)
49
- m[:valid_at] = event.metadata.fetch(:valid_at).iso8601(TIMESTAMP_PRECISION)
50
- end
51
- end
52
-
53
- def correlation_stream_name
54
- "$by_correlation_id_#{metadata.fetch(:correlation_id)}" if metadata.has_key?(:correlation_id)
55
- end
56
-
57
- def causation_stream_name
58
- "$by_causation_id_#{event.event_id}"
59
- end
60
-
61
- def type_stream_name
62
- "$by_type_#{event.event_type}"
63
- end
64
- end
65
- end
66
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyEventStore
4
- module Browser
5
- class JsonApiStream
6
- def initialize(stream_name, events_from_stream_url, related_streams)
7
- @stream_name = stream_name
8
- @events_from_stream_url = events_from_stream_url
9
- @related_streams = related_streams
10
- end
11
-
12
- def to_h
13
- {
14
- id: stream_name,
15
- type: "streams",
16
- attributes: {
17
- related_streams: related_streams,
18
- },
19
- relationships: {
20
- events: {
21
- links: {
22
- self: events_from_stream_url,
23
- },
24
- },
25
- },
26
- }
27
- end
28
-
29
- private
30
-
31
- attr_reader :stream_name, :events_from_stream_url, :related_streams
32
- end
33
- end
34
- end
data/public/bootstrap.js DELETED
@@ -1,30 +0,0 @@
1
- const flags = JSON.parse(
2
- document.querySelector("meta[name='ruby-event-store-browser-settings']").getAttribute("content")
3
- );
4
- flags.platform = navigator.platform;
5
- const app = Elm.Main.init({ flags });
6
-
7
- app.ports.copyToClipboard.subscribe(function (message) {
8
- navigator.clipboard.writeText(message);
9
- });
10
-
11
- app.ports.toggleDialog.subscribe(function (id) {
12
- const dialog = document.querySelector(`#${id}`);
13
- dialog.open ? dialog.close() : dialog.showModal();
14
- });
15
-
16
- app.ports.closeSearch.subscribe(function (id) {
17
- document.querySelector(`#${id}`).close();
18
- });
19
-
20
- window.addEventListener("keydown", function (event) {
21
- if (event.key === "k" && (event.ctrlKey || event.metaKey)) {
22
- app.ports.requestSearch.send(null);
23
- event.preventDefault();
24
- }
25
-
26
- if (event.key === "Escape") {
27
- app.ports.requestSearchClose.send(null);
28
- event.preventDefault();
29
- }
30
- });