cradova 1.2.0 → 1.3.0

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/dist/index.js CHANGED
@@ -3,10 +3,12 @@ var Screen = class {
3
3
  constructor(cradova_screen_initials) {
4
4
  this.packed = false;
5
5
  this.secondaryChildren = [];
6
+ this.template = document.createElement("div");
6
7
  this.persist = true;
7
8
  this.rendered = false;
9
+ this.pushed = false;
8
10
  this.effects = [];
9
- const { template, name, callBack, transition, persist } = cradova_screen_initials;
11
+ const { template, name, transition, persist } = cradova_screen_initials;
10
12
  if (typeof template !== "function") {
11
13
  throw new Error(
12
14
  " \u2718 Cradova err: only functions that returns a cradova element is valid as screen"
@@ -14,28 +16,33 @@ var Screen = class {
14
16
  }
15
17
  this.html = template.bind(this);
16
18
  this.name = name;
17
- this.template = document.createDocumentFragment();
18
- this.callBack = callBack;
19
+ this.template.id = "cradova-screen-set";
19
20
  this.transition = transition;
20
21
  if (typeof persist === "boolean") {
21
22
  this.persist = persist;
22
23
  }
23
24
  }
24
25
  effect(fn) {
25
- if (!this.rendered) {
26
- this.effects.push(fn);
26
+ if (!this.rendered && !this.pushed) {
27
+ this.effects.push(
28
+ new Promise(async (res, rej) => {
29
+ try {
30
+ res(await fn());
31
+ } catch (error) {
32
+ rej(error);
33
+ }
34
+ })
35
+ );
27
36
  }
28
37
  }
29
38
  async effector() {
30
- if (!this.rendered) {
31
- this.rendered = true;
32
- for (let fnIdex = 0; fnIdex < this.effects.length; fnIdex++) {
33
- const fn = this.effects[fnIdex];
34
- const data = await fn();
35
- if (data) {
36
- await this.Activate(data, true);
37
- }
38
- }
39
+ if (this.rendered) {
40
+ await Promise.allSettled(this.effects);
41
+ }
42
+ }
43
+ async updateState(data) {
44
+ if (this.rendered) {
45
+ await this.Activate(data, true);
39
46
  }
40
47
  }
41
48
  async package(data) {
@@ -61,7 +68,7 @@ var Screen = class {
61
68
  );
62
69
  }
63
70
  if (this.secondaryChildren.length) {
64
- this.template.append(...this.secondaryChildren);
71
+ this.template.append(this.secondaryChildren);
65
72
  }
66
73
  }
67
74
  onActivate(cb) {
@@ -73,12 +80,20 @@ var Screen = class {
73
80
  this.secondaryChildren.push(addOns[i]);
74
81
  }
75
82
  if (addOns[i] && typeof addOns[i] === "function") {
76
- this.secondaryChildren.push(addOns[i]());
83
+ let a = addOns[i]();
84
+ if (a && a instanceof HTMLElement) {
85
+ this.secondaryChildren.push(a);
86
+ }
87
+ if (addOns[i] && typeof addOns[i] === "function") {
88
+ a = a();
89
+ if (a && a instanceof HTMLElement) {
90
+ this.secondaryChildren.push(a);
91
+ }
92
+ }
77
93
  }
78
94
  }
79
95
  }
80
96
  deActivate() {
81
- this.template.parentElement?.removeChild(this.template);
82
97
  if (!this.persist) {
83
98
  this.rendered = false;
84
99
  }
@@ -93,21 +108,32 @@ var Screen = class {
93
108
  this.packed = true;
94
109
  }
95
110
  }
96
- if (force) {
111
+ if (this.persist && force) {
97
112
  await this.package(data);
98
113
  this.packed = true;
99
114
  this.rendered = false;
100
115
  }
116
+ if (!this.pushed) {
117
+ this.pushed = true;
118
+ }
101
119
  document.title = this.name;
102
120
  const doc = document.querySelector("[data-cra-id=cradova-app-wrapper]");
121
+ if (!doc) {
122
+ throw new Error(
123
+ " \u2718 Cradova err: Unable to render, cannot find cradova root [data-cra-id=cradova-app-wrapper]"
124
+ );
125
+ }
103
126
  doc?.replaceChildren(this.template);
104
127
  if (!this.persist) {
105
128
  this.packed = false;
106
129
  }
107
- await this.effector();
108
- if (doc?.firstChild?.afterMount) {
109
- doc?.firstChild.afterMount();
110
- doc.firstChild.afterMount = void 0;
130
+ if (this.effects.length) {
131
+ await this.effector();
132
+ this.rendered = true;
133
+ }
134
+ if (doc?.firstChild?.firstChild?.afterMount) {
135
+ const c = doc?.firstChild;
136
+ c?.firstChild.afterMount();
111
137
  }
112
138
  if (this.callBack) {
113
139
  await this.callBack(data);
@@ -252,15 +278,15 @@ Router.route = function(path = "/", screen) {
252
278
  };
253
279
  };
254
280
  Router.navigate = function(href, data = null, force = false) {
255
- if (typeof data === "boolean") {
256
- force = true;
257
- data = null;
258
- }
259
281
  if (typeof href !== "string") {
260
282
  throw new TypeError(
261
283
  " \u2718 Cradova err: href must be a defined path but got " + href + " instead"
262
284
  );
263
285
  }
286
+ if (typeof data === "boolean") {
287
+ force = true;
288
+ data = null;
289
+ }
264
290
  let route = null, params, link = null;
265
291
  if (href.includes("://")) {
266
292
  window.location.href = href;
@@ -276,9 +302,9 @@ Router.navigate = function(href, data = null, force = false) {
276
302
  link = href;
277
303
  RouterBox["pageHide"] && RouterBox["pageHide"](href + " :navigated");
278
304
  window.history.pushState({}, "", link);
279
- setTimeout(async () => {
305
+ (async () => {
280
306
  await RouterBox.router(null, force);
281
- }, 0);
307
+ })();
282
308
  }
283
309
  }
284
310
  };
@@ -354,11 +380,11 @@ Router["onPageHide"] = function(callback) {
354
380
  }
355
381
  };
356
382
  Router.packageScreen = async function(path, data) {
357
- if (!Router.routes[path]) {
383
+ if (!RouterBox.routes[path]) {
358
384
  console.error(" \u2718 Cradova err: no screen with path " + path);
359
385
  throw new Error(" \u2718 Cradova err: cradova err: Not a defined screen path");
360
386
  }
361
- await Router.routes[path].packager(data);
387
+ await RouterBox.routes[path].packager(data);
362
388
  };
363
389
  window.addEventListener("pageshow", RouterBox.router);
364
390
  window.addEventListener("popstate", (e) => {
@@ -471,7 +497,7 @@ function media(value, ...properties) {
471
497
  aniStyleTag.innerHTML = totalAnimation;
472
498
  document.head.append(aniStyleTag);
473
499
  }
474
- function css(identifier, properties = {}) {
500
+ function css(identifier, properties) {
475
501
  if (typeof identifier === "string" && typeof properties === "undefined") {
476
502
  let styTag = document.querySelector("style");
477
503
  if (styTag !== null) {
@@ -484,6 +510,9 @@ function css(identifier, properties = {}) {
484
510
  document.head.append(styTag);
485
511
  return;
486
512
  }
513
+ if (!properties) {
514
+ return;
515
+ }
487
516
  const styS = "" + identifier + `{
488
517
  `;
489
518
  const styE = `}
@@ -617,40 +646,26 @@ var RefList = class {
617
646
  constructor(component) {
618
647
  this.stateID = uuid();
619
648
  this.parentElement = null;
620
- this.datas = [];
621
649
  this.component = component.bind(this);
622
650
  }
623
- stale(datas) {
624
- this.datas = datas;
625
- }
626
651
  r(d) {
627
652
  return this.render(d);
628
653
  }
629
- u(d) {
630
- return this.updateState(d);
631
- }
632
- render(datas) {
633
- if (datas) {
634
- this.datas = datas;
635
- }
636
- if (!this.datas) {
637
- throw new Error(
638
- " \u2718 Cradova err: RefList cannot be rendered without input"
639
- );
640
- }
641
- if (!Array.isArray(this.datas)) {
654
+ render(datas = []) {
655
+ if (!Array.isArray(datas)) {
642
656
  throw new Error(
643
657
  " \u2718 Cradova err: RefList cannot render non-array input"
644
658
  );
645
659
  }
646
660
  const elements = [];
647
- const data = this.datas.length;
661
+ const data = datas.length;
648
662
  for (let i = 0; i < data; i++) {
649
- elements.push(
650
- this.component(this.datas[i], i)({ stateID: this.stateID })
651
- );
663
+ elements.push(this.component(datas[i], i)({ stateID: this.stateID }));
652
664
  }
653
- return elements;
665
+ if (elements.length) {
666
+ return elements;
667
+ }
668
+ return lib_default("div")({ stateID: this.stateID });
654
669
  }
655
670
  updateState(datas) {
656
671
  if (!datas) {
@@ -702,12 +717,8 @@ var RefList = class {
702
717
  var Ref = class {
703
718
  constructor(component) {
704
719
  this.stateID = uuid();
705
- this.data = void 0;
706
720
  this.component = component.bind(this);
707
721
  }
708
- stale(data) {
709
- this.data = data;
710
- }
711
722
  r(d) {
712
723
  return this.render(d);
713
724
  }
@@ -715,10 +726,7 @@ var Ref = class {
715
726
  return this.updateState(d);
716
727
  }
717
728
  render(data) {
718
- if (data) {
719
- this.data = data;
720
- }
721
- const chtml = this.component(this.data);
729
+ const chtml = this.component(data);
722
730
  if (typeof chtml !== "function") {
723
731
  throw new Error(
724
732
  " \u2718 Cradova err : Invalid component type for cradova Ref, got - " + chtml
@@ -740,6 +748,18 @@ var Ref = class {
740
748
  `Cradova can't render component make sure it's a valid component`
741
749
  );
742
750
  }
751
+ if (typeof this.upcb !== "undefined" && element.afterMount) {
752
+ const afterMount = element.afterMount;
753
+ const upcb = this.upcb.bind(null, data);
754
+ element.afterMount = () => {
755
+ upcb();
756
+ afterMount();
757
+ };
758
+ } else {
759
+ if (this.upcb) {
760
+ element.afterMount = this.upcb.bind(null, data);
761
+ }
762
+ }
743
763
  return () => element;
744
764
  }
745
765
  instance() {
@@ -752,7 +772,7 @@ var Ref = class {
752
772
  cradovaDispatchTrackBreak: true
753
773
  });
754
774
  }
755
- onStateUpdate(cb) {
775
+ effect(cb) {
756
776
  this.upcb = cb;
757
777
  }
758
778
  updateState(data) {
@@ -796,7 +816,7 @@ var Ref = class {
796
816
  fn(element, data);
797
817
  }
798
818
  } catch (e0) {
799
- console.log(e0);
819
+ console.warn(e0);
800
820
  }
801
821
  if (this.upcb) {
802
822
  this.upcb(data);
@@ -806,7 +826,7 @@ var Ref = class {
806
826
  dispatch(this.stateID, { remove: true });
807
827
  }
808
828
  };
809
- var frag = function(children) {
829
+ var frag = function(...children) {
810
830
  const par = document.createDocumentFragment();
811
831
  for (let i = 0; i < children.length; i++) {
812
832
  if (typeof children[i] === "function") {
@@ -915,12 +935,12 @@ function cradovaDispatchTrack(nodes, state) {
915
935
  }
916
936
  if (Array.isArray(state[key])) {
917
937
  throw new TypeError(
918
- " \u2718 Cradova err: invalid tree element type, should be a single element or parent element from cradova"
938
+ " \u2718 Cradova err: invalid tree element type, should be a single element or parent element from cradova"
919
939
  );
920
940
  }
921
941
  if (!(state[key] instanceof HTMLElement)) {
922
942
  console.error(
923
- " \u2718 Cradova err: wrong element type: can't update tree using " + state[key]
943
+ " \u2718 Cradova err: wrong element type: can't update tree using " + state[key]
924
944
  );
925
945
  throw new TypeError(
926
946
  " \u2718 Cradova err: invalid element, should be a html element from cradova"
@@ -929,8 +949,22 @@ function cradovaDispatchTrack(nodes, state) {
929
949
  element.replaceChildren(state[key]);
930
950
  continue;
931
951
  }
932
- element[key] = state[key];
952
+ try {
953
+ if (typeof element[key] !== "undefined") {
954
+ element[key] = state[key];
955
+ } else {
956
+ element[key] = state[key];
957
+ if (key !== "afterMount" && key !== "for" && key !== "text" && key !== "class" && !key.includes("aria")) {
958
+ console.error(" \u2718 Cradova err: invalid html attribute " + key);
959
+ }
960
+ }
961
+ } catch (error) {
962
+ console.error(" \u2718 Cradova err: Cradova got ", state);
963
+ console.error(" \u2718 Cradova err: ", error);
964
+ }
933
965
  }
966
+ } else {
967
+ throw new TypeError(" \u2718 Cradova err: invalid state object" + state);
934
968
  }
935
969
  }
936
970
  }
@@ -1134,12 +1168,10 @@ var createSignal = class {
1134
1168
 
1135
1169
  // lib/scripts/simplestore.ts
1136
1170
  var simpleStore = class {
1137
- constructor(initial, ref) {
1171
+ constructor(initial) {
1172
+ this.ref = [];
1138
1173
  this.value = null;
1139
1174
  this.value = initial;
1140
- if (ref) {
1141
- this.bindRef(ref);
1142
- }
1143
1175
  }
1144
1176
  set(value, shouldRefRender) {
1145
1177
  if (typeof value === "function") {
@@ -1147,8 +1179,30 @@ var simpleStore = class {
1147
1179
  } else {
1148
1180
  this.value = value;
1149
1181
  }
1150
- if (this.ref && shouldRefRender !== false) {
1151
- this.ref.updateState(this.value);
1182
+ if (this.ref.length && shouldRefRender !== false) {
1183
+ this.updateState();
1184
+ }
1185
+ }
1186
+ bind(prop) {
1187
+ if (typeof this.value === "object" && typeof this.value[prop] !== "undefined") {
1188
+ return [this, prop];
1189
+ } else {
1190
+ throw new Error(
1191
+ "\u2718 Cradova err : can't bind an unavailable property! " + prop
1192
+ );
1193
+ }
1194
+ }
1195
+ updateState(name) {
1196
+ if (name) {
1197
+ const entry = this.ref.find((ent) => ent.prop === name);
1198
+ if (entry) {
1199
+ entry.ref.updateState({ [entry.key]: this.value[entry.prop] });
1200
+ }
1201
+ } else {
1202
+ for (let i = 0; i < this.ref.length; i++) {
1203
+ const entry = this.ref[i];
1204
+ entry.ref.updateState({ [entry.prop]: this.value[entry.prop] });
1205
+ }
1152
1206
  }
1153
1207
  }
1154
1208
  setKey(name, value, shouldRefRender) {
@@ -1158,19 +1212,21 @@ var simpleStore = class {
1158
1212
  } else {
1159
1213
  this.value[name] = value;
1160
1214
  }
1161
- if (this.ref && shouldRefRender !== false) {
1162
- this.ref.updateState(this.value);
1215
+ if (this.ref.length && shouldRefRender !== false) {
1216
+ this.updateState(name);
1163
1217
  }
1164
1218
  }
1165
1219
  }
1166
- bindRef(Ref2) {
1167
- if (Ref2 && Ref2.updateState) {
1168
- this.ref = Ref2;
1169
- if (Ref2.stale) {
1170
- Ref2.stale(this.value);
1220
+ bindRef(ref, key, prop) {
1221
+ if (ref && ref.updateState && prop) {
1222
+ this.ref.push({ prop, ref, key });
1223
+ if (ref.reader) {
1224
+ ref.render = ref.render.bind(ref, this.value);
1171
1225
  }
1172
1226
  } else {
1173
- throw new Error("\u2718 Cradova err : Invalid ref component" + Ref2);
1227
+ throw new Error(
1228
+ "\u2718 Cradova err : Invalid parameters for binding ref to simple store"
1229
+ );
1174
1230
  }
1175
1231
  }
1176
1232
  };
@@ -1609,72 +1665,134 @@ var make = function(txx) {
1609
1665
  return { tag, className, ID, innerValue };
1610
1666
  };
1611
1667
  var _ = (...element_initials) => {
1612
- let firstProps, firstLevelChildren = [], beforeMount;
1613
- if (typeof element_initials[1] === "object" && !Array.isArray(element_initials[1])) {
1614
- firstProps = element_initials[1];
1615
- if (firstProps?.beforeMount) {
1616
- beforeMount = firstProps["beforeMount"];
1617
- firstProps["beforeMount"] = void 0;
1618
- }
1619
- if (element_initials.length > 2) {
1620
- firstLevelChildren = element_initials.slice(2, element_initials.length);
1621
- }
1622
- } else {
1623
- firstLevelChildren = element_initials.slice(1, element_initials.length);
1624
- }
1625
1668
  if (element_initials[0].raw) {
1626
1669
  element_initials[0] = element_initials[0]["raw"][0];
1627
1670
  }
1628
- function identify(element_initials2) {
1629
- if (typeof element_initials2 !== "object") {
1630
- element_initials2 = [element_initials2];
1631
- }
1632
- const initials = make(element_initials2[0]);
1633
- return (...incoming) => {
1634
- let secondLevelChildren = [], props = {}, text;
1635
- for (let i = 0; i < incoming.length; i++) {
1636
- if (typeof incoming[i] === "object" && !Array.isArray(incoming[1])) {
1637
- props = incoming[i];
1638
- if (incoming[i].beforeMount) {
1639
- beforeMount = incoming[i]["beforeMount"];
1640
- incoming[i]["beforeMount"] = void 0;
1671
+ if (typeof element_initials[0] !== "string") {
1672
+ console.error(" \u2718 Cradova err: NO TEMPLATE STRING PROVIDED");
1673
+ return () => " \u2718 NO TEMPLATE STRING PROVIDED";
1674
+ }
1675
+ let beforeMount = null, firstLevelChildren = [];
1676
+ if (element_initials.length > 1) {
1677
+ firstLevelChildren = element_initials.splice(1);
1678
+ }
1679
+ if (typeof element_initials !== "object") {
1680
+ element_initials = [element_initials];
1681
+ }
1682
+ return (...incoming) => {
1683
+ const initials = make(element_initials[0]);
1684
+ let secondLevelChildren = [], props = null, text = null;
1685
+ if (firstLevelChildren.length) {
1686
+ secondLevelChildren.push(...firstLevelChildren);
1687
+ }
1688
+ if (incoming.length) {
1689
+ secondLevelChildren.push(...incoming);
1690
+ }
1691
+ let element;
1692
+ try {
1693
+ element = document.createElement(initials.tag.trim());
1694
+ } catch (error) {
1695
+ throw new TypeError(
1696
+ " \u2718 Cradova err: invalid tag given " + initials.tag
1697
+ );
1698
+ }
1699
+ if (initials.className) {
1700
+ element.className = initials.className.trim();
1701
+ }
1702
+ if (initials.ID) {
1703
+ element.setAttribute("id", initials.ID.trim());
1704
+ }
1705
+ if (initials.innerValue) {
1706
+ element.innerText = initials.innerValue;
1707
+ }
1708
+ if (secondLevelChildren.length) {
1709
+ for (let i = 0; i < secondLevelChildren.length; i++) {
1710
+ if (typeof secondLevelChildren[i] === "function") {
1711
+ let child2 = secondLevelChildren[i]();
1712
+ if (typeof child2 === "function") {
1713
+ child2 = child2();
1714
+ }
1715
+ try {
1716
+ if (child2 instanceof HTMLElement || child2 instanceof DocumentFragment) {
1717
+ element.append(child2);
1718
+ }
1719
+ if (child2 && child2.afterMount) {
1720
+ child2.afterMount(child2);
1721
+ child2.afterMount = void 0;
1722
+ }
1723
+ } catch (error) {
1724
+ console.error(" \u2718 Cradova err: ", error);
1725
+ if (!(child2 instanceof HTMLElement)) {
1726
+ throw new Error(
1727
+ " \u2718 Cradova err: invalid child type: " + child2 + " (" + typeof child2 + ")"
1728
+ );
1729
+ }
1641
1730
  }
1642
1731
  continue;
1643
1732
  }
1644
- if (typeof incoming[i] === "function" || incoming[i] instanceof HTMLElement) {
1645
- secondLevelChildren.push(incoming[i]);
1733
+ if (secondLevelChildren[i] instanceof HTMLElement || secondLevelChildren[i] instanceof DocumentFragment) {
1734
+ element.append(secondLevelChildren[i]);
1646
1735
  continue;
1647
1736
  }
1648
- if (typeof incoming[i] === "string") {
1649
- text = incoming[i];
1737
+ if (Array.isArray(secondLevelChildren[i])) {
1738
+ const arrCX = secondLevelChildren[i];
1739
+ const arrCXLength = arrCX.length;
1740
+ const arrSET = [];
1741
+ for (let p = 0; p < arrCXLength; p++) {
1742
+ if (!(arrCX[p] instanceof HTMLElement) && typeof arrCX[p] !== "function" && !Array.isArray(arrCX[p])) {
1743
+ console.error(" \u2718 Cradova err: ", arrCX[p]);
1744
+ throw new TypeError(
1745
+ " \u2718 Cradova err: invalid tag type or template literal, cradova was enable to create this element show above \u21D1"
1746
+ );
1747
+ }
1748
+ arrSET.push(arrCX[p]);
1749
+ }
1750
+ secondLevelChildren = [
1751
+ ...secondLevelChildren.slice(0, i + 1),
1752
+ ...arrSET,
1753
+ ...secondLevelChildren.slice(i + 1, secondLevelChildren.length)
1754
+ ];
1650
1755
  continue;
1651
1756
  }
1652
- }
1653
- if (firstLevelChildren.length) {
1654
- secondLevelChildren.push(...firstLevelChildren);
1655
- }
1656
- let element;
1657
- try {
1658
- element = document.createElement(initials.tag.trim());
1659
- } catch (error) {
1660
- throw new TypeError(
1661
- " \u2718 Cradova err: invalid tag given " + initials.tag
1662
- );
1663
- }
1664
- if (initials.className) {
1665
- element.className = initials.className.trim();
1666
- }
1667
- if (initials.ID) {
1668
- element.setAttribute("id", initials.ID.trim());
1669
- }
1670
- if (initials.innerValue) {
1671
- element.innerText = initials.innerValue;
1672
- }
1673
- if (firstProps) {
1674
- for (const prp in firstProps) {
1675
- props[prp] = firstProps[prp];
1757
+ const child = secondLevelChildren[i];
1758
+ if (child instanceof HTMLElement || child instanceof DocumentFragment) {
1759
+ element.append(child);
1760
+ if (child.afterMount) {
1761
+ child.afterMount(child);
1762
+ child.afterMount = void 0;
1763
+ }
1764
+ } else {
1765
+ if (typeof child === "object" && !Array.isArray(child) && !(child instanceof HTMLElement)) {
1766
+ if (!props) {
1767
+ props = child;
1768
+ } else {
1769
+ const po = child;
1770
+ for (const p in po) {
1771
+ props[p] = po[p];
1772
+ }
1773
+ }
1774
+ continue;
1775
+ }
1776
+ if (typeof child === "string") {
1777
+ text = child;
1778
+ continue;
1779
+ }
1780
+ if (typeof child === "string" || typeof child === "number") {
1781
+ text = child;
1782
+ } else {
1783
+ console.error(" \u2718 Cradova err: got", child);
1784
+ throw new Error(
1785
+ " \u2718 Cradova err: invalid child type: (" + typeof child + ")"
1786
+ );
1787
+ }
1676
1788
  }
1677
1789
  }
1790
+ }
1791
+ if (props) {
1792
+ if (props.beforeMount) {
1793
+ beforeMount = props["beforeMount"];
1794
+ props["beforeMount"] = void 0;
1795
+ }
1678
1796
  for (const prop in props) {
1679
1797
  if (prop === "style" && typeof props[prop] === "object") {
1680
1798
  for (const [k, v] of Object.entries(props[prop])) {
@@ -1692,7 +1810,7 @@ var _ = (...element_initials) => {
1692
1810
  element.style[prop] = props[prop];
1693
1811
  continue;
1694
1812
  }
1695
- if (prop === "text" && typeof props[prop] === "string" && props[prop] !== "") {
1813
+ if (prop === "text" && (typeof props[prop] === "string" || typeof props[prop] === "number") && props[prop] !== "") {
1696
1814
  text = props[prop];
1697
1815
  continue;
1698
1816
  }
@@ -1713,6 +1831,11 @@ var _ = (...element_initials) => {
1713
1831
  element.setAttribute("data-" + prop.split("$")[1], props[prop]);
1714
1832
  continue;
1715
1833
  }
1834
+ if (Array.isArray(props[prop]) && props[prop][0] instanceof simpleStore) {
1835
+ element.updateState = dispatch.bind(null, element);
1836
+ props[prop][0].bindRef(element, prop, props[prop][1]);
1837
+ continue;
1838
+ }
1716
1839
  if (prop === "shouldUpdate" && props[prop] === true) {
1717
1840
  element.updateState = dispatch.bind(null, element);
1718
1841
  continue;
@@ -1722,92 +1845,24 @@ var _ = (...element_initials) => {
1722
1845
  element[prop] = props[prop];
1723
1846
  } else {
1724
1847
  element[prop] = props[prop];
1725
- if (prop !== "afterMount" && prop !== "for" && !prop.includes("aria")) {
1848
+ if (prop !== "afterMount" && prop !== "for" && prop !== "text" && prop !== "class" && !prop.includes("aria")) {
1726
1849
  console.error(" \u2718 Cradova err: invalid html attribute " + prop);
1727
1850
  }
1728
1851
  }
1729
1852
  } catch (error) {
1853
+ console.error(" \u2718 Cradova err: Cradova got ", props);
1730
1854
  console.error(" \u2718 Cradova err: ", error);
1731
1855
  }
1732
1856
  }
1733
- if (secondLevelChildren.length) {
1734
- for (let i = 0; i < secondLevelChildren.length; i++) {
1735
- if (typeof secondLevelChildren[i] === "function") {
1736
- let child2 = secondLevelChildren[i]();
1737
- if (typeof child2 === "function") {
1738
- child2 = child2();
1739
- }
1740
- try {
1741
- if (child2) {
1742
- element.append(child2);
1743
- }
1744
- if (child2 && child2.afterMount) {
1745
- child2.afterMount(child2);
1746
- child2.afterMount = void 0;
1747
- }
1748
- } catch (error) {
1749
- console.error(" \u2718 Cradova err: ", error);
1750
- if (!(child2 instanceof HTMLElement)) {
1751
- throw new Error(
1752
- " \u2718 Cradova err: invalid child type: " + child2 + " (" + typeof child2 + ")"
1753
- );
1754
- }
1755
- }
1756
- continue;
1757
- }
1758
- if (Array.isArray(secondLevelChildren[i])) {
1759
- const arrCX = secondLevelChildren[i];
1760
- const arrCXLength = arrCX.length;
1761
- const arrSET = [];
1762
- for (let p = 0; p < arrCXLength; p++) {
1763
- if (!(arrCX[p] instanceof HTMLElement) && typeof arrCX[p] !== "function" && !Array.isArray(arrCX[p])) {
1764
- console.error(" \u2718 Cradova err: ", arrCX[p]);
1765
- throw new TypeError(
1766
- " \u2718 Cradova err: invalid tag type or template literal, cradova was enable to create this element show above \u21D1"
1767
- );
1768
- }
1769
- arrSET.push(arrCX[p]);
1770
- }
1771
- secondLevelChildren = [
1772
- ...secondLevelChildren.slice(0, i + 1),
1773
- ...arrSET,
1774
- ...secondLevelChildren.slice(i + 1, secondLevelChildren.length)
1775
- ];
1776
- continue;
1777
- }
1778
- const child = secondLevelChildren[i];
1779
- if (child instanceof HTMLElement || child instanceof DocumentFragment) {
1780
- element.append(child);
1781
- if (child.afterMount) {
1782
- child.afterMount(child);
1783
- child.afterMount = void 0;
1784
- }
1785
- } else {
1786
- if (typeof child === "string") {
1787
- text = child;
1788
- } else {
1789
- console.error(" \u2718 Cradova err: got", child);
1790
- throw new Error(
1791
- " \u2718 Cradova err: invalid child type: (" + typeof child + ")"
1792
- );
1793
- }
1794
- }
1795
- }
1796
- }
1797
- if (text) {
1798
- element.innerText = text;
1799
- }
1800
- if (beforeMount) {
1801
- beforeMount(element);
1802
- }
1803
- return element;
1804
- };
1805
- }
1806
- if (typeof element_initials[0] !== "string") {
1807
- console.error(" \u2718 Cradova err: NO TEMPLATE STRING PROVIDED");
1808
- return () => " \u2718 NO TEMPLATE STRING PROVIDED";
1809
- }
1810
- return identify(element_initials);
1857
+ }
1858
+ if (text) {
1859
+ element.innerText = text;
1860
+ }
1861
+ if (beforeMount) {
1862
+ beforeMount(element);
1863
+ }
1864
+ return element;
1865
+ };
1811
1866
  };
1812
1867
  Init();
1813
1868
  var lib_default = _;
@@ -1833,7 +1888,6 @@ export {
1833
1888
  fullScreen,
1834
1889
  loadCradovaUICss,
1835
1890
  ls,
1836
- make,
1837
1891
  media,
1838
1892
  simpleStore,
1839
1893
  swipe,