cradova 3.3.1 → 3.3.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
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2023 friday candour
189
+ Copyright 2022 friday candour
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -511,9 +511,9 @@ Join Us on [telegram](https://t.me/UiedbookHQ).
511
511
 
512
512
  If you contribute code to this project, you are implicitly allowing your code to be distributed under same license. You are also implicitly verifying that all code is your original work.
513
513
 
514
- ## Supporting Exabase development
514
+ ## Supporting Cradova development
515
515
 
516
- Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova, Exabase, JetPath etc, growth and improvement by making a re-occuring or fixed sponsorship
516
+ Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova, Cradova, JetPath etc, growth and improvement by making a re-occuring or fixed sponsorship
517
517
  to [github sponsors](https://github.com/sponsors/FridayCandour):
518
518
  or crypto using
519
519
  etheruen: `0xD7DDD4312A4e514751A582AF725238C7E6dF206c`,
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.3.1",
3
+ "version": "3.3.4",
4
4
  "description": "Web framework for building powerful web apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist/index.d.ts",
9
+ "dist/primitives/**",
9
10
  "dist/index.js"
10
11
  ],
11
12
  "repository": {
@@ -65,9 +66,7 @@
65
66
  "eslint": "^8.30.0",
66
67
  "eslint-config-prettier": "^8.5.0",
67
68
  "eslint-plugin-prettier": "^4.2.1",
68
- "prettier": "^2.8.1",
69
- "tsup": "^6.7.0",
70
- "typescript": "^4.9.4"
69
+ "prettier": "^2.8.1"
71
70
  },
72
71
  "dependencies": {
73
72
  "csstype": "^3.1.2"
package/dist/index.d.ts DELETED
@@ -1,639 +0,0 @@
1
-
2
- /*
3
- ============================================================================="
4
- ██████╗ ██████╗ █████═╗ ███████╗ ███████╗ ██╗ ██╗ █████╗
5
- ██╔════╝ ██╔══██╗ ██╔═╗██║ █ ██ ██╔═════╝█ ██║ ██║ ██╔═╗██
6
- ██║ ██████╔╝ ███████║ █ ██ ██║ ██ ██║ ██║ ██████╗
7
- ██║ ██╔══██╗ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██╗
8
- ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ████████ ╚███╔╝ ██║ ██║
9
- ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚══╝ ╚═╝ ╚═╝
10
- =============================================================================
11
- Cradova
12
- @version 3.3.0
13
- License: Apache V2
14
- Copyright 2022 Friday Candour.
15
- Repository - https://github.com/fridaycandour/cradova
16
- =============================================================================
17
- */
18
- import * as CSS from 'csstype';
19
-
20
- /*! *****************************************************************************
21
- Copyright 2022 Friday Candour. All rights reserved.
22
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
23
- this file except in compliance with the License. You may obtain a copy of the
24
- License at http://www.apache.org/licenses/LICENSE-2.0
25
-
26
- See the Apache Version 2.0 License for specific language governing permissions
27
- and limitations under the License.
28
- ********************************************************************************/
29
-
30
- /**
31
- * Cradova event
32
- */
33
- declare class cradovaEvent {
34
- private listeners;
35
- private active_listeners;
36
- addEventListener(eventName: string, callback: () => void): Promise<void>;
37
- addActiveEventListener(eventName: string, callback: () => void): Promise<void>;
38
- dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
39
- /**
40
- * Active refs is a concept for delegated screens to keep their active refs alive
41
- * even in the case of naviagtion
42
- * @param eventName
43
- * @param eventArgs
44
- */
45
- dispatchActiveEvent(eventName: string, eventArgs?: unknown): Promise<void>;
46
- }
47
- declare const CradovaEvent: cradovaEvent;
48
- /**
49
- * Cradova Ref
50
- * -------
51
- * create dynamic components
52
- */
53
- declare class Ref<Prop extends Record<string, any> = any> {
54
- private component;
55
- private effects;
56
- private effectuate;
57
- methods: Record<string, Function>;
58
- private rendered;
59
- private published;
60
- private preRendered;
61
- private reference;
62
- Signal: createSignal<any> | undefined;
63
- _state: Prop[];
64
- _state_track: {
65
- [x: number]: boolean;
66
- };
67
- _state_index: number;
68
- stash: Prop | undefined;
69
- constructor(component: (this: Ref<Prop>, data: Prop) => HTMLElement | DocumentFragment);
70
- preRender(data?: Prop, stash?: boolean): void;
71
- destroyPreRendered(): void;
72
- /**
73
- * Cradova Ref
74
- * ---
75
- * construct to add custom methods to Refs
76
- * @param methodName
77
- * @param method
78
- * @returns void
79
- */
80
- define(methodName: string, method: (this: this, ...arg: any) => void): void;
81
- /**
82
- * Cradova Ref
83
- * ---
84
- * returns html with cradova reference
85
- * @param data
86
- * @returns () => HTMLElement
87
- */
88
- render(data?: Prop, stash?: boolean): HTMLElement | DocumentFragment;
89
- instance(): HTMLElement;
90
- _setExtra(Extra: createSignal<any>): void;
91
- _roll_state(data: any, idx: number, get?: boolean): Prop;
92
- _effect(fn: () => Promise<void> | void): void;
93
- private effector;
94
- /**
95
- * Cradova Ref
96
- * ---
97
- * update ref component with new data and update the dom.
98
- * @param data
99
- * @returns
100
- */
101
- updateState(data?: Prop, stash?: boolean): void;
102
- private Activate;
103
- }
104
- /**
105
- * cradova
106
- * ---
107
- * lazy load a file
108
- */
109
- declare class lazy<Type> {
110
- content: Type | undefined;
111
- private _cb;
112
- constructor(cb: () => Promise<unknown>);
113
- load(): Promise<void>;
114
- }
115
- /**
116
- * Cradova
117
- * ---
118
- * make reference to dom elements
119
- */
120
- declare class reference {
121
- tree: Record<string, any>;
122
- globalTree: Record<string, HTMLElement>;
123
- /**
124
- * Bind a DOM element to a reference name.
125
- * @param name - The name to reference the DOM element by.
126
- */
127
- bindAs(name: string): reference;
128
- /**
129
- * Retrieve a referenced DOM element.
130
- * @param name - The name of the referenced DOM element.
131
- */
132
- current<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType;
133
- /**
134
- * Append a DOM element to the reference, overwriting any existing reference.
135
- * @param name - The name to reference the DOM element by.
136
- * @param element - The DOM element to reference.
137
- */
138
- _appendDomForce(name: string, Element: HTMLElement): void;
139
- _appendDomForceGlobal(name: string, Element: HTMLElement): void;
140
- }
141
- /**
142
- * Cradova Signal
143
- * ----
144
- * Create stateful data store.
145
- * Features:
146
- * - create a store
147
- * - create actions and fire them
148
- * - bind a Ref and elements
149
- * - listen to updates
150
- * - set object keys instead of all values
151
- * - persist changes to localStorage
152
- * - update a cradova Ref automatically
153
- * @constructor initial: unknown, props: {useHistory, persist}
154
- */
155
- declare class createSignal<Type extends Record<string, any>> {
156
- private callback;
157
- private persistName;
158
- private actions;
159
- private ref;
160
- value: Type;
161
- constructor(initial: Type, props?: {
162
- persistName?: string | undefined;
163
- });
164
- /**
165
- * Cradova Signal
166
- * ----
167
- * set signal value
168
- * @param value - signal value
169
- * @returns void
170
- */
171
- set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
172
- /**
173
- * Cradova Signal
174
- * ----
175
- * set a key value if it's an object
176
- * @param key - key of the key
177
- * @param value - value of the key
178
- * @returns void
179
- */
180
- setKey<k extends keyof Type>(key: k, value: unknown, shouldRefRender?: boolean): void;
181
- /**
182
- * Cradova Signal
183
- * ----
184
- * set a key to signal an action
185
- * @param name - name of the action
186
- * @param action function to execute
187
- */
188
- createAction(name: string, action: (data?: unknown) => void): void;
189
- /**
190
- * Cradova Signal
191
- * ----
192
- * creates man y actions at a time
193
- * @param name - name of the action
194
- * @param action function to execute
195
- */
196
- createActions(Actions: Record<string, (data?: unknown) => void>): void;
197
- /**
198
- * Cradova Signal
199
- * ----
200
- * fires an action if available
201
- * @param key - string key of the action
202
- * @param data - data for the action
203
- */
204
- fireAction(key: string, data?: Type): Type;
205
- /**
206
- * Cradova
207
- * ---
208
- * is used to bind signal data to elements and Refs
209
- *
210
- * @param prop
211
- * @returns something
212
- */
213
- bind(prop: string): any;
214
- private _updateState;
215
- /**
216
- * Cradova Signal
217
- * ----
218
- * set a auto - rendering component for this store
219
- *
220
- * @param Ref component to bind to.
221
- * @param path a property in the object to send to attached ref
222
- */
223
- bindRef(ref: Partial<Ref>, binding?: {
224
- event?: string;
225
- signalProperty: string;
226
- _element_property: string;
227
- }): void;
228
- /**
229
- * Cradova Signal
230
- * ----
231
- * set a update listener on value changes
232
- * @param callback
233
- */
234
- listen(callback: (a: Type) => void): void;
235
- /**
236
- * Cradova Signal
237
- * ----
238
- * clear the history on local storage
239
- *
240
- */
241
- clearPersist(): void;
242
- }
243
- /**
244
- * Cradova Screen
245
- * ---
246
- * create instances of manageable pages
247
- * @param name
248
- * @param template
249
- */
250
- declare class Screen$1 {
251
- /**
252
- * used internally
253
- */
254
- private _name;
255
- /**
256
- * this should be a cradova screen component
257
- */
258
- _html: ((this: Screen$1, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
259
- _packed: boolean;
260
- private _template;
261
- private _callBack;
262
- private _deCallBack;
263
- private _persist;
264
- private _delegatedRoutesCount;
265
- private _dropped;
266
- /**
267
- * error handler for the screen
268
- */
269
- _errorHandler: ((err: unknown) => void) | null;
270
- constructor(cradova_screen_initials: CradovaScreenType);
271
- _derive(): {
272
- _name: string;
273
- _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
274
- _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
275
- };
276
- _apply_derivation(derivation: {
277
- _name: string;
278
- _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
279
- _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
280
- }): void;
281
- get _delegatedRoutes(): number;
282
- set _delegatedRoutes(count: number);
283
- setErrorHandler(errorHandler: (err: unknown) => void): void;
284
- _package(): Promise<void>;
285
- onActivate(cb: () => Promise<void> | void): void;
286
- onDeactivate(cb: () => Promise<void> | void): void;
287
- _deActivate(): Promise<void>;
288
- drop(state?: boolean): boolean | undefined;
289
- _Activate(force?: boolean): Promise<void>;
290
- }
291
- /** cradova router
292
- * ---
293
- * Registers a route.
294
- *
295
- * @param {string} path Route path.
296
- * @param screen the cradova document tree for the route.
297
- */
298
- declare class Router {
299
- /** cradova router
300
- * ---
301
- * Registers a route.
302
- *
303
- * accepts an object containing
304
- *
305
- * @param {string} path Route path.
306
- * @param screen the cradova screen.
307
- */
308
- static BrowserRoutes(obj: Record<string, any>): void;
309
- /**
310
- Go back in Navigation history
311
- */
312
- static back(): void;
313
- /**
314
- Go forward in Navigation history
315
- */
316
- static forward(): void;
317
- /**
318
- Pause navigation
319
- */
320
- static pauseNaviagtion(): void;
321
- /**
322
- resume navigation
323
- */
324
- static resumeNaviagtion(): void;
325
- /**
326
- * Cradova Router
327
- * ------
328
- *
329
- * Navigates to a designated screen in your app
330
- *
331
- * @param href string
332
- * @param data object
333
- * @param force boolean
334
- */
335
- static navigate(href: string, data?: Record<string, unknown> | null, force?: boolean): void;
336
- /**
337
- * Cradova Router
338
- * ------
339
- *
340
- * Navigates to a designated screen in your app by loading a seperate page;
341
- *
342
- * @param pathname string
343
- */
344
- static navigateNauturally(pathname: string): void;
345
- /**
346
- * Cradova
347
- * ---
348
- * Loading screen for your app
349
- *
350
- * lazy loaded loading use
351
- *
352
- * @param screen
353
- */
354
- static setLoadingScreen(screen: Screen$1): void;
355
- /** cradova router
356
- * ---
357
- * Listen for navigation events
358
- *
359
- * @param callback () => void
360
- */
361
- static onPageEvent(callback: () => void): void;
362
- /** cradova router
363
- * ---
364
- * get a screen ready before time.
365
- *
366
- * @param {string} path Route path.
367
- * @param data data for the screen.
368
- */
369
- static packageScreen(path: string): Promise<void>;
370
- /**
371
- * Cradova Router
372
- * ------
373
- *
374
- * return last set router params
375
- *
376
- * .
377
- */
378
- static getParams(): Record<string, unknown>;
379
- /**
380
- * Cradova
381
- * ---
382
- * Error Handler for your app
383
- *
384
- * @param callback
385
- * @param path? page path
386
- */
387
- static addErrorHandler(callback: (err: unknown) => void): void;
388
- static _mount(): void;
389
- }
390
-
391
- /*! *****************************************************************************
392
- Copyright 2022 Friday Candour. All rights reserved.
393
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
394
- this file except in compliance with the License. You may obtain a copy of the
395
- License at http://www.apache.org/licenses/LICENSE-2.0
396
-
397
- See the Apache Version 2.0 License for specific language governing permissions
398
- and limitations under the License.
399
- ***************************************************************************** */
400
-
401
- type DataAttributes = {
402
- [key: `data-${string}`]: string;
403
- };
404
- type AriaAttributes = {
405
- [key: `aria-${string}`]: string;
406
- };
407
- type VJSType<T> = (...VJS: (undefined | string | HTMLElement | HTMLElement[] | Ref | Ref[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties | {
408
- style?: CSS.Properties;
409
- onmount?: (this: T) => void;
410
- reference?: reference;
411
- })[]) => T;
412
- type VJS_params_TYPE<T> = (undefined | string | HTMLElement | HTMLElement[] | Ref | Ref[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number> | {
413
- src?: string;
414
- href?: string;
415
- placeholder?: string;
416
- type?: string;
417
- action?: string;
418
- name?: string;
419
- alt?: string;
420
- for?: string;
421
- method?: string;
422
- rows?: string;
423
- value?: string;
424
- target?: string;
425
- rel?: string;
426
- required?: string;
427
- frameBorder?: string;
428
- style?: CSS.Properties;
429
- onmount?: (this: T) => void;
430
- reference?: reference;
431
- })[];
432
- type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
433
- type VJS_props_TYPE = {
434
- style?: CSS.Properties;
435
- onmount?: () => void;
436
- reference?: reference;
437
- };
438
- type CradovaScreenType<T = unknown> = {
439
- /**
440
- * Cradova screen
441
- * ---
442
- * title of the page
443
- * .
444
- */
445
- name?: string;
446
- /**
447
- * Cradova screen
448
- * ---
449
- * a css className to add to screen when rendering it
450
- * Usually for adding css transitions
451
- * .
452
- */
453
- /**
454
- * Cradova screen
455
- * ---
456
- * The component for the screen
457
- * @param data
458
- * @returns void
459
- * .
460
- */
461
- template: ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment | Ref<any>;
462
- /**
463
- * Cradova screen
464
- * ---
465
- * Allows this screen render in parallel for unique routes
466
- *
467
- * limit is 1000
468
- *
469
- * .
470
- */
471
- renderInParallel?: boolean;
472
- /**
473
- * Cradova screen
474
- * ---
475
- * Should this screen be cached after first render?
476
- * you can use Route.navigate(url, null, true) to force later
477
- *
478
- * .
479
- */
480
- persist?: boolean;
481
- };
482
-
483
- /*! *****************************************************************************
484
- Copyright 2022 Friday Candour. All rights reserved.
485
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
486
- this file except in compliance with the License. You may obtain a copy of the
487
- License at http://www.apache.org/licenses/LICENSE-2.0
488
-
489
- See the Apache Version 2.0 License for specific language governing permissions
490
- and limitations under the License.
491
- ********************************************************************************/
492
-
493
- declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
494
- declare const make: (descriptor: any) => any[];
495
- declare const cra: <E extends HTMLElement>(tag: string) => VJSType<E>;
496
- declare function Rhoda(l: VJSType<HTMLElement>[] | (() => any)[] | Ref[] | HTMLElement[]): DocumentFragment;
497
- declare function css(identifier: string | TemplateStringsArray): void;
498
- /**
499
- *
500
- * @param {expression} condition
501
- * @param {function} elements[]
502
- */
503
- declare function $if<Type>(condition: boolean, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): HTMLElement[] | undefined;
504
- declare function $ifelse<Type>(condition: boolean, ifTrue: VJS_Child_TYPE<Type | HTMLElement> | VJS_Child_TYPE<Type | HTMLElement>[], ifFalse: VJS_Child_TYPE<Type | HTMLElement> | VJS_Child_TYPE<Type | HTMLElement>[]): VJS_Child_TYPE<HTMLElement | Type> | VJS_Child_TYPE<HTMLElement | Type>[];
505
- declare function $case<Type>(value: any, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): (key: any) => HTMLElement[] | undefined;
506
- declare function $switch(key: unknown, ...cases: ((key: any) => HTMLElement[] | undefined)[]): HTMLElement[] | undefined;
507
- type LoopData<Type> = Type[];
508
- declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
509
- /** Calculate a simple numerical representation of the URL */
510
- declare let SNRU: string;
511
- declare function memo_SNRU(): void;
512
- /**
513
- * Document fragment
514
- * @param children
515
- * @returns
516
- */
517
- declare const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
518
- /**
519
- * Cradova
520
- * ---
521
- * Allows functional components to manage state by providing a state value and a function to update it.
522
- * @param initialValue
523
- * @param ActiveRef
524
- * @returns [state, setState]
525
- */
526
- declare function useState<S = unknown>(initialValue: S, ActiveRef: Ref): [S, (newState: S) => void];
527
- /**
528
- * Cradova
529
- * ---
530
- Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
531
- * @param effect
532
- * @returns
533
- */
534
- declare function useEffect(effect: () => void, ActiveRef: Ref): void;
535
- /**
536
- * Cradova
537
- * ---
538
- Returns a mutable reference object of dom elements that persists across component renders.
539
- * @returns reference
540
- */
541
- declare function useRef(): Record<string, HTMLElement | undefined>;
542
-
543
- declare const a: VJSType<HTMLAnchorElement>;
544
- declare const article: VJSType<HTMLElement>;
545
- declare const audio: VJSType<HTMLAudioElement>;
546
- declare const br: VJSType<HTMLBRElement>;
547
- declare const button: VJSType<HTMLButtonElement>;
548
- declare const canvas: VJSType<HTMLCanvasElement>;
549
- declare const caption: VJSType<HTMLTableCaptionElement>;
550
- declare const col: VJSType<HTMLTableColElement>;
551
- declare const colgroup: VJSType<HTMLOptGroupElement>;
552
- declare const datalist: VJSType<HTMLDataListElement>;
553
- declare const details: VJSType<HTMLDetailsElement>;
554
- declare const dialog: VJSType<HTMLDialogElement>;
555
- declare const div: VJSType<HTMLDivElement>;
556
- declare const em: VJSType<HTMLElement>;
557
- declare const embed: VJSType<HTMLEmbedElement>;
558
- declare const figure: VJSType<HTMLElement>;
559
- declare const footer: VJSType<HTMLElement>;
560
- declare const form: VJSType<HTMLFormElement>;
561
- declare const h1: VJSType<HTMLHeadingElement>;
562
- declare const h2: VJSType<HTMLHeadingElement>;
563
- declare const h3: VJSType<HTMLHeadingElement>;
564
- declare const h4: VJSType<HTMLHeadingElement>;
565
- declare const h5: VJSType<HTMLHeadingElement>;
566
- declare const h6: VJSType<HTMLHeadingElement>;
567
- declare const head: VJSType<HTMLHeadElement>;
568
- declare const header: VJSType<HTMLHeadElement>;
569
- declare const hr: VJSType<HTMLHRElement>;
570
- declare const i: VJSType<HTMLLIElement>;
571
- declare const iframe: VJSType<HTMLIFrameElement>;
572
- declare const img: VJSType<HTMLImageElement>;
573
- declare const input: VJSType<HTMLInputElement>;
574
- declare const label: VJSType<HTMLLabelElement>;
575
- declare const li: VJSType<HTMLLIElement>;
576
- declare const main: VJSType<HTMLElement>;
577
- declare const nav: VJSType<HTMLElement>;
578
- declare const ol: VJSType<HTMLOListElement>;
579
- declare const optgroup: VJSType<HTMLOptGroupElement>;
580
- declare const option: VJSType<HTMLOptionElement>;
581
- declare const p: VJSType<HTMLParagraphElement>;
582
- declare const progress: VJSType<HTMLProgressElement>;
583
- declare const q: VJSType<HTMLQuoteElement>;
584
- declare const section: VJSType<HTMLElement>;
585
- declare const select: VJSType<HTMLSelectElement>;
586
- declare const source: VJSType<HTMLSourceElement>;
587
- declare const span: VJSType<HTMLSpanElement>;
588
- declare const strong: VJSType<HTMLElement>;
589
- declare const summary: VJSType<HTMLElement>;
590
- declare const table: VJSType<HTMLTableElement>;
591
- declare const tbody: VJSType<HTMLTableColElement>;
592
- declare const td: VJSType<HTMLTableCellElement>;
593
- declare const template: VJSType<HTMLTemplateElement>;
594
- declare const textarea: VJSType<HTMLTextAreaElement>;
595
- declare const th: VJSType<HTMLTableSectionElement>;
596
- declare const title: VJSType<HTMLTitleElement>;
597
- declare const tr: VJSType<HTMLTableRowElement>;
598
- declare const track: VJSType<HTMLTrackElement>;
599
- declare const u: VJSType<HTMLUListElement>;
600
- declare const ul: VJSType<HTMLUListElement>;
601
- declare const video: VJSType<HTMLVideoElement>;
602
- declare const svg: (svg: string, properties?: VJS_props_TYPE) => HTMLSpanElement;
603
- declare const raw: (html: string) => HTMLElement[];
604
-
605
- /*! *****************************************************************************
606
- Copyright 2022 Friday Candour. All rights reserved.
607
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
608
- this file except in compliance with the License. You may obtain a copy of the
609
- License at http://www.apache.org/licenses/LICENSE-2.0
610
-
611
- See the Apache Version 2.0 License for specific language governing permissions
612
- and limitations under the License.
613
- ********************************************************************************/
614
-
615
- type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE<E | HTMLElement>) => E | HTMLElement | DocumentFragment;
616
- /**
617
- * Cradova
618
- * ---
619
- * Creates new cradova HTML element
620
- * @example
621
- * // using template
622
- * const p = _("p");
623
- * _("p.foo.bar#poo.loo");
624
- *
625
- * // full example
626
- * _("p", // template first
627
- * // property next if wanted
628
- * {style: {color: "brown"}, // optional
629
- * // the rest should be children or text
630
- * _("span", " am a span tag text like so"),
631
- * ...
632
- * )
633
- *
634
- * @param element_initials
635
- * @returns function - cradova element
636
- */
637
- declare const _: TemplateType;
638
-
639
- export { $case, $if, $ifelse, $switch, CradovaEvent, Ref, Rhoda, Router, SNRU, Screen$1 as Screen, a, article, audio, br, button, canvas, caption, col, colgroup, cra, createSignal, css, datalist, _ as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, label, lazy, li, loop, main, make, makeElement, memo_SNRU, nav, ol, optgroup, option, p, progress, q, raw, reference, section, select, source, span, strong, summary, svg, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
package/dist/index.js DELETED
@@ -1,20 +0,0 @@
1
-
2
- /*
3
- ============================================================================="
4
- ██████╗ ██████╗ █████═╗ ███████╗ ███████╗ ██╗ ██╗ █████╗
5
- ██╔════╝ ██╔══██╗ ██╔═╗██║ █ ██ ██╔═════╝█ ██║ ██║ ██╔═╗██
6
- ██║ ██████╔╝ ███████║ █ ██ ██║ ██ ██║ ██║ ██████╗
7
- ██║ ██╔══██╗ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██╗
8
- ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ████████ ╚███╔╝ ██║ ██║
9
- ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚══╝ ╚═╝ ╚═╝
10
- =============================================================================
11
- Cradova
12
- @version 3.3.0
13
- License: Apache V2
14
- Copyright 2022 Friday Candour.
15
- Repository - https://github.com/fridaycandour/cradova
16
- =============================================================================
17
- */
18
- var v=class{constructor(){this.listeners={};this.active_listeners={};}async addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);}async addActiveEventListener(e,t){this.active_listeners[e]||(this.active_listeners[e]=[]),this.active_listeners[e].push(t);}async dispatchEvent(e,t){let n=this.listeners[e]||[];for(;n.length!==0;)n.shift()(t);}async dispatchActiveEvent(e,t){let n=this.listeners[e]||[];n.length&&w();for(let o=0;o<n.length;o++)n[o](t);}},f=new v,h=class{constructor(e){this.effects=[];this.effectuate=null;this.methods={};this.rendered=!1;this.published=!1;this.preRendered=null;this.reference=new u;this._state=[];this._state_track={};this._state_index=0;this.component=e.bind(this),f.addActiveEventListener("active-Refs",()=>{this._state_index=0,this.published=!1;});}preRender(e,t){this.preRendered=this.render(e,t);}destroyPreRendered(){this.preRendered=null;}define(e,t){typeof e=="string"&&typeof t=="function"&&!Object.prototype.hasOwnProperty.call(this,e)?this.methods[e]=t.bind(this):console.error(" \u2718 Cradova err : Invalid Ref.define parameters");}render(e,t){if(this.effects=[],this.rendered=!1,t&&(this.stash=e),this.preRendered)return this.preRendered;{let n=this.component(e);return n instanceof HTMLElement||n instanceof DocumentFragment?(this.reference._appendDomForce("html",n),this.effector.apply(this),this.rendered=!0,this.published=!0):console.error(" \u2718 Cradova err : Invalid html content, got - "+n),n}}instance(){return this.reference.current("html")}_setExtra(e){this.Signal=e;}_roll_state(e,t,n=!1){return n||(this._state[t]=e),this._state[t]}_effect(e){this.rendered||this.effects.push(e.bind(this));}async effector(){if(!this.rendered){for(let e=0;e<this.effects.length;e++)await this.effects[e].apply(this);this.effects=[];}this.effectuate&&(this.effectuate(),this.effectuate=null);}updateState(e,t){this.rendered?this.published&&this.Activate(e):this.effectuate=()=>{this.published&&this.Activate(e);},t&&(this.stash=e);}async Activate(e){if(this._state_index=0,this.published=!1,!this.rendered)return;let t=this.component(e);if(t instanceof HTMLElement||t instanceof DocumentFragment){let n=this.reference.current("html");n&&(n.insertAdjacentElement("beforebegin",t),n.remove()),this.published=!0,this.reference._appendDomForce("html",t),f.dispatchEvent("onmountEvent");}else console.error(" \u2718 Cradova err : Invalid html content, got - "+t);}},H=class{constructor(e){this._cb=e;}async load(){let e=await this._cb();typeof e=="function"?e=await e():e=await e;let t=e;t.default&&(this.content=t?.default);}},u=class{constructor(){this.tree={};this.globalTree={};}bindAs(e){return [this,e]}current(e){return this.tree[p]?this.tree[p][e]:null}_appendDomForce(e,t){this.tree[p]?this.tree[p][e]=t:(this.tree[p]={},this.tree[p][e]=t);}_appendDomForceGlobal(e,t){this.globalTree[e]=t;}},d=new u,_=class{constructor(e,t){this.persistName="";this.actions={};this.ref=[];if(this.value=e,t&&t.persistName){this.persistName=t.persistName;let n=localStorage.getItem(t.persistName);if(n&&n!=="undefined"&&(this.value=JSON.parse(n)),typeof e=="object")for(let o in e)Object.prototype.hasOwnProperty.call(this.value,o)||(this.value[o]=e[o]);}}set(e,t){typeof e=="function"?this.value=e(this.value):this.value=e,this.persistName&&localStorage.setItem(this.persistName,JSON.stringify(this.value)),this.ref.length&&t!==!1&&this._updateState(),this.callback&&this.callback(this.value);}setKey(e,t,n){if(typeof this.value=="object"&&!Array.isArray(this.value))this.value[e]=t,this.persistName&&localStorage.setItem(this.persistName,JSON.stringify(this.value)),this.ref.length&&n!==!1&&this._updateState(),this.callback&&this.callback(this.value);else throw new Error(`\u2718 Cradova err : can't set key ${String(e)} . store.value is not a javascript object`)}createAction(e,t){if(typeof e=="string"&&typeof t=="function")this.actions[e]=t;else throw new Error(`\u2718 Cradova err : can't create action, ${e} is not a function`)}createActions(e){for(let[t,n]of Object.entries(e))if(typeof t=="string"&&typeof n=="function")this.actions[t]=n;else throw new Error(`\u2718 Cradova err : can't create action, ${t} is not a function`)}fireAction(e,t){if(this._updateState(e,t),typeof this.actions[e]=="function")return this.actions[e].call(this,t);throw Error("\u2718 Cradova err : action "+e+" does not exist!")}bind(e){if(typeof this.value=="object"&&typeof this.value[e]<"u")return [this,e];throw new Error("\u2718 Cradova err : can't bind an unavailable property! "+e)}_updateState(e,t){if(e&&t)this.ref.map(n=>{if(n._event===e){if(n._element_property&&n._signalProperty){n.ref?.updateState({[n._element_property]:t[n._signalProperty]});return}if(n._element_property){n.ref.updateState({[n._element_property]:t});return}if(n._signalProperty){n.ref.updateState(t[n._signalProperty]);return}}});else for(let n=0;n<this.ref.length;n++){let o=this.ref[n];if(o._element_property&&o._signalProperty){o.ref.updateState({[o._element_property]:this.value[o._signalProperty]});continue}if(o._element_property){o.ref.updateState({[o._element_property]:this.value});continue}if(o._signalProperty){o.ref.updateState(this.value[o._signalProperty]);continue}if(!o._element_property&&!o._signalProperty){o.ref.updateState(this.value);continue}}}bindRef(e,t={signalProperty:"",_element_property:""}){if(e.render&&(e.render=e.render.bind(e,this.value)),e._setExtra&&e._setExtra(this),e&&e.updateState){this.ref.push({ref:e,_signalProperty:t.signalProperty,_element_property:t._element_property,_event:t.event});return}throw new Error("\u2718 Cradova err : Invalid parameters for binding ref to Signal")}listen(e){this.callback=e;}clearPersist(){this.persistName&&localStorage.removeItem(this.persistName);}},m=class{constructor(e){this._packed=!1;this._template=document.createElement("div");this._persist=!0;this._delegatedRoutesCount=-1;this._dropped=!1;this._errorHandler=null;let{template:t,name:n,persist:o,renderInParallel:i}=e;t instanceof h?this._html=()=>t.render({}):this._html=t,this._name=n||"Document",this._template.setAttribute("id","cradova-screen-set"),i===!0?(this._delegatedRoutesCount=0,this._persist=!1):typeof o=="boolean"&&(this._persist=o);}_derive(){return {_name:this._name,_callBack:this._callBack,_deCallBack:this._deCallBack}}_apply_derivation(e){this._name=e._name,this._callBack=e._callBack,this._deCallBack=e._deCallBack;}get _delegatedRoutes(){return this._delegatedRoutesCount>100?-1:this._delegatedRoutesCount}set _delegatedRoutes(e){e&&(this._delegatedRoutesCount+=1);}setErrorHandler(e){this._errorHandler=e;}async _package(){if(typeof this._html=="function"){let e=await this._html.apply(this);if(typeof e=="function")e=e(),(e instanceof HTMLElement||e instanceof DocumentFragment)&&(this._template.innerHTML="",this._template.appendChild(e));else if(e instanceof HTMLElement||e instanceof DocumentFragment)this._template.innerHTML="",this._template.appendChild(e);else throw new Error(` \u2718 Cradova err: template function for the screen with name '${this._name}' returned ${e} instead of html`)}}onActivate(e){this._callBack=e;}onDeactivate(e){this._deCallBack=e;}async _deActivate(){this._deCallBack&&await this._deCallBack(d.globalTree.doc);}drop(e){if(typeof e=="boolean"){this._dropped=e;return}else return this._dropped}async _Activate(e=!1){if(this._dropped){history.go(-1);return}w(),f.dispatchActiveEvent("active-Refs"),(!this._persist||e||!this._packed)&&(await this._package(),this._packed=!0),document.title=this._name,d.globalTree.doc.innerHTML="",d.globalTree.doc.appendChild(this._template),f.dispatchEvent("onmountEvent"),window.scrollTo({top:0,left:0,behavior:"instant"}),this._callBack&&await this._callBack(d.globalTree.doc);}},E=class{constructor(){this.pageShow=null;this.pageHide=null;this.loadingScreen=null;this.params={};this.routes={};this.pageevents=[];this.paused=!1;}async start_pageevents(e){setTimeout(()=>{for(let t=0;t<this.pageevents.length;t++)this.pageevents[t](e);},100);}route(e,t){if(typeof t<"u"){if(t&&!t)throw console.error(" \u2718 Cradova err: not a valid screen ",t),new Error(" \u2718 Cradova err: Not a valid cradova screen component");return this.routes[e]=t}}async router(e,t){let n=window.location.pathname,o,i;if(this.paused){window.location.hash="paused";return}if(n!==this.lastNavigatedRoute)if(this.nextRouteController?(o=this.nextRouteController,this.nextRouteController=void 0):[o,i]=this.checker(n),typeof o<"u")try{if(typeof o=="function"&&(this.loadingScreen instanceof m&&await this.loadingScreen._Activate(),o=await o(),!o)){this.lastNavigatedRoute&&history.pushState({},n,this.lastNavigatedRoute);return}if(o._delegatedRoutes!==-1){o._delegatedRoutes=1;let l=o._derive();o=new m({template:o._html}),o._apply_derivation(l),this.routes[n]=o;}i&&(this.params.params=i),await o._Activate(t),this.start_pageevents(n),this.lastNavigatedRouteController&&this.lastNavigatedRouteController._deActivate(),this.lastNavigatedRoute=n,this.lastNavigatedRouteController=o;}catch(l){if(o&&o._errorHandler)o._errorHandler(l);else if(typeof this.errorHandler=="function")this.errorHandler(Error);else throw console.error(l),new Error(" \u2718 Cradova err: consider adding error boundary to the specific screen ")}else this.routes["*"]&&await this.routes["*"]._Activate(t);}checker(e){if(this.routes[e])return [this.routes[e],{path:e}];if(this.routes[e+"/"])return [this.routes[e],{path:e}];for(let t in this.routes){if(!t.includes(":"))continue;let n=e.split("/"),o=t.split("/");e.endsWith("/")&&n.pop();let i=0,l=0;if(n.shift(),o.shift(),o.length===n.length){let y={_path:""};for(let c=0;c<o.length;c++){if(o[c].includes(":")){l++;continue}n[c]===o[c]&&i++;}if(i+l===o.length){for(let c=0;c<o.length;c++)o[c].includes(":")&&(y[o[c].split(":")[1]]=n[c]);return y._path=t,[this.routes[t],y]}}}return []}},s=new E,g=class{static BrowserRoutes(e){for(let t in e){let n=e[t];typeof n=="object"&&typeof n.then=="function"||typeof n=="function"?s.routes[t]=async()=>(n=await(typeof n=="function"?await n():await n),s.route(t,n?.default||n)):s.route(t,n);}g._mount();}static back(){history.go(-1);}static forward(){history.go(1);}static pauseNaviagtion(){s.paused=!0,window.location.hash="paused";}static resumeNaviagtion(){s.paused=!1,window.location.replace(window.location.pathname+window.location.search),history.go(-1);}static navigate(e,t=null,n=!1){if(typeof e!="string")throw new TypeError(" \u2718 Cradova err: href must be a defined path but got "+e+" instead");let o=null,i;if(e.includes("://"))window.location.href=e;else {if(e===window.location.pathname)return;[o,i]=s.checker(e),o&&(s.nextRouteController=o,window.history.pushState({},"",e)),s.params.params=i,s.params.data=t,s.router(null,n);}}static navigateNauturally(e){if(typeof e!="string")throw new TypeError(" \u2718 Cradova err: pathname must be a defined path but got "+e+" instead");window.location.pathname=e;}static setLoadingScreen(e){if(e instanceof m)s.loadingScreen=e;else throw new Error(" \u2718 Cradova err: Loading Screen should be a cradova screen class")}static onPageEvent(e){if(typeof e=="function")s.pageevents.push(e);else throw new Error(" \u2718 Cradova err: callback for pageShow event is not a function")}static async packageScreen(e){if(!s.routes[e])throw console.error(" \u2718 Cradova err: no screen with path "+e),new Error(" \u2718 Cradova err: cradova err: Not a defined screen path");let[t]=s.checker(e);if(typeof t=="function"&&(t=await t()),t._delegatedRoutes!==-1){t._delegatedRoutes=1;let n=t._derive();t=new m({template:t._html}),t._apply_derivation(n),s.routes[e]=t;}t._package(),t._packed=!0;}static getParams(){return s.params}static addErrorHandler(e){if(typeof e=="function")s.errorHandler=e;else throw new Error(" \u2718 Cradova err: callback for error event is not a function")}static _mount(){let e=document.querySelector("[data-wrapper=app]");e||(e=document.createElement("div"),e.setAttribute("data-wrapper","app"),document.body.appendChild(e)),d._appendDomForceGlobal("doc",e),window.addEventListener("pageshow",()=>s.router()),window.addEventListener("popstate",t=>{t.preventDefault(),s.router();});}};var T=(r,e)=>{let t={},n=null;if(e.length!==0)for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="function"&&(i=i()),i instanceof h&&(i=i.render()),i instanceof HTMLElement||i instanceof DocumentFragment){r.appendChild(i);continue}if(Array.isArray(i)){r.appendChild(x(i));continue}if(typeof i=="string"||typeof i=="number"){n=i;continue}if(typeof i=="object"){t=Object.assign(t,i);continue}}else return r;if(typeof t=="object"&&r)for(let[o,i]of Object.entries(t)){if(o==="style"&&typeof i=="object"){Object.assign(r.style,i);continue}if(Array.isArray(i)){if(o=="reference"&&i[0]instanceof u){i[0]._appendDomForce(i[1],r);continue}if(i[0]instanceof _){i[0].bindRef(r,{_element_property:o,signalProperty:i[1]});continue}}if(o==="onmount"&&typeof t.onmount=="function"){let l=()=>{t.onmount?.apply(r),t.onmount=void 0;};f.addEventListener("onmountEvent",l);continue}if(o.includes("data-")){r.setAttribute(o,i);continue}if(o.includes("aria-")){r.setAttribute(o,i);continue}if(o==="href"&&typeof i=="string"){let l=i||"";l.includes("://")||r.addEventListener("click",y=>{y.preventDefault(),g.navigate(r.pathname);if(l.includes("#")){let c=l.split("#").at(-1);document.getElementById("#"+c)?.scrollIntoView();}}),r.setAttribute(o,i);continue}if(typeof r.style[o]<"u"&&o!=="src"){r.style[o]=i;continue}r[o]=i;}return n&&r.appendChild(document.createTextNode(n)),r},L=function(r){if(Array.isArray(r)&&(r=r[0]),typeof r!="string")return [];let e="";if(r.includes("|")&&([r,e]=r.split("|"),!r))return ["P",void 0,void 0,e];let t;if(r.includes("#")){if(!r.includes("."))return r=r.split("#"),t=r.shift(),t||(t="DIV"),r[0].includes(" ")&&(r=[r[0].split(" ")[1]]),[t,r[0],void 0,e]}else return r=r.split("."),t=r.shift(),t||(t="DIV"),[t,void 0,r.join(" "),e];r=r.split(".");let n=[],o=[];t=!r[0].includes("#")&&r.shift(),t||(t="DIV");for(let i=0;i<r.length;i++){if(r[i].includes("#")){let l=r[i].split("#");if(o.push(l[1]),i===0){t=l[0];continue}n.push(l[0]);continue}n.push(r[i]);}return [t,o[0],n.join(" "),e]},a=r=>(...t)=>T(document.createElement(r),t);function x(r){let e=new DocumentFragment;for(let t of r)if(Array.isArray(t))e.appendChild(x(t));else {if(t instanceof h&&(t=t.render(void 0)),typeof t=="function"&&(t=t(),typeof t=="function"&&(t=t())),typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(t));continue}if(t instanceof HTMLElement||t instanceof DocumentFragment)e.appendChild(t);else if(typeof t<"u")throw new Error(" \u2718 Cradova err: invalid child type: "+t+" ("+typeof t+")")}return e}function P(r){if(Array.isArray(r)&&(r=r[0]),typeof r=="string"){let e=document.querySelector("style");if(e!==null){e.textContent=r+e.textContent;return}e=document.createElement("style"),e.textContent=r,document.head.appendChild(e);}}function R(r,...e){if(r)return e}function D(r,e,t){return r?e:t}function A(r,...e){return t=>{if(t===r)return e}}function N(r,...e){if(e.length)for(let t=0;t<e.length;t++){let n=e[t],o=n(r);if(o)return o}}function F(r,e){if(typeof e!="function")throw new Error(" \u2718 Cradova err : Invalid component type, must be a function that returns html ");return Array.isArray(r)?r.map(e):void 0}var p;function w(){let r=0,e=window.location.href;for(let t=0;t<e.length;t++)r+=e.charCodeAt(t);p=r.toString();}var V=function(r){let e=document.createDocumentFragment();for(let t=0;t<r.length;t++){let n=r[t];if(typeof n=="function"&&(n=n()),n instanceof HTMLElement||n instanceof DocumentFragment){e.appendChild(n);continue}if(n instanceof String){e.appendChild(document.createTextNode(n));continue}throw console.error(" \u2718 Cradova err: wrong element type"+n),new TypeError(" \u2718 Cradova err: invalid element")}return e};function J(r,e){e._state_index+=1;let t=e._state_index;e._state_track[t]||(e._roll_state(r,t),e._state_track[t]=!0);function n(o){e._roll_state(o,t),e.updateState();}return [e._roll_state(null,t,!0),n]}function B(r,e){e._effect(r);}function I(){return new u}var O=a("a"),$=a("article"),U=a("audio"),G=a("br"),q=a("button"),K=a("canvas"),Q=a("caption"),W=a("col"),X=a("colgroup"),Z=a("datalist"),z=a("details"),ee=a("dialog"),te=a("div"),ne=a("em"),re=a("embed"),oe=a("figure"),ae=a("footer"),ie=a("form"),se=a("h1"),le=a("h2"),ce=a("h3"),pe=a("h4"),ue=a("h5"),de=a("h6"),fe=a("head"),he=a("header"),me=a("hr"),ge=a("i"),ye=a("iframe"),Te=a("img"),_e=a("input"),ve=a("label"),Ee=a("li"),we=a("main"),He=a("nav"),Le=a("ol"),xe=a("optgroup"),Me=a("option"),be=a("p"),Se=a("progress"),ke=a("q"),Ce=a("section"),Pe=a("select"),Re=a("source"),De=a("span"),Ae=a("strong"),Ne=a("summary"),Fe=a("table"),Ve=a("tbody"),Je=a("td"),Be=a("template"),Ie=a("textarea"),je=a("th"),Ye=a("title"),Oe=a("tr"),$e=a("track"),Ue=a("u"),Ge=a("ul"),qe=a("video"),Ke=(r,e)=>{let t=document.createElement("span");return t.innerHTML=r,T(t,[e])},Qe=r=>{let e=document.createElement("div");return e.innerHTML=r,Array.from(e.children)};var M=(...r)=>{let{0:e,1:t,2:n,3:o}=L(r[0]),i=e?document.createElement(e):new DocumentFragment;return e&&(n&&(i.className=n),t&&(i.id=t),o&&(i.innerText=o),r.shift()),T(i,r)},Ze=M;
19
-
20
- export { A as $case, R as $if, D as $ifelse, N as $switch, f as CradovaEvent, h as Ref, x as Rhoda, g as Router, p as SNRU, m as Screen, O as a, $ as article, U as audio, G as br, q as button, K as canvas, Q as caption, W as col, X as colgroup, a as cra, _ as createSignal, P as css, Z as datalist, Ze as default, z as details, ee as dialog, te as div, ne as em, re as embed, oe as figure, ae as footer, ie as form, V as frag, se as h1, le as h2, ce as h3, pe as h4, ue as h5, de as h6, fe as head, he as header, me as hr, ge as i, ye as iframe, Te as img, _e as input, ve as label, H as lazy, Ee as li, F as loop, we as main, L as make, T as makeElement, w as memo_SNRU, He as nav, Le as ol, xe as optgroup, Me as option, be as p, Se as progress, ke as q, Qe as raw, u as reference, Ce as section, Pe as select, Re as source, De as span, Ae as strong, Ne as summary, Ke as svg, Fe as table, Ve as tbody, Je as td, Be as template, Ie as textarea, je as th, Ye as title, Oe as tr, $e as track, Ue as u, Ge as ul, B as useEffect, I as useRef, J as useState, qe as video };