objs-core 1.0.5 → 1.0.6

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,7 +1,5 @@
1
1
  # Objs
2
- > Fast and simple JS library to develop, test, cache and optimize. You can develop new features with Objs without rewriting anything. Examples and full documentation are [here](https://fous.name/objs)
3
-
4
- Feel free to use and share ideas for the next versions!
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)
5
3
 
6
4
 
7
5
 
@@ -21,7 +19,7 @@ npm i objs-core
21
19
  ## Features
22
20
 
23
21
  #### Develop
24
- - Elements state control
22
+ - Samples and state control
25
23
  - Store data in object itself
26
24
  - Cache server rendered elements
27
25
 
@@ -33,27 +31,37 @@ npm i objs-core
33
31
  #### Optimize
34
32
  - Separated HTML and JS logic
35
33
  - Async loading JS, CSS, images
36
- - Cache JS, CSS
34
+ - Controlled JS and CSS cache
37
35
 
38
36
 
39
37
 
40
38
 
41
39
  ## Main principles
42
- Logic structure to create any dynamic module and controll it
43
- To control element Objs uses states. State - it's an information how to create or change element. To create element use `render` state with html (inner HTML) and tag attributes:
40
+
41
+ ### Dynamic content
42
+
43
+ #### Create sample
44
+
45
+ To control elements Objs uses states. State - it's an information how to create or change DOM element. To create an element use `render` state with html (inner HTML) and tag attributes:
44
46
  ```
45
- // timer create state called render
47
+ // state called render for timer example
46
48
  const timerStates = {
47
49
  render: {
50
+ tag: 'div',
48
51
  class: 'timer',
49
52
  html: 'Seconds: <span>0</span>',
50
53
  }
51
54
  }
52
55
  ```
53
- > Default tag is `div`. Attributes `dataset` and `style` can be object type. Also, `render` could be a string like:
54
- `'<divclass="timer">Seconds:<span>0</span></div>'`
56
+ - `render` could be a string if you use HTML samples (see [documentation](https://fous.name/objs/documentation/?parameter=value#states)):
57
+ `'<div class="timer">Seconds:<span>0</span></div>'`
58
+ - default tag is `div` (if tag is undefined)
59
+ - attributes `dataset` and `style` can be object type
60
+ - to append elements inside - use `append` with DOM element/Objs or an array of them as a value
61
+
62
+ #### States
55
63
 
56
- Then add a new state that will start counting. Number will be stored in the object itself - `self` object. So the state will be a function that gets `self`, creates a variable, increments it by interval and shows as innerHTML of `span`:
64
+ Then add a new state that will start and finish counting. Number will be stored in the object itself - `self` object. So the state will be a function that gets `self`, creates a variable, increments it by interval and shows as innerHTML of `span`:
57
65
  ```
58
66
  // new timer states object
59
67
  const timerStates = {
@@ -65,16 +73,40 @@ const timerStates = {
65
73
  // save number or create
66
74
  self.n = self.n || 0;
67
75
  // start interval
68
- setInterval(() => {
76
+ self.interval = setInterval(() => {
69
77
  self.n++;
70
78
  o(self).first('span').html(self.n);
71
79
  }, 1000);
80
+ },
81
+ stop: ({self}) => {
82
+ clearInterval(self.interval);
72
83
  }
73
84
  }
74
85
  ```
75
- States are done and the last thing is to create and append element on the page. To do this - init states, render object and start timer... And also - append it:
76
- `o.init(timerStates).render().start().appendInside('#simpleTimer');`
77
- > This and some more complex live examples are [HERE](https://fous.name/objs) but everywhere is the same logic: create states, some functions that changes element then init and append elements on page. States after initialization are used as `self` methods in addition to standart `on(), first(), remove()` and etc.
86
+ - every state gets object with
87
+ `self` - Objs object
88
+ `o` - o-function to use inside
89
+ `i` - index of the current element in Objs object
90
+
91
+ #### Append in DOM
92
+
93
+ The last thing is to create and append element on the page. To do this - init states, render object and start timer... And also - append it.
94
+ ```
95
+ // create and start timer
96
+ const timer = o.init(timerStates).render().start().appendInside('#simpleTimer');
97
+
98
+ // stop timer
99
+ timer.stop();
100
+ ```
101
+
102
+ #### Main settings
103
+
104
+ `o.showErrors` – turn on/off showing errors (false)
105
+ `o.errors` – an array of all hidden errors, can be logged by `o.logErrors()` for debug
106
+ `o.onError` – a function than will be called with an error as an argument
107
+
108
+ > This and some more complex live examples are in the [full documentation](https://fous.name/objs). There are lots of useful methods and settings.
109
+
78
110
 
79
111
 
80
112
 
@@ -82,21 +114,27 @@ States are done and the last thing is to create and append element on the page.
82
114
  ## Functions
83
115
  Almost all functions return control object with methods, let's call it **Objs**.
84
116
 
85
- ### Root functions
86
- `o(q)` – gets elements to control object. If [string] - by querySelectorAll(q) into control object, if DOM element or an array of them - gets them, if [number] - gets control object from **o.inits[q]**.
117
+ ### Core functions
118
+ `o(q)` – gets elements to control object. If [string] - by **querySelectorAll(q)** into control object, if DOM element or an array of them - gets them, if [number] - gets control object from **o.inits[q]**.
87
119
 
88
- `o.first(q)` – gets element to control by querySelector(q).
120
+ `o.first(q)` – gets element to control by **querySelector(q)**.
89
121
 
90
- `o.take(q)` – gets elements like **o(q)** from DOM but if there is just one element or equal number of elements to inited in **o.inits[]**, gets all inited methods.
122
+ `o.take(q)` – gets elements like **o(q)** from DOM but if there is just one element or equal number of elements to inited in **o.inits[]** before, gets all inited elements and their methods.
91
123
 
92
124
  #### States control
93
- `o.init(states)` – returns **Objs**, creates method(s) for each state to create, change elements. State called **render** is reserved for creation elements. **states** can be [string], [object], [function] that returns [string] or [object]. After **init()** **Objs** gets a **initID** parameter for a saved object in **o.inits**. More info [here](https://fous.name/objs).
125
+ `o.init(states)` – returns **Objs**, creates method(s) for each state to create, change elements. State called **render** is reserved for creation elements. **states** can be [string], [object], [function] that returns [string] or [object]. After **init()** **Objs** gets a **initID** parameter for a saved object in **o.inits**. More info about structure and features [here](https://fous.name/objs).
94
126
 
95
- `o.initState(state, [props])` – inite method and call it with props, e.g. to render/create element. **Objs** gets a **initID** parameter for a saved object in **o.inits**.
127
+ `o.initState(state, [props])` – inite method and call it with props, e.g. to render/create element. **Objs** gets a **.initID** parameter for a saved object in **o.inits[]**.
96
128
 
97
129
  `o.inits[initID]` – an array of all inited objects. Available by index **initID** or **o.take()**.
98
130
 
99
- `o.onError` – false as default, but can be a function that will get errors as the first parameter.
131
+ `o.showErrors` – false as default, but all errors are saved in **o.errors[]**
132
+
133
+ `o.errors` – an array of all errors
134
+
135
+ `o.logErrors()` – a function to log all hidden errors in console
136
+
137
+ `o.onError(error)` – a function that called if an error happens, set it for your needs
100
138
 
101
139
  #### AJAX
102
140
  `o.get(url, [props])` – returns promise for GET AJAX, **data** in **props** as an [object] will be converted to string parameters.
@@ -238,4 +276,4 @@ Here are methods, **o()** means that they are available after getting elements f
238
276
 
239
277
 
240
278
  ## License
241
- Apache 2.0: Save author name in the file: `// Roman Torshin`
279
+ Apache 2.0
package/objs.1.0.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @function Objs
3
3
  * DOM Modify and state control
4
4
  *
5
- * @version 1.0 02 2023
5
+ * @version 1.0
6
6
  * @author Roman Torshin
7
7
  * @copyright
8
8
  * Apache-2.0 license *
@@ -93,33 +93,52 @@ const o = (query) => {
93
93
  * @param {object} state States data
94
94
  * @param {object} props additional props and dynamic content
95
95
  */
96
-
97
96
  const transform = (el, state, props) => {
98
97
  cycleObj(state, (s) => {
99
98
  let value = state[s];
100
99
 
101
- if (type(value) === functionType) {
100
+ // eval functions in attributes
101
+ if (type(value) === functionType) {
102
102
  value = value(props);
103
103
  }
104
104
 
105
+ // prepare objs to append
106
+ if (s === 'append' && type(value) === objectType) {
107
+ if (value.els) {
108
+ value = [value];
109
+ }
110
+ valueBuff = [];
111
+ cycleObj(value, (i) => {
112
+ valueBuff.push(...value[i].els);
113
+ });
114
+ value = valueBuff;
115
+ }
116
+
105
117
  if (value !== u) {
106
- ['tag','sample','state'].includes(s) ? '' :
118
+ // skip these
119
+ ['tag','sample','state'].includes(s) ? '' :
120
+ // insert html
107
121
  ['html','innerHTML'].includes(s) ? el.innerHTML = value :
122
+ // attach dataset
108
123
  s === 'dataset' && type(value) === objectType ?
109
124
  cycleObj(value, (data) => {
110
- el.dataset[data] = value[data];
111
- }) :
125
+ el.dataset[data] = value[data];
126
+ }) :
127
+ // classes
112
128
  s === 'toggleClass' ? el.classList.toggle(value) :
113
129
  s === 'addClass' ? (type(value) === objectType ? el.classList.add(...value) : el.classList.add(value)) :
114
130
  s === 'removeClass' ? el.classList.remove(value) :
131
+ // style attribute
115
132
  s === 'style' && type(value) === objectType ?
116
133
  cycleObj(value, (data) => {
117
134
  el.style[data] = value[data];
118
- }) :
135
+ }) :
136
+ // append DOM objects
119
137
  s === 'append' && type(value) === objectType ?
120
138
  cycleObj(value.length ? value : [value], (j) => {
121
139
  el.appendChild(value[j]);
122
- }) :
140
+ }) :
141
+ // set attributes
123
142
  el.setAttribute(s, value);
124
143
  }
125
144
  });
@@ -588,7 +607,7 @@ const o = (query) => {
588
607
  * Making result object
589
608
  */
590
609
  if (query)
591
- result.add(query);
610
+ result.add(query);
592
611
 
593
612
  result.take = (innerQuery) => {
594
613
  result.add(innerQuery);
@@ -636,8 +655,10 @@ o.first = (query) => {
636
655
  };
637
656
 
638
657
  o.inits = [];
639
- o.onError = false;
640
- // o.onError = (e) => console.log(e);
658
+ o.errors = [];
659
+ o.showErrors = false;// on and off errors
660
+ o.logErrors = () => {o.errors.length ? o.errors.forEach((e) => console.log(e)) : console.log('No errors')};
661
+ o.onError = (e) => {o.showErrors ? console.log(e) : o.errors.push(e)};// function for errors
641
662
 
642
663
  /**
643
664
  * Creating elements from state
package/objs.1.0.min.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @author Roman Torshin, Apache 2.0 licence
2
- const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=2,l=3,a="object",r="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||(()=>{}),C=e=>(...a)=>{try{let r=e(a[n],a[i],a[s],a[l]);return r!==c?r:t}catch(d){L(d)}},$=e=>{for(u=g;u<=f;u++)e()},E=e=>(m(e)!==a&&(e=o.first(e).el),e),Z=(e=!0,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[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,n)=>{S(t,i=>{let s=t[i];m(s)===r&&(s=s(n)),s!==c&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=s:"dataset"===i&&m(s)===a?S(s,t=>{e.dataset[t]=s[t]}):"toggleClass"===i?e.classList.toggle(s):"addClass"===i?m(s)===a?e.classList.add(...s):e.classList.add(s):"removeClass"===i?e.classList.remove(s):"style"===i&&m(s)===a?S(s,t=>{e.style[t]=s[t]}):"append"===i&&m(s)===a?S(s.length?s:[s],t=>{e.appendChild(s[t])}):e.setAttribute(i,s)))}),e.dataset.oState=t.state};return t.init=C(e=>{let s=t.initID||o.inits.length||n;t.initID=s,Z(),o.inits[t.initID]=t,(m(e)!==a||e.render===c)&&(e={render:e}),S(e,l=>{p.push(l),t[l]=C((h=[{}])=>{let p=e[l]||{tag:"div"},S=t.els.slice(g,f+i);m(p)===a&&(p.state=l,p["data-o-init"]=s);let L=(e,t={})=>m(p)===a?d.createElement(p.tag||"div"):((u=d.createElement("div")).innerHTML=m(p)===r?p(t):p,u.children.length>i||!u.firstElementChild)?(u.dataset.oInit=e,u):(u.firstElementChild.dataset.oInit=e,u.firstElementChild);h.length||(h=[h]);let C=!S[n]&&"render"===l;h=h.map((e,n)=>(e.self=t,e.o=o,e.i=e.i===c?n:e.i,C&&S.push(L(s,e)),e)),C&&(t.els=S,Z(!1)),S&&(y=S.length===h.length,S.map((e,t)=>{h[y?t:n].i=t+g;let i=m(p)===r?p(h[y?t:n]):p;m(i)===a&&v(e,i,h[y?t:n])}))})})}),t.initState=C((e,n)=>{t.init(e).render(n)}),t.sample=C((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let a of i)"data-"!==a.nodeName.substring(n,5)&&(l[a.nodeName]=a.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=C(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=C(()=>{f=t.length-i,g=n,t.el=t.els[n],h=n}),t.remove=C(e=>{e===c&&h&&(e=g),e!==c?t.els[e].parentNode.removeChild(t.els[e]):$(()=>{t.els[u].parentNode.removeChild(t.els[u])}),Z(!1)}),t.skip=C(e=>{e===c&&(e=g),t.els.splice(u,i),Z()}),t.add=C((e,i)=>{"string"===m(e)&&""!==e?t.els.push(...F(e)):m(e)===a?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=C(e=>{$(()=>{E(e).appendChild(t.els[u])})}),t.appendBefore=C(e=>{$(()=>{E(e).parentNode.insertBefore(t.els[u],E(e))})}),t.appendAfter=C(e=>{$(()=>{E(e).after(...t.els)})}),t.find=C((e="")=>{let n=[];$(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=C((e="")=>{let n=c,i=[];$(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=C((e,i)=>{if(e){if(i===c){let s=[];return $(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?$(()=>{t.els[u].setAttribute(e,i)}):$(()=>{t.els[u].removeAttribute(e)})}}),t.attrs=C(()=>{let e=[];return $(()=>{let n={};[...t.els[u].attributes].forEach(e=>{n[e.nodeName]=e.nodeValue}),e.push(n)}),h?e[n]:e}),t.dataset=C(e=>{if(typeof e===a)$(()=>{S(e,n=>{t.els[u].dataset[n]=e[n]})});else{let i=[];return $(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),t.style=C(e=>{t.attr("style",e)}),t.css=C((e={})=>{let n="";S(e,t=>{n+=t+":"+e[t].replace('"',"'")+";"}),t.style(n)}),t.setClass=C(e=>{$(()=>{t.els[u].setAttribute("class",e)})}),t.addClass=C(e=>{$(()=>{t.els[u].classList.add(e)})}),t.removeClass=C(e=>{$(()=>{t.els[u].classList.remove(e)})}),t.toggleClass=C((e,n)=>{$(()=>{t.els[u].classList.toggle(e,n)})}),t.haveClass=e=>{let n=!0;return $(()=>{t.els[u].classList.contains(e)||(n=!1)}),n},t.innerHTML=C(e=>{if(e!==c)$(()=>{t.els[u].innerHTML=e});else{let n="";return $(()=>{n+=t.els[u].innerHTML}),n}}),t.innerText=C((e="")=>{$(()=>{t.els[u].innerText=e})}),t.textContent=C((e="")=>{$(()=>{t.els[u].textContent=e})}),t.html=C(e=>{if(e)t.innerHTML(e);else{let n="";return $(()=>{n+=t.els[u].outerHTML}),n}}),t.forEach=C(e=>{t.initState(e)}),t.on=C((e,n,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=C((e,i,s)=>{e.split(", ").forEach(e=>{$(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),t.onAll=C((e,l)=>{S(t.ie,(a,r)=>{e&&e!==a||r[a].forEach(e=>{$(()=>{l?t.els[u].removeEventListener(a,e[n]):t.els[u].addEventListener(a,e[n],e[i],e[s])})})})}),t.offAll=C(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],Z(!1,t.els),t}},t};o.first=e=>o(document.querySelector(e)||""),o.inits=[],o.onError=!1,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 i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return 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 i of n)t[i[o.Z]]=i[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 i=o.Z,s=o.Z,l="function";if("object"!=typeof e||!e)return o.incSet[o.Z];o.incSet[o.Z]++;let a=o.incSet[o.Z];o.incSet[a]=t||o.Z,o.incReady[a]=[];let r=o.incReady[a];r[o.Z]=o.N;let c={};for(let d in e)if(o.C(e,d)){i++,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){r[i]={name:d,loaded:o.N},s++;continue}if(r[i]={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-"+a+"-"+i,innerHTML:h,"data-o-inc":a}).appendInside("head"),r[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,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-"+a+"-"+c[d],innerHTML:e,"data-o-inc":a}).appendInside("head"),o.incCheck(a,c[d],o.N)})}))}else{let u={tag:f,id:"oInc-"+a+"-"+i,"data-o-inc":a,async:o.incAsync,onload:"o.incCheck("+a+","+i+",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 r[o.Z]+=s,i!==o.Z&&(s===i?typeof t===l&&t(a):setTimeout(e=>{o.incReady[e]&&o.incReady[e].length<o.incReady[e][o.Z]&&(o.incSet[e]=o.Z,typeof n===l&&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=(e="",...t)=>{let n=o.tLog.length,i=0,s="├ OK: ",l="├ ✘ ",a="\n",r="\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>",s=o.tPre+o.tOk,l=o.tPre+o.tXx,r=(a=o.tDc)+a):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]+=s+t[f][o.Z]+a)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+r:(i++,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+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"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 i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let a=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+a+"</b>"+o.tDc:o.tLog[e.n]+="└ "+a,"function"==typeof o.tFns[e.n]&&o.tFns[e.n](e.n)}};
2
+ const o=e=>{let t={els:[],ie:{}},n=0,i=1,s=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[i],r[s],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,s=t.els)=>{let l=s.length;t.length=l,f=l-i,g=n,t.el=l?s[n]:c,t.last=l?s[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,n)=>{S(t,i=>{let s=t[i];m(s)===a&&(s=s(n)),"append"===i&&m(s)===r&&(s.els&&(s=[s]),valueBuff=[],S(s,e=>{valueBuff.push(...s[e].els)}),s=valueBuff),s!==c&&(["tag","sample","state"].includes(i)||(["html","innerHTML"].includes(i)?e.innerHTML=s:"dataset"===i&&m(s)===r?S(s,t=>{e.dataset[t]=s[t]}):"toggleClass"===i?e.classList.toggle(s):"addClass"===i?m(s)===r?e.classList.add(...s):e.classList.add(s):"removeClass"===i?e.classList.remove(s):"style"===i&&m(s)===r?S(s,t=>{e.style[t]=s[t]}):"append"===i&&m(s)===r?S(s.length?s:[s],t=>{e.appendChild(s[t])}):e.setAttribute(i,s)))}),e.dataset.oState=t.state};return t.init=E(e=>{let s=t.initID||o.inits.length||n;t.initID=s,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+i);m(p)===r&&(p.state=l,p["data-o-init"]=s);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>i||!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(s,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 i=m(p)===a?p(h[y?t:n]):p;m(i)===r&&v(e,i,h[y?t:n])}))})})}),t.initState=E((e,n)=>{t.init(e).render(n)}),t.sample=E((e="render")=>{let i=t.els[g].attributes,s=t.els[g].dataset,l={tag:t.els[g].tagName,html:t.els[g].innerHTML,dataset:{}};for(let r of i)"data-"!==r.nodeName.substring(n,5)&&(l[r.nodeName]=r.value);return S(s,e=>{l.dataset[e]=s[e]}),{[e]:l}}),t.select=E(e=>{e===c&&(e=t.length-i),f=e,g=e,t.el=t.els[e],h=i}),t.all=E(()=>{f=t.length-i,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,i),Z()}),t.add=E((e,i)=>{"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=[];C(()=>{n.push(...Array.from(t.els[u].querySelectorAll(":scope "+e)))}),t.els=n,Z()}),t.first=E((e="")=>{let n=c,i=[];C(()=>{(n=t.els[u].querySelector(e))&&i.push(n)}),t.els=i,Z()}),t.attr=E((e,i)=>{if(e){if(i===c){let s=[];return C(()=>{s[u]=t.els[u].getAttribute(e)}),h?s[n]:s}""!==i?C(()=>{t.els[u].setAttribute(e,i)}):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 i=[];return C(()=>{i.push({...t.els[u].dataset})}),h?i[n]:i}}),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=>{t.initState(e)}),t.on=E((e,n,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].addEventListener(e,n,i,s)}),t.ie[e]||(t.ie[e]=[]),t.ie[e].push([n,i,s])})}),t.off=E((e,i,s)=>{e.split(", ").forEach(e=>{C(()=>{t.els[u].removeEventListener(e,i,s)}),t.ie[e]&&(t.ie[e]=t.ie[e].filter(e=>e[n]!==i))})}),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[i],e[s])})})})}),t.offAll=E(e=>{t.onAll(e,i)}),e&&t.add(e),t.take=e=>{if(t.add(e),t.el){let s=t.el.dataset.oInit;if(s!==c&&o.inits[s])return t.length===i?(y=t.els[n],Object.assign(t,o.inits[s]),t.els=[y]):t=o.inits[s],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 i in t.data)o.C(t.data,i)&&("object"==typeof t.data[i]?n.set(i,encodeURIComponent(JSON.stringify(t.data[i]))):n.set(i,t.data[i]));"GET"===t.method||"get"===t.method?e+="?"+n.toString():t.body||(t.body=n),delete t.data}return 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 i of n)t[i[o.Z]]=i[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 i=o.Z,s=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)){i++,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[i]={name:d,loaded:o.N},s++;continue}if(a[i]={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+"-"+i,innerHTML:h,"data-o-inc":r}).appendInside("head"),a[i].loaded=o.N,o.incFns[d]=o.N,s++):(c[d]=i,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+"-"+i,"data-o-inc":r,async:o.incAsync,onload:"o.incCheck("+r+","+i+",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]+=s,i!==o.Z&&(s===i?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,i=0,s="├ 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>",s=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]+=s+t[f][o.Z]+r)):h!==o.U?o.tLog[n]+=l+t[f][o.Z]+(h!==o.F?": <i>"+h+"</i>":"")+a:(i++,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+i!==c?"red":"green")+';"><b>':o.tLog[n]+=i?"├":"└ ",o.tLog[n]+="DONE "+d+"/"+(c-i),i&&(o.tLog[n]+=", waiting: "+i),o.tStyled?o.tLog[n]+="</b>"+o.tDc+o.tDc:o.tLog[n]+="\n",i||"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 i=o.Z,s=i;for(let l of o.tStatus[e.n]){if(l===o.U)return;!l&&i++,s++}o.tRes[e.n]=!i;let r=i?"FAILED "+i+"/"+s:"DONE "+s+"/"+s;e.tStyled?o.tLog[e.n]+=o.tPre+'<b style="color:'+(i?"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 CHANGED
@@ -1,7 +1,7 @@
1
1
  // @author Roman Torshin, Apache 2.0 licence
2
2
  (function(globals) {
3
3
  'use strict';
4
- function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}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:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;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 r=0,i=function t(){};return{s:i,n:function e(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function t(e){throw e},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,c=!0,s=!1;return{s:function e(){n=n.call(t)},n:function t(){var e=n.next();return c=e.done,e},e:function t(e){s=!0,a=e},f:function t(){try{c||null==n.return||n.return()}finally{if(s)throw a}}}}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=Object.prototype.toString.call(t).slice(8,-1);if("Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(t,e)}}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,r=Array(e);n<e;n++)r[n]=t[n];return r}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={els:[],ie:{}},r="object",i="function",a=void 0,c=document,s=-1,l=0,u=0,f=[],d=0,y=0,p=function t(e){return _typeof(e)},v=function t(e,n){for(var r in e)Object.hasOwnProperty.call(e,r)&&n(r,e)},g=t.onError||function(){},$=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!==a?t:n}catch(r){g(r)}}},h=function t(e){for(d=l;d<=s;d++)e()},m=function e(n){return p(n)!==r&&(n=t.first(n).el),n},b=function t(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.els,i=r.length;n.length=i,s=i-1,l=0,n.el=i?r[0]:a,n.last=i?r[s]:a,e&&(v(f,function(t,e){delete n[e[t]]}),f=[],n.ie={})},S=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Array.from(c.querySelectorAll(e))};n.reset=t;var _=function t(e,n,c){v(n,function(t){var s,l=n[t];p(l)===i&&(l=l(c)),l!==a&&(["tag","sample","state"].includes(t)||(["html","innerHTML"].includes(t)?e.innerHTML=l:"dataset"===t&&p(l)===r?v(l,function(t){e.dataset[t]=l[t]}):"toggleClass"===t?e.classList.toggle(l):"addClass"===t?p(l)===r?(s=e.classList).add.apply(s,_toConsumableArray(l)):e.classList.add(l):"removeClass"===t?e.classList.remove(l):"style"===t&&p(l)===r?v(l,function(t){e.style[t]=l[t]}):"append"===t&&p(l)===r?v(l.length?l:[l],function(t){e.appendChild(l[t])}):e.setAttribute(t,l)))}),e.dataset.oState=n.state};return n.init=$(function(e){var u=n.initID||t.inits.length||0;n.initID=u,b(),t.inits[n.initID]=n,(p(e)!==r||e.render===a)&&(e={render:e}),v(e,function(v){f.push(v),n[v]=$(function(){var f=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}],g=e[v]||{tag:"div"},$=n.els.slice(l,s+1);p(g)===r&&(g.state=v,g["data-o-init"]=u);var h=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(g)===r?c.createElement(g.tag||"div"):((d=c.createElement("div")).innerHTML=p(g)===i?g(n):g,d.children.length>1||!d.firstElementChild)?(d.dataset.oInit=e,d):(d.firstElementChild.dataset.oInit=e,d.firstElementChild)};f.length||(f=[f]);var m=!$[0]&&"render"===v;f=f.map(function(e,r){return e.self=n,e.o=t,e.i=e.i===a?r:e.i,m&&$.push(h(u,e)),e}),m&&(n.els=$,b(!1)),$&&(y=$.length===f.length,$.map(function(t,e){f[y?e:0].i=e+l;var n=p(g)===i?g(f[y?e:0]):g;p(n)===r&&_(t,n,f[y?e:0])}))})})}),n.initState=$(function(t,e){n.init(t).render(e)}),n.sample=$(function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"render",r=n.els[l].attributes,i=n.els[l].dataset,a={tag:n.els[l].tagName,html:n.els[l].innerHTML,dataset:{}},c=_createForOfIteratorHelper(r);try{for(c.s();!(t=c.n()).done;){var s=t.value;"data-"!==s.nodeName.substring(0,5)&&(a[s.nodeName]=s.value)}}catch(u){c.e(u)}finally{c.f()}return v(i,function(t){a.dataset[t]=i[t]}),_defineProperty({},e,a)}),n.select=$(function(t){t===a&&(t=n.length-1),s=t,l=t,n.el=n.els[t],u=1}),n.all=$(function(){s=n.length-1,l=0,n.el=n.els[0],u=0}),n.remove=$(function(t){t===a&&u&&(t=l),t!==a?n.els[t].parentNode.removeChild(n.els[t]):h(function(){n.els[d].parentNode.removeChild(n.els[d])}),b(!1)}),n.skip=$(function(t){t===a&&(t=l),n.els.splice(d,1),b()}),n.add=$(function(e,i){var c,s,l;"string"===p(e)&&""!==e?(c=n.els).push.apply(c,_toConsumableArray(S(e))):p(e)===r?e.tagName?n.els.push(e):e.els?(s=n.els).push.apply(s,_toConsumableArray(e.els)):e.length&&e[0].tagName&&(l=n.els).push.apply(l,_toConsumableArray(e)):"number"===p(e)&&t.inits[e]&&(n=t.inits[e]),b(!1),n.initID!==a&&n.dataset({oInit:n.initID})}),n.appendInside=$(function(t){h(function(){m(t).appendChild(n.els[d])})}),n.appendBefore=$(function(t){h(function(){m(t).parentNode.insertBefore(n.els[d],m(t))})}),n.appendAfter=$(function(t){h(function(){var e;(e=m(t)).after.apply(e,_toConsumableArray(n.els))})}),n.find=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=[];h(function(){e.push.apply(e,_toConsumableArray(Array.from(n.els[d].querySelectorAll(":scope "+t))))}),n.els=e,b()}),n.first=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=a,r=[];h(function(){(e=n.els[d].querySelector(t))&&r.push(e)}),n.els=r,b()}),n.attr=$(function(t,e){if(t){if(e===a){var r=[];return h(function(){r[d]=n.els[d].getAttribute(t)}),u?r[0]:r}""!==e?h(function(){n.els[d].setAttribute(t,e)}):h(function(){n.els[d].removeAttribute(t)})}}),n.attrs=$(function(){var t=[];return h(function(){var e={};_toConsumableArray(n.els[d].attributes).forEach(function(t){e[t.nodeName]=t.nodeValue}),t.push(e)}),u?t[0]:t}),n.dataset=$(function(t){if(_typeof(t)===r)h(function(){v(t,function(e){n.els[d].dataset[e]=t[e]})});else{var e=[];return h(function(){e.push(_objectSpread({},n.els[d].dataset))}),u?e[0]:e}}),n.style=$(function(t){n.attr("style",t)}),n.css=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="";v(t,function(n){e+=n+":"+t[n].replace('"',"'")+";"}),n.style(e)}),n.setClass=$(function(t){h(function(){n.els[d].setAttribute("class",t)})}),n.addClass=$(function(t){h(function(){n.els[d].classList.add(t)})}),n.removeClass=$(function(t){h(function(){n.els[d].classList.remove(t)})}),n.toggleClass=$(function(t,e){h(function(){n.els[d].classList.toggle(t,e)})}),n.haveClass=function(t){var e=!0;return h(function(){n.els[d].classList.contains(t)||(e=!1)}),e},n.innerHTML=$(function(t){if(t!==a)h(function(){n.els[d].innerHTML=t});else{var e="";return h(function(){e+=n.els[d].innerHTML}),e}}),n.innerText=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].innerText=t})}),n.textContent=$(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";h(function(){n.els[d].textContent=t})}),n.html=$(function(t){if(t)n.innerHTML(t);else{var e="";return h(function(){e+=n.els[d].outerHTML}),e}}),n.forEach=$(function(t){n.initState(t)}),n.on=$(function(t,e,r,i){t.split(", ").forEach(function(t){h(function(){n.els[d].addEventListener(t,e,r,i)}),n.ie[t]||(n.ie[t]=[]),n.ie[t].push([e,r,i])})}),n.off=$(function(t,e,r){t.split(", ").forEach(function(t){h(function(){n.els[d].removeEventListener(t,e,r)}),n.ie[t]&&(n.ie[t]=n.ie[t].filter(function(t){return t[0]!==e}))})}),n.onAll=$(function(t,e){v(n.ie,function(r,i){t&&t!==r||i[r].forEach(function(t){h(function(){e?n.els[d].removeEventListener(r,t[0]):n.els[d].addEventListener(r,t[0],t[1],t[2])})})})}),n.offAll=$(function(t){n.onAll(t,1)}),e&&n.add(e),n.take=function(e){if(n.add(e),n.el){var r=n.el.dataset.oInit;if(r!==a&&t.inits[r])return 1===n.length?(y=n.els[0],Object.assign(n,t.inits[r]),n.els=[y]):n=t.inits[r],b(!1,n.els),n}},n};o.first=function(t){return o(document.querySelector(t)||"")},o.inits=[],o.onError=!1,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 r in e.data)o.C(e.data,r)&&("object"===_typeof(e.data[r])?n.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):n.set(r,e.data[r]));"GET"===e.method||"get"===e.method?t+="?"+n.toString():e.body||(e.body=n),delete e.data}return 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={},r=new URLSearchParams(window.location.search).entries(),i=_createForOfIteratorHelper(r);try{for(i.s();!(e=i.n()).done;){var a=e.value;n[a[o.Z]]=a[o.N]}}catch(c){i.e(c)}finally{i.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 r=o.Z,i=o.Z,a="function";if("object"!==_typeof(t)||!t)return o.incSet[o.Z];o.incSet[o.Z]++;var c=o.incSet[o.Z];o.incSet[c]=e||o.Z,o.incReady[c]=[];var s=o.incReady[c];s[o.Z]=o.N;var l={},u=function e(n){if(o.C(t,n)){r++,o.incN++;var a=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 s[r]={name:n,loaded:o.N},i++,1;if(s[r]={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 u=localStorage,f=u.getItem("inc-"+n),d=u.getItem("inc-"+n+"Expires");f&&d&&new Date().getTime()<d?(o.initState({tag:a,id:"oInc-"+c+"-"+r,innerHTML:f,"data-o-inc":c}).appendInside("head"),s[r].loaded=o.N,o.incFns[n]=o.N,i++):(l[n]=r,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){u.setItem("inc-"+n,t),u.setItem("inc-"+n+"Expires",new Date().getTime()+o.incCacheExp),o.initState({tag:a,id:"oInc-"+c+"-"+l[n],innerHTML:t,"data-o-inc":c}).appendInside("head"),o.incCheck(c,l[n],o.N)})}))}else{var y={tag:a,id:"oInc-"+c+"-"+r,"data-o-inc":c,async:o.incAsync,onload:"o.incCheck("+c+","+r+",1)"};t[n].indexOf(".css")>-1?(y.tag="link",y.rel="stylesheet",y.href=t[n]):(t[n].indexOf(".js")>-1||(y.tag="img",y.style="display:none;"),y.src=t[n]),o.initState(y).appendInside(y.style?"body":"head")}}};for(var f in t)if(u(f))continue;return s[o.Z]+=i,r!==o.Z&&(i===r?_typeof(e)===a&&e(c):setTimeout(function(t){o.incReady[t]&&o.incReady[t].length<o.incReady[t][o.Z]&&(o.incSet[t]=o.Z,_typeof(n)===a&&n(c))},o.incTimeout,c)),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=o.tLog.length,n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];var a=0,c="├ OK: ",s="├ ✘ ",l="\n",u="\n",f=r.length,d=o.Z;"function"==typeof r[f-o.N]&&(o.tFns[e]=r[f-o.N],f--),o.tStyled?(o.tLog[e]="<div><b>"+t+" #"+e+"</b></div>",c=o.tPre+o.tOk,s=o.tPre+o.tXx,u=(l=o.tDc)+l):o.tLog[e]=t+" #"+e+"\n",o.tRes[e]=o.F,o.tStatus[e]=[];for(var y=o.Z;y<f;y++){var p={n:e,i:y,title:r[y][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled},v=r[y][o.N];if("function"==typeof v)try{v=v(p)}catch(g){v=g.message,o.onError&&o.onError(g)}o.tStatus[e][y]="string"==typeof v?o.F:v,!0===v?(d++,o.tShowOk&&(o.tLog[e]+=c+r[y][o.Z]+l)):v!==o.U?o.tLog[e]+=s+r[y][o.Z]+(v!==o.F?": <i>"+v+"</i>":"")+u:(a++,setTimeout(function(t){t.title+=" (timeout)",o.testUpdate(t)},o.tTime,p))}return o.tRes[e]=d===f,o.tStyled?o.tLog[e]+=o.tPre+'<div style="color:'+(d+a!==f?"red":"green")+';"><b>':o.tLog[e]+=a?"├":"└ ",o.tLog[e]+="DONE "+d+"/"+(f-a),a&&(o.tLog[e]+=", waiting: "+a),o.tStyled?o.tLog[e]+="</b>"+o.tDc+o.tDc:o.tLog[e]+="\n",a||"function"!=typeof o.tFns[e]||o.tFns[e](e),e},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 r,i=o.Z,a=i,c=_createForOfIteratorHelper(o.tStatus[t.n]);try{for(c.s();!(r=c.n()).done;){var s=r.value;if(s===o.U)return;!s&&i++,a++}}catch(l){c.e(l)}finally{c.f()}o.tRes[t.n]=!i;var u=i?"FAILED "+i+"/"+a:"DONE "+a+"/"+a;t.tStyled?o.tLog[t.n]+=o.tPre+'<b style="color:'+(i?"red":"green")+';">'+u+"</b>"+o.tDc:o.tLog[t.n]+="└ "+u,"function"==typeof o.tFns[t.n]&&o.tFns[t.n](t.n)}};
4
+ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(obj,key,value){key=_toPropertyKey(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key)}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return(hint==="string"?String:Number)(input)}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}var o=function o(query){var result={els:[],ie:{}},ZERO=0,ONE=1,TWO=2,THREE=3,objectType="object",functionType="function",u=undefined,D=document;var start=-1,finish=0,select=0,initedStates=[],i=0,j=0;var type=function type(obj){return _typeof(obj)};var cycleObj=function cycleObj(obj,func){for(var item in obj)if(Object.hasOwnProperty.call(obj,item))func(item,obj)};var error=o.onError||function(){return};var returner=function returner(f){return function(){try{var res=f(arguments.length<=ZERO?undefined:arguments[ZERO],arguments.length<=ONE?undefined:arguments[ONE],arguments.length<=TWO?undefined:arguments[TWO],arguments.length<=THREE?undefined:arguments[THREE]);return res!==u?res:result}catch(err){error(err)}}};var iterator=function iterator(f){for(i=finish;i<=start;i++)f()};var toEl=function toEl(el){if(type(el)!==objectType)el=o.first(el).el;return el};var setResultVals=function setResultVals(){var clearStates=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var els=arguments.length>1&&arguments[1]!==undefined?arguments[1]:result.els;var ln=els.length;result.length=ln;start=ln-ONE;finish=ZERO;result.el=ln?els[ZERO]:u;result.last=ln?els[start]:u;if(clearStates){cycleObj(initedStates,function(i,state){delete result[state[i]]});initedStates=[];result.ie={}}};var getObjs=function getObjs(){var innerQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";return Array.from(D.querySelectorAll(innerQuery))};result.reset=o;var transform=function transform(el,state,props){cycleObj(state,function(s){var value=state[s];if(type(value)===functionType){value=value(props)}if(s==="append"&&type(value)===objectType){if(value.els){value=[value]}valueBuff=[];cycleObj(value,function(i){var _valueBuff;(_valueBuff=valueBuff).push.apply(_valueBuff,_toConsumableArray(value[i].els))});value=valueBuff}if(value!==u){var _el$classList;["tag","sample","state"].includes(s)?"":["html","innerHTML"].includes(s)?el.innerHTML=value:s==="dataset"&&type(value)===objectType?cycleObj(value,function(data){el.dataset[data]=value[data]}):s==="toggleClass"?el.classList.toggle(value):s==="addClass"?type(value)===objectType?(_el$classList=el.classList).add.apply(_el$classList,_toConsumableArray(value)):el.classList.add(value):s==="removeClass"?el.classList.remove(value):s==="style"&&type(value)===objectType?cycleObj(value,function(data){el.style[data]=value[data]}):s==="append"&&type(value)===objectType?cycleObj(value.length?value:[value],function(j){el.appendChild(value[j])}):el.setAttribute(s,value)}});el.dataset["oState"]=state.state};result.init=returner(function(states){var initN=result.initID||o.inits.length||ZERO;result.initID=initN;setResultVals();o.inits[result.initID]=result;if(type(states)!==objectType||states.render===u){states={render:states}}cycleObj(states,function(state){initedStates.push(state);result[state]=returner(function(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[{}];var data=states[state]||{tag:"div"};var els=result.els.slice(finish,start+ONE);if(type(data)===objectType){data.state=state;data["data-o-init"]=initN}var newEl=function newEl(n){var prop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(type(data)===objectType){return D.createElement(data.tag||"div")}else{i=D.createElement("div");i.innerHTML=type(data)===functionType?data(prop):data;if(i.children.length>ONE||!i.firstElementChild){i.dataset.oInit=n;return i}else{i.firstElementChild.dataset.oInit=n;return i.firstElementChild}}};!props.length?props=[props]:"";var creation=!els[ZERO]&&state==="render";props=props.map(function(prop,i){prop.self=result;prop.o=o;prop.i=prop.i===u?i:prop.i;if(creation){els.push(newEl(initN,prop))}return prop});if(creation){result.els=els;setResultVals(false)}if(els){j=els.length===props.length;els.map(function(el,i){props[j?i:ZERO].i=i+finish;var buff=type(data)===functionType?data(props[j?i:ZERO]):data;if(type(buff)===objectType){transform(el,buff,props[j?i:ZERO])}})}})})});result.initState=returner(function(state,props){result.init(state).render(props)});result.sample=returner(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"render";var attrs=result.els[finish].attributes,ds=result.els[finish].dataset,res={tag:result.els[finish].tagName,html:result.els[finish].innerHTML,dataset:{}};var _iterator=_createForOfIteratorHelper(attrs),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var attr=_step.value;if(attr.nodeName.substring(ZERO,5)!=="data-"){res[attr.nodeName]=attr.value}}}catch(err){_iterator.e(err)}finally{_iterator.f()}cycleObj(ds,function(data){res.dataset[data]=ds[data]});return _defineProperty({},state,res)});result.select=returner(function(i){if(i===u){i=result.length-ONE}start=i;finish=i;result.el=result.els[i];select=ONE});result.all=returner(function(){start=result.length-ONE;finish=ZERO;result.el=result.els[ZERO];select=ZERO});result.remove=returner(function(j){if(j===u&&select){j=finish}if(j!==u){result.els[j].parentNode.removeChild(result.els[j])}else{iterator(function(){result.els[i].parentNode.removeChild(result.els[i])})}setResultVals(false)});result.skip=returner(function(j){if(j===u){j=finish}result.els.splice(i,ONE);setResultVals()});result.add=returner(function(el,l){if(type(el)==="string"&&el!==""){var _result$els;(_result$els=result.els).push.apply(_result$els,_toConsumableArray(getObjs(el)))}else if(type(el)===objectType){if(el.tagName){result.els.push(el)}else if(el.els){var _result$els2;(_result$els2=result.els).push.apply(_result$els2,_toConsumableArray(el.els))}else if(el.length&&el[ZERO].tagName){var _result$els3;(_result$els3=result.els).push.apply(_result$els3,_toConsumableArray(el))}}else if(type(el)==="number"&&o.inits[el]){result=o.inits[el]}setResultVals(false);if(result.initID!==u){result.dataset({oInit:result.initID})}});result.appendInside=returner(function(el){iterator(function(){toEl(el).appendChild(result.els[i])})});result.appendBefore=returner(function(el){iterator(function(){toEl(el).parentNode.insertBefore(result.els[i],toEl(el))})});result.appendAfter=returner(function(el){iterator(function(){var _toEl;(_toEl=toEl(el)).after.apply(_toEl,_toConsumableArray(result.els))})});result.find=returner(function(){var innerQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var newEls=[];iterator(function(){newEls.push.apply(newEls,_toConsumableArray(Array.from(result.els[i].querySelectorAll(":scope "+innerQuery))))});result.els=newEls;setResultVals()});result.first=returner(function(){var innerQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var buff=u;var newEls=[];iterator(function(){buff=result.els[i].querySelector(innerQuery);if(buff){newEls.push(buff)}});result.els=newEls;setResultVals()});result.attr=returner(function(attr,val){if(attr){if(val===u){var attrs=[];iterator(function(){attrs[i]=result.els[i].getAttribute(attr)});return select?attrs[ZERO]:attrs}else if(val!==""){iterator(function(){result.els[i].setAttribute(attr,val)})}else{iterator(function(){result.els[i].removeAttribute(attr)})}}});result.attrs=returner(function(){var res=[];iterator(function(){var obj={};_toConsumableArray(result.els[i].attributes).forEach(function(attr){obj[attr.nodeName]=attr.nodeValue});res.push(obj)});return select?res[ZERO]:res});result.dataset=returner(function(values){if(_typeof(values)===objectType){iterator(function(){cycleObj(values,function(data){result.els[i].dataset[data]=values[data]})})}else{var res=[];iterator(function(){res.push(_objectSpread({},result.els[i].dataset))});return select?res[ZERO]:res}});result.style=returner(function(val){result.attr("style",val)});result.css=returner(function(){var styles=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var val="";cycleObj(styles,function(style){val+=style+":"+styles[style].replace('"',"'")+";"});result.style(val)});result.setClass=returner(function(cl){iterator(function(){result.els[i].setAttribute("class",cl)})});result.addClass=returner(function(cl){iterator(function(){result.els[i].classList.add(cl)})});result.removeClass=returner(function(cl){iterator(function(){result.els[i].classList.remove(cl)})});result.toggleClass=returner(function(cl,check){iterator(function(){result.els[i].classList.toggle(cl,check)})});result.haveClass=function(cl){var res=true;iterator(function(){if(!result.els[i].classList.contains(cl)){res=false}});return res};result.innerHTML=returner(function(html){if(html!==u){iterator(function(){result.els[i].innerHTML=html})}else{var res="";iterator(function(){res+=result.els[i].innerHTML});return res}});result.innerText=returner(function(){var text=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";iterator(function(){result.els[i].innerText=text})});result.textContent=returner(function(){var text=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";iterator(function(){result.els[i].textContent=text})});result.html=returner(function(value){if(value){result.innerHTML(value)}else{var html="";iterator(function(){html+=result.els[i].outerHTML});return html}});result.forEach=returner(function(f){result.initState(f)});result.on=returner(function(a,b,c,d){a.split(", ").forEach(function(ev){iterator(function(){result.els[i].addEventListener(ev,b,c,d)});if(!result.ie[ev]){result.ie[ev]=[]}result.ie[ev].push([b,c,d])})});result.off=returner(function(a,b,c){a.split(", ").forEach(function(ev){iterator(function(){result.els[i].removeEventListener(ev,b,c)});if(result.ie[ev]){result.ie[ev]=result.ie[ev].filter(function(f){return f[ZERO]!==b})}})});result.onAll=returner(function(type,off){cycleObj(result.ie,function(ev,events){if(!type||type===ev){events[ev].forEach(function(data){iterator(function(){if(off){result.els[i].removeEventListener(ev,data[ZERO])}else{result.els[i].addEventListener(ev,data[ZERO],data[ONE],data[TWO])}})})}})});result.offAll=returner(function(type){result.onAll(type,ONE)});if(query)result.add(query);result.take=function(innerQuery){result.add(innerQuery);if(result.el){var initID=result.el.dataset["oInit"];if(initID!==u&&o.inits[initID]){if(result.length===ONE){j=result.els[ZERO];Object.assign(result,o.inits[initID]);result.els=[j]}else{result=o.inits[initID]}setResultVals(false,result.els);return result}}};return result};o.first=function(query){return o(document.querySelector(query)||"")};o.inits=[];o.errors=[];o.showErrors=false;o.logErrors=function(){o.errors.length?o.errors.forEach(function(e){return console.log(e)}):console.log("No errors")};o.onError=function(e){o.showErrors?console.log(e):o.errors.push(e)};o.init=function(states){return o().init(states)};o.initState=function(state,props){return o().init(state).render(props)};o.take=function(query){return o().take(query)};o.Z=0;o.N=1;o.W=2;o.H=100;o.F=false;o.C=function(a,b){return Object.hasOwnProperty.call(a,b)};o.ajax=function(url){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var row=new URLSearchParams;if(props.data&&_typeof(props.data)==="object"){for(var param in props.data){if(o.C(props.data,param)){if(_typeof(props.data[param])==="object"){row.set(param,encodeURIComponent(JSON.stringify(props.data[param])))}else{row.set(param,props.data[param])}}}if(props.method==="GET"||props.method==="get"){url+="?"+row.toString()}else if(!props.body){props.body=row}delete props.data}return fetch(url,props)};o.get=function(url){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return o.ajax(url,_objectSpread(_objectSpread({},props),{},{method:"GET"}))};o.post=function(url){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return o.ajax(url,_objectSpread(_objectSpread({},props),{},{method:"POST"}))};o.getParams=function(key){var params={};var paramsRaw=new URLSearchParams(window.location.search).entries();var _iterator2=_createForOfIteratorHelper(paramsRaw),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var entry=_step2.value;params[entry[o.Z]]=entry[o.N]}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}return key?params[key]:params};o.incCache=true;o.incCacheExp=1e3*60*60*24;o.incTimeout=6e3;o.incSource="";o.incForce=o.F;o.incAsync=true;o.incCors=o.F;o.incFns={};o.incSet=[o.Z];o.incReady=[o.Z];o.incN=o.Z;o.incCheck=function(){var set=arguments.length>0&&arguments[0]!==undefined?arguments[0]:0;var fnId=arguments.length>1?arguments[1]:undefined;var loaded=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;if(!loaded&&set&&fnId===o.U&&o.incReady[set]){return o.incSet[set]===o.N}if(o.incReady[set]===o.U||o.incReady[set][fnId]===o.U){return o.F}o.incReady[set][fnId].loaded=loaded;o.incFns[o.incReady[set][fnId].name]=loaded;o.incReady[set][o.Z]+=loaded;if(set&&o.incReady[set].length===o.incReady[set][o.Z]){if(typeof o.incSet[set]==="function"){o.incSet[set](set)}o.incSet[set]=o.N}return o.incSet[set]===o.N};o.incCacheClear=function(){var all=arguments.length>0&&arguments[0]!==undefined?arguments[0]:o.F;for(var name in o.incFns){if(o.C(o.incFns,name)){localStorage.removeItem("inc-"+name);localStorage.removeItem("inc-"+name+"Expires")}}if(all){o.incReady.forEach(function(val,i){if(i){val.forEach(function(a,j){if(j){o("#oInc-"+i+"-"+j).remove()}})}});o.incN=o.Z;o.incFns={};o.incSet=[o.Z];o.incReady=[o.Z]}return true};o.inc=function(sources,callBack,callBad){var sourcesN=o.Z,sourcesReady=o.Z;var f="function",FOUR=4,no=-1;if(_typeof(sources)!=="object"||!sources){return o.incSet[o.Z]}o.incSet[o.Z]++;var setN=o.incSet[o.Z];o.incSet[setN]=callBack||o.Z;o.incReady[setN]=[];var fnsStatus=o.incReady[setN];fnsStatus[o.Z]=o.N;var fnId={};var _loop=function _loop(name){if(o.C(sources,name)){sourcesN++;o.incN++;var tag=sources[name].indexOf(".css")>no?"style":"script";sources[name]=(o.incSource?o.incSource+"/":"")+sources[name];if(isNaN(name)&&o.C(o.incFns,name)&&o.incFns[name]&&!o.incForce){fnsStatus[sourcesN]={name:name,loaded:o.N};sourcesReady++;return 1}fnsStatus[sourcesN]={name:name,loaded:o.Z};if(isNaN(name)){o.incFns[name]=o.Z}if(isNaN(name)&&o.incCache&&sources[name].substring(o.Z,FOUR)!=="http"&&window.location.protocol!=="file:"&&(sources[name].indexOf(".css")>no||sources[name].indexOf(".js")>no)){var ls=localStorage,script=ls.getItem("inc-"+name),cacheSavedTill=ls.getItem("inc-"+name+"Expires");if(script&&cacheSavedTill&&(new Date).getTime()<cacheSavedTill){o.initState({tag:tag,id:"oInc-"+setN+"-"+sourcesN,innerHTML:script,"data-o-inc":setN}).appendInside("head");fnsStatus[sourcesN].loaded=o.N;o.incFns[name]=o.N;sourcesReady++}else{fnId[name]=sourcesN;o.get(sources[name],{mode:o.incCors?"cors":"same-origin"}).then(function(response){if(response.status!==200){o.onError?o.onError({message:o.incSource+sources[name]+" was not loaded"}):"";return}response.text().then(function(script){ls.setItem("inc-"+name,script);ls.setItem("inc-"+name+"Expires",(new Date).getTime()+o.incCacheExp);o.initState({tag:tag,id:"oInc-"+setN+"-"+fnId[name],innerHTML:script,"data-o-inc":setN}).appendInside("head");o.incCheck(setN,fnId[name],o.N)})})}}else{var state={tag:tag,id:"oInc-"+setN+"-"+sourcesN,"data-o-inc":setN,"async":o.incAsync,onload:"o.incCheck("+setN+","+sourcesN+",1)"};if(sources[name].indexOf(".css")>no){state.tag="link";state.rel="stylesheet";state.href=sources[name]}else if(sources[name].indexOf(".js")>no){state.src=sources[name]}else{state.tag="img";state.style="display:none;";state.src=sources[name]}o.initState(state).appendInside(state.style?"body":"head")}}};for(var name in sources){if(_loop(name))continue}fnsStatus[o.Z]+=sourcesReady;if(sourcesN!==o.Z){if(sourcesReady===sourcesN){if(_typeof(callBack)===f){callBack(setN)}}else{setTimeout(function(set){if(o.incReady[set]&&o.incReady[set].length<o.incReady[set][o.Z]){o.incSet[set]=o.Z;if(_typeof(callBad)===f){callBad(setN)}}},o.incTimeout,setN)}}return 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(){var title=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";var testN=o.tLog.length;for(var _len=arguments.length,tests=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){tests[_key-1]=arguments[_key]}var waits=0,preOk="├ OK: ",preXx="├ ✘ ",posOk="\n",posXx="\n",num=tests.length,done=o.Z;if(typeof tests[num-o.N]==="function"){o.tFns[testN]=tests[num-o.N];num--}if(o.tStyled){o.tLog[testN]="<div><b>"+title+" #"+testN+"</b></div>";preOk=o.tPre+o.tOk;preXx=o.tPre+o.tXx;posOk=o.tDc;posXx=posOk+posOk}else{o.tLog[testN]=title+" #"+testN+"\n"}o.tRes[testN]=o.F;o.tStatus[testN]=[];for(var i=o.Z;i<num;i++){var testInfo={n:testN,i:i,title:tests[i][o.Z],tShowOk:o.tShowOk,tStyled:o.tStyled};var res=tests[i][o.N];if(typeof res==="function"){try{res=res(testInfo)}catch(error){res=error.message;if(o.onError){o.onError(error)}}}o.tStatus[testN][i]=typeof res==="string"?o.F:res;if(res===true){done++;if(o.tShowOk){o.tLog[testN]+=preOk+tests[i][o.Z]+posOk}}else if(res!==o.U){o.tLog[testN]+=preXx+tests[i][o.Z]+(res!==o.F?": <i>"+res+"</i>":"")+posXx}else{waits++;setTimeout(function(info){info.title+=" (timeout)";o.testUpdate(info)},o.tTime,testInfo)}}o.tRes[testN]=done===num;if(o.tStyled){o.tLog[testN]+=o.tPre+'<div style="color:'+(done+waits!==num?"red":"green")+';"><b>'}else{o.tLog[testN]+=waits?"├":"└ "}o.tLog[testN]+="DONE "+done+"/"+(num-waits);if(waits){o.tLog[testN]+=", waiting: "+waits}if(o.tStyled){o.tLog[testN]+="</b>"+o.tDc+o.tDc}else{o.tLog[testN]+="\n"}if(!waits&&typeof o.tFns[testN]==="function"){o.tFns[testN](testN)}return testN};o.testUpdate=function(info){var res=arguments.length>1&&arguments[1]!==undefined?arguments[1]:o.F;var suff=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"";if(o.tStatus[info.n][info.i]===o.U){o.tStatus[info.n][info.i]=res===true;if(res===true){if(info.tShowOk){if(info.tStyled){o.tLog[info.n]+=o.tPre+o.tOk+info.title+suff+o.tDc}else{o.tLog[info.n]+="└ OK: "+info.title+suff+"\n"}}}else{o.tRes[info.n]=o.F;if(info.tStyled){o.tLog[info.n]+=o.tPre+o.tXx+info.title+suff+(res?": "+res:"")+o.tDc+o.tDc}else{o.tLog[info.n]+="└ ✘ "+info.title+(res?": "+res:"")+suff+"\n"}}var fails=o.Z,n=fails;var _iterator3=_createForOfIteratorHelper(o.tStatus[info.n]),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var s=_step3.value;if(s===o.U){return}if(!s){fails++}n++}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}o.tRes[info.n]=!fails;var text=fails?"FAILED "+fails+"/"+n:"DONE "+n+"/"+n;if(info.tStyled){o.tLog[info.n]+=o.tPre+'<b style="color:'+(!fails?"green":"red")+';">'+text+"</b>"+o.tDc}else{o.tLog[info.n]+="└ "+text}if(typeof o.tFns[info.n]==="function"){o.tFns[info.n](info.n)}}};
5
5
 
6
6
  if (typeof module !== 'undefined' && module.exports) {
7
7
  o.default = o;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "objs-core",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
+ "description": "Encreases coding speed, by lightweight samples, states control, caching and auto tests. Easy to use: just split design into samples, their states and give them data for rendering. Also Objs can create samples from server rendered DOM to increase application's loading speed.",
4
5
  "homepage": "https://fous.name/objs/",
5
6
  "repository": {
6
7
  "type": "git",
@@ -13,24 +14,23 @@
13
14
  },
14
15
  "main": "objs.npm.1.0.js",
15
16
  "scripts": {
16
- "test": "https://fous.name/objs/documentation/"
17
+ "test": "node tests.js"
17
18
  },
19
+ "dependencies": {},
18
20
  "keywords": [
19
- "objs",
20
21
  "fast coding",
21
- "optimisation",
22
22
  "samples",
23
- "test",
23
+ "state control",
24
+ "lightweight",
25
+ "optimisation",
26
+ "auto test",
24
27
  "script cache",
25
28
  "optimize",
26
29
  "fast develop",
27
- "lightweight",
28
- "library",
29
30
  "sample",
30
- "state",
31
31
  "ajax",
32
32
  "caching",
33
- "dom control"
34
- ],
35
- "description": "JS library for fast develop, states control and optimisation with auto tests."
33
+ "dom control",
34
+ "objs"
35
+ ]
36
36
  }
package/tests.js ADDED
@@ -0,0 +1 @@
1
+ console.log("It's a DOM dependent library, all tests are here: https://fous.name/objs/documentation/");