cradova 2.1.1 → 2.2.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/README.md +9 -4
- package/dist/index.d.ts +246 -345
- package/dist/index.js +738 -827
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
Cradova is a JavaScript framework for building Single Page Applications and PWAs.
|
|
43
43
|
|
|
44
|
-
It's
|
|
44
|
+
It's a fast and simple framework, it provides state management, routing system and a rest API utility out of the box.
|
|
45
45
|
|
|
46
46
|
Cradova follows the [VJS specification](https://github.com/fridaycandour/cradova/blob/main/spec.md)
|
|
47
47
|
|
|
@@ -49,12 +49,17 @@ Cradova follows the [VJS specification](https://github.com/fridaycandour/cradova
|
|
|
49
49
|
|
|
50
50
|
Cradova is aimed to be fast and simple with and fewer abstractions and yet easily composable.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Cradova does't rely on visual DOM or diff algorithms to manage the DOM, instead, State management is done more elegantly with a simple predictive model, manually and easily with all the speed.
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
### is this a big benefit?
|
|
55
|
+
|
|
56
|
+
Yes!
|
|
57
|
+
see for yourself.
|
|
55
58
|
|
|
56
59
|
Cradova has been used on a couple of projects in production and we will update this page to reflect our progress as we keep improving.
|
|
57
60
|
|
|
61
|
+
[current version changes](https://github.com/fridaycandour/cradova/blob/main/CHANGELOG.md#v220)
|
|
62
|
+
|
|
58
63
|
## Installation
|
|
59
64
|
|
|
60
65
|
### CDN sources
|
|
@@ -192,7 +197,7 @@ function counter() {
|
|
|
192
197
|
function dataCounter() {
|
|
193
198
|
return _("h1| 0", {
|
|
194
199
|
shouldUpdate: true,
|
|
195
|
-
|
|
200
|
+
"data-num": "0",
|
|
196
201
|
onclick() {
|
|
197
202
|
const num = Number(this.getAttribute("data-num")) + 1;
|
|
198
203
|
this.updateState({ text: num, $num: num });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,144 +1,4 @@
|
|
|
1
1
|
declare module "cradova" {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* Cradova Ajax
|
|
5
|
-
* ------------------
|
|
6
|
-
* your new axios alternative
|
|
7
|
-
* supports files upload
|
|
8
|
-
* @param url string
|
|
9
|
-
* @param {{method: string;data;header;callbacks;}} opts
|
|
10
|
-
* @returns any
|
|
11
|
-
*/
|
|
12
|
-
export function Ajax(
|
|
13
|
-
url: string | URL,
|
|
14
|
-
opts?:
|
|
15
|
-
| {
|
|
16
|
-
method?: "GET" | "POST";
|
|
17
|
-
data?: Record<string, any>;
|
|
18
|
-
header?: {
|
|
19
|
-
"content-type": string;
|
|
20
|
-
} & Record<string, any>;
|
|
21
|
-
callbacks?: Record<string, (arg: any) => void>;
|
|
22
|
-
}
|
|
23
|
-
| any
|
|
24
|
-
): Promise<unknown>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Cradova Signal
|
|
28
|
-
* ----
|
|
29
|
-
* create stateful data store.
|
|
30
|
-
* ability to:
|
|
31
|
-
* - create a store
|
|
32
|
-
* - create actions and fire them
|
|
33
|
-
* - bind a Ref or RefList
|
|
34
|
-
* - listen to changes
|
|
35
|
-
* - persist changes to localStorage
|
|
36
|
-
* - set keys instead of all values
|
|
37
|
-
* - update a cradova Ref/RefList automatically
|
|
38
|
-
* @constructor initial: any, props: {useHistory, persist}
|
|
39
|
-
*/
|
|
40
|
-
export class createSignal<Type> {
|
|
41
|
-
private callback;
|
|
42
|
-
private persistName;
|
|
43
|
-
private actions;
|
|
44
|
-
private ref;
|
|
45
|
-
private path;
|
|
46
|
-
value: Type;
|
|
47
|
-
constructor(
|
|
48
|
-
initial: Type,
|
|
49
|
-
props?: {
|
|
50
|
-
persistName?: string | undefined;
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
/**
|
|
54
|
-
* Cradova Signal
|
|
55
|
-
* ----
|
|
56
|
-
* set signal value
|
|
57
|
-
* @param value - signal value
|
|
58
|
-
* @returns void
|
|
59
|
-
*/
|
|
60
|
-
set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
|
|
61
|
-
/**
|
|
62
|
-
* Cradova Signal
|
|
63
|
-
* ----
|
|
64
|
-
* set a key value if it's an object
|
|
65
|
-
* @param key - key of the key
|
|
66
|
-
* @param value - value of the key
|
|
67
|
-
* @returns void
|
|
68
|
-
*/
|
|
69
|
-
setKey<k extends keyof Type>(
|
|
70
|
-
key: k,
|
|
71
|
-
value: any,
|
|
72
|
-
shouldRefRender?: boolean
|
|
73
|
-
): void;
|
|
74
|
-
/**
|
|
75
|
-
* Cradova Signal
|
|
76
|
-
* ----
|
|
77
|
-
* set a key to signal an action
|
|
78
|
-
* @param key - key of the action
|
|
79
|
-
* @param action function to execute
|
|
80
|
-
*/
|
|
81
|
-
createAction(
|
|
82
|
-
key: string | Record<string, (data?: Type) => void>,
|
|
83
|
-
action?: (data?: Type) => void
|
|
84
|
-
): void;
|
|
85
|
-
/**
|
|
86
|
-
* Cradova Signal
|
|
87
|
-
* ----
|
|
88
|
-
* fires an action if available
|
|
89
|
-
* @param key - string key of the action
|
|
90
|
-
* @param data - data for the action
|
|
91
|
-
*/
|
|
92
|
-
fireAction(key: string, data?: Type): void;
|
|
93
|
-
/**
|
|
94
|
-
* Cradova Signal
|
|
95
|
-
* ----
|
|
96
|
-
* set a auto - rendering component for this store
|
|
97
|
-
*
|
|
98
|
-
* @param Ref component to bind to.
|
|
99
|
-
* @param path a property in the object to send to attached ref
|
|
100
|
-
*/
|
|
101
|
-
bindRef(Ref: any, path?: string): void;
|
|
102
|
-
/**
|
|
103
|
-
* Cradova Signal
|
|
104
|
-
* ----
|
|
105
|
-
* set a update listener on value changes
|
|
106
|
-
* @param callback
|
|
107
|
-
*/
|
|
108
|
-
listen(callback: (a: any) => void): void;
|
|
109
|
-
/**
|
|
110
|
-
* Cradova Signal
|
|
111
|
-
* ----
|
|
112
|
-
* clear the history on local storage
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* .
|
|
116
|
-
*/
|
|
117
|
-
clearPersist(): void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
type stateType =
|
|
121
|
-
| Partial<HTMLElement>
|
|
122
|
-
| {
|
|
123
|
-
class?: string;
|
|
124
|
-
text?: string;
|
|
125
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
126
|
-
tree?: Function | HTMLElement;
|
|
127
|
-
remove?: boolean;
|
|
128
|
-
};
|
|
129
|
-
type stateID = string;
|
|
130
|
-
/**
|
|
131
|
-
* Send a new state to specified element with stateID
|
|
132
|
-
*
|
|
133
|
-
* @param stateID
|
|
134
|
-
* @param state
|
|
135
|
-
* @returns element(s)
|
|
136
|
-
*/
|
|
137
|
-
export function dispatch(
|
|
138
|
-
stateID: stateID | Record<stateID, stateType>,
|
|
139
|
-
state?: stateType
|
|
140
|
-
): any;
|
|
141
|
-
|
|
142
2
|
type ElementType<T> = (
|
|
143
3
|
...VJS: (
|
|
144
4
|
| string
|
|
@@ -157,71 +17,6 @@ declare module "cradova" {
|
|
|
157
17
|
}
|
|
158
18
|
)[]
|
|
159
19
|
) => T;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Cradova Router
|
|
163
|
-
* ---
|
|
164
|
-
* Facilitates navigation within the application and initializes
|
|
165
|
-
* page views based on the matched routes.
|
|
166
|
-
*/
|
|
167
|
-
type RouterType = {
|
|
168
|
-
/**
|
|
169
|
-
* Registers a route.
|
|
170
|
-
*
|
|
171
|
-
* @param {string} path Route path.
|
|
172
|
-
* @param {any} screen the cradova document tree for the route.
|
|
173
|
-
*/
|
|
174
|
-
route: (path: string, screen: Screen) => void;
|
|
175
|
-
/**
|
|
176
|
-
* get a screen ready before time.
|
|
177
|
-
*
|
|
178
|
-
* @param {string} path Route path.
|
|
179
|
-
* @param {any} data data for the screen.
|
|
180
|
-
*/
|
|
181
|
-
packageScreen: (path: string, data?: any) => Promise<void>;
|
|
182
|
-
onPageShow: (callback: () => void) => void;
|
|
183
|
-
onPageHide: (callback: () => void) => void;
|
|
184
|
-
/**
|
|
185
|
-
* Cradova Router
|
|
186
|
-
* ------
|
|
187
|
-
*
|
|
188
|
-
* return last set router params
|
|
189
|
-
*
|
|
190
|
-
* .
|
|
191
|
-
*/
|
|
192
|
-
getParams: <D>() => { data: D | unknown; params: any };
|
|
193
|
-
/**
|
|
194
|
-
* Cradova Router
|
|
195
|
-
* ------
|
|
196
|
-
*
|
|
197
|
-
* Navigates to a designated screen in your app
|
|
198
|
-
*/
|
|
199
|
-
navigate: (
|
|
200
|
-
href: string,
|
|
201
|
-
data?: Record<string, any> | null,
|
|
202
|
-
force?: boolean
|
|
203
|
-
) => void;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Cradova
|
|
207
|
-
* ---
|
|
208
|
-
* Error Handler for your app
|
|
209
|
-
*
|
|
210
|
-
* @param callback
|
|
211
|
-
* @param path? page path
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
addErrorHandler: (callback: (error: string) => void, path?: string) => void;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Cradova Router
|
|
219
|
-
* ---
|
|
220
|
-
* Facilitates navigation within the application and initializes
|
|
221
|
-
* page views based on the matched routes.
|
|
222
|
-
*/
|
|
223
|
-
export const Router: RouterType;
|
|
224
|
-
|
|
225
20
|
/**
|
|
226
21
|
*
|
|
227
22
|
*/
|
|
@@ -230,13 +25,19 @@ declare module "cradova" {
|
|
|
230
25
|
* Cradova screen
|
|
231
26
|
* ---
|
|
232
27
|
* title of the page
|
|
233
|
-
* @param data
|
|
234
|
-
* @returns void
|
|
235
28
|
*
|
|
236
29
|
*
|
|
237
30
|
* .
|
|
238
31
|
*/
|
|
239
32
|
name: string;
|
|
33
|
+
/**
|
|
34
|
+
* Cradova screen
|
|
35
|
+
* ---
|
|
36
|
+
* a css className to add to screen when rendering it
|
|
37
|
+
* Usually for adding css transitions
|
|
38
|
+
* .
|
|
39
|
+
*/
|
|
40
|
+
transition?: string;
|
|
240
41
|
/**
|
|
241
42
|
* Cradova screen
|
|
242
43
|
* ---
|
|
@@ -251,20 +52,19 @@ declare module "cradova" {
|
|
|
251
52
|
/**
|
|
252
53
|
* Cradova screen
|
|
253
54
|
* ---
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
55
|
+
* Allows this screen render in parallel for unique routes
|
|
56
|
+
*
|
|
57
|
+
* limit is 1000
|
|
58
|
+
*
|
|
257
59
|
*
|
|
258
60
|
*
|
|
259
61
|
* .
|
|
260
62
|
*/
|
|
261
|
-
|
|
63
|
+
renderInParallel?: boolean;
|
|
262
64
|
/**
|
|
263
65
|
* Cradova screen
|
|
264
66
|
* ---
|
|
265
67
|
* gets called when the the screen is displayed
|
|
266
|
-
* @param data
|
|
267
|
-
* @returns void
|
|
268
68
|
*
|
|
269
69
|
*
|
|
270
70
|
* .
|
|
@@ -273,113 +73,17 @@ declare module "cradova" {
|
|
|
273
73
|
* Cradova screen
|
|
274
74
|
* ---
|
|
275
75
|
* Should this screen be cached after first render?
|
|
276
|
-
*
|
|
277
|
-
* @returns void
|
|
278
|
-
*
|
|
76
|
+
* you can use Route.navigate(url, null, true) to force later
|
|
279
77
|
*
|
|
280
78
|
* .
|
|
281
79
|
*/
|
|
282
80
|
persist?: boolean;
|
|
283
81
|
};
|
|
284
82
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* @param name
|
|
290
|
-
* @param template
|
|
291
|
-
* @param transitions
|
|
292
|
-
*/
|
|
293
|
-
export class Screen {
|
|
294
|
-
/**
|
|
295
|
-
* this should be a cradova screen component
|
|
296
|
-
*/
|
|
297
|
-
private html;
|
|
298
|
-
/**
|
|
299
|
-
* this is the name of the screen that appears as the title
|
|
300
|
-
*/
|
|
301
|
-
private name;
|
|
302
|
-
private packed;
|
|
303
|
-
private secondaryChildren;
|
|
304
|
-
/**
|
|
305
|
-
* used internally
|
|
306
|
-
*/
|
|
307
|
-
private template;
|
|
308
|
-
private callBack;
|
|
309
|
-
private deCallBack;
|
|
310
|
-
errorHandler: (() => void) | null;
|
|
311
|
-
/**
|
|
312
|
-
* this tells cradova to persist state on the screen or not
|
|
313
|
-
* persisting is better
|
|
314
|
-
*/
|
|
315
|
-
private persist;
|
|
316
|
-
private data;
|
|
317
|
-
constructor(cradova_screen_initials: CradovaScreenType);
|
|
318
|
-
setErrorHandler(errorHandler: () => void): void;
|
|
319
|
-
package(): Promise<void>;
|
|
320
|
-
onActivate(cb: () => Promise<void> | void): void;
|
|
321
|
-
onDeactivate(cb: () => Promise<void> | void): void;
|
|
322
|
-
addChild(...addOns: any[]): void;
|
|
323
|
-
deActivate(): void;
|
|
324
|
-
Activate(force?: boolean): Promise<void>;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Cradova simpleStore
|
|
329
|
-
* ----
|
|
330
|
-
* create stateful data store.
|
|
331
|
-
* ability to:
|
|
332
|
-
* - create a store
|
|
333
|
-
* - set keys instead of all values
|
|
334
|
-
* - able to update state on any element as a property value
|
|
335
|
-
* @constructor initial: any, Ref/RefList/RefElement: any
|
|
336
|
-
*/
|
|
337
|
-
export class $<Type extends Record<string, unknown>> {
|
|
338
|
-
private ref;
|
|
339
|
-
value: Type;
|
|
340
|
-
constructor(initial: Type);
|
|
341
|
-
/**
|
|
342
|
-
* Cradova simpleStore
|
|
343
|
-
* ----
|
|
344
|
-
* set simpleStore value
|
|
345
|
-
* @param value - simpleStore value
|
|
346
|
-
* @returns void
|
|
347
|
-
*/
|
|
348
|
-
set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
|
|
349
|
-
/**
|
|
350
|
-
* Cradova
|
|
351
|
-
* ---
|
|
352
|
-
* is used to bind store data to any element
|
|
353
|
-
*
|
|
354
|
-
* @param prop
|
|
355
|
-
* @returns something
|
|
356
|
-
*/
|
|
357
|
-
bind(prop: string): (string | this)[];
|
|
358
|
-
private updateState;
|
|
359
|
-
/**
|
|
360
|
-
* Cradova simpleStore
|
|
361
|
-
* ----
|
|
362
|
-
* set a key value if it's an object
|
|
363
|
-
* @param name - name of the key
|
|
364
|
-
* @param value - value of the key
|
|
365
|
-
* @returns void
|
|
366
|
-
*/
|
|
367
|
-
setKey<k extends keyof Type>(
|
|
368
|
-
name: k,
|
|
369
|
-
value: any,
|
|
370
|
-
shouldRefRender?: boolean
|
|
371
|
-
): void;
|
|
372
|
-
/**
|
|
373
|
-
* Cradova simpleStore
|
|
374
|
-
* ----
|
|
375
|
-
* set a auto - rendering component for this store
|
|
376
|
-
*
|
|
377
|
-
* @param Ref component to bind to.
|
|
378
|
-
* @param path a property in the object to send to attached ref
|
|
379
|
-
*/
|
|
380
|
-
bindRef(ref: any, key: string, prop: string): void;
|
|
381
|
-
}
|
|
382
|
-
|
|
83
|
+
export const makeElement: (
|
|
84
|
+
element: Record<string, any>,
|
|
85
|
+
...ElementChildrenAndPropertyList: ElementType<HTMLElement>[]
|
|
86
|
+
) => Record<string, any>;
|
|
383
87
|
export const a: ElementType<HTMLAnchorElement>;
|
|
384
88
|
export const abbr: ElementType<HTMLElement>;
|
|
385
89
|
export const address: ElementType<HTMLElement>;
|
|
@@ -493,6 +197,30 @@ declare module "cradova" {
|
|
|
493
197
|
export const video: ElementType<HTMLVideoElement>;
|
|
494
198
|
export const wbr: ElementType<HTMLElement>;
|
|
495
199
|
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* Cradova Ajax
|
|
203
|
+
* ------------------
|
|
204
|
+
* your new axios alternative
|
|
205
|
+
* supports files upload
|
|
206
|
+
* @param url string
|
|
207
|
+
* @param {{method: string;data;header;callbacks;}} opts
|
|
208
|
+
* @returns any
|
|
209
|
+
*/
|
|
210
|
+
export function Ajax(
|
|
211
|
+
url: string | URL,
|
|
212
|
+
opts?:
|
|
213
|
+
| {
|
|
214
|
+
method?: "GET" | "POST";
|
|
215
|
+
data?: Record<string, any>;
|
|
216
|
+
header?: {
|
|
217
|
+
"content-type": string;
|
|
218
|
+
} & Record<string, any>;
|
|
219
|
+
callbacks?: Record<string, (arg: any) => void>;
|
|
220
|
+
}
|
|
221
|
+
| any
|
|
222
|
+
): Promise<unknown>;
|
|
223
|
+
|
|
496
224
|
/**
|
|
497
225
|
* Cradova afterMount event
|
|
498
226
|
*/
|
|
@@ -523,24 +251,13 @@ css(".btn:hover",
|
|
|
523
251
|
/**
|
|
524
252
|
*
|
|
525
253
|
* @param {expression} condition
|
|
526
|
-
* @param {function}
|
|
254
|
+
* @param {function} elements[]
|
|
527
255
|
*/
|
|
528
|
-
export function assert(
|
|
529
|
-
condition: any,
|
|
530
|
-
...callback: (() => any)[]
|
|
531
|
-
): "" | (() => any)[];
|
|
532
|
-
|
|
256
|
+
export function assert(condition: any, ...elements: any): any;
|
|
533
257
|
export function loop(
|
|
534
258
|
datalist: any[],
|
|
535
|
-
component: (value: any, index?: number, array?: any[]) =>
|
|
536
|
-
):
|
|
537
|
-
|
|
538
|
-
export function svgNS(
|
|
539
|
-
type: string,
|
|
540
|
-
props: Record<string, any>,
|
|
541
|
-
...children: any
|
|
542
|
-
): HTMLElement;
|
|
543
|
-
|
|
259
|
+
component: (value: any, index?: number, array?: any[]) => any
|
|
260
|
+
): HTMLElement | undefined;
|
|
544
261
|
export function assertOr(
|
|
545
262
|
condition: boolean,
|
|
546
263
|
ifTrue: () => any,
|
|
@@ -596,6 +313,206 @@ css(".btn:hover",
|
|
|
596
313
|
private Activate;
|
|
597
314
|
remove(): void;
|
|
598
315
|
}
|
|
316
|
+
export const svgNS: (
|
|
317
|
+
type: string,
|
|
318
|
+
props: Record<string, any>,
|
|
319
|
+
...children: any
|
|
320
|
+
) => HTMLElement;
|
|
321
|
+
export class lazy {
|
|
322
|
+
content: any;
|
|
323
|
+
private _cb;
|
|
324
|
+
constructor(cb: () => Promise<any>);
|
|
325
|
+
load(): Promise<void>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Cradova Signal
|
|
330
|
+
* ----
|
|
331
|
+
* create stateful data store.
|
|
332
|
+
* ability to:
|
|
333
|
+
* - create store
|
|
334
|
+
* - create actions and fire them
|
|
335
|
+
* - bind a Ref
|
|
336
|
+
* - listen to changes
|
|
337
|
+
* - persist changes to localStorage
|
|
338
|
+
* - set keys instead of all values
|
|
339
|
+
* - update a cradova Ref and bindings automatically
|
|
340
|
+
* @constructor initial: any, props: {useHistory, persist}
|
|
341
|
+
*/
|
|
342
|
+
|
|
343
|
+
export class createSignal<Type extends Record<string, any>> {
|
|
344
|
+
private callback;
|
|
345
|
+
private persistName;
|
|
346
|
+
private actions;
|
|
347
|
+
private ref;
|
|
348
|
+
value: Type;
|
|
349
|
+
constructor(
|
|
350
|
+
initial: Type,
|
|
351
|
+
props?: {
|
|
352
|
+
persistName?: string | undefined;
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
/**
|
|
356
|
+
* Cradova Signal
|
|
357
|
+
* ----
|
|
358
|
+
* set signal value
|
|
359
|
+
* @param value - signal value
|
|
360
|
+
* @returns void
|
|
361
|
+
*/
|
|
362
|
+
set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
|
|
363
|
+
/**
|
|
364
|
+
* Cradova Signal
|
|
365
|
+
* ----
|
|
366
|
+
* set a key value if it's an object
|
|
367
|
+
* @param key - key of the key
|
|
368
|
+
* @param value - value of the key
|
|
369
|
+
* @returns void
|
|
370
|
+
*/
|
|
371
|
+
setKey<k extends keyof Type>(
|
|
372
|
+
key: k,
|
|
373
|
+
value: any,
|
|
374
|
+
shouldRefRender?: boolean
|
|
375
|
+
): void;
|
|
376
|
+
/**
|
|
377
|
+
* Cradova Signal
|
|
378
|
+
* ----
|
|
379
|
+
* set a key to signal an action
|
|
380
|
+
* @param key - key of the action
|
|
381
|
+
* @param action function to execute
|
|
382
|
+
*/
|
|
383
|
+
createAction(
|
|
384
|
+
key: string | Record<string, (data?: Type) => void>,
|
|
385
|
+
action?: ((data?: Type) => void) | Ref<unknown>
|
|
386
|
+
): void;
|
|
387
|
+
/**
|
|
388
|
+
* Cradova Signal
|
|
389
|
+
* ----
|
|
390
|
+
* fires an action if available
|
|
391
|
+
* @param key - string key of the action
|
|
392
|
+
* @param data - data for the action
|
|
393
|
+
*/
|
|
394
|
+
fireAction(key: string, data?: Type): void;
|
|
395
|
+
/**
|
|
396
|
+
* Cradova
|
|
397
|
+
* ---
|
|
398
|
+
* is used to bind store data to an element
|
|
399
|
+
*
|
|
400
|
+
* @param prop
|
|
401
|
+
* @returns something
|
|
402
|
+
*/
|
|
403
|
+
bind(prop: string): (string | this)[];
|
|
404
|
+
private _updateState;
|
|
405
|
+
/**
|
|
406
|
+
* Cradova Signal
|
|
407
|
+
* ----
|
|
408
|
+
* set a auto - rendering component for this store
|
|
409
|
+
*
|
|
410
|
+
* @param Ref component to bind to.
|
|
411
|
+
* @param path a property in the object to send to attached ref
|
|
412
|
+
*/
|
|
413
|
+
bindRef(
|
|
414
|
+
ref: any,
|
|
415
|
+
binding: {
|
|
416
|
+
event?: string;
|
|
417
|
+
signalProperty: string;
|
|
418
|
+
_element_property: string;
|
|
419
|
+
}
|
|
420
|
+
): void;
|
|
421
|
+
/**
|
|
422
|
+
* Cradova Signal
|
|
423
|
+
* ----
|
|
424
|
+
* set a update listener on value changes
|
|
425
|
+
* @param callback
|
|
426
|
+
*/
|
|
427
|
+
listen(callback: (a: any) => void): void;
|
|
428
|
+
/**
|
|
429
|
+
* Cradova Signal
|
|
430
|
+
* ----
|
|
431
|
+
* clear the history on local storage
|
|
432
|
+
*
|
|
433
|
+
*
|
|
434
|
+
* .
|
|
435
|
+
*/
|
|
436
|
+
clearPersist(): void;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
type stateType =
|
|
440
|
+
| Partial<HTMLElement>
|
|
441
|
+
| {
|
|
442
|
+
class?: string;
|
|
443
|
+
text?: string;
|
|
444
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
445
|
+
tree?: Function | HTMLElement;
|
|
446
|
+
remove?: boolean;
|
|
447
|
+
};
|
|
448
|
+
type stateID = string;
|
|
449
|
+
/**
|
|
450
|
+
* Send a new state to specified element with stateID
|
|
451
|
+
*
|
|
452
|
+
* @param stateID
|
|
453
|
+
* @param state
|
|
454
|
+
* @returns element(s)
|
|
455
|
+
*/
|
|
456
|
+
export function dispatch(
|
|
457
|
+
stateID: stateID | Record<stateID, stateType>,
|
|
458
|
+
state?: stateType
|
|
459
|
+
): any;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Cradova Router
|
|
463
|
+
* ---
|
|
464
|
+
* Facilitates navigation within the application and initializes
|
|
465
|
+
* page views based on the matched routes.
|
|
466
|
+
*/
|
|
467
|
+
export const Router: Record<string, any>;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Cradova Screen
|
|
471
|
+
* ---
|
|
472
|
+
* create instances of manageable pages and scaffolds
|
|
473
|
+
* @param name
|
|
474
|
+
* @param template
|
|
475
|
+
* @param transitions
|
|
476
|
+
*/
|
|
477
|
+
export class Screen {
|
|
478
|
+
/**
|
|
479
|
+
* this should be a cradova screen component
|
|
480
|
+
*/
|
|
481
|
+
_html: Function;
|
|
482
|
+
/**
|
|
483
|
+
* this is a set of added html to the screen
|
|
484
|
+
*/
|
|
485
|
+
_secondaryChildren: Array<Node>;
|
|
486
|
+
/**
|
|
487
|
+
* error handler for the screen
|
|
488
|
+
*/
|
|
489
|
+
errorHandler: (() => void) | null;
|
|
490
|
+
/**
|
|
491
|
+
* used internally
|
|
492
|
+
*/
|
|
493
|
+
_name: string;
|
|
494
|
+
private _packed;
|
|
495
|
+
private _template;
|
|
496
|
+
private _callBack;
|
|
497
|
+
private _deCallBack;
|
|
498
|
+
private _persist;
|
|
499
|
+
private _data;
|
|
500
|
+
_params: Record<string, any> | null;
|
|
501
|
+
private _delegatedRoutesCount;
|
|
502
|
+
private _transition;
|
|
503
|
+
constructor(cradova_screen_initials: CradovaScreenType);
|
|
504
|
+
get _delegatedRoutes(): boolean;
|
|
505
|
+
set _delegatedRoutes(count: boolean);
|
|
506
|
+
get _paramData(): typeof this._params;
|
|
507
|
+
set _paramData(params: typeof this._params);
|
|
508
|
+
setErrorHandler(errorHandler: () => void): void;
|
|
509
|
+
_package(): Promise<void>;
|
|
510
|
+
onActivate(cb: () => Promise<void> | void): void;
|
|
511
|
+
onDeactivate(cb: () => Promise<void> | void): void;
|
|
512
|
+
addChild(...addOns: any[]): void;
|
|
513
|
+
_deActivate(): Promise<void>;
|
|
514
|
+
_Activate(force?: boolean): Promise<void>;
|
|
515
|
+
}
|
|
599
516
|
|
|
600
517
|
/**
|
|
601
518
|
* Cradova
|
|
@@ -617,11 +534,6 @@ css(".btn:hover",
|
|
|
617
534
|
* color: "blue"
|
|
618
535
|
* }
|
|
619
536
|
* })
|
|
620
|
-
* // or no style props it works!
|
|
621
|
-
* _("p",{
|
|
622
|
-
* text: "am a p tag",
|
|
623
|
-
* color: "blue"
|
|
624
|
-
* })
|
|
625
537
|
*
|
|
626
538
|
* // props and children
|
|
627
539
|
* _("p", // template first
|
|
@@ -632,17 +544,6 @@ css(".btn:hover",
|
|
|
632
544
|
* ...
|
|
633
545
|
* )
|
|
634
546
|
*
|
|
635
|
-
* // list of children
|
|
636
|
-
* _("p",
|
|
637
|
-
* // all children goes after
|
|
638
|
-
* _("span",
|
|
639
|
-
* {
|
|
640
|
-
* text:" am a span tag like so",
|
|
641
|
-
* color: "brown",
|
|
642
|
-
* }),
|
|
643
|
-
* ...
|
|
644
|
-
* )
|
|
645
|
-
*
|
|
646
547
|
* @param {...any[]} element_initials
|
|
647
548
|
* @returns function - cradova element
|
|
648
549
|
*/
|