cradova 3.2.2 โ†’ 3.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <br/>
2
2
  <p align="center">
3
- <a href="https://github.com/fridaycandour/cradova">
3
+ <a href="https://github.com/uiedbook/cradova">
4
4
  <img src="cradova.png" alt="Logo" width="80" height="80">
5
5
  </a>
6
6
 
@@ -10,22 +10,72 @@
10
10
  Cradova is a JavaScript framework for building Single Page Applications and PWAs.
11
11
  <br/>
12
12
  <br/>
13
- <a href="https://github.com/fridaycandour/cradova#examples"><strong>Explore the ๐ŸŽ™๏ธ docs ยป</strong></a>
13
+ <a href="https://github.com/uiedbook/cradova#examples"><strong>Explore the ๐ŸŽ™๏ธ docs ยป</strong></a>
14
14
  <br/>
15
15
  <br/>
16
- <a href="https://t.me/cradovaframework">Join Community</a>
16
+ <a href="https://t.me/uiedbookHQ">Join Community</a>
17
17
  .
18
- <a href="https://github.com/fridaycandour/cradova/issues">Report Bug</a>
18
+ <a href="https://github.com/uiedbook/cradova/issues">Report Bug</a>
19
19
  .
20
- <a href="https://github.com/fridaycandour/cradova/issues">Request Feature</a>
20
+ <a href="https://github.com/uiedbook/cradova/issues">Request Feature</a>
21
21
  </p>
22
22
  </p>
23
23
 
24
- ![Contributors](https://img.shields.io/github/contributors/fridaycandour/cradova?color=dark-green) ![Issues](https://img.shields.io/github/issues/fridaycandour/cradova) ![License](https://img.shields.io/github/license/fridaycandour/cradova)
24
+ ![Contributors](https://img.shields.io/github/contributors/uiedbook/cradova?color=dark-green) ![Issues](https://img.shields.io/github/issues/uiedbook/cradova) ![License](https://img.shields.io/github/license/uiedbook/cradova)
25
25
  [![npm Version](https://img.shields.io/npm/v/cradova.svg)](https://www.npmjs.com/package/cradova)
26
26
  [![License](https://img.shields.io/npm/l/cradova.svg)](https://github.com/cradova/cradova.js/blob/next/LICENSE)
27
27
  [![npm Downloads](https://img.shields.io/npm/dm/cradova.svg)](https://www.npmjs.com/package/cradova)
28
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/cradova/cradova.js/blob/next/contributing.md)![Forks](https://img.shields.io/github/forks/fridaycandour/cradova?style=social) ![Stargazers](https://img.shields.io/github/stars/fridaycandour/cradova?style=social)
28
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/cradova/cradova.js/blob/next/contributing.md)![Forks](https://img.shields.io/github/forks/uiedbook/cradova?style=social) ![Stargazers](https://img.shields.io/github/stars/uiedbook/cradova?style=social)
29
+
30
+ ## 2024 - What's New? Ref methods!
31
+
32
+ ```js
33
+ type dataType = { year: string, age: string };
34
+
35
+ const Header =
36
+ new Ref() <
37
+ dataType >
38
+ function (data = { year: "2023", age: "2" }) {
39
+ return header(h1("Cradova is " + data.age + " yrs old in " + data.year));
40
+ };
41
+
42
+ Header.define("increase", function (isNewYear) {
43
+ if (isNewYear) {
44
+ this.updateState({ year: "2024", age: "3" });
45
+ }
46
+ });
47
+ document.body.appendChild(Header.render());
48
+ Header.methods.increase(true);
49
+ ```
50
+
51
+ ## 2023 - What's New? Conditionals!
52
+
53
+ ```js
54
+ import { div, h1, $if, $ifelse, $case, $switch } from "cradova";
55
+
56
+ function Hello({ name }) {
57
+ return div(
58
+ $if(name === "john", h1("Hello john")),
59
+ $if(name === "paul", h1("Goodbye paul")),
60
+ $ifelse(name === "john", h1("Hello john"), h1("Hello Paul"))
61
+ );
62
+ }
63
+
64
+ const html = div(Hello("john"), Hello("paul"));
65
+
66
+ function whatsAllowed({ age }) {
67
+ return div(
68
+ $switch(
69
+ age,
70
+ $case(12, h1("too young")),
71
+ $case(26, h1("you are welcome")),
72
+ $case(52, h1("too old"))
73
+ )
74
+ );
75
+ }
76
+
77
+ document.body.append(html, whatsAllowed({ age: 26 }));
78
+ ```
29
79
 
30
80
  # Contents
31
81
 
@@ -43,7 +93,7 @@ Cradova is a web development framework for building Single Page Applications and
43
93
 
44
94
  It's a fast and simple framework, it provides an easy to use state management and router system.
45
95
 
46
- Cradova follows the [VJS specification](https://github.com/FridayCandour/cradova/blob/main/VJS_spec/spec.md)
96
+ Cradova follows the [VJS specification](https://github.com/uiedbook/cradova/blob/main/VJS_spec/specification.md)
47
97
 
48
98
  ## What's the benefit?
49
99
 
@@ -58,7 +108,7 @@ Undoubtedly, this provides a significant advantage.
58
108
 
59
109
  Cradova has already been utilized in multiple production projects, and we will continuously update this page to showcase our advancements as we keep improving.
60
110
 
61
- [current version changes](https://github.com/fridaycandour/cradova/blob/main/CHANGELOG.md#v300)
111
+ [current version changes](https://github.com/uiedbook/cradova/blob/main/CHANGELOG.md#v330)
62
112
 
63
113
  ## Installation
64
114
 
@@ -100,10 +150,9 @@ const html = div(Hello("peter"), Hello("joe"));
100
150
  document.body.append(html);
101
151
  ```
102
152
 
103
- ## working with state:
153
+ ## Basic Samples:
104
154
 
105
- this a collection of basic examples
106
- you can choose any that best suite what problem you want to solve
155
+ this a collection of basic examples that can give you some ideas
107
156
 
108
157
  ```js
109
158
  import _, { button, createSignal, Ref, reference, h1, br, div } from "cradova";
@@ -196,7 +245,7 @@ Let's see a simple TodoList example
196
245
 
197
246
  ```js
198
247
  import _, {
199
- // elements
248
+ // tags
200
249
  div,
201
250
  button,
202
251
  main,
@@ -206,8 +255,6 @@ import _, {
206
255
  createSignal,
207
256
  // dom ref
208
257
  useRef(),
209
- // useState
210
- // useEffect
211
258
  // dynamic component class
212
259
  Ref,
213
260
  css,
@@ -431,23 +478,44 @@ At the moment, we're in the process of creating a documentation website for Crad
431
478
 
432
479
  ## Getting Help
433
480
 
434
- To get further insights and help on Cradova, visit our [Discord](https://discord.gg/b7fvMg38) and [Telegram](https://t.me/cradovaframework) Community Chats.
481
+ To get further insights and help on Cradova, visit our [Discord](https://discord.gg/b7fvMg38) and [Telegram](https://t.me/uiedbookHQ) Community Chats.
435
482
 
436
483
  ## Contributing
437
484
 
438
- We are currently working to [set](https://github.com/fridaycandour/cradova/blob/main/contributing.md) up the following:
485
+ We are currently working to [set](https://github.com/uiedbook/cradova/blob/main/contributing.md) up the following:
439
486
 
440
487
  - building Cradova CLI (in progress)
441
488
  - Cradova Documentation Website
442
- - UI component libraries for cradova
489
+ - UI component libraries for cradova (The Sacho Project)
443
490
  - Sample projects
444
491
  - maintenance and promotion
445
- <!--
446
492
 
447
- ## Sponsor
493
+ ```
494
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•โ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
495
+ โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ•—โ–ˆโ–ˆโ•‘ โ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ•โ–ˆ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•”โ•โ•—โ–ˆโ–ˆ
496
+ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘ โ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
497
+ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆ โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•—
498
+ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ•šโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘
499
+ โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ• โ•šโ•โ•โ• โ•šโ•โ• โ•šโ•โ•
500
+ ```
501
+
502
+ ## Apache Lincenced
503
+
504
+ Opensourced And Free.
505
+
506
+ Uiedbook is an open source team of web focused engineers, Our vision is to make the web better, improving and innovating infrastructures for a better web experience.
507
+
508
+ Join Us on [telegram](https://t.me/UiedbookHQ).
509
+
510
+ ### Contribution and License Agreement
448
511
 
449
- Your support is appreciated and needed to advance Cradova for more performance and improvements.
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.
450
513
 
451
- Sponsorships can be done via [Patreon](https://www.patreon.com/FridayCandour) and [KO-FI](https://www.ko-fi.com/fridaycandour).
514
+ ## Supporting Exabase development
452
515
 
453
- Both monthly-recurring sponsorships and one-time donations are accepted. -->
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
517
+ to [github sponsors](https://github.com/sponsors/FridayCandour):
518
+ or crypto using
519
+ etheruen: `0xD7DDD4312A4e514751A582AF725238C7E6dF206c`,
520
+ Bitcoin: `bc1q5548kdanwyd3y07nyjjzt5zkdxqec4nqqrd760` or
521
+ LTC: `ltc1qgqn6nqq6x555rpj3pw847402aw6kw7a25dc29w`.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,143 @@
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
+ */
1
18
  import * as CSS from 'csstype';
2
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
+ }
3
141
  /**
4
142
  * Cradova Signal
5
143
  * ----
@@ -14,7 +152,7 @@ import * as CSS from 'csstype';
14
152
  * - update a cradova Ref automatically
15
153
  * @constructor initial: unknown, props: {useHistory, persist}
16
154
  */
17
- declare class createSignal<Type extends Record<string, unknown>> {
155
+ declare class createSignal<Type extends Record<string, any>> {
18
156
  private callback;
19
157
  private persistName;
20
158
  private actions;
@@ -82,7 +220,7 @@ declare class createSignal<Type extends Record<string, unknown>> {
82
220
  * @param Ref component to bind to.
83
221
  * @param path a property in the object to send to attached ref
84
222
  */
85
- bindRef(ref: Partial<Ref<unknown>>, binding?: {
223
+ bindRef(ref: Partial<Ref>, binding?: {
86
224
  event?: string;
87
225
  signalProperty: string;
88
226
  _element_property: string;
@@ -102,186 +240,46 @@ declare class createSignal<Type extends Record<string, unknown>> {
102
240
  */
103
241
  clearPersist(): void;
104
242
  }
105
-
106
- declare const isNode: (element: unknown) => boolean;
107
- /**
108
- * Cradova event
109
- */
110
- declare class cradovaEvent {
111
- private listeners;
112
- addEventListener(eventName: string, callback: () => void): Promise<void>;
113
- dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
114
- }
115
- declare const CradovaEvent: cradovaEvent;
116
- declare function Rhoda(l: VJSType<HTMLElement>[] | (() => any)[] | Ref<unknown>[] | HTMLElement[]): DocumentFragment;
117
- declare function css(identifier: string | TemplateStringsArray): void;
118
- /**
119
- *
120
- * @param {expression} condition
121
- * @param {function} elements[]
122
- */
123
- declare function assert<Type>(condition: boolean, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): HTMLElement[] | undefined;
124
- declare function assertOr<Type>(condition: boolean, ifTrue: VJS_Child_TYPE<Type | HTMLElement>, ifFalse: VJS_Child_TYPE<Type | HTMLElement>): VJS_Child_TYPE<HTMLElement | Type>;
125
- type LoopData<Type> = Type[];
126
- declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
127
- /**
128
- * Cradova Ref
129
- * -------
130
- * create dynamic components
131
- */
132
- declare class Ref<D> {
133
- private component;
134
- private effects;
135
- private effectuate;
136
- private rendered;
137
- private published;
138
- private preRendered;
139
- private reference;
140
- Signal: createSignal<any> | undefined;
141
- _state: D[];
142
- _state_track: {
143
- [x: number]: boolean;
144
- };
145
- _state_index: number;
146
- stash: D | undefined;
147
- constructor(component: (this: Ref<D>, data: D) => HTMLElement | DocumentFragment);
148
- preRender(data?: D, stash?: boolean): void;
149
- destroyPreRendered(): void;
150
- /**
151
- * Cradova Ref
152
- * ---
153
- * returns html with cradova reference
154
- * @param data
155
- * @returns () => HTMLElement
156
- */
157
- render(data?: D, stash?: boolean): HTMLElement | DocumentFragment;
158
- instance(): HTMLElement;
159
- _setExtra(Extra: createSignal<any>): void;
160
- _roll_state(data: D, idx: number, get?: boolean): D;
161
- _effect(fn: () => Promise<void> | void): void;
162
- private effector;
163
- /**
164
- * Cradova Ref
165
- * ---
166
- * update ref component with new data and update the dom.
167
- * @param data
168
- * @returns
169
- */
170
- updateState(data?: D, stash?: boolean): void;
171
- private Activate;
172
- }
173
- /**
174
- * Document fragment
175
- * @param children
176
- * @returns
177
- */
178
- declare const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
179
- /**
180
- * cradova
181
- * ---
182
- * lazy load a file
183
- */
184
- declare class lazy<Type> {
185
- content: Type | undefined;
186
- private _cb;
187
- constructor(cb: () => Promise<unknown>);
188
- load(): Promise<void>;
189
- }
190
- /**
191
- * Cradova
192
- * ---
193
- * make reference to dom elements
194
- */
195
- declare class reference {
196
- tree: Record<string, any>;
197
- globalTree: Record<string, HTMLElement>;
198
- /**
199
- * Bind a DOM element to a reference name.
200
- * @param name - The name to reference the DOM element by.
201
- */
202
- bindAs(name: string): reference;
203
- /**
204
- * Retrieve a referenced DOM element.
205
- * @param name - The name of the referenced DOM element.
206
- */
207
- current<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType;
208
- /**
209
- * Append a DOM element to the reference, overwriting any existing reference.
210
- * @param name - The name to reference the DOM element by.
211
- * @param element - The DOM element to reference.
212
- */
213
- _appendDomForce(name: string, Element: HTMLElement): void;
214
- _appendDomForceGlobal(name: string, Element: HTMLElement): void;
215
- }
216
- /**
217
- * Cradova
218
- * ---
219
- * Allows functional components to manage state by providing a state value and a function to update it.
220
- * @param initialValue
221
- * @param ActiveRef
222
- * @returns [state, setState]
223
- */
224
- declare function useState<S = unknown>(initialValue: S, ActiveRef: Ref<unknown>): [S, (newState: S) => void];
225
- /**
226
- * Cradova
227
- * ---
228
- Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
229
- * @param effect
230
- * @returns
231
- */
232
- declare function useEffect(effect: () => void, ActiveRef: Ref<unknown>): void;
233
- /**
234
- * Cradova
235
- * ---
236
- Returns a mutable reference object of dom elements that persists across component renders.
237
- * @returns reference
238
- */
239
- declare function useRef(): Record<string, HTMLElement | undefined>;
240
-
241
243
  /**
242
244
  * Cradova Screen
243
245
  * ---
244
- * create instances of manageable pages and scaffolds
246
+ * create instances of manageable pages
245
247
  * @param name
246
248
  * @param template
247
- * @param transitions
248
249
  */
249
- declare class Screen {
250
- /**
251
- * this should be a cradova screen component
252
- */
253
- _html: ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
254
- /**
255
- * error handler for the screen
256
- */
257
- _errorHandler: ((err: unknown) => void) | null;
250
+ declare class Screen$1 {
258
251
  /**
259
252
  * used internally
260
253
  */
261
254
  private _name;
262
- private _transition;
263
- private _packed;
255
+ /**
256
+ * this should be a cradova screen component
257
+ */
258
+ _html: ((this: Screen$1, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
259
+ _packed: boolean;
264
260
  private _template;
265
261
  private _callBack;
266
262
  private _deCallBack;
267
263
  private _persist;
268
264
  private _delegatedRoutesCount;
269
265
  private _dropped;
266
+ /**
267
+ * error handler for the screen
268
+ */
269
+ _errorHandler: ((err: unknown) => void) | null;
270
270
  constructor(cradova_screen_initials: CradovaScreenType);
271
271
  _derive(): {
272
272
  _name: string;
273
- _transition: string | undefined;
274
- _callBack: (() => void | Promise<void>) | undefined;
275
- _deCallBack: (() => void | Promise<void>) | undefined;
273
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
274
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
276
275
  };
277
276
  _apply_derivation(derivation: {
278
277
  _name: string;
279
- _transition: string | undefined;
280
- _callBack: (() => void | Promise<void>) | undefined;
281
- _deCallBack: (() => void | Promise<void>) | undefined;
278
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
279
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
282
280
  }): void;
283
- get _delegatedRoutes(): boolean;
284
- set _delegatedRoutes(count: boolean);
281
+ get _delegatedRoutes(): number;
282
+ set _delegatedRoutes(count: number);
285
283
  setErrorHandler(errorHandler: (err: unknown) => void): void;
286
284
  _package(): Promise<void>;
287
285
  onActivate(cb: () => Promise<void> | void): void;
@@ -290,90 +288,6 @@ declare class Screen {
290
288
  drop(state?: boolean): boolean | undefined;
291
289
  _Activate(force?: boolean): Promise<void>;
292
290
  }
293
-
294
- type DataAttributes = {
295
- [key: `data-${string}`]: string;
296
- };
297
- type AriaAttributes = {
298
- [key: `aria-${string}`]: string;
299
- };
300
- type VJSType<T> = (...VJS: (undefined | string | HTMLElement | HTMLElement[] | Ref<unknown> | Ref<unknown>[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties | {
301
- style?: CSS.Properties;
302
- onmount?: (this: T) => void;
303
- reference?: reference;
304
- })[]) => T;
305
- type VJS_params_TYPE<T> = (undefined | string | HTMLElement | HTMLElement[] | Ref<unknown> | Ref<unknown>[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number> | {
306
- src?: string;
307
- href?: string;
308
- placeholder?: string;
309
- type?: string;
310
- action?: string;
311
- name?: string;
312
- alt?: string;
313
- for?: string;
314
- method?: string;
315
- rows?: string;
316
- value?: string;
317
- target?: string;
318
- rel?: string;
319
- required?: string;
320
- frameBorder?: string;
321
- style?: CSS.Properties;
322
- onmount?: (this: T) => void;
323
- reference?: reference;
324
- })[];
325
- type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
326
- type VJS_props_TYPE = {
327
- style?: CSS.Properties;
328
- onmount?: () => void;
329
- reference?: reference;
330
- };
331
- type CradovaScreenType<T = unknown> = {
332
- /**
333
- * Cradova screen
334
- * ---
335
- * title of the page
336
- * .
337
- */
338
- name?: string;
339
- /**
340
- * Cradova screen
341
- * ---
342
- * a css className to add to screen when rendering it
343
- * Usually for adding css transitions
344
- * .
345
- */
346
- transition?: string;
347
- /**
348
- * Cradova screen
349
- * ---
350
- * The component for the screen
351
- * @param data
352
- * @returns void
353
- * .
354
- */
355
- template: ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
356
- /**
357
- * Cradova screen
358
- * ---
359
- * Allows this screen render in parallel for unique routes
360
- *
361
- * limit is 1000
362
- *
363
- * .
364
- */
365
- renderInParallel?: boolean;
366
- /**
367
- * Cradova screen
368
- * ---
369
- * Should this screen be cached after first render?
370
- * you can use Route.navigate(url, null, true) to force later
371
- *
372
- * .
373
- */
374
- persist?: boolean;
375
- };
376
-
377
291
  /** cradova router
378
292
  * ---
379
293
  * Registers a route.
@@ -437,7 +351,7 @@ declare class Router {
437
351
  *
438
352
  * @param screen
439
353
  */
440
- static setLoadingScreen(screen: Screen): void;
354
+ static setLoadingScreen(screen: Screen$1): void;
441
355
  /** cradova router
442
356
  * ---
443
357
  * Listen for navigation events
@@ -452,7 +366,7 @@ declare class Router {
452
366
  * @param {string} path Route path.
453
367
  * @param data data for the screen.
454
368
  */
455
- static packageScreen(path: string, data?: Record<string, unknown>): Promise<void>;
369
+ static packageScreen(path: string): Promise<void>;
456
370
  /**
457
371
  * Cradova Router
458
372
  * ------
@@ -461,7 +375,7 @@ declare class Router {
461
375
  *
462
376
  * .
463
377
  */
464
- static getParams(): any;
378
+ static getParams(): Record<string, unknown>;
465
379
  /**
466
380
  * Cradova
467
381
  * ---
@@ -474,24 +388,167 @@ declare class Router {
474
388
  static _mount(): void;
475
389
  }
476
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
+
477
493
  declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
478
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
+
479
543
  declare const a: VJSType<HTMLAnchorElement>;
480
- declare const area: VJSType<HTMLAreaElement>;
481
544
  declare const article: VJSType<HTMLElement>;
482
- declare const aside: VJSType<HTMLElement>;
483
545
  declare const audio: VJSType<HTMLAudioElement>;
484
- declare const b: VJSType<HTMLElement>;
485
- declare const base: VJSType<HTMLBaseElement>;
486
- declare const blockquote: VJSType<HTMLElement>;
487
546
  declare const br: VJSType<HTMLBRElement>;
488
547
  declare const button: VJSType<HTMLButtonElement>;
489
548
  declare const canvas: VJSType<HTMLCanvasElement>;
490
549
  declare const caption: VJSType<HTMLTableCaptionElement>;
491
- declare const code: VJSType<HTMLElement>;
492
550
  declare const col: VJSType<HTMLTableColElement>;
493
551
  declare const colgroup: VJSType<HTMLOptGroupElement>;
494
- declare const data: VJSType<HTMLDataElement>;
495
552
  declare const datalist: VJSType<HTMLDataListElement>;
496
553
  declare const details: VJSType<HTMLDetailsElement>;
497
554
  declare const dialog: VJSType<HTMLDialogElement>;
@@ -515,18 +572,13 @@ declare const iframe: VJSType<HTMLIFrameElement>;
515
572
  declare const img: VJSType<HTMLImageElement>;
516
573
  declare const input: VJSType<HTMLInputElement>;
517
574
  declare const label: VJSType<HTMLLabelElement>;
518
- declare const legend: VJSType<HTMLLegendElement>;
519
575
  declare const li: VJSType<HTMLLIElement>;
520
- declare const link: VJSType<HTMLLinkElement>;
521
576
  declare const main: VJSType<HTMLElement>;
522
- declare const menu: VJSType<HTMLMenuElement>;
523
577
  declare const nav: VJSType<HTMLElement>;
524
- declare const object: VJSType<HTMLObjectElement>;
525
578
  declare const ol: VJSType<HTMLOListElement>;
526
579
  declare const optgroup: VJSType<HTMLOptGroupElement>;
527
580
  declare const option: VJSType<HTMLOptionElement>;
528
581
  declare const p: VJSType<HTMLParagraphElement>;
529
- declare const pre: VJSType<HTMLPreElement>;
530
582
  declare const progress: VJSType<HTMLProgressElement>;
531
583
  declare const q: VJSType<HTMLQuoteElement>;
532
584
  declare const section: VJSType<HTMLElement>;
@@ -548,25 +600,17 @@ declare const u: VJSType<HTMLUListElement>;
548
600
  declare const ul: VJSType<HTMLUListElement>;
549
601
  declare const video: VJSType<HTMLVideoElement>;
550
602
  declare const svg: (svg: string, properties?: VJS_props_TYPE) => HTMLSpanElement;
603
+ declare const raw: (html: string) => HTMLElement[];
551
604
 
552
- /**
553
- *
554
- * Cradova Ajax
555
- * ------------------
556
- * your new axios alternative
557
- * supports files upload
558
- * @param url string
559
- * @param {{method: string;data;header;callbacks;}} opts
560
- * @returns unknown
561
- */
562
- declare function Ajax(url: string | URL, opts?: {
563
- method?: "GET" | "POST";
564
- data?: Record<string, unknown>;
565
- header?: {
566
- "content-type"?: string;
567
- } & Record<string, string>;
568
- callbacks?: Record<string, (arg: Function) => void>;
569
- }): Promise<string>;
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
+ ********************************************************************************/
570
614
 
571
615
  type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE<E | HTMLElement>) => E | HTMLElement | DocumentFragment;
572
616
  /**
@@ -576,21 +620,9 @@ type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE
576
620
  * @example
577
621
  * // using template
578
622
  * const p = _("p");
579
- * _("p.class");
580
- * _("p#id");
581
- * _("p.class#id");
582
623
  * _("p.foo.bar#poo.loo");
583
624
  *
584
- * // using inline props
585
- *
586
- * _("p",{
587
- * text: "am a p tag",
588
- * style: {
589
- * color: "blue"
590
- * }
591
- * })
592
- *
593
- * // props and children
625
+ * // full example
594
626
  * _("p", // template first
595
627
  * // property next if wanted
596
628
  * {style: {color: "brown"}, // optional
@@ -604,4 +636,4 @@ type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE
604
636
  */
605
637
  declare const _: TemplateType;
606
638
 
607
- export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, createSignal, css, data, 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, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, svg, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
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 CHANGED
@@ -8,14 +8,13 @@
8
8
  โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ•šโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘
9
9
  โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ• โ•šโ•โ•โ• โ•šโ•โ• โ•šโ•โ•
10
10
  =============================================================================
11
- Cradova FrameWork
12
- @version 3.0.0
11
+ Cradova
12
+ @version 3.3.0
13
13
  License: Apache V2
14
14
  Copyright 2022 Friday Candour.
15
15
  Repository - https://github.com/fridaycandour/cradova
16
16
  =============================================================================
17
17
  */
18
- var u=r=>r instanceof HTMLElement||r instanceof DocumentFragment,H=class{constructor(){this.listeners={};}async addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);}async dispatchEvent(e,t){let n=this.listeners[e]||[];for(;n.length!==0;)n.shift()?.call(void 0,t);}},h=new H;function b(r){let e=new DocumentFragment;for(let t of r)if(Array.isArray(t))e.appendChild(b(t));else {if(t instanceof T&&(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(u(t))e.appendChild(t);else if(typeof t<"u")throw new Error(" \u2718 Cradova err: invalid child type: "+t+" ("+typeof t+")")}return e}function A(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 N(r,...e){if(r)return e}function j(r,e,t){return r?e:t}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}function x(){let r=0,e=window.location.href;for(let t=0;t<e.length;t++)r+=e.charCodeAt(t);return r.toString()}var T=class{constructor(e){this.effects=[];this.effectuate=null;this.rendered=!1;this.published=!1;this.preRendered=null;this.reference=new f;this._state=[];this._state_track={};this._state_index=0;this.component=e.bind(this);}preRender(e,t){this.reference._appendDomForce("html",this.render(e,t));}destroyPreRendered(){this.preRendered=null;}render(e,t){this.effects=[],this.rendered=!1;let n=this.component(e);return typeof n=="function"&&(n=n()),n||(n=this.preRendered),t&&(this.stash=e),u(n)?(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(typeof t=="function"&&(t=t()),u(t)){let n=this.reference.current("html");n&&(n.insertAdjacentElement("beforebegin",t),n.remove()),this.published=!0,this.reference._appendDomForce("html",t),h.dispatchEvent("onmountEvent");}else console.error(" \u2718 Cradova err : Invalid html content, got - "+t);}},M=function(r){let e=document.createDocumentFragment();for(let t=0;t<r.length;t++){let n=r[t];if(typeof n=="function"&&(n=n()),u(n)){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},C=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);}},f=class{constructor(){this.tree={};this.globalTree={};}bindAs(e){return [this,e]}current(e){return this.tree[x()]?this.tree[x()][e]:null}_appendDomForce(e,t){let n=x();this.tree[n]?this.tree[n][e]=t:(this.tree[n]={},this.tree[n][e]=t);}_appendDomForceGlobal(e,t){this.globalTree[e]=t;}};function V(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(o);}return [e._roll_state(null,t,!0),n]}function J(r,e){e._effect(r);}function O(){return new f}function k(r,e){if(r){if(typeof e=="object"&&!Array.isArray(e))for(let t in e){if(t==="style"&&typeof e[t]=="object"){for(let[o,i]of Object.entries(e[t]))if(typeof r.style[o]<"u"&&o!=="src"&&typeof i=="string")r.style[o]=i;else throw new Error("\u2718 Cradova err : "+o+" is not a valid css style property");continue}let n=e;if(typeof r[t]=="function"){t.startsWith("on")?r[t]=n[t]:r[t].apply(r);continue}if(t==="text"){r.innerText=n[t];continue}if(t==="tree"){r.innerHTML="",r.appendChild(M([n[t]]));continue}if(t.includes("data-")){r.setAttribute(t,n[t]);continue}r[t]=n[t];}if(typeof e=="string"){r.innerText=e;return}if(typeof e=="function"){r.appendChild(M([e]));return}if(e instanceof HTMLElement&&r.appendChild(e),!(typeof e=="object"&&!Array.isArray(e)))throw new Error(` \u2718 Cradova err: Cradova got invalid state =>
19
- `+String(e))}}var _=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);}};var v=new f,g=class{constructor(e){this._errorHandler=null;this._packed=!1;this._template=document.createElement("div");this._persist=!0;this._delegatedRoutesCount=-1;this._dropped=!1;let{template:t,name:n,persist:o,renderInParallel:i,transition:l}=e;this._html=t,this._name=n||"Document",this._transition=l,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,_transition:this._transition,_callBack:this._callBack,_deCallBack:this._deCallBack}}_apply_derivation(e){this._name=e._name,this._transition=e._transition,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(),u(e)&&(this._template.innerHTML="",this._template.appendChild(e));else if(u(e))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(),this._transition&&this._template.classList.remove(this._transition);}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}(!this._persist||e||!this._packed)&&(await this._package(),this._packed=!0),this._transition&&this._template.classList.add(this._transition),document.title=this._name,v.globalTree.doc.innerHTML="",v.globalTree.doc.appendChild(this._template),h.dispatchEvent("onmountEvent"),window.scrollTo({top:0,left:0,behavior:"instant"}),this._callBack&&this._callBack();}};var s={};s.lastNavigatedRouteController=null;s.nextRouteController=null;s.lastNavigatedRoute=null;s.pageShow=null;s.pageHide=null;s.errorHandler=null;s.loadingScreen=null;s.params={};s.routes={};s.pageevents=[];s.paused=!1;s.start_pageevents=async function(r){setTimeout(()=>{for(let e=0;e<s.pageevents.length;e++)s.pageevents[e](r);},100);};var S=r=>{if(s.routes[r])return [s.routes[r],{path:r}];if(s.routes[r+"/"])return [s.routes[r],{path:r}];for(let e in s.routes){if(!e.includes(":"))continue;let t=r.split("/"),n=e.split("/");r.endsWith("/")&&t.pop();let o=0,i=0;if(t.shift(),n.shift(),n.length===t.length){let l={_path:""};for(let c=0;c<n.length;c++){if(n[c].includes(":")){i++;continue}t[c]===n[c]&&o++;}if(o+i===n.length){for(let c=0;c<n.length;c++)n[c].includes(":")&&(l[n[c].split(":")[1]]=t[c]);return l._path=e,[s.routes[e],l]}}}return []};s.route=(r,e)=>{if(typeof e<"u"){if(e&&!e._Activate)throw console.error(" \u2718 Cradova err: not a valid screen ",e),new Error(" \u2718 Cradova err: Not a valid cradova screen component");return s.routes[r]=e}};s.router=async function(r,e){let t=window.location.pathname,n,o;if(s.paused){window.location.hash="paused";return}if(t!==s.lastNavigatedRoute)if(s.nextRouteController?(n=s.nextRouteController,s.nextRouteController=null):[n,o]=S(t),typeof n<"u")try{if(typeof n=="function"&&(s.LoadingScreen&&s.LoadingScreen._Activate&&await s.LoadingScreen._Activate(),n=await n(),!n)){s.lastNavigatedRoute&&history.pushState({},t,s.lastNavigatedRoute);return}if(n._delegatedRoutes!==-1){n._delegatedRoutes=!0;let i=n._derive();n=new g({template:n._html}),n._apply_derivation(i),s.routes[t]=n,h.dispatchEvent("onTransition");}o&&(s.params.params=o),await n._Activate(e),s.start_pageevents(t),s.lastNavigatedRouteController&&s.lastNavigatedRouteController._deActivate(),s.lastNavigatedRoute=t,s.lastNavigatedRouteController=n;}catch(i){if(n&&n._errorHandler)n._errorHandler(i);else if(s.errorHandler)s.errorHandler(i);else throw console.error(i),new Error(" \u2718 Cradova err: consider adding error boundary to the specific screen ")}else s.routes["*"]&&await s.routes["*"]._Activate(e);};var y=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);}y._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(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 g)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,t={}){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[n,o]=S(e);!n._Activate&&typeof n=="function"&&(n=await n()),n._delegatedRoutes!==-1&&(n._delegatedRoutes=!0,n=new g({name:n._name,template:n._html}),s.routes[e]=n),n._package(Object.assign(t,o||{})),n._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?v._appendDomForceGlobal("doc",e):(e=document.createElement("div"),e.setAttribute("data-wrapper","app"),document.body.appendChild(e),v._appendDomForceGlobal("doc",e)),window.addEventListener("pageshow",s.router),window.addEventListener("popstate",t=>{t.preventDefault(),s.router();});}};var E=(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 T&&(i=i.render()),u(i)){r.appendChild(i);continue}if(Array.isArray(i)){r.appendChild(b(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(i[0]instanceof _){r.updateState=k.bind(null,r),i[0].bindRef(r,{_element_property:o,signalProperty:i[1]});continue}if(o=="reference"&&i[0]instanceof f){r.updateState=k.bind(null,r),i[0]._appendDomForce(i[1],r);continue}}if(o==="onmount"&&typeof t.onmount=="function"){let l=()=>{t.onmount?.apply(r),t.onmount=void 0;};h.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",c=>{c.preventDefault(),y.navigate(r.pathname);if(l.includes("#")){let p=l.split("#").at(-1);document.getElementById("#"+p)?.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},R=function(r){if(typeof r!="string")return [];Array.isArray(r)&&(r=r[0]);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)=>E(document.createElement(r),t),te=a("a"),ne=a("area"),re=a("article"),oe=a("aside"),ae=a("audio"),ie=a("b"),se=a("base"),le=a("blockquote"),ce=a("br"),pe=a("button"),ue=a("canvas"),de=a("caption"),fe=a("code"),me=a("col"),he=a("colgroup"),ge=a("data"),ye=a("datalist"),Te=a("details"),_e=a("dialog"),ve=a("div"),Ee=a("em"),we=a("embed"),Le=a("figure"),xe=a("footer"),He=a("form"),be=a("h1"),Me=a("h2"),ke=a("h3"),Se=a("h4"),Ce=a("h5"),Re=a("h6"),De=a("head"),Pe=a("header"),Ae=a("hr"),Ne=a("i"),je=a("iframe"),Fe=a("img"),Ve=a("input"),Je=a("label"),Oe=a("legend"),Be=a("li"),Ie=a("link"),Ye=a("main"),qe=a("menu"),Ge=a("nav"),$e=a("object"),Ue=a("ol"),Xe=a("optgroup"),Ke=a("option"),We=a("p"),Qe=a("pre"),Ze=a("progress"),ze=a("q"),et=a("section"),tt=a("select"),nt=a("source"),rt=a("span"),ot=a("strong"),at=a("summary"),it=a("table"),st=a("tbody"),lt=a("td"),ct=a("template"),pt=a("textarea"),ut=a("th"),dt=a("title"),ft=a("tr"),mt=a("track"),ht=a("u"),gt=a("ul"),yt=a("video"),Tt=(r,e)=>{let t=document.createElement("span");return t.innerHTML=r,E(t,[e])};function D(r,e={}){let{method:t,data:n,header:o,callbacks:i}=e;if(typeof r!="string")throw new Error("\u2718 Cradova err : Ajax invalid url "+r);return new Promise(function(l,c){let p=new XMLHttpRequest,w=new FormData;if(i&&typeof i=="object")for(let[m,L]of Object.entries(i))p.addEventListener(m,L);if(p.addEventListener("load",function(){l(p.response);}),n&&typeof n=="object")for(let[m,L]of Object.entries(n)){let d=L;typeof d=="object"&&d&&!d.name&&(d=JSON.stringify(d),w.set(m,d)),typeof d=="string"&&w.set(m,d);}p.addEventListener("error",()=>{navigator.onLine?c(JSON.stringify({message:"problem with the action, please try again!"})):c(JSON.stringify({message:"this device is offline!"}));}),t?p.open(t,r,!0):p.open(n&&typeof n=="object"?"POST":"GET",r,!0),o&&typeof o=="object"&&Object.keys(o).forEach(function(m){p.setRequestHeader(m,o[m]);}),p.send(w);})}var P=(...r)=>{let{0:e,1:t,2:n,3:o}=R(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()),E(i,r)},wt=P;
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;
20
19
 
21
- export { D as Ajax, h as CradovaEvent, T as Ref, b as Rhoda, y as Router, g as Screen, te as a, ne as area, re as article, oe as aside, N as assert, j as assertOr, ae as audio, ie as b, se as base, le as blockquote, ce as br, pe as button, ue as canvas, de as caption, fe as code, me as col, he as colgroup, _ as createSignal, A as css, ge as data, ye as datalist, wt as default, Te as details, _e as dialog, ve as div, Ee as em, we as embed, Le as figure, xe as footer, He as form, M as frag, be as h1, Me as h2, ke as h3, Se as h4, Ce as h5, Re as h6, De as head, Pe as header, Ae as hr, Ne as i, je as iframe, Fe as img, Ve as input, u as isNode, Je as label, C as lazy, Oe as legend, Be as li, Ie as link, F as loop, Ye as main, R as make, E as makeElement, qe as menu, Ge as nav, $e as object, Ue as ol, Xe as optgroup, Ke as option, We as p, Qe as pre, Ze as progress, ze as q, f as reference, et as section, tt as select, nt as source, rt as span, ot as strong, at as summary, Tt as svg, it as table, st as tbody, lt as td, ct as template, pt as textarea, ut as th, dt as title, ft as tr, mt as track, ht as u, gt as ul, J as useEffect, O as useRef, V as useState, yt as video };
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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.2.2",
4
- "description": "Web framework for building web apps and PWAs",
3
+ "version": "3.3.1",
4
+ "description": "Web framework for building powerful web apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "files": [
@@ -13,19 +13,22 @@
13
13
  "url": "git+https://github.com/FridayCandour/cradova.git"
14
14
  },
15
15
  "scripts": {
16
- "build": "tsup lib/index.ts",
17
- "pub": "tsup lib/index.ts && npm publish",
16
+ "build": "tsup src/index.ts",
17
+ "pub": "tsup src/index.ts && npm publish",
18
18
  "lint": "eslint . --fix"
19
19
  },
20
20
  "keywords": [
21
- "javascript",
22
- "typescript",
23
- "frontend",
24
- "framework",
25
21
  "PWA",
26
- "web",
27
- "app",
28
- "mobile"
22
+ "webapp",
23
+ "parallel rendering",
24
+ "conditionals",
25
+ "prerendering",
26
+ "cradova elements",
27
+ "Refs",
28
+ "createSignal",
29
+ "VJS",
30
+ "vjs specification",
31
+ "cradova"
29
32
  ],
30
33
  "author": {
31
34
  "name": "friday candour",
@@ -57,15 +60,12 @@
57
60
  },
58
61
  "homepage": "https://github.com/FridayCandour/cradova",
59
62
  "devDependencies": {
60
- "@types/jest": "^29.2.4",
61
63
  "@typescript-eslint/eslint-plugin": "^5.47.0",
62
64
  "@typescript-eslint/parser": "^5.47.0",
63
65
  "eslint": "^8.30.0",
64
66
  "eslint-config-prettier": "^8.5.0",
65
67
  "eslint-plugin-prettier": "^4.2.1",
66
- "jest": "^29.3.1",
67
68
  "prettier": "^2.8.1",
68
- "ts-jest": "^29.0.3",
69
69
  "tsup": "^6.7.0",
70
70
  "typescript": "^4.9.4"
71
71
  },