From 2afb5f44756ba149aea35b613b3794fe1412ab17 Mon Sep 17 00:00:00 2001 From: Andrew Forward Date: Fri, 12 Apr 2019 18:13:48 -0400 Subject: [PATCH] Install phoenix_live_view --- mix.exs | 3 ++- mix.lock | 1 + priv/static/js/app.js | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index 2a3fad88..662b6474 100644 --- a/mix.exs +++ b/mix.exs @@ -32,10 +32,11 @@ defmodule Hangman.MixProject do # Type `mix help deps` for examples and options. defp deps do [ - {:phoenix, "~> 1.4.2"}, + {:phoenix, "~> 1.4", override: true}, {:phoenix_pubsub, "~> 1.1"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, + {:phoenix_live_view, github: "phoenixframework/phoenix_live_view"}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, {:plug_cowboy, "~> 2.0"}, diff --git a/mix.lock b/mix.lock index 6e3adee9..a654b40c 100644 --- a/mix.lock +++ b/mix.lock @@ -8,6 +8,7 @@ "phoenix": {:hex, :phoenix, "1.4.3", "8eed4a64ff1e12372cd634724bddd69185938f52c18e1396ebac76375d85677d", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm"}, "phoenix_html": {:hex, :phoenix_html, "2.13.2", "f5d27c9b10ce881a60177d2b5227314fc60881e6b66b41dfe3349db6ed06cf57", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.2.0", "3bb31a9fbd40ffe8652e60c8660dffd72dd231efcdf49b744fb75b9ef7db5dd2", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, + "phoenix_live_view": {:git, "https://github.com/phoenixframework/phoenix_live_view.git", "c7ea73ba9223e2cf285fb970cd9090f92183ed80", []}, "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm"}, "plug": {:hex, :plug, "1.8.0", "9d2685cb007fe5e28ed9ac27af2815bc262b7817a00929ac10f56f169f43b977", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"}, "plug_cowboy": {:hex, :plug_cowboy, "2.0.2", "6055f16868cc4882b24b6e1d63d2bada94fb4978413377a3b32ac16c18dffba2", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, diff --git a/priv/static/js/app.js b/priv/static/js/app.js index 82f901c5..debf12eb 100644 --- a/priv/static/js/app.js +++ b/priv/static/js/app.js @@ -90,7 +90,7 @@ eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./css/ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _css_app_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../css/app.css */ \"./css/app.css\");\n/* harmony import */ var _css_app_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_app_css__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var phoenix_html__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! phoenix_html */ \"./node_modules/phoenix_html/priv/static/phoenix_html.js\");\n/* harmony import */ var phoenix_html__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(phoenix_html__WEBPACK_IMPORTED_MODULE_1__);\n// We need to import the CSS so that webpack will load it.\n// The MiniCssExtractPlugin is used to separate it out into\n// its own CSS file.\n // webpack automatically bundles all modules in your\n// entry points. Those entry points can be configured\n// in \"webpack.config.js\".\n//\n// Import dependencies\n//\n\n // Import local files\n//\n// Local files can be imported directly using relative paths, for example:\n// import socket from \"./socket\"\n\n//# sourceURL=webpack:///./js/app.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _css_app_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../css/app.css */ \"./css/app.css\");\n/* harmony import */ var _css_app_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_app_css__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var phoenix_html__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! phoenix_html */ \"./node_modules/phoenix_html/priv/static/phoenix_html.js\");\n/* harmony import */ var phoenix_html__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(phoenix_html__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var phoenix_live_view__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! phoenix_live_view */ \"./node_modules/phoenix_live_view/priv/static/phoenix_live_view.js\");\n/* harmony import */ var phoenix_live_view__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(phoenix_live_view__WEBPACK_IMPORTED_MODULE_2__);\n// We need to import the CSS so that webpack will load it.\n// The MiniCssExtractPlugin is used to separate it out into\n// its own CSS file.\n // webpack automatically bundles all modules in your\n// entry points. Those entry points can be configured\n// in \"webpack.config.js\".\n//\n// Import dependencies\n//\n\n // Enable LiveView client side connections\n\n\nvar liveSocket = new phoenix_live_view__WEBPACK_IMPORTED_MODULE_2___default.a(\"/live\");\nliveSocket.connect();\n\n//# sourceURL=webpack:///./js/app.js?"); /***/ }), @@ -102,7 +102,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _css /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\n(function() {\n var PolyfillEvent = eventConstructor();\n\n function eventConstructor() {\n if (typeof window.CustomEvent === \"function\") return window.CustomEvent;\n // IE<=9 Support\n function CustomEvent(event, params) {\n params = params || {bubbles: false, cancelable: false, detail: undefined};\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt;\n }\n CustomEvent.prototype = window.Event.prototype;\n return CustomEvent;\n }\n\n function buildHiddenInput(name, value) {\n var input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = name;\n input.value = value;\n return input;\n }\n\n function handleClick(element) {\n var to = element.getAttribute(\"data-to\"),\n method = buildHiddenInput(\"_method\", element.getAttribute(\"data-method\")),\n csrf = buildHiddenInput(\"_csrf_token\", element.getAttribute(\"data-csrf\")),\n form = document.createElement(\"form\"),\n target = element.getAttribute(\"target\");\n\n form.method = (element.getAttribute(\"data-method\") === \"get\") ? \"get\" : \"post\";\n form.action = to;\n form.style.display = \"hidden\";\n\n if (target) form.target = target;\n\n form.appendChild(csrf);\n form.appendChild(method);\n document.body.appendChild(form);\n form.submit();\n }\n\n window.addEventListener(\"click\", function(e) {\n var element = e.target;\n\n while (element && element.getAttribute) {\n var phoenixLinkEvent = new PolyfillEvent('phoenix.link.click', {\n \"bubbles\": true, \"cancelable\": true\n });\n\n if (!element.dispatchEvent(phoenixLinkEvent)) {\n e.preventDefault();\n e.stopImmediatePropagation();\n return false;\n }\n\n if (element.getAttribute(\"data-method\")) {\n handleClick(element);\n e.preventDefault();\n return false;\n } else {\n element = element.parentNode;\n }\n }\n }, false);\n\n window.addEventListener('phoenix.link.click', function (e) {\n var message = e.target.getAttribute(\"data-confirm\");\n if(message && !window.confirm(message)) {\n e.preventDefault();\n }\n }, false);\n})();\n\n\n//# sourceURL=webpack:///./node_modules/phoenix_html/priv/static/phoenix_html.js?"); +eval("\n\n(function() {\n var PolyfillEvent = eventConstructor();\n\n function eventConstructor() {\n if (typeof window.CustomEvent === \"function\") return window.CustomEvent;\n // IE<=9 Support\n function CustomEvent(event, params) {\n params = params || {bubbles: false, cancelable: false, detail: undefined};\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt;\n }\n CustomEvent.prototype = window.Event.prototype;\n return CustomEvent;\n }\n\n function buildHiddenInput(name, value) {\n var input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = name;\n input.value = value;\n return input;\n }\n\n function handleClick(element) {\n var to = element.getAttribute(\"data-to\"),\n method = buildHiddenInput(\"_method\", element.getAttribute(\"data-method\")),\n csrf = buildHiddenInput(\"_csrf_token\", element.getAttribute(\"data-csrf\")),\n form = document.createElement(\"form\"),\n target = element.getAttribute(\"target\");\n\n form.method = (element.getAttribute(\"data-method\") === \"get\") ? \"get\" : \"post\";\n form.action = to;\n form.style.display = \"hidden\";\n\n if (target) form.target = target;\n\n form.appendChild(csrf);\n form.appendChild(method);\n document.body.appendChild(form);\n form.submit();\n }\n\n window.addEventListener(\"click\", function(e) {\n var element = e.target;\n\n while (element && element.getAttribute) {\n var phoenixLinkEvent = new PolyfillEvent('phoenix.link.click', {\n \"bubbles\": true, \"cancelable\": true\n });\n\n if (!element.dispatchEvent(phoenixLinkEvent)) {\n e.preventDefault();\n return false;\n }\n\n if (element.getAttribute(\"data-method\")) {\n handleClick(element);\n e.preventDefault();\n return false;\n } else {\n element = element.parentNode;\n }\n }\n }, false);\n\n window.addEventListener('phoenix.link.click', function (e) {\n var message = e.target.getAttribute(\"data-confirm\");\n if(message && !window.confirm(message)) {\n e.preventDefault();\n }\n }, false);\n})();\n\n\n//# sourceURL=webpack:///./node_modules/phoenix_html/priv/static/phoenix_html.js?"); + +/***/ }), + +/***/ "./node_modules/phoenix_live_view/priv/static/phoenix_live_view.js": +/*!*************************************************************************!*\ + !*** ./node_modules/phoenix_live_view/priv/static/phoenix_live_view.js ***! + \*************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("!function(e,t){ true?module.exports=t():undefined}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,\"__esModule\",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=4)}([function(e,t,n){e.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=0)}([function(e,t,n){(function(t){e.exports=t.Phoenix=n(2)}).call(this,n(1))},function(e,t){var n;n=function(){return this}();try{n=n||Function(\"return this\")()||(0,eval)(\"this\")}catch(e){\"object\"==typeof window&&(n=window)}e.exports=n},function(e,t,n){\"use strict\";function i(e){return(i=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")}function o(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.timeout;if(this.joinedOnce)throw new Error(\"tried to join multiple times. 'join' can only be called a single time per channel instance\");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}},{key:\"onClose\",value:function(e){this.on(d.close,e)}},{key:\"onError\",value:function(e){return this.on(d.error,function(t){return e(t)})}},{key:\"on\",value:function(e,t){var n=this.bindingRef++;return this.bindings.push({event:e,ref:n,callback:t}),n}},{key:\"off\",value:function(e,t){this.bindings=this.bindings.filter(function(n){return!(n.event===e&&(void 0===t||t===n.ref))})}},{key:\"canPush\",value:function(){return this.socket.isConnected()&&this.isJoined()}},{key:\"push\",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(!this.joinedOnce)throw new Error(\"tried to push '\".concat(e,\"' to '\").concat(this.topic,\"' before joining. Use channel.join() before pushing events\"));var i=new m(this,e,function(){return t},n);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}},{key:\"leave\",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.rejoinTimer.reset(),this.state=f.leaving;var n=function(){e.socket.hasLogger()&&e.socket.log(\"channel\",\"leave \".concat(e.topic)),e.trigger(d.close,\"leave\")},i=new m(this,d.leave,y({}),t);return i.receive(\"ok\",function(){return n()}).receive(\"timeout\",function(){return n()}),i.send(),this.canPush()||i.trigger(\"ok\",{}),i}},{key:\"onMessage\",value:function(e,t,n){return t}},{key:\"isLifecycleEvent\",value:function(e){return v.indexOf(e)>=0}},{key:\"isMember\",value:function(e,t,n,i){return!(this.topic!==e||i&&i!==this.joinRef()&&this.isLifecycleEvent(t)&&(this.socket.hasLogger()&&this.socket.log(\"channel\",\"dropping outdated message\",{topic:e,event:t,payload:n,joinRef:i}),1))}},{key:\"joinRef\",value:function(){return this.joinPush.ref}},{key:\"sendJoin\",value:function(e){this.state=f.joining,this.joinPush.resend(e)}},{key:\"rejoin\",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.isLeaving()||this.sendJoin(e)}},{key:\"trigger\",value:function(e,t,n,i){var r=this.onMessage(e,t,n,i);if(t&&!r)throw new Error(\"channel onMessage callbacks must return the payload, modified or unmodified\");for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{};r(this,e),this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=i.timeout||h,this.transport=i.transport||c.WebSocket||w,this.defaultEncoder=b.encode,this.defaultDecoder=b.decode,this.closeWasClean=!1,this.unloaded=!1,this.binaryType=i.binaryType||\"arraybuffer\",this.transport!==w?(this.encode=i.encode||this.defaultEncoder,this.decode=i.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder),u&&u.addEventListener(\"beforeunload\",function(e){n.unloaded=!0,n.abnormalClose(\"unloaded\")}),this.heartbeatIntervalMs=i.heartbeatIntervalMs||3e4,this.rejoinAfterMs=function(e){return i.rejoinAfterMs?i.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4},this.reconnectAfterMs=function(e){return n.unloaded?100:i.reconnectAfterMs?i.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3},this.logger=i.logger||null,this.longpollerTimeout=i.longpollerTimeout||2e4,this.params=y(i.params||{}),this.endPoint=\"\".concat(t,\"/\").concat(p.websocket),this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new x(function(){n.teardown(function(){return n.connect()})},this.reconnectAfterMs)}return s(e,[{key:\"protocol\",value:function(){return location.protocol.match(/^https/)?\"wss\":\"ws\"}},{key:\"endPointURL\",value:function(){var e=E.appendParams(E.appendParams(this.endPoint,this.params()),{vsn:\"2.0.0\"});return\"/\"!==e.charAt(0)?e:\"/\"===e.charAt(1)?\"\".concat(this.protocol(),\":\").concat(e):\"\".concat(this.protocol(),\"://\").concat(location.host).concat(e)}},{key:\"disconnect\",value:function(e,t,n){this.closeWasClean=!0,this.reconnectTimer.reset(),this.teardown(e,t,n)}},{key:\"connect\",value:function(e){var t=this;e&&(console&&console.log(\"passing params to connect is deprecated. Instead pass :params to the Socket constructor\"),this.params=y(e)),this.conn||(this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=function(){return t.onConnOpen()},this.conn.onerror=function(e){return t.onConnError(e)},this.conn.onmessage=function(e){return t.onConnMessage(e)},this.conn.onclose=function(e){return t.onConnClose(e)})}},{key:\"log\",value:function(e,t,n){this.logger(e,t,n)}},{key:\"hasLogger\",value:function(){return null!==this.logger}},{key:\"onOpen\",value:function(e){this.stateChangeCallbacks.open.push(e)}},{key:\"onClose\",value:function(e){this.stateChangeCallbacks.close.push(e)}},{key:\"onError\",value:function(e){this.stateChangeCallbacks.error.push(e)}},{key:\"onMessage\",value:function(e){this.stateChangeCallbacks.message.push(e)}},{key:\"onConnOpen\",value:function(){this.hasLogger()&&this.log(\"transport\",\"connected to \".concat(this.endPointURL())),this.unloaded=!1,this.closeWasClean=!1,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(function(e){return e()})}},{key:\"resetHeartbeat\",value:function(){var e=this;this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(function(){return e.sendHeartbeat()},this.heartbeatIntervalMs))}},{key:\"teardown\",value:function(e,t,n){this.conn&&(this.conn.onclose=function(){},t?this.conn.close(t,n||\"\"):this.conn.close(),this.conn=null),e&&e()}},{key:\"onConnClose\",value:function(e){this.hasLogger()&&this.log(\"transport\",\"close\",e),this.triggerChanError(),clearInterval(this.heartbeatTimer),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(function(t){return t(e)})}},{key:\"onConnError\",value:function(e){this.hasLogger()&&this.log(\"transport\",e),this.triggerChanError(),this.stateChangeCallbacks.error.forEach(function(t){return t(e)})}},{key:\"triggerChanError\",value:function(){this.channels.forEach(function(e){e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(d.error)})}},{key:\"connectionState\",value:function(){switch(this.conn&&this.conn.readyState){case l.connecting:return\"connecting\";case l.open:return\"open\";case l.closing:return\"closing\";default:return\"closed\"}}},{key:\"isConnected\",value:function(){return\"open\"===this.connectionState()}},{key:\"remove\",value:function(e){this.channels=this.channels.filter(function(t){return t.joinRef()!==e.joinRef()})}},{key:\"channel\",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new g(e,t,this);return this.channels.push(n),n}},{key:\"push\",value:function(e){var t=this;if(this.hasLogger()){var n=e.topic,i=e.event,r=e.payload,o=e.ref,s=e.join_ref;this.log(\"push\",\"\".concat(n,\" \").concat(i,\" (\").concat(s,\", \").concat(o,\")\"),r)}this.isConnected()?this.encode(e,function(e){return t.conn.send(e)}):this.sendBuffer.push(function(){return t.encode(e,function(e){return t.conn.send(e)})})}},{key:\"makeRef\",value:function(){var e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}},{key:\"sendHeartbeat\",value:function(){if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.hasLogger()&&this.log(\"transport\",\"heartbeat timeout. Attempting to re-establish connection\"),void this.abnormalClose(\"heartbeat timeout\");this.pendingHeartbeatRef=this.makeRef(),this.push({topic:\"phoenix\",event:\"heartbeat\",payload:{},ref:this.pendingHeartbeatRef})}}},{key:\"abnormalClose\",value:function(e){this.closeWasClean=!1,this.conn.close(1e3,e)}},{key:\"flushSendBuffer\",value:function(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(function(e){return e()}),this.sendBuffer=[])}},{key:\"onConnMessage\",value:function(e){var t=this;this.decode(e.data,function(e){var n=e.topic,i=e.event,r=e.payload,o=e.ref,s=e.join_ref;o&&o===t.pendingHeartbeatRef&&(t.pendingHeartbeatRef=null),t.hasLogger()&&t.log(\"receive\",\"\".concat(r.status||\"\",\" \").concat(n,\" \").concat(i,\" \").concat(o&&\"(\"+o+\")\"||\"\"),r);for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:{};r(this,e);var o=i.events||{state:\"presence_state\",diff:\"presence_diff\"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(o.state,function(t){var i=n.caller,r=i.onJoin,o=i.onLeave,s=i.onSync;n.joinRef=n.channel.joinRef(),n.state=e.syncState(n.state,t,r,o),n.pendingDiffs.forEach(function(t){n.state=e.syncDiff(n.state,t,r,o)}),n.pendingDiffs=[],s()}),this.channel.on(o.diff,function(t){var i=n.caller,r=i.onJoin,o=i.onLeave,s=i.onSync;n.inPendingSyncState()?n.pendingDiffs.push(t):(n.state=e.syncDiff(n.state,t,r,o),s())})}return s(e,[{key:\"onJoin\",value:function(e){this.caller.onJoin=e}},{key:\"onLeave\",value:function(e){this.caller.onLeave=e}},{key:\"onSync\",value:function(e){this.caller.onSync=e}},{key:\"list\",value:function(t){return e.list(this.state,t)}},{key:\"inPendingSyncState\",value:function(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}}],[{key:\"syncState\",value:function(e,t,n,i){var r=this,o=this.clone(e),s={},a={};return this.map(o,function(e,n){t[e]||(a[e]=n)}),this.map(t,function(e,t){var n=o[e];if(n){var i=t.metas.map(function(e){return e.phx_ref}),u=n.metas.map(function(e){return e.phx_ref}),c=t.metas.filter(function(e){return u.indexOf(e.phx_ref)<0}),l=n.metas.filter(function(e){return i.indexOf(e.phx_ref)<0});c.length>0&&(s[e]=t,s[e].metas=c),l.length>0&&(a[e]=r.clone(n),a[e].metas=l)}else s[e]=t}),this.syncDiff(o,{joins:s,leaves:a},n,i)}},{key:\"syncDiff\",value:function(e,t,n,i){var r=t.joins,o=t.leaves,s=this.clone(e);return n||(n=function(){}),i||(i=function(){}),this.map(r,function(e,t){var i=s[e];if(s[e]=t,i){var r,o=s[e].metas.map(function(e){return e.phx_ref}),a=i.metas.filter(function(e){return o.indexOf(e.phx_ref)<0});(r=s[e].metas).unshift.apply(r,function(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t90)&&n===i.toUpperCase()}function a(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,\"\"):e.removeAttribute(n))}var u={OPTION:function(e,t){a(e,t,\"selected\")},INPUT:function(e,t){a(e,t,\"checked\"),a(e,t,\"disabled\"),e.value!==t.value&&(e.value=t.value),t.hasAttribute(\"value\")||e.removeAttribute(\"value\")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var i=e.firstChild;if(i){var r=i.nodeValue;if(r==n||!n&&r==e.placeholder)return;i.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute(\"multiple\")){for(var n=0,i=t.firstChild;i;){var r=i.nodeName;if(r&&\"OPTION\"===r.toUpperCase()){if(i.hasAttribute(\"selected\"))break;n++}i=i.nextSibling}e.selectedIndex=n}}},c=1,l=3,h=8;function f(){}function d(e){return e.id}var v=function(e){return function(t,n,a){if(a||(a={}),\"string\"==typeof n)if(\"#document\"===t.nodeName||\"HTML\"===t.nodeName){var v=n;(n=o.createElement(\"html\")).innerHTML=v}else p=n,!i&&o.createRange&&(i=o.createRange()).selectNode(o.body),i&&i.createContextualFragment?y=i.createContextualFragment(p):(y=o.createElement(\"body\")).innerHTML=p,n=y.childNodes[0];var p,y,m,g=a.getNodeKey||d,b=a.onBeforeNodeAdded||f,k=a.onNodeAdded||f,w=a.onBeforeElUpdated||f,E=a.onElUpdated||f,A=a.onBeforeNodeDiscarded||f,x=a.onNodeDiscarded||f,S=a.onBeforeElChildrenUpdated||f,j=!0===a.childrenOnly,C={};function T(e){m?m.push(e):m=[e]}function R(e,t,n){!1!==A(e)&&(t&&t.removeChild(e),x(e),function e(t,n){if(t.nodeType===c)for(var i=t.firstChild;i;){var r=void 0;n&&(r=g(i))?T(r):(x(i),i.firstChild&&e(i,n)),i=i.nextSibling}}(e,n))}function L(e){k(e);for(var t=e.firstChild;t;){var n=t.nextSibling,i=g(t);if(i){var r=C[i];r&&s(t,r)&&(t.parentNode.replaceChild(r,t),O(r,t))}L(t),t=n}}function O(i,r,a){var f,d=g(r);if(d&&delete C[d],!n.isSameNode||!n.isSameNode(t)){if(!a){if(!1===w(i,r))return;if(e(i,r),E(i),!1===S(i,r))return}if(\"TEXTAREA\"!==i.nodeName){var v,p,y,m,k=r.firstChild,A=i.firstChild;e:for(;k;){for(y=k.nextSibling,v=g(k);A;){if(p=A.nextSibling,k.isSameNode&&k.isSameNode(A)){k=y,A=p;continue e}f=g(A);var x=A.nodeType,j=void 0;if(x===k.nodeType&&(x===c?(v?v!==f&&((m=C[v])?A.nextSibling===m?j=!1:(i.insertBefore(m,A),p=A.nextSibling,f?T(f):R(A,i,!0),A=m):j=!1):f&&(j=!1),(j=!1!==j&&s(A,k))&&O(A,k)):x!==l&&x!=h||(j=!0,A.nodeValue!==k.nodeValue&&(A.nodeValue=k.nodeValue))),j){k=y,A=p;continue e}f?T(f):R(A,i,!0),A=p}if(v&&(m=C[v])&&s(m,k))i.appendChild(m),O(m,k);else{var P=b(k);!1!==P&&(P&&(k=P),k.actualize&&(k=k.actualize(i.ownerDocument||o)),i.appendChild(k),L(k))}k=y,A=p}for(;A;)p=A.nextSibling,(f=g(A))?T(f):R(A,i,!0),A=p}var N=u[i.nodeName];N&&N(i,r)}}!function e(t){if(t.nodeType===c)for(var n=t.firstChild;n;){var i=g(n);i&&(C[i]=n),e(n),n=n.nextSibling}}(t);var P,N,_=t,B=_.nodeType,I=n.nodeType;if(!j)if(B===c)I===c?s(t,n)||(x(t),_=function(e,t){for(var n=e.firstChild;n;){var i=n.nextSibling;t.appendChild(n),n=i}return t}(t,(P=n.nodeName,(N=n.namespaceURI)&&N!==r?o.createElementNS(N,P):o.createElement(P)))):_=n;else if(B===l||B===h){if(I===B)return _.nodeValue!==n.nodeValue&&(_.nodeValue=n.nodeValue),_;_=n}if(_===n)x(t);else if(O(_,n,j),m)for(var M=0,V=m.length;M=0;--n)r=(i=a[n]).name,o=i.namespaceURI,s=i.value,o?(r=i.localName||r,e.getAttributeNS(o,r)!==s&&e.setAttributeNS(o,r,s)):e.getAttribute(r)!==s&&e.setAttribute(r,s);for(n=(a=e.attributes).length-1;n>=0;--n)!1!==(i=a[n]).specified&&(r=i.name,(o=i.namespaceURI)?(r=i.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r))});t.default=v},function(e,t,n){\"use strict\";Object.defineProperty(t,\"__esModule\",{value:!0}),t.View=t.Browser=t.LiveSocket=t.Rendered=t.debug=void 0;var i,r=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw o}}return n}(e,t);throw new TypeError(\"Invalid attempt to destructure non-iterable instance\")}}(),o=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{}).static},toString:function(e){var t={buffer:\"\"};return this.toOutputBuffer(e,t),t.buffer},toOutputBuffer:function(e,t){if(e.dynamics)return this.comprehensionToBuffer(e,t);var n=e.static;t.buffer+=n[0];for(var i=1;i1&&void 0!==arguments[1]?arguments[1]:{};l(this,e),this.unloaded=!1,this.socket=new c.Socket(t,i),this.socket.onOpen(function(){n.isUnloaded()&&(n.destroyAllViews(),n.joinRootViews()),n.unloaded=!1}),window.addEventListener(\"beforeunload\",function(e){n.unloaded=!0}),this.bindingPrefix=i.bindingPrefix||p,this.opts=i,this.views={},this.viewLogger=i.viewLogger,this.activeElement=null,this.prevActive=null,this.bindTopLevelEvents()}return o(e,[{key:\"isUnloaded\",value:function(){return this.unloaded}},{key:\"getSocket\",value:function(){return this.socket}},{key:\"log\",value:function(e,t,n){if(this.viewLogger){var i=n(),o=r(i,2),s=o[0],a=o[1];this.viewLogger(e,t,s,a)}}},{key:\"connect\",value:function(){var e=this;return[\"complete\",\"loaded\",\"interactive\"].indexOf(document.readyState)>=0?this.joinRootViews():document.addEventListener(\"DOMContentLoaded\",function(){e.joinRootViews()}),this.socket.connect()}},{key:\"getBindingPrefix\",value:function(){return this.bindingPrefix}},{key:\"binding\",value:function(e){return\"\"+this.getBindingPrefix()+e}},{key:\"disconnect\",value:function(){this.socket.disconnect()}},{key:\"channel\",value:function(e,t){return this.socket.channel(e,t||{})}},{key:\"joinRootViews\",value:function(){var e=this;document.querySelectorAll(f+\":not([data-phx-parent-id])\").forEach(function(t){e.joinView(t)})}},{key:\"joinView\",value:function(e,t){if(!this.getViewById(e.id)){var n=new A(e,this,t);this.views[n.id]=n,n.join()}}},{key:\"owner\",value:function(e,t){var n=this.getViewById(m(e.closest(f),\"id\"));n&&t(n)}},{key:\"getViewById\",value:function(e){return this.views[e]}},{key:\"onViewError\",value:function(e){this.dropActiveElement(e)}},{key:\"destroyAllViews\",value:function(){for(var e in this.views)this.destroyViewById(e)}},{key:\"destroyViewById\",value:function(e){var t=this.views[e];t&&(delete this.views[t.id],t.destroy())}},{key:\"setActiveElement\",value:function(e){var t=this;if(this.activeElement!==e){this.activeElement=e;var n=function(){e===t.activeElement&&(t.activeElement=null),e.removeEventListener(\"mouseup\",t),e.removeEventListener(\"touchend\",t)};e.addEventListener(\"mouseup\",n),e.addEventListener(\"touchend\",n)}}},{key:\"getActiveElement\",value:function(){return document.activeElement===document.body&&this.activeElement||document.activeElement}},{key:\"dropActiveElement\",value:function(e){this.prevActive&&e.ownsElement(this.prevActive)&&(this.prevActive=null)}},{key:\"restorePreviouslyActiveFocus\",value:function(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}},{key:\"blurActiveElement\",value:function(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}},{key:\"bindTopLevelEvents\",value:function(){this.bindClicks(),this.bindForms(),this.bindTargetable([\"keyup\",\"keydown\"],function(e,t,n,i,r,o){n.pushKey(i,t,e,r)}),this.bindTargetable([\"blur\",\"focus\"],function(e,t,n,i,r,o){\"window\"===o&&e.target!==window||e.target===document||n.pushEvent(t,i,r)})}},{key:\"bindTargetable\",value:function(e,t){var n=this,i=function(e){window.addEventListener(e,function(i){var r=n.binding(e),o=n.binding(\"target\"),s=i.target.getAttribute&&i.target.getAttribute(r);s&&!i.target.getAttribute(o)?n.owner(i.target,function(n){return t(i,e,n,i.target,s,null)}):document.querySelectorAll(\"[\"+r+\"][\"+o+\"=window]\").forEach(function(o){var s=o.getAttribute(r);n.owner(o,function(n){return t(i,e,n,o,s,\"window\")})})},!0)},r=!0,o=!1,s=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){i(a.value)}}catch(e){o=!0,s=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw s}}}},{key:\"bindClicks\",value:function(){var e=this;window.addEventListener(\"click\",function(t){var n=e.binding(\"click\"),i=function(e,t){do{if(e.matches(\"[\"+t+\"]\"))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType&&!e.matches(f));return null}(t.target,n),r=i&&i.getAttribute(n);r&&(t.preventDefault(),e.owner(i,function(e){return e.pushEvent(\"click\",i,r)}))},!0)}},{key:\"bindForms\",value:function(){var e=this;window.addEventListener(\"submit\",function(t){var n=t.target.getAttribute(e.binding(\"submit\"));n&&(t.preventDefault(),t.target.disabled=!0,e.owner(t.target,function(e){return e.submitForm(t.target,n)}))},!0);for(var t=function(t){window.addEventListener(t,function(n){var i=n.target;if(\"input\"!==t||\"radio\"!==i.type){var r=i.form&&i.form.getAttribute(e.binding(\"change\"));r&&e.owner(i,function(t){E.isTextualInput(i)?i.setAttribute(\"data-phx-has-focused\",!0):e.setActiveElement(i),t.pushInput(i,r)})}},!0)},n=[\"change\",\"input\"],i=0;i\"+i+\"\",{childrenOnly:!0,onBeforeNodeAdded:function(e){return E.discardError(e),e},onNodeAdded:function(t){if(E.isPhxChild(t)&&e.ownsElement(t))return e.onNewChildAdded(t),!0},onBeforeNodeDiscarded:function(t){if(E.isPhxChild(t))return e.liveSocket.destroyViewById(t.id),!0},onBeforeElUpdated:function(e,t){return E.isPhxChild(t)?(E.mergeAttrs(e,t),!1):(e.getAttribute&&e.getAttribute(\"data-phx-has-submitted\")&&t.setAttribute(\"data-phx-has-submitted\",!0),e.getAttribute&&e.getAttribute(\"data-phx-has-focused\")&&t.setAttribute(\"data-phx-has-focused\",!0),E.discardError(t),!E.isTextualInput(e)||e!==r||(E.mergeInputs(e,t),!1))}}),E.restoreFocus(r,o,s),document.dispatchEvent(new Event(\"phx:update\"))},mergeAttrs:function(e,t){t.getAttributeNames().forEach(function(n){var i=t.getAttribute(n);e.setAttribute(n,i)})},mergeInputs:function(e,t){E.mergeAttrs(e,t),e.readOnly=t.readOnly},restoreFocus:function(e,t,n){E.isTextualInput(e)&&((\"\"===e.value||e.readOnly)&&e.blur(),e.focus(),(e.setSelectionRange&&\"text\"===e.type||\"textarea\"===e.type)&&e.setSelectionRange(t,n))},isTextualInput:function(e){return d.indexOf(e.type)>=0}},A=t.View=function(){function e(t,n,i){var r=this;l(this,e),this.liveSocket=n,this.parent=i,this.newChildrenAdded=!1,this.gracefullyClosed=!1,this.el=t,this.loader=this.el.nextElementSibling,this.id=this.el.id,this.view=this.el.getAttribute(h),this.channel=this.liveSocket.channel(\"lv:\"+this.id,function(){return{session:r.getSession()}}),this.loaderTimer=setTimeout(function(){return r.showLoader()},v),this.bindChannel()}return o(e,[{key:\"getSession\",value:function(){return this.el.getAttribute(\"data-phx-session\")}},{key:\"destroy\",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.hasGracefullyClosed()?(this.log(\"destroyed\",function(){return[\"the server view has gracefully closed\"]}),e()):(this.log(\"destroyed\",function(){return[\"the child has been removed from the parent\"]}),this.channel.leave().receive(\"ok\",e).receive(\"error\",e).receive(\"timeout\",e))}},{key:\"hideLoader\",value:function(){clearTimeout(this.loaderTimer),this.loader.style.display=\"none\"}},{key:\"showLoader\",value:function(){clearTimeout(this.loaderTimer),this.el.classList=\"phx-disconnected\",this.loader.style.display=\"block\";var e=Math.floor(this.el.clientHeight/2);this.loader.style.top=\"-\"+e+\"px\"}},{key:\"log\",value:function(e,t){this.liveSocket.log(this,e,t)}},{key:\"onJoin\",value:function(e){var t=e.rendered;this.log(\"join\",function(){return[\"\",JSON.stringify(t)]}),this.rendered=t,this.hideLoader(),this.el.classList=\"phx-connected\",E.patch(this,this.el,this.id,b.toString(this.rendered)),this.joinNewChildren()}},{key:\"joinNewChildren\",value:function(){var e=this,t=f+'[data-phx-parent-id=\"'+this.id+'\"]';document.querySelectorAll(t).forEach(function(t){e.liveSocket.getViewById(t.id)||e.liveSocket.joinView(t,e)})}},{key:\"update\",value:function(e){if(t=e,0!==Object.keys(t).length){var t;this.log(\"update\",function(){return[\"\",JSON.stringify(e)]}),this.rendered=b.mergeDiff(this.rendered,e);var n=b.toString(this.rendered);this.newChildrenAdded=!1,E.patch(this,this.el,this.id,n),this.newChildrenAdded&&this.joinNewChildren()}}},{key:\"onNewChildAdded\",value:function(e){this.newChildrenAdded=!0}},{key:\"bindChannel\",value:function(){var e=this;this.channel.on(\"render\",function(t){return e.update(t)}),this.channel.on(\"redirect\",function(e){var t=e.to,n=e.flash;return w.redirect(t,n)}),this.channel.on(\"session\",function(t){var n=t.token;return e.el.setAttribute(\"data-phx-session\",n)}),this.channel.onError(function(t){return e.onError(t)}),this.channel.onClose(function(){return e.onGracefulClose()})}},{key:\"onGracefulClose\",value:function(){this.gracefullyClosed=!0,this.liveSocket.destroyViewById(this.id)}},{key:\"hasGracefullyClosed\",value:function(){return this.gracefullyClosed}},{key:\"join\",value:function(){var e=this;this.parent&&(this.parent.channel.onClose(function(){return e.onGracefulClose()}),this.parent.channel.onError(function(){return e.liveSocket.destroyViewById(e.id)})),this.channel.join().receive(\"ok\",function(t){return e.onJoin(t)}).receive(\"error\",function(t){return e.onJoinError(t)}).receive(\"timeout\",function(){return e.onJoinError(\"timeout\")})}},{key:\"onJoinError\",value:function(e){this.displayError(),this.log(\"error\",function(){return[\"unable to join\",e]})}},{key:\"onError\",value:function(e){this.log(\"error\",function(){return[\"view crashed\",e]}),this.liveSocket.onViewError(this),document.activeElement.blur(),this.liveSocket.isUnloaded()?this.showLoader():this.displayError()}},{key:\"displayError\",value:function(){this.showLoader(),this.el.classList=\"phx-disconnected phx-error\"}},{key:\"pushWithReply\",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};this.channel.push(e,t,2e4).receive(\"ok\",function(e){n.update(e),i()})}},{key:\"pushEvent\",value:function(e,t,n){var i=t.getAttribute(this.binding(\"value\"))||t.value||\"\";this.pushWithReply(\"event\",{type:e,event:n,value:i})}},{key:\"pushKey\",value:function(e,t,n,i){this.pushWithReply(\"event\",{type:t,event:i,value:e.value||n.key})}},{key:\"pushInput\",value:function(e,t){this.pushWithReply(\"event\",{type:\"form\",event:t,value:g(e.form)})}},{key:\"pushFormSubmit\",value:function(e,t,n){this.pushWithReply(\"event\",{type:\"form\",event:t,value:g(e)},n)}},{key:\"ownsElement\",value:function(e){return e.getAttribute(\"data-phx-parent-id\")===this.id||m(e.closest(f),\"id\")===this.id}},{key:\"submitForm\",value:function(e,t){var n=this,i=this.liveSocket.getBindingPrefix();e.setAttribute(\"data-phx-has-submitted\",\"true\"),E.disableForm(e,i),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(e,t,function(){E.restoreDisabledForm(e,i),n.liveSocket.restorePreviouslyActiveFocus()})}},{key:\"binding\",value:function(e){return this.liveSocket.binding(e)}}]),e}();t.default=k},function(e,t){var n;n=function(){return this}();try{n=n||Function(\"return this\")()||(0,eval)(\"this\")}catch(e){\"object\"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){t.Phoenix||(t.Phoenix={}),e.exports=t.Phoenix.LiveView=n(2)}).call(this,n(3))}])});\n\n//# sourceURL=webpack:///./node_modules/phoenix_live_view/priv/static/phoenix_live_view.js?"); /***/ }),