cradova 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,41 +1,18 @@
1
- # Cradova
2
-
3
- <center>
4
- <img src="cradova.png" width="100px">
5
-
6
- Cradova is a JavaScript framework for building Single Page Applications and PWAs.
7
-
8
- </center>
9
- <br>
10
- <p>
11
- <a href="https://www.npmjs.com/package/cradova">
12
- <img src="https://img.shields.io/npm/v/cradova.svg" alt="npm Version" />
13
- </a>&nbsp;
14
- <a href="https://github.com/cradova/cradova.js/blob/next/LICENSE">
15
- <img src="https://img.shields.io/npm/l/cradova.svg" alt="License" />
16
- </a>&nbsp;
17
- <a href="https://www.npmjs.com/package/cradova">
18
- <img src="https://img.shields.io/npm/dm/cradova.svg" alt="npm Downloads">
19
- </a>&nbsp;
20
- <a href="https://www.npmjs.com/package/cradova">
21
- <img src="https://img.shields.io/travis/cradova/cradova.js/next.svg?colorB=brightgreen" alt="Build Status">
22
- </a>
23
- &nbsp;
24
- <a href="https://opencollective.com/cradova">
25
- <img src="https://img.shields.io/opencollective/all/cradova.svg?colorB=brightgreen" alt="Donate at OpenCollective">
26
- </a>&nbsp;
27
-
28
- </p>
29
-
1
+ <a><img src="cradova.png" alt="logo" width="80" height="80" align="right"></a>
2
+
3
+ # Cradova.js
4
+ [![npm Version](https://img.shields.io/npm/v/cradova.svg)](https://www.npmjs.com/package/cradova)
5
+ [![License](https://img.shields.io/npm/l/cradova.svg)](https://github.com/cradova/cradova.js/blob/next/LICENSE)
6
+ [![npm Downloads](https://img.shields.io/npm/dm/cradova.svg)](https://www.npmjs.com/package/cradova)
7
+ [![Build Status](https://img.shields.io/travis/cradova/cradova.js/next.svg?colorB=brightgreen)](https://www.npmjs.com/package/cradova)
8
+ [![Donate at OpenCollective](https://img.shields.io/opencollective/all/cradova.svg?colorB=brightgreen)](https://opencollective.com/cradova)
30
9
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/cradova/cradova.js/blob/next/contributing.md)
31
10
 
32
- <br>
33
- <br>
34
11
 
35
12
  ## Contents
36
13
 
37
- - [What is cradova.js?](#what-is-cradova?)
38
- - [Why we built cradova?](#the-?)
14
+ - [What is Cradova](#what-is-cradovajs)
15
+ - [Why did we build Cradova?](#whats-the-benefit)
39
16
  - [Installation](#installation)
40
17
  - [Examples](#examples)
41
18
  - [Documentation](#documentation)
@@ -44,27 +21,17 @@ Cradova is a JavaScript framework for building Single Page Applications and PWAs
44
21
 
45
22
  ## What is cradova.js?
46
23
 
47
- cradova is a JavaScript framework for building Single Page Applications and PWAs.
24
+ Cradova is a JavaScript framework for building Single Page Applications and PWAs.
48
25
 
49
26
  It's small, fast and provides state management, routing and XHR utilities out of the box.
50
27
 
51
- # Whats the benefit?
52
-
53
- Javascript is a powerful language.
54
- our aim is not to limit what you can achieve but rather make your make them limitless.
55
-
56
- we made Cradova to give you more power at no cost.
57
- extra speed, ease and security.
58
-
59
- we don't use visual DOM or diff algorithms to manage the DOM, we rather do it the natural way.
60
-
61
- which is fast and simple, with all the benefits and no abstracts whatsoever.
28
+ ## What's the benefit?
29
+ We aim to be fast and simple with and no hidden abstractions whatsoever.
30
+ We don't use visual DOM or any diff algorithms to manage the DOM.
62
31
 
63
- cradova has been used in production and we will update this README to reflect them as ASAP.
32
+ Cradova has been used in production and we will update this README to reflect our lessons as we go.
64
33
 
65
- It's time to change gears.
66
-
67
- # Installation
34
+ ## Installation
68
35
 
69
36
  ### CDN sources
70
37
 
@@ -84,13 +51,11 @@ It's time to change gears.
84
51
  npm i cradova
85
52
  ```
86
53
 
87
- # Examples
88
-
89
- Before you confirm these below, please know that they are many cool parts about cradova not described here but will be on a later time. and eventually when we get a frontend hosting.
90
54
 
91
- You can get deeper insights from the [telegram community](https://t.me/cradovaframework) for the moment.
55
+ ## Examples
56
+ Many aspects of Cradova are not reflected in the following example. More functionality will be entailed in future docs.
92
57
 
93
- Here's an example of create a basic component in cradova:
58
+ Here's an example of create a basic component in Cradova:
94
59
 
95
60
  ```js
96
61
  import _, { frag } from "cradova";
@@ -106,8 +71,7 @@ const html = frag(Hello("peter"), Hello("joe"));
106
71
  document.body.append(html);
107
72
  ```
108
73
 
109
- ## using screen
110
-
74
+ ## Using Screen
111
75
  ```js
112
76
  import _, { Screen, Router } from "cradova";
113
77
 
@@ -137,7 +101,7 @@ Router.route("/", home);
137
101
 
138
102
  ```
139
103
 
140
- # State management
104
+ ## State management
141
105
 
142
106
  ```js
143
107
  // we have
@@ -148,9 +112,7 @@ Router.route("/", home);
148
112
 
149
113
  // Ref components (global and local)
150
114
 
151
- // RefList components (global and local)
152
-
153
- // state can be bind to a store when using createSignal or simpleStores
115
+ // state can be managed from a store when using createSignal or simpleStores
154
116
 
155
117
  import _, { Ref } from "cradova";
156
118
 
@@ -206,17 +168,14 @@ const home = new Screen({
206
168
  Router.route("/", home);
207
169
  ```
208
170
 
209
- # Documentation
210
-
211
- We are currently working building cradova's documentation and we have only a few hands, if you are interested you can join the community and learn first hand and also support cradova's progress.
171
+ ## Documentation
172
+ We are currently building cradova's documentation and we have only a few hands, if you're interested in helping you can join the community, learn first hand, and support cradova's progress.
212
173
 
213
- # getting help
174
+ ## Getting Help
175
+ To get further insights and help on Cradova, visit our new [Telegram Community Chat](https://t.me/cradovaframework).
214
176
 
215
- To get help visit our new [telegram community](https://t.me/cradovaframework)
216
-
217
- # contributing
218
-
219
- we are currently working to set up.
177
+ ## Contributing
178
+ We are currently working to set up:
220
179
 
221
180
  - Cradova Documentation Website
222
181
  - UI component libraries for cradova
@@ -224,14 +183,8 @@ we are currently working to set up.
224
183
  - maintenance and promotion
225
184
  - building cradova CLI
226
185
 
227
- community [telegram](https://t.me/cradovaframework)
228
-
229
- # Sponsor
230
-
231
- It's a general aim to have a development tool
232
- with great developer experience and speed and that what
233
- cradova gives, "low abstraction with great speed".
234
-
235
- it's measurable, to take cradova further your support is needed.
236
186
 
237
- Sponsorships can be done via [Patreon](https://www.patreon.com/FridayCandour). Both monthly-recurring sponsorships and one-time donations are accepted. Recurring sponsorships will be entitled to logo placements in Tiers.
187
+ ## Sponsor
188
+ Your support is appriciated and needed to advance Cradova further into the future.\
189
+ Sponsorships can be done via [Patreon](https://www.patreon.com/FridayCandour).\
190
+ Both monthly-recurring sponsorships and one-time donations are accepted. Recurring sponsorships will be entitled to logo placements in Tiers.
package/dist/index.d.ts CHANGED
@@ -21,17 +21,18 @@ declare module "cradova" {
21
21
  */
22
22
  effect?(fn: () => void | Promise<void>): void;
23
23
  /**
24
- * Cradova screen
24
+ * Cradova Screen
25
25
  * ---
26
- * runs on first render.
27
- * @param data
28
- * @returns void
26
+ * re-renders the screen -
29
27
  *
28
+ * first level call will only be called once
29
+ * lower level calls will be continuously called
30
+ * @param data .
30
31
  *
31
- * .
32
- *
32
+ * *
33
33
  */
34
- updateState: (data: any) => any;
34
+
35
+ updateState(data: unknown): void;
35
36
  };
36
37
 
37
38
  type CradovaElementType = Record<string, any>;
@@ -42,44 +43,40 @@ declare module "cradova" {
42
43
  * ---
43
44
  * returns html with cradova reference
44
45
  * @param data
45
- * @returns html
46
+ * @returns HTMLElement
46
47
  */
47
- render: (data: any) => () => HTMLElement;
48
+ render(data?: any): () => any;
48
49
  /**
49
50
  * Cradova Ref
50
51
  * ---
51
- * runs on every state update
52
- *
52
+ * checks if element is in the dom and returns it.
53
+ * @param data
54
+ * @return HTMLElement
53
55
  */
54
- r: (data: any) => () => HTMLElement;
56
+ instance(): HTMLElement | null;
55
57
  /**
56
58
  * Cradova Ref
57
59
  * ---
58
- * runs on render and every state update
59
- *
60
+ * update ref component with new data and update the dom.
61
+ * @param data
62
+ * @returns void
60
63
  */
61
- effect(fn: (data: unknown) => Promise<void> | void): void;
64
+ updateState(data: any): void;
62
65
  /**
63
66
  * Cradova Ref
64
67
  * ---
65
- * update ref component with new data and update the dom.
68
+ * remove element from the dom
66
69
  * @param data
67
- * @returns void
70
+ * @returns () => HTMLElement
68
71
  */
69
- updateState: (data: any) => any;
72
+ remove(): void;
70
73
  /**
71
74
  * Cradova Ref
72
75
  * ---
73
- * update ref component with new data and update the dom.
74
- * @param data
75
- * @returns void
76
+ * runs once on render
77
+ *
76
78
  */
77
- u: (data: any) => any;
78
- };
79
- type RouterRouteObject = {
80
- controller: (params: object, force?: boolean) => any;
81
- deactivate: (params: object) => any;
82
- packager: (params: any) => void;
79
+ effect(fn: (data: unknown) => Promise<void> | void): void;
83
80
  };
84
81
  /**
85
82
  * Cradova Router
@@ -87,42 +84,71 @@ declare module "cradova" {
87
84
  * Facilitates navigation within the application and initializes
88
85
  * page views based on the matched routes.
89
86
  */
90
- type RouterType =
91
- | {
92
- /**
93
- * Registers a route.
94
- *
95
- * @param {string} path Route path.
96
- * @param {any} screen the cradova document tree for the route.
97
- */
98
- route: (path: string, screen: CradovaScreenType) => void;
99
- /**
100
- * get a screen ready before time.
101
- *
102
- * @param {string} path Route path.
103
- * @param {any} data data for the screen.
104
- */
105
- packageScreen: (path: string, data?: any) => void;
106
- onPageShow: (callback: () => void) => void;
107
- onPageHide: (callback: () => void) => void;
108
- /**
109
- * Cradova Router
110
- * ------
111
- *
112
- * Navigates to a designated screen in your app
113
- */
114
- navigate: (
115
- href: string,
116
- data?: Record<string, any> | null,
117
- force?: boolean
118
- ) => void;
119
- }
120
- | Record<string, any>;
87
+ type RouterType = {
88
+ /**
89
+ * Registers a route.
90
+ *
91
+ * @param {string} path Route path.
92
+ * @param {any} screen the cradova document tree for the route.
93
+ */
94
+ route: (path: string, screen: CradovaScreenType) => void;
95
+ /**
96
+ * get a screen ready before time.
97
+ *
98
+ * @param {string} path Route path.
99
+ * @param {any} data data for the screen.
100
+ */
101
+ packageScreen: (path: string, data?: any) => void;
102
+ onPageShow: (callback: () => void) => void;
103
+ onPageHide: (callback: () => void) => void;
104
+ /**
105
+ * Cradova Router
106
+ * ------
107
+ *
108
+ * return last set router params
109
+ *
110
+ * .
111
+ */
112
+ getParams: () => unknown;
113
+ /**
114
+ * Cradova Router
115
+ * ------
116
+ *
117
+ * Navigates to a designated screen in your app
118
+ */
119
+ navigate: (
120
+ href: string,
121
+ data?: Record<string, any> | null,
122
+ force?: boolean
123
+ ) => void;
124
+
125
+ /**
126
+ * Cradova
127
+ * ---
128
+ * Error Handler for your app
129
+ *
130
+ * @param callback
131
+ * @param path? page path
132
+ */
133
+
134
+ addErrorHandler: (callback: (error: string) => void, path?: string) => void;
135
+ };
136
+
137
+ /**
138
+ * Cradova
139
+ * ---
140
+ * Cradova afterMount event
141
+ *
142
+ * dispatch this manually if you are not using a cradova screen object
143
+ *
144
+ */
145
+
146
+ export const cradovaAftermountEvent: CustomEvent<string>;
121
147
 
122
148
  /**
123
149
  * Cradova Screen
124
150
  * ---
125
- * create instances of manageable pages and scaffolds
151
+ * create instances of manageable pages
126
152
  * @param name
127
153
  * @param template
128
154
  * @param transitions
@@ -141,7 +167,7 @@ declare module "cradova" {
141
167
  /**
142
168
  * Cradova Screen
143
169
  * ---
144
- * create instances of manageable pages and scaffolds
170
+ * create instances of manageable pages
145
171
  * @param name
146
172
  * @param template
147
173
  * @param transitions
@@ -159,14 +185,19 @@ declare module "cradova" {
159
185
  addChild(...addOns: any[]): void;
160
186
  deActivate(): void;
161
187
  Activate(data?: any, force?: boolean): Promise<void>;
162
- }
188
+ /**
189
+ * Cradova Screen
190
+ * ---
191
+ * re-renders the screen -
192
+ *
193
+ * first level call will only be called once
194
+ * lower level calls will be continuously called
195
+ * @param data .
196
+ *
197
+ * *
198
+ */
163
199
 
164
- export class Scaffold {
165
- private history;
166
- private Scaffolds;
167
- push(label: string, data?: unknown, force?: boolean): Promise<void>;
168
- pop(data?: unknown, force?: boolean): Promise<void>;
169
- addScaffolds(scaffolds: Record<string, CradovaScreenType>): Promise<void>;
200
+ updateState(data: unknown): void;
170
201
  }
171
202
 
172
203
  /**
@@ -196,12 +227,12 @@ declare module "cradova" {
196
227
  * ability to:
197
228
  * - create a store
198
229
  * - create actions and fire them
199
- * - bind a Ref or RefList
230
+ * - bind a Ref
200
231
  * - listen to changes
201
232
  * - persist changes to localStorage
202
233
  * - go back and forward in value history
203
234
  * - set keys instead of all values
204
- * - update a cradova Ref/RefList automatically
235
+ * - update a cradova Ref automatically
205
236
  * @constructor initial: any, props: {useHistory, persist}
206
237
  */
207
238
  export class createSignal {
@@ -332,11 +363,11 @@ declare module "cradova" {
332
363
  * ability to:
333
364
  * - create a store
334
365
  * - set keys instead of all values
335
- * - update a cradova Ref/RefList/RefElement automatically
336
- * @constructor initial: any, Ref/RefList/RefElement: any
366
+ * - update a cradova Ref automatically
367
+ * @constructor initial: any, Ref: any
337
368
  */
338
369
 
339
- export class simpleStore {
370
+ export class $ {
340
371
  private ref;
341
372
  value: any;
342
373
  constructor(initial: unknown);
@@ -357,15 +388,6 @@ declare module "cradova" {
357
388
  * @returns void
358
389
  */
359
390
  setKey(name: string, value: any, shouldRefRender?: boolean): void;
360
- /**
361
- * Cradova simpleStore
362
- * ----
363
- * set a auto - rendering component for this store
364
- *
365
- * @param Ref component to bind to.
366
- * @param path a property in the object to send to attached ref
367
- */
368
- bindRef(Ref: any, prop?: string): void;
369
391
  /**
370
392
  * Cradova simpleStore
371
393
  * ---
@@ -400,53 +422,9 @@ declare module "cradova" {
400
422
  | any
401
423
  ): Promise<unknown>;
402
424
 
403
- /**
404
- * swipe
405
- * ---
406
- * Now you can detect swipes the best way possible
407
- *
408
- * @param callback
409
- * @param touching?
410
- * @param element?
411
- */
412
- export function swipe(
413
- callback: (swipe_data: Record<string, number>) => void,
414
- touching?: boolean,
415
- element?: HTMLElement
416
- ): {
417
- start(): void;
418
- stop(): void;
419
- };
420
-
421
425
  export function loadCradovaUICss(seconds?: number): void;
422
-
423
- export function IsElementInView(element: HTMLElement): boolean;
424
-
425
- export const controls: () => void;
426
426
  export function uuid(): string;
427
- export function PromptBeforeLeave(callback?: (e: any) => void): void;
428
- /**
429
- Write CSS media in javascript
430
-
431
- @example
432
427
 
433
- _.media("min-width: 790px",
434
- ["#container",
435
- {
436
- width: "100%",
437
- height: "100%",
438
- "background-color": "#0000"
439
- }],
440
-
441
- ["#header",
442
- {
443
- width: "100%",
444
- height: "20%",
445
- "background-color": "#fff"
446
- }]
447
- )
448
- */
449
- export function media(value: string, ...properties: any[]): void;
450
428
  /**
451
429
  Write CSS styles in Javascript
452
430
  @example
@@ -471,29 +449,6 @@ css(".btn:hover",
471
449
  properties?: Record<string, string>
472
450
  ): void;
473
451
  /**
474
- Write animation value in javascript
475
-
476
- @example
477
-
478
- _.animate("polarization",
479
- ["from",
480
- {
481
- transform: "scale3D(2)" ,
482
- height: "10%",
483
- "background-color": "#0000"
484
- }],
485
-
486
- ["to",
487
- {
488
- transform: "scale3D(1)" ,
489
- height: "100%",
490
- "background-color": "#ff9800"
491
- }]
492
- )
493
-
494
- */
495
- export function animate(identifier: string, ...properties: any[]): void;
496
- /**
497
452
  *
498
453
  * @param {expression} condition
499
454
  * @param {function} callback
@@ -516,35 +471,9 @@ _.animate("polarization",
516
471
  * @param props
517
472
  * @returns
518
473
  */
519
- export function RefElement(
520
- element_initials?: string,
521
- props?: any,
522
- ...other: any
523
- ): {
524
- render(data?: any): any;
525
- r(data?: any): any;
526
- instance(): any;
527
- i(): any;
528
- updateState(state: Record<string, any>): void;
529
- u(state: Record<string, any>): void;
530
- };
474
+
531
475
  export const ls: Record<string, Function>;
532
- export function fullScreen(e: Element): {
533
- set(): void;
534
- exist(): void;
535
- };
536
- export class RefList {
537
- private component;
538
- private stateID;
539
- private parentElement;
540
- constructor(component: (...data: any) => any);
541
- r(d?: any): any;
542
- render(datas?: any): any;
543
- updateState(datas: any[]): void;
544
- remove(): void;
545
- instance(): any;
546
- i(): any;
547
- }
476
+
548
477
  /**
549
478
  * Cradova Ref
550
479
  * -------
@@ -552,21 +481,23 @@ _.animate("polarization",
552
481
  *
553
482
  */
554
483
  export class Ref {
555
- private component;
556
- private stateID;
557
- private upcb;
558
484
  constructor(component: (...data: any) => any);
559
- r(d?: any): () => any;
560
485
  /**
561
486
  * Cradova Ref
562
487
  * ---
563
488
  * returns html with cradova reference
564
489
  * @param data
565
- * @returns () => HTMLElement
490
+ * @returns HTMLElement
566
491
  */
567
492
  render(data?: any): () => any;
568
- instance(): any;
569
- i(): any;
493
+ /**
494
+ * Cradova Ref
495
+ * ---
496
+ * checks if element is in the dom and returns it.
497
+ * @param data
498
+ * @return HTMLElement
499
+ */
500
+ instance(): HTMLElement | null;
570
501
  /**
571
502
  * Cradova Ref
572
503
  * ---
@@ -575,22 +506,22 @@ _.animate("polarization",
575
506
  * @returns void
576
507
  */
577
508
  updateState(data: any): void;
509
+ /**
510
+ * Cradova Ref
511
+ * ---
512
+ * remove element from the dom
513
+ * @param data
514
+ * @returns () => HTMLElement
515
+ */
578
516
  remove(): void;
579
517
  /**
580
518
  * Cradova Ref
581
519
  * ---
582
- * runs on render and every state update
520
+ * runs once on render
583
521
  *
584
522
  */
585
523
  effect(fn: (data: unknown) => Promise<void> | void): void;
586
524
  }
587
- /**
588
- * Document fragment
589
- * @param children
590
- * @returns
591
- */
592
- type fragmentTYPE = () => (() => HTMLElement) | HTMLElement;
593
- export const frag: (...children: fragmentTYPE[]) => DocumentFragment;
594
525
 
595
526
  /**
596
527
  * Cradova