Socket
Socket
Sign inDemoInstall

yallajs

Package Overview
Dependencies
0
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-beta.35 to 2.0.0-beta.36

23

lib/yalla.js

@@ -531,3 +531,3 @@ "use strict";

if (callbackItem.calledOnce) {
var _callbackItem$token$s = callbackItem.token.split(':'),
var _callbackItem$token$s = callbackItem.token.split(":"),
_callbackItem$token$s2 = _slicedToArray(_callbackItem$token$s, 2),

@@ -571,3 +571,3 @@ _event = _callbackItem$token$s2[0],

}
throw new Error("Unable to find outlet " + id);
return false;
};

@@ -635,4 +635,6 @@

var outlet = getTemporaryOutlet(id, context);
outlet.setContent(result);
syncNode(result, outlet.commentNode);
if (outlet) {
outlet.setContent(result);
syncNode(result, outlet.commentNode);
}
});

@@ -649,3 +651,5 @@ } else {

var outlet = getTemporaryOutlet(_id, context);
template.factory.apply(null, [outlet]);
if (outlet) {
template.factory.apply(null, [outlet]);
}
}, true);

@@ -1026,2 +1030,9 @@ } else {

};
var executeWithRequestAnimationFrame = function executeWithRequestAnimationFrame(callback) {
if ('requestAnimationFrame' in window) {
requestAnimationFrame(callback);
} else {
callback();
}
};

@@ -1031,3 +1042,3 @@ var render = function render(templateValue, node) {

return new Promise(function (resolve) {
executeWithIdleCallback(function () {
executeWithRequestAnimationFrame(function () {
setContent.apply(null, [templateValue, node]);

@@ -1034,0 +1045,0 @@ resolve();

@@ -1,1 +0,1 @@

"use strict";function _taggedTemplateLiteral(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _slicedToArray=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var a,l=e[Symbol.iterator]();!(o=(a=l.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&l.return&&l.return()}finally{if(r)throw i}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),_typeof="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},_templateObject=_taggedTemplateLiteral(['<span id="','" style="display: none" data-async-outlet>outlet</span>'],['<span id="','" style="display: none" data-async-outlet>outlet</span>']);!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=t():(e.yalla=t(),e.Context=e.Context||e.yalla.Context,e.render=e.render||e.yalla.render,e.plug=e.plug||e.yalla.plug,e.uuidv4=e.uuidv4||e.yalla.uuidv4)}("undefined"!=typeof self?self:eval("this"),function(){var e="chrome"in window&&"webstore"in window.chrome,t=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},n=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"destroy",value:function(){throw new Error("Please implement template.destroy ")}}]),e}(),o={INPUT:["VALUE"]},r={col:"colgroup",td:"tr",area:"map",tbody:"table",tfoot:"table",th:"tr",thead:"table",tr:"tbody",caption:"table",colgroup:"table",li:"ul",g:"svg",circle:"svg",rect:"svg",polygon:"svg",eclipse:"svg",text:"svg"},i=function(e,t,n){var o=e,r=t.map(function(e){return n[e]});return t.forEach(function(e,t){o=o.replace("\x3c!--"+e+"--\x3e",r[t])}),o},a=function(e){function t(e,n,o,r){_classCallCheck(this,t);var i=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.items=e,i.keyFn="string"==typeof n?function(e){return e[n]}:n,i.templateFn=o,i.context=r,i.keys=[],i.templates={},i.initialzed=!1,i}return _inherits(t,n),_createClass(t,[{key:"iterateRight",value:function(e){if(this.initialzed)for(var t=this.keys.length-1;t>=0;){var n=this.items[t],o=this.keys[t],r=this.templates[o];e&&e.apply(null,[n,o,r,t]),t--}else{for(var i=this.items.length-1;i>=0;){var a=this.items[i],l=this.keyFn.apply(this,[a,i]),s=this.templateFn.apply(this,[a,i]);e&&e.apply(null,[a,l,s,i]),i--,this.keys.push(l),this.templates[l]=s}this.initialzed=!0,this.keys.reverse()}}}]),t}(),l=function(){function e(t){_classCallCheck(this,e),this.node=t,this.attributes={}}return _createClass(e,null,[{key:"from",value:function(t){var n=t;return t.nodeType===Node.ATTRIBUTE_NODE&&(n=t.ownerElement),n.$data=n.$data||new e(n),n.$data}}]),e}(),s=function(e){function t(e,n,o){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.strings=e,r.values=n,r.context=o,r.key=r.strings.join("").trim(),r.nodeValueIndexArray=null,r.documentFragment=null,r}return _inherits(t,n),_createClass(t,[{key:"buildTemplate",value:function(e){this.documentFragment=t.getProperTemplateTag(e),this.nodeValueIndexArray=this.buildNodeValueIndex(this.documentFragment,this.documentFragment.nodeName),t.applyValues(this,this.nodeValueIndexArray)}},{key:"buildNodeValueIndex",value:function(e,n){var o=[],r=e.childNodes[0];if(void 0===r)return o;do{if(r.nodeType===Node.ELEMENT_NODE){for(var i=r.attributes,a=i.length,l=0;l<a;l++){var s=i[l].nodeValue,c=t.lookNodeValueArray(s).map(function(e){return e.match(/[\w\.]+/)[0]}).map(function(e){return parseInt(e)});c&&c.length>0&&o.push({node:i[l],valueIndexes:c,nodeValue:s})}o=o.concat(this.buildNodeValueIndex(r,r.nodeName))}if(r.nodeType===Node.TEXT_NODE&&"STYLE"===n.toUpperCase()){var u=r.nodeValue,d=t.lookNodeValueArray(u).map(function(e){return e.match(/[\w\.]+/)[0]}).map(function(e){return parseInt(e)});d&&d.length>0&&o.push({node:r,valueIndexes:d,nodeValue:u})}if(r.nodeType===Node.COMMENT_NODE){var f=r.nodeValue;r.nodeValue="outlet",o.push({node:r,valueIndexes:parseInt(f)})}r=r.nextSibling}while(r);return o}},{key:"constructTemplate",value:function(){if(!this.context.hasCache(this.key)){var e=this.buildStringSequence();return this.buildTemplate(e),this.context.cache(this.key,this)}for(var t=this.context.cache(this.key),n=t.documentFragment.querySelectorAll("span[data-async-outlet]"),o=n.length;o--;){var r=n[o];if(r.nextSibling){d.from(r.nextSibling).clearContent()}}return t}},{key:"buildStringSequence",value:function(){return this.strings.reduce(function(e,t,n){return 0===n?t:e+"\x3c!--"+(n-1)+"--\x3e"+t},"").trim()}}],[{key:"lookNodeValueArray",value:function(e){for(var t=[],n=e.indexOf("\x3c!--"),o=e.indexOf("--\x3e",n);o<e.length&&o>=0&&n>=0;)t.push(e.substring(n+4,o)),n=e.indexOf("\x3c!--",o+3),o=e.indexOf("--\x3e",n);return t}},{key:"getProperTemplateTag",value:function(e){var t=e.substring(1,e.indexOf(">"));t=(t.indexOf(" ")>0?t.substring(0,t.indexOf(" ")):t).toLowerCase();var n=r[t];n=n||"div";var o=document.createElement(n);return o.innerHTML=e,o}},{key:"applyValues",value:function(e,t){var n=e.values,r=e.context;t&&t.forEach(function(e){var t=e.node,a=e.valueIndexes,s=e.values,c=Array.isArray(a)?a.map(function(e){return n[e]}):n[a],u=t.nodeName,f=t.nodeType===Node.ATTRIBUTE_NODE&&0===u.indexOf("on");if(!(function(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(var n=!0,o=0;o<t.length;o++)if(!(n=n&&e[o]===t[o]))return!1;return!0}return!1}(c,s)||f&&c[0].name)){if(t.nodeType===Node.ATTRIBUTE_NODE){var h=l.from(t),m=e.nodeValue;if(f){var p=a[0];t.ownerElement[u]=n[p],h.attributes[u]=n[p]}else{var y=i(m,a,n);if(!function(e){return["checked","compact","declare","defer","disabled","ismap","noresize","noshade","nowrap","selected"].indexOf(e.nodeName)>=0}(t)?(t.ownerElement.setAttribute(u,y),function(e,t){return e=e.toUpperCase(),t=t.toUpperCase(),!!o[t]&&o[t].indexOf(e)>=0}(u,t.ownerElement.nodeName)&&(t.ownerElement[u]=y)):(t.ownerElement[u]="true"===y.trim(),t.ownerElement.setAttribute(u,"")),u.indexOf(".bind")>=0){var v=u.substring(0,u.indexOf(".bind"));t.ownerElement.setAttribute(v,y)}h.attributes[u]=y}}if(t.nodeType===Node.TEXT_NODE&&(t.nodeValue=i(e.nodeValue,a,n)),t.nodeType===Node.COMMENT_NODE){var C=n[a];d.from(t).setContent(C,r)}e.values=c}})}}]),t}(),c=function(){function e(){var t=this;_classCallCheck(this,e),this.cacheInstance={},this.syncCallbackStack=[],this.html=function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return new s(e,o,t)},this.htmlCollection=function(e,n,o){return new a(e,n,o,t)},this.listeners={}}return _createClass(e,[{key:"hasCache",value:function(e){return e in this.cacheInstance}},{key:"cache",value:function(e,t){return this.hasCache(e)||(this.cacheInstance[e]=t),this.cacheInstance[e]}},{key:"addSyncCallback",value:function(e){this.syncCallbackStack.push(e)}},{key:"addEventListener",value:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e+":"+t();this.listeners[e]=this.listeners[e]||[];return this.listeners[e].push({token:r,callback:n,calledOnce:o}),r}},{key:"removeEventListener",value:function(e){var t=e.split(":"),n=_slicedToArray(t,2),o=n[0],r=n[1],i=this.listeners[o];i=i.filter(function(e){return e.token!=r}),this.listeners[o]=i}},{key:"dispatchEvent",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];if(e in this.listeners){var r=this.listeners[e],i=[];r.forEach(function(e){if(e.callback.apply(null,n),e.calledOnce){var t=e.token.split(":"),o=_slicedToArray(t,2),r=(o[0],o[1]);i.push(r)}}),i.length>0&&(r=r.filter(function(e){return i.indexOf(e.token)<0})),this.listeners[e]=r}}},{key:"clearSyncCallbacks",value:function(){this.syncCallbackStack.forEach(function(e){return e.apply()}),this.syncCallbackStack=[],this.dispatchEvent("syncingdone")}}]),e}(),u=function(e,t){var n=document.getElementById(e);if(n||(n=t.root.getElementsByTagName("*")[e]),n){var o=n.nextSibling;return n.remove(),d.from(o)}throw new Error("Unable to find outlet "+e)},d=function(){function e(t){_classCallCheck(this,e),this.commentNode=t,this.content=null}return _createClass(e,[{key:"constructTextContent",value:function(){this.content=this.commentNode.previousSibling}},{key:"constructHtmlTemplateCollectionContent",value:function(e){var t=this;this.content=new f(e,this),this.content.instance={};var n=this.commentNode;e.iterateRight(function(e,o){do{n=n.previousSibling}while(n.nodeType!==Node.COMMENT_NODE&&"outlet-child"!==n.nodeValue);t.content.instance[o]=n})}},{key:"constructHtmlTemplateContent",value:function(e){if(void 0!==e){var t=e.context.cache(e.key).documentFragment.childNodes.length;this.content=new h(e,this);for(var n=this.commentNode;t--;)n=n.previousSibling,this.content.instance.push(n);this.content.instance.reverse()}}},{key:"makeTemporaryOutlet",value:function(e){var n=t();return this.setHtmlTemplateContent(e.html(_templateObject,n)),n}},{key:"setContent",value:function(e,t){var n=this;if(function(e){return"object"===(void 0===e?"undefined":_typeof(e))&&"constructor"in e&&"Promise"===e.constructor.name}(e))if(null===this.content){var o=this.makeTemporaryOutlet(t);e.then(function(e){var n=u(o,t);n.setContent(e),p(e,n.commentNode)})}else e.then(function(e){n.setContent(e)});else if(e instanceof x)if(null===this.content){var r=this.makeTemporaryOutlet(t);t.addEventListener("syncingdone",function(){var n=u(r,t);e.factory.apply(null,[n])},!0)}else e.factory.apply(null,[this]);else e instanceof s?this.setHtmlTemplateContent(e):e instanceof a?this.setHtmlTemplateCollectionContent(e):this.setTextContent(e)}},{key:"setTextContent",value:function(e){this.content instanceof Text?this.content.nodeValue=e:(this.clearContent(),this.content=document.createTextNode(e),this.commentNode.parentNode.insertBefore(this.content,this.commentNode))}},{key:"setHtmlTemplateCollectionContent",value:function(e){var t=!1;!this.content||this.content instanceof f||(t=!0,this.clearContent()),this.content=this.content||new f(e,this),this.content.applyValues(e),t&&p(e,this.commentNode)}},{key:"setHtmlTemplateContent",value:function(e){var t=!1,n=!!(this.content&&this.content instanceof h)&&this.content.template.key===e.key;if(null===this.content||n||(this.clearContent(),t=!0),!this.content){var o=e.constructTemplate();this.content=new h(o,this)}this.content.applyValues(e),t&&p(e,this.commentNode)}},{key:"clearContent",value:function(){null!==this.content&&(this.content instanceof n?this.content.destroy():this.content.remove(),this.content=null)}},{key:"firstChildNode",value:function(){if(this.content instanceof h)return this.content.instance[0];if(this.content instanceof f){var t=this.content.template.keys[0];return e.from(this.content.instance[t]).firstChildNode()}return this.content}},{key:"validateInstancePosition",value:function(){this.content instanceof h?this.content.instance.reduceRight(function(e,t){return e.previousSibling!==t&&e.parentNode.insertBefore(t,e),t},this.commentNode):this.content instanceof f||this.commentNode.previousSibling!==this.content&&this.commentNode.parentNode.insertBefore(this.content,this.commentNode)}}],[{key:"from",value:function(t){return t instanceof Comment?(t.$data=t.$data||new e(t),t.$data):(t.$outlet||(t.$outlet=document.createComment("outlet"),t.appendChild(t.$outlet)),e.from(t.$outlet))}}]),e}(),f=function(e){function t(e,n){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.template=e,o.outlet=n,o.instance=null,o}return _inherits(t,n),_createClass(t,[{key:"applyValues",value:function(e){var t=this,n=e.context;if(null===this.instance){this.instance={};var o=this.outlet.commentNode;e.iterateRight(function(e,r,i){var a=d.from(document.createComment("outlet-child"));o.parentNode.insertBefore(a.commentNode,o),d.from(a.commentNode).setContent(i,n),o=a.firstChildNode(),t.instance[r]=a.commentNode})}else{if(e.iterateRight(),0===e.items.length){if(this.outlet.commentNode.parentNode.$htmlCollectionInstanceChild&&1===this.outlet.commentNode.parentNode.$htmlCollectionInstanceChild.length){var r=this.outlet.commentNode.parentNode;r.innerText="",r.appendChild(this.outlet.commentNode),this.instance={}}}else{this.template.keys.forEach(function(n){if(e.keys.indexOf(n)<0){var o=t.instance[n];d.from(o).clearContent(),o.remove(),delete t.instance[n]}})}var i=this.outlet.commentNode;e.iterateRight(function(e,o,r){var a=t.instance[o];if(a){var l=d.from(a);l.setContent(r),i.previousSibling!==a&&(i.parentNode.insertBefore(a,i),l.validateInstancePosition()),i=l.firstChildNode()}else{var s=d.from(document.createComment("outlet-child"));i.parentNode.insertBefore(s.commentNode,i),d.from(s.commentNode).setContent(r,n),i=s.firstChildNode(),t.instance[o]=s.commentNode,t.template.context.addSyncCallback(function(){return p(r,s.commentNode)})}}),this.template=e}}},{key:"destroy",value:function(){var e=this;this.template.keys.forEach(function(t){var n=e.instance[t];d.from(n).clearContent(),n.remove(),delete e.instance[t]}),this.outlet=null,this.instance=null,this.template=null}}]),t}(),h=function(t){function o(e,t){_classCallCheck(this,o);var n=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this));return n.template=e,n.outlet=t,n.instance=[],n.nodeValueIndexArray=null,n}return _inherits(o,n),_createClass(o,[{key:"applyValues",value:function(t){if(null===this.instance||0===this.instance.length){s.applyValues(t,this.template.nodeValueIndexArray);var n=function t(n){if(e)return n.cloneNode(!0);for(var o=3===n.nodeType?document.createTextNode(n.nodeValue):n.cloneNode(!1),r=n.firstChild;r;)o.appendChild(t(r)),r=r.nextSibling;return o}(this.template.documentFragment),o=this.outlet.commentNode,r=n.childNodes[0],i=null;do{this.instance.push(r),i=r.nextSibling,o.parentNode.insertBefore(r,o),r=i}while(r)}else this.nodeValueIndexArray&&s.applyValues(t,this.nodeValueIndexArray)}},{key:"destroy",value:function(){this.instance.forEach(function(e){return e.remove()}),this.nodeValueIndexArray=null,this.outlet=null,this.template=null}}]),o}(),m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=e.nodeValue,r=e.valueIndexes,c=function(e,t){return e.reduce(function(e,t){return"number"==typeof t?e.childNodes[t]:e.attributes[t.name]},t)}(function e(t){if(t.nodeType===Node.ATTRIBUTE_NODE)return e(t.ownerElement).concat([{name:t.nodeName}]);for(var n=0,o=t;null!==(o=o.previousSibling);)n++;var r=[];return r.push(n),t.parentNode&&t.parentNode.parentNode?e(t.parentNode).concat(r):r}(e.node),t),u=Array.isArray(r)?r.map(function(e){return n[e]}):n[r];return c.parentNode&&"STYLE"===c.parentNode.nodeName.toUpperCase()?{node:c,valueIndexes:r,nodeValue:o,values:u}:c.nodeType===Node.ATTRIBUTE_NODE?(function(e,t,n,o){var r=l.from(e),a=e.nodeName;if(0===a.indexOf("on")){var s=t[0];r.attributes[a]=n[s],e.ownerElement.setAttribute(a,"return false;"),e.ownerElement[a]=n[s]}else r.attributes[a]=i(o,t,n)}(c,r,n,o),{node:c,valueIndexes:r,nodeValue:o,values:u}):(function(e,t,n){var o=d.from(e),r=t[n];r instanceof s?(o.constructHtmlTemplateContent(r),p(r,o.commentNode)):r instanceof a?(o.constructHtmlTemplateCollectionContent(r),p(r,o.commentNode)):o.constructTextContent()}(c,n,r),{node:c,valueIndexes:r,values:u})},p=function e(t,n){var o=d.from(n);if(o.content&&o.content instanceof h){var r=o.content,i=r.template,a=t.values,l={childNodes:r.instance};if(null===i.nodeValueIndexArray){var c=i.context.cache(i.key);l={childNodes:o.content.instance},r.nodeValueIndexArray=c.nodeValueIndexArray.map(function(e){return m(e,l,a)})}else r.nodeValueIndexArray=i.nodeValueIndexArray.map(function(e){return m(e,l,a)})}if(o.content&&o.content instanceof f){var u=o.content,p=u.template.templates,y=u.template.keys;o.commentNode.parentNode.$htmlCollectionInstanceChild=o.commentNode.parentNode.$htmlCollectionInstanceChild||[],o.commentNode.parentNode.$htmlCollectionInstanceChild.push(o.commentNode),y.forEach(function(t){var n=p[t],o=u.instance[t],r=d.from(o);null===r.content?n instanceof s&&(r.constructHtmlTemplateContent(n.context.cache(n.key)),e(n,o)):r.content instanceof h&&e(n,o)})}},y=function(e,t){t.$synced||(p(e,t),t.$synced=!0)},v=function(e,t){e.context.root=e.context.root||t,d.from(t).setContent(e)},C=function(e){"requestIdleCallback"in window?requestIdleCallback(e):e()},x=function e(t){_classCallCheck(this,e),this.factory=t};return{Context:c,render:function(e,t){if("Promise"in window)return new Promise(function(n){C(function(){v.apply(null,[e,t]),n()})}).then(function(){return new Promise(function(n){C(function(){y.apply(null,[e,t]),n()})})}).then(function(){return new Promise(function(t){C(function(){e.context.clearSyncCallbacks(),t()})})});var n={then:function(){}};return setTimeout(function(){v(e,t),y(e,t),e.context.clearSyncCallbacks(),n.then.apply(null,[])},0),n},plug:function(e){return new x(e)},uuidv4:t}});
"use strict";function _taggedTemplateLiteral(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _slicedToArray=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],o=!0,i=!1,r=void 0;try{for(var a,l=e[Symbol.iterator]();!(o=(a=l.next()).done)&&(n.push(a.value),!t||n.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{!o&&l.return&&l.return()}finally{if(i)throw r}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),_typeof="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},_templateObject=_taggedTemplateLiteral(['<span id="','" style="display: none" data-async-outlet>outlet</span>'],['<span id="','" style="display: none" data-async-outlet>outlet</span>']);!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=t():(e.yalla=t(),e.Context=e.Context||e.yalla.Context,e.render=e.render||e.yalla.render,e.plug=e.plug||e.yalla.plug,e.uuidv4=e.uuidv4||e.yalla.uuidv4)}("undefined"!=typeof self?self:eval("this"),function(){var e="chrome"in window&&"webstore"in window.chrome,t=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},n=function(){function e(){_classCallCheck(this,e)}return _createClass(e,[{key:"destroy",value:function(){throw new Error("Please implement template.destroy ")}}]),e}(),o={INPUT:["VALUE"]},i={col:"colgroup",td:"tr",area:"map",tbody:"table",tfoot:"table",th:"tr",thead:"table",tr:"tbody",caption:"table",colgroup:"table",li:"ul",g:"svg",circle:"svg",rect:"svg",polygon:"svg",eclipse:"svg",text:"svg"},r=function(e,t,n){var o=e,i=t.map(function(e){return n[e]});return t.forEach(function(e,t){o=o.replace("\x3c!--"+e+"--\x3e",i[t])}),o},a=function(e){function t(e,n,o,i){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.items=e,r.keyFn="string"==typeof n?function(e){return e[n]}:n,r.templateFn=o,r.context=i,r.keys=[],r.templates={},r.initialzed=!1,r}return _inherits(t,n),_createClass(t,[{key:"iterateRight",value:function(e){if(this.initialzed)for(var t=this.keys.length-1;t>=0;){var n=this.items[t],o=this.keys[t],i=this.templates[o];e&&e.apply(null,[n,o,i,t]),t--}else{for(var r=this.items.length-1;r>=0;){var a=this.items[r],l=this.keyFn.apply(this,[a,r]),s=this.templateFn.apply(this,[a,r]);e&&e.apply(null,[a,l,s,r]),r--,this.keys.push(l),this.templates[l]=s}this.initialzed=!0,this.keys.reverse()}}}]),t}(),l=function(){function e(t){_classCallCheck(this,e),this.node=t,this.attributes={}}return _createClass(e,null,[{key:"from",value:function(t){var n=t;return t.nodeType===Node.ATTRIBUTE_NODE&&(n=t.ownerElement),n.$data=n.$data||new e(n),n.$data}}]),e}(),s=function(e){function t(e,n,o){_classCallCheck(this,t);var i=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.strings=e,i.values=n,i.context=o,i.key=i.strings.join("").trim(),i.nodeValueIndexArray=null,i.documentFragment=null,i}return _inherits(t,n),_createClass(t,[{key:"buildTemplate",value:function(e){this.documentFragment=t.getProperTemplateTag(e),this.nodeValueIndexArray=this.buildNodeValueIndex(this.documentFragment,this.documentFragment.nodeName),t.applyValues(this,this.nodeValueIndexArray)}},{key:"buildNodeValueIndex",value:function(e,n){var o=[],i=e.childNodes[0];if(void 0===i)return o;do{if(i.nodeType===Node.ELEMENT_NODE){for(var r=i.attributes,a=r.length,l=0;l<a;l++){var s=r[l].nodeValue,c=t.lookNodeValueArray(s).map(function(e){return e.match(/[\w\.]+/)[0]}).map(function(e){return parseInt(e)});c&&c.length>0&&o.push({node:r[l],valueIndexes:c,nodeValue:s})}o=o.concat(this.buildNodeValueIndex(i,i.nodeName))}if(i.nodeType===Node.TEXT_NODE&&"STYLE"===n.toUpperCase()){var u=i.nodeValue,d=t.lookNodeValueArray(u).map(function(e){return e.match(/[\w\.]+/)[0]}).map(function(e){return parseInt(e)});d&&d.length>0&&o.push({node:i,valueIndexes:d,nodeValue:u})}if(i.nodeType===Node.COMMENT_NODE){var f=i.nodeValue;i.nodeValue="outlet",o.push({node:i,valueIndexes:parseInt(f)})}i=i.nextSibling}while(i);return o}},{key:"constructTemplate",value:function(){if(!this.context.hasCache(this.key)){var e=this.buildStringSequence();return this.buildTemplate(e),this.context.cache(this.key,this)}for(var t=this.context.cache(this.key),n=t.documentFragment.querySelectorAll("span[data-async-outlet]"),o=n.length;o--;){var i=n[o];if(i.nextSibling){d.from(i.nextSibling).clearContent()}}return t}},{key:"buildStringSequence",value:function(){return this.strings.reduce(function(e,t,n){return 0===n?t:e+"\x3c!--"+(n-1)+"--\x3e"+t},"").trim()}}],[{key:"lookNodeValueArray",value:function(e){for(var t=[],n=e.indexOf("\x3c!--"),o=e.indexOf("--\x3e",n);o<e.length&&o>=0&&n>=0;)t.push(e.substring(n+4,o)),n=e.indexOf("\x3c!--",o+3),o=e.indexOf("--\x3e",n);return t}},{key:"getProperTemplateTag",value:function(e){var t=e.substring(1,e.indexOf(">"));t=(t.indexOf(" ")>0?t.substring(0,t.indexOf(" ")):t).toLowerCase();var n=i[t];n=n||"div";var o=document.createElement(n);return o.innerHTML=e,o}},{key:"applyValues",value:function(e,t){var n=e.values,i=e.context;t&&t.forEach(function(e){var t=e.node,a=e.valueIndexes,s=e.values,c=Array.isArray(a)?a.map(function(e){return n[e]}):n[a],u=t.nodeName,f=t.nodeType===Node.ATTRIBUTE_NODE&&0===u.indexOf("on");if(!(function(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(var n=!0,o=0;o<t.length;o++)if(!(n=n&&e[o]===t[o]))return!1;return!0}return!1}(c,s)||f&&c[0].name)){if(t.nodeType===Node.ATTRIBUTE_NODE){var h=l.from(t),m=e.nodeValue;if(f){var p=a[0];t.ownerElement[u]=n[p],h.attributes[u]=n[p]}else{var y=r(m,a,n);if(!function(e){return["checked","compact","declare","defer","disabled","ismap","noresize","noshade","nowrap","selected"].indexOf(e.nodeName)>=0}(t)?(t.ownerElement.setAttribute(u,y),function(e,t){return e=e.toUpperCase(),t=t.toUpperCase(),!!o[t]&&o[t].indexOf(e)>=0}(u,t.ownerElement.nodeName)&&(t.ownerElement[u]=y)):(t.ownerElement[u]="true"===y.trim(),t.ownerElement.setAttribute(u,"")),u.indexOf(".bind")>=0){var v=u.substring(0,u.indexOf(".bind"));t.ownerElement.setAttribute(v,y)}h.attributes[u]=y}}if(t.nodeType===Node.TEXT_NODE&&(t.nodeValue=r(e.nodeValue,a,n)),t.nodeType===Node.COMMENT_NODE){var C=n[a];d.from(t).setContent(C,i)}e.values=c}})}}]),t}(),c=function(){function e(){var t=this;_classCallCheck(this,e),this.cacheInstance={},this.syncCallbackStack=[],this.html=function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return new s(e,o,t)},this.htmlCollection=function(e,n,o){return new a(e,n,o,t)},this.listeners={}}return _createClass(e,[{key:"hasCache",value:function(e){return e in this.cacheInstance}},{key:"cache",value:function(e,t){return this.hasCache(e)||(this.cacheInstance[e]=t),this.cacheInstance[e]}},{key:"addSyncCallback",value:function(e){this.syncCallbackStack.push(e)}},{key:"addEventListener",value:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e+":"+t();this.listeners[e]=this.listeners[e]||[];return this.listeners[e].push({token:i,callback:n,calledOnce:o}),i}},{key:"removeEventListener",value:function(e){var t=e.split(":"),n=_slicedToArray(t,2),o=n[0],i=n[1],r=this.listeners[o];r=r.filter(function(e){return e.token!=i}),this.listeners[o]=r}},{key:"dispatchEvent",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];if(e in this.listeners){var i=this.listeners[e],r=[];i.forEach(function(e){if(e.callback.apply(null,n),e.calledOnce){var t=e.token.split(":"),o=_slicedToArray(t,2),i=(o[0],o[1]);r.push(i)}}),r.length>0&&(i=i.filter(function(e){return r.indexOf(e.token)<0})),this.listeners[e]=i}}},{key:"clearSyncCallbacks",value:function(){this.syncCallbackStack.forEach(function(e){return e.apply()}),this.syncCallbackStack=[],this.dispatchEvent("syncingdone")}}]),e}(),u=function(e,t){var n=document.getElementById(e);if(n||(n=t.root.getElementsByTagName("*")[e]),n){var o=n.nextSibling;return n.remove(),d.from(o)}return!1},d=function(){function e(t){_classCallCheck(this,e),this.commentNode=t,this.content=null}return _createClass(e,[{key:"constructTextContent",value:function(){this.content=this.commentNode.previousSibling}},{key:"constructHtmlTemplateCollectionContent",value:function(e){var t=this;this.content=new f(e,this),this.content.instance={};var n=this.commentNode;e.iterateRight(function(e,o){do{n=n.previousSibling}while(n.nodeType!==Node.COMMENT_NODE&&"outlet-child"!==n.nodeValue);t.content.instance[o]=n})}},{key:"constructHtmlTemplateContent",value:function(e){if(void 0!==e){var t=e.context.cache(e.key).documentFragment.childNodes.length;this.content=new h(e,this);for(var n=this.commentNode;t--;)n=n.previousSibling,this.content.instance.push(n);this.content.instance.reverse()}}},{key:"makeTemporaryOutlet",value:function(e){var n=t();return this.setHtmlTemplateContent(e.html(_templateObject,n)),n}},{key:"setContent",value:function(e,t){var n=this;if(function(e){return"object"===(void 0===e?"undefined":_typeof(e))&&"constructor"in e&&"Promise"===e.constructor.name}(e))if(null===this.content){var o=this.makeTemporaryOutlet(t);e.then(function(e){var n=u(o,t);n&&(n.setContent(e),p(e,n.commentNode))})}else e.then(function(e){n.setContent(e)});else if(e instanceof x)if(null===this.content){var i=this.makeTemporaryOutlet(t);t.addEventListener("syncingdone",function(){var n=u(i,t);n&&e.factory.apply(null,[n])},!0)}else e.factory.apply(null,[this]);else e instanceof s?this.setHtmlTemplateContent(e):e instanceof a?this.setHtmlTemplateCollectionContent(e):this.setTextContent(e)}},{key:"setTextContent",value:function(e){this.content instanceof Text?this.content.nodeValue=e:(this.clearContent(),this.content=document.createTextNode(e),this.commentNode.parentNode.insertBefore(this.content,this.commentNode))}},{key:"setHtmlTemplateCollectionContent",value:function(e){var t=!1;!this.content||this.content instanceof f||(t=!0,this.clearContent()),this.content=this.content||new f(e,this),this.content.applyValues(e),t&&p(e,this.commentNode)}},{key:"setHtmlTemplateContent",value:function(e){var t=!1,n=!!(this.content&&this.content instanceof h)&&this.content.template.key===e.key;if(null===this.content||n||(this.clearContent(),t=!0),!this.content){var o=e.constructTemplate();this.content=new h(o,this)}this.content.applyValues(e),t&&p(e,this.commentNode)}},{key:"clearContent",value:function(){null!==this.content&&(this.content instanceof n?this.content.destroy():this.content.remove(),this.content=null)}},{key:"firstChildNode",value:function(){if(this.content instanceof h)return this.content.instance[0];if(this.content instanceof f){var t=this.content.template.keys[0];return e.from(this.content.instance[t]).firstChildNode()}return this.content}},{key:"validateInstancePosition",value:function(){this.content instanceof h?this.content.instance.reduceRight(function(e,t){return e.previousSibling!==t&&e.parentNode.insertBefore(t,e),t},this.commentNode):this.content instanceof f||this.commentNode.previousSibling!==this.content&&this.commentNode.parentNode.insertBefore(this.content,this.commentNode)}}],[{key:"from",value:function(t){return t instanceof Comment?(t.$data=t.$data||new e(t),t.$data):(t.$outlet||(t.$outlet=document.createComment("outlet"),t.appendChild(t.$outlet)),e.from(t.$outlet))}}]),e}(),f=function(e){function t(e,n){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.template=e,o.outlet=n,o.instance=null,o}return _inherits(t,n),_createClass(t,[{key:"applyValues",value:function(e){var t=this,n=e.context;if(null===this.instance){this.instance={};var o=this.outlet.commentNode;e.iterateRight(function(e,i,r){var a=d.from(document.createComment("outlet-child"));o.parentNode.insertBefore(a.commentNode,o),d.from(a.commentNode).setContent(r,n),o=a.firstChildNode(),t.instance[i]=a.commentNode})}else{if(e.iterateRight(),0===e.items.length){if(this.outlet.commentNode.parentNode.$htmlCollectionInstanceChild&&1===this.outlet.commentNode.parentNode.$htmlCollectionInstanceChild.length){var i=this.outlet.commentNode.parentNode;i.innerText="",i.appendChild(this.outlet.commentNode),this.instance={}}}else{this.template.keys.forEach(function(n){if(e.keys.indexOf(n)<0){var o=t.instance[n];d.from(o).clearContent(),o.remove(),delete t.instance[n]}})}var r=this.outlet.commentNode;e.iterateRight(function(e,o,i){var a=t.instance[o];if(a){var l=d.from(a);l.setContent(i),r.previousSibling!==a&&(r.parentNode.insertBefore(a,r),l.validateInstancePosition()),r=l.firstChildNode()}else{var s=d.from(document.createComment("outlet-child"));r.parentNode.insertBefore(s.commentNode,r),d.from(s.commentNode).setContent(i,n),r=s.firstChildNode(),t.instance[o]=s.commentNode,t.template.context.addSyncCallback(function(){return p(i,s.commentNode)})}}),this.template=e}}},{key:"destroy",value:function(){var e=this;this.template.keys.forEach(function(t){var n=e.instance[t];d.from(n).clearContent(),n.remove(),delete e.instance[t]}),this.outlet=null,this.instance=null,this.template=null}}]),t}(),h=function(t){function o(e,t){_classCallCheck(this,o);var n=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).call(this));return n.template=e,n.outlet=t,n.instance=[],n.nodeValueIndexArray=null,n}return _inherits(o,n),_createClass(o,[{key:"applyValues",value:function(t){if(null===this.instance||0===this.instance.length){s.applyValues(t,this.template.nodeValueIndexArray);var n=function t(n){if(e)return n.cloneNode(!0);for(var o=3===n.nodeType?document.createTextNode(n.nodeValue):n.cloneNode(!1),i=n.firstChild;i;)o.appendChild(t(i)),i=i.nextSibling;return o}(this.template.documentFragment),o=this.outlet.commentNode,i=n.childNodes[0],r=null;do{this.instance.push(i),r=i.nextSibling,o.parentNode.insertBefore(i,o),i=r}while(i)}else this.nodeValueIndexArray&&s.applyValues(t,this.nodeValueIndexArray)}},{key:"destroy",value:function(){this.instance.forEach(function(e){return e.remove()}),this.nodeValueIndexArray=null,this.outlet=null,this.template=null}}]),o}(),m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=e.nodeValue,i=e.valueIndexes,c=function(e,t){return e.reduce(function(e,t){return"number"==typeof t?e.childNodes[t]:e.attributes[t.name]},t)}(function e(t){if(t.nodeType===Node.ATTRIBUTE_NODE)return e(t.ownerElement).concat([{name:t.nodeName}]);for(var n=0,o=t;null!==(o=o.previousSibling);)n++;var i=[];return i.push(n),t.parentNode&&t.parentNode.parentNode?e(t.parentNode).concat(i):i}(e.node),t),u=Array.isArray(i)?i.map(function(e){return n[e]}):n[i];return c.parentNode&&"STYLE"===c.parentNode.nodeName.toUpperCase()?{node:c,valueIndexes:i,nodeValue:o,values:u}:c.nodeType===Node.ATTRIBUTE_NODE?(function(e,t,n,o){var i=l.from(e),a=e.nodeName;if(0===a.indexOf("on")){var s=t[0];i.attributes[a]=n[s],e.ownerElement.setAttribute(a,"return false;"),e.ownerElement[a]=n[s]}else i.attributes[a]=r(o,t,n)}(c,i,n,o),{node:c,valueIndexes:i,nodeValue:o,values:u}):(function(e,t,n){var o=d.from(e),i=t[n];i instanceof s?(o.constructHtmlTemplateContent(i),p(i,o.commentNode)):i instanceof a?(o.constructHtmlTemplateCollectionContent(i),p(i,o.commentNode)):o.constructTextContent()}(c,n,i),{node:c,valueIndexes:i,values:u})},p=function e(t,n){var o=d.from(n);if(o.content&&o.content instanceof h){var i=o.content,r=i.template,a=t.values,l={childNodes:i.instance};if(null===r.nodeValueIndexArray){var c=r.context.cache(r.key);l={childNodes:o.content.instance},i.nodeValueIndexArray=c.nodeValueIndexArray.map(function(e){return m(e,l,a)})}else i.nodeValueIndexArray=r.nodeValueIndexArray.map(function(e){return m(e,l,a)})}if(o.content&&o.content instanceof f){var u=o.content,p=u.template.templates,y=u.template.keys;o.commentNode.parentNode.$htmlCollectionInstanceChild=o.commentNode.parentNode.$htmlCollectionInstanceChild||[],o.commentNode.parentNode.$htmlCollectionInstanceChild.push(o.commentNode),y.forEach(function(t){var n=p[t],o=u.instance[t],i=d.from(o);null===i.content?n instanceof s&&(i.constructHtmlTemplateContent(n.context.cache(n.key)),e(n,o)):i.content instanceof h&&e(n,o)})}},y=function(e,t){t.$synced||(p(e,t),t.$synced=!0)},v=function(e,t){e.context.root=e.context.root||t,d.from(t).setContent(e)},C=function(e){"requestIdleCallback"in window?requestIdleCallback(e):e()},x=function e(t){_classCallCheck(this,e),this.factory=t};return{Context:c,render:function(e,t){if("Promise"in window)return new Promise(function(n){!function(e){"requestAnimationFrame"in window?requestAnimationFrame(e):e()}(function(){v.apply(null,[e,t]),n()})}).then(function(){return new Promise(function(n){C(function(){y.apply(null,[e,t]),n()})})}).then(function(){return new Promise(function(t){C(function(){e.context.clearSyncCallbacks(),t()})})});var n={then:function(){}};return setTimeout(function(){v(e,t),y(e,t),e.context.clearSyncCallbacks(),n.then.apply(null,[])},0),n},plug:function(e){return new x(e)},uuidv4:t}});
{
"name": "yallajs",
"version": "2.0.0-beta.35",
"version": "2.0.0-beta.36",
"description": "Web Application with zero boiler plate",

@@ -5,0 +5,0 @@ "scripts": {

@@ -428,3 +428,3 @@ (function (root, factory) {

if(callbackItem.calledOnce){
let [event,tokenId] = callbackItem.token.split(':');
let [event,tokenId] = callbackItem.token.split(":");
markForRemoval.push(tokenId);

@@ -458,3 +458,3 @@ }

}
throw new Error(`Unable to find outlet ${id}`);
return false;
};

@@ -524,4 +524,6 @@

let outlet = getTemporaryOutlet(id, context);
outlet.setContent(result);
syncNode(result, outlet.commentNode);
if(outlet){
outlet.setContent(result);
syncNode(result, outlet.commentNode);
}
});

@@ -538,3 +540,5 @@ } else {

let outlet = getTemporaryOutlet(id, context);
template.factory.apply(null, [outlet]);
if(outlet){
template.factory.apply(null, [outlet]);
}
},true);

@@ -852,3 +856,10 @@ } else {

}
}
};
const executeWithRequestAnimationFrame = (callback) => {
if ('requestAnimationFrame' in window) {
requestAnimationFrame(callback);
} else {
callback();
}
};

@@ -858,3 +869,3 @@ const render = (templateValue, node) => {

return new Promise(resolve => {
executeWithIdleCallback(()=>{
executeWithRequestAnimationFrame(()=>{
setContent.apply(null,[templateValue,node]);

@@ -861,0 +872,0 @@ resolve();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc