diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 3bf43ea737d..90d11cedceb 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -461,9 +461,6 @@ export default Component.extend(TextareaTextManipulation, { previewPromise = loadScript("/javascripts/diffhtml.min.js").then(() => { const previewElement = this.element.querySelector(".d-editor-preview"); - // This is a workaround for a known bug in diffHTML - // https://github.com/tbranyen/diffhtml/issues/217#issuecomment-1479956332 - window.diff.release(previewElement); window.diff.innerHTML(previewElement, cookedElement.innerHTML); }); } diff --git a/app/assets/javascripts/discourse/app/lib/public-js-versions.js b/app/assets/javascripts/discourse/app/lib/public-js-versions.js index b92c9da219b..2d3af3a5795 100644 --- a/app/assets/javascripts/discourse/app/lib/public-js-versions.js +++ b/app/assets/javascripts/discourse/app/lib/public-js-versions.js @@ -7,7 +7,7 @@ export const PUBLIC_JS_VERSIONS = { "chart.min.js": "chart.js/3.5.1/chart.min.js", "chartjs-plugin-datalabels.min.js": "chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js", - "diffhtml.min.js": "diffhtml/1.0.0-beta.29/diffhtml.min.js", + "diffhtml.min.js": "diffhtml/1.0.0-beta.30/diffhtml.min.js", "jquery.magnific-popup.min.js": "magnific-popup/1.1.0/jquery.magnific-popup.min.js", "pikaday.js": "pikaday/1.8.2/pikaday.js", diff --git a/package.json b/package.json index 8646e30a53f..d21d54e602a 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "chrome-launcher": "^0.15.1", "chrome-remote-interface": "^0.31.3", "concurrently": "^8.2.1", - "diffhtml": "1.0.0-beta.20", + "diffhtml": "1.0.0-beta.30", "ember-template-lint": "5.11.2", "esbuild": "^0.19.2", "eslint": "^8.37.0", diff --git a/public/javascripts/diffhtml/1.0.0-beta.29/diffhtml.min.js b/public/javascripts/diffhtml/1.0.0-beta.29/diffhtml.min.js deleted file mode 100644 index 327295e7eaa..00000000000 --- a/public/javascripts/diffhtml/1.0.0-beta.29/diffhtml.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,t(e.diff={}))}(this,function(e){"use strict";function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r(e){for(var r=1;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&void 0!==arguments[2]?arguments[2]:typeof t,n=arguments.length>3?arguments[3]:void 0,a=ue.location,o=ue.URLSearchParams,i=void 0!==o,s=void 0!==a,c=i&&s,l=de.env;if(n&&e in n)return n[e];var d="DIFF_".concat(e.replace(/[^a-zA-Z0-9]/,""));if(c){var u=new o(a.search),f=d.toLowerCase();if(u.has(f))return g(decodeURIComponent(String(u.get(f))),r)}var h=d.toUpperCase();return l&&h in de.env?g(de.env[h.toUpperCase()],r):t}function N(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=0;r3?C-3:0),A=3;A2&&void 0!==arguments[2]?arguments[2]:{};r.parser||(r.parser={}),t||(t=Me);var n=new Set(b("rawElements",_e,"array",r.parser)),a=new Set(b("selfClosingElements",De,"array",r.parser)),o=/)-->|<(\/?)([a-z\-\_][a-z0-9\-\_]*)\s*([^>]*?)(".*?"|'.*?')?(\/?)>/gi,i=y("#document-fragment",null,[]),c=[i],l=i,d=-1;if(!e.includes("<")&&e)return Ve(l,e,t),i;for(var u,f,h=0;u=o.exec(e);h++){var p=u,v=s(p,6),m=v[0],g=v[1],N=v[2],T=v[3],E=v[4],w=v[5];d>-1&&d+m.length0){var O=e.slice(0,S);O&&!xe.exec(O)&&Ve(l,O,t)}if(d=o.lastIndex,"!"!==u[0][1]){var k=Ce.exec(N),R=k&&t.tags[k[1]],x=R?R.name||R:N,C=void 0;if(!g){!u[4]&&Le[l.rawNodeName]&&Le[l.rawNodeName][x]&&(c.pop(),l=c[c.length-1]);var M=T+(E||"");if(l=l.childNodes[l.childNodes.push(Pe(N,M,t))-1],c.push(l),r.parser.strict||n.has(x)){var A=""),I=e.indexOf(A,o.lastIndex);if(n.has(x)){-1===I?d=o.lastIndex=e.length+1:(d=I+A.length,o.lastIndex=d,C=!0);var _=e.slice(u.index+m.length,I);Ve(l,_,t)}}}if(C||g||w||a.has(x))for(;l;){if("/"===w&&k){c.pop(),l=c[c.length-1];break}if(R&&l.rawNodeName===x){c.pop(),l=c[c.length-1];break}if(l.rawNodeName===x){c.pop(),l=c[c.length-1];break}var D=je[l.rawNodeName];{if(!D||!D[x])break;c.pop(),l=c[c.length-1]}}}}var L=e.slice(-1===d?0:d);if(L&&Ve(l,L,t),i.childNodes.length&&"html"===i.childNodes[0].nodeName){var j={before:[],after:[]},V={after:[]},P=i.childNodes[0],F=!0,H=!0;if(P.childNodes=P.childNodes.filter(function(e){if("body"===e.nodeName||"head"===e.nodeName)return"head"===e.nodeName&&(F=!1),"body"===e.nodeName&&(H=!1),!0;e.nodeType===K.ELEMENT&&(F&&H?j.before.push(e):!F&&H?j.after.push(e):H||V.after.push(e))}),P.childNodes[0]&&"head"===P.childNodes[0].nodeName){var B=P.childNodes[0].childNodes;B.unshift.apply(B,j.before),B.push.apply(B,j.after)}else{var z=y("head",null,[]);if(z){var U=z.childNodes;U.unshift.apply(U,j.before),U.push.apply(U,j.after),P.childNodes.unshift(z)}}if(P.childNodes[1]&&"body"===P.childNodes[1].nodeName){var J=P.childNodes[1].childNodes;J.push.apply(J,V.after)}else{var G=y("body",null,[]);if(G){var X=G.childNodes;X.push.apply(X,V.after),P.childNodes.push(G)}}}return i}function E(e){var t=e.mount,r=e.input,n=r,a=Be++;return b("collectMetrics",!1)?function(e){e="[".concat(a,"] ").concat(e);var r=t.host;t&&r?e="".concat(r.constructor.name," ").concat(e):n&&"function"==typeof n.rawNodeName&&(e="".concat(n.rawNodeName.name," ").concat(e));var o="".concat(e,"-end");if(He.has(e)){var i=He.get(e)||0,s=(performance.now()-i).toFixed(3);He.delete(e),performance.mark(o),performance.measure("".concat(Fe," ").concat(e," (").concat(s,"ms)"),e,o)}else He.set(e,performance.now()),performance.mark(e)}:Q.FUN}function w(e){if(ze(e),e.childNodes.length)for(var t=0;t1&&(e.newTree=y(d.childNodes))}e.oldTree=t.oldTree;var p=e.oldTree,v=e.newTree;if(o&&p&&v){var m="string"!=typeof v.rawNodeName,g=v.nodeType===K.FRAGMENT,b=g&&!m?v.childNodes:v;e.newTree=y(c,l,b)}}function M(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Q.OBJ,o=arguments.length>5?arguments[5]:void 0;e||(e=Q.OBJ),t||(t=Q.OBJ);var i=n.svgElements,s=void 0===i?new Set:i,c=e.nodeName,l=t.nodeName,d=e===Q.OBJ||o,u="svg"===l||s.has(t),f=null;if(se.size&&se.forEach(function(n){var o=n(e,t,a);o&&o===e?f=r:!1===o?f=!1:o&&(t=o)}),null!==f||!t)return f;if(l===Qe){if(c===Qe&&e.nodeValue!==t.nodeValue)return r.push(W.NODE_VALUE,e,t.nodeValue,e.nodeValue),e.nodeValue=t.nodeValue,r;if(d)return r.push(W.NODE_VALUE,t,t.nodeValue,null),r}var h=t.childNodes||[];if(t.nodeType===K.ELEMENT){var p=d?Q.OBJ:e.attributes,v=t.attributes||{};for(var m in v){var g=v[m];m in p&&p[m]===v[m]||(d||(p[m]=g),(e&&"script"===e.nodeName||"script"!==t.nodeName||"type"!==m)&&r.push(W.SET_ATTRIBUTE,d?t:e,m,g))}if(!d)for(var b in p)b in v||(r.push(W.REMOVE_ATTRIBUTE,e,b),delete p[b])}if(o){for(var N=0;NA&&x.splice(B,1),r.push(W.REPLACE_CHILD,_,I)}}else h.splice(A,0,I),C+=1}else x.push(_),M(null,_,r,n,a,!0),r.push(W.INSERT_BEFORE,e,_,null);else!1===M(I,null,r,n,a,!0)&&h.splice(A,0,I)}if(x.length!==h.length){for(var z=h.length;z1&&void 0!==arguments[1]?arguments[1]:ue.document,r=arguments.length>2?arguments[2]:void 0,n=y(e),a=ne.get(n);if(a)return a;var o=n.nodeName,i=n.rawNodeName,s=void 0===i?o:i,c=n.childNodes,l=void 0===c?[]:c;r=r||"svg"===o;var d=null,u=null;if(ie.forEach(function(e){(u=e(n))&&(d=u)}),!t)return d;var f=d;f||(f="#text"===o?t.createTextNode(n.nodeValue||Q.STR):"#document-fragment"===o?t.createDocumentFragment():r?t.createElementNS(We,s):t.createElement(s),"script"===o&&(f.type="no-execute")),ne.set(n,f);for(var h=0;h1?t-1:0),n=1;n1&&void 0!==arguments[1]?arguments[1]:Q.OBJ,r=[],n=t.ownerDocument,a=t.svgElements,o=void 0===a?new Set:a,i=e.length,s=0;;){var l=e[s];if(s===i)break;switch(l){case W.REMOVE_ATTRIBUTE:case W.SET_ATTRIBUTE:if("break"===function(){var t=l===W.SET_ATTRIBUTE,a=e[s+1],i=e[s+2],d=t?j(e[s+3]):null;s+=t?4:3;var u=o.has(a),f=A(a,n,u),h=f.getAttribute(i),p=L("attributeChanged",a,i,h,d);w(a);var v=t?st:ct;return p.length?(Promise.all(p).then(function(){return v(a,f,i,d)}),r.push.apply(r,c(p))):v(a,f,i,d),"break"}())break;case W.NODE_VALUE:if("break"===function(){var t=e[s+1],a=e[s+2],i=e[s+3],l=o.has(t);s+=4;var d=A(t,n,l);w(t);var u=L("textChanged",t,i,a);return u.length?(Promise.all(u).then(function(){return lt(d,a)}),r.push.apply(r,c(u))):lt(d,a),"break"}())break;case W.INSERT_BEFORE:var d=e[s+1],u=e[s+2],f=e[s+3];if(s+=4,!ne.has(d)&&d!==rt)continue;var h=ne.get(d);if(d===rt){var p=ne.get(f);p&&(h=p.parentNode,f=p.nextSibling?p.nextSibling:null)}var v=o.has(u);w(u);var m=f&&A(f,n,v),g=A(u,n,v);h.insertBefore(g,m||null),r.push.apply(r,c(L("attached",u)));break;case W.REPLACE_CHILD:if("break"===function(){var t,a,i,l=e[s+1],d=e[s+2];s+=3;var u=o.has(l),f=ne.get(d),h=A(l,n,u);if(!f||!f.parentNode)return"break";w(l);var p=null===(t=te.get("attached"))||void 0===t?void 0:t.size,v=null===(a=te.get("detached"))||void 0===a?void 0:a.size,m=null===(i=te.get("replaced"))||void 0===i?void 0:i.size;if(!p&&!v&&!m)return f.parentNode.replaceChild(h,f),S(d),"break";f.parentNode.insertBefore(h,f);var g=[].concat(c(p&&L("attached",l)||Q.ARR),c(v&&L("detached",d)||Q.ARR),c(m&&L("replaced",d,l)||Q.ARR));return g.length?(Promise.all(g).then(function(){f.parentNode&&f.parentNode.removeChild(f),S(d)}),r.push.apply(r,c(g))):(f.parentNode.removeChild(f),S(d)),"break"}())break;case W.REMOVE_CHILD:if("break"===function(){var t=e[s+1];s+=2;var n=ne.get(t);if(!n||!n.parentNode)return"break";var a=L("detached",t);return a.length?(Promise.all(a).then(function(){n.parentNode&&n.parentNode.removeChild(n),S(t)}),r.push.apply(r,c(a))):(n.parentNode.removeChild(n),S(t)),"break"}())break}}return r}function P(e){var t=e.mount,r=e.state,n=e.patches,a=r.mutationObserver,o=r.measure,i=r.scriptsToExecute;o("patch node");var s=t.ownerDocument,l=e.promises||[];r.ownerDocument=s||ue.document,a&&a.disconnect();var d=function(e){"script"===e.nodeName&&i.set(e,e.attributes.type)};ie.add(d),r.ownerDocument&&l.push.apply(l,c(V(n,r))),ie.delete(d),e.promises=l,o("patch node")}function F(e){var t=e.promises;return t&&t.length?e.promise=Promise.all(t).then(function(){return e.end()}):e.promise=Promise.resolve(e.end())}function H(){return Boolean(dt&&"noModule"in dt)}function B(e){var t=e.state,r=e.input,n=e.config,a=t.measure;if("string"==typeof r){a("parsing input for new tree");var o=T(r,void 0,n),i=o.childNodes,s=y(i);s&&(e.newTree=s),a("parsing input for new tree")}}function z(e){return e.replace(/[&<>]/g,function(e){return"&#".concat(e.charCodeAt(0),";")})}function U(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Q.STR,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.inner=!0,r.executeScripts=!("executeScripts"in r)||r.executeScripts,r.tasks=r.tasks||ft,pt.create(e,t,r).start()}function J(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Q.STR,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.inner=!1,r.executeScripts=!("executeScripts"in r)||r.executeScripts,r.tasks=r.tasks||ft,pt.create(e,t,r).start()}function G(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=y(),n=new Set(t.tasks||ft);n.delete(ht.patchNode),n.delete(ht.endAsPromise),n.add(function(e){return q(e.oldTree)}),t.tasks=c(n),t.inner=!0;var a="";try{a=pt.create(r,e,t).start()}catch(e){throw x(r),e}return x(r),a}function X(e){var t=gt(e);return t.length?" "+t.map(function(t){var r=e[t],n=!r,a="object"==typeof r||"function"==typeof r;return!0===r?t:"".concat(t).concat(n||a?"":'="'.concat(String(r),'"'))}).join(" "):""}function q(e){var t="";if(!e)return t;var r=e.childNodes,n=e.nodeType,a=e.nodeName,o=e.nodeValue,i=e.attributes;if(11===n)for(var s=0;s").concat(c,"")}}else t+="<".concat(a).concat(X(i),">");return t}function Y(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n")1?t-1:0),n=1;n/i,Ce=new RegExp("".concat(Re,"([^_]*)__")),Me={tags:[],attributes:{},children:{}},Ae=Object.assign,Ie=Array.isArray,_e=["script","noscript","style","template"],De=["source","embed","param","track","input","meta","link","area","base","col","wbr","img","br","hr"],Le={li:{li:!0},p:{p:!0,div:!0},td:{td:!0,th:!0},th:{td:!0,th:!0}},je={li:{ul:!0,ol:!0},a:{div:!0},b:{div:!0},i:{div:!0},p:{div:!0},td:{tr:!0,table:!0},th:{tr:!0,table:!0}},Ve=function(e,t,r){var n;if(!("childNodes"in e.attributes)){if(t&&!xe.test(t)&&!Ce.test(t))return e.childNodes.push(y("#text",t));for(var a=[],o=t.split(Ce),i=0;i\/=\uFDD0-\uFDEF\uFFFE\uFFFF]*)\s*(=\s*("([^"]+)"|'([^']+)'|(\S+)))?/gi;if(a=Ce.exec(e))return Pe(r.tags[a[1]],t,r);for(var i,s={};i=o.exec(t||Q.STR);){var c="string"==typeof e,l=i[1],d=void 0;if(""===l){var u=t.match(Ce);d=u?u[0]:""}var f=i[6]||i[5]||i[4],h=d||f||(c?i[1]:f||!0),p="''"===h||'""'===h?Q.STR:h,v=String(p).match(Ce);if(v&&v.length)for(var m=String(p).split(Ce),g=Ce.exec(l),b=g?r.attributes[g[1]]:l,N=0;N{}},o={SET_ATTRIBUTE:0,REMOVE_ATTRIBUTE:1,NODE_VALUE:2,INSERT_BEFORE:3,REPLACE_CHILD:4,REMOVE_CHILD:5},s=new Map,r=new Map,i=new Set,c=new Set,d=new Set,a=new Set,l=new Set,u=new Set;var h="undefined"!=typeof process?process:{env:{NODE_ENV:"development"},argv:[]},f="object"==typeof global?global:("object"==typeof window?window:self)||{};const{parseInt:p}=Number,{parse:N}=JSON;function m(e,t){const n=String(e);switch(t){case"boolean":return"false"!==n;case"string":return n;case"number":return p(n,10);case"object":return N(n)}}function T(e,t,n=typeof t,o){const{location:s,URLSearchParams:r}=f,i=void 0!==r&&void 0!==s,c=h.env;if(o&&e in o)return o[e];const d=`DIFF_${e.replace(/[^a-zA-Z0-9]/,"")}`;if(i){const e=new r(s.search),t=d.toLowerCase();if(e.has(t))return m(decodeURIComponent(String(e.get(t))),n)}const a=d.toUpperCase();return c&&a in h.env?m(h.env[a.toUpperCase()],n):t}const g=T("initialPoolSize",5e3),b=new Set,E=new Set,y=new Set,w=()=>({rawNodeName:n.STR,nodeName:n.STR,nodeValue:n.STR,nodeType:t.ELEMENT,key:n.STR,childNodes:[],attributes:{}}),S={free:b,allocated:E,protected:y};let O=b.values();const R={size:g,memory:S,fill(){for(let e=b.size;e{b.size!==this.size&&b.delete(e)}))},get(){const{value:e=w(),done:t}=O.next();return t&&(O=b.values()),b.delete(e),E.add(e),e},protect(e){E.delete(e),y.add(e)},unprotect(e){(y.has(e)||E.has(e))&&(y.delete(e),E.add(e))}};R.fill();const{isArray:x}=Array,{memory:M}=R,k="#document-fragment",v="#text";function C(e,t=[]){for(let n=0;n{t===e&&(d=n)})),d=d||V(l.nodeName,o,s),d.attributes={...d.attributes,...o},d.childNodes=s,r.set(d,l),d}if(a&&!o){const{rawNodeName:t,nodeName:n,nodeValue:o,attributes:s,childNodes:r,children:i}=e,c=V(t||n,s||null,i||r);return o&&(c.nodeValue=o),c}i.length&&(s=[s,...i]),d=R.get();const u=e===v;"string"==typeof e?(d.rawNodeName=e,d.nodeName=d.rawNodeName.toLowerCase()):(d.rawNodeName=e,d.nodeName=k),d.nodeValue=n.STR,d.key=n.STR,d.childNodes.length=0,d.attributes={};const h=x(o)||"object"!=typeof o?o:s,f=C(x(h)?h:[h]);if(u){const e=f.join(n.STR);return d.nodeType=t.TEXT,d.nodeValue=String(e),d}if(d.nodeName===k?d.nodeType=t.FRAGMENT:d.nodeType="#comment"===e?t.COMMENT:t.ELEMENT,h&&f.length&&(!o||!o.childNodes))for(let e=0;e{(t=e(d))&&(d=V(t))})),d}const I=new Map;let _=0;function A(e){const{mount:t,input:o}=e,s=o,r=_++;return T("collectMetrics",!1)?e=>{e=`[${r}] ${e}`;const{host:n}=t;t&&n?e=`${n.constructor.name} ${e}`:s&&"function"==typeof s.rawNodeName&&(e=`${s.rawNodeName.name} ${e}`);const o=`${e}-end`;if(I.has(e)){const t=I.get(e)||0,n=(performance.now()-t).toFixed(3);I.delete(e),performance.mark(o),performance.measure(`diffHTML ${e} (${n}ms)`,e,o)}else I.set(e,performance.now()),performance.mark(e)}:n.FUN}const{protect:L,unprotect:B,memory:D}=R;function U(e){if(L(e),e.childNodes.length)for(let t=0;t{e.attributes={},e.childNodes.length=0,e.key=n.STR,D.free.add(e),D.allocated.delete(e),r.delete(e)}))}var j=Object.freeze({__proto__:null,protectVTree:U,unprotectVTree:H,gc:$});function F(e){const{mount:t,input:n,state:{measure:o},config:s}=e,r=s.inner?"innerHTML":"outerHTML";o("should update");if("string"==typeof n&&t[r]===n)return e.abort(!0);o("should update")}const J="undefined"!=typeof requestIdleCallback;let P=-1;function z(e){if(s.has(e)){const{mutationObserver:t,oldTree:n}=s.get(e);t&&t.disconnect(),n&&!r.has(n)&&(l.forEach((e=>e(n))),H(n)),s.delete(e)}if(!e)return;const t=e;if(t.childNodes&&t.childNodes.length)for(let e=0;e{e===t&&(l.forEach((e=>e(n))),H(n))})),(J?cancelIdleCallback:clearTimeout)(P),P=(J?requestIdleCallback:setTimeout)($)}function G(e){const{state:n,mount:o,input:r,config:i}=e,{inner:c}=i,d=o;n.mutationObserver&&!n.isDirty?n.isDirty=Boolean(n.mutationObserver.takeRecords().length):n.mutationObserver||(n.isDirty=!1),!n.isDirty&&n.oldTree||(z(d),d.ownerDocument&&n.mutationObserver&&n.mutationObserver.observe(d,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),n.oldTree=V(d),U(n.oldTree),s.set(o,n));const{nodeName:a,attributes:l}=n.oldTree;e.newTree||(e.newTree=V(r));const u=e.newTree;if(!c&&u.nodeType===t.FRAGMENT&&n.oldTree.nodeType!==t.FRAGMENT){let n=[];for(let e=0;e1&&(e.newTree=V(u.childNodes))}e.oldTree=n.oldTree;const{oldTree:h,newTree:f}=e;if(c&&h&&f){const n="string"!=typeof f.rawNodeName,o=f.nodeType===t.FRAGMENT&&!n?f.childNodes:f;e.newTree=V(a,l,o)}}const{assign:X}=Object,{max:q}=Math,Y=["old","new"],Z="#text";function K(e,s,r=[],i={},c=n.OBJ,d){e||(e=n.OBJ),s||(s=n.OBJ);const{svgElements:l=new Set}=i,u=e===n.OBJ||d;let h=null;if(a.size&&a.forEach((t=>{const n=t(e,s,c);n&&n===e?h=r:!1===n?h=!1:n&&X(s,n)})),null!==h||!s)return h;const f=e.nodeName,p=s.nodeName,N="svg"===p||l.has(s);if(p===Z){if(f===Z&&e.nodeValue!==s.nodeValue)return r.push(o.NODE_VALUE,e,s.nodeValue,e.nodeValue),e.nodeValue=s.nodeValue,r;if(u)return r.push(o.NODE_VALUE,s,s.nodeValue,null),r}const m=s.childNodes||[];if(s.nodeType===t.ELEMENT){const t=u?n.OBJ:e.attributes,i=s.attributes||n.OBJ;for(let n in i){const c=i[n];n in t&&t[n]===i[n]||(u||(t[n]=c),(e&&"script"===e.nodeName||"script"!==s.nodeName||"type"!==n)&&r.push(o.SET_ATTRIBUTE,u?s:e,n,c))}if(!u)for(let n in t)n in i||(r.push(o.REMOVE_ATTRIBUTE,e,n),delete t[n])}if(d){for(let e=0;et&&g.splice(e,1),r.push(o.REPLACE_CHILD,s,n)}}else m.splice(t,0,n),b+=1}if(g.length!==m.length){for(let e=m.length;e{(h=e(s))&&(u=h)})),!t)return u;let p=u;p||(p="#comment"===c?t.createComment(s.nodeValue||n.STR):"#text"===c?t.createTextNode(s.nodeValue||n.STR):"#document-fragment"===c?t.createDocumentFragment():o?t.createElementNS("http://www.w3.org/2000/svg",a):t.createElement(a),"script"===c&&(p.type="no-execute")),r.set(s,p);for(let e=0;e{const r="object"==typeof s&&s,i="function"==typeof s,c="symbol"==typeof s,d=t,a=0===o.indexOf("on")?o.toLowerCase():o,l="s-"+e.nodeName+"-"+a,u=t;if(ie.has(l))d[a]=s;else if(!re.has(l))try{d[a]=s,ie.add(l)}catch{re.add(l)}if(r||i||c){if(r&&"style"===a){const e=se(s);for(let t=0;t{const o="r-"+e.nodeName+"-"+n,s=t;if(ie.has(o))s[n]=void 0,delete s[n];else if(!re.has(o))try{s[n]=void 0,delete s[n],ie.add(o)}catch{re.add(o)}t.removeAttribute(n)};function ae(e){const{mount:t,state:s,patches:i}=e,{measure:c,scriptsToExecute:a}=s;c("patch node");const{ownerDocument:l}=t;s.ownerDocument=l||f.document;const u=e=>{"script"===e.nodeName&&a.set(e,e.attributes.type)};d.add(u),s.ownerDocument&&function(e,t=n.OBJ){const{ownerDocument:s,svgElements:i=new Set}=t,{length:c}=e;let d=0;for(;;){const t=e[d];if(d===c)break;switch(t){case o.REMOVE_ATTRIBUTE:case o.SET_ATTRIBUTE:{const n=t===o.SET_ATTRIBUTE,r=e[d+1],c=e[d+2],a=n?te(e[d+3]):null;d+=n?4:3;const l=Q(r,s,i.has(r));U(r),(n?ce:de)(r,l,c,a);break}case o.NODE_VALUE:{const t=e[d+1],n=e[d+2];d+=4;const o=Q(t,s,i.has(t));U(t),n.includes("&")?o.nodeValue=te(n):o.nodeValue=n;break}case o.INSERT_BEFORE:{const t=e[d+1],n=e[d+2];let o=e[d+3];if(d+=4,!r.has(t)&&t!==ne)continue;let c=r.get(t);if(t===ne){const e=r.get(o);e&&(c=e.parentNode,o=e.nextSibling?e.nextSibling:null)}const a=i.has(n);U(n);const l=o&&Q(o,s,a),u=Q(n,s,a);c.insertBefore(u,l||null);break}case o.REPLACE_CHILD:{const t=e[d+1],n=e[d+2];d+=3;const o=i.has(t),c=r.get(n),a=Q(t,s,o);if(!c||!c.parentNode)break;U(t),c.parentNode.insertBefore(a,c),c.parentNode.removeChild(c),H(n);break}case o.REMOVE_CHILD:{const t=e[d+1];d+=2;const n=r.get(t);if(!n||!n.parentNode)break;n.parentNode.removeChild(n),H(t);break}}}}(i,s),d.delete(u),c("patch node")}function le(e){return e.end()}const ue=f.document?document.createElement("script"):null;const{assign:he}=Object,fe=[F,G,W,ae,le],pe={shouldUpdate:F,reconcileTrees:G,syncTrees:W,patchNode:ae,endAsTransaction:le};class Ne{static create(e,t,n){return new Ne(e,t,n)}static flow(e,t){let n=e;for(let o=0;o{const s=`invoke ${o.name||"anon"}`;t(s);const r=o(e);r&&n.push(r),t(s)}))}constructor(e,t,o){this.mount=e,this.input=t,this.config=o;const r=!o.disableMutationObserver&&"MutationObserver"in(f.window||n.OBJ);this.state=s.get(e)||{measure:A(this),svgElements:new Set,scriptsToExecute:new Map,mutationObserver:r&&new f.window.MutationObserver((()=>{this.state.isDirty=!0}))},this.tasks=T("tasks",fe,void 0,o).slice(),this.endedCallbacks=new Set,s.set(e,this.state)}start(){const{state:{measure:e},tasks:t}=this,n=t.pop();return e("render"),this.aborted=!1,Ne.invokeMiddleware(this),n&&t.push(n),Ne.flow(this,t)}abort(e){if(this.aborted=!0,e)return this.tasks[this.tasks.length-1](this)}end(){const{state:e,config:t,mount:n}=this,{mutationObserver:o,measure:i,svgElements:c,scriptsToExecute:d}=e,a=n;return i("finalize"),this.completed=!0,c.clear(),e.isRendering=!1,e.isDirty=!1,s.forEach((e=>{e.mutationObserver&&e.mutationObserver.takeRecords()})),a.ownerDocument&&o?o.observe(a,{subtree:!0,childList:!0,attributes:!0,characterData:!0}):e.isDirty=!0,d.forEach(((n,o)=>{const i=r.get(o);if(i.type=n,!t.executeScripts||Boolean(ue&&"noModule"in ue)&&"nomodule"===n)return;const c=he(i.ownerDocument.createElement("script"),i);for(let e in o.attributes){const t=o.attributes[e];c.setAttribute(e,t)}c.textContent=i.textContent,s.has(i)&&(z(i),s.set(c,e)),r.set(o,c),i.parentNode&&i.parentNode.replaceChild(c,i)})),d.clear(),this.endedCallbacks.forEach((e=>e(this))),this.endedCallbacks.clear(),i("finalize"),i("render"),e.oldTree&&U(e.oldTree),this}onceEnded(e){this.endedCallbacks.add(e)}state=n.OBJ;mount=n.OBJ;input=n.OBJ;oldTree=void 0;newTree=void 0;tasks=[];patches=[]}function me(e){return e.replace(/[&<>]/g,(e=>`&#${e.charCodeAt(0)};`))}var Te={decodeEntities:te,escape:me,makeMeasure:A,memory:j,Pool:R,process:h,globalConfig:{collectMetrics:!0,executeScripts:!0},parse:n.FUN,PATCH_TYPE:o,NODE_TYPE:t,createNode:Q,syncTree:K,Transaction:Ne,defaultTasks:fe,tasks:pe,...{StateCache:s,NodeCache:r,MiddlewareCache:i,CreateTreeHookCache:c,CreateNodeHookCache:d,SyncTreeHookCache:a,ReleaseHookCache:l,ParseHookCache:u}};const ge=["script","noscript","style","template"],be=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Ee={li:{li:n.NUM},dt:{dt:n.NUM,dd:n.NUM},dd:{dt:n.NUM,dd:n.NUM},td:{td:n.NUM,th:n.NUM},th:{td:n.NUM,th:n.NUM},tbody:{tbody:n.NUM,tfoot:n.NUM},tfoot:{tbody:n.NUM,tfoot:n.NUM}},ye=//g,Se=/<([^\s\\/>]*)\s?/g,Oe=/\s?(\/>)|(<\/(.*?)>)/g,Re=/([^>\/\n ])*?(["'])(?:(?=(\\?))\3.)*?\2|.*?(?=\/>|>|\n| )/gms,xe=/([^=]*)=(.*)|([^>])/gms,Me=/([^<]*)/g;function ke(e){if("string"!=typeof e)return e;const t=['"',"'"],n=t.indexOf(e[0]),o=-1!==n&&t.indexOf(e[e.length-1]);return-1!==n&&o===n?e.slice(1,e.length-1):e}function ve(e,t=n.STR,o={}){return o.inner=!0,o.executeScripts=!("executeScripts"in o)||o.executeScripts,o.tasks=o.tasks||fe,Ne.create(e,t,o).start()}function Ce(e,t=n.STR,o={}){return o.inner=!1,o.executeScripts=!("executeScripts"in o)||o.executeScripts,o.tasks=o.tasks||fe,Ne.create(e,t,o).start()}const{keys:Ve}=Object;function Ie(e,t={}){const n=V(),o=new Set(t.tasks||fe);o.delete(pe.patchNode),o.delete(pe.endAsTransaction),o.add((function(e){return Ae(e.oldTree)})),t.tasks=[...o],t.inner=!0;let s="";try{s=Ne.create(n,e,t).start()}catch(e){throw z(n),e}return z(n),s}function _e(e){const t=Ve(e);return t.length?" "+t.map((t=>{const n=e[t];return!0===n?t:`${t}${!n||("object"==typeof n||"function"==typeof n)?"":`="${String(n)}"`}`})).join(" "):""}function Ae(e){let t="";if(!e)return t;const{childNodes:n,nodeType:o,nodeName:s,nodeValue:r,attributes:i}=e;if(11===o)for(let e=0;e`${Ae(e)}`)).join("");t+=`<${s}${_e(i)}>${e}`}}else t+=`<${s}${_e(i)}>`;return t}const Le="__DIFFHTML__",{getOwnPropertyNames:Be}=Object,{isArray:De}=Array,Ue=new RegExp(`${Le}([^_]*)__`),He=(e,o)=>{let s=null,r=e.rawNodeName;if(e.nodeType===t.COMMENT){const t=e.nodeValue.split(Ue);let n="";for(let e=0;e{const r=e.attributes[t];let i=r,c=t;if(s=Ue.exec(r)){const e=r.split(Ue);if(i="",3===e.length&&e[0]===n.STR&&e[2]===n.STR)i=o.attributes[e[1]];else for(let t=0;t{if(r+=e,o.length){const e=(e=>{const t=e.shift();return"string"==typeof t?me(te(t)):t})(o),n=r.trim().slice(-1),s=r.trim().slice(-2),c=r.lastIndexOf(">"){t&&i.delete(e),o&&o(Te),s&&c.delete(s),r&&d.delete(r),h&&a.delete(h),f&&l.delete(f),p&&u.delete(p)}}const Fe="1.0.0-beta.30";fe.splice(fe.indexOf(G),0,(function(e){const{state:t,input:n,config:o}=e,{measure:s}=t;if("string"==typeof n){s("parsing input for new tree");const{childNodes:t}=Te.parse(n,o),r=V(t);r&&(e.newTree=r),s("parsing input for new tree")}})),Te.VERSION=Fe,Te.parse=function(e,o={}){const s=V("#document-fragment",null,[]);if(!e)return s.childNodes.push(V("#text",n.STR)),s;o.parser||(o.parser=n.OBJ);const r=new Set(T("rawElements",ge,"array",o.parser)),i=new Set(T("voidElements",be,"array",o.parser));if(!e.includes("<")&&!e.includes(">")){const t=V("#text",e);return s.childNodes.push(t),s}const c=[s];let d=0,a=s,l=!1,u=e.indexOf("\x3c!--");const h=()=>{const e=V(c.pop());a=c[c.length-1],a.childNodes.push(e)};for(;d",T)+1;continue}const t={rawNodeName:m,nodeName:m,childNodes:[],attributes:{},nodeType:n.NUM,nodeValue:n.STR,key:n.STR},o=Ee[m];o&&o[a.nodeName]&&h(),a=t,c.push(a),l=!0,d=T+N.length;continue}const{0:g,index:b}=Re.exec(e)||n.OBJ,E=b===d&&g.trim();if(l&&b===d){if(!E){if(d=d+g.length+1,">"===e[d-1]){const t=d===e.length;("/"===e[d-2]||i.has(a.nodeName)||t)&&h(),l=!1}continue}const{1:t=g,2:o=g}=xe.exec(E)||n.OBJ,s=t===o||void 0===o,r=t.trim();a.attributes[r]=s?Boolean(o):ke(o),d=b+g.length;continue}if(p){const t=``;let n=e.indexOf(t,d);-1===n&&(n=e.length);const o=e.slice(d,n);o&&a.childNodes.push(V("#text",o)),d=n+t.length,l=!1,h();continue}if(">"===e[d]){l=!1,d+=1,i.has(a.nodeName)&&h();continue}const{0:y,3:w,index:S}=Oe.exec(e)||n.OBJ;if(S===d&&y){const e=i.has(w);"/"===y[1]&&f&&!e&&h(),l=!1,d=S+y.length;continue}const{0:O,index:R}=Me.exec(e)||n.OBJ;if(l||R!==d||!O.length)a.childNodes.push(V("#text",e.slice(d,e.length))),d=e.length;else{const t=V("#text",O);a.childNodes.push(t),d=R+O.length,d===e.length&&f&&h()}}if(s.childNodes.length&&"html"===s.childNodes[0].nodeName){const e={before:[],after:[]},n={after:[]},o=s.childNodes[0];let r=!0,i=!0;if(o.childNodes=o.childNodes.filter((o=>{if("body"===o.nodeName||"head"===o.nodeName)return"head"===o.nodeName&&(r=!1),"body"===o.nodeName&&(i=!1),!0;o.nodeType===t.ELEMENT&&(r&&i?e.before.push(o):!r&&i?e.after.push(o):i||n.after.push(o))})),o.childNodes[0]&&"head"===o.childNodes[0].nodeName){const t=o.childNodes[0].childNodes;t.unshift.apply(t,e.before),t.push.apply(t,e.after)}else{const t=V("head",null,[]);if(t){const n=t.childNodes;n.unshift.apply(n,e.before),n.push.apply(n,e.after),o.childNodes.unshift(t)}}if(o.childNodes[1]&&"body"===o.childNodes[1].nodeName){const e=o.childNodes[1].childNodes;e.push.apply(e,n.after)}else{const e=V("body",null,[]);if(e){const t=e.childNodes;t.push.apply(t,n.after),o.childNodes.push(e)}}}return s};const Je={};if(Je.VERSION=Fe,Je.release=z,Je.createTree=V,Je.use=je,Je.outerHTML=Ce,Je.innerHTML=ve,Je.toString=Ie,Je.html=$e,Je.Internals=Te,oe in f){const e=f[oe];Fe!==e.VERSION&&console.log(`Loaded 1.0.0-beta.30 after ${e.VERSION}`)}f[oe]=Je,f.devTools&&(f.unsubscribeDevTools=je(f.devTools(Te))),e.Internals=Te,e.VERSION=Fe,e.createTree=V,e.default=Je,e.html=$e,e.innerHTML=ve,e.outerHTML=Ce,e.release=z,e.toString=Ie,e.use=je,Object.defineProperty(e,"__esModule",{value:!0})})); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 8e465cfa078..521cbe5ff75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1490,10 +1490,10 @@ devtools-protocol@0.0.1147663: resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1147663.tgz#4ec5610b39a6250d1f87e6b9c7e16688ed0ac78e" integrity sha512-hyWmRrexdhbZ1tcJUGpO95ivbRhWXz++F4Ko+n21AY5PNln2ovoJw+8ZMNDTtip+CNFQfrtLVh/w4009dXO/eQ== -diffhtml@1.0.0-beta.20: - version "1.0.0-beta.20" - resolved "https://registry.yarnpkg.com/diffhtml/-/diffhtml-1.0.0-beta.20.tgz#129b403fa152276c9b876188980ca0f9b2540351" - integrity sha512-xSSwGb2dkQsTc7Bl910iySH65PkzsCtowfVGMfrmc2fEwvYrhJUpIEIx+3mpZ1wMWVt+t/0ltVwrjQkMJotxLg== +diffhtml@1.0.0-beta.30: + version "1.0.0-beta.30" + resolved "https://registry.yarnpkg.com/diffhtml/-/diffhtml-1.0.0-beta.30.tgz#725c0a5941bd825675f8a62b701a12a67e7516c7" + integrity sha512-yrBteaq309reltj+kAnGqsnpJyQSqmCkd5LAJNAcWNmlgvu+PbiUm9bNxdRYi21BQsQsljTxrjs+AWeeHHghWA== dir-glob@^3.0.1: version "3.0.1"