objs-core 1.0.10 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Objs
2
- > Fast and simple library to increase developing speed by samples and state control, auto-tests, cache and other. You can develop new features with Objs without rewriting anything. Examples and full documentation are here: [Full Documentation](https://fous.name/objs) (sandbox and free samples are coming soon)
2
+ > Fast and simple library to speed up developing by separating samples and states logic, auto-tests, cache and other. You can develop new features with Objs without rewriting anything. Also in React Apps. Examples and full documentation are here: [Full Documentation](https://fous.name/objs) (sandbox and free samples are coming soon)
3
+
4
+
5
+ Update v.1.1.1: Fixed o().forEach() method.
3
6
 
4
7
 
5
8
 
@@ -7,7 +10,7 @@
7
10
  ## Get started
8
11
  Just include script or load in project by NPM
9
12
  ```
10
- <script src="objs.1.0.min.js" type="text/javascript"></script>
13
+ <script src="objs.1.1.min.js" type="text/javascript"></script>
11
14
  ```
12
15
  ```
13
16
  npm i objs-core
@@ -255,7 +258,7 @@ Here are methods, **o()** means that they are available after getting elements f
255
258
  `o().textContent(content)` – sets textContent for all elements.
256
259
 
257
260
  #### System
258
- `o().forEach(function)` – runs **function** with ab object as the first parameter: {o, self, i} where is o-function, self Objs object and i-index of current element.
261
+ `o().forEach(function)` – runs **function** with an object as the first parameter: {o, self, i, el} where is o-function, self Objs object, i-index of current element and el - DOM element.
259
262
 
260
263
  #### Events
261
264
  `o().on(events, function, [options])` – adds **events** listeners separated by ', ' to elements.
@@ -275,6 +278,8 @@ Here are methods, **o()** means that they are available after getting elements f
275
278
 
276
279
  `o().appendAfter(q)` – append elements after element **q** or got by **q** query.
277
280
 
281
+ `o().prepareFor(React.createElement, [React.Component])` – clones and returns React element or JSX Component if React.Component is given. Allows to use Objs in React Apps. Objs states should be inited on rendered elements.
282
+
278
283
 
279
284
 
280
285
 
@@ -2,7 +2,7 @@
2
2
  * @function Objs
3
3
  * DOM Modify and state control
4
4
  *
5
- * @version 1.0
5
+ * @version 1.1
6
6
  * @author Roman Torshin
7
7
  * @copyright
8
8
  * Apache-2.0 license *
@@ -19,9 +19,10 @@ const o = (query) => {
19
19
  THREE = 3,
20
20
  objectType = 'object',
21
21
  functionType = 'function',
22
+ reactProp = 'dangerouslySetInnerHTML',
22
23
  u = undefined,
23
- D = document;
24
- let start = -1,
24
+ D = document,
25
+ start = -1,
25
26
  finish = 0,
26
27
  select = 0,
27
28
  initedStates = [],
@@ -31,9 +32,6 @@ const o = (query) => {
31
32
 
32
33
 
33
34
 
34
-
35
-
36
-
37
35
  // shorten typeof
38
36
  const type = obj => typeof obj;
39
37
  // cycle from object
@@ -84,8 +82,6 @@ const o = (query) => {
84
82
 
85
83
 
86
84
 
87
-
88
-
89
85
  /**
90
86
  * Transformation of DOM elements
91
87
  *
@@ -551,10 +547,42 @@ const o = (query) => {
551
547
 
552
548
  result.forEach = returner((f) => {
553
549
  iterator(() => {
554
- f({self: o(result.els[i]).select(), i});
550
+ f({self: result, i, o, el: result.els[i]});
555
551
  });
556
552
  });
557
553
 
554
+ /**
555
+ * Transform to React Element or Component (if defined)
556
+ *
557
+ * @param {object} React or React.createElement to get Element
558
+ * @param {object} React.Component to get Component
559
+ * @returns {object}
560
+ */
561
+ result.prepareFor = returner((createElement, ReactComp) => {
562
+ if (createElement.createElement) {
563
+ createElement = createElement.createElement;
564
+ }
565
+ const getElement = () => {
566
+ if (result.length === ONE) {
567
+ return createElement(result.el.tagName.toLowerCase(), {
568
+ ...result.attrs()[ZERO],
569
+ [reactProp]: {__html: result.innerHTML()},
570
+ });
571
+ } else {
572
+ return createElement('div', {[reactProp]: {__html: result.html()}});
573
+ }
574
+ };
575
+ if (!ReactComp) {
576
+ return getElement();
577
+ } else {
578
+ return class extends ReactComp {
579
+ render() {
580
+ return getElement();
581
+ }
582
+ };
583
+ }
584
+ });
585
+
558
586
 
559
587
 
560
588
 
Binary file
@@ -0,0 +1,2 @@
1
+ // Objs v.1.1, Roman Torshin, Apache 2.0 licence
2
+ const o=e=>{let t={els:[],ie:{}},n=0,s=1,i=2,l=3,r="object",a="function",c="dangerouslySetInnerHTML",d,f=document,h=-1,g=0,p=0,u=[],y=0,m=0,S=e=>typeof e,L=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},E=o.onError||(()=>{}),C=e=>(...r)=>{try{let a=e(r[n],r[s],r[i],r[l]);return a!==d?a:t}catch(c){E(c)}},$=e=>{for(y=g;y<=h;y++)e()},F=e=>(S(e)!==r&&(e=o.first(e).el),e),Z=(e=!0,i=t.els)=>{let l=i.length;t.length=l,h=l-s,g=n,t.el=l?i[n]:d,t.last=l?i[h]:d,e&&(L(u,(e,n)=>{delete t[n[e]]}),u=[],t.ie={})},v=(e="")=>Array.from(f.querySelectorAll(e));t.reset=o;let N=(e,t,s)=>{L(t,i=>{let l=t[i];S(l)===a&&(l=l(s)),"append"===i&&S(l)===r&&(l.els&&(l=[l]),l[n]&&l[n].els&&(valueBuff=[],L(l,e=>{valueBuff.push(...l[e].els)}),l=valueBuff)),l!==d&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=l:"dataset"===i&&S(l)===r?L(l,t=>{e.dataset[t]=l[t]}):"toggleClass"===i?e.classList.toggle(l):"addClass"===i?S(l)===r?e.classList.add(...l):e.classList.add(l):"removeClass"===i?e.classList.remove(l):"style"===i&&S(l)===r?L(l,t=>{e.style[t]=l[t]}):"append"===i&&S(l)===r?L(l.length?l:[l],t=>{e.appendChild(l[t])}):e.setAttribute(i,l)))}),e.dataset.oState=t.state};return t.init=C(e=>{let i=t.initID||o.inits.length||n;t.initID=i,Z(),o.inits[t.initID]=t,(S(e)!==r||e.render===d)&&(e={render:e}),L(e,l=>{u.push(l),t[l]=C((c=[{}])=>{let p=e[l]||{tag:"div"},u=t.els.slice(g,h+s);S(p)===r&&(p.state=l,p["data-o-init"]=i);let L=(e,t={})=>S(p)===r?f.createElement(p.tag||"div"):((y=f.createElement("div")).innerHTML=S(p)===a?p(t):p,y.children.length>s||!y.firstElementChild)?(y.dataset.oInit=e,y):(y.firstElementChild.dataset.oInit=e,y.firstElementChild);c.length||(c=[c]);let E=!u[n]&&"render"===l;c=c.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===d?n:e.i,E&&u.push(L(i,e)),e)),E&&(t.els=u,Z(!1)),u&&(m=u.length===c.length,u.map((e,t)=>{c[m?t:n].i=t+g;let s=S(p)===a?p(c[m?t:n]):p;S(s)===r&&N(e,s,c[m?t:n])}))})})}),t.initState=C((e,n)=>{t.init(e).render(n)}),t.sample=C((e="render")=>{let s=t.els[g].attributes,i=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let r of s)"data-"!==r.nodeName.substring(n,5)&&(l[r.nodeName]=r.value);return L(i,e=>{l.dataset[e]=i[e]}),{[e]:l}}),t.select=C(e=>{e===d&&(e=t.length-s),h=e,g=e,t.el=t.els[e],p=s}),t.all=C(()=>{h=t.length-s,g=n,t.el=t.els[n],p=n}),t.remove=C(e=>{e===d&&p&&(e=g),e!==d?t.els[e].parentNode.removeChild(t.els[e]):$(()=>{t.els[y].parentNode.removeChild(t.els[y])}),Z(!1)}),t.skip=C(e=>{e===d&&(e=g),t.els.splice(y,s),Z()}),t.add=C((e,s)=>{"string"===S(e)&&""!==e?t.els.push(...v(e)):S(e)===r?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===S(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==d&&t.dataset({oInit:t.initID})}),t.appendInside=C(e=>{$(()=>{F(e).appendChild(t.els[y])})}),t.appendBefore=C(e=>{$(()=>{F(e).parentNode.insertBefore(t.els[y],F(e))})}),t.appendAfter=C(e=>{$(()=>{F(e).after(...t.els)})}),t.find=C((e="")=>{let n=[];return $(()=>{n.push(...Array.from(t.els[y].querySelectorAll(":scope "+e)))}),o(n)}),t.first=C((e="")=>{let n=d,s=[];return $(()=>{(n=t.els[y].querySelector(e))&&s.push(n)}),o(s)}),t.attr=C((e,s)=>{if(e){if(s===d){let i=[];return $(()=>{i[y]=t.els[y].getAttribute(e)}),p?i[n]:i}""!==s?$(()=>{t.els[y].setAttribute(e,s)}):$(()=>{t.els[y].removeAttribute(e)})}}),t.attrs=C(()=>{let e=[];return $(()=>{let n={};[...t.els[y].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),p?e[n]:e}),t.dataset=C(e=>{if(typeof e===r)$(()=>{L(e,n=>{t.els[y].dataset[n]=e[n]})});else{let s=[];return $(()=>{s.push({...t.els[y].dataset})}),p?s[n]:s}}),t.style=C(e=>{t.attr("style",e)}),t.css=C((e={})=>{let n="";L(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=C(e=>{$(()=>{t.els[y].setAttribute("class",e)})}),t.addClass=C(e=>{$(()=>{t.els[y].classList.add(e)})}),t.removeClass=C(e=>{$(()=>{t.els[y].classList.remove(e)})}),t.toggleClass=C((e,n)=>{$(()=>{t.els[y].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return $(()=>{t.els[y].classList.contains(e)||(n=!1)}),n},t.innerHTML=C(e=>{if(e!==d)$(()=>{t.els[y].innerHTML=e});else{let n="";return $(()=>{n+=t.els[y].innerHTML}),n}}),t.innerText=C((e="")=>{$(()=>{t.els[y].innerText=e})}),t.textContent=C((e="")=>{$(()=>{t.els[y].textContent=e})}),t.html=C(e=>{if(e)t.innerHTML(e);else{let n="";return $(()=>{n+=t.els[y].outerHTML}),n}}),t.forEach=C(e=>{$(()=>{e({self:t,i:y,o,el:t.els[y]})})}),t.prepareFor=C((e,i)=>{e.createElement&&(e=e.createElement);let l=()=>t.length===s?e(t.el.tagName.toLowerCase(),{...t.attrs()[n],[c]:{__html:t.innerHTML()}}):e("div",{[c]:{__html:t.html()}});return i?class extends i{render(){return l()}}:l()}),t.on=C((e,n,s,i)=>{e.split(", ").forEach(e=>{$(()=>{t.els[y].addEventListener(e,n,s,i)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,s,i])})}),t.off=C((e,s,i)=>{e.split(", ").forEach(e=>{$(()=>{t.els[y].removeEventListener(e,s,i)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==s))})}),t.onAll=C((e,l)=>{L(t.ie,(r,a)=>{e&&e!==r||a[r].forEach(e=>{$(()=>{l?t.els[y].removeEventListener(r,e[n]):t.els[y].addEventListener(r,e[n],e[s],e[i])})})})}),t.offAll=C(e=>{t.onAll(e,s)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let i=t.el.dataset.oInit;if(i!==d&&o.inits[i])return t.length===s?(m=t.els[n],Object.assign(t,o.inits[i]),t.els=[m]):t=o.inits[i],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=()=>{o.errors.length?o.errors.forEach(e=>console.log(e)):console.log("No errors")},o.onError=e=>{o.showErrors?console.log(e):o.errors.push(e)},o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let s in t.data)o.C(t.data,s)&&("object"==typeof t.data[s]?n.set(s,encodeURIComponent(JSON.stringify(t.data[s]))):n.set(s,t.data[s]));"get"===t.method.toLowerCase()?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return t.headers||(t.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=e=>{let t={},n=new URLSearchParams(window.location.search).entries();for(let s of n)t[s[o.Z]]=s[o.N];return e?t[e]:t},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let s=o.Z,i=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let r=o.incSet[o.Z];o.incSet[r]=t||o.Z,o.incReady[r]=[];let a=o.incReady[r];a[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){s++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){a[s]={name:d,loaded:o.N},i++;continue}if(a[s]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let h=localStorage,g=h.getItem("inc-"+d),p=h.getItem("inc-"+d+"Expires");g&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+r+"-"+s,innerHTML:g,"data-o-inc":r}).appendInside("head"),a[s].loaded=o.N,o.incFns[d]=o.N,i++):(c[d]=s,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{h.setItem("inc-"+d,e),h.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+r+"-"+c[d],innerHTML:e,"data-o-inc":r}).appendInside("head"),o.incCheck(r,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+r+"-"+s,"data-o-inc":r,async:o.incAsync,onload:"o.incCheck("+r+","+s+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return a[o.Z]+=i,s!==o.Z&&(i===s?typeof t===l&&t(r):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(r))},o.incTimeout,r)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,s=0,i="├ OK: ",l="├ ✘ ",r="\n",a="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",i=o.tPre+o.tOk,l=o.tPre+o.tXx,a=(r=o.tDc)+r):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let h={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},g=t[f][o.N];if("function"==typeof g)try{g=g(h)}catch(p){g=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof g?o.F:g,!0===g?(d++,o.tShowOk&&(o.tLog[n]+=i+t[f][o.Z]+r)):g!==o.U?o.tLog[n]+=l+t[f][o.Z]+(g!==o.F?": <i>"+g+"</i>":"")+a:(s++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,h))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+s!==c?"red":"green")+';"><b>':o.tLog[n]+=s?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-s),s&&(o.tLog[n]+=", waiting: "+s),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",s||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let s=o.Z,i=s;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&s++,i++}o.tRes[e.n]=!s;let r=s?"FAILED "+s+"/"+i:"DONE "+i+"/"+i;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(s?"red":"green")+';">'+r+"</b>"+o.tDc:o.tLog[e.n]+="└ "+r,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
Binary file
@@ -0,0 +1,16 @@
1
+ // Objs v.1.1, Roman Torshin, Apache 2.0 licence
2
+ (function(globals) {
3
+ 'use strict';
4
+ function ownKeys(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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:t+""}function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function e(){};return{s:i,n:function t(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function e(t){throw t},f:i}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,l=!1;return{s:function t(){r=r.call(e)},n:function e(){var t=r.next();return s=t.done,t},e:function e(t){l=!0,a=t},f:function e(){try{s||null==r.return||r.return()}finally{if(l)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=({}).toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var o=e=>{var t,r={els:[],ie:{}},n=0,i=1,a=2,s=3,l="object",c="function",d="dangerouslySetInnerHTML",f=document,u=-1,p=0,y=0,g=[],h=0,v=0,m=e=>typeof e,S=(e,t)=>{for(var r in e)Object.hasOwnProperty.call(e,r)&&t(r,e)},b=o.onError||(()=>{}),L=e=>(...l)=>{try{var c=e(l[n],l[i],l[a],l[s]);return c!==t?c:r}catch(d){b(d)}},E=e=>{for(h=p;h<=u;h++)e()},C=e=>(m(e)!==l&&(e=o.first(e).el),e),F=(e=!0,a=r.els)=>{var s=a.length;r.length=s,u=s-i,p=n,r.el=s?a[n]:t,r.last=s?a[u]:t,e&&(S(g,(e,t)=>{delete r[t[e]]}),g=[],r.ie={})},I=(e="")=>Array.from(f.querySelectorAll(e));r.reset=o;var $=(e,r,i)=>{S(r,a=>{var s=r[a];m(s)===c&&(s=s(i)),"append"===a&&m(s)===l&&(s.els&&(s=[s]),s[n]&&s[n].els&&(valueBuff=[],S(s,e=>{valueBuff.push(...s[e].els)}),s=valueBuff)),s!==t&&(["tag","sample","state"].includes(a)||(["html","innerHTML"].includes(a)?e.innerHTML=s:"dataset"===a&&m(s)===l?S(s,t=>{e.dataset[t]=s[t]}):"toggleClass"===a?e.classList.toggle(s):"addClass"===a?m(s)===l?e.classList.add(...s):e.classList.add(s):"removeClass"===a?e.classList.remove(s):"style"===a&&m(s)===l?S(s,t=>{e.style[t]=s[t]}):"append"===a&&m(s)===l?S(s.length?s:[s],t=>{e.appendChild(s[t])}):e.setAttribute(a,s)))}),e.dataset.oState=r.state};return r.init=L(e=>{var a=r.initID||o.inits.length||n;r.initID=a,F(),o.inits[r.initID]=r,(m(e)!==l||e.render===t)&&(e={render:e}),S(e,s=>{g.push(s),r[s]=L((d=[{}])=>{var y=e[s]||{tag:"div"},g=r.els.slice(p,u+i);m(y)===l&&(y.state=s,y["data-o-init"]=a);var S=(e,t={})=>m(y)===l?f.createElement(y.tag||"div"):((h=f.createElement("div")).innerHTML=m(y)===c?y(t):y,h.children.length>i||!h.firstElementChild)?(h.dataset.oInit=e,h):(h.firstElementChild.dataset.oInit=e,h.firstElementChild);d.length||(d=[d]);var b=!g[n]&&"render"===s;d=d.map((e,n)=>(e.self=r,e.o=o,e.i=e.i===t?n:e.i,b&&g.push(S(a,e)),e)),b&&(r.els=g,F(!1)),g&&(v=g.length===d.length,g.map((e,t)=>{d[v?t:n].i=t+p;var r=m(y)===c?y(d[v?t:n]):y;m(r)===l&&$(e,r,d[v?t:n])}))})})}),r.initState=L((e,t)=>{r.init(e).render(t)}),r.sample=L((e="render")=>{var t,i=r.els[p].attributes,a=r.els[p].dataset,s={tag:r.els[p].tagName,html:r.els[p].innerHTML,dataset:{}},l=_createForOfIteratorHelper(i);try{for(l.s();!(t=l.n()).done;){var c=t.value;"data-"!==c.nodeName.substring(n,5)&&(s[c.nodeName]=c.value)}}catch(d){l.e(d)}finally{l.f()}return S(a,e=>{s.dataset[e]=a[e]}),{[e]:s}}),r.select=L(e=>{e===t&&(e=r.length-i),u=e,p=e,r.el=r.els[e],y=i}),r.all=L(()=>{u=r.length-i,p=n,r.el=r.els[n],y=n}),r.remove=L(e=>{e===t&&y&&(e=p),e!==t?r.els[e].parentNode.removeChild(r.els[e]):E(()=>{r.els[h].parentNode.removeChild(r.els[h])}),F(!1)}),r.skip=L(e=>{e===t&&(e=p),r.els.splice(h,i),F()}),r.add=L((e,i)=>{"string"===m(e)&&""!==e?r.els.push(...I(e)):m(e)===l?e.tagName?r.els.push(e):e.els?r.els.push(...e.els):e.length&&e[n].tagName&&r.els.push(...e):"number"===m(e)&&o.inits[e]&&(r=o.inits[e]),F(!1),r.initID!==t&&r.dataset({oInit:r.initID})}),r.appendInside=L(e=>{E(()=>{C(e).appendChild(r.els[h])})}),r.appendBefore=L(e=>{E(()=>{C(e).parentNode.insertBefore(r.els[h],C(e))})}),r.appendAfter=L(e=>{E(()=>{C(e).after(...r.els)})}),r.find=L((e="")=>{var t=[];return E(()=>{t.push(...Array.from(r.els[h].querySelectorAll(":scope "+e)))}),o(t)}),r.first=L((e="")=>{var n=t,i=[];return E(()=>{(n=r.els[h].querySelector(e))&&i.push(n)}),o(i)}),r.attr=L((e,i)=>{if(e){if(i===t){var a=[];return E(()=>{a[h]=r.els[h].getAttribute(e)}),y?a[n]:a}""!==i?E(()=>{r.els[h].setAttribute(e,i)}):E(()=>{r.els[h].removeAttribute(e)})}}),r.attrs=L(()=>{var e=[];return E(()=>{var t={};[...r.els[h].attributes].forEach(e=>{t[e.nodeName]=e.nodeValue}),e.push(t)}),y?e[n]:e}),r.dataset=L(e=>{if(typeof e===l)E(()=>{S(e,t=>{r.els[h].dataset[t]=e[t]})});else{var t=[];return E(()=>{t.push(_objectSpread({},r.els[h].dataset))}),y?t[n]:t}}),r.style=L(e=>{r.attr("style",e)}),r.css=L((e={})=>{var t="";S(e,r=>{t+=r+":"+e[r].replace('"',"'")+";"}),r.style(t)}),r.setClass=L(e=>{E(()=>{r.els[h].setAttribute("class",e)})}),r.addClass=L(e=>{E(()=>{r.els[h].classList.add(e)})}),r.removeClass=L(e=>{E(()=>{r.els[h].classList.remove(e)})}),r.toggleClass=L((e,t)=>{E(()=>{r.els[h].classList.toggle(e,t)})}),r.haveClass=e=>{var t=!0;return E(()=>{r.els[h].classList.contains(e)||(t=!1)}),t},r.innerHTML=L(e=>{if(e!==t)E(()=>{r.els[h].innerHTML=e});else{var n="";return E(()=>{n+=r.els[h].innerHTML}),n}}),r.innerText=L((e="")=>{E(()=>{r.els[h].innerText=e})}),r.textContent=L((e="")=>{E(()=>{r.els[h].textContent=e})}),r.html=L(e=>{if(e)r.innerHTML(e);else{var t="";return E(()=>{t+=r.els[h].outerHTML}),t}}),r.forEach=L(e=>{E(()=>{e({self:r,i:h,o,el:r.els[h]})})}),r.prepareFor=L((e,t)=>{e.createElement&&(e=e.createElement);var a=()=>r.length===i?e(r.el.tagName.toLowerCase(),_objectSpread(_objectSpread({},r.attrs()[n]),{},{[d]:{__html:r.innerHTML()}})):e("div",{[d]:{__html:r.html()}});return t?class extends t{render(){return a()}}:a()}),r.on=L((e,t,n,i)=>{e.split(", ").forEach(e=>{E(()=>{r.els[h].addEventListener(e,t,n,i)}),r.ie[e]||(r.ie[e]=[]),r.ie[e].push([t,n,i])})}),r.off=L((e,t,i)=>{e.split(", ").forEach(e=>{E(()=>{r.els[h].removeEventListener(e,t,i)}),r.ie[e]&&(r.ie[e]=r.ie[e].filter(e=>e[n]!==t))})}),r.onAll=L((e,t)=>{S(r.ie,(s,l)=>{e&&e!==s||l[s].forEach(e=>{E(()=>{t?r.els[h].removeEventListener(s,e[n]):r.els[h].addEventListener(s,e[n],e[i],e[a])})})})}),r.offAll=L(e=>{r.onAll(e,i)}),e&&r.add(e),r.take=e=>{if(r.add(e),r.el){var a=r.el.dataset.oInit;if(a!==t&&o.inits[a])return r.length===i?(v=r.els[n],Object.assign(r,o.inits[a]),r.els=[v]):r=o.inits[a],F(!1,r.els),r}},r};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=()=>{o.errors.length?o.errors.forEach(e=>console.log(e)):console.log("No errors")},o.onError=e=>{o.showErrors?console.log(e):o.errors.push(e)},o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{var r=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(var n in t.data)o.C(t.data,n)&&("object"==typeof t.data[n]?r.set(n,encodeURIComponent(JSON.stringify(t.data[n]))):r.set(n,t.data[n]));"get"===t.method.toLowerCase()?e+="?"+r.toString():t.body||(t.body=r),delete t.data}return t.headers||(t.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(e,t)},o.get=(e,t={})=>o.ajax(e,_objectSpread(_objectSpread({},t),{},{method:"GET"})),o.post=(e,t={})=>o.ajax(e,_objectSpread(_objectSpread({},t),{},{method:"POST"})),o.getParams=e=>{var t,r={},n=new URLSearchParams(window.location.search).entries(),i=_createForOfIteratorHelper(n);try{for(i.s();!(t=i.n()).done;){var a=t.value;r[a[o.Z]]=a[o.N]}}catch(s){i.e(s)}finally{i.f()}return e?r[e]:r},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,r=0)=>!r&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=r,o.incFns[o.incReady[e][t].name]=r,o.incReady[e][o.Z]+=r,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(var t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,r)=>{r&&o("#oInc-"+t+"-"+r).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,r)=>{var n=o.Z,i=o.Z,a="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;var s=o.incSet[o.Z];o.incSet[s]=t||o.Z,o.incReady[s]=[];var l=o.incReady[s];l[o.Z]=o.N;var c={},d=function t(r){if(o.C(e,r)){n++,o.incN++;var a=e[r].indexOf(".css")>-1?"style":"script";if(e[r]=(o.incSource?o.incSource+"/":"")+e[r],isNaN(r)&&o.C(o.incFns,r)&&o.incFns[r]&&!o.incForce)return l[n]={name:r,loaded:o.N},i++,1;if(l[n]={name:r,loaded:o.Z},isNaN(r)&&(o.incFns[r]=o.Z),isNaN(r)&&o.incCache&&"http"!==e[r].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[r].indexOf(".css")>-1||e[r].indexOf(".js")>-1)){var d=localStorage,f=d.getItem("inc-"+r),u=d.getItem("inc-"+r+"Expires");f&&u&&new Date().getTime()<u?(o.initState({tag:a,id:"oInc-"+s+"-"+n,innerHTML:f,"data-o-inc":s}).appendInside("head"),l[n].loaded=o.N,o.incFns[r]=o.N,i++):(c[r]=n,o.get(e[r],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[r]+" was not loaded"});return}t.text().then(e=>{d.setItem("inc-"+r,e),d.setItem("inc-"+r+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+s+"-"+c[r],innerHTML:e,"data-o-inc":s}).appendInside("head"),o.incCheck(s,c[r],o.N)})}))}else{var p={tag:a,id:"oInc-"+s+"-"+n,"data-o-inc":s,async:o.incAsync,onload:"o.incCheck("+s+","+n+",1)"};e[r].indexOf(".css")>-1?(p.tag="link",p.rel="stylesheet",p.href=e[r]):(e[r].indexOf(".js")>-1||(p.tag="img",p.style="display:none;"),p.src=e[r]),o.initState(p).appendInside(p.style?"body":"head")}}};for(var f in e)if(d(f))continue;return l[o.Z]+=i,n!==o.Z&&(i===n?typeof t===a&&t(s):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof r===a&&r(s))},o.incTimeout,s)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{var r=o.tLog.length,n=0,i="├ OK: ",a="├ ✘ ",s="\n",l="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[r]=t[c-o.N],c--),o.tStyled?(o.tLog[r]="<div><b>"+e+" #"+r+"</b></div>",i=o.tPre+o.tOk,a=o.tPre+o.tXx,l=(s=o.tDc)+s):o.tLog[r]=e+" #"+r+"\n",o.tRes[r]=o.F,o.tStatus[r]=[];for(var f=o.Z;f<c;f++){var u={n:r,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},p=t[f][o.N];if("function"==typeof p)try{p=p(u)}catch(y){p=y.message,o.onError&&o.onError(y)}o.tStatus[r][f]="string"==typeof p?o.F:p,!0===p?(d++,o.tShowOk&&(o.tLog[r]+=i+t[f][o.Z]+s)):p!==o.U?o.tLog[r]+=a+t[f][o.Z]+(p!==o.F?": <i>"+p+"</i>":"")+l:(n++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,u))}return o.tRes[r]=d===c,o.tStyled?o.tLog[r]+=o.tPre+'<div style="color:'+(d+n!==c?"red":"green")+';"><b>':o.tLog[r]+=n?"├":"└ ",o.tLog[r]+="DONE "+d+"/"+(c-n),n&&(o.tLog[r]+=", waiting: "+n),o.tStyled?o.tLog[r]+="</b>"+o.tDc+o.tDc:o.tLog[r]+="\n",n||"function"!=typeof o.tFns[r]||o.tFns[r](r),r},o.testUpdate=(e,t=o.F,r="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+r+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+r+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+r+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+r+"\n");var n,i=o.Z,a=i,s=_createForOfIteratorHelper(o.tStatus[e.n]);try{for(s.s();!(n=s.n()).done;){var l=n.value;if(l===o.U)return;!l&&i++,a++}}catch(c){s.e(c)}finally{s.f()}o.tRes[e.n]=!i;var d=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+d+"</b>"+o.tDc:o.tLog[e.n]+="└ "+d,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
5
+
6
+ if (typeof module !== 'undefined' && module.exports) {
7
+ o.default = o;
8
+ module.exports = o;
9
+ } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
10
+ define('o', [], function () {
11
+ return o;
12
+ });
13
+ } else {
14
+ window.o = o;
15
+ }
16
+ })(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "objs-core",
3
- "version": "1.0.10",
3
+ "version": "1.1.1",
4
4
  "description": "Encrease coding speed, by lightweight samples, states control, caching and auto tests. Easy to use: just split design into samples and give them data to render and action. Also Objs-core can create samples from server rendered DOM and more.",
5
5
  "homepage": "https://fous.name/objs/",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/foggysq/objs/issues"
14
14
  },
15
- "main": "objs.npm.1.0.js",
15
+ "main": "objs.npm.1.1.js",
16
16
  "scripts": {
17
17
  "test": "node tests.js"
18
18
  },
@@ -31,6 +31,7 @@
31
31
  "ajax",
32
32
  "caching",
33
33
  "dom control",
34
+ "react speed up",
34
35
  "objs"
35
36
  ]
36
37
  }
package/objs.1.0.min.js DELETED
@@ -1,2 +0,0 @@
1
- // @author Roman Torshin, Apache 2.0 licence
2
- const o=e=>{let t={els:[],ie:{}},n=0,s=1,i=2,l=3,r="object",a="function",c,d=document,f=-1,g=0,h=0,p=[],u=0,y=0,m=e=>typeof e,S=(e,t)=>{for(let n in e)Object.hasOwnProperty.call(e,n)&&t(n,e)},L=o.onError||(()=>{}),E=e=>(...r)=>{try{let a=e(r[n],r[s],r[i],r[l]);return a!==c?a:t}catch(d){L(d)}},C=e=>{for(u=g;u<=f;u++)e()},$=e=>(m(e)!==r&&(e=o.first(e).el),e),Z=(e=!0,i=t.els)=>{let l=i.length;t.length=l,f=l-s,g=n,t.el=l?i[n]:c,t.last=l?i[f]:c,e&&(S(p,(e,n)=>{delete t[n[e]]}),p=[],t.ie={})},F=(e="")=>Array.from(d.querySelectorAll(e));t.reset=o;let v=(e,t,s)=>{S(t,i=>{let l=t[i];m(l)===a&&(l=l(s)),"append"===i&&m(l)===r&&(l.els&&(l=[l]),l[n]&&l[n].els&&(valueBuff=[],S(l,e=>{valueBuff.push(...l[e].els)}),l=valueBuff)),l!==c&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=l:"dataset"===i&&m(l)===r?S(l,t=>{e.dataset[t]=l[t]}):"toggleClass"===i?e.classList.toggle(l):"addClass"===i?m(l)===r?e.classList.add(...l):e.classList.add(l):"removeClass"===i?e.classList.remove(l):"style"===i&&m(l)===r?S(l,t=>{e.style[t]=l[t]}):"append"===i&&m(l)===r?S(l.length?l:[l],t=>{e.appendChild(l[t])}):e.setAttribute(i,l)))}),e.dataset.oState=t.state};return t.init=E(e=>{let i=t.initID||o.inits.length||n;t.initID=i,Z(),o.inits[t.initID]=t,(m(e)!==r||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=E((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+s);m(p)===r&&(p.state=l,p["data-o-init"]=i);let L=(e,t={})=>m(p)===r?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===a?p(t):p,u.children.length>s||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let E=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,E&&S.push(L(i,e)),e)),E&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let s=m(p)===a?p(h[y?t:n]):p;m(s)===r&&v(e,s,h[y?t:n])}))})})}),t.initState=E((e,n)=>{t.init(e).render(n)}),t.sample=E((e="render")=>{let s=t.els[g].attributes,i=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let r of s)"data-"!==r.nodeName.substring(n,5)&&(l[r.nodeName]=r.value);return S(i,e=>{l.dataset[e]=i[e]}),{[e]:l}}),t.select=E(e=>{e===c&&(e=t.length-s),f=e,g=e,t.el=t.els[e],h=s}),t.all=E(()=>{f=t.length-s,g=n,t.el=t.els[n],h=n}),t.remove=E(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):C(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=E(e=>{e===c&&(e=g),t.els.splice(u,s),Z()}),t.add=E((e,s)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===r?e.tagName?t.els.push(e):e.els?t.els.push(...e.els):e.length&&e[n].tagName&&t.els.push(...e):"number"===m(e)&&o.inits[e]&&(t=o.inits[e]),Z(!1),t.initID!==c&&t.dataset({oInit:t.initID})}),t.appendInside=E(e=>{C(()=>{$(e).appendChild(t.els[u])})}),t.appendBefore=E(e=>{C(()=>{$(e).parentNode.insertBefore(t.els[u],$(e))})}),t.appendAfter=E(e=>{C(()=>{$(e).after(...t.els)})}),t.find=E((e="")=>{let n=[];return C(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),o(n)}),t.first=E((e="")=>{let n=c,s=[];return C(()=>{(n=t.els[u].querySelector(e))&&s.push(n)}),o(s)}),t.attr=E((e,s)=>{if(e){if(s===c){let i=[];return C(()=>{i[u]=t.els[u].getAttribute(e)}),h?i[n]:i}""!==s?C(()=>{t.els[u].setAttribute(e,s)}):C(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=E(()=>{let e=[];return C(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=E(e=>{if(typeof e===r)C(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let s=[];return C(()=>{s.push({...t.els[u].dataset})}),h?s[n]:s}}),t.style=E(e=>{t.attr("style",e)}),t.css=E((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=E(e=>{C(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=E(e=>{C(()=>{t.els[u].classList.add(e)})}),t.removeClass=E(e=>{C(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=E((e,n)=>{C(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return C(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=E(e=>{if(e!==c)C(()=>{t.els[u].innerHTML=e});else{let n="";return C(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=E((e="")=>{C(()=>{t.els[u].innerText=e})}),t.textContent=E((e="")=>{C(()=>{t.els[u].textContent=e})}),t.html=E(e=>{if(e)t.innerHTML(e);else{let n="";return C(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=E(e=>{C(()=>{e({self:o(t.els[u]).select(),i:u})})}),t.on=E((e,n,s,i)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].addEventListener(e,n,s,i)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,s,i])})}),t.off=E((e,s,i)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].removeEventListener(e,s,i)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==s))})}),t.onAll=E((e,l)=>{S(t.ie,(r,a)=>{e&&e!==r||a[r].forEach(e=>{C(()=>{l?t.els[u].removeEventListener(r,e[n]):t.els[u].addEventListener(r,e[n],e[s],e[i])})})})}),t.offAll=E(e=>{t.onAll(e,s)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let i=t.el.dataset.oInit;if(i!==c&&o.inits[i])return t.length===s?(y=t.els[n],Object.assign(t,o.inits[i]),t.els=[y]):t=o.inits[i],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.errors=[],o.showErrors=!1,o.logErrors=()=>{o.errors.length?o.errors.forEach(e=>console.log(e)):console.log("No errors")},o.onError=e=>{o.showErrors?console.log(e):o.errors.push(e)},o.init=e=>o().init(e),o.initState=(e,t)=>o().init(e).render(t),o.take=e=>o().take(e),o.Z=0,o.N=1,o.W=2,o.H=100,o.F=!1,o.C=(e,t)=>Object.hasOwnProperty.call(e,t),o.ajax=(e,t={})=>{let n=new URLSearchParams;if(t.data&&"object"==typeof t.data){for(let s in t.data)o.C(t.data,s)&&("object"==typeof t.data[s]?n.set(s,encodeURIComponent(JSON.stringify(t.data[s]))):n.set(s,t.data[s]));"get"===t.method.toLowerCase()?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return t.headers||(t.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(e,t)},o.get=(e,t={})=>o.ajax(e,{...t,method:"GET"}),o.post=(e,t={})=>o.ajax(e,{...t,method:"POST"}),o.getParams=e=>{let t={},n=new URLSearchParams(window.location.search).entries();for(let s of n)t[s[o.Z]]=s[o.N];return e?t[e]:t},o.incCache=!0,o.incCacheExp=864e5,o.incTimeout=6e3,o.incSource="",o.incForce=o.F,o.incAsync=!0,o.incCors=o.F,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z],o.incN=o.Z,o.incCheck=(e=0,t,n=0)=>!n&&e&&t===o.U&&o.incReady[e]?o.incSet[e]===o.N:o.incReady[e]===o.U||o.incReady[e][t]===o.U?o.F:(o.incReady[e][t].loaded=n,o.incFns[o.incReady[e][t].name]=n,o.incReady[e][o.Z]+=n,e&&o.incReady[e].length===o.incReady[e][o.Z]&&("function"==typeof o.incSet[e]&&o.incSet[e](e),o.incSet[e]=o.N),o.incSet[e]===o.N),o.incCacheClear=(e=o.F)=>{for(let t in o.incFns)o.C(o.incFns,t)&&(localStorage.removeItem("inc-"+t),localStorage.removeItem("inc-"+t+"Expires"));return e&&(o.incReady.forEach((e,t)=>{t&&e.forEach((e,n)=>{n&&o("#oInc-"+t+"-"+n).remove()})}),o.incN=o.Z,o.incFns={},o.incSet=[o.Z],o.incReady=[o.Z]),!0},o.inc=(e,t,n)=>{let s=o.Z,i=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let r=o.incSet[o.Z];o.incSet[r]=t||o.Z,o.incReady[r]=[];let a=o.incReady[r];a[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){s++,o.incN++;let f=e[d].indexOf(".css")>-1?"style":"script";if(e[d]=(o.incSource?o.incSource+"/":"")+e[d],isNaN(d)&&o.C(o.incFns,d)&&o.incFns[d]&&!o.incForce){a[s]={name:d,loaded:o.N},i++;continue}if(a[s]={name:d,loaded:o.Z},isNaN(d)&&(o.incFns[d]=o.Z),isNaN(d)&&o.incCache&&"http"!==e[d].substring(o.Z,4)&&"file:"!==window.location.protocol&&(e[d].indexOf(".css")>-1||e[d].indexOf(".js")>-1)){let g=localStorage,h=g.getItem("inc-"+d),p=g.getItem("inc-"+d+"Expires");h&&p&&new Date().getTime()<p?(o.initState({tag:f,id:"oInc-"+r+"-"+s,innerHTML:h,"data-o-inc":r}).appendInside("head"),a[s].loaded=o.N,o.incFns[d]=o.N,i++):(c[d]=s,o.get(e[d],{mode:o.incCors?"cors":"same-origin"}).then(t=>{if(200!==t.status){o.onError&&o.onError({message:o.incSource+e[d]+" was not loaded"});return}t.text().then(e=>{g.setItem("inc-"+d,e),g.setItem("inc-"+d+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:f,id:"oInc-"+r+"-"+c[d],innerHTML:e,"data-o-inc":r}).appendInside("head"),o.incCheck(r,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+r+"-"+s,"data-o-inc":r,async:o.incAsync,onload:"o.incCheck("+r+","+s+",1)"};e[d].indexOf(".css")>-1?(u.tag="link",u.rel="stylesheet",u.href=e[d]):(e[d].indexOf(".js")>-1||(u.tag="img",u.style="display:none;"),u.src=e[d]),o.initState(u).appendInside(u.style?"body":"head")}}return a[o.Z]+=i,s!==o.Z&&(i===s?typeof t===l&&t(r):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&n(r))},o.incTimeout,r)),o.incSet[o.Z]},o.tLog=[],o.tRes=[],o.tStatus=[],o.tFns=[],o.tShowOk=o.F,o.tStyled=o.F,o.tTime=2e3,o.tPre='<div style="font-family:monospace;text-align:left;">',o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',o.tXx='<div style="background:#fcc;padding:3px;">',o.tDc="</div>",o.test=(e="",...t)=>{let n=o.tLog.length,s=0,i="├ OK: ",l="├ ✘ ",r="\n",a="\n",c=t.length,d=o.Z;"function"==typeof t[c-o.N]&&(o.tFns[n]=t[c-o.N],c--),o.tStyled?(o.tLog[n]="<div><b>"+e+" #"+n+"</b></div>",i=o.tPre+o.tOk,l=o.tPre+o.tXx,a=(r=o.tDc)+r):o.tLog[n]=e+" #"+n+"\n",o.tRes[n]=o.F,o.tStatus[n]=[];for(let f=o.Z;f<c;f++){let g={n:n,i:f,title:t[f][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},h=t[f][o.N];if("function"==typeof h)try{h=h(g)}catch(p){h=p.message,o.onError&&o.onError(p)}o.tStatus[n][f]="string"==typeof h?o.F:h,!0===h?(d++,o.tShowOk&&(o.tLog[n]+=i+t[f][o.Z]+r)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+a:(s++,setTimeout(e=>{e.title+=" (timeout)",o.testUpdate(e)},o.tTime,g))}return o.tRes[n]=d===c,o.tStyled?o.tLog[n]+=o.tPre+'<div style="color:'+(d+s!==c?"red":"green")+';"><b>':o.tLog[n]+=s?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-s),s&&(o.tLog[n]+=", waiting: "+s),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",s||"function"!=typeof o.tFns[n]||o.tFns[n](n),n},o.testUpdate=(e,t=o.F,n="")=>{if(o.tStatus[e.n][e.i]===o.U){o.tStatus[e.n][e.i]=!0===t,!0===t?e.tShowOk&&(e.tStyled?o.tLog[e.n]+=o.tPre+o.tOk+e.title+n+o.tDc:o.tLog[e.n]+="└ OK: "+e.title+n+"\n"):(o.tRes[e.n]=o.F,e.tStyled?o.tLog[e.n]+=o.tPre+o.tXx+e.title+n+(t?": "+t:"")+o.tDc+o.tDc:o.tLog[e.n]+="└ ✘ "+e.title+(t?": "+t:"")+n+"\n");let s=o.Z,i=s;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&s++,i++}o.tRes[e.n]=!s;let r=s?"FAILED "+s+"/"+i:"DONE "+i+"/"+i;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(s?"red":"green")+';">'+r+"</b>"+o.tDc:o.tLog[e.n]+="└ "+r,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
package/objs.npm.1.0.js DELETED
@@ -1,16 +0,0 @@
1
- // @author Roman Torshin, Apache 2.0 licence
2
- (function(globals) {
3
- 'use strict';
4
- function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=_typeof(o))return o;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _createForOfIteratorHelper(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var o=0,r=function t(){};return{s:r,n:function e(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function t(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return a=e.done,e},e:function t(e){c=!0,i=e},f:function t(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var n=({}).toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var _o=function t(e){var n,o={els:[],ie:{}},r="object",i="function",a=document,c=-1,s=0,l=0,u=[],f=0,d=0,p=function t(e){return _typeof(e)},y=function t(e,n){for(var o in e)Object.hasOwnProperty.call(e,o)&&n(o,e)},v=_o.onError||function(){},h=function t(e){return function(){try{var t=e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3]);return t!==n?t:o}catch(r){v(r)}}},g=function t(e){for(f=s;f<=c;f++)e()},$=function t(e){return p(e)!==r&&(e=_o.first(e).el),e},m=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.els,i=r.length;o.length=i,c=i-1,s=0,o.el=i?r[0]:n,o.last=i?r[c]:n,e&&(y(u,function(t,e){delete o[e[t]]}),u=[],o.ie={})},b=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(a.querySelectorAll(e))};o.reset=_o;var S=function t(e,o,a){y(o,function(t){var c,s=o[t];p(s)===i&&(s=s(a)),"append"===t&&p(s)===r&&(s.els&&(s=[s]),s[0]&&s[0].els&&(valueBuff=[],y(s,function(t){var e;(e=valueBuff).push.apply(e,_toConsumableArray(s[t].els))}),s=valueBuff)),s!==n&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=s:"dataset"===t&&p(s)===r?y(s,function(t){e.dataset[t]=s[t]}):"toggleClass"===t?e.classList.toggle(s):"addClass"===t?p(s)===r?(c=e.classList).add.apply(c,_toConsumableArray(s)):e.classList.add(s):"removeClass"===t?e.classList.remove(s):"style"===t&&p(s)===r?y(s,function(t){e.style[t]=s[t]}):"append"===t&&p(s)===r?y(s.length?s:[s],function(t){e.appendChild(s[t])}):e.setAttribute(t,s)))}),e.dataset.oState=o.state};return o.init=h(function(t){var e=o.initID||_o.inits.length||0;o.initID=e,m(),_o.inits[o.initID]=o,(p(t)!==r||t.render===n)&&(t={render:t}),y(t,function(l){u.push(l),o[l]=h(function(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],y=t[l]||{tag:"div"},v=o.els.slice(s,c+1);p(y)===r&&(y.state=l,y["data-o-init"]=e);var h=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(y)===r?a.createElement(y.tag||"div"):((f=a.createElement("div")).innerHTML=p(y)===i?y(n):y,f.children.length>1||!f.firstElementChild)?(f.dataset.oInit=e,f):(f.firstElementChild.dataset.oInit=e,f.firstElementChild)};u.length||(u=[u]);var g=!v[0]&&"render"===l;u=u.map(function(t,r){return t.self=o,t.o=_o,t.i=t.i===n?r:t.i,g&&v.push(h(e,t)),t}),g&&(o.els=v,m(!1)),v&&(d=v.length===u.length,v.map(function(t,e){u[d?e:0].i=e+s;var n=p(y)===i?y(u[d?e:0]):y;p(n)===r&&S(t,n,u[d?e:0])}))})})}),o.initState=h(function(t,e){o.init(t).render(e)}),o.sample=h(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",n=o.els[s].attributes,r=o.els[s].dataset,i={tag:o.els[s].tagName,html:o.els[s].innerHTML,dataset:{}},a=_createForOfIteratorHelper(n);try{for(a.s();!(t=a.n()).done;){var c=t.value;"data-"!==c.nodeName.substring(0,5)&&(i[c.nodeName]=c.value)}}catch(l){a.e(l)}finally{a.f()}return y(r,function(t){i.dataset[t]=r[t]}),_defineProperty({},e,i)}),o.select=h(function(t){t===n&&(t=o.length-1),c=t,s=t,o.el=o.els[t],l=1}),o.all=h(function(){c=o.length-1,s=0,o.el=o.els[0],l=0}),o.remove=h(function(t){t===n&&l&&(t=s),t!==n?o.els[t].parentNode.removeChild(o.els[t]):g(function(){o.els[f].parentNode.removeChild(o.els[f])}),m(!1)}),o.skip=h(function(t){t===n&&(t=s),o.els.splice(f,1),m()}),o.add=h(function(t,e){var i,a,c;"string"===p(t)&&""!==t?(i=o.els).push.apply(i,_toConsumableArray(b(t))):p(t)===r?t.tagName?o.els.push(t):t.els?(a=o.els).push.apply(a,_toConsumableArray(t.els)):t.length&&t[0].tagName&&(c=o.els).push.apply(c,_toConsumableArray(t)):"number"===p(t)&&_o.inits[t]&&(o=_o.inits[t]),m(!1),o.initID!==n&&o.dataset({oInit:o.initID})}),o.appendInside=h(function(t){g(function(){$(t).appendChild(o.els[f])})}),o.appendBefore=h(function(t){g(function(){$(t).parentNode.insertBefore(o.els[f],$(t))})}),o.appendAfter=h(function(t){g(function(){var e;(e=$(t)).after.apply(e,_toConsumableArray(o.els))})}),o.find=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];return g(function(){e.push.apply(e,_toConsumableArray(Array.from(o.els[f].querySelectorAll(":scope "+t))))}),_o(e)}),o.first=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=n,r=[];return g(function(){(e=o.els[f].querySelector(t))&&r.push(e)}),_o(r)}),o.attr=h(function(t,e){if(t){if(e===n){var r=[];return g(function(){r[f]=o.els[f].getAttribute(t)}),l?r[0]:r}""!==e?g(function(){o.els[f].setAttribute(t,e)}):g(function(){o.els[f].removeAttribute(t)})}}),o.attrs=h(function(){var t=[];return g(function(){var e={};_toConsumableArray(o.els[f].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),l?t[0]:t}),o.dataset=h(function(t){if(_typeof(t)===r)g(function(){y(t,function(e){o.els[f].dataset[e]=t[e]})});else{var e=[];return g(function(){e.push(_objectSpread({},o.els[f].dataset))}),l?e[0]:e}}),o.style=h(function(t){o.attr("style",t)}),o.css=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";y(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),o.style(e)}),o.setClass=h(function(t){g(function(){o.els[f].setAttribute("class",t)})}),o.addClass=h(function(t){g(function(){o.els[f].classList.add(t)})}),o.removeClass=h(function(t){g(function(){o.els[f].classList.remove(t)})}),o.toggleClass=h(function(t,e){g(function(){o.els[f].classList.toggle(t,e)})}),o.haveClass=function(t){var e=!0;return g(function(){o.els[f].classList.contains(t)||(e=!1)}),e},o.innerHTML=h(function(t){if(t!==n)g(function(){o.els[f].innerHTML=t});else{var e="";return g(function(){e+=o.els[f].innerHTML}),e}}),o.innerText=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";g(function(){o.els[f].innerText=t})}),o.textContent=h(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";g(function(){o.els[f].textContent=t})}),o.html=h(function(t){if(t)o.innerHTML(t);else{var e="";return g(function(){e+=o.els[f].outerHTML}),e}}),o.forEach=h(function(t){g(function(){t({self:_o(o.els[f]).select(),i:f})})}),o.on=h(function(t,e,n,r){t.split(", ").forEach(function(t){g(function(){o.els[f].addEventListener(t,e,n,r)}),o.ie[t]||(o.ie[t]=[]),o.ie[t].push([e,n,r])})}),o.off=h(function(t,e,n){t.split(", ").forEach(function(t){g(function(){o.els[f].removeEventListener(t,e,n)}),o.ie[t]&&(o.ie[t]=o.ie[t].filter(function(t){return t[0]!==e}))})}),o.onAll=h(function(t,e){y(o.ie,function(n,r){t&&t!==n||r[n].forEach(function(t){g(function(){e?o.els[f].removeEventListener(n,t[0]):o.els[f].addEventListener(n,t[0],t[1],t[2])})})})}),o.offAll=h(function(t){o.onAll(t,1)}),e&&o.add(e),o.take=function(t){if(o.add(t),o.el){var e=o.el.dataset.oInit;if(e!==n&&_o.inits[e])return 1===o.length?(d=o.els[0],Object.assign(o,_o.inits[e]),o.els=[d]):o=_o.inits[e],m(!1,o.els),o}},o};_o.first=function(t){return _o(document.querySelector(t)||"")},_o.inits=[],_o.errors=[],_o.showErrors=!1,_o.logErrors=function(){_o.errors.length?_o.errors.forEach(function(t){return console.log(t)}):console.log("No errors")},_o.onError=function(t){_o.showErrors?console.log(t):_o.errors.push(t)},_o.init=function(t){return _o().init(t)},_o.initState=function(t,e){return _o().init(t).render(e)},_o.take=function(t){return _o().take(t)},_o.Z=0,_o.N=1,_o.W=2,_o.H=100,_o.F=!1,_o.C=function(t,e){return Object.hasOwnProperty.call(t,e)},_o.ajax=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new URLSearchParams;if(e.data&&"object"==_typeof(e.data)){for(var o in e.data)_o.C(e.data,o)&&("object"==_typeof(e.data[o])?n.set(o,encodeURIComponent(JSON.stringify(e.data[o]))):n.set(o,e.data[o]));"get"===e.method.toLowerCase()?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return e.headers||(e.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(t,e)},_o.get=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return _o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"GET"}))},_o.post=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return _o.ajax(t,_objectSpread(_objectSpread({},e),{},{method:"POST"}))},_o.getParams=function(t){var e,n={},o=new URLSearchParams(window.location.search).entries(),r=_createForOfIteratorHelper(o);try{for(r.s();!(e=r.n()).done;){var i=e.value;n[i[_o.Z]]=i[_o.N]}}catch(a){r.e(a)}finally{r.f()}return t?n[t]:n},_o.incCache=!0,_o.incCacheExp=864e5,_o.incTimeout=6e3,_o.incSource="",_o.incForce=_o.F,_o.incAsync=!0,_o.incCors=_o.F,_o.incFns={},_o.incSet=[_o.Z],_o.incReady=[_o.Z],_o.incN=_o.Z,_o.incCheck=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return!n&&t&&e===_o.U&&_o.incReady[t]?_o.incSet[t]===_o.N:_o.incReady[t]===_o.U||_o.incReady[t][e]===_o.U?_o.F:(_o.incReady[t][e].loaded=n,_o.incFns[_o.incReady[t][e].name]=n,_o.incReady[t][_o.Z]+=n,t&&_o.incReady[t].length===_o.incReady[t][_o.Z]&&("function"==typeof _o.incSet[t]&&_o.incSet[t](t),_o.incSet[t]=_o.N),_o.incSet[t]===_o.N)},_o.incCacheClear=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_o.F;for(var e in _o.incFns)_o.C(_o.incFns,e)&&(localStorage.removeItem("inc-"+e),localStorage.removeItem("inc-"+e+"Expires"));return t&&(_o.incReady.forEach(function(t,e){e&&t.forEach(function(t,n){n&&_o("#oInc-"+e+"-"+n).remove()})}),_o.incN=_o.Z,_o.incFns={},_o.incSet=[_o.Z],_o.incReady=[_o.Z]),!0},_o.inc=function(t,e,n){var o=_o.Z,r=_o.Z,i="function";if("object"!=_typeof(t)||!t)return _o.incSet[_o.Z];_o.incSet[_o.Z]++;var a=_o.incSet[_o.Z];_o.incSet[a]=e||_o.Z,_o.incReady[a]=[];var c=_o.incReady[a];c[_o.Z]=_o.N;var s={},l=function e(n){if(_o.C(t,n)){o++,_o.incN++;var i=t[n].indexOf(".css")>-1?"style":"script";if(t[n]=(_o.incSource?_o.incSource+"/":"")+t[n],isNaN(n)&&_o.C(_o.incFns,n)&&_o.incFns[n]&&!_o.incForce)return c[o]={name:n,loaded:_o.N},r++,1;if(c[o]={name:n,loaded:_o.Z},isNaN(n)&&(_o.incFns[n]=_o.Z),isNaN(n)&&_o.incCache&&"http"!==t[n].substring(_o.Z,4)&&"file:"!==window.location.protocol&&(t[n].indexOf(".css")>-1||t[n].indexOf(".js")>-1)){var l=localStorage,u=l.getItem("inc-"+n),f=l.getItem("inc-"+n+"Expires");u&&f&&new Date().getTime()<f?(_o.initState({tag:i,id:"oInc-"+a+"-"+o,innerHTML:u,"data-o-inc":a}).appendInside("head"),c[o].loaded=_o.N,_o.incFns[n]=_o.N,r++):(s[n]=o,_o.get(t[n],{mode:_o.incCors?"cors":"same-origin"}).then(function(e){if(200!==e.status){_o.onError&&_o.onError({message:_o.incSource+t[n]+" was not loaded"});return}e.text().then(function(t){l.setItem("inc-"+n,t),l.setItem("inc-"+n+"Expires",new Date().getTime()+_o.incCacheExp),_o.initState({tag:i,id:"oInc-"+a+"-"+s[n],innerHTML:t,"data-o-inc":a}).appendInside("head"),_o.incCheck(a,s[n],_o.N)})}))}else{var d={tag:i,id:"oInc-"+a+"-"+o,"data-o-inc":a,async:_o.incAsync,onload:"o.incCheck("+a+","+o+",1)"};t[n].indexOf(".css")>-1?(d.tag="link",d.rel="stylesheet",d.href=t[n]):(t[n].indexOf(".js")>-1||(d.tag="img",d.style="display:none;"),d.src=t[n]),_o.initState(d).appendInside(d.style?"body":"head")}}};for(var u in t)if(l(u))continue;return c[_o.Z]+=r,o!==_o.Z&&(r===o?_typeof(e)===i&&e(a):setTimeout(function(t){_o.incReady[t]&&_o.incReady[t].length<_o.incReady[t][_o.Z]&&(_o.incSet[t]=_o.Z,_typeof(n)===i&&n(a))},_o.incTimeout,a)),_o.incSet[_o.Z]},_o.tLog=[],_o.tRes=[],_o.tStatus=[],_o.tFns=[],_o.tShowOk=_o.F,_o.tStyled=_o.F,_o.tTime=2e3,_o.tPre='<div style="font-family:monospace;text-align:left;">',_o.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',_o.tXx='<div style="background:#fcc;padding:3px;">',_o.tDc="</div>",_o.test=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];var r=_o.tLog.length,i=0,a="├ OK: ",c="├ ✘ ",s="\n",l="\n",u=n.length,f=_o.Z;"function"==typeof n[u-_o.N]&&(_o.tFns[r]=n[u-_o.N],u--),_o.tStyled?(_o.tLog[r]="<div><b>"+t+" #"+r+"</b></div>",a=_o.tPre+_o.tOk,c=_o.tPre+_o.tXx,l=(s=_o.tDc)+s):_o.tLog[r]=t+" #"+r+"\n",_o.tRes[r]=_o.F,_o.tStatus[r]=[];for(var d=_o.Z;d<u;d++){var p={n:r,i:d,title:n[d][_o.Z],tShowOk:_o.tShowOk,tStyled:_o.tStyled},y=n[d][_o.N];if("function"==typeof y)try{y=y(p)}catch(v){y=v.message,_o.onError&&_o.onError(v)}_o.tStatus[r][d]="string"==typeof y?_o.F:y,!0===y?(f++,_o.tShowOk&&(_o.tLog[r]+=a+n[d][_o.Z]+s)):y!==_o.U?_o.tLog[r]+=c+n[d][_o.Z]+(y!==_o.F?": <i>"+y+"</i>":"")+l:(i++,setTimeout(function(t){t.title+=" (timeout)",_o.testUpdate(t)},_o.tTime,p))}return _o.tRes[r]=f===u,_o.tStyled?_o.tLog[r]+=_o.tPre+'<div style="color:'+(f+i!==u?"red":"green")+';"><b>':_o.tLog[r]+=i?"├":"└ ",_o.tLog[r]+="DONE "+f+"/"+(u-i),i&&(_o.tLog[r]+=", waiting: "+i),_o.tStyled?_o.tLog[r]+="</b>"+_o.tDc+_o.tDc:_o.tLog[r]+="\n",i||"function"!=typeof _o.tFns[r]||_o.tFns[r](r),r},_o.testUpdate=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_o.F,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(_o.tStatus[t.n][t.i]===_o.U){_o.tStatus[t.n][t.i]=!0===e,!0===e?t.tShowOk&&(t.tStyled?_o.tLog[t.n]+=_o.tPre+_o.tOk+t.title+n+_o.tDc:_o.tLog[t.n]+="└ OK: "+t.title+n+"\n"):(_o.tRes[t.n]=_o.F,t.tStyled?_o.tLog[t.n]+=_o.tPre+_o.tXx+t.title+n+(e?": "+e:"")+_o.tDc+_o.tDc:_o.tLog[t.n]+="└ ✘ "+t.title+(e?": "+e:"")+n+"\n");var o,r=_o.Z,i=r,a=_createForOfIteratorHelper(_o.tStatus[t.n]);try{for(a.s();!(o=a.n()).done;){var c=o.value;if(c===_o.U)return;!c&&r++,i++}}catch(s){a.e(s)}finally{a.f()}_o.tRes[t.n]=!r;var l=r?"FAILED "+r+"/"+i:"DONE "+i+"/"+i;t.tStyled?_o.tLog[t.n]+=_o.tPre+'<b style="color:'+(r?"red":"green")+';">'+l+"</b>"+_o.tDc:_o.tLog[t.n]+="└ "+l,"function"==typeof _o.tFns[t.n]&&_o.tFns[t.n](t.n)}}; var o = _o;
5
-
6
- if (typeof module !== 'undefined' && module.exports) {
7
- o.default = o;
8
- module.exports = o;
9
- } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
10
- define('o', [], function () {
11
- return o;
12
- });
13
- } else {
14
- window.o = o;
15
- }
16
- })(this);