cradova 3.1.4 → 3.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "Web framework for building web apps and PWAs",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -62,7 +62,6 @@
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",
66
65
  "eslint": "^8.30.0",
67
66
  "eslint-config-prettier": "^8.5.0",
68
67
  "eslint-plugin-prettier": "^4.2.1",
@@ -71,5 +70,8 @@
71
70
  "ts-jest": "^29.0.3",
72
71
  "tsup": "^6.7.0",
73
72
  "typescript": "^4.9.4"
73
+ },
74
+ "dependencies": {
75
+ "csstype": "^3.1.2"
74
76
  }
75
77
  }
package/dist/index.d.ts DELETED
@@ -1,677 +0,0 @@
1
- /*
2
- ============================================================================="
3
- ██████╗ ██████╗ █████═╗ ███████╗ ███████╗ ██╗ ██╗ █████╗
4
- ██╔════╝ ██╔══██╗ ██╔═╗██║ █ ██ ██╔═════╝█ ██║ ██║ ██╔═╗██
5
- ██║ ██████╔╝ ███████║ █ ██ ██║ ██ ██║ ██║ ██████╗
6
- ██║ ██╔══██╗ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██╗
7
- ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ████████ ╚███╔╝ ██║ ██║
8
- ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚══╝ ╚═╝ ╚═╝
9
- =============================================================================
10
- Cradova FrameWork
11
- @version 3.0.0
12
- License: Apache V2
13
- Copyright 2022 Friday Candour.
14
- Repository - https://github.com/fridaycandour/cradova
15
- =============================================================================
16
- */
17
-
18
- import * as CSS from "csstype";
19
-
20
- declare module "cradova" {
21
- /**
22
- * Cradova Signal
23
- * ----
24
- * Create stateful data store.
25
- * Features:
26
- * - create a store
27
- * - create actions and fire them
28
- * - bind a Ref and elements
29
- * - listen to updates
30
- * - set object keys instead of all values
31
- * - persist changes to localStorage
32
- * - update a cradova Ref automatically
33
- * @constructor initial: unknown, props: {useHistory, persist}
34
- */
35
- export class createSignal<Type extends Record<string, unknown>> {
36
- private callback;
37
- private persistName;
38
- private actions;
39
- private ref;
40
- value: Type;
41
- constructor(
42
- initial: Type,
43
- props?: {
44
- persistName?: string | undefined;
45
- }
46
- );
47
- /**
48
- * Cradova Signal
49
- * ----
50
- * set signal value
51
- * @param value - signal value
52
- * @returns void
53
- */
54
- set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
55
- /**
56
- * Cradova Signal
57
- * ----
58
- * set a key value if it's an object
59
- * @param key - key of the key
60
- * @param value - value of the key
61
- * @returns void
62
- */
63
- setKey<k extends keyof Type>(
64
- key: k,
65
- value: unknown,
66
- shouldRefRender?: boolean
67
- ): void;
68
- /**
69
- * Cradova Signal
70
- * ----
71
- * set a key to signal an action
72
- * @param name - name of the action
73
- * @param action function to execute
74
- */
75
- createAction(name: string, action: (data?: unknown) => void): void;
76
- /**
77
- * Cradova Signal
78
- * ----
79
- * creates man y actions at a time
80
- * @param name - name of the action
81
- * @param action function to execute
82
- */
83
- createActions(Actions: Record<string, (data?: unknown) => void>): void;
84
- /**
85
- * Cradova Signal
86
- * ----
87
- * fires an action if available
88
- * @param key - string key of the action
89
- * @param data - data for the action
90
- */
91
- fireAction(key: string, data?: Type): Type;
92
- /**
93
- * Cradova
94
- * ---
95
- * is used to bind signal data to elements and Refs
96
- *
97
- * @param prop
98
- * @returns something
99
- */
100
- bind(prop: string): any;
101
- private _updateState;
102
- /**
103
- * Cradova Signal
104
- * ----
105
- * set a auto - rendering component for this store
106
- *
107
- * @param Ref component to bind to.
108
- * @param path a property in the object to send to attached ref
109
- */
110
- bindRef(
111
- ref: Partial<Ref<unknown>>,
112
- binding?: {
113
- event?: string;
114
- signalProperty: string;
115
- _element_property: string;
116
- }
117
- ): void;
118
- /**
119
- * Cradova Signal
120
- * ----
121
- * set a update listener on value changes
122
- * @param callback
123
- */
124
- listen(callback: (a: Type) => void): void;
125
- /**
126
- * Cradova Signal
127
- * ----
128
- * clear the history on local storage
129
- *
130
- */
131
- clearPersist(): void;
132
- }
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;
147
- export function css(identifier: string | TemplateStringsArray): void;
148
- /**
149
- *
150
- * @param {expression} condition
151
- * @param {function} elements[]
152
- */
153
- export function assert<Type>(
154
- condition: boolean,
155
- ...elements: VJS_Child_TYPE<Type | 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>;
162
- type LoopData<Type> = Type[];
163
- export function loop<Type>(
164
- datalist: LoopData<Type>,
165
- component: (
166
- value: Type,
167
- index?: number,
168
- array?: LoopData<Type>
169
- ) => HTMLElement | DocumentFragment | undefined
170
- ): HTMLElement[] | undefined;
171
- /**
172
- * Cradova Ref
173
- * -------
174
- * create dynamic components
175
- */
176
- export class Ref<D> {
177
- private component;
178
- private effects;
179
- private effectuate;
180
- private rendered;
181
- private published;
182
- private preRendered;
183
- private reference;
184
- Signal: createSignal<any> | undefined;
185
- _state: D[];
186
- _state_track: {
187
- [x: number]: boolean;
188
- };
189
- _state_index: number;
190
- stash: D | undefined;
191
- constructor(
192
- component: (this: Ref<D>, data: D) => HTMLElement | DocumentFragment
193
- );
194
- preRender(data?: D): void;
195
- destroyPreRendered(): void;
196
- /**
197
- * Cradova Ref
198
- * ---
199
- * returns html with cradova reference
200
- * @param data
201
- * @returns () => HTMLElement
202
- */
203
- render(data?: D, stash?: boolean): HTMLElement | DocumentFragment;
204
- instance(): Record<string, any>;
205
- _setExtra(Extra: createSignal<any>): void;
206
- _roll_state(data: D, idx: number, get?: boolean): D;
207
- _effect(fn: () => Promise<void> | void): void;
208
- private effector;
209
- /**
210
- * Cradova Ref
211
- * ---
212
- * update ref component with new data and update the dom.
213
- * @param data
214
- * @returns
215
- */
216
- updateState(data?: D, stash?: boolean): void;
217
- private Activate;
218
- }
219
- /**
220
- * Document fragment
221
- * @param children
222
- * @returns
223
- */
224
- export const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
225
- /**
226
- * cradova
227
- * ---
228
- * lazy load a file
229
- */
230
- export class lazy<Type> {
231
- content: Type | undefined;
232
- private _cb;
233
- constructor(cb: () => Promise<unknown>);
234
- load(): Promise<void>;
235
- }
236
- /**
237
- * Cradova
238
- * ---
239
- * make reference to dom elements
240
- */
241
- export class reference {
242
- [x: string]: Record<string, any>;
243
- bindAs(name: string): reference;
244
- dom<ElementType>(name: string): ElementType | undefined;
245
- _appendDomForce(name: string, Element: HTMLElement): void;
246
- }
247
- /**
248
- * Cradova
249
- * ---
250
- * Allows functional components to manage state by providing a state value and a function to update it.
251
- * @param initialValue
252
- * @param ActiveRef
253
- * @returns [state, setState]
254
- */
255
- export function useState<S = unknown>(
256
- initialValue: S,
257
- ActiveRef: Ref<unknown>
258
- ): [S, (newState: S) => void];
259
- /**
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
- */
266
- export function useEffect(effect: () => void, ActiveRef: Ref<unknown>): void;
267
- /**
268
- * Cradova
269
- * ---
270
- Returns a mutable reference object of dom elements that persists across component renders.
271
- * @returns reference
272
- */
273
- export function useRef(): Record<string, HTMLElement | undefined>;
274
-
275
- /**
276
- * Cradova Screen
277
- * ---
278
- * create instances of manageable pages and scaffolds
279
- * @param name
280
- * @param template
281
- * @param transitions
282
- */
283
- export class Screen {
284
- /**
285
- * this should be a cradova screen component
286
- */
287
- _html:
288
- | ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment)
289
- | HTMLElement
290
- | DocumentFragment;
291
- /**
292
- * this is a set of added html to the screen
293
- */
294
- /**
295
- * error handler for the screen
296
- */
297
- _errorHandler: ((err: unknown) => void) | null;
298
- /**
299
- * used internally
300
- */
301
- _name: string;
302
- private _packed;
303
- private _template;
304
- private _callBack;
305
- private _deCallBack;
306
- private _persist;
307
- private _delegatedRoutesCount;
308
- private _transition;
309
- private _dropped;
310
- constructor(cradova_screen_initials: CradovaScreenType);
311
- get _delegatedRoutes(): boolean;
312
- set _delegatedRoutes(count: boolean);
313
- setErrorHandler(errorHandler: (err: unknown) => void): void;
314
- _package(): Promise<void>;
315
- onActivate(cb: () => Promise<void> | void): void;
316
- onDeactivate(cb: () => Promise<void> | void): void;
317
- _deActivate(): Promise<void>;
318
- drop(state: boolean): boolean | undefined;
319
- _Activate(force?: boolean): Promise<void>;
320
- }
321
-
322
- type DataAttributes = {
323
- [key: `data-${string}`]: string;
324
- };
325
- type AriaAttributes = {
326
- [key: `aria-${string}`]: string;
327
- };
328
- type VJSType<T> = (
329
- ...VJS: (
330
- | undefined
331
- | string
332
- | HTMLElement
333
- | HTMLElement[]
334
- | DocumentFragment
335
- | DocumentFragment[]
336
- | TemplateStringsArray
337
- | Partial<T>
338
- | (() => HTMLElement)
339
- | Partial<DataAttributes>
340
- | Partial<AriaAttributes>
341
- | CSS.Properties
342
- | {
343
- style?: CSS.Properties;
344
- onmount?: (this: T) => void;
345
- reference?: reference;
346
- }
347
- )[]
348
- ) => T;
349
- type VJS_params_TYPE<T> = (
350
- | undefined
351
- | string
352
- | HTMLElement
353
- | HTMLElement[]
354
- | DocumentFragment
355
- | DocumentFragment[]
356
- | TemplateStringsArray
357
- | Partial<T>
358
- | (() => HTMLElement)
359
- | Partial<DataAttributes>
360
- | Partial<AriaAttributes>
361
- | CSS.Properties<string | number>
362
- | {
363
- src?: string;
364
- href?: string;
365
- placeholder?: string;
366
- type?: string;
367
- action?: string;
368
- name?: string;
369
- alt?: string;
370
- for?: string;
371
- method?: string;
372
- rows?: string;
373
- value?: string;
374
- target?: string;
375
- rel?: string;
376
- required?: string;
377
- frameBorder?: string;
378
- style?: CSS.Properties;
379
- onmount?: (this: T) => void;
380
- reference?: reference;
381
- }
382
- )[];
383
- type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
384
- type CradovaScreenType<T = unknown> = {
385
- /**
386
- * Cradova screen
387
- * ---
388
- * title of the page
389
- * .
390
- */
391
- name: string;
392
- /**
393
- * Cradova screen
394
- * ---
395
- * a css className to add to screen when rendering it
396
- * Usually for adding css transitions
397
- * .
398
- */
399
- transition?: string;
400
- /**
401
- * Cradova screen
402
- * ---
403
- * The component for the screen
404
- * @param data
405
- * @returns void
406
- * .
407
- */
408
- template:
409
- | ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment)
410
- | HTMLElement
411
- | DocumentFragment;
412
- /**
413
- * Cradova screen
414
- * ---
415
- * Allows this screen render in parallel for unique routes
416
- *
417
- * limit is 1000
418
- *
419
- * .
420
- */
421
- renderInParallel?: boolean;
422
- /**
423
- * Cradova screen
424
- * ---
425
- * Should this screen be cached after first render?
426
- * you can use Route.navigate(url, null, true) to force later
427
- *
428
- * .
429
- */
430
- persist?: boolean;
431
- };
432
-
433
- export const makeElement: <E extends HTMLElement>(
434
- element: E & HTMLElement,
435
- ElementChildrenAndPropertyList: VJS_params_TYPE<E>
436
- ) => E;
437
- export const make: (descriptor: any) => any[];
438
- export const a: VJSType<HTMLAnchorElement>;
439
- export const area: VJSType<HTMLAreaElement>;
440
- export const article: VJSType<HTMLElement>;
441
- export const aside: VJSType<HTMLElement>;
442
- export const audio: VJSType<HTMLAudioElement>;
443
- export const b: VJSType<HTMLElement>;
444
- export const base: VJSType<HTMLBaseElement>;
445
- export const blockquote: VJSType<HTMLElement>;
446
- export const br: VJSType<HTMLBRElement>;
447
- export const button: VJSType<HTMLButtonElement>;
448
- export const canvas: VJSType<HTMLCanvasElement>;
449
- export const caption: VJSType<HTMLTableCaptionElement>;
450
- export const code: VJSType<HTMLElement>;
451
- export const col: VJSType<HTMLTableColElement>;
452
- export const colgroup: VJSType<HTMLOptGroupElement>;
453
- export const data: VJSType<HTMLDataElement>;
454
- export const datalist: VJSType<HTMLDataListElement>;
455
- export const details: VJSType<HTMLDetailsElement>;
456
- export const dialog: VJSType<HTMLDialogElement>;
457
- export const div: VJSType<HTMLDivElement>;
458
- export const em: VJSType<HTMLElement>;
459
- export const embed: VJSType<HTMLEmbedElement>;
460
- export const figure: VJSType<HTMLElement>;
461
- export const footer: VJSType<HTMLElement>;
462
- export const form: VJSType<HTMLFormElement>;
463
- export const h1: VJSType<HTMLHeadingElement>;
464
- export const h2: VJSType<HTMLHeadingElement>;
465
- export const h3: VJSType<HTMLHeadingElement>;
466
- export const h4: VJSType<HTMLHeadingElement>;
467
- export const h5: VJSType<HTMLHeadingElement>;
468
- export const h6: VJSType<HTMLHeadingElement>;
469
- export const head: VJSType<HTMLHeadElement>;
470
- export const header: VJSType<HTMLHeadElement>;
471
- export const hr: VJSType<HTMLHRElement>;
472
- export const i: VJSType<HTMLLIElement>;
473
- export const iframe: VJSType<HTMLIFrameElement>;
474
- export const img: VJSType<HTMLImageElement>;
475
- export const input: VJSType<HTMLInputElement>;
476
- export const label: VJSType<HTMLLabelElement>;
477
- export const legend: VJSType<HTMLLegendElement>;
478
- export const li: VJSType<HTMLLIElement>;
479
- export const link: VJSType<HTMLLinkElement>;
480
- export const main: VJSType<HTMLElement>;
481
- export const menu: VJSType<HTMLMenuElement>;
482
- export const nav: VJSType<HTMLElement>;
483
- export const object: VJSType<HTMLObjectElement>;
484
- export const ol: VJSType<HTMLOListElement>;
485
- export const optgroup: VJSType<HTMLOptGroupElement>;
486
- export const option: VJSType<HTMLOptionElement>;
487
- export const p: VJSType<HTMLParagraphElement>;
488
- export const pre: VJSType<HTMLPreElement>;
489
- export const progress: VJSType<HTMLProgressElement>;
490
- export const q: VJSType<HTMLQuoteElement>;
491
- export const section: VJSType<HTMLElement>;
492
- export const select: VJSType<HTMLSelectElement>;
493
- export const source: VJSType<HTMLSourceElement>;
494
- export const span: VJSType<HTMLSpanElement>;
495
- export const strong: VJSType<HTMLElement>;
496
- export const summary: VJSType<HTMLElement>;
497
- export const table: VJSType<HTMLTableElement>;
498
- export const tbody: VJSType<HTMLTableColElement>;
499
- export const td: VJSType<HTMLTableCellElement>;
500
- export const template: VJSType<HTMLTemplateElement>;
501
- export const textarea: VJSType<HTMLTextAreaElement>;
502
- export const th: VJSType<HTMLTableSectionElement>;
503
- export const title: VJSType<HTMLTitleElement>;
504
- export const tr: VJSType<HTMLTableRowElement>;
505
- export const track: VJSType<HTMLTrackElement>;
506
- export const u: VJSType<HTMLUListElement>;
507
- export const ul: VJSType<HTMLUListElement>;
508
- export const video: VJSType<HTMLVideoElement>;
509
-
510
- /** cradova router
511
- * ---
512
- * Registers a route.
513
- *
514
- * @param {string} path Route path.
515
- * @param screen the cradova document tree for the route.
516
- */
517
- export class Router {
518
- /** cradova router
519
- * ---
520
- * Registers a route.
521
- *
522
- * accepts an object containing
523
- *
524
- * @param {string} path Route path.
525
- * @param screen the cradova screen.
526
- */
527
- static BrowserRoutes(obj: Record<string, any>): void;
528
- /**
529
- Go back in Navigation history
530
- */
531
- static back(): void;
532
- /**
533
- Go forward in Navigation history
534
- */
535
- static forward(): void;
536
- /**
537
- Pause navigation
538
- */
539
- static pauseNaviagtion(): void;
540
- /**
541
- resume navigation
542
- */
543
- static resumeNaviagtion(): void;
544
- /**
545
- * Cradova Router
546
- * ------
547
- *
548
- * Navigates to a designated screen in your app
549
- *
550
- * @param href string
551
- * @param data object
552
- * @param force boolean
553
- */
554
- static navigate(
555
- href: string,
556
- data?: Record<string, unknown> | null,
557
- force?: boolean
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;
568
- /**
569
- * Cradova
570
- * ---
571
- * Loading screen for your app
572
- *
573
- * lazy loaded loading use
574
- *
575
- * @param screen
576
- */
577
- static setLoadingScreen(screen: Screen): void;
578
- /** cradova router
579
- * ---
580
- * Listen for navigation events
581
- *
582
- * @param callback () => void
583
- */
584
- static onPageEvent(callback: () => void): void;
585
- /** cradova router
586
- * ---
587
- * get a screen ready before time.
588
- *
589
- * @param {string} path Route path.
590
- * @param data data for the screen.
591
- */
592
- static packageScreen(
593
- path: string,
594
- data?: Record<string, unknown>
595
- ): Promise<void>;
596
- /**
597
- * Cradova Router
598
- * ------
599
- *
600
- * return last set router params
601
- *
602
- * .
603
- */
604
- static getParams(): any;
605
- /**
606
- * Cradova
607
- * ---
608
- * Error Handler for your app
609
- *
610
- * @param callback
611
- * @param path? page path
612
- */
613
- static addErrorHandler(callback: (err: unknown) => void): void;
614
- static _mount(): void;
615
- }
616
-
617
- /**
618
- *
619
- * Cradova Ajax
620
- * ------------------
621
- * your new axios alternative
622
- * supports files upload
623
- * @param url string
624
- * @param {{method: string;data;header;callbacks;}} opts
625
- * @returns unknown
626
- */
627
- export function Ajax(
628
- url: string | URL,
629
- opts?: {
630
- method?: "GET" | "POST";
631
- data?: Record<string, unknown>;
632
- header?: {
633
- "content-type"?: string;
634
- } & Record<string, string>;
635
- callbacks?: Record<string, (arg: Function) => void>;
636
- }
637
- ): Promise<string>;
638
-
639
- type TemplateType = <E extends HTMLElement>(
640
- ...element_initials: VJS_params_TYPE<E | HTMLElement>
641
- ) => E | HTMLElement | DocumentFragment;
642
- /**
643
- * Cradova
644
- * ---
645
- * Creates new cradova HTML element
646
- * @example
647
- * // using template
648
- * const p = _("p");
649
- * _("p.class");
650
- * _("p#id");
651
- * _("p.class#id");
652
- * _("p.foo.bar#poo.loo");
653
- *
654
- * // using inline props
655
- *
656
- * _("p",{
657
- * text: "am a p tag",
658
- * style: {
659
- * color: "blue"
660
- * }
661
- * })
662
- *
663
- * // props and children
664
- * _("p", // template first
665
- * // property next if wanted
666
- * {style: {color: "brown"}, // optional
667
- * // the rest should be children or text
668
- * _("span", " am a span tag text like so"),
669
- * ...
670
- * )
671
- *
672
- * @param element_initials
673
- * @returns function - cradova element
674
- */
675
- const _: TemplateType;
676
- export default _;
677
- }