cable_ready 5.0.0 → 5.0.2

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.
@@ -4,7 +4,7 @@
4
4
  })(this, (function(exports, morphdom) {
5
5
  "use strict";
6
6
  var name = "cable_ready";
7
- var version = "5.0.0";
7
+ var version = "5.0.1";
8
8
  var description = "CableReady helps you create great real-time user experiences by making it simple to trigger client-side DOM changes from server-side Ruby.";
9
9
  var keywords = [ "ruby", "rails", "websockets", "actioncable", "cable", "ssr", "stimulus_reflex", "client-side", "dom" ];
10
10
  var homepage = "https://cableready.stimulusreflex.com";
@@ -44,7 +44,7 @@
44
44
  rollup: "^3.19.1",
45
45
  sinon: "^15.0.2",
46
46
  vite: "^4.1.4",
47
- vitepress: "^1.0.0-alpha.56",
47
+ vitepress: "^1.0.0-beta.1",
48
48
  "vitepress-plugin-search": "^1.0.4-alpha.19"
49
49
  };
50
50
  var packageInfo = {
@@ -248,8 +248,28 @@
248
248
  console.error(`Could not fetch ${url}`);
249
249
  }
250
250
  }
251
+ class BoundedQueue {
252
+ constructor(maxSize) {
253
+ this.maxSize = maxSize;
254
+ this.queue = [];
255
+ }
256
+ push(item) {
257
+ if (this.isFull()) {
258
+ // Remove the oldest item to make space for the new one
259
+ this.shift();
260
+ }
261
+ this.queue.push(item);
262
+ }
263
+ shift() {
264
+ return this.queue.shift();
265
+ }
266
+ isFull() {
267
+ return this.queue.length === this.maxSize;
268
+ }
269
+ }
251
270
  var utils = Object.freeze({
252
271
  __proto__: null,
272
+ BoundedQueue: BoundedQueue,
253
273
  after: after,
254
274
  assignFocus: assignFocus,
255
275
  before: before,
@@ -912,38 +932,48 @@
912
932
  };
913
933
  const request = (data, blocks) => {
914
934
  if (Debug.disabled) return;
915
- console.log(`↑ Updatable request affecting ${blocks.length} element(s): `, {
935
+ const message = `↑ Updatable request affecting ${blocks.length} element(s): `;
936
+ console.log(message, {
916
937
  elements: blocks.map((b => b.element)),
917
938
  identifiers: blocks.map((b => b.element.getAttribute("identifier"))),
918
939
  data: data
919
940
  });
941
+ return message;
920
942
  };
921
943
  const cancel = (timestamp, reason) => {
922
944
  if (Debug.disabled) return;
923
945
  const duration = new Date - timestamp;
924
- console.log(`❌ Updatable request canceled after ${duration}ms: ${reason}`);
946
+ const message = `❌ Updatable request canceled after ${duration}ms: ${reason}`;
947
+ console.log(message);
948
+ return message;
925
949
  };
926
950
  const response = (timestamp, element, urls) => {
927
951
  if (Debug.disabled) return;
928
952
  const duration = new Date - timestamp;
929
- console.log(`↓ Updatable response: All URLs fetched in ${duration}ms`, {
953
+ const message = `↓ Updatable response: All URLs fetched in ${duration}ms`;
954
+ console.log(message, {
930
955
  element: element,
931
956
  urls: urls
932
957
  });
958
+ return message;
933
959
  };
934
960
  const morphStart = (timestamp, element) => {
935
961
  if (Debug.disabled) return;
936
962
  const duration = new Date - timestamp;
937
- console.log(`↻ Updatable morph: starting after ${duration}ms`, {
963
+ const message = `↻ Updatable morph: starting after ${duration}ms`;
964
+ console.log(message, {
938
965
  element: element
939
966
  });
967
+ return message;
940
968
  };
941
969
  const morphEnd = (timestamp, element) => {
942
970
  if (Debug.disabled) return;
943
971
  const duration = new Date - timestamp;
944
- console.log(`↺ Updatable morph: completed after ${duration}ms`, {
972
+ const message = `↺ Updatable morph: completed after ${duration}ms`;
973
+ console.log(message, {
945
974
  element: element
946
975
  });
976
+ return message;
947
977
  };
948
978
  var Log = {
949
979
  request: request,
@@ -952,6 +982,55 @@
952
982
  morphStart: morphStart,
953
983
  morphEnd: morphEnd
954
984
  };
985
+ class AppearanceObserver {
986
+ constructor(delegate, element = null) {
987
+ this.delegate = delegate;
988
+ this.element = element || delegate;
989
+ this.started = false;
990
+ this.intersecting = false;
991
+ this.intersectionObserver = new IntersectionObserver(this.intersect);
992
+ }
993
+ start() {
994
+ if (!this.started) {
995
+ this.started = true;
996
+ this.intersectionObserver.observe(this.element);
997
+ this.observeVisibility();
998
+ }
999
+ }
1000
+ stop() {
1001
+ if (this.started) {
1002
+ this.started = false;
1003
+ this.intersectionObserver.unobserve(this.element);
1004
+ this.unobserveVisibility();
1005
+ }
1006
+ }
1007
+ observeVisibility=() => {
1008
+ document.addEventListener("visibilitychange", this.handleVisibilityChange);
1009
+ };
1010
+ unobserveVisibility=() => {
1011
+ document.removeEventListener("visibilitychange", this.handleVisibilityChange);
1012
+ };
1013
+ intersect=entries => {
1014
+ entries.forEach((entry => {
1015
+ if (entry.target === this.element) {
1016
+ if (entry.isIntersecting && document.visibilityState === "visible") {
1017
+ this.intersecting = true;
1018
+ this.delegate.appearedInViewport();
1019
+ } else {
1020
+ this.intersecting = false;
1021
+ this.delegate.disappearedFromViewport();
1022
+ }
1023
+ }
1024
+ }));
1025
+ };
1026
+ handleVisibilityChange=event => {
1027
+ if (document.visibilityState === "visible" && this.intersecting) {
1028
+ this.delegate.appearedInViewport();
1029
+ } else {
1030
+ this.delegate.disappearedFromViewport();
1031
+ }
1032
+ };
1033
+ }
955
1034
  const template = `\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n`;
956
1035
  class UpdatesForElement extends SubscribingElement {
957
1036
  static get tagName() {
@@ -963,6 +1042,11 @@
963
1042
  mode: "open"
964
1043
  });
965
1044
  shadowRoot.innerHTML = template;
1045
+ this.triggerElementLog = new BoundedQueue(10);
1046
+ this.targetElementLog = new BoundedQueue(10);
1047
+ this.appearanceObserver = new AppearanceObserver(this);
1048
+ this.visible = false;
1049
+ this.didTransitionToVisible = false;
966
1050
  }
967
1051
  async connectedCallback() {
968
1052
  if (this.preview) return;
@@ -973,18 +1057,27 @@
973
1057
  } else {
974
1058
  console.error("The `cable_ready_updates_for` helper cannot connect. You must initialize CableReady with an Action Cable consumer.");
975
1059
  }
1060
+ if (this.observeAppearance) {
1061
+ this.appearanceObserver.start();
1062
+ }
1063
+ }
1064
+ disconnectedCallback() {
1065
+ if (this.observeAppearance) {
1066
+ this.appearanceObserver.stop();
1067
+ }
976
1068
  }
977
1069
  async update(data) {
978
1070
  this.lastUpdateTimestamp = new Date;
979
1071
  const blocks = Array.from(document.querySelectorAll(this.query), (element => new Block(element))).filter((block => block.shouldUpdate(data)));
980
- Log.request(data, blocks);
1072
+ this.triggerElementLog.push(`${(new Date).toLocaleString()}: ${Log.request(data, blocks)}`);
981
1073
  if (blocks.length === 0) {
982
- Log.cancel(this.lastUpdateTimestamp, "All elements filtered out");
1074
+ this.triggerElementLog.push(`${(new Date).toLocaleString()}: ${Log.cancel(this.lastUpdateTimestamp, "All elements filtered out")}`);
983
1075
  return;
984
1076
  }
985
1077
  // first <cable-ready-updates-for> element in the DOM *at any given moment* updates all of the others
986
- if (blocks[0].element !== this) {
987
- Log.cancel(this.lastUpdateTimestamp, "Update already requested");
1078
+ // if the element becomes visible though, we have to overrule and load it
1079
+ if (blocks[0].element !== this && !this.didTransitionToVisible) {
1080
+ this.triggerElementLog.push(`${(new Date).toLocaleString()}: ${Log.cancel(this.lastUpdateTimestamp, "Update already requested")}`);
988
1081
  return;
989
1082
  }
990
1083
  // hold a reference to the active element so that it can be restored after the morph
@@ -1000,7 +1093,7 @@
1000
1093
  this.html[url] = await response.text();
1001
1094
  }
1002
1095
  })));
1003
- Log.response(this.lastUpdateTimestamp, this, uniqueUrls);
1096
+ this.triggerElementLog.push(`${(new Date).toLocaleString()}: ${Log.response(this.lastUpdateTimestamp, this, uniqueUrls)}`);
1004
1097
  // track current block index for each URL; referred to as fragments
1005
1098
  this.index = {};
1006
1099
  blocks.forEach((block => {
@@ -1009,6 +1102,17 @@
1009
1102
  block.process(data, this.html, this.index, this.lastUpdateTimestamp);
1010
1103
  }));
1011
1104
  }
1105
+ appearedInViewport() {
1106
+ if (!this.visible) {
1107
+ // transition from invisible to visible forces update
1108
+ this.didTransitionToVisible = true;
1109
+ this.update({});
1110
+ }
1111
+ this.visible = true;
1112
+ }
1113
+ disappearedFromViewport() {
1114
+ this.visible = false;
1115
+ }
1012
1116
  get query() {
1013
1117
  return `${this.tagName}[identifier="${this.identifier}"]`;
1014
1118
  }
@@ -1018,20 +1122,23 @@
1018
1122
  get debounce() {
1019
1123
  return this.hasAttribute("debounce") ? parseInt(this.getAttribute("debounce")) : 20;
1020
1124
  }
1125
+ get observeAppearance() {
1126
+ return this.hasAttribute("observe-appearance");
1127
+ }
1021
1128
  }
1022
1129
  class Block {
1023
1130
  constructor(element) {
1024
1131
  this.element = element;
1025
1132
  }
1026
- async process(data, html, index, startTimestamp) {
1027
- const blockIndex = index[this.url];
1133
+ async process(data, html, fragmentsIndex, startTimestamp) {
1134
+ const blockIndex = fragmentsIndex[this.url];
1028
1135
  const template = document.createElement("template");
1029
1136
  this.element.setAttribute("updating", "updating");
1030
1137
  template.innerHTML = String(html[this.url]).trim();
1031
1138
  await this.resolveTurboFrames(template.content);
1032
1139
  const fragments = template.content.querySelectorAll(this.query);
1033
1140
  if (fragments.length <= blockIndex) {
1034
- console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}.`);
1141
+ console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}, the offending element is:`, this.element);
1035
1142
  return;
1036
1143
  }
1037
1144
  const operation = {
@@ -1040,17 +1147,18 @@
1040
1147
  permanentAttributeName: "data-ignore-updates"
1041
1148
  };
1042
1149
  dispatch(this.element, "cable-ready:before-update", operation);
1043
- Log.morphStart(startTimestamp, this.element);
1150
+ this.element.targetElementLog.push(`${(new Date).toLocaleString()}: ${Log.morphStart(startTimestamp, this.element)}`);
1044
1151
  morphdom(this.element, fragments[blockIndex], {
1045
1152
  childrenOnly: true,
1046
1153
  onBeforeElUpdated: shouldMorph(operation),
1047
1154
  onElUpdated: _ => {
1048
1155
  this.element.removeAttribute("updating");
1156
+ this.element.didTransitionToVisible = false;
1049
1157
  dispatch(this.element, "cable-ready:after-update", operation);
1050
1158
  assignFocus(operation.focusSelector);
1051
1159
  }
1052
1160
  });
1053
- Log.morphEnd(startTimestamp, this.element);
1161
+ this.element.targetElementLog.push(`${(new Date).toLocaleString()}: ${Log.morphEnd(startTimestamp, this.element)}`);
1054
1162
  }
1055
1163
  async resolveTurboFrames(documentFragment) {
1056
1164
  const reloadingTurboFrames = [ ...documentFragment.querySelectorAll('turbo-frame[src]:not([loading="lazy"])') ];
@@ -1072,7 +1180,7 @@
1072
1180
  }
1073
1181
  shouldUpdate(data) {
1074
1182
  // if everything that could prevent an update is false, update this block
1075
- return !this.ignoresInnerUpdates && this.hasChangesSelectedForUpdate(data);
1183
+ return !this.ignoresInnerUpdates && this.hasChangesSelectedForUpdate(data) && (!this.observeAppearance || this.visible);
1076
1184
  }
1077
1185
  hasChangesSelectedForUpdate(data) {
1078
1186
  // if there's an only attribute, only update if at least one of the attributes changed is in the allow list
@@ -1092,6 +1200,12 @@
1092
1200
  get query() {
1093
1201
  return this.element.query;
1094
1202
  }
1203
+ get visible() {
1204
+ return this.element.visible;
1205
+ }
1206
+ get observeAppearance() {
1207
+ return this.element.observeAppearance;
1208
+ }
1095
1209
  }
1096
1210
  const registerInnerUpdates = () => {
1097
1211
  document.addEventListener("stimulus-reflex:before", (event => {
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("morphdom")):"function"==typeof define&&define.amd?define(["exports","morphdom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CableReady={},e.morphdom)}(this,(function(e,t){"use strict";var n="5.0.0-pre9";const o={INPUT:!0,TEXTAREA:!0,SELECT:!0},r={INPUT:!0,TEXTAREA:!0,OPTION:!0},s={"datetime-local":!0,"select-multiple":!0,"select-one":!0,color:!0,date:!0,datetime:!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,textarea:!0,time:!0,url:!0,week:!0};let a;var i={get element(){return a},set(e){a=e}};const l=e=>o[e.tagName]&&s[e.type],c=e=>{const t=(e&&e.nodeType===Node.ELEMENT_NODE?e:document.querySelector(e))||i.element;t&&t.focus&&t.focus()},u=(e,t,n={})=>{const o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(o),window.jQuery&&window.jQuery(e).trigger(t,n)},d=e=>document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,m=(e,t=!1)=>{const n=document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),o=[];for(let e=0;e<n.snapshotLength;e++)o.push(n.snapshotItem(e));return t?o.reverse():o},h=e=>Array.from(e).flat(),p=(e,t)=>{Array.from(e.selectAll?e.element:[e.element]).forEach(t)},f=(b=function(e,t,n){return e+(n?"-":"")+t.toLowerCase()},function(e){return g(e).reduce(b,"")});var b;const g=e=>(e=null==e?"":e).match(/([A-Z]{2,}|[0-9]+|[A-Z]?[a-z]+|[A-Z])/g)||[],y=(e,t)=>!e.cancel&&(e.delay?setTimeout(t,e.delay):t(),!0),w=(e,t)=>u(e,`cable-ready:before-${f(t.operation)}`,t),E=(e,t)=>u(e,`cable-ready:after-${f(t.operation)}`,t);function v(e,t=250){let n;return(...o)=>{n&&clearTimeout(n),n=setTimeout((()=>e.apply(this,o)),t)}}function A(e){if(!e.ok)throw Error(e.statusText);return e}function T(e){return void 0===e||["string","number","boolean"].includes(typeof e)||console.warn(`Operation expects a string, number or boolean, but got ${e} (${typeof e})`),null!=e?e:""}function S(e){return void 0!==e&&"string"!=typeof e&&console.warn(`Operation expects a string, but got ${e} (${typeof e})`),null!=e?String(e):""}function C(e){return void 0===e||Array.isArray(e)||console.warn(`Operation expects an array, but got ${e} (${typeof e})`),null!=e?Array.from(e):[]}function M(e){return void 0!==e&&"object"!=typeof e&&console.warn(`Operation expects an object, but got ${e} (${typeof e})`),null!=e?Object(e):{}}function x(e){return void 0===e||Array.isArray(e)||"string"==typeof e||console.warn(`Operation expects an Array or a String, but got ${e} (${typeof e})`),null==e?"":Array.isArray(e)?Array.from(e):String(e)}async function O(e,t){try{const n=await fetch(e,{headers:{"X-REQUESTED-WITH":"XmlHttpRequest",...t}});if(null==n)return;return A(n),n}catch(t){console.error(`Could not fetch ${e}`)}}var L=Object.freeze({__proto__:null,after:E,assignFocus:c,before:w,debounce:v,dispatch:u,fragmentToString:function(e){return(new XMLSerializer).serializeToString(e)},getClassNames:h,graciouslyFetch:O,handleErrors:A,isTextInput:l,kebabize:f,operate:y,processElements:p,safeArray:C,safeObject:M,safeScalar:T,safeString:S,safeStringOrArray:x,xpathToElement:d,xpathToElementArray:m});const R=e=>(t,n)=>!P.map((o=>"function"!=typeof o||o(e,t,n))).includes(!1),$=e=>t=>{D.forEach((n=>{"function"==typeof n&&n(e,t)}))},U=(e,t,n)=>!(!r[t.tagName]&&t.isEqualNode(n)),k=(e,t,n)=>t!==i.element||!t.isContentEditable,q=(e,t,n)=>{const{permanentAttributeName:o}=e;if(!o)return!0;const r=t.closest(`[${o}]`);if(!r&&t===i.element&&l(t)){const e={value:!0};return Array.from(n.attributes).forEach((n=>{e[n.name]||t.setAttribute(n.name,n.value)})),!1}return!r},P=[U,q,k],D=[];var N=Object.freeze({__proto__:null,didMorph:$,didMorphCallbacks:D,shouldMorph:R,shouldMorphCallbacks:P,verifyNotContentEditable:k,verifyNotMutable:U,verifyNotPermanent:q}),H={append:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("beforeend",T(n)),c(o)})),E(t,e)}))},graft:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{parent:n,focusSelector:o}=e,r=document.querySelector(n);r&&(r.appendChild(t),c(o))})),E(t,e)}))},innerHtml:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.innerHTML=T(n),c(o)})),E(t,e)}))},insertAdjacentHtml:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{html:n,position:o,focusSelector:r}=e;t.insertAdjacentHTML(o||"beforeend",T(n)),c(r)})),E(t,e)}))},insertAdjacentText:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{text:n,position:o,focusSelector:r}=e;t.insertAdjacentText(o||"beforeend",T(n)),c(r)})),E(t,e)}))},outerHtml:e=>{p(e,(t=>{const n=t.parentElement,o=n&&Array.from(n.children).indexOf(t);w(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=T(n),c(o)})),E(n?n.children[o]:document.documentElement,e)}))},prepend:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.insertAdjacentHTML("afterbegin",T(n)),c(o)})),E(t,e)}))},remove:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{focusSelector:n}=e;t.remove(),c(n)})),E(document,e)}))},replace:e=>{p(e,(t=>{const n=t.parentElement,o=n&&Array.from(n.children).indexOf(t);w(t,e),y(e,(()=>{const{html:n,focusSelector:o}=e;t.outerHTML=T(n),c(o)})),E(n?n.children[o]:document.documentElement,e)}))},textContent:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{text:n,focusSelector:o}=e;t.textContent=T(n),c(o)})),E(t,e)}))},addCssClass:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n}=e;t.classList.add(...h([x(n)]))})),E(t,e)}))},removeAttribute:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n}=e;t.removeAttribute(S(n))})),E(t,e)}))},removeCssClass:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n}=e;t.classList.remove(...h([x(n)])),0===t.classList.length&&t.removeAttribute("class")})),E(t,e)}))},setAttribute:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n,value:o}=e;t.setAttribute(S(n),T(o))})),E(t,e)}))},setDatasetProperty:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n,value:o}=e;t.dataset[S(n)]=T(o)})),E(t,e)}))},setProperty:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n,value:o}=e;n in t&&(t[S(n)]=T(o))})),E(t,e)}))},setStyle:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n,value:o}=e;t.style[S(n)]=T(o)})),E(t,e)}))},setStyles:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{styles:n}=e;for(let[e,o]of Object.entries(n))t.style[S(e)]=T(o)})),E(t,e)}))},setValue:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{value:n}=e;t.value=T(n)})),E(t,e)}))},dispatchEvent:e=>{p(e,(t=>{w(t,e),y(e,(()=>{const{name:n,detail:o}=e;u(t,S(n),M(o))})),E(t,e)}))},setMeta:e=>{w(document,e),y(e,(()=>{const{name:t,content:n}=e;let o=document.head.querySelector(`meta[name='${t}']`);o||(o=document.createElement("meta"),o.name=S(t),document.head.appendChild(o)),o.content=T(n)})),E(document,e)},setTitle:e=>{w(document,e),y(e,(()=>{const{title:t}=e;document.title=T(t)})),E(document,e)},clearStorage:e=>{w(document,e),y(e,(()=>{const{type:t}=e;("session"===t?sessionStorage:localStorage).clear()})),E(document,e)},go:e=>{w(window,e),y(e,(()=>{const{delta:t}=e;history.go(t)})),E(window,e)},pushState:e=>{w(window,e),y(e,(()=>{const{state:t,title:n,url:o}=e;history.pushState(M(t),S(n),S(o))})),E(window,e)},redirectTo:e=>{w(window,e),y(e,(()=>{let{url:t,action:n,turbo:o}=e;n=n||"advance",t=S(t),void 0===o&&(o=!0),o?(window.Turbo&&window.Turbo.visit(t,{action:n}),window.Turbolinks&&window.Turbolinks.visit(t,{action:n}),window.Turbo||window.Turbolinks||(window.location.href=t)):window.location.href=t})),E(window,e)},reload:e=>{w(window,e),y(e,(()=>{window.location.reload()})),E(window,e)},removeStorageItem:e=>{w(document,e),y(e,(()=>{const{key:t,type:n}=e;("session"===n?sessionStorage:localStorage).removeItem(S(t))})),E(document,e)},replaceState:e=>{w(window,e),y(e,(()=>{const{state:t,title:n,url:o}=e;history.replaceState(M(t),S(n),S(o))})),E(window,e)},scrollIntoView:e=>{const{element:t}=e;w(t,e),y(e,(()=>{t.scrollIntoView(e)})),E(t,e)},setCookie:e=>{w(document,e),y(e,(()=>{const{cookie:t}=e;document.cookie=T(t)})),E(document,e)},setFocus:e=>{const{element:t}=e;w(t,e),y(e,(()=>{c(t)})),E(t,e)},setStorageItem:e=>{w(document,e),y(e,(()=>{const{key:t,value:n,type:o}=e;("session"===o?sessionStorage:localStorage).setItem(S(t),T(n))})),E(document,e)},consoleLog:e=>{w(document,e),y(e,(()=>{const{message:t,level:n}=e;n&&["warn","info","error"].includes(n)?console[n](t):console.log(t)})),E(document,e)},consoleTable:e=>{w(document,e),y(e,(()=>{const{data:t,columns:n}=e;console.table(t,C(n))})),E(document,e)},notification:e=>{w(document,e),y(e,(()=>{const{title:t,options:n}=e;Notification.requestPermission().then((o=>{e.permission=o,"granted"===o&&new Notification(S(t),M(n))}))})),E(document,e)},morph:e=>{p(e,(n=>{const{html:o}=e,r=document.createElement("template");r.innerHTML=String(T(o)).trim(),e.content=r.content;const s=n.parentElement,a=s&&Array.from(s.children).indexOf(n);w(n,e),y(e,(()=>{const{childrenOnly:o,focusSelector:s}=e;t(n,o?r.content:r.innerHTML,{childrenOnly:!!o,onBeforeElUpdated:R(e),onElUpdated:$(e)}),c(s)})),E(s?s.children[a]:document.documentElement,e)}))}};let I=H;const _=e=>{I={...I,...e}};var j={get all(){return I}};let F="warn";var z={get behavior(){return F},set(e){["warn","ignore","event","exception"].includes(e)?F=e:console.warn("Invalid 'onMissingElement' option. Defaulting to 'warn'.")}};const X=(e,t={onMissingElement:z.behavior})=>{const n={};e.forEach((e=>{e.batch&&(n[e.batch]=n[e.batch]?++n[e.batch]:1)})),e.forEach((e=>{const o=e.operation;try{if(e.selector?e.xpath?e.element=e.selectAll?m(e.selector):d(e.selector):e.element=e.selectAll?document.querySelectorAll(e.selector):document.querySelector(e.selector):e.element=document,e.element||"ignore"!==t.onMissingElement){i.set(document.activeElement);const t=j.all[o];t?(t(e),e.batch&&0==--n[e.batch]&&u(document,"cable-ready:batch-complete",{batch:e.batch})):console.error(`CableReady couldn't find the "${o}" operation. Make sure you use the camelized form when calling an operation method.`)}}catch(n){if(e.element)console.error(`CableReady detected an error in ${o||"operation"}: ${n.message}. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`),console.error(n);else{const n=`CableReady ${o||""} operation failed due to missing DOM element for selector: '${e.selector}'`;switch(t.onMissingElement){case"ignore":break;case"event":u(document,"cable-ready:missing-element",{warning:n,operation:e});break;case"exception":throw n;default:console.warn(n)}}}}))};class V extends HTMLElement{disconnectedCallback(){this.channel&&this.channel.unsubscribe()}createSubscription(e,t,n){this.channel=e.subscriptions.create({channel:t,identifier:this.identifier},{received:n})}get preview(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}get identifier(){return this.getAttribute("identifier")}}let Y;const Q=[25,50,75,100,200,250,500,800,1e3,2e3],Z=async(e=0)=>{if(Y)return Y;if(e>=Q.length)throw new Error("Couldn't obtain a Action Cable consumer within 5s");var t;return await(t=Q[e],new Promise((e=>setTimeout(e,t)))),await Z(e+1)};var B={setConsumer(e){Y=e},get consumer(){return Y},getConsumer:async()=>await Z()};class W extends V{static define(){customElements.get("stream-from")||customElements.define("stream-from",this)}async connectedCallback(){if(this.preview)return;const e=await B.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.performOperations.bind(this)):console.error("The `stream_from` helper cannot connect. You must initialize CableReady with an Action Cable consumer.")}performOperations(e){e.cableReady&&X(e.operations,{onMissingElement:this.onMissingElement})}get onMissingElement(){const e=this.getAttribute("missing")||z.behavior;return["warn","ignore","event"].includes(e)?e:(console.warn("Invalid 'missing' attribute. Defaulting to 'warn'."),"warn")}}let G=!1;var J={get enabled(){return G},get disabled(){return!G},get value(){return G},set(e){G=!!e},set debug(e){G=!!e}};var K=(e,t)=>{J.disabled||console.log(`↑ Updatable request affecting ${t.length} element(s): `,{elements:t.map((e=>e.element)),identifiers:t.map((e=>e.element.getAttribute("identifier"))),data:e})},ee=(e,t)=>{if(J.disabled)return;const n=new Date-e;console.log(`❌ Updatable request canceled after ${n}ms: ${t}`)},te=(e,t,n)=>{if(J.disabled)return;const o=new Date-e;console.log(`↓ Updatable response: All URLs fetched in ${o}ms`,{element:t,urls:n})},ne=(e,t)=>{if(J.disabled)return;const n=new Date-e;console.log(`↻ Updatable morph: starting after ${n}ms`,{element:t})},oe=(e,t)=>{if(J.disabled)return;const n=new Date-e;console.log(`↺ Updatable morph: completed after ${n}ms`,{element:t})};class re extends V{static define(){customElements.get("updates-for")||customElements.define("updates-for",this)}constructor(){super();this.attachShadow({mode:"open"}).innerHTML="\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n"}async connectedCallback(){if(this.preview)return;this.update=v(this.update.bind(this),this.debounce);const e=await B.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.update):console.error("The `updates-for` helper cannot connect. You must initialize CableReady with an Action Cable consumer.")}async update(e){this.lastUpdateTimestamp=new Date;const t=Array.from(document.querySelectorAll(this.query),(e=>new se(e))).filter((t=>t.shouldUpdate(e)));if(K(e,t),0===t.length)return void ee(this.lastUpdateTimestamp,"All elements filtered out");if(t[0].element!==this)return void ee(this.lastUpdateTimestamp,"Update already requested");i.set(document.activeElement),this.html={};const n=[...new Set(t.map((e=>e.url)))];await Promise.all(n.map((async e=>{if(!this.html.hasOwnProperty(e)){const t=await O(e,{"X-Cable-Ready":"update"});this.html[e]=await t.text()}}))),te(this.lastUpdateTimestamp,this,n),this.index={},t.forEach((t=>{this.index.hasOwnProperty(t.url)?this.index[t.url]++:this.index[t.url]=0,t.process(e,this.html,this.index,this.lastUpdateTimestamp)}))}get query(){return`updates-for[identifier="${this.identifier}"]`}get identifier(){return this.getAttribute("identifier")}get debounce(){return this.hasAttribute("debounce")?parseInt(this.getAttribute("debounce")):20}}class se{constructor(e){this.element=e}async process(e,n,o,r){const s=o[this.url],a=document.createElement("template");this.element.setAttribute("updating","updating"),a.innerHTML=String(n[this.url]).trim(),await this.resolveTurboFrames(a.content);const i=a.content.querySelectorAll(this.query);if(i.length<=s)return void console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}.`);const l={element:this.element,html:i[s],permanentAttributeName:"data-ignore-updates"};u(this.element,"cable-ready:before-update",l),ne(r,this.element),t(this.element,i[s],{childrenOnly:!0,onBeforeElUpdated:R(l),onElUpdated:e=>{this.element.removeAttribute("updating"),u(this.element,"cable-ready:after-update",l),c(l.focusSelector)}}),oe(r,this.element)}async resolveTurboFrames(e){const t=[...e.querySelectorAll('turbo-frame[src]:not([loading="lazy"])')];return Promise.all(t.map((e=>new Promise((async t=>{const n=await O(e.getAttribute("src"),{"Turbo-Frame":e.id,"X-Cable-Ready":"update"}),o=document.createElement("template");o.innerHTML=await n.text(),await this.resolveTurboFrames(o.content);const r=`turbo-frame#${e.id}`,s=o.content.querySelector(r),a=s?s.innerHTML.trim():"";docFragment.querySelector(r).innerHTML=a,t()})))))}shouldUpdate(e){return!this.ignoresInnerUpdates&&this.hasChangesSelectedForUpdate(e)}hasChangesSelectedForUpdate(e){const t=this.element.getAttribute("only");return!(t&&e.changed&&!t.split(" ").some((t=>e.changed.includes(t))))}get ignoresInnerUpdates(){return this.element.hasAttribute("ignore-inner-updates")&&this.element.hasAttribute("performing-inner-update")}get url(){return this.element.hasAttribute("url")?this.element.getAttribute("url"):location.href}get identifier(){return this.element.identifier}get query(){return this.element.query}}const ae=e=>{const t=e&&e.parentElement&&e.parentElement.closest("updates-for");t&&(t.setAttribute("performing-inner-update",""),ae(t))},ie=e=>{const t=e&&e.parentElement&&e.parentElement.closest("updates-for");t&&(t.removeAttribute("performing-inner-update"),ie(t))},le=()=>{document.addEventListener("stimulus-reflex:before",(e=>{ae(e.detail.element)})),document.addEventListener("stimulus-reflex:after",(e=>{setTimeout((()=>{ie(e.detail.element)}))})),document.addEventListener("turbo:submit-start",(e=>{ae(e.target)})),document.addEventListener("turbo:submit-end",(e=>{setTimeout((()=>{ie(e.target)}))})),document.addEventListener("turbo-boost:command:start",(e=>{ae(e.target)})),document.addEventListener("turbo-boost:command:finish",(e=>{setTimeout((()=>{ie(e.target)}))})),document.addEventListener("turbo-boost:command:error",(e=>{setTimeout((()=>{ie(e.target)}))})),W.define(),re.define()},ce={perform:X,performAsync:(e,t={onMissingElement:z.behavior})=>new Promise(((n,o)=>{try{n(X(e,t))}catch(e){o(e)}})),shouldMorphCallbacks:P,didMorphCallbacks:D,initialize:(e={})=>{const{consumer:t,onMissingElement:n,debug:o}=e;J.set(!!o),t?B.setConsumer(t):console.error("CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`."),n&&MissingElement.set(n),le()},addOperation:(e,t)=>{const n={};n[e]=t,_(n)},addOperations:e=>{_(e)},version:n,cable:B,get DOMOperations(){return console.warn("DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`"),j.all},get operations(){return j.all},get consumer(){return B.consumer}};window.CableReady=ce,e.MorphCallbacks=N,e.StreamFromElement=W,e.SubscribingElement=V,e.UpdatesForElement=re,e.Utils=L,e.default=ce,Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=cable_ready.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cable_ready.umd.min.js","sources":["../../../javascript/enums.js","../../../javascript/active_element.js","../../../javascript/utils.js","../../../javascript/morph_callbacks.js","../../../javascript/operations.js","../../../javascript/operation_store.js","../../../javascript/missing_element.js","../../../javascript/cable_ready.js","../../../javascript/elements/subscribing_element.js","../../../javascript/cable_consumer.js","../../../javascript/elements/stream_from_element.js","../../../javascript/debug.js","../../../javascript/updatable/log.js","../../../javascript/elements/updates_for_element.js","../../../javascript/updatable/inner_updates_compat.js","../../../javascript/elements/index.js","../../../javascript/index.js"],"sourcesContent":["export const inputTags = {\n INPUT: true,\n TEXTAREA: true,\n SELECT: true\n}\n\nexport const mutableTags = {\n INPUT: true,\n TEXTAREA: true,\n OPTION: true\n}\n\nexport const textInputTypes = {\n 'datetime-local': true,\n 'select-multiple': true,\n 'select-one': true,\n color: true,\n date: true,\n datetime: true,\n email: true,\n month: true,\n number: true,\n password: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n textarea: true,\n time: true,\n url: true,\n week: true\n}\n","let activeElement\n\nexport default {\n get element () {\n return activeElement\n },\n set (element) {\n activeElement = element\n }\n}\n","import { inputTags, textInputTypes } from './enums'\nimport ActiveElement from './active_element'\n\n// Indicates if the passed element is considered a text input.\n//\nconst isTextInput = element => {\n return inputTags[element.tagName] && textInputTypes[element.type]\n}\n\n// Assigns focus to the appropriate element... preferring the explicitly passed selector\n//\n// * selector - a CSS selector for the element that should have focus\n//\nconst assignFocus = selector => {\n const element =\n selector && selector.nodeType === Node.ELEMENT_NODE\n ? selector\n : document.querySelector(selector)\n const focusElement = element || ActiveElement.element\n if (focusElement && focusElement.focus) focusElement.focus()\n}\n\n// Dispatches an event on the passed element\n//\n// * element - the element\n// * name - the name of the event\n// * detail - the event detail\n//\nconst dispatch = (element, name, detail = {}) => {\n const init = { bubbles: true, cancelable: true, detail }\n const event = new CustomEvent(name, init)\n element.dispatchEvent(event)\n if (window.jQuery) window.jQuery(element).trigger(name, detail)\n}\n\n// Accepts an xPath query and returns the element found at that position in the DOM\n//\nconst xpathToElement = xpath => {\n return document.evaluate(\n xpath,\n document,\n null,\n XPathResult.FIRST_ORDERED_NODE_TYPE,\n null\n ).singleNodeValue\n}\n\n// Accepts an xPath query and returns all matching elements in the DOM\n//\nconst xpathToElementArray = (xpath, reverse = false) => {\n const snapshotList = document.evaluate(\n xpath,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n )\n const snapshots = []\n\n for (let i = 0; i < snapshotList.snapshotLength; i++) {\n snapshots.push(snapshotList.snapshotItem(i))\n }\n\n return reverse ? snapshots.reverse() : snapshots\n}\n\n// Return an array with the class names to be used\n//\n// * names - could be a string or an array of strings for multiple classes.\n//\nconst getClassNames = names => Array.from(names).flat()\n\n// Perform operation for either the first or all of the elements returned by CSS selector\n//\n// * operation - the instruction payload from perform\n// * callback - the operation function to run for each element\n//\nconst processElements = (operation, callback) => {\n Array.from(\n operation.selectAll ? operation.element : [operation.element]\n ).forEach(callback)\n}\n\n// convert string to kebab-case\n// most other implementations (lodash) are focused on camelCase to kebab-case\n// instead, this uses word token boundaries to produce readable URL slugs and keys\n// this implementation will not support Emoji or other non-ASCII characters\n//\nconst kebabize = createCompounder(function (result, word, index) {\n return result + (index ? '-' : '') + word.toLowerCase()\n})\n\nfunction createCompounder (callback) {\n return function (str) {\n return words(str).reduce(callback, '')\n }\n}\n\nconst words = str => {\n str = str == null ? '' : str\n return str.match(/([A-Z]{2,}|[0-9]+|[A-Z]?[a-z]+|[A-Z])/g) || []\n}\n\n// Provide a standardized pipeline of checks and modifications to all operations based on provided options\n// Currently skips execution if cancelled and implements an optional delay\n//\nconst operate = (operation, callback) => {\n if (!operation.cancel) {\n operation.delay ? setTimeout(callback, operation.delay) : callback()\n return true\n }\n return false\n}\n\n// Dispatch life-cycle events with standardized naming\nconst before = (target, operation) =>\n dispatch(\n target,\n `cable-ready:before-${kebabize(operation.operation)}`,\n operation\n )\n\nconst after = (target, operation) =>\n dispatch(\n target,\n `cable-ready:after-${kebabize(operation.operation)}`,\n operation\n )\n\nfunction debounce (fn, delay = 250) {\n let timer\n return (...args) => {\n const callback = () => fn.apply(this, args)\n if (timer) clearTimeout(timer)\n timer = setTimeout(callback, delay)\n }\n}\n\nfunction handleErrors (response) {\n if (!response.ok) throw Error(response.statusText)\n return response\n}\n\nfunction safeScalar (val) {\n if (\n val !== undefined &&\n !['string', 'number', 'boolean'].includes(typeof val)\n )\n console.warn(\n `Operation expects a string, number or boolean, but got ${val} (${typeof val})`\n )\n return val != null ? val : ''\n}\n\nfunction safeString (str) {\n if (str !== undefined && typeof str !== 'string')\n console.warn(`Operation expects a string, but got ${str} (${typeof str})`)\n\n return str != null ? String(str) : ''\n}\n\nfunction safeArray (arr) {\n if (arr !== undefined && !Array.isArray(arr))\n console.warn(`Operation expects an array, but got ${arr} (${typeof arr})`)\n return arr != null ? Array.from(arr) : []\n}\n\nfunction safeObject (obj) {\n if (obj !== undefined && typeof obj !== 'object')\n console.warn(`Operation expects an object, but got ${obj} (${typeof obj})`)\n return obj != null ? Object(obj) : {}\n}\n\nfunction safeStringOrArray (elem) {\n if (elem !== undefined && !Array.isArray(elem) && typeof elem !== 'string')\n console.warn(`Operation expects an Array or a String, but got ${elem} (${typeof elem})`)\n\n return elem == null ? '' : Array.isArray(elem) ? Array.from(elem) : String(elem)\n}\n\nfunction fragmentToString (fragment) {\n return new XMLSerializer().serializeToString(fragment)\n}\n\n// A proxy method to wrap a fetch call in error handling\n//\n// * url - the URL to fetch\n// * additionalHeaders - an object of additional headers passed to fetch\n//\nasync function graciouslyFetch (url, additionalHeaders) {\n try {\n const response = await fetch(url, {\n headers: {\n 'X-REQUESTED-WITH': 'XmlHttpRequest',\n ...additionalHeaders\n }\n })\n if (response == undefined) return\n\n handleErrors(response)\n\n return response\n } catch (e) {\n console.error(`Could not fetch ${url}`)\n }\n}\n\nexport {\n isTextInput,\n assignFocus,\n dispatch,\n xpathToElement,\n xpathToElementArray,\n getClassNames,\n processElements,\n operate,\n before,\n after,\n debounce,\n handleErrors,\n graciouslyFetch,\n kebabize,\n safeScalar,\n safeString,\n safeArray,\n safeObject,\n safeStringOrArray,\n fragmentToString\n}\n","import { mutableTags } from './enums'\nimport { isTextInput } from './utils'\nimport ActiveElement from './active_element'\n\n// Indicates whether or not we should morph an element via onBeforeElUpdated callback\n// SEE: https://github.com/patrick-steele-idem/morphdom#morphdomfromnode-tonode-options--node\n//\nconst shouldMorph = operation => (fromEl, toEl) => {\n return !shouldMorphCallbacks\n .map(callback => {\n return typeof callback === 'function'\n ? callback(operation, fromEl, toEl)\n : true\n })\n .includes(false)\n}\n\n// Execute any pluggable functions that modify elements after morphing via onElUpdated callback\n//\nconst didMorph = operation => el => {\n didMorphCallbacks.forEach(callback => {\n if (typeof callback === 'function') callback(operation, el)\n })\n}\n\nconst verifyNotMutable = (detail, fromEl, toEl) => {\n // Skip nodes that are equal:\n // https://github.com/patrick-steele-idem/morphdom#can-i-make-morphdom-blaze-through-the-dom-tree-even-faster-yes\n if (!mutableTags[fromEl.tagName] && fromEl.isEqualNode(toEl)) return false\n return true\n}\n\nconst verifyNotContentEditable = (detail, fromEl, toEl) => {\n if (fromEl === ActiveElement.element && fromEl.isContentEditable) return false\n return true\n}\n\nconst verifyNotPermanent = (detail, fromEl, toEl) => {\n const { permanentAttributeName } = detail\n if (!permanentAttributeName) return true\n\n const permanent = fromEl.closest(`[${permanentAttributeName}]`)\n\n // only morph attributes on the active non-permanent text input\n if (!permanent && fromEl === ActiveElement.element && isTextInput(fromEl)) {\n const ignore = { value: true }\n Array.from(toEl.attributes).forEach(attribute => {\n if (!ignore[attribute.name])\n fromEl.setAttribute(attribute.name, attribute.value)\n })\n return false\n }\n\n return !permanent\n}\n\nconst shouldMorphCallbacks = [\n verifyNotMutable,\n verifyNotPermanent,\n verifyNotContentEditable\n]\nconst didMorphCallbacks = []\n\nexport {\n shouldMorphCallbacks,\n didMorphCallbacks,\n shouldMorph,\n didMorph,\n verifyNotMutable,\n verifyNotContentEditable,\n verifyNotPermanent\n}\n","import morphdom from 'morphdom'\n\nimport { shouldMorph, didMorph } from './morph_callbacks'\nimport {\n assignFocus,\n dispatch,\n getClassNames,\n processElements,\n before,\n after,\n operate,\n safeScalar,\n safeString,\n safeArray,\n safeObject,\n safeStringOrArray\n} from './utils'\n\nexport default {\n // DOM Mutations\n\n append: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('beforeend', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n graft: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { parent, focusSelector } = operation\n const parentElement = document.querySelector(parent)\n if (parentElement) {\n parentElement.appendChild(element)\n assignFocus(focusSelector)\n }\n })\n after(element, operation)\n })\n },\n\n innerHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.innerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, position, focusSelector } = operation\n element.insertAdjacentHTML(position || 'beforeend', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentText: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, position, focusSelector } = operation\n element.insertAdjacentText(position || 'beforeend', safeScalar(text))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n outerHtml: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n },\n\n prepend: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('afterbegin', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n remove: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { focusSelector } = operation\n element.remove()\n assignFocus(focusSelector)\n })\n after(document, operation)\n })\n },\n\n replace: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n },\n\n textContent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, focusSelector } = operation\n element.textContent = safeScalar(text)\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n // Element Property Mutations\n\n addCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.add(...getClassNames([safeStringOrArray(name)]))\n })\n after(element, operation)\n })\n },\n\n removeAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.removeAttribute(safeString(name))\n })\n after(element, operation)\n })\n },\n\n removeCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.remove(...getClassNames([safeStringOrArray(name)]))\n if (element.classList.length === 0) element.removeAttribute('class')\n })\n after(element, operation)\n })\n },\n\n setAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.setAttribute(safeString(name), safeScalar(value))\n })\n after(element, operation)\n })\n },\n\n setDatasetProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.dataset[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n if (name in element) element[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setStyle: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.style[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setStyles: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { styles } = operation\n for (let [name, value] of Object.entries(styles))\n element.style[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setValue: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { value } = operation\n element.value = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n // DOM Events and Meta-Operations\n\n dispatchEvent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, detail } = operation\n dispatch(element, safeString(name), safeObject(detail))\n })\n after(element, operation)\n })\n },\n\n setMeta: operation => {\n before(document, operation)\n operate(operation, () => {\n const { name, content } = operation\n let meta = document.head.querySelector(`meta[name='${name}']`)\n if (!meta) {\n meta = document.createElement('meta')\n meta.name = safeString(name)\n document.head.appendChild(meta)\n }\n meta.content = safeScalar(content)\n })\n after(document, operation)\n },\n\n setTitle: operation => {\n before(document, operation)\n operate(operation, () => {\n const { title } = operation\n document.title = safeScalar(title)\n })\n after(document, operation)\n },\n\n // Browser Manipulations\n\n clearStorage: operation => {\n before(document, operation)\n operate(operation, () => {\n const { type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.clear()\n })\n after(document, operation)\n },\n\n go: operation => {\n before(window, operation)\n operate(operation, () => {\n const { delta } = operation\n history.go(delta)\n })\n after(window, operation)\n },\n\n pushState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.pushState(safeObject(state), safeString(title), safeString(url))\n })\n after(window, operation)\n },\n\n redirectTo: operation => {\n before(window, operation)\n operate(operation, () => {\n let { url, action, turbo } = operation\n action = action || 'advance'\n url = safeString(url)\n if (turbo === undefined) turbo = true\n\n if (turbo) {\n if (window.Turbo) window.Turbo.visit(url, { action })\n if (window.Turbolinks) window.Turbolinks.visit(url, { action })\n if (!window.Turbo && !window.Turbolinks) window.location.href = url\n } else {\n window.location.href = url\n }\n })\n after(window, operation)\n },\n\n reload: operation => {\n before(window, operation)\n operate(operation, () => {\n window.location.reload()\n })\n after(window, operation)\n },\n\n removeStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.removeItem(safeString(key))\n })\n after(document, operation)\n },\n\n replaceState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.replaceState(\n safeObject(state),\n safeString(title),\n safeString(url)\n )\n })\n after(window, operation)\n },\n\n scrollIntoView: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n element.scrollIntoView(operation)\n })\n after(element, operation)\n },\n\n setCookie: operation => {\n before(document, operation)\n operate(operation, () => {\n const { cookie } = operation\n document.cookie = safeScalar(cookie)\n })\n after(document, operation)\n },\n\n setFocus: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n assignFocus(element)\n })\n after(element, operation)\n },\n\n setStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, value, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.setItem(safeString(key), safeScalar(value))\n })\n after(document, operation)\n },\n\n // Notifications\n\n consoleLog: operation => {\n before(document, operation)\n operate(operation, () => {\n const { message, level } = operation\n level && ['warn', 'info', 'error'].includes(level)\n ? console[level](message)\n : console.log(message)\n })\n after(document, operation)\n },\n\n consoleTable: operation => {\n before(document, operation)\n operate(operation, () => {\n const { data, columns } = operation\n console.table(data, safeArray(columns))\n })\n after(document, operation)\n },\n\n notification: operation => {\n before(document, operation)\n operate(operation, () => {\n const { title, options } = operation\n Notification.requestPermission().then(result => {\n operation.permission = result\n if (result === 'granted')\n new Notification(safeString(title), safeObject(options))\n })\n })\n after(document, operation)\n },\n\n // Morph operations\n\n morph: operation => {\n processElements(operation, element => {\n const { html } = operation\n const template = document.createElement('template')\n template.innerHTML = String(safeScalar(html)).trim()\n operation.content = template.content\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { childrenOnly, focusSelector } = operation\n morphdom(\n element,\n childrenOnly ? template.content : template.innerHTML,\n {\n childrenOnly: !!childrenOnly,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: didMorph(operation)\n }\n )\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n }\n}\n","import Operations from './operations'\n\nlet operations = Operations\n\nconst add = newOperations => {\n operations = { ...operations, ...newOperations }\n}\n\nconst addOperations = operations => {\n add(operations)\n}\n\nconst addOperation = (name, operation) => {\n const operations = {}\n operations[name] = operation\n\n add(operations)\n}\n\nexport { addOperation, addOperations }\n\nexport default {\n get all () {\n return operations\n }\n}\n","let missingElement = 'warn'\n\nexport default {\n get behavior () {\n return missingElement\n },\n set (value) {\n if (['warn', 'ignore', 'event', 'exception'].includes(value))\n missingElement = value\n else\n console.warn(\"Invalid 'onMissingElement' option. Defaulting to 'warn'.\")\n }\n}\n","import { xpathToElement, xpathToElementArray, dispatch } from './utils'\nimport ActiveElement from './active_element'\nimport OperationStore from './operation_store'\nimport MissingElement from './missing_element'\n\nconst perform = (\n operations,\n options = { onMissingElement: MissingElement.behavior }\n) => {\n const batches = {}\n operations.forEach(operation => {\n if (!!operation.batch)\n batches[operation.batch] = batches[operation.batch]\n ? ++batches[operation.batch]\n : 1\n })\n operations.forEach(operation => {\n const name = operation.operation\n try {\n if (operation.selector) {\n if (operation.xpath) {\n operation.element = operation.selectAll\n ? xpathToElementArray(operation.selector)\n : xpathToElement(operation.selector)\n } else {\n operation.element = operation.selectAll\n ? document.querySelectorAll(operation.selector)\n : document.querySelector(operation.selector)\n }\n } else {\n operation.element = document\n }\n if (operation.element || options.onMissingElement !== 'ignore') {\n ActiveElement.set(document.activeElement)\n const cableReadyOperation = OperationStore.all[name]\n\n if (cableReadyOperation) {\n cableReadyOperation(operation)\n if (!!operation.batch && --batches[operation.batch] === 0)\n dispatch(document, 'cable-ready:batch-complete', {\n batch: operation.batch\n })\n } else {\n console.error(\n `CableReady couldn't find the \"${name}\" operation. Make sure you use the camelized form when calling an operation method.`\n )\n }\n }\n } catch (e) {\n if (operation.element) {\n console.error(\n `CableReady detected an error in ${name || 'operation'}: ${\n e.message\n }. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`\n )\n console.error(e)\n } else {\n const warning = `CableReady ${name ||\n ''} operation failed due to missing DOM element for selector: '${\n operation.selector\n }'`\n switch (options.onMissingElement) {\n case 'ignore':\n break\n case 'event':\n dispatch(document, 'cable-ready:missing-element', {\n warning,\n operation\n })\n break\n case 'exception':\n throw warning\n default:\n console.warn(warning)\n }\n }\n }\n })\n}\n\nconst performAsync = (\n operations,\n options = { onMissingElement: MissingElement.behavior }\n) => {\n return new Promise((resolve, reject) => {\n try {\n resolve(perform(operations, options))\n } catch (err) {\n reject(err)\n }\n })\n}\n\nexport { perform, performAsync }\n","export default class SubscribingElement extends HTMLElement {\n disconnectedCallback () {\n if (this.channel) this.channel.unsubscribe()\n }\n\n createSubscription (consumer, channel, receivedCallback) {\n this.channel = consumer.subscriptions.create(\n {\n channel,\n identifier: this.identifier\n },\n {\n received: receivedCallback\n }\n )\n }\n\n get preview () {\n return (\n document.documentElement.hasAttribute('data-turbolinks-preview') ||\n document.documentElement.hasAttribute('data-turbo-preview')\n )\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n}\n","let consumer\n\nconst BACKOFF = [25, 50, 75, 100, 200, 250, 500, 800, 1000, 2000]\n\nconst wait = (ms) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst getConsumerWithRetry = async (retry = 0) => {\n if (consumer) return consumer\n\n if (retry >= BACKOFF.length) {\n throw new Error(\"Couldn't obtain a Action Cable consumer within 5s\")\n }\n\n await wait(BACKOFF[retry])\n\n return await getConsumerWithRetry(retry + 1)\n}\n\nexport default {\n setConsumer (value) {\n consumer = value\n },\n\n get consumer () {\n return consumer\n },\n\n async getConsumer () {\n return await getConsumerWithRetry()\n }\n}\n","import { perform } from '../cable_ready'\nimport SubscribingElement from './subscribing_element'\nimport CableConsumer from '../cable_consumer'\nimport MissingElement from '../missing_element'\n\nexport default class StreamFromElement extends SubscribingElement {\n static define () {\n if (!customElements.get('stream-from')) {\n customElements.define('stream-from', this)\n }\n }\n\n async connectedCallback () {\n if (this.preview) return\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(\n consumer,\n 'CableReady::Stream',\n this.performOperations.bind(this)\n )\n } else {\n console.error(\n 'The `stream_from` helper cannot connect. You must initialize CableReady with an Action Cable consumer.'\n )\n }\n }\n\n performOperations (data) {\n if (data.cableReady)\n perform(data.operations, { onMissingElement: this.onMissingElement })\n }\n\n get onMissingElement () {\n const value = this.getAttribute('missing') || MissingElement.behavior\n\n // stream_from does not support raising exceptions on missing elements because there's no way to catch them\n if (['warn', 'ignore', 'event'].includes(value)) return value\n else {\n console.warn(\"Invalid 'missing' attribute. Defaulting to 'warn'.\")\n return 'warn'\n }\n }\n}\n","let debugging = false\n\nexport default {\n get enabled () {\n return debugging\n },\n get disabled () {\n return !debugging\n },\n get value () {\n return debugging\n },\n set (value) {\n debugging = !!value\n },\n set debug (value) {\n debugging = !!value\n }\n}\n","import Debug from '../debug'\n\nconst request = (data, blocks) => {\n if (Debug.disabled) return\n\n console.log(\n `\\u2191 Updatable request affecting ${blocks.length} element(s): `,\n {\n elements: blocks.map(b => b.element),\n identifiers: blocks.map(b => b.element.getAttribute('identifier')),\n data\n }\n )\n}\n\nconst cancel = (timestamp, reason) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(\n `\\u274C Updatable request canceled after ${duration}ms: ${reason}`\n )\n}\n\nconst response = (timestamp, element, urls) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u2193 Updatable response: All URLs fetched in ${duration}ms`, {\n element,\n urls\n })\n}\n\nconst morphStart = (timestamp, element) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u21BB Updatable morph: starting after ${duration}ms`, {\n element\n })\n}\n\nconst morphEnd = (timestamp, element) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u21BA Updatable morph: completed after ${duration}ms`, {\n element\n })\n}\n\nexport default { request, cancel, response, morphStart, morphEnd }\n","import morphdom from 'morphdom'\nimport SubscribingElement from './subscribing_element'\n\nimport { shouldMorph } from '../morph_callbacks'\nimport { debounce, assignFocus, dispatch, graciouslyFetch } from '../utils'\n\nimport ActiveElement from '../active_element'\nimport CableConsumer from '../cable_consumer'\nimport Log from '../updatable/log'\n\nconst template = `\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n`\n\nfunction url (element) {\n return element.hasAttribute('url')\n ? element.getAttribute('url')\n : location.href\n}\n\nexport default class UpdatesForElement extends SubscribingElement {\n static define () {\n if (!customElements.get('updates-for')) {\n customElements.define('updates-for', this)\n }\n }\n\n constructor () {\n super()\n const shadowRoot = this.attachShadow({ mode: 'open' })\n shadowRoot.innerHTML = template\n }\n\n async connectedCallback () {\n if (this.preview) return\n this.update = debounce(this.update.bind(this), this.debounce)\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(consumer, 'CableReady::Stream', this.update)\n } else {\n console.error(\n 'The `updates-for` helper cannot connect. You must initialize CableReady with an Action Cable consumer.'\n )\n }\n }\n\n async update (data) {\n this.lastUpdateTimestamp = new Date()\n\n const blocks = Array.from(\n document.querySelectorAll(this.query),\n element => new Block(element)\n ).filter(block => block.shouldUpdate(data))\n\n Log.request(data, blocks)\n\n if (blocks.length === 0) {\n Log.cancel(this.lastUpdateTimestamp, 'All elements filtered out')\n\n return\n }\n\n // first updates-for element in the DOM *at any given moment* updates all of the others\n if (blocks[0].element !== this) {\n Log.cancel(this.lastUpdateTimestamp, 'Update already requested')\n\n return\n }\n\n // hold a reference to the active element so that it can be restored after the morph\n ActiveElement.set(document.activeElement)\n\n // store all retrieved HTML in an object keyed by URL to minimize fetch calls\n this.html = {}\n\n const uniqueUrls = [...new Set(blocks.map(block => block.url))]\n\n await Promise.all(\n uniqueUrls.map(async url => {\n if (!this.html.hasOwnProperty(url)) {\n const response = await graciouslyFetch(url, {\n 'X-Cable-Ready': 'update'\n })\n this.html[url] = await response.text()\n }\n })\n )\n\n Log.response(this.lastUpdateTimestamp, this, uniqueUrls)\n\n // track current block index for each URL; referred to as fragments\n this.index = {}\n\n blocks.forEach(block => {\n // if the block's URL is not in the index, initialize it to 0; otherwise, increment it\n this.index.hasOwnProperty(block.url)\n ? this.index[block.url]++\n : (this.index[block.url] = 0)\n\n block.process(data, this.html, this.index, this.lastUpdateTimestamp)\n })\n }\n\n get query () {\n return `updates-for[identifier=\"${this.identifier}\"]`\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n\n get debounce () {\n return this.hasAttribute('debounce')\n ? parseInt(this.getAttribute('debounce'))\n : 20\n }\n}\n\nclass Block {\n constructor (element) {\n this.element = element\n }\n\n async process (data, html, index, startTimestamp) {\n const blockIndex = index[this.url]\n const template = document.createElement('template')\n this.element.setAttribute('updating', 'updating')\n\n template.innerHTML = String(html[this.url]).trim()\n\n await this.resolveTurboFrames(template.content)\n\n const fragments = template.content.querySelectorAll(this.query)\n\n if (fragments.length <= blockIndex) {\n console.warn(\n `Update aborted due to insufficient number of elements. The offending url is ${this.url}.`\n )\n return\n }\n\n const operation = {\n element: this.element,\n html: fragments[blockIndex],\n permanentAttributeName: 'data-ignore-updates'\n }\n\n dispatch(this.element, 'cable-ready:before-update', operation)\n Log.morphStart(startTimestamp, this.element)\n\n morphdom(this.element, fragments[blockIndex], {\n childrenOnly: true,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: _ => {\n this.element.removeAttribute('updating')\n dispatch(this.element, 'cable-ready:after-update', operation)\n assignFocus(operation.focusSelector)\n }\n })\n Log.morphEnd(startTimestamp, this.element)\n }\n\n async resolveTurboFrames (documentFragment) {\n const reloadingTurboFrames = [\n ...documentFragment.querySelectorAll(\n 'turbo-frame[src]:not([loading=\"lazy\"])'\n )\n ]\n\n return Promise.all(\n reloadingTurboFrames.map(frame => {\n return new Promise(async resolve => {\n const frameResponse = await graciouslyFetch(\n frame.getAttribute('src'),\n {\n 'Turbo-Frame': frame.id,\n 'X-Cable-Ready': 'update'\n }\n )\n\n const frameTemplate = document.createElement('template')\n frameTemplate.innerHTML = await frameResponse.text()\n\n // recurse here to get all nested eager loaded frames\n await this.resolveTurboFrames(frameTemplate.content)\n\n const selector = `turbo-frame#${frame.id}`\n const frameContent = frameTemplate.content.querySelector(selector)\n const content = frameContent ? frameContent.innerHTML.trim() : ''\n\n docFragment.querySelector(selector).innerHTML = content\n\n resolve()\n })\n })\n )\n }\n\n shouldUpdate (data) {\n // if everything that could prevent an update is false, update this block\n return !this.ignoresInnerUpdates && this.hasChangesSelectedForUpdate(data)\n }\n\n hasChangesSelectedForUpdate (data) {\n // if there's an only attribute, only update if at least one of the attributes changed is in the allow list\n const only = this.element.getAttribute('only')\n\n return !(\n only &&\n data.changed &&\n !only.split(' ').some(attribute => data.changed.includes(attribute))\n )\n }\n\n get ignoresInnerUpdates () {\n // don't update during a Reflex or Turbolinks redraw\n return (\n this.element.hasAttribute('ignore-inner-updates') &&\n this.element.hasAttribute('performing-inner-update')\n )\n }\n\n get url () {\n return this.element.hasAttribute('url')\n ? this.element.getAttribute('url')\n : location.href\n }\n\n get identifier () {\n return this.element.identifier\n }\n\n get query () {\n return this.element.query\n }\n}\n","export const registerInnerUpdates = () => {\n document.addEventListener('stimulus-reflex:before', event => {\n recursiveMarkUpdatesForElements(event.detail.element)\n })\n\n document.addEventListener('stimulus-reflex:after', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.detail.element)\n })\n })\n\n document.addEventListener('turbo:submit-start', event => {\n recursiveMarkUpdatesForElements(event.target)\n })\n\n document.addEventListener('turbo:submit-end', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n\n document.addEventListener('turbo-boost:command:start', event => {\n recursiveMarkUpdatesForElements(event.target)\n })\n\n document.addEventListener('turbo-boost:command:finish', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n\n document.addEventListener('turbo-boost:command:error', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n}\n\nconst recursiveMarkUpdatesForElements = leaf => {\n const closestUpdatesFor =\n leaf && leaf.parentElement && leaf.parentElement.closest('updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.setAttribute('performing-inner-update', '')\n recursiveMarkUpdatesForElements(closestUpdatesFor)\n }\n}\n\nconst recursiveUnmarkUpdatesForElements = leaf => {\n const closestUpdatesFor =\n leaf && leaf.parentElement && leaf.parentElement.closest('updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.removeAttribute('performing-inner-update')\n recursiveUnmarkUpdatesForElements(closestUpdatesFor)\n }\n}\n","import StreamFromElement from './stream_from_element'\nimport UpdatesForElement from './updates_for_element'\n\nimport { registerInnerUpdates } from '../updatable/inner_updates_compat'\n\nexport const defineElements = () => {\n registerInnerUpdates()\n\n StreamFromElement.define()\n UpdatesForElement.define()\n}\n","import morphdom from 'morphdom'\n\nimport packageInfo from '../package.json'\nimport { perform, performAsync } from './cable_ready'\nimport { defineElements } from './elements'\nimport { shouldMorphCallbacks, didMorphCallbacks } from './morph_callbacks'\n\nimport * as MorphCallbacks from './morph_callbacks'\nimport * as Utils from './utils'\n\nimport OperationStore, { addOperation, addOperations } from './operation_store'\nimport StreamFromElement from './elements/stream_from_element'\nimport UpdatesForElement from './elements/updates_for_element'\nimport SubscribingElement from './elements/subscribing_element'\nimport CableConsumer from './cable_consumer'\nimport Debug from './debug'\n\nconst initialize = (initializeOptions = {}) => {\n const { consumer, onMissingElement, debug } = initializeOptions\n\n Debug.set(!!debug)\n\n if (consumer) {\n CableConsumer.setConsumer(consumer)\n } else {\n console.error(\n 'CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`.'\n )\n }\n\n if (onMissingElement) {\n MissingElement.set(onMissingElement)\n }\n\n defineElements()\n}\n\nexport {\n Utils,\n MorphCallbacks,\n StreamFromElement,\n UpdatesForElement,\n SubscribingElement\n}\n\nconst global = {\n perform,\n performAsync,\n shouldMorphCallbacks,\n didMorphCallbacks,\n initialize,\n addOperation,\n addOperations,\n version: packageInfo.version,\n cable: CableConsumer,\n get DOMOperations () {\n console.warn(\n 'DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`'\n )\n return OperationStore.all\n },\n get operations () {\n return OperationStore.all\n },\n get consumer () {\n return CableConsumer.consumer\n }\n}\n\nwindow.CableReady = global\n\nexport default global\n"],"names":["inputTags","INPUT","TEXTAREA","SELECT","mutableTags","OPTION","textInputTypes","color","date","datetime","email","month","number","password","range","search","tel","text","textarea","time","url","week","activeElement","ActiveElement","element","set","isTextInput","tagName","type","assignFocus","selector","focusElement","nodeType","Node","ELEMENT_NODE","document","querySelector","focus","dispatch","name","detail","event","CustomEvent","bubbles","cancelable","dispatchEvent","window","jQuery","trigger","xpathToElement","xpath","evaluate","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","xpathToElementArray","reverse","snapshotList","ORDERED_NODE_SNAPSHOT_TYPE","snapshots","i","snapshotLength","push","snapshotItem","getClassNames","names","Array","from","flat","processElements","operation","callback","selectAll","forEach","kebabize","result","word","index","toLowerCase","str","words","reduce","match","operate","cancel","delay","setTimeout","before","target","after","debounce","fn","timer","args","clearTimeout","apply","this","handleErrors","response","ok","Error","statusText","safeScalar","val","undefined","includes","console","warn","safeString","String","safeArray","arr","isArray","safeObject","obj","Object","safeStringOrArray","elem","async","graciouslyFetch","additionalHeaders","fetch","headers","e","error","fragment","XMLSerializer","serializeToString","shouldMorph","fromEl","toEl","shouldMorphCallbacks","map","didMorph","el","didMorphCallbacks","verifyNotMutable","isEqualNode","verifyNotContentEditable","isContentEditable","verifyNotPermanent","permanentAttributeName","permanent","closest","ignore","value","attributes","attribute","setAttribute","Operations","append","html","focusSelector","insertAdjacentHTML","graft","parent","parentElement","appendChild","innerHtml","innerHTML","insertAdjacentHtml","position","insertAdjacentText","outerHtml","idx","children","indexOf","outerHTML","documentElement","prepend","remove","replace","textContent","addCssClass","classList","add","removeAttribute","removeCssClass","length","setDatasetProperty","dataset","setProperty","setStyle","style","setStyles","styles","entries","setValue","setMeta","content","meta","head","createElement","setTitle","title","clearStorage","sessionStorage","localStorage","clear","go","delta","history","pushState","state","redirectTo","action","turbo","Turbo","visit","Turbolinks","location","href","reload","removeStorageItem","key","removeItem","replaceState","scrollIntoView","setCookie","cookie","setFocus","setStorageItem","setItem","consoleLog","message","level","log","consoleTable","data","columns","table","notification","options","Notification","requestPermission","then","permission","morph","template","trim","childrenOnly","morphdom","onBeforeElUpdated","onElUpdated","operations","newOperations","OperationStore","all","missingElement","MissingElement$1","behavior","perform","onMissingElement","MissingElement","batches","batch","querySelectorAll","cableReadyOperation","warning","SubscribingElement","HTMLElement","disconnectedCallback","channel","unsubscribe","createSubscription","consumer","receivedCallback","subscriptions","create","identifier","received","preview","hasAttribute","getAttribute","BACKOFF","getConsumerWithRetry","retry","ms","Promise","resolve","CableConsumer","setConsumer","StreamFromElement","static","customElements","get","define","getConsumer","performOperations","bind","cableReady","debugging","Debug","enabled","disabled","debug","Log","blocks","elements","b","identifiers","timestamp","reason","duration","Date","urls","UpdatesForElement","constructor","super","attachShadow","mode","update","lastUpdateTimestamp","query","Block","filter","block","shouldUpdate","uniqueUrls","Set","hasOwnProperty","process","parseInt","startTimestamp","blockIndex","resolveTurboFrames","fragments","_","documentFragment","reloadingTurboFrames","frame","frameResponse","id","frameTemplate","frameContent","docFragment","ignoresInnerUpdates","hasChangesSelectedForUpdate","only","changed","split","some","recursiveMarkUpdatesForElements","leaf","closestUpdatesFor","recursiveUnmarkUpdatesForElements","defineElements","addEventListener","global","performAsync","reject","err","initialize","initializeOptions","addOperation","addOperations","version","packageInfo","cable","DOMOperations","CableReady"],"mappings":"iTAAO,MAAMA,EAAY,CACvBC,OAAO,EACPC,UAAU,EACVC,QAAQ,GAGGC,EAAc,CACzBH,OAAO,EACPC,UAAU,EACVG,QAAQ,GAGGC,EAAiB,CAC5B,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,MAAM,E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AAkBC,EAAeH,YAEtC,IAAI4B,SAAQ,CAACC,EAASuE,KAC3B,IACEvE,EAAQ5B,EAAQP,EAAYZ,GAG7B,CAFC,MAAOuH,GACPD,EAAOC,EACR,KSzCH5N,uBACAI,oBACAyN,WAjCiB,CAACC,EAAoB,MACtC,MAAMxF,SAAEA,EAAQb,iBAAEA,EAAgB2C,MAAEA,GAAU0D,EAE9C7D,EAAM3Q,MAAM8Q,GAER9B,EACFe,EAAcC,YAAYhB,GAE1B/J,QAAQkB,MACN,4PAIAgI,GACFC,eAAepO,IAAImO,GAGrB8F,IAAgB,EAiBhBQ,aXvCmB,CAAC3T,EAAM+B,KAC1B,MAAM8K,EAAa,CAAE,EACrBA,EAAW7M,GAAQ+B,EAEnByG,EAAIqE,EAAW,EWoCf+G,cX5CoB/G,IACpBrE,EAAIqE,EAAW,EW4CfgH,QAASC,EACTC,MAAO9E,EACH+E,oBAIF,OAHA7P,QAAQC,KACN,wFAEK2I,EAAeC,GACvB,EACGH,iBACF,OAAOE,EAAeC,GACvB,EACGkB,eACF,OAAOe,EAAcf,QACtB,GAGH3N,OAAO0T,WAAaZ"}
@@ -27,12 +27,13 @@ module CableReady
27
27
  tag.cable_ready_stream_from(**build_options(*keys, html_options))
28
28
  end
29
29
 
30
- def cable_ready_updates_for(*keys, url: nil, debounce: nil, only: nil, ignore_inner_updates: false, html_options: {}, &block)
30
+ def cable_ready_updates_for(*keys, url: nil, debounce: nil, only: nil, ignore_inner_updates: false, observe_appearance: false, html_options: {}, &block)
31
31
  options = build_options(*keys, html_options)
32
32
  options[:url] = url if url
33
33
  options[:debounce] = debounce if debounce
34
34
  options[:only] = only if only
35
35
  options[:"ignore-inner-updates"] = "" if ignore_inner_updates
36
+ options[:"observe-appearance"] = "" if observe_appearance
36
37
  tag.cable_ready_updates_for(**options) { capture(&block) }
37
38
  end
38
39
 
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/concern"
4
+ require "cable_ready/config"
4
5
 
5
6
  module CableReady
6
7
  module Updatable
7
8
  extend ::ActiveSupport::Concern
8
9
 
9
- mattr_accessor :debounce_adapter, default: ::CableReady::Updatable::MemoryCacheDebounceAdapter.instance
10
-
11
10
  included do |base|
12
11
  if defined?(ActiveRecord) && base < ActiveRecord::Base
13
12
  include ExtendHasMany
@@ -190,12 +189,12 @@ module CableReady
190
189
 
191
190
  if debounce_time.to_f > 0
192
191
  key = compound([model_class, *options])
193
- old_wait_until = CableReady::Updatable.debounce_adapter[key]
192
+ old_wait_until = CableReady.config.updatable_debounce_adapter[key]
194
193
  now = Time.now.to_f
195
194
 
196
195
  if old_wait_until.nil? || old_wait_until < now
197
196
  new_wait_until = now + debounce_time.to_f
198
- CableReady::Updatable.debounce_adapter[key] = new_wait_until
197
+ CableReady.config.updatable_debounce_adapter[key] = new_wait_until
199
198
  ActionCable.server.broadcast(model_class, options)
200
199
  end
201
200
  else
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("lib/cable_ready/version", __dir__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "cable_ready"
7
+ gem.license = "MIT"
8
+ gem.version = CableReady::VERSION
9
+ gem.authors = ["Nathan Hopkins"]
10
+ gem.email = ["natehop@gmail.com"]
11
+ gem.homepage = "https://github.com/stimulusreflex/cable_ready"
12
+ gem.summary = "Out-of-Band Server Triggered DOM Operations"
13
+
14
+ gem.files = Dir[
15
+ "lib/**/*.{rb,rake}",
16
+ "app/**/*.rb",
17
+ "app/assets/javascripts/*",
18
+ "bin/*",
19
+ "[A-Z]*"
20
+ ]
21
+
22
+ gem.required_ruby_version = ">= 2.7.0"
23
+
24
+ rails_version = ">= 5.2"
25
+
26
+ gem.add_dependency "actionpack", rails_version
27
+ gem.add_dependency "actionview", rails_version
28
+ gem.add_dependency "activesupport", rails_version
29
+ gem.add_dependency "railties", rails_version
30
+ gem.add_dependency "thread-local", ">= 1.1.0"
31
+
32
+ gem.add_development_dependency "magic_frozen_string_literal"
33
+ gem.add_development_dependency "mocha"
34
+ gem.add_development_dependency "pry"
35
+ gem.add_development_dependency "pry-nav"
36
+ gem.add_development_dependency "rake"
37
+ gem.add_development_dependency "sqlite3"
38
+ gem.add_development_dependency "standard", "1.19.1"
39
+ gem.add_development_dependency "standardrb"
40
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "thread/local"
4
4
 
5
+ require "active_support/core_ext/enumerable"
6
+
5
7
  module CableReady
6
8
  # This class is a thread local singleton: CableReady::Channels.instance
7
9
  # SEE: https://github.com/socketry/thread-local/tree/master/guides/getting-started
@@ -4,6 +4,8 @@ require "monitor"
4
4
  require "observer"
5
5
  require "singleton"
6
6
 
7
+ require "active_support/core_ext/numeric/time"
8
+
7
9
  module CableReady
8
10
  # This class is a process level singleton shared by all threads: CableReady::Config.instance
9
11
  class Config
@@ -11,7 +13,7 @@ module CableReady
11
13
  include Observable
12
14
  include Singleton
13
15
 
14
- attr_accessor :on_failed_sanity_checks, :broadcast_job_queue, :precompile_assets, :updatable_debounce_time
16
+ attr_accessor :on_failed_sanity_checks, :broadcast_job_queue, :precompile_assets, :updatable_debounce_time, :updatable_debounce_adapter
15
17
  attr_writer :verifier_key
16
18
 
17
19
  def on_new_version_available
@@ -55,5 +55,9 @@ module CableReady
55
55
  app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts")
56
56
  end
57
57
  end
58
+
59
+ config.after_initialize do
60
+ CableReady.config.updatable_debounce_adapter ||= CableReady::Updatable::MemoryCacheDebounceAdapter.instance
61
+ end
58
62
  end
59
63
  end