cradova 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +19 -0
- package/CHANGELOG.md +23 -0
- package/README.md +51 -19
- package/contributing.md +7 -0
- package/dist/index.d.ts +467 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1684 -0
- package/dist/index.js.map +1 -0
- package/dist/module.js +1707 -0
- package/dist/module.js.map +1 -0
- package/dist/site/app.d.ts +1 -0
- package/dist/site/app.js +1 -0
- package/dist/site/doc/home.d.ts +3 -0
- package/dist/site/doc/home.js +17 -0
- package/dist/site/doc/info.d.ts +3 -0
- package/dist/site/doc/info.js +121 -0
- package/dist/site/index.d.ts +1 -0
- package/dist/site/index.js +11 -0
- package/dist/site/workers/online-only-after-initial-cache.d.ts +1 -0
- package/dist/site/workers/online-only-after-initial-cache.js +152 -0
- package/dist/site/workers/service-worker.d.ts +1 -0
- package/{service-worker.ts → dist/site/workers/service-worker.js} +13 -12
- package/dist/src/index.d.ts +59 -0
- package/dist/src/index.js +450 -0
- package/dist/src/sacho/loadCss.d.ts +1 -0
- package/dist/src/sacho/loadCss.js +216 -0
- package/dist/src/sacho/swipe.d.ts +15 -0
- package/dist/src/sacho/swipe.js +122 -0
- package/dist/src/sacho/swipe1.d.ts +15 -0
- package/dist/src/sacho/swipe1.js +122 -0
- package/dist/src/scripts/Router.d.ts +8 -0
- package/dist/src/scripts/Router.js +296 -0
- package/dist/src/scripts/Screen.d.ts +54 -0
- package/dist/src/scripts/Screen.js +181 -0
- package/dist/src/scripts/ajax.d.ts +21 -0
- package/dist/src/scripts/ajax.js +70 -0
- package/dist/src/scripts/createSignal.d.ts +140 -0
- package/dist/src/scripts/createSignal.js +259 -0
- package/dist/src/scripts/fns.d.ts +161 -0
- package/dist/src/scripts/fns.js +561 -0
- package/dist/src/scripts/init.d.ts +1 -0
- package/dist/src/scripts/init.js +9 -0
- package/dist/src/scripts/track.d.ts +11 -0
- package/dist/src/scripts/track.js +154 -0
- package/dist/src/types.d.ts +264 -0
- package/{docs/README.md → dist/src/types.js} +0 -0
- package/git +35 -0
- package/index.html +48 -0
- package/package.json +31 -17
- package/site/app.ts +2 -0
- package/site/assets/badge.svg +85 -0
- package/site/assets/bulb.png +0 -0
- package/site/assets/cloud.png +0 -0
- package/site/assets/correct.svg +1 -0
- package/site/assets/cradova.png +0 -0
- package/site/assets/des.svg +132 -0
- package/site/assets/sacho.png +0 -0
- package/site/assets/shoot.svg +1 -0
- package/site/assets/spaceship.svg +1 -0
- package/site/assets/star.svg +11 -0
- package/site/assets/support.svg +1 -0
- package/site/doc/home.ts +19 -0
- package/site/doc/info.ts +142 -0
- package/site/index.ts +15 -0
- package/{manifest.json → site/manifest.json} +8 -9
- package/site/prism/prism.css +3 -0
- package/site/prism/prism.js +1013 -0
- package/site/styles/style.css +201 -0
- package/site/sw.js +58 -0
- package/{online-only-after-initial-cache.ts → site/workers/online-only-after-initial-cache.ts} +16 -11
- package/site/workers/service-worker.ts +60 -0
- package/src/index.ts +487 -0
- package/src/sacho/loadCss.ts +216 -0
- package/src/sacho/style.css +187 -0
- package/src/sacho/swipe.ts +136 -0
- package/src/sacho/swipe1.ts +136 -0
- package/src/scripts/Router.ts +268 -0
- package/src/scripts/Screen.ts +168 -0
- package/src/scripts/ajax.ts +83 -0
- package/src/scripts/createSignal.ts +273 -0
- package/src/scripts/fns.ts +604 -0
- package/src/scripts/init.ts +9 -0
- package/src/scripts/track.ts +158 -0
- package/src/types.ts +286 -0
- package/tsconfig.json +17 -98
- package/index.ts +0 -353
- package/scripts/JsonDB.ts +0 -747
- package/scripts/Metrics.ts +0 -66
- package/scripts/Router.ts +0 -112
- package/scripts/Screen.ts +0 -74
- package/scripts/animate.ts +0 -55
- package/scripts/createState.ts +0 -27
- package/scripts/css.ts +0 -47
- package/scripts/dispatcher.ts +0 -158
- package/scripts/fetcher.ts +0 -31
- package/scripts/file-system.ts +0 -173
- package/scripts/fullscreen.ts +0 -21
- package/scripts/init.ts +0 -17
- package/scripts/littleAxios.ts +0 -40
- package/scripts/localStorage.ts +0 -19
- package/scripts/media.ts +0 -51
- package/scripts/promptbeforeleave.ts +0 -10
- package/scripts/reuse.ts +0 -79
- package/scripts/speaker.ts +0 -25
- package/scripts/store.ts +0 -47
- package/scripts/swipe.ts +0 -125
- package/scripts/uuid.ts +0 -10
- package/scripts/widget.ts +0 -21
- package/types.d.ts +0 -0
- package/types.ts +0 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": [
|
|
3
|
+
"childrens",
|
|
4
|
+
"chtml",
|
|
5
|
+
"deactivatecall",
|
|
6
|
+
"Dispatchtrack",
|
|
7
|
+
"Divs",
|
|
8
|
+
"domimg",
|
|
9
|
+
"Lenght",
|
|
10
|
+
"myappname",
|
|
11
|
+
"proplen",
|
|
12
|
+
"removeclass",
|
|
13
|
+
"stateid",
|
|
14
|
+
"tabindex",
|
|
15
|
+
"toggleclass",
|
|
16
|
+
"upcb",
|
|
17
|
+
"wrappper"
|
|
18
|
+
]
|
|
19
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# cradova changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- basic functionality not proper way to handle state
|
|
6
|
+
|
|
7
|
+
## 1.0.1
|
|
8
|
+
|
|
9
|
+
- improved performance score
|
|
10
|
+
|
|
11
|
+
## 1.0.2
|
|
12
|
+
|
|
13
|
+
- improved api and dev experience
|
|
14
|
+
|
|
15
|
+
## 1.0.3
|
|
16
|
+
|
|
17
|
+
- improved state management
|
|
18
|
+
|
|
19
|
+
## 1.0.4
|
|
20
|
+
|
|
21
|
+
- big performance gain
|
|
22
|
+
- improved state management
|
|
23
|
+
- battle testing and production readiness
|
package/README.md
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
# cradova PWA sample
|
|
2
2
|
|
|
3
3
|
<p>
|
|
4
|
-
<a href="https://www.npmjs.com/package/
|
|
5
|
-
<img src="https://img.shields.io/npm/v/
|
|
4
|
+
<a href="https://www.npmjs.com/package/cradova">
|
|
5
|
+
<img src="https://img.shields.io/npm/v/cradova.svg" alt="npm Version" />
|
|
6
6
|
</a>
|
|
7
|
-
<a href="https://github.com/
|
|
8
|
-
<img src="https://img.shields.io/npm/l/
|
|
7
|
+
<a href="https://github.com/cradova/cradova.js/blob/next/LICENSE">
|
|
8
|
+
<img src="https://img.shields.io/npm/l/cradova.svg" alt="License" />
|
|
9
9
|
</a>
|
|
10
|
-
<a href="https://www.npmjs.com/package/
|
|
11
|
-
<img src="https://img.shields.io/npm/dm/
|
|
10
|
+
<a href="https://www.npmjs.com/package/cradova">
|
|
11
|
+
<img src="https://img.shields.io/npm/dm/cradova.svg" alt="npm Downloads">
|
|
12
12
|
</a>
|
|
13
|
-
<a href="https://www.npmjs.com/package/
|
|
14
|
-
<img src="https://img.shields.io/travis/
|
|
13
|
+
<a href="https://www.npmjs.com/package/cradova">
|
|
14
|
+
<img src="https://img.shields.io/travis/cradova/cradova.js/next.svg?colorB=brightgreen" alt="Build Status">
|
|
15
15
|
</a>
|
|
16
16
|
|
|
17
|
-
<a href="https://opencollective.com/
|
|
18
|
-
<img src="https://img.shields.io/opencollective/all/
|
|
17
|
+
<a href="https://opencollective.com/cradova">
|
|
18
|
+
<img src="https://img.shields.io/opencollective/all/cradova.svg?colorB=brightgreen" alt="Donate at OpenCollective">
|
|
19
19
|
</a>
|
|
20
20
|
</p>
|
|
21
21
|
|
|
22
|
-
- [What is
|
|
22
|
+
- [What is cradova.js?](#what-is-cradova?)
|
|
23
23
|
- [Installation](#installation)
|
|
24
24
|
- [Documentation](#documentation)
|
|
25
25
|
- [Getting Help](#getting-help)
|
|
26
|
-
- [Contributing](#building-
|
|
26
|
+
- [Contributing](#building-cradova-parkages)
|
|
27
27
|
|
|
28
|
-
## What is
|
|
28
|
+
## What is cradova.js?
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
cradova is a JavaScript framework for building Single Page Applications and PWAs.
|
|
31
31
|
|
|
32
32
|
It's small, fast and provides routing and XHR utilities out of the box.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
cradova.js supports various versions of IE11, Firefox ESR, and Firefox,
|
|
35
|
+
Edge, Safari, and Chrome. No polyfills required.
|
|
35
36
|
|
|
36
37
|
## Installation
|
|
37
38
|
|
|
@@ -39,14 +40,45 @@ Cradova.js supports various versions of IE11, Firefox ESR, and Firefox, Edge, Sa
|
|
|
39
40
|
|
|
40
41
|
```html
|
|
41
42
|
<!-- Production: whichever you prefer -->
|
|
42
|
-
<script src="https://unpkg.com/
|
|
43
|
-
<script src="https://cdn.jsdelivr.net/npm/
|
|
43
|
+
<script src="https://unpkg.com/cradova/cradova.min.js"></script>
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/cradova/cradova.min.js"></script>
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
### npm
|
|
47
48
|
|
|
48
49
|
```bash
|
|
49
|
-
npm install
|
|
50
|
+
npm install cradova --save
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
<img src="
|
|
53
|
+
<img src="cradova.jpg">
|
|
54
|
+
|
|
55
|
+
### `npm start`
|
|
56
|
+
|
|
57
|
+
Runs the app in the development mode.\
|
|
58
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
59
|
+
|
|
60
|
+
The page will reload when you make changes.\
|
|
61
|
+
You may also see any lint errors in the console.
|
|
62
|
+
|
|
63
|
+
### `npm test`
|
|
64
|
+
|
|
65
|
+
Launches the test runner in the interactive watch mode.\
|
|
66
|
+
See the section about [running tests](https://fridaycandour.github.io/cradova/docs/running-tests) for more information.
|
|
67
|
+
|
|
68
|
+
### `npm run build`
|
|
69
|
+
|
|
70
|
+
Builds the app for production to the `build` folder.\
|
|
71
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
72
|
+
|
|
73
|
+
The build is minified and the filenames include the hashes.\
|
|
74
|
+
Your app is ready to be deployed!
|
|
75
|
+
|
|
76
|
+
See the section about [deployment](https://fridaycandour.github.io/cradova/docs/deployment) for more information.
|
|
77
|
+
|
|
78
|
+
### Analyzing the Bundle Size
|
|
79
|
+
|
|
80
|
+
This section has moved here: [https://fridaycandour.github.io/cradova/docs/analyzing-the-bundle-size](https://fridaycandour.github.io/cradova/docs/analyzing-the-bundle-size)
|
|
81
|
+
|
|
82
|
+
### Making a Progressive Web App
|
|
83
|
+
|
|
84
|
+
This section has moved here: [https://fridaycandour.github.io/cradova/docs/making-a-progressive-web-app](https://fridaycandour.github.io/cradova/docs/making-a-progressive-web-app)
|
package/contributing.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* swipe
|
|
3
|
+
* ---
|
|
4
|
+
* Now you can detect swipes the best way possible
|
|
5
|
+
*
|
|
6
|
+
* @param callabck
|
|
7
|
+
* @param touching?
|
|
8
|
+
*/
|
|
9
|
+
export function swipe(
|
|
10
|
+
callabck: (swipe_data: Record<string, number>) => void,
|
|
11
|
+
touching?: boolean
|
|
12
|
+
): {
|
|
13
|
+
start(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Cradova Signal
|
|
18
|
+
* ----
|
|
19
|
+
* create stateful data store.
|
|
20
|
+
* ability to:
|
|
21
|
+
* - create a store
|
|
22
|
+
* - create actions and fire them
|
|
23
|
+
* - bind a Ref or RefList
|
|
24
|
+
* - listen to changes
|
|
25
|
+
* - persist changes to localStorage
|
|
26
|
+
* - go back and forward in value history
|
|
27
|
+
* - set keys instead of all values
|
|
28
|
+
* - update a cradova Ref/RefList automatically
|
|
29
|
+
* @constructor initial: any, props: {useHistory, persist}
|
|
30
|
+
*/
|
|
31
|
+
export class createSignal {
|
|
32
|
+
value: any;
|
|
33
|
+
constructor(
|
|
34
|
+
initial: unknown,
|
|
35
|
+
props?: {
|
|
36
|
+
useHistory?: boolean;
|
|
37
|
+
persistName?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
/**
|
|
41
|
+
* Cradova Signal
|
|
42
|
+
* ----
|
|
43
|
+
* set signal value
|
|
44
|
+
* @param value - signal value
|
|
45
|
+
* @returns void
|
|
46
|
+
*/
|
|
47
|
+
set(value: unknown, shouldRefRender?: boolean): void;
|
|
48
|
+
/**
|
|
49
|
+
* Cradova Signal
|
|
50
|
+
* ----
|
|
51
|
+
* set a key value if it's an object
|
|
52
|
+
* @param name - name of the key
|
|
53
|
+
* @param value - value of the key
|
|
54
|
+
* @returns void
|
|
55
|
+
*/
|
|
56
|
+
setKey(name: string, value: any, shouldRefRender?: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* Cradova Signal
|
|
59
|
+
* ----
|
|
60
|
+
* set a prop value inside an object prop of the store
|
|
61
|
+
* @param key - a prop of the store - object value
|
|
62
|
+
* @param name - prop of the key object
|
|
63
|
+
* @param value - value of the name
|
|
64
|
+
* @returns void
|
|
65
|
+
*/
|
|
66
|
+
setPath(
|
|
67
|
+
key: string,
|
|
68
|
+
name: string,
|
|
69
|
+
value: any,
|
|
70
|
+
shouldRefRender?: boolean
|
|
71
|
+
): void;
|
|
72
|
+
/**
|
|
73
|
+
* Cradova Signal
|
|
74
|
+
* ----
|
|
75
|
+
* set a prop value inside an array prop of the store
|
|
76
|
+
* @param key - a prop of the store - object value
|
|
77
|
+
* @param index - index of the key object
|
|
78
|
+
* @param value - value of the index
|
|
79
|
+
* @returns void
|
|
80
|
+
*/
|
|
81
|
+
setIndex(
|
|
82
|
+
key: string,
|
|
83
|
+
index: number,
|
|
84
|
+
value: any,
|
|
85
|
+
shouldRefRender?: boolean
|
|
86
|
+
): void;
|
|
87
|
+
/**
|
|
88
|
+
* Cradova Signal
|
|
89
|
+
* ----
|
|
90
|
+
* set a key to signal an action
|
|
91
|
+
* @param name - name of the action
|
|
92
|
+
* @param action function to execute
|
|
93
|
+
*/
|
|
94
|
+
createAction(
|
|
95
|
+
name: string | Record<string, (self?: any, data?: any) => void>,
|
|
96
|
+
action?: (self?: any, data?: any) => void
|
|
97
|
+
): void;
|
|
98
|
+
/**
|
|
99
|
+
* Cradova Signal
|
|
100
|
+
* ----
|
|
101
|
+
* fires an action if available
|
|
102
|
+
* @param name - string name of the action
|
|
103
|
+
* @param data - data for the action
|
|
104
|
+
*/
|
|
105
|
+
fireAction(name: string, data?: any): void;
|
|
106
|
+
/**
|
|
107
|
+
* Cradova Signal
|
|
108
|
+
* ----
|
|
109
|
+
* set a auto - rendering component for this store
|
|
110
|
+
*
|
|
111
|
+
* @param Ref component to bind to.
|
|
112
|
+
* @param path a property in the object to send to attached ref
|
|
113
|
+
*/
|
|
114
|
+
bindRef(Ref: any, path?: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Cradova Signal
|
|
117
|
+
* ----
|
|
118
|
+
* set signal value to a future one
|
|
119
|
+
* @returns void
|
|
120
|
+
*/
|
|
121
|
+
forward(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Cradova Signal
|
|
124
|
+
* ----
|
|
125
|
+
* set signal value to a old past one
|
|
126
|
+
* @returns void
|
|
127
|
+
*/
|
|
128
|
+
backward(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Cradova Signal
|
|
131
|
+
* ----
|
|
132
|
+
* set a update listener on value changes
|
|
133
|
+
* @param callback
|
|
134
|
+
*/
|
|
135
|
+
listen(callback: (a: any) => void): void;
|
|
136
|
+
/**
|
|
137
|
+
* Cradova Signal
|
|
138
|
+
* ----
|
|
139
|
+
* get value */
|
|
140
|
+
get(): any;
|
|
141
|
+
/**
|
|
142
|
+
* Cradova Signal
|
|
143
|
+
* ----
|
|
144
|
+
* clear the history on local storage
|
|
145
|
+
*/
|
|
146
|
+
clearPersist(): void;
|
|
147
|
+
}
|
|
148
|
+
type CradovaScreenType = {
|
|
149
|
+
name: string;
|
|
150
|
+
template: Function | HTMLElement;
|
|
151
|
+
transition?: string;
|
|
152
|
+
callBack?: (html?: any, data?: Record<string, any>) => void;
|
|
153
|
+
persist?: boolean;
|
|
154
|
+
};
|
|
155
|
+
type RouterRouteObject = {
|
|
156
|
+
controller: (params: object, force?: boolean) => any;
|
|
157
|
+
deactivate: (params: object) => any;
|
|
158
|
+
packager: (params: any) => void;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Cradova Router
|
|
162
|
+
* ---
|
|
163
|
+
* Facilitates navigation within the application and initializes
|
|
164
|
+
* page views based on the matched routes.
|
|
165
|
+
*/
|
|
166
|
+
type RouterType =
|
|
167
|
+
| {
|
|
168
|
+
/**
|
|
169
|
+
* Registers a route.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} path Route path.
|
|
172
|
+
* @param {any} screen the cradova document tree for the route.
|
|
173
|
+
*/
|
|
174
|
+
route: (path: string, screen: CradovaScreenType) => void;
|
|
175
|
+
routes: Record<string, RouterRouteObject>;
|
|
176
|
+
lastNavigatedRoute: string | null;
|
|
177
|
+
lastNavigatedRouteController: RouterRouteObject | null;
|
|
178
|
+
nextRouteController: RouterRouteObject | null;
|
|
179
|
+
params: Record<string, any>;
|
|
180
|
+
/**
|
|
181
|
+
* n/a
|
|
182
|
+
*/
|
|
183
|
+
router: (e: any, force?: boolean) => void;
|
|
184
|
+
/**
|
|
185
|
+
* get a screen ready before time.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} path Route path.
|
|
188
|
+
* @param {any} data data for the screen.
|
|
189
|
+
*/
|
|
190
|
+
packageScreen: (path: string, data?: any) => void;
|
|
191
|
+
pageShow: ((path: string) => void) | null;
|
|
192
|
+
pageHide: ((path: string) => void) | null;
|
|
193
|
+
onPageShow: (callback: () => void) => void;
|
|
194
|
+
onPageHide: (callback: () => void) => void;
|
|
195
|
+
/**
|
|
196
|
+
* Cradova Router
|
|
197
|
+
* ------
|
|
198
|
+
*
|
|
199
|
+
* Navigates to a designated screen in your app
|
|
200
|
+
*/
|
|
201
|
+
navigate: (
|
|
202
|
+
href: string,
|
|
203
|
+
data?: Record<string, any> | null,
|
|
204
|
+
force?: boolean
|
|
205
|
+
) => void;
|
|
206
|
+
}
|
|
207
|
+
| Record<string, any>;
|
|
208
|
+
/**
|
|
209
|
+
* Cradova Router
|
|
210
|
+
* ---
|
|
211
|
+
* Facilitates navigation within the application and initializes
|
|
212
|
+
* page views based on the matched routes.
|
|
213
|
+
*/
|
|
214
|
+
export const Router: RouterType;
|
|
215
|
+
/**
|
|
216
|
+
*
|
|
217
|
+
* @param name
|
|
218
|
+
* @param template
|
|
219
|
+
* @param transitions
|
|
220
|
+
*/
|
|
221
|
+
export class Screen {
|
|
222
|
+
/**
|
|
223
|
+
* this is the name of the screen that appears as the title
|
|
224
|
+
*/
|
|
225
|
+
name: string;
|
|
226
|
+
secondaryChildren: Array<any>;
|
|
227
|
+
static SCALE_IN: string;
|
|
228
|
+
static SCALE_OUT: string;
|
|
229
|
+
static CIRCLE_IN: string;
|
|
230
|
+
static CIRCLE_OUT: string;
|
|
231
|
+
static FADE_OUT: string;
|
|
232
|
+
static FADE_IN: string;
|
|
233
|
+
static SLIDE_UP: string;
|
|
234
|
+
static SLIDE_DOWN: string;
|
|
235
|
+
static SLIDE_LEFT: string;
|
|
236
|
+
static SLIDE_RIGHT: string;
|
|
237
|
+
/**
|
|
238
|
+
* this tells cradova to persist state on the screen or not
|
|
239
|
+
* persisting is better
|
|
240
|
+
*/
|
|
241
|
+
persist: boolean;
|
|
242
|
+
constructor(cradova_screen_initials: CradovaScreenType);
|
|
243
|
+
package(data: any): Promise<void>;
|
|
244
|
+
onActivate(cb: (data: any) => void): void;
|
|
245
|
+
onDeactivate(cb: (data: any) => void): void;
|
|
246
|
+
addChild(...addOns: any[]): void;
|
|
247
|
+
detach(): void;
|
|
248
|
+
Activate(data: any, force: boolean): Promise<void>;
|
|
249
|
+
}
|
|
250
|
+
export const controls: () => void;
|
|
251
|
+
export function uuid(num?: number): string;
|
|
252
|
+
export function PromptBeforeLeave(callback?: (e: any) => void): void;
|
|
253
|
+
/**
|
|
254
|
+
Write CSS media in javascript
|
|
255
|
+
|
|
256
|
+
@example
|
|
257
|
+
|
|
258
|
+
_.media("min-width: 790px",
|
|
259
|
+
["#container",
|
|
260
|
+
{
|
|
261
|
+
width: "100%",
|
|
262
|
+
height: "100%",
|
|
263
|
+
"background-color": "#0000"
|
|
264
|
+
}],
|
|
265
|
+
|
|
266
|
+
["#header",
|
|
267
|
+
{
|
|
268
|
+
width: "100%",
|
|
269
|
+
height: "20%",
|
|
270
|
+
"background-color": "#fff"
|
|
271
|
+
}]
|
|
272
|
+
)
|
|
273
|
+
*/
|
|
274
|
+
export function media(value: string, ...properties: any[]): void;
|
|
275
|
+
/**
|
|
276
|
+
Write CSS styles in Javascript
|
|
277
|
+
@example
|
|
278
|
+
|
|
279
|
+
css("#container",
|
|
280
|
+
{
|
|
281
|
+
height: "100%",
|
|
282
|
+
height: "100%",
|
|
283
|
+
background-color: "#ff9800"
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
css(".btn:hover",
|
|
287
|
+
{
|
|
288
|
+
height: "100%",
|
|
289
|
+
height: "100%",
|
|
290
|
+
background-color: "#ff9800"
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
*/
|
|
294
|
+
export function css(
|
|
295
|
+
identifier: string,
|
|
296
|
+
properties: Record<string, string>
|
|
297
|
+
): void;
|
|
298
|
+
/**
|
|
299
|
+
Write animation value in javascript
|
|
300
|
+
|
|
301
|
+
@example
|
|
302
|
+
|
|
303
|
+
_.animate("polarization",
|
|
304
|
+
["from",
|
|
305
|
+
{
|
|
306
|
+
transform: "scale3D(2)" ,
|
|
307
|
+
height: "10%",
|
|
308
|
+
"background-color": "#0000"
|
|
309
|
+
}],
|
|
310
|
+
|
|
311
|
+
["to",
|
|
312
|
+
{
|
|
313
|
+
transform: "scale3D(1)" ,
|
|
314
|
+
height: "100%",
|
|
315
|
+
"background-color": "#ff9800"
|
|
316
|
+
}]
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
*/
|
|
320
|
+
export function animate(identifier: string, ...properties: any[]): void;
|
|
321
|
+
/**
|
|
322
|
+
*
|
|
323
|
+
* @param {expression} condition
|
|
324
|
+
* @param {function} callback
|
|
325
|
+
*/
|
|
326
|
+
export function assert(
|
|
327
|
+
condition: any,
|
|
328
|
+
...callback: (() => any)[]
|
|
329
|
+
): "" | (() => any)[];
|
|
330
|
+
export function assertOr(
|
|
331
|
+
condition: any,
|
|
332
|
+
ifTrue: () => any,
|
|
333
|
+
ifFalse: () => any
|
|
334
|
+
): () => any;
|
|
335
|
+
/**
|
|
336
|
+
* Create element and get a callback to update their state
|
|
337
|
+
* no need to manage stateIDs
|
|
338
|
+
* ----------------------------------------------------------------
|
|
339
|
+
*
|
|
340
|
+
* @param element_initials
|
|
341
|
+
* @param props
|
|
342
|
+
* @returns
|
|
343
|
+
*/
|
|
344
|
+
export function RefElement(
|
|
345
|
+
element_initials?: string,
|
|
346
|
+
props?: Record<string, string>
|
|
347
|
+
): {
|
|
348
|
+
render(data: any): any;
|
|
349
|
+
updateState(state: Record<string, any>): void;
|
|
350
|
+
};
|
|
351
|
+
export const ls: Record<string, Function>;
|
|
352
|
+
export function fullScreen(e: Element): {
|
|
353
|
+
set(): void;
|
|
354
|
+
exist(): void;
|
|
355
|
+
};
|
|
356
|
+
export class RefList {
|
|
357
|
+
constructor(component: (...data: any) => any);
|
|
358
|
+
stale(datas: any): void;
|
|
359
|
+
render(datas?: any): any;
|
|
360
|
+
updateState(datas: any[]): void;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Cradova Ref
|
|
364
|
+
* -------
|
|
365
|
+
* create dynamic components
|
|
366
|
+
*
|
|
367
|
+
*/
|
|
368
|
+
export class Ref {
|
|
369
|
+
constructor(component: (...data: any) => any);
|
|
370
|
+
stale(...data: any): void;
|
|
371
|
+
/**
|
|
372
|
+
* Cradova Ref
|
|
373
|
+
* ---
|
|
374
|
+
* returns html with cradova reference
|
|
375
|
+
* @param data
|
|
376
|
+
* @returns html
|
|
377
|
+
*/
|
|
378
|
+
render(...data: any): () => any;
|
|
379
|
+
onStateUpdate(cb: any): void;
|
|
380
|
+
/**
|
|
381
|
+
* Cradova Ref
|
|
382
|
+
* ---
|
|
383
|
+
* update ref component with new data and update the dom.
|
|
384
|
+
* @param data
|
|
385
|
+
* @returns void
|
|
386
|
+
*/
|
|
387
|
+
updateState(...data: any): void;
|
|
388
|
+
remove(): void;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Document fragment
|
|
392
|
+
* @param children
|
|
393
|
+
* @returns
|
|
394
|
+
*/
|
|
395
|
+
type fragmentTYPE = () => (() => HTMLElement) | HTMLElement;
|
|
396
|
+
export const frag: (...children: fragmentTYPE[]) => DocumentFragment;
|
|
397
|
+
/**
|
|
398
|
+
* Send a new state to specified element with stateID
|
|
399
|
+
*
|
|
400
|
+
* @param stateID
|
|
401
|
+
* @param state
|
|
402
|
+
* @returns element(s)
|
|
403
|
+
*/
|
|
404
|
+
export function dispatch(
|
|
405
|
+
stateID: string | Record<string, any>,
|
|
406
|
+
state?: Record<string, any>
|
|
407
|
+
): Node[];
|
|
408
|
+
/**
|
|
409
|
+
*
|
|
410
|
+
* Cradova Ajax
|
|
411
|
+
* ------------------
|
|
412
|
+
* your new axios alternative
|
|
413
|
+
* supports files upload
|
|
414
|
+
* @param url string
|
|
415
|
+
* @param {{method: string;data;header;callbacks;}} opts
|
|
416
|
+
* @returns any
|
|
417
|
+
*/
|
|
418
|
+
export function Ajax(
|
|
419
|
+
url: string | URL,
|
|
420
|
+
opts?:
|
|
421
|
+
| {
|
|
422
|
+
method?: string;
|
|
423
|
+
data?: Record<string, any>;
|
|
424
|
+
header?: Record<string, any>;
|
|
425
|
+
callbacks?: Record<string, (arg: any) => void>;
|
|
426
|
+
}
|
|
427
|
+
| any
|
|
428
|
+
): Promise<unknown>;
|
|
429
|
+
/**
|
|
430
|
+
* Creates new cradova HTML element
|
|
431
|
+
* @example
|
|
432
|
+
* _("p") // or _("p.class") or _("p#id") or _("p.class#id")
|
|
433
|
+
* using inline props
|
|
434
|
+
* _("p",{
|
|
435
|
+
* text: "am a p tag",
|
|
436
|
+
* style: {
|
|
437
|
+
* color: "blue"
|
|
438
|
+
* }
|
|
439
|
+
* )
|
|
440
|
+
* adding children
|
|
441
|
+
* _("p",
|
|
442
|
+
* _("span",{text:" am a span tag like so",
|
|
443
|
+
* {style: {color: "brown"}
|
|
444
|
+
* })
|
|
445
|
+
* )
|
|
446
|
+
*
|
|
447
|
+
* props and children
|
|
448
|
+
* _("p",
|
|
449
|
+
* // props first
|
|
450
|
+
* {
|
|
451
|
+
* text: "am a p tag",
|
|
452
|
+
* style: {
|
|
453
|
+
* color: "blue"
|
|
454
|
+
* },
|
|
455
|
+
* // all children goes after
|
|
456
|
+
* _("span",{text:" am a span tag like so",
|
|
457
|
+
* {style: {color: "brown"}
|
|
458
|
+
* })
|
|
459
|
+
* )
|
|
460
|
+
*
|
|
461
|
+
* @param {...any} element_initials
|
|
462
|
+
* @returns function - cradova element
|
|
463
|
+
*/
|
|
464
|
+
declare const _: any;
|
|
465
|
+
export default _;
|
|
466
|
+
|
|
467
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA;;;;;;;GAOG;AACH,sBACE,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,EACtD,QAAQ,GAAE,OAAe;;;EA8G1B;ACxHD;;;;;;;;;;;;;;GAcG;AAEH;IASE,KAAK,EAAE,GAAG,CAAQ;gBAGhB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;IAepE;;;;;;OAMG;IACH,GAAG,CA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,CAAC,GAAG,IAAI,EAAE,GAAG;IAGlB;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG;IAgCnB,aAAa,CAAC,EAAE,EAAE,GAAG;IAGrB;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,IAAI,EAAE,GAAG;IA8CxB,MAAM;CAGP;AAED;;;;GAIG;AAEH,oBAAoB,MAAM,CAAC,MAAM,WAAW,CAAC,GAAG,WAAW,CAAC;AAE5D,OAAO,MAAM,oBAA8B,YAAY,EAAE,qBAcxD,CAAC;AC9eF;;;;;;GAMG;AAEH,yBACE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAsC5B;AC7JD;;;;;;;;;GASG;AACH,qBACE,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GACA;IACE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;CAChD,GACD,GAAQ,oBAgEb;AEgDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,QAAA,MAAM,CAAC,EAAE,GA2TR,CAAC;AAIF,eAAe,CAAC,CAAC","sources":["src/src/sacho/swipe.ts","src/src/scripts/createSignal.ts","src/src/types.ts","src/src/scripts/Router.ts","src/src/scripts/Screen.ts","src/src/scripts/fns.ts","src/src/scripts/track.ts","src/src/scripts/ajax.ts","src/src/scripts/init.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,"/*\n\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\"\n\" ██████╗ ██████╗ █████ ██████╗ ███████╗ ██╗ ██╗ █████ \n\" ██╔════╝ ██╔══██╗ ██╔═╗██ █ ██ ██╔═════╝ ██║ ██║ ██╔═╗██ \n\" ██║ ██████╔╝ ██████╗ █ ██ ██║ ██ ██║ ██║ ██████╗ \n\" ██║ ██╔══██ ██║ ██║ █ ██ ██║ ██ ╚██╗ ██╔╝ ██║ ██ \n\" ╚██████╗ ██║ ██║ ██║ ██║ ███████╔╝ ██████ ╚████╔╝ ██║ ██║\n\" ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚════╝ ╚═══╝ ╚═╝ ╚═╝ \n\" Sacho inside\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\n\" =============================================================================\n\" By Friday Candour\n\" -----------------------------------------------------------------------------\n\" =============================================================================\n\" Cradova FrameWork\n\" @version 1.*.*\n\" -----------------------------------------------------------------------------\n\" License: Apache V2\n\" -----------------------------------------------------------------------------\n\" fridaymaxtour@gmail.com ...\n\" =============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n \n Copyright 2022 Friday Candour. All Rights Reserved.\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n http://www.apache.org/licenses/LICENSE-2.0\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n\n// importing cradova helper scripts\n\nexport { swipe } from \"./sacho/swipe\";\nexport { Signal as createSignal } from \"./scripts/createSignal\";\nexport { Router } from \"./scripts/Router\";\nexport { Screen } from \"./scripts/Screen\";\nexport { dispatch } from \"./scripts/track\";\nexport { Ajax } from \"./scripts/ajax\";\nexport {\n frag,\n fullScreen,\n assert,\n uuid,\n animate,\n controls,\n PromptBeforeLeave,\n RefElement,\n css,\n media,\n ls,\n Ref,\n RefList,\n assertOr,\n} from \"./scripts/fns\";\n\nimport { Init } from \"./scripts/init\";\n\n// importing types declarations\n\nimport { CradovaElementType } from \"./types\";\n\n(\"use strict\");\n\nconst make = function (txx: any) {\n if (Array.isArray(txx)) {\n txx = txx[0].trim();\n }\n\n if (!txx) {\n return {\n tag: \"div\",\n };\n }\n\n let tag;\n const itemsPurifier = (impure: string, pure: string, items: any) => {\n if (!items.includes(pure)) return [];\n const pureItems = [];\n items = items.split(pure);\n for (let i = 0; i < items.length; i++) {\n if (items[i].includes(impure)) {\n items[i] = items[i].split(impure)[0];\n }\n pureItems.push(items[i]);\n }\n return pureItems;\n };\n\n let innerValue;\n if (txx.includes(\"|\")) {\n const tc = txx.split(\"|\");\n innerValue = tc[1];\n txx = tc[0] && tc[0];\n }\n\n const classes = itemsPurifier(\"#\", \".\", txx);\n const ids = itemsPurifier(\".\", \"#\", txx);\n\n if (typeof tag !== \"string\") {\n tag = classes.shift();\n }\n if (typeof tag !== \"string\") {\n tag = ids.shift();\n }\n\n if (!tag) {\n tag = \"div\";\n }\n\n if (!txx.includes(\".\") && !txx.includes(\"#\")) {\n tag = txx;\n ids.length = 0;\n classes.length = 0;\n }\n\n let ID = ids[1] ? ids[1].trim() : null;\n const className = classes.join(\" \");\n return { tag, className, ID, innerValue };\n};\n\n/**\n * Creates new cradova HTML element\n * @example\n * _(\"p\") // or _(\"p.class\") or _(\"p#id\") or _(\"p.class#id\")\n * using inline props\n * _(\"p\",{\n * text: \"am a p tag\",\n * style: {\n * color: \"blue\"\n * }\n * )\n * adding children\n * _(\"p\",\n * _(\"span\",{text:\" am a span tag like so\",\n * {style: {color: \"brown\"}\n * })\n * )\n *\n * props and children\n * _(\"p\",\n * // props first\n * {\n * text: \"am a p tag\",\n * style: {\n * color: \"blue\"\n * },\n * // all children goes after\n * _(\"span\",{text:\" am a span tag like so\",\n * {style: {color: \"brown\"}\n * })\n * )\n *\n * @param {...any} element_initials\n * @returns function - cradova element\n */\n\nconst _: any = (...element_initials: any) => {\n let properties: Record<string, any>,\n childrens: string | any[] = [],\n beforeMount: (self: HTMLElement) => void;\n\n if (\n typeof element_initials[1] == \"object\" &&\n !(\n element_initials[1] instanceof HTMLElement && !element_initials[1].tagName\n )\n ) {\n properties = element_initials[1];\n if (properties?.beforeMount) {\n beforeMount = properties[\"beforeMount\"];\n }\n if (element_initials.length > 2) {\n childrens = element_initials.slice(2, element_initials.length);\n }\n } else {\n if (\n element_initials[1] instanceof HTMLElement ||\n typeof element_initials[1] === \"function\" ||\n typeof element_initials[1] === \"string\"\n ) {\n childrens = element_initials.slice(1, element_initials.length);\n }\n }\n\n if (element_initials[0].raw) {\n // getting the value of static cradova calls\n element_initials[0] = element_initials[0][\"raw\"][0];\n }\n // verifying the children array\n\n function identify(element_initials: any) {\n if (typeof element_initials !== \"object\") {\n element_initials = [element_initials];\n }\n const initials = make(element_initials[0]);\n // TODO: tag debugger\n // const { tag, className, ID, innerValue } = initials;\n\n /**\n *\n * --- Cradova Element Initials ---\n * --------------------------------\n *\n * Note: this element has not been initialized!\n *\n * add to a parent element or call this return function\n *\n * .\n */\n return (...incoming: string[] | any[]) => {\n /*\n *\n * --- Cradova Element Initials ---\n * --------------------------------\n *\n * Note: this element has not been initialized!\n *\n * add to a parent element or call this return function\n *\n * .\n */\n let childrens2rd = [],\n props: Record<string, any> = {},\n text;\n\n for (let i = 0; i < incoming.length; i++) {\n if (\n typeof incoming[i] === \"function\" ||\n incoming[i] instanceof HTMLElement\n // ||\n // incoming[i].tagName\n ) {\n childrens2rd.push(incoming[i]);\n continue;\n }\n\n if (\n // !incoming[i].tagName &&\n !(incoming[i] instanceof HTMLElement) &&\n !Array.isArray(incoming[i]) &&\n typeof incoming[i] === \"object\" &&\n !incoming[i].tagName\n ) {\n if (incoming[i].beforeMount) {\n beforeMount = incoming[i][\"beforeMount\"];\n continue;\n }\n if (incoming[i].composedPath) {\n continue;\n }\n props = incoming[i];\n continue;\n }\n //\n if (typeof incoming[i] === \"string\") {\n text = incoming[i];\n continue;\n }\n }\n\n if (childrens.length) {\n childrens2rd.push(...childrens);\n }\n\n let element: CradovaElementType | undefined;\n\n try {\n element = document.createElement(initials.tag.trim());\n } catch (error) {\n throw new TypeError(\"cradova err invalid tag given \" + initials.tag);\n }\n if (!element) {\n return;\n }\n if (initials.className) {\n element.className = initials.className.trim();\n }\n\n if (initials.ID) {\n element.id = initials.ID.trim();\n }\n if (initials.innerValue) {\n element.append(initials.innerValue);\n }\n\n for (const prop in properties) {\n if (prop === \"style\" && typeof properties[prop] === \"object\") {\n for (const [k, v] of Object.entries(properties[prop])) {\n element.style[k] = v;\n }\n continue;\n }\n\n if (element.style[prop] === \"\" && prop !== \"src\") {\n element.style[prop] = properties[prop];\n continue;\n }\n\n if (prop === \"class\" && typeof properties[prop] === \"string\") {\n const classes = properties[prop].split(\" \");\n for (let i = 0; i < classes.length; i++) {\n if (classes[i]) {\n element.classList.add(classes[i]);\n }\n }\n continue;\n }\n if (prop === \"text\") {\n element.innerText = properties[prop];\n continue;\n }\n try {\n element[prop] = properties[prop];\n } catch (error) {\n console.log(properties);\n throw new Error(\n \"cradova err invalid props \" +\n prop +\n \" for this element type with value \" +\n properties[prop]\n );\n }\n }\n\n //\n // dynamic props\n // over-rides props that appear in the first level\n\n if (props && typeof props === \"object\" && !Array.isArray(props)) {\n for (const prop in props) {\n if (prop === \"style\" && typeof props[prop] === \"object\") {\n for (const [k, v] of Object.entries(props[prop])) {\n element.style[k] = v;\n }\n continue;\n }\n if (element.style[prop] === \"\" && prop !== \"src\") {\n element.style[prop] = props[prop];\n continue;\n }\n if (prop === \"text\" && typeof props[prop] === \"string\") {\n element.innerText = props[prop];\n continue;\n }\n if (prop === \"class\" && typeof props[prop] === \"string\") {\n element.classList.add(props[prop]);\n continue;\n }\n\n if (prop === \"beforeMount\") {\n beforeMount = props[\"beforeMount\"];\n continue;\n }\n\n try {\n element[prop] = props[prop];\n } catch (error) {\n console.error(error);\n }\n }\n }\n // getting children ready\n if (childrens2rd.length) {\n for (let i = 0; i < childrens2rd.length; i++) {\n // single child lane\n if (typeof childrens2rd[i] === \"function\") {\n let child = childrens2rd[i]();\n if (typeof child === \"function\") {\n child = child();\n }\n try {\n if (child) {\n element.append(child);\n }\n if (child && child.afterMount) {\n child.afterMount(child);\n child.afterMount = undefined;\n }\n } catch (error) {\n console.error(error);\n if (!(child instanceof HTMLElement)) {\n throw new Error(\n \" cradova err invalid child type: \" +\n child +\n \" (\" +\n typeof child +\n \")\"\n );\n }\n }\n continue;\n }\n // children array\n if (Array.isArray(childrens2rd[i])) {\n const arrCX: HTMLElement[] | Function[] = childrens2rd[i];\n const arrCXLenght = arrCX.length;\n const arrSET = [];\n for (let p = 0; p < arrCXLenght; p++) {\n if (\n !(arrCX[p] instanceof HTMLElement) &&\n typeof arrCX[p] !== \"function\" &&\n !Array.isArray(arrCX[p])\n ) {\n console.error(arrCX[p]);\n throw new TypeError(\n \"cradova err: invalid tag type or template literal, cradova was enable to create this element show above ⇑\"\n );\n }\n arrSET.push(arrCX[p]);\n }\n //\n childrens2rd = [\n ...childrens2rd.slice(0, i + 1),\n ...arrSET,\n ...childrens2rd.slice(i + 1, childrens2rd.length),\n ];\n continue;\n }\n const child = childrens2rd[i];\n if (\n child instanceof HTMLElement ||\n child instanceof DocumentFragment ||\n typeof child === \"string\"\n ) {\n element.append(child);\n // @ts-ignore\n if (child.afterMount) {\n // @ts-ignore\n child.afterMount(child);\n // @ts-ignore\n child.afterMount = undefined;\n }\n } else {\n console.error(\"cradova got\");\n console.error(child);\n throw new Error(\n \" cradova err invalid child type: \" + \"(\" + typeof child + \")\"\n );\n }\n }\n }\n //\n if (text) {\n element.append(text);\n }\n // TODO: this will be updated to use data-stateid soon\n // speed test still going on\n if (element.stateID) {\n // adding cradova dynamic signature\n element.classList.add(\"cra_child_doc\");\n }\n\n if (beforeMount) {\n beforeMount(element);\n }\n\n return element;\n };\n }\n if (typeof element_initials[0] !== \"string\") {\n console.error(\"cradova err: NO TEMPLATE STRING PROVIDED\");\n return () => \"NO TEMPLATE STRING PROVIDED\";\n }\n const CradovaElement: () => HTMLElement | undefined =\n identify(element_initials);\n if (!CradovaElement) {\n throw new Error(\n \"Cradova err invalid element initials \" + element_initials\n );\n }\n return CradovaElement;\n};\n\nInit();\n\nexport default _;\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../"}
|