vaderjs 1.4.1-lv56aadeg5 → 1.4.2-bml56

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.
@@ -1,4 +0,0 @@
1
- #Binaries
2
-
3
- Folder contains polyfills for missing functionality within windows
4
- Folder contains ssg code for generating html pages for each route on the fly
@@ -1,74 +0,0 @@
1
- /**
2
-
3
- * @file watcher.js
4
-
5
- * @description This file is used as a polyfill for missing functionality of bun.js fs watch on windows
6
-
7
- */
8
-
9
- import { watch } from "fs";
10
-
11
- import IPC from "../binaries/IPC/index.js";
12
-
13
- IPC.NOLISTEN = true;
14
-
15
- const s = await IPC.newServer(IPC.typeEnums.WATCHER, { port: process.env.PORT || 3434 });
16
-
17
- console = s.Console;
18
-
19
- process.cwd = () => {
20
- return process.env.PWD;
21
- };
22
-
23
- let folders = process.env.FOLDERS.split(",");
24
-
25
- let hasSent = false;
26
-
27
- folders.forEach((folder) => {
28
- watch(process.cwd() + "/" + folder, { recursive: true }, (event, filename) => {
29
- switch (event) {
30
- case "change":
31
- if (!hasSent) {
32
- console.log({ type: "change", filename });
33
-
34
- hasSent = true;
35
-
36
- setTimeout(() => {
37
- hasSent = false;
38
- }, 500);
39
- }
40
-
41
- break;
42
-
43
- case "add":
44
- if (!hasSent) {
45
- console.log({ type: "add", filename });
46
-
47
- hasSent = true;
48
-
49
- setTimeout(() => {
50
- hasSent = false;
51
- }, 500);
52
- }
53
-
54
- break;
55
-
56
- case "close":
57
- if (!hasSent) {
58
- console.log({ type: "close", filename });
59
-
60
- hasSent = true;
61
-
62
- setTimeout(() => {
63
- hasSent = false;
64
- }, 500);
65
- }
66
-
67
- break;
68
- }
69
- });
70
- });
71
-
72
- process.on("exit", function (code) {
73
- console.log("About to exit with code:", code);
74
- });
@@ -1,7 +0,0 @@
1
- $chrometest = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
2
-
3
- if($chrometest -eq $true){
4
- Write-Host "Google Chrome is installed"
5
- }else{
6
- Write-Host "Google Chrome is not installed"
7
- }
package/client/index.js DELETED
@@ -1,441 +0,0 @@
1
- /**
2
- * @file Vader.js - A lightweight, modern, and fast front-end framework for building web applications.
3
- * @copyright - Malikwhitten67
4
- * @license MIT
5
- */
6
-
7
-
8
- /**
9
- * @class Component
10
- * @description Base class for all components - functional and class components
11
- * @example
12
- * class App extends Component {
13
- * constructor(props){
14
- * super(props)
15
- * this.state = {
16
- * count: 0
17
- * }
18
- * }
19
- *
20
- * render(){
21
- * return <div>
22
- * <h1>Count is {this.state.count}</h1>
23
- * <button onClick={()=> this.setState({count: this.state.count + 1})}>Click me</button>
24
- * </div>
25
- * }
26
- * }
27
- *
28
- */
29
- export class Component {
30
- /**
31
- * @constructor
32
- * @param {object} props - Component props
33
- * @param {string} props.key - Unique identifier for the component
34
- * @param {object} props.children - Content to be displayed inside the component
35
- */
36
- constructor() {
37
- this.state = {};
38
- this.props = {};
39
- this.key = Math.random();
40
- this.__internalInstance = {};
41
- }
42
-
43
- /**
44
- * @function
45
- * @description This method allows you to update the state of a component
46
- */
47
- render() {}
48
- /**
49
- * @function
50
- * @description This method allows you to update the state of a component
51
- * **/
52
- onMount() {}
53
-
54
- /**
55
- * @function
56
- * @description This method allows you to update the state of a component
57
- * @param {any} initialValue
58
- * @returns {[any, Function]}
59
- */
60
-
61
- useState(initialValue) {
62
- if (!this.state[key]) this.state[key] = initialValue;
63
- let state = this.state[key];
64
- const setState = (newState) => {
65
- state = newState;
66
- this.state[key] = newState;
67
- this.updateInstance(this.__internalInstance);
68
- };
69
- const getUpdatedState = () => {
70
- return this.state[key] || initialValue;
71
- }
72
- state = getUpdatedState();
73
- return [state, setState];
74
-
75
- }
76
-
77
- /**
78
- * @function useRef
79
- * @description This method allows you to create a reference to a DOM element
80
- * @param {string} key
81
- * @param {any} initialValue
82
- * @returns {current: any}
83
- */
84
- useRef(initialValue) {
85
- return {current: initialValue}
86
- }
87
-
88
- /**
89
- * @function useReducer
90
- * @description This method allows you to use a reducer to manage state
91
- * @param {function} reducer
92
- * @param {any} initialState
93
- */
94
- useReducer(reducer, initialState) {
95
- if (!this.state[key]) this.state[key] = initialState;
96
- let state = this.state[key];
97
- const setState = (newState) => {
98
- state = newState;
99
- this.state[key] = newState;
100
- this.updateInstance(this.__internalInstance);
101
- };
102
- const getUpdatedState = () => {
103
- return this.state[key] || initialState;
104
- }
105
- state = getUpdatedState();
106
- return [state, setState];
107
- }
108
-
109
- }
110
-
111
- /**
112
- * @method Mounted
113
- * @description This method allows you to await until the component is mounted before running a callback
114
- *
115
- * @param {function} callback - Function to be called when the component is mounted
116
- * @param {Component} component - Component to be determined mounted
117
- * @param {boolean} runOnlyOnce - Run the callback only once - default: true
118
- */
119
- export const Mounted = (callback, /**@type {Component} */ component, runOnlyOnce = true) => {
120
-
121
- };
122
-
123
-
124
-
125
- /**
126
- * @function fontmatter
127
- * @description This method allows you to get the frontmatter of a markdown file
128
- * @param {string} path - Path to the markdown file
129
- * @returns {{title: string, description: string, content: string}}
130
- */
131
-
132
- export const fontmatter = (path) => {
133
- return {
134
- title: '',
135
- description: '',
136
- content: Object.keys({}).includes('content') ? '' : ''
137
- }
138
-
139
- }
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
- /**
149
- * @class Link
150
- * @description Allows you to seamlessly navigate to different pages in your application
151
- * @extends Component
152
- * @example
153
- * <Link href="/some-path" class="custom-link" style="color: blue;">Click me!</Link>
154
- */
155
- export class Link extends Component {
156
- /**
157
- * @constructor
158
- * @param {object} props - Component props
159
- * @param {string} props.href - URL for the link
160
- * @param {string} props.action - Action to be performed when the link is clicked - can be function or string
161
- * @param {string} [props.class] - CSS class for the link
162
- * @param {string} [props.style] - Inline CSS style for the link
163
- * @param {string} [props.children] - Content to be displayed inside the link
164
- */
165
- constructor(props) {
166
- super(props);
167
- /**
168
- * @type {object}
169
- * @property {string} href - URL for the link
170
- * @property {string} [action] - Action to be performed when the link is clicked
171
- * @property {string} [class] - CSS class for the link
172
- * @property {string} [style] - Inline CSS style for the link
173
- * @property {string} [children] - Content to be displayed inside the link
174
- */
175
- this.props = {
176
- href: props.href,
177
- /**
178
- * @type {string|function}
179
- * @param {string} [action='outside'] - Action to be performed when the link is clicked
180
- */
181
- action: props.action || 'outside',
182
- class: props.class,
183
- style: props.style,
184
- }
185
-
186
- /**
187
- * @type {HTMLAnchorElement}
188
- */
189
- this.link = document.createElement('a');
190
-
191
- /**
192
- * @type {string}
193
- */
194
- this.key = props.href + Math.random();
195
- }
196
-
197
- /**
198
- * @function
199
- * @returns {string} - Rendered HTML for the Link component
200
- */
201
- render() {
202
-
203
- return this.link.outerHTML;
204
- }
205
- }
206
-
207
-
208
-
209
- /**
210
- * @class Image
211
- * @description Image component
212
- * @extends Component
213
- * @example
214
- * <Image src="https://via.placeholder.com/150" alt="image" />
215
- */
216
- export class Image extends Component {
217
- /**
218
- * @constructor
219
- * @param {object} props - Component props
220
- * @param {string} props.src - Image source URL
221
- * @param {string} props.class - CSS class for the image
222
- * @param {string} props.style - Inline CSS style for the image
223
- * @param {number} props.blur - Blur value for the image (optional)
224
- * @param {number} props.width - Width of the image (optional)
225
- * @param {number} props.height - Height of the image (optional)
226
- * @param {boolean} props.optimize - Optimize the image (optional, default: true)
227
- * @param {boolean} props.loader - Show a placeholder loader (optional, default: true)
228
- * @param {string} props.alt - Alt text for the image (optional, default: 'image')
229
- */
230
- constructor(props) {
231
- super(props);
232
-
233
- /**
234
- * @type {object}
235
- * @property {string} src - Image source URL
236
- * @property {string} [class] - CSS class for the image
237
- * @property {string} [style] - Inline CSS style for the image
238
- * @property {number} [blur] - Blur value for the image (optional)
239
- * @property {number} [width] - Width of the image (optional)
240
- * @property {number} [height] - Height of the image (optional)
241
- * @property {boolean} [optimize] - Optimize the image (optional, default: true)
242
- * @property {boolean} [loader] - Show a placeholder loader (optional, default: true)
243
- * @property {string} [alt] - Alt text for the image (optional, default: 'image')
244
- * @property {string} [children] - Content to be displayed inside the image
245
- * @property {string} [key] - Unique identifier for the image
246
- * @property {string} [onLoad] - Function to be called when the image is loaded
247
- */
248
- this.props = {
249
- src: props.src,
250
- class: props.class,
251
- style: props.style,
252
- blur: props.blur,
253
- width: props.width,
254
- height: props.height,
255
- optimize: props.optimize || true,
256
- loader: props.loader || true,
257
- alt: props.alt || 'image',
258
- };
259
-
260
- /**
261
- * @type {string}
262
- */
263
- this.key = props.src + Math.random();
264
-
265
- /**
266
- * @type {HTMLImageElement}
267
- * @private
268
- */
269
- this.img = document.createElement('img');
270
-
271
- /**
272
- * @type {HTMLDivElement}
273
- * @private
274
- */
275
- this.placeholder = document.createElement('div');
276
- }
277
-
278
- /**
279
- * @function
280
- * @returns {string} - Rendered JSX for the Image component
281
- */
282
- render() {
283
- // adjust width and height to the user's screen size
284
-
285
-
286
- return this.img.outerHTML;
287
- }
288
- }
289
-
290
- export class Head extends Component {
291
- /**
292
- * @constructor
293
- * @param {object} props - Component props
294
- * @param {boolean} props.updateOnReload - update metadata and title when rerendered
295
- * @param {string} props.children - Content to be displayed inside the head
296
- */
297
- constructor(props) {
298
- super(props);
299
- /**
300
- * @type {object}
301
- * @param {object} props - Component props
302
- * @param {boolean} props.updateOnReload - update metadata and title when rerendered
303
- * @param {string} props.children - Content to be displayed inside the head
304
- */
305
- this.props = {
306
- children: props.children,
307
- updateOnReload: props.updateOnReload
308
- }
309
- this.key = 'head';
310
- this.head = document.createElement('head');
311
- }
312
-
313
-
314
-
315
- render() {
316
- this.head.innerHTML = this.props.children;
317
- return this.head.outerHTML;
318
- }
319
-
320
- onMount() {
321
- document.head.innerHTML = this.head.innerHTML;
322
- document.body.querySelector(`[key="${this.key}"]`).remove();
323
- }
324
- }
325
-
326
- export class Script extends Component {
327
- /**
328
- * @constructor
329
- * @param {object} props - Component props
330
- * @param {string} props.children - Content to be displayed inside the script
331
- */
332
- constructor(props) {
333
- super(props);
334
- this.props = {
335
- children: props.children,
336
- }
337
- this.key = 'script';
338
- this.script = document.createElement('script');
339
- }
340
-
341
-
342
-
343
- render() {
344
- this.script.innerHTML = this.props.children.split('\n').join(';\n');
345
- return this.script.outerHTML;
346
- }
347
-
348
- onMount() {
349
- document.head.appendChild(this.script);
350
- document.body.querySelector(`[key="${this.key}"]`).remove();
351
- }
352
-
353
- }
354
-
355
- /**
356
- * @class HTML
357
- * @description HTML component
358
- * @extends Component
359
- */
360
- export class Html extends Component {
361
- /**
362
- * @constructor
363
- * @param {object} props - Component props
364
- * @param {string} props.key - Identifier which is used to check if the component has been mounted
365
- * @param {string} props.children - Content to be displayed inside the HTML
366
- * @param {string} props.lang - Language for the HTML
367
- */
368
- constructor(props) {
369
- super(props);
370
- /**
371
- * @type {object}
372
- * @property {string} children - Content to be displayed inside the HTML
373
- * @property {string} lang - Language for the HTML
374
- * @property {object} attributes - Attributes for the HTML
375
- */
376
- this.props = {
377
- children: props.children,
378
- lang: props.lang || 'en',
379
- attributes: props.attributes || {},
380
- }
381
- this.key = props.key || 'html';
382
- this.html = document.createElement('html');
383
- }
384
-
385
- render() {
386
- this.html.innerHTML = this.props.children;
387
- return this.html.outerHTML;
388
- }
389
-
390
- onMount() {
391
- if (window.isServer) {
392
- document.documentElement.innerHTML = this.html.outerHTML;
393
- }
394
- console.log('Document Has Been Mounted')
395
- }
396
-
397
- }
398
- /**
399
- * @function useRef
400
- * @description This method allows you to create a reference to a DOM element
401
- * @param {any} initialValue
402
- * @returns
403
- */
404
- export const useRef = (initialValue) => {
405
- return {
406
- current: initialValue
407
- }
408
- }
409
-
410
- /**
411
- * @function useState
412
- * @description This method allows you to use to bind state to a component and update on changes
413
- * @param {any} initialValue
414
- * @returns {[any, Function]}
415
- */
416
- export const useState = (initialValue) => {
417
- return [initialValue, () => {}]
418
- }
419
- /**
420
- * @function useReducer
421
- * @description This method allows you to use a reducer to manage state
422
- * @param {function} reducer
423
- * @param {any} initialState
424
- * @returns
425
- */
426
-
427
- export const useReducer = (reducer, initialState) => {
428
- return [initialState, () => {}]
429
- }
430
- export default {
431
- Component,
432
- useRef,
433
- useReducer,
434
- useState,
435
- strictMount,
436
- Link,
437
- Image,
438
- Head,
439
- Html,
440
-
441
- }
package/config/index.js DELETED
@@ -1,36 +0,0 @@
1
- /**
2
- * @function defineConfig
3
- * @description Define the configuration for the application
4
- * @param {Object} config
5
- * @param {Object} config.host - Important metadata
6
- * @param {string} config.host.hostname - The hostname for your webapplication
7
- * @param {Object} config.host.prod - Define data for production use
8
- * @param {Number} config.host.prod.port - The production port for your webapp
9
- * @param {('vercel'|'netlify'|'cloudflare')} config.host.provider - Helps vader to generate routes for your webapp
10
- * @param {Object} config.dev - The development server configuration
11
- * @param {Number} config.dev.port - The port to use for the development server
12
- * @param {('localhost')} config.dev.host - The hostname to use for the development server
13
- * @param {Array} config.integrations - Additional integrations to enhance vaderjs
14
- * @param {Function} config.integrations[0] - The integration to use for the application
15
- * @returns {Object} The defined configuration
16
- */
17
- export const defineConfig = (config = {
18
- host: {
19
- provider: '',
20
- hostname:'',
21
- prod:{
22
- port:3000,
23
- }
24
- },
25
- dev: {
26
- port: 3000, // Default port for the development server
27
- host: 'localhost' // Default hostname for the development server
28
- },
29
- integrations: []
30
- }) => {
31
- return config;
32
- };
33
-
34
- export default {
35
- defineConfig
36
- };
package/logo.png DELETED
Binary file
package/runtime/router.js DELETED
@@ -1 +0,0 @@
1
- import t from"./vader.js";let e=[];export default class Router{constructor(t,e){this.routes=[],this.middlewares=[],this.errorMiddlewares=[],this.listeners=[],this.basePath=t}get(t,e){this.routes.push({method:"get",path:t,handler:e})}use(t){this.middlewares.push(t)}matchingRoute(){return routes.find((t=>t.url===window.location.pathname||window.location.pathname.split("/")[1]===t.url.split("/")[1]||void 0))}listen(t,e){t||(t=Math.random().toString(36).substring(7)),this.listeners.push(t),window.onpopstate=async t=>{let e=window.location.pathname;if(e.includes("#noNavigation"))return;let r=`/${e.split("/")[1]}`,n=(new DOMParser).parseFromString(await fetch(r,{cache:"reload"}).then((t=>t.text())),"text/html").documentElement,o=(n.querySelector("head"),n.querySelector("body"));document.querySelector("#app").innerHTML=o.querySelector("#app").innerHTML;let s=document.createElement("script");s.id="router",s.innerHTML=o.querySelector('script[id="router"]').innerHTML,s.setAttribute("type","module"),document.body.removeChild(document.getElementById("router")),document.body.appendChild(s)},window.location.pathname.includes("#noNavigation")||(console.log("no navigation"),this.handleRoute(window.location.pathname)),e&&e()}render(e){document.querySelector("#app").innerHTML="",t.render(e,document.querySelector("#app"))}extractParams(t,e){const r=t.split("/").filter((t=>""!==t)),n=e.split("/").filter((t=>""!==t)),o={};return r.forEach(((t,e)=>{if(t.startsWith(":")){const r=t.slice(1);o[r]=n[e]}else if(t.startsWith("*")){n.slice(e).forEach(((t,e)=>{o[e]=t}))}})),o}extractQueryParams(t){const e=t.split("?")[1];if(!e)return{};const r={};return e.split("&").forEach((t=>{const[e,n]=t.split("=");r[e]=n})),r}checkroute(t){return(t=t.endsWith("/")?t.slice(0,-1):t).includes("index.html")&&(t=t.replace("index.html","")),t.includes("?")&&(t=t.split("?")[0]),this.routes.find((e=>{if(console,e.path===t)return!0;if(""===t&&"/"===e.path)return!0;if(e.path.includes("*")||e.path.includes(":")){const r=e.path.split("/").filter((t=>""!==t)),n=t.split("/").filter((t=>""!==t));if(this.basePath&&n.shift(),console.log(r,n),r.length!==n.length&&!e.path.endsWith("*"))return!1;for(let t=0;t<r.length;t++){const e=r[t],o=n[t];if(!e.startsWith(":")&&!e.startsWith("*")&&e!==o)return!1}return!0}const r=this.extractParams(e.path,t);return Object.keys(r).length>0}))}handleRoute(r){let n=200,o={},s=r,a=this.checkroute(r);a||(n=404,a=this.routes.find((t=>"*"===t.path)),a&&(o=this.extractParams(a.path,r)));const i=this.extractQueryParams(s),l=a&&a.path?this.extractParams(a.path,s):o;Object.keys(l).forEach((t=>{l[t]=l[t].split("?")?l[t].split("?")[0]:l[t]}));const c={headers:{},params:l,query:i,path:r,fileUrl:window.location.href.split(window.location.origin)[1],url:window.location.href,method:a?a.method:"get",pause:!1,timestamp:Date.now()};window.$CURRENT_URL=c.path,window.$basePath=" ",window.$FULL_URL=window.location.href.replace("#","");const h={status:n,log:t=>{void 0===t?console.log(`${c.path} ${c.method} ${h.status} ${c.timestamp}`):console.table({"Request Path":c.path,"Request Method":a.method,"Response Status":h.status,"Request Timestamp":c.timestamp})},refresh:()=>{this.handleRoute(window.location.pathname)},redirect:t=>{!t.startsWith("/")&&(t=`/${t}`),window.history.pushState({},"",t),window.dispatchEvent(new Event("popstate"))},render:async e=>{e?.default&&(e=e.default),document.querySelector("#app").innerHTML="",t.render(e,document.querySelector("#app"),{passProps:{router:{req:c,res:h}}})},setQuery:t=>{if($SERVER)return;let e="";Object.keys(t).forEach(((r,n)=>{e+=`${0===n?"?":"&"}${r}=${t[r]}`}));let r=window.location.pathname.split("?")[0];e=e.replace("/","-").replaceAll("/","-"),c.query={...c.query,...t},window.history.pushState({},"",`${r}${e}`)},getQuery:t=>{let e=window.location.search,r=new URLSearchParams(e);return t?r.get(t.key):r},send:t=>{document.querySelector("#app").innerHTML=t},json:t=>{const e=document.querySelector("#app");e.innerHTML="";const r=document.createElement("pre");r.textContent=JSON.stringify(t,null,2),e.appendChild(r)}};e.forEach((t=>{t(c,h)})),a?h.render(a.handler):h.status(404).send("Not Found")}}
package/runtime/vader.js DELETED
@@ -1 +0,0 @@
1
- let e=[],t={},s={};export const Mounted=(t,s,r=!1)=>{let n=setInterval((()=>{switch(!0){case r&&e.includes(s.key):return clearInterval(n);case r&&!e.includes(s.key):e.push(s.key),t();break;case!document.querySelector(`[key="${s.key}"]`):return;default:t(),clearInterval(n)}}),100)};export class Component{constructor(e){this.state=s[this.constructor.name]||{},this.__internalInstance=null,this.key=e?.key||Math.random(),this.checkMount(),this.mounted=!1,this.props=e,this.useKey=e=>{this.props.key=e,this.key=e}}setState(e){this.state=Object.assign({},this.state,e),this.updateInstance(this.__internalInstance)}useState(e,t){this.state[e]||(this.state[e]=t);let s=this.state[e];const state=()=>this.state[e];return[state,t=>{this.state[e]=t,this.updateInstance(this.__internalInstance),s=state()}]}useRef(e,t){return this.state[e]||(this.state[e]=t),{current:this.state[e]}}onMount(){}domDifference(e,t){let s=[];for(let r=0;r<e.length;r++){let n=e[r],a=t[r];n&&a&&n.childNodes.length>0&&a.childNodes.length>0&&s.push(...this.domDifference(Array.from(n.childNodes),Array.from(a.childNodes))),n.nodeValue!==a.nodeValue&&s.push({type:"replace",old:n,new:a})}return s}checkMount(){if(this.mounted)return;setInterval((()=>{document.querySelector(`[key="${this.key}"]`)&&!this.mounted&&(this.mounted=!0,this.onMount())}))}updateChangedElements(e){e.forEach((e=>{if(e)switch(e.type){case"replace":if(e.old.panrntNode&&"BODY"===e.old.parentNode.nodeName)return;e.old.replaceWith(e.new.cloneNode(!0));break;case"remove":e.old.remove();break;case"attributeSwap":let t=Array.from(e.old.attributes),s=Array.from(e.new.attributes);t.forEach((t=>{e.old.removeAttribute(t.name)})),s.forEach((t=>{e.old.setAttribute(t.name,t.value)}));break;case"add":e.old.appendChild(e.new.cloneNode(!0))}}))}updateInstance(e){let t=document.querySelector(`[key="${this.key}"]`)||document.querySelector("#app").firstChild,s=r.render(e,t,{return:!0}),n=this.domDifference(Array.from(t.childNodes),Array.from(s.childNodes));console.log(n),this.updateChangedElements(n)}parseStyle(e,t,s={useImportant:!1}){let r="",n=document.head.querySelector("#vader-stylesheet")||document.createElement("style");return n.setAttribute("id","vader-stylesheet"),Object.keys(e).forEach((a=>{let i=e[a],o="",l="";switch(!0){case a.includes("hover"):return o=a.split("hover(")[1].replace(/\)/g,""),l=`.${o}:hover{${this.parseStyle(i,t,{useImportant:!0})}};`,n.innerHTML.includes(l)||(n.innerHTML+=l),void t.classList.add(o);case a.includes("transition"):let e=`transition:${i} ${s.useImportant?" !important":""};`;r+=e;break;case a.includes("@mobile"):o=a.split("@mobile")[1].replace(/\(/g,"").replace(/\)/g,""),l=`@media (max-width: 768px){.${o}{${this.parseStyle(i,t,{useImportant:!0})}};}`,document.querySelector("#vader-stylesheet").innerHTML.includes(l)||(document.head.querySelector("#vader-stylesheet").innerHTML+=l),t.classList.add(o);break;case a.includes("@tablet"):o=a.split("@tablet")[1].replace(/\(/g,"").replace(/\)/g,""),l=`@media (min-width: 769px) and (max-width: 1024px){.${o}{${this.parseStyle(i,t,{useImportant:!0})}};}`,document.querySelector("#vader-stylesheet").innerHTML.includes(l)||(document.head.querySelector("#vader-stylesheet").innerHTML+=l),t.classList.add(o);break;case a.includes("@desktop"):o=a.split("@desktop")[1].replace(/\(/g,"").replace(/\)/g,""),l=`@media (min-width: 1025px){.${o}{${this.parseStyle(i,t,{useImportant:!0})}};}`,document.querySelector("#vader-stylesheet").innerHTML.includes(l)||(document.head.querySelector("#vader-stylesheet").innerHTML+=l),t.classList.add(o);break;case a.includes("transform"):let c=`transform:${i} ${s.useImportant?" !important":""};`;r+=c;break;case a.includes("animation"):r+=`animation:${i};`;break;case a.includes("active"):o=a.split("active(")[1].replace(/\)/g,""),l=`.${o}:active{${this.parseStyle(i,t,{useImportant:!0})}};`,n.innerHTML.includes(l)||(n.innerHTML+=l),t.classList.add(o);break;case a.includes("body"):let d=`body{${this.parseStyle(i,t)}};`;return void(document.head.querySelector("#vader-stylesheet").innerHTML.includes(`body{${this.parseStyle(i,t)}};`)||(document.head.querySelector("#vader-stylesheet").innerHTML+=d));case a.includes("focus"):o=a.split("focus(")[1].replace(/\)/g,"");let p=`.${o}:focus{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(p)||(n.innerHTML+=p),t.classList.add(o);break;case a.includes("before"):o=a.split("before(")[1].replace(/\)/g,"");let h=`.${o}::before{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(h)||(n.innerHTML+=h),t.classList.add(o);break;case a.includes("after"):o=a.split("after(")[1].replace(/\)/g,"");let u=`.${o}::after{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(u)||(n.innerHTML+=u),t.classList.add(o);break;case a.includes("placeholder"):o=a.split("placeholder(")[1].replace(/\)/g,"");let y=`.${o}::placeholder{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(y)||(n.innerHTML+=y),t.classList.add(o);break;case a.includes("first-child"):o=a.split("first-child(")[1].replace(/\)/g,"");let m=`.${o}:first-child{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(m)||(n.innerHTML+=m),t.classList.add(o);break;case a.includes("last-child"):o=a.split("last-child(")[1].replace(/\)/g,"");let f=`.${o}:last-child{${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(f)||(n.innerHTML+=f),t.classList.add(o);break;case a.includes("nth-child"):o=a.split("nth-child(")[1].replace(/\)/g,"").split("(")[0];let k=`.${o}:nth-child(${a.split("nth-child(")[1].replace(/\)/g,"").split("(")[1]}){${this.parseStyle(i,t,{useImportant:!0,noReturn:!0})}};`;n.innerHTML.includes(k)||(n.innerHTML+=k),t.classList.add(o);break;case a.includes(">"):let b=`${a}{${this.parseStyle(i,t)}};`;n.innerHTML.includes(b)||(n.innerHTML+=b),t.classList.add(o)}a=a.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),r+=`${a}:${i} ${s.useImportant?" !important":""};`})),document.head.querySelector("#vader-stylesheet")||document.head.appendChild(n),r}}export const useState=e=>{this.state[key]||(this.state[key]=e);let t=this.state[key];const getUpdatedState=()=>this.state[key]||e;return t=getUpdatedState(),[getUpdatedState,e=>{t=e,this.state[key]=e,this.updateInstance(this.__internalInstance)}]};export const useReducer=(e,t)=>{const[s,r]=useState(t);return[s,t=>{const n=e(s,t);r(n)}]};export const useRef=e=>{this.state[key]||(this.state[key]=e);let t=this.state[key];return t=(()=>this.state[key]||e)(),[t,e=>{t=e,this.state[key]=e,this.updateInstance(this.__internalInstance)}]};export class Html extends Component{constructor(e){super(e),this.key=e?.key||"DOCUMENT_ROOT",this.props=e,this.checkMount()}render(){return $SERVER?(this.props.lang&&document.documentElement.setAttribute("lang",this.props.lang),r.createElement("div",{children:this.props.children,key:this.key})):r.createElement("div",{children:this.props.children,key:this.key})}onMount(){this.props?.parent&&this.props?.parent&&this.props.parent.onMount()}}export class Head extends Component{constructor(e){super(e),this.head=document.createElement("div"),this.useKey("head"),this.hasRefreshed=!1}render(){if($SERVER||this.props.refresh&&!t[this.key]){Array.isArray(this.props.children)&&this.props.children.forEach((e=>{let s=r.render(e,this.head,{return:!0}),n=this.head.querySelectorAll("*");for(let e=0;e<n.length;e++)n[e].isEqualNode(s)&&console.log("Equal");console.log(this.key,"key"),this.head.appendChild(s),t[this.key]=!0})),Object.keys(this.props).includes("children")&&!Array.isArray(this.props.children)&&this.head.appendChild(r.render(this.props.children,this.head,{return:!0}));let e=document.head;this.head.querySelectorAll("*").forEach((t=>{switch(t.tagName){case"TITLE":e.querySelector("title")&&e.querySelector("title").remove(),e.appendChild(t);break;case"META":return void(e.querySelector(`meta[name="${t.name}"]`)||e.appendChild(t));case"LINK":if($SERVER)return console.log("Server"),void(e.querySelector(`link[href="${t.href}"]`)||e.appendChild(t));case"SCRIPT":if(!t.hasAttribute("eager"))return void(document.querySelector(`script[src="${t.src}"]`)||e.appendChild(t));if(document.querySelector(`script[srcid="${t.src}"]`))return;fetch(t.src).then((e=>e.text())).then((s=>{let r=document.createElement("script");r.innerHTML=s,r.setAttribute("srcid",t.src),r.setAttribute("type",t.type),r.setAttribute("async",t.async||!1),r.setAttribute("defer",t.defer||!1),e.querySelector(`script[srcid="${t.src}"]`)||e.prepend(r)})).catch((e=>{console.warn("Error fetching script",e)}));break;default:console.warn("Unknown tag",t.tagName)}}))}return""}}export class Link extends Component{constructor(e){super(e),this.key=e?.key||Math.random(),this.props=e,this.checkMount()}render(){let e={...this.props,href:this.props?.href,onClick:e=>{switch(e.preventDefault(),!0){case"outside"===this.props.action:console.log("Outside"),e.preventDefault(),window.open(this.props.href,"_blank");break;case"function"==typeof this.props.action:this.props.action(e);break;default:e.preventDefault(),window.history.pushState({},"",this.props.href),window.dispatchEvent(new Event("popstate"))}},key:this.key};return r.createElement("a",e,this.props?.key,null)}}let r=new class vjsx{constructor(){this._vjsx=!0}isClass(e){return/^\s*class\s+/.test(e.toString())}instanizeClass(e,t={}){if("string"==typeof e||"object"==typeof e)return e;switch(this.isClass(e)){case!0:let r=new e(t);return s[e.name]=r.state,r.state=s[e.name],r.$$typeof="vjsx",r.type=e.name,r.key=t?.key||r.name,r.props=t,r.__internalInstance=()=>r.render(r.props),r.render();case!1:let n=new Component;n.key=e.name+Math.random(),e.$$typeof="vjsx",e.useState=n.useState.bind(n),e.setState=n.setState.bind(n),s[e.name]=n.state,n.state=s[e.name],e.state=n.state;let a={},i={};return t?.router&&(a=t.router.req,i=t.router.res),n.__internalInstance=()=>e.bind(n)(t,a,i),e.apply?e.apply(n,[t,a,i]):e}}createElement(e,t,s,...r){let n="function"==typeof e,a=r.find((e=>"vjsx"===e?.$$typeof));if(n)return t.key=s||t?.key||Math.random(),t.parent=a,this.instanizeClass(e,t);let i={type:e,RootParent:a,props:{...t,key:t?.key||Math.random(),children:Array.isArray(t.children)?t.children:[t.children]}};return"TEXT_ELEMENT"===("string"==typeof i?"TEXT_ELEMENT":i.type)?function createTextElement(e){return{type:"TEXT_ELEMENT",props:{nodeValue:e,children:[]}}}(i):i}render(e,t,s){let r=this.instanizeClass(e,s?.passProps);if(s&&s?.passProps&&s?.passProps?.router){let e=s.passProps.router.req;s.passProps.router.res;e.pause}if(!r.type)return;let n="TEXT_ELEMENT"===r.type?document.createTextNode(""):document.createElement(r.type),isListener=e=>e.startsWith("on");if(r.props&&(r.props.key&&(r.key=r.props.key),Object.keys(r.props).filter(isListener).forEach((e=>{let t=e.toLowerCase().substring(2);n.addEventListener(t,r.props[e].bind(r))})),Object.keys(r.props).filter((e=>!isListener(e))).forEach((e=>{switch(!0){case"className"===e||"class"===e||"classname"===e:n.setAttribute("class",r.props[e]),delete r.props[e];break;case"ref"===e:if(Array.isArray(r.props[e].current))return void r.props[e].current.push(n);r.props[e].current=n,n.removeAttribute("ref");break;case"htmlFor"===e:n.setAttribute("for",r.props[e]);break;case"style"===e:n.setAttribute("style",Component.prototype.parseStyle(r.props[e],n));break;default:"children"!==e&&n.setAttribute(e,r.props[e])}"TEXT_ELEMENT"!==r.type||(n.nodeValue=r.props[e])}))),r.props&&r.props.children&&Array.isArray(r.props.children)&&r.props?.children&&r.props.children.forEach((e=>{if("number"!=typeof e&&"string"!=typeof e||(e=e.toString()),Array.isArray(e))return void e.forEach((e=>{null!==e&&this.render(e,n,!0)}));if(!e)return;let t="function"==typeof e?this.instanizeClass(e):e;"TEXT_ELEMENT"!==(t?.type?t.type:"TEXT_ELEMENT")?this.render(t,n):n.appendChild(document.createTextNode(t))})),s?.return)return n;r.key&&n.setAttribute("key",r.key),!s?.return&&document.body.contains(t)&&(r?.RootParent?.onMount(),t.innerHTML=""),t.appendChild(n)}},n={createElement:r.createElement,useState:useState,instanizeClass:r.instanizeClass,render:r.render,useRef:useRef,isClass:r.isClass,Head:Head,Html:Html,Mounted:Mounted,Component:Component,Link:Link};export default n;