cradova 3.16.0 โ†’ 3.16.2

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.
Files changed (2) hide show
  1. package/README.md +24 -288
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  Build web apps that are fast, small, and simple.
11
11
  <br/>
12
12
  <br/>
13
- <a href="https://github.com/codedynasty-dev/cradova#examples"><strong>Explore the ๐ŸŽ™๏ธ docs ยป</strong></a>
13
+ <a href="https://cradova.codedynasty.dev/"><strong>Explore the ๐ŸŽ™๏ธ docs ยป</strong></a>
14
14
  <br/>
15
15
  <br/>
16
16
  <a href="https://t.me/codedynasty-devHQ">Join Community</a>
@@ -31,165 +31,38 @@ Build web apps that are fast, small, and simple.
31
31
  ![Forks](https://img.shields.io/github/forks/codedynasty-dev/cradova?style=social)
32
32
  ![Stargazers](https://img.shields.io/github/stars/codedynasty-dev/cradova?style=social)
33
33
 
34
- # Cradova is 3
35
-
36
- ## 2025 - What's New? Function as reactive components
37
-
38
- this can't be better anywhere XD
34
+
35
+ ## Component in Cradova
39
36
 
40
37
  ```js
41
- // functional components - USE REGULAR FUNCTIONS, NOT ARROW FUNCTIONS
42
- // Arrow functions do NOT receive ctx - they are not reactive components
43
- // Regular functions receive ctx which gives access to hooks (useState, useEffect, useMemo, useRef)
44
- // This convention exists because functions get a state tree, but arrow functions do not
45
- // This allows you to control how many state objects are in the DOM
46
-
47
- const Cradova = function (ctx) {
48
- // ctx gives you access to hooks
49
- const [year, setYear] = ctx.useState(3);
50
- const [count] = ctx.useMemo(() => year * 2, [year]);
51
-
52
- ctx.useEffect(() => {
53
- console.log("Component mounted");
54
- return () => console.log("Cleanup");
55
- }, []);
56
-
57
- return h1("Cradova is " + year + " years old", {
58
- onclick() {
59
- setYear((lastYear) => lastYear + 1);
60
- },
61
- });
62
- };
63
-
64
- // WRONG - arrow function does not receive ctx
65
- const BrokenComponent = (ctx) => {
66
- // ctx is undefined here!
67
- const [count, setCount] = ctx.useState(0); // Will fail
68
- return div(count);
69
- };
70
-
71
- // CORRECT - regular function receives ctx
72
- const WorkingComponent = function (ctx) {
73
- const [count, setCount] = ctx.useState(0); // Works!
74
- return div(count, { onclick: () => setCount(count + 1) });
75
- };
76
- ```
77
-
78
- ### Page Templates - Must Use Regular Functions
79
-
80
- ```js
81
- // template function gets ctx with hooks if you using function to declare them.
82
- const HomePage = new Page({
83
- title: "Home",
84
- template: function (ctx) {
85
- const [view, setView] = ctx.useState("home");
86
- return div(
87
- h1("Welcome"),
88
- button("Switch View", { onclick: () => setView("other") })
89
- );
90
- }
91
- });
92
-
93
- // WRONG - arrow function template does not get ctx
94
- const BrokenPage = new Page({
95
- title: "Home",
96
- template: (ctx) => { // ctx is undefined!
97
- const [view, setView] = ctx.useState("home"); // Will fail
98
- return div(view);
99
- }
100
- });
101
- ```
102
-
103
- // add reactivity to a signal element.
104
- const counterSignal = new Signal({ count: 0 });
105
- function count2() {
106
- useEffect(() => {
107
- let count = 0;
108
- setInterval(() => {
109
- count++;
110
- counterSignal.publish("count", count);
111
- }, 1000);
112
- }, this);
113
-
114
- return h1(" count: 0", {
115
- subscription: counterSignal.subscriber("count", function ({ count }) {
116
- this.innerText = " count: " + count;
117
- }),
118
- });
119
- }
120
-
121
- // converts to html and append to the Dom
122
- document.body.appendChild(div(Cradova));
123
- ```
124
-
125
- ## 2024 - What's New? Signals pub/sub
38
+ import { div, h1 } from "cradova";
126
39
 
127
- ```js
128
- import { Signal, getSignal, $if, $ifelse, div, h1 } from "cradova";
40
+ function Hello(ctx) {
129
41
 
130
- const signal = new Signal({ name: "john" });
42
+ const [name, setName] = ctx.useState("");
131
43
 
132
- function Hello() {
133
- const name = getSignal("name", this).name;
134
44
  return div(
135
- $if(name === "john", h1("Hello john")),
136
- $if(name === "paul", h1("Goodbye paul")),
137
- $ifelse(name === "john", h1("Hello john"), h1("Hello Paul"))
138
- );
139
- }
140
-
141
- signal.bind("name", this);
142
- const html = div(Hello);
143
- document.body.append(html);
144
45
 
145
- setInterval(() => {
146
- signal.publish("name", "paul");
147
- }, 5000);
148
- ```
149
-
150
- ## 2023 - What's New? Conditionals
46
+ h1("Hello " + name, {
47
+ className: "title",
48
+ style: {
49
+ color: "grey",
50
+ },
51
+ }),
151
52
 
152
- ```js
153
- import { $case, $if, $ifelse, $switch, div, h1 } from "cradova";
53
+ input({
54
+ oninput(e){
55
+ setName(e.target.value);
56
+ }
57
+ }),
154
58
 
155
- function Hello({ name }) {
156
- return div(
157
- $if(name === "john", h1("Hello john")),
158
- $if(name === "paul", h1("Goodbye paul")),
159
- $ifelse(name === "john", h1("Hello john"), h1("Hello Paul"))
160
- );
59
+ )
161
60
  }
162
61
 
163
- const html = div(Hello("john"), Hello("paul"));
164
62
 
165
- function whatsAllowed({ age }) {
166
- return div(
167
- $switch(
168
- age,
169
- $case(12, h1("too young")),
170
- $case(26, h1("you are welcome")),
171
- $case(52, h1("too old"))
172
- )
173
- );
174
- }
175
-
176
- document.body.append(html, whatsAllowed({ age: 26 }));
63
+ document.body.append(div(hello)); //
177
64
  ```
178
65
 
179
- ## 2023 - What's New? Router
180
-
181
- ```js
182
- Router.BrowserRoutes({
183
- "/home": home,
184
- });
185
- // creates these routes
186
- Router.navigate("/home", data);
187
- ```
188
-
189
- ## 2021 - first version
190
-
191
- ...
192
-
193
66
  # Contents
194
67
 
195
68
  - [What is Cradova](#what-is-cradova)
@@ -200,11 +73,11 @@ Router.navigate("/home", data);
200
73
  - [Getting Help](#getting-help)
201
74
  - [Contributing](#contributing)
202
75
 
203
- ## What is Cradova?
76
+ ## Why Cradova?
204
77
 
205
- Cradova is a web development framework for building Single Page Applications and
206
- PWAs.
78
+ Cradova is not react, it's simpler, faster for most components and basically bare javascript syntax, no bundler needed.
207
79
 
80
+ And.
208
81
  Cradova follows the
209
82
  [VJS specification](https://github.com/codedynasty-dev/cradova/blob/main/VJS_spec/specification.md)
210
83
 
@@ -213,7 +86,7 @@ Cradova follows the
213
86
  Fast and simple with and fewer abstractions and yet easily composable.
214
87
 
215
88
  Cradova is not built on virtual DOM or diff algorithms. Instead, State
216
- management is done in a way that is simple, easy and fast.
89
+ management is even based and only affect dom parts is updated, least repaint, done in a way that is simple, easy and fast.
217
90
 
218
91
  ## Is this a big benefit?
219
92
 
@@ -238,30 +111,6 @@ npm i cradova
238
111
  <script src="https://cdn.jsdelivr.net/npm/cradova/dist/index.js"></script>
239
112
  ```
240
113
 
241
- ## Examples
242
-
243
- Some aspects of Cradova are not reflected in the following example. More
244
- functionality will be entailed in future docs.
245
-
246
- ## A basic component in Cradova
247
-
248
- ```js
249
- import { div, h1 } from "cradova";
250
-
251
- function Hello(name) {
252
- return h1("Hello " + name, {
253
- className: "title",
254
- style: {
255
- color: "grey",
256
- },
257
- });
258
- }
259
-
260
- const html = div(Hello("peter"), Hello("joe"));
261
-
262
- document.body.append(html);
263
- ```
264
-
265
114
  ## Basic Samples
266
115
 
267
116
  This a collection of basic examples that can give you some ideas
@@ -388,118 +237,6 @@ const todoList = function () {
388
237
  document.body.appendChild(TodoList());
389
238
  ```
390
239
 
391
- ## working with page and Router
392
-
393
- Unlike just appending stuff to the DOM, a better to build apps is to use a
394
- routing system.
395
-
396
- Cradova Router is a module that allows you do the following:
397
-
398
- Create specified routes in you application help you handle navigation render a
399
- page on a route listen to Navigation changes create error boundary at page level
400
- apart from Function level.
401
-
402
- let's try an example.
403
-
404
- ```js
405
- import { Page, Router, useEffect } from "cradova";
406
-
407
- const home = new Page({
408
- name: "home page", // page title
409
- template: () => div(template),
410
- });
411
-
412
- // in your routes.ts file
413
- Router.BrowserRoutes({
414
- // Ways to use paths and Pages
415
- "*": home,
416
- "/home": home,
417
- "/home?": home,
418
- "/home/:name": home,
419
- // will be lazy loaded
420
- "/lazy-loaded-home": async () => await import("./home"),
421
- });
422
- // creates these routes
423
-
424
- Router.navigate("/home", data);
425
- // navigates to that page
426
-
427
- Router.onPageEvent((lastRoute, newRoute) => {
428
- console.log(lastRoute, newRoute);
429
- });
430
- // listen for navigation changes
431
- ```
432
-
433
- ### More info
434
-
435
- ---
436
-
437
- More info on Cradova Router
438
-
439
- ---
440
-
441
- Every Cradova app mounts on a div with attribute data-wrapper="app"
442
-
443
- if it already exist Cradova will use it instead.
444
-
445
- Cradova will create a div with data-wrapper="app" if it doesn't exists already.
446
-
447
- so if you want to use your own mount point then create a div with
448
- data-wrapper="app".
449
-
450
- ---
451
-
452
- More info on Cradova pages
453
-
454
- ---
455
-
456
- Cradova pages has onActivate() and onDeactivate() methods which is also
457
- available in the component function on the this variable bound to it.
458
-
459
- this allow you manage rendering circle for each page in your app
460
-
461
- ---
462
-
463
- More info on Cradova Function
464
-
465
- ---
466
-
467
- Cradova Function is a dynamic component class, which ships simple abstractions like:
468
-
469
- - Signal
470
- - useEffect
471
- - useState
472
- - useRef
473
- - preRender
474
-
475
- these behaviors allow you manage rendering circle for Functions in your app
476
-
477
- ---
478
-
479
- More info on Cradova createSignal
480
-
481
- ---
482
-
483
- Cradova Signals allows you to create powerful data stores.
484
-
485
- with ability to:
486
-
487
- - create store
488
- - create actions and fire them
489
- - bind a Function
490
- - listen to changes
491
- - persist changes to localStorage
492
-
493
- With these simple and easy abstractions, you can write datastores with so much
494
- convenience.
495
-
496
- ## Documentation
497
-
498
- At the moment, we're in the process of creating a documentation website for
499
- Cradova, and we have limited resources. If you're interested in lending a hand,
500
- we invite you to join our community, gain firsthand experience, and contribute
501
- to the advancement of Cradova.
502
-
503
240
  ## Getting Help
504
241
 
505
242
  To get further insights and help on Cradova, visit the
@@ -512,8 +249,7 @@ We are currently working to
512
249
  [set](https://github.com/codedynasty-dev/cradova/blob/main/contributing.md) up the
513
250
  following:
514
251
 
515
- - building Cradova CLI (in progress)
516
- - Cradova Documentation Website
252
+ - Cradova Docs
517
253
  - Sample projects
518
254
  - maintenance and promotion
519
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.16.0",
3
+ "version": "3.16.2",
4
4
  "description": "A UI framework for web applications.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",