cradova 3.1.2 → 3.1.4

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/LICENSE CHANGED
@@ -2,180 +2,180 @@
2
2
  Version 2.0, January 2004
3
3
  http://www.apache.org/licenses/
4
4
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
179
 
180
180
  To apply the Apache License to your work, attach the following
181
181
  boilerplate notice, with the fields enclosed by brackets "[]"
@@ -186,16 +186,16 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [yyyy] [name of copyright owner]
189
+ Copyright 2023 friday candour
190
190
 
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
194
 
195
195
  http://www.apache.org/licenses/LICENSE-2.0
196
196
 
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -43,13 +43,13 @@ Cradova is a web development framework for building Single Page Applications and
43
43
 
44
44
  It's a fast and simple framework, it provides an easy to use state management and router system.
45
45
 
46
- Cradova follows the [VJS specification](https://github.com/fridaycandour/cradova/blob/main/spec.md)
46
+ Cradova follows the [VJS specification](https://github.com/FridayCandour/cradova/blob/main/VJS_spec/spec.md)
47
47
 
48
48
  ## What's the benefit?
49
49
 
50
50
  Cradova is aimed to be fast and simple with and fewer abstractions and yet easily composable.
51
51
 
52
- Cradova is not built on visual DOM or diff algorithms.
52
+ Cradova is not built on virtual DOM or diff algorithms.
53
53
  Instead, State management is done more elegantly with a simple predictive model, simple and easy with all the speed.
54
54
 
55
55
  ## Is this a big benefit?
@@ -62,24 +62,21 @@ Cradova has already been utilized in multiple production projects, and we will c
62
62
 
63
63
  ## Installation
64
64
 
65
+ ### From npm
66
+
67
+ ```bash
68
+ npm i cradova
69
+ ```
70
+
65
71
  ### CDN sources
66
72
 
67
73
  ```html
68
74
  <!-- unpkg -->
69
-
70
75
  <script src="https://unpkg.com/cradova/dist/index.js"></script>
71
-
72
76
  <!-- js deliver -->
73
-
74
77
  <script src="https://cdn.jsdelivr.net/npm/cradova/dist/index.js"></script>
75
78
  ```
76
79
 
77
- ### npm
78
-
79
- ```bash
80
- npm i cradova
81
- ```
82
-
83
80
  ## Examples
84
81
 
85
82
  Many aspects of Cradova are not reflected in the following example. More functionality will be entailed in future docs.
@@ -155,7 +152,7 @@ function HelloMessage() {
155
152
  });
156
153
  }
157
154
 
158
- // using cradova Ref
155
+ // using CradovaRef
159
156
 
160
157
  const nameRef = new Ref(function (name) {
161
158
  const self = this;
@@ -190,8 +187,6 @@ function App() {
190
187
  return div(count, counter, dataCounter, HelloMessage, br, nameRef);
191
188
  }
192
189
 
193
- // add your app to the DOM
194
-
195
190
  document.body.append(App());
196
191
  ```
197
192
 
@@ -201,20 +196,26 @@ Let's see a simple TodoList example
201
196
 
202
197
  ```js
203
198
  import _, {
204
- button,
205
- createSignal,
206
- css,
199
+ // elements
207
200
  div,
208
- input,
201
+ button,
209
202
  main,
210
203
  p,
204
+ input,
205
+ // allows you to create powerful data stores
206
+ createSignal,
207
+ // dom ref
208
+ useRef(),
209
+ // useState
210
+ // useEffect
211
+ // dynamic component class
211
212
  Ref,
212
- reference,
213
+ css,
213
214
  } from "cradova";
214
215
 
215
216
  function TodoList() {
216
217
  // can be used to hold multiple references
217
- const referenceSet = new reference();
218
+ const referenceSet = useRef();
218
219
 
219
220
  // creating a store
220
221
  const todoStore = new createSignal([
@@ -355,21 +356,21 @@ Router.onPageEvent((lastRoute, newRoute) => {
355
356
 
356
357
  ---
357
358
 
358
- More info on cradova Router
359
+ More info on Cradova Router
359
360
 
360
361
  ---
361
362
 
362
- Every cradova app mounts on a div with attribute data-wrapper="app"
363
+ Every Cradova app mounts on a div with attribute data-wrapper="app"
363
364
 
364
- if it already exist cradova will use it instead.
365
+ if it already exist Cradova will use it instead.
365
366
 
366
- cradova will create a div with data-wrapper="app" if it doesn't exists already.
367
+ Cradova will create a div with data-wrapper="app" if it doesn't exists already.
367
368
 
368
369
  so if you want to use your own mount point then create a div with data-wrapper="app".
369
370
 
370
371
  ---
371
372
 
372
- More info on cradova screens
373
+ More info on Cradova screens
373
374
 
374
375
  ---
375
376
 
@@ -391,11 +392,11 @@ circle for each screen in your app
391
392
 
392
393
  ---
393
394
 
394
- More info on cradova Ref
395
+ More info on Cradova Ref
395
396
 
396
397
  ---
397
398
 
398
- Refs are dynamic components, they have simple abstractions like:
399
+ Cradova Ref is a dynamic component class, which ships simple abstractions like:
399
400
 
400
401
  - Effects
401
402
  - stash
@@ -407,7 +408,7 @@ circle for refs in your app
407
408
 
408
409
  ---
409
410
 
410
- More info on cradova createSignal
411
+ More info on Cradova createSignal
411
412
 
412
413
  ---
413
414
 
@@ -420,7 +421,7 @@ with ability to:
420
421
  - bind a Ref
421
422
  - listen to changes
422
423
  - persist changes to localStorage
423
- - update a cradova Ref and bindings automatically
424
+ - update a CradovaRef and bindings automatically
424
425
 
425
426
  With these simple and easy abstractions, you can use datastores with powerful convenience.
426
427
 
@@ -436,7 +437,7 @@ To get further insights and help on Cradova, visit our [Discord](https://discord
436
437
 
437
438
  We are currently working to [set](https://github.com/fridaycandour/cradova/blob/main/contributing.md) up the following:
438
439
 
439
- - building cradova CLI (in progress)
440
+ - building Cradova CLI (in progress)
440
441
  - Cradova Documentation Website
441
442
  - UI component libraries for cradova
442
443
  - Sample projects
package/dist/index.d.ts CHANGED
@@ -6,15 +6,17 @@
6
6
  ██║ ██╔══██╗ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██╗
7
7
  ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ████████ ╚███╔╝ ██║ ██║
8
8
  ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚══╝ ╚═╝ ╚═╝
9
- =============================================================================
10
- Cradova FrameWork
11
- @version 3.0.0
12
- License: Apache V2
9
+ =============================================================================
10
+ Cradova FrameWork
11
+ @version 3.0.0
12
+ License: Apache V2
13
13
  Copyright 2022 Friday Candour.
14
14
  Repository - https://github.com/fridaycandour/cradova
15
15
  =============================================================================
16
16
  */
17
17
 
18
+ import * as CSS from "csstype";
19
+
18
20
  declare module "cradova" {
19
21
  /**
20
22
  * Cradova Signal
@@ -129,6 +131,19 @@ declare module "cradova" {
129
131
  clearPersist(): void;
130
132
  }
131
133
 
134
+ export const isNode: (element: unknown) => boolean;
135
+ /**
136
+ * Cradova event
137
+ */
138
+ export class cradovaEvent {
139
+ private listeners;
140
+ addEventListener(eventName: string, callback: () => void): Promise<void>;
141
+ dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
142
+ }
143
+ export const CradovaEvent: cradovaEvent;
144
+ export function Rhoda(
145
+ l: VJSType<HTMLElement>[] | (() => any)[] | Ref<unknown>[] | HTMLElement[]
146
+ ): DocumentFragment;
132
147
  export function css(identifier: string | TemplateStringsArray): void;
133
148
  /**
134
149
  *
@@ -138,7 +153,12 @@ declare module "cradova" {
138
153
  export function assert<Type>(
139
154
  condition: boolean,
140
155
  ...elements: VJS_Child_TYPE<Type | HTMLElement>[]
141
- ): HTMLElement[];
156
+ ): HTMLElement[] | undefined;
157
+ export function assertOr<Type>(
158
+ condition: boolean,
159
+ ifTrue: VJS_Child_TYPE<Type | HTMLElement>,
160
+ ifFalse: VJS_Child_TYPE<Type | HTMLElement>
161
+ ): VJS_Child_TYPE<HTMLElement | Type>;
142
162
  type LoopData<Type> = Type[];
143
163
  export function loop<Type>(
144
164
  datalist: LoopData<Type>,
@@ -148,11 +168,6 @@ declare module "cradova" {
148
168
  array?: LoopData<Type>
149
169
  ) => HTMLElement | DocumentFragment | undefined
150
170
  ): HTMLElement[] | undefined;
151
- export function assertOr<Type>(
152
- condition: boolean,
153
- ifTrue: VJS_Child_TYPE<Type | HTMLElement>,
154
- ifFalse: VJS_Child_TYPE<Type | HTMLElement>
155
- ): HTMLElement;
156
171
  /**
157
172
  * Cradova Ref
158
173
  * -------
@@ -201,6 +216,12 @@ declare module "cradova" {
201
216
  updateState(data?: D, stash?: boolean): void;
202
217
  private Activate;
203
218
  }
219
+ /**
220
+ * Document fragment
221
+ * @param children
222
+ * @returns
223
+ */
224
+ export const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
204
225
  /**
205
226
  * cradova
206
227
  * ---
@@ -220,6 +241,7 @@ declare module "cradova" {
220
241
  export class reference {
221
242
  [x: string]: Record<string, any>;
222
243
  bindAs(name: string): reference;
244
+ dom<ElementType>(name: string): ElementType | undefined;
223
245
  _appendDomForce(name: string, Element: HTMLElement): void;
224
246
  }
225
247
  /**
@@ -230,24 +252,24 @@ declare module "cradova" {
230
252
  * @param ActiveRef
231
253
  * @returns [state, setState]
232
254
  */
233
- export function useState<S>(
255
+ export function useState<S = unknown>(
234
256
  initialValue: S,
235
- ActiveRef: Ref<S>
257
+ ActiveRef: Ref<unknown>
236
258
  ): [S, (newState: S) => void];
237
259
  /**
238
- * Cradova
239
- * ---
240
- Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
241
- * @param effect
242
- * @returns
243
- */
260
+ * Cradova
261
+ * ---
262
+ Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
263
+ * @param effect
264
+ * @returns
265
+ */
244
266
  export function useEffect(effect: () => void, ActiveRef: Ref<unknown>): void;
245
267
  /**
246
- * Cradova
247
- * ---
248
- Returns a mutable reference object of dom elements that persists across component renders.
249
- * @returns reference
250
- */
268
+ * Cradova
269
+ * ---
270
+ Returns a mutable reference object of dom elements that persists across component renders.
271
+ * @returns reference
272
+ */
251
273
  export function useRef(): Record<string, HTMLElement | undefined>;
252
274
 
253
275
  /**
@@ -269,7 +291,6 @@ Returns a mutable reference object of dom elements that persists across componen
269
291
  /**
270
292
  * this is a set of added html to the screen
271
293
  */
272
- _secondaryChildren: VJSType<HTMLElement>[];
273
294
  /**
274
295
  * error handler for the screen
275
296
  */
@@ -285,6 +306,7 @@ Returns a mutable reference object of dom elements that persists across componen
285
306
  private _persist;
286
307
  private _delegatedRoutesCount;
287
308
  private _transition;
309
+ private _dropped;
288
310
  constructor(cradova_screen_initials: CradovaScreenType);
289
311
  get _delegatedRoutes(): boolean;
290
312
  set _delegatedRoutes(count: boolean);
@@ -292,8 +314,8 @@ Returns a mutable reference object of dom elements that persists across componen
292
314
  _package(): Promise<void>;
293
315
  onActivate(cb: () => Promise<void> | void): void;
294
316
  onDeactivate(cb: () => Promise<void> | void): void;
295
- addChildren(...addOns: VJSType<HTMLElement>[]): void;
296
317
  _deActivate(): Promise<void>;
318
+ drop(state: boolean): boolean | undefined;
297
319
  _Activate(force?: boolean): Promise<void>;
298
320
  }
299
321
 
@@ -316,9 +338,9 @@ Returns a mutable reference object of dom elements that persists across componen
316
338
  | (() => HTMLElement)
317
339
  | Partial<DataAttributes>
318
340
  | Partial<AriaAttributes>
319
- | Partial<CSSStyleDeclaration>
341
+ | CSS.Properties
320
342
  | {
321
- style?: Partial<CSSStyleDeclaration>;
343
+ style?: CSS.Properties;
322
344
  onmount?: (this: T) => void;
323
345
  reference?: reference;
324
346
  }
@@ -336,9 +358,8 @@ Returns a mutable reference object of dom elements that persists across componen
336
358
  | (() => HTMLElement)
337
359
  | Partial<DataAttributes>
338
360
  | Partial<AriaAttributes>
339
- | Partial<CSSStyleDeclaration>
361
+ | CSS.Properties<string | number>
340
362
  | {
341
- style?: Partial<CSSStyleDeclaration>;
342
363
  src?: string;
343
364
  href?: string;
344
365
  placeholder?: string;
@@ -354,6 +375,7 @@ Returns a mutable reference object of dom elements that persists across componen
354
375
  rel?: string;
355
376
  required?: string;
356
377
  frameBorder?: string;
378
+ style?: CSS.Properties;
357
379
  onmount?: (this: T) => void;
358
380
  reference?: reference;
359
381
  }
@@ -412,6 +434,7 @@ Returns a mutable reference object of dom elements that persists across componen
412
434
  element: E & HTMLElement,
413
435
  ElementChildrenAndPropertyList: VJS_params_TYPE<E>
414
436
  ) => E;
437
+ export const make: (descriptor: any) => any[];
415
438
  export const a: VJSType<HTMLAnchorElement>;
416
439
  export const area: VJSType<HTMLAreaElement>;
417
440
  export const article: VJSType<HTMLElement>;
@@ -491,7 +514,7 @@ Returns a mutable reference object of dom elements that persists across componen
491
514
  * @param {string} path Route path.
492
515
  * @param screen the cradova document tree for the route.
493
516
  */
494
- export class RouterClass {
517
+ export class Router {
495
518
  /** cradova router
496
519
  * ---
497
520
  * Registers a route.
@@ -501,15 +524,23 @@ Returns a mutable reference object of dom elements that persists across componen
501
524
  * @param {string} path Route path.
502
525
  * @param screen the cradova screen.
503
526
  */
504
- BrowserRoutes(obj: Record<string, any>): void;
527
+ static BrowserRoutes(obj: Record<string, any>): void;
528
+ /**
529
+ Go back in Navigation history
530
+ */
531
+ static back(): void;
505
532
  /**
506
- Go back in Navigation history
507
- */
508
- back(): void;
533
+ Go forward in Navigation history
534
+ */
535
+ static forward(): void;
509
536
  /**
510
- Go forward in Navigation history
511
- */
512
- forward(): void;
537
+ Pause navigation
538
+ */
539
+ static pauseNaviagtion(): void;
540
+ /**
541
+ resume navigation
542
+ */
543
+ static resumeNaviagtion(): void;
513
544
  /**
514
545
  * Cradova Router
515
546
  * ------
@@ -520,11 +551,20 @@ Returns a mutable reference object of dom elements that persists across componen
520
551
  * @param data object
521
552
  * @param force boolean
522
553
  */
523
- navigate(
554
+ static navigate(
524
555
  href: string,
525
556
  data?: Record<string, unknown> | null,
526
557
  force?: boolean
527
558
  ): void;
559
+ /**
560
+ * Cradova Router
561
+ * ------
562
+ *
563
+ * Navigates to a designated screen in your app by loading a seperate page;
564
+ *
565
+ * @param pathname string
566
+ */
567
+ static navigateNauturally(pathname: string): void;
528
568
  /**
529
569
  * Cradova
530
570
  * ---
@@ -534,14 +574,14 @@ Returns a mutable reference object of dom elements that persists across componen
534
574
  *
535
575
  * @param screen
536
576
  */
537
- setLoadingScreen(screen: Screen): void;
577
+ static setLoadingScreen(screen: Screen): void;
538
578
  /** cradova router
539
579
  * ---
540
580
  * Listen for navigation events
541
581
  *
542
582
  * @param callback () => void
543
583
  */
544
- onPageEvent(callback: () => void): void;
584
+ static onPageEvent(callback: () => void): void;
545
585
  /** cradova router
546
586
  * ---
547
587
  * get a screen ready before time.
@@ -549,7 +589,10 @@ Returns a mutable reference object of dom elements that persists across componen
549
589
  * @param {string} path Route path.
550
590
  * @param data data for the screen.
551
591
  */
552
- packageScreen(path: string, data?: Record<string, unknown>): Promise<void>;
592
+ static packageScreen(
593
+ path: string,
594
+ data?: Record<string, unknown>
595
+ ): Promise<void>;
553
596
  /**
554
597
  * Cradova Router
555
598
  * ------
@@ -558,7 +601,7 @@ Returns a mutable reference object of dom elements that persists across componen
558
601
  *
559
602
  * .
560
603
  */
561
- getParams(): any;
604
+ static getParams(): any;
562
605
  /**
563
606
  * Cradova
564
607
  * ---
@@ -567,10 +610,9 @@ Returns a mutable reference object of dom elements that persists across componen
567
610
  * @param callback
568
611
  * @param path? page path
569
612
  */
570
- addErrorHandler(callback: (err: unknown) => void): void;
571
- _mount(): void;
613
+ static addErrorHandler(callback: (err: unknown) => void): void;
614
+ static _mount(): void;
572
615
  }
573
- export const Router: RouterClass;
574
616
 
575
617
  /**
576
618
  *
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var cradovaEvent = class {
21
21
  constructor() {
22
22
  this.listeners = {};
23
23
  }
24
- addEventListener(eventName, callback) {
24
+ async addEventListener(eventName, callback) {
25
25
  if (!this.listeners[eventName]) {
26
26
  this.listeners[eventName] = [];
27
27
  }
@@ -30,7 +30,7 @@ var cradovaEvent = class {
30
30
  // removeEventListener(eventName: string, num: number) {
31
31
  // this.listeners[eventName].splice(num, 1);
32
32
  // }
33
- dispatchEvent(eventName, eventArgs) {
33
+ async dispatchEvent(eventName, eventArgs) {
34
34
  const eventListeners = this.listeners[eventName] || [];
35
35
  for (; eventListeners.length !== 0; ) {
36
36
  eventListeners.shift()?.call(void 0, eventArgs);
@@ -281,6 +281,9 @@ var reference = class {
281
281
  bindAs(name) {
282
282
  return [this, name];
283
283
  }
284
+ dom(name) {
285
+ return this[name];
286
+ }
284
287
  _appendDomForce(name, Element) {
285
288
  this[name] = Element;
286
289
  }
@@ -611,7 +614,7 @@ var Screen = class {
611
614
  /**
612
615
  * this is a set of added html to the screen
613
616
  */
614
- this._secondaryChildren = [];
617
+ // private _secondaryChildren: VJSType<HTMLElement>[] = [];
615
618
  /**
616
619
  * error handler for the screen
617
620
  */
@@ -620,6 +623,7 @@ var Screen = class {
620
623
  this._template = document.createElement("div");
621
624
  this._persist = true;
622
625
  this._delegatedRoutesCount = -1;
626
+ this._dropped = false;
623
627
  const { template: template2, name, persist, renderInParallel, transition } = cradova_screen_initials;
624
628
  this._html = template2;
625
629
  this._name = name;
@@ -668,9 +672,6 @@ var Screen = class {
668
672
  }
669
673
  }
670
674
  }
671
- if (this._secondaryChildren.length) {
672
- this._template.appendChild(frag(this._secondaryChildren));
673
- }
674
675
  }
675
676
  onActivate(cb) {
676
677
  this._callBack = cb;
@@ -678,15 +679,26 @@ var Screen = class {
678
679
  onDeactivate(cb) {
679
680
  this._deCallBack = cb;
680
681
  }
681
- addChildren(...addOns) {
682
- this._secondaryChildren.push(...addOns);
683
- }
682
+ // addChildren(...addOns: VJSType<HTMLElement>[]) {
683
+ // this._secondaryChildren.push(...addOns);
684
+ // }
684
685
  async _deActivate() {
685
686
  if (this._deCallBack) {
686
687
  await this._deCallBack();
687
688
  }
688
689
  }
690
+ drop(state) {
691
+ if (typeof state === "boolean") {
692
+ this._dropped = state;
693
+ return void 0;
694
+ } else
695
+ return this._dropped;
696
+ }
689
697
  async _Activate(force = false) {
698
+ if (this._dropped) {
699
+ history.go(-1);
700
+ return;
701
+ }
690
702
  if (!this._persist || force || !this._packed) {
691
703
  await this._package();
692
704
  this._packed = true;
@@ -722,6 +734,7 @@ RouterBox["loadingScreen"] = null;
722
734
  RouterBox["params"] = {};
723
735
  RouterBox["routes"] = {};
724
736
  RouterBox["pageevents"] = [];
737
+ RouterBox["paused"] = false;
725
738
  RouterBox["start_pageevents"] = async function(url) {
726
739
  setTimeout(() => {
727
740
  for (let ci = 0; ci < RouterBox["pageevents"].length; ci++) {
@@ -784,9 +797,10 @@ RouterBox.route = (path, screen) => {
784
797
  return void 0;
785
798
  };
786
799
  RouterBox.router = async function(_e, _force) {
787
- let url, route, params;
788
- if (!url) {
789
- url = window.location.pathname;
800
+ let url = window.location.pathname, route, params;
801
+ if (RouterBox["paused"]) {
802
+ window.location.hash = "paused";
803
+ return;
790
804
  }
791
805
  if (url === RouterBox["lastNavigatedRoute"]) {
792
806
  return;
@@ -847,7 +861,7 @@ RouterBox.router = async function(_e, _force) {
847
861
  }
848
862
  }
849
863
  };
850
- var RouterClass = class {
864
+ var Router = class {
851
865
  /** cradova router
852
866
  * ---
853
867
  * Registers a route.
@@ -857,7 +871,7 @@ var RouterClass = class {
857
871
  * @param {string} path Route path.
858
872
  * @param screen the cradova screen.
859
873
  */
860
- BrowserRoutes(obj) {
874
+ static BrowserRoutes(obj) {
861
875
  for (const path in obj) {
862
876
  let screen = obj[path];
863
877
  if (typeof screen === "object" && typeof screen.then === "function" || typeof screen === "function") {
@@ -869,20 +883,35 @@ var RouterClass = class {
869
883
  RouterBox.route(path, screen);
870
884
  }
871
885
  }
872
- this._mount();
886
+ Router._mount();
873
887
  }
874
888
  /**
875
889
  Go back in Navigation history
876
890
  */
877
- back() {
891
+ static back() {
878
892
  history.go(-1);
879
893
  }
880
894
  /**
881
895
  Go forward in Navigation history
882
896
  */
883
- forward() {
897
+ static forward() {
884
898
  history.go(1);
885
899
  }
900
+ /**
901
+ Pause navigation
902
+ */
903
+ static pauseNaviagtion() {
904
+ RouterBox["paused"] = true;
905
+ window.location.hash = "paused";
906
+ }
907
+ /**
908
+ resume navigation
909
+ */
910
+ static resumeNaviagtion() {
911
+ RouterBox["paused"] = false;
912
+ window.location.replace(window.location.pathname + window.location.search);
913
+ history.go(-1);
914
+ }
886
915
  /**
887
916
  * Cradova Router
888
917
  * ------
@@ -893,7 +922,7 @@ var RouterClass = class {
893
922
  * @param data object
894
923
  * @param force boolean
895
924
  */
896
- navigate(href, data2 = null, force = false) {
925
+ static navigate(href, data2 = null, force = false) {
897
926
  if (typeof href !== "string") {
898
927
  throw new TypeError(
899
928
  " \u2718 Cradova err: href must be a defined path but got " + href + " instead"
@@ -916,6 +945,22 @@ var RouterClass = class {
916
945
  RouterBox.router(null, force);
917
946
  }
918
947
  }
948
+ /**
949
+ * Cradova Router
950
+ * ------
951
+ *
952
+ * Navigates to a designated screen in your app by loading a seperate page;
953
+ *
954
+ * @param pathname string
955
+ */
956
+ static navigateNauturally(pathname) {
957
+ if (typeof pathname !== "string") {
958
+ throw new TypeError(
959
+ " \u2718 Cradova err: pathname must be a defined path but got " + pathname + " instead"
960
+ );
961
+ }
962
+ window.location.pathname = pathname;
963
+ }
919
964
  /**
920
965
  * Cradova
921
966
  * ---
@@ -925,7 +970,7 @@ var RouterClass = class {
925
970
  *
926
971
  * @param screen
927
972
  */
928
- setLoadingScreen(screen) {
973
+ static setLoadingScreen(screen) {
929
974
  if (screen instanceof Screen) {
930
975
  RouterBox["LoadingScreen"] = screen;
931
976
  } else {
@@ -940,7 +985,7 @@ var RouterClass = class {
940
985
  *
941
986
  * @param callback () => void
942
987
  */
943
- onPageEvent(callback) {
988
+ static onPageEvent(callback) {
944
989
  if (typeof callback === "function") {
945
990
  RouterBox["pageevents"].push(callback);
946
991
  } else {
@@ -956,7 +1001,7 @@ var RouterClass = class {
956
1001
  * @param {string} path Route path.
957
1002
  * @param data data for the screen.
958
1003
  */
959
- async packageScreen(path, data2 = {}) {
1004
+ static async packageScreen(path, data2 = {}) {
960
1005
  if (!RouterBox.routes[path]) {
961
1006
  console.error(" \u2718 Cradova err: no screen with path " + path);
962
1007
  throw new Error(
@@ -986,7 +1031,7 @@ var RouterClass = class {
986
1031
  *
987
1032
  * .
988
1033
  */
989
- getParams() {
1034
+ static getParams() {
990
1035
  return RouterBox["params"];
991
1036
  }
992
1037
  /**
@@ -997,7 +1042,7 @@ var RouterClass = class {
997
1042
  * @param callback
998
1043
  * @param path? page path
999
1044
  */
1000
- addErrorHandler(callback) {
1045
+ static addErrorHandler(callback) {
1001
1046
  if (typeof callback === "function") {
1002
1047
  RouterBox["errorHandler"] = callback;
1003
1048
  } else {
@@ -1006,7 +1051,7 @@ var RouterClass = class {
1006
1051
  );
1007
1052
  }
1008
1053
  }
1009
- _mount() {
1054
+ static _mount() {
1010
1055
  let doc = document.querySelector("[data-wrapper=app]");
1011
1056
  if (!doc) {
1012
1057
  doc = document.createElement("div");
@@ -1023,7 +1068,6 @@ var RouterClass = class {
1023
1068
  });
1024
1069
  }
1025
1070
  };
1026
- var Router = new RouterClass();
1027
1071
 
1028
1072
  // lib/parts/elements.ts
1029
1073
  var makeElement = (element, ElementChildrenAndPropertyList) => {
@@ -1053,12 +1097,6 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
1053
1097
  props = Object.assign(props, child);
1054
1098
  continue;
1055
1099
  }
1056
- if (typeof child !== "undefined") {
1057
- console.error(" \u2718 Cradova err: got", { child });
1058
- throw new Error(
1059
- " \u2718 Cradova err: invalid child type: (" + typeof child + ")"
1060
- );
1061
- }
1062
1100
  }
1063
1101
  } else {
1064
1102
  return element;
@@ -1139,8 +1177,8 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
1139
1177
  return element;
1140
1178
  };
1141
1179
  var make = function(descriptor) {
1142
- if (!descriptor.length) {
1143
- return ["DIV"];
1180
+ if (typeof descriptor !== "string") {
1181
+ return [];
1144
1182
  }
1145
1183
  if (Array.isArray(descriptor)) {
1146
1184
  descriptor = descriptor[0];
@@ -1193,7 +1231,7 @@ var make = function(descriptor) {
1193
1231
  }
1194
1232
  classes.push(descriptor[i2]);
1195
1233
  }
1196
- return [tag || "DIV", IDs[0], classes.join(" "), innerValue];
1234
+ return [tag, IDs[0], classes.join(" "), innerValue];
1197
1235
  };
1198
1236
  var cra = (tag) => {
1199
1237
  const extend = (...Children_and_Properties) => makeElement(document.createElement(tag), Children_and_Properties);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "Web framework for building web apps and PWAs",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -62,6 +62,7 @@
62
62
  "@types/jest": "^29.2.4",
63
63
  "@typescript-eslint/eslint-plugin": "^5.47.0",
64
64
  "@typescript-eslint/parser": "^5.47.0",
65
+ "csstype": "^3.1.2",
65
66
  "eslint": "^8.30.0",
66
67
  "eslint-config-prettier": "^8.5.0",
67
68
  "eslint-plugin-prettier": "^4.2.1",