vaderjs 1.4.1-lv56aadeg5 → 1.4.2
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/.editorconfig +11 -0
- package/.vscode/c_cpp_properties.json +21 -0
- package/.vscode/settings.json +12 -0
- package/README.md +35 -198
- package/binaries/Kalix/index.js +665 -0
- package/binaries/compiler/main.js +461 -0
- package/binaries/vader.js +74 -0
- package/binaries/watcher/hmr.js +36 -0
- package/client/index.d.ts +226 -0
- package/client/runtime/index.js +417 -0
- package/client/runtime/router.js +235 -0
- package/config/index.ts +68 -0
- package/index.ts +344 -0
- package/package.json +14 -25
- package/plugins/cloudflare/functions/index.js +98 -0
- package/plugins/cloudflare/toCopy/@server/Kalix/index.js +625 -0
- package/plugins/cloudflare/toCopy/@server/cloudflare_ssr/index.js +85 -0
- package/plugins/cloudflare/toCopy/node_modules/vaderjs/server/index.js +99 -0
- package/plugins/cloudflare/toCopy/src/client.js +432 -0
- package/plugins/cloudflare/toCopy/src/router.js +235 -0
- package/plugins/ssg/index.js +124 -0
- package/plugins/vercel/functions/index.ts +8 -0
- package/router/index.ts +181 -0
- package/server/index.js +129 -0
- package/vader.js +59 -112
- package/@integrations/ssg.js +0 -163
- package/LICENSE +0 -21
- package/binaries/IPC/index.js +0 -277
- package/binaries/main.js +0 -1328
- package/binaries/readme.md +0 -4
- package/binaries/watcher.js +0 -74
- package/binaries/win32/check.ps1 +0 -7
- package/client/index.js +0 -441
- package/config/index.js +0 -36
- package/logo.png +0 -0
- package/runtime/router.js +0 -1
- package/runtime/vader.js +0 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview - A simple router for vaderjs - Kuai
|
|
3
|
+
* @version - 1.0.0
|
|
4
|
+
*/
|
|
5
|
+
export class Kuai{
|
|
6
|
+
constructor(config = { container: '#app'}){
|
|
7
|
+
this.routes = [];
|
|
8
|
+
this.middleware = [];
|
|
9
|
+
this.container = config.container ? config.container : document.getElementById('app');
|
|
10
|
+
this.renderPlugins = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
res = {
|
|
14
|
+
/**
|
|
15
|
+
* @description render text to the container
|
|
16
|
+
* @param {string} data
|
|
17
|
+
*/
|
|
18
|
+
text: (data) => {
|
|
19
|
+
this.container.innerHTML = data;
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* @method html
|
|
23
|
+
* @description render html to the container
|
|
24
|
+
* @param {any} data
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
html: (data) => {
|
|
28
|
+
switch(typeof data){
|
|
29
|
+
case 'function':
|
|
30
|
+
if(this.renderPlugins.length > 0){
|
|
31
|
+
this.renderPlugins.forEach((plugin) => {
|
|
32
|
+
if(plugin.for === 'html'){
|
|
33
|
+
console.log('Plugin', plugin)
|
|
34
|
+
plugin.plugin(data, this.container)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.container.innerHTML = data();
|
|
40
|
+
break;
|
|
41
|
+
case 'string':
|
|
42
|
+
this.container.innerHTML = data;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* @method json
|
|
49
|
+
* @description render json to the container
|
|
50
|
+
* @param {Object} data
|
|
51
|
+
*/
|
|
52
|
+
json: (data) => {
|
|
53
|
+
this.container.innerHTML = `<Oject data=${JSON.stringify(data)}></Object>`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
req = {
|
|
57
|
+
/**
|
|
58
|
+
* @method navigate
|
|
59
|
+
* @description - navigate to a new route
|
|
60
|
+
* @param {string} path
|
|
61
|
+
*/
|
|
62
|
+
navigate: (path) => {
|
|
63
|
+
window.history.pushState({}, '', path);
|
|
64
|
+
let currentPath = this.match(window.location.pathname.replace('/index.html', ''))
|
|
65
|
+
if(currentPath){
|
|
66
|
+
this.currentRoute = currentPath.path
|
|
67
|
+
currentPath.callback(this.res, currentPath.params, this.extractQueryParams(window.location.search));
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* @method back
|
|
72
|
+
* @description - go back to the previous route
|
|
73
|
+
*/
|
|
74
|
+
back: () => {
|
|
75
|
+
window.history.back();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @method forward
|
|
80
|
+
* @description - go forward to the next route
|
|
81
|
+
* @returns {void}
|
|
82
|
+
* **/
|
|
83
|
+
forward: () => {
|
|
84
|
+
window.history.forward();
|
|
85
|
+
},
|
|
86
|
+
url: window.location
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
extractQueryParams(path){
|
|
92
|
+
let params = new URLSearchParams(path);
|
|
93
|
+
let query = {};
|
|
94
|
+
for(let param of params){
|
|
95
|
+
query[param[0]] = param[1];
|
|
96
|
+
}
|
|
97
|
+
return query;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
extractParams(routePath, currentPath){
|
|
103
|
+
const routeParts = routePath.split('/').filter((part) => part !== '');
|
|
104
|
+
const hashParts = currentPath.split('/').filter((part) => part !== '');
|
|
105
|
+
const params = {};
|
|
106
|
+
routeParts.forEach((part, index) => {
|
|
107
|
+
if (part.startsWith(':')) {
|
|
108
|
+
const paramName = part.slice(1);
|
|
109
|
+
params[paramName] = hashParts[index];
|
|
110
|
+
}else if(part.startsWith('*')){
|
|
111
|
+
let array = hashParts.slice(index)
|
|
112
|
+
array.forEach((i, index)=>{
|
|
113
|
+
params[index] = i
|
|
114
|
+
})
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
return params;
|
|
118
|
+
}
|
|
119
|
+
use(path, middleware){
|
|
120
|
+
this.middleware.push({path, middleware});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @method usePlugin
|
|
124
|
+
* @description - add a plugin to handle how the route should be rendered
|
|
125
|
+
* @param {Function} plugin
|
|
126
|
+
* @param {('html')} method
|
|
127
|
+
*/
|
|
128
|
+
usePlugin(plugin, method){
|
|
129
|
+
this.renderPlugins.push({plugin, for: method})
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @method match
|
|
133
|
+
* @description - match a route to the current path and return the route object
|
|
134
|
+
* @param {string} route
|
|
135
|
+
* @returns {Object} - {path: string, callback: Function, params: Object}
|
|
136
|
+
*/
|
|
137
|
+
match(hash){
|
|
138
|
+
hash = hash.endsWith('/') ? hash.slice(0, -1) : hash;
|
|
139
|
+
hash.includes('index.html') ? hash = hash.replace('index.html', '') : null;
|
|
140
|
+
if(hash.includes('?')){
|
|
141
|
+
hash = hash.split('?')[0]
|
|
142
|
+
}
|
|
143
|
+
let route = this.routes.find((route) => {
|
|
144
|
+
if (route.path === hash) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if(hash === '' && route.path === '/'){
|
|
149
|
+
return true
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if (route.path.includes('*') || route.path.includes(':')) {
|
|
154
|
+
const routeParts = route.path.split('/').filter((part) => part !== '');
|
|
155
|
+
const hashParts = hash.split('/').filter((part) => part !== '');
|
|
156
|
+
if(this.basePath){
|
|
157
|
+
hashParts.shift();
|
|
158
|
+
}
|
|
159
|
+
if (routeParts.length !== hashParts.length && !route.path.endsWith('*')) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for (let index = 0; index < routeParts.length; index++) {
|
|
164
|
+
const routePart = routeParts[index];
|
|
165
|
+
const hashPart = hashParts[index];
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if (routePart.startsWith(':') || routePart.startsWith('*')) {
|
|
169
|
+
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (routePart !== hashPart) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
});
|
|
183
|
+
if(route){
|
|
184
|
+
let params = this.extractParams(route.path, hash)
|
|
185
|
+
return { ...route, params}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @description - create a new route
|
|
193
|
+
* @param {string} path
|
|
194
|
+
* @param {Function} callback
|
|
195
|
+
*/
|
|
196
|
+
get(path, callback){
|
|
197
|
+
this.routes.push({path, callback});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @method listen
|
|
202
|
+
* @description - listen for route changes
|
|
203
|
+
*/
|
|
204
|
+
listen(){
|
|
205
|
+
let currentPath = this.match(window.location.pathname.replace('/index.html', ''))
|
|
206
|
+
if(currentPath){
|
|
207
|
+
this.middleware.forEach((middleware) => {
|
|
208
|
+
if(middleware.path === currentPath.path){
|
|
209
|
+
middleware.middleware();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
this.currentRoute = currentPath.path
|
|
213
|
+
let obj = {
|
|
214
|
+
...this.res,
|
|
215
|
+
res: this.res,
|
|
216
|
+
req:{
|
|
217
|
+
...this.req,
|
|
218
|
+
params: (param) => currentPath.params[param]
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
currentPath.callback(obj);
|
|
223
|
+
}
|
|
224
|
+
window.onpopstate = () => {
|
|
225
|
+
let currentPath = this.match(window.location.pathname.replace('/index.html', ''))
|
|
226
|
+
if(currentPath){
|
|
227
|
+
this.currentRoute = currentPath.path
|
|
228
|
+
currentPath.callback(this.res, currentPath.params, this.extractQueryParams(window.location.search));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export default Kuai;
|
package/config/index.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Instruct the compiler to use the provided configuration
|
|
3
|
+
* @typedef {Object} Config
|
|
4
|
+
* @property {string} target - The target environment
|
|
5
|
+
* @property {Object} host - The host object
|
|
6
|
+
* @property {string} host.hostname - The hostname of the application
|
|
7
|
+
* @property {string} host.provider - The provider of the application
|
|
8
|
+
* @property {Object} compilerOptions - The compiler options
|
|
9
|
+
* @property {string} compilerOptions.outDir - The output directory
|
|
10
|
+
* @property {string} compilerOptions.target - The target of the compiler
|
|
11
|
+
* @property {any[]} plugins - The plugins to be used in the application
|
|
12
|
+
* @property {string} mode - The mode of the application
|
|
13
|
+
* @param config - The configuration object
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Defines the configuration options for VaderJS.
|
|
18
|
+
* @param {Object} config - The configuration object.
|
|
19
|
+
* @param {string} config.target - The target platform for the code ('web' or 'bun').
|
|
20
|
+
* @param {Object} [config.host] - The host configuration.
|
|
21
|
+
* @param {string} [config.host.hostname] - The hostname for the host.
|
|
22
|
+
* @param {('vercel','netlify')} [config.host.provider] - The provider for the host ('vercel', 'netlify', 'aws', 'azure', 'gcp').
|
|
23
|
+
* @param {number} [config.host.port] - The port number for the host.
|
|
24
|
+
* @param {Object} [config.compilerOptions] - The compiler options.
|
|
25
|
+
* @param {string} [config.compilerOptions.outDir] - The output directory for the compiled code.
|
|
26
|
+
* @param {string} [config.mode] - The mode for the configuration.
|
|
27
|
+
* @param {Array} [config.plugins] - The plugins for the configuration.
|
|
28
|
+
* @param {Object} [config.env] - The environment variables for the configuration.
|
|
29
|
+
* @returns {Object} The configured object.
|
|
30
|
+
*/
|
|
31
|
+
export const defineConfig = (config: {
|
|
32
|
+
/**
|
|
33
|
+
* @type {string}
|
|
34
|
+
* @param {('web'|'bun')} target
|
|
35
|
+
*/
|
|
36
|
+
target:string,
|
|
37
|
+
host?: {
|
|
38
|
+
hostname?: string,
|
|
39
|
+
/**
|
|
40
|
+
* @param {('vercel', 'netlify', 'aws', 'azure', 'gcp')} provider
|
|
41
|
+
*/
|
|
42
|
+
provider?: string,
|
|
43
|
+
port?: number
|
|
44
|
+
},
|
|
45
|
+
compilerOptions?: {
|
|
46
|
+
outDir?: string,
|
|
47
|
+
},
|
|
48
|
+
mode?: string,
|
|
49
|
+
plugins?: any[]
|
|
50
|
+
env?: {
|
|
51
|
+
[key: string]: any
|
|
52
|
+
}
|
|
53
|
+
}) => {
|
|
54
|
+
// add config.env to globalThis.env
|
|
55
|
+
let env = {}
|
|
56
|
+
if(config.env){
|
|
57
|
+
for(let key in config.env){
|
|
58
|
+
env[key] = config.env[key]
|
|
59
|
+
}
|
|
60
|
+
for(let key in globalThis.env){
|
|
61
|
+
env[key] = globalThis.env[key]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//@ts-ignore
|
|
66
|
+
globalThis.env = env
|
|
67
|
+
return config
|
|
68
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
import {Element} from 'vaderjs/binaries/Kalix'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
export const Vader = {
|
|
5
|
+
version: "0.0.1",
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
/**
|
|
10
|
+
* @type {boolean}
|
|
11
|
+
* @description A boolean value that returns true if the current environment is a server
|
|
12
|
+
*/
|
|
13
|
+
const isServer: boolean;
|
|
14
|
+
var location: {
|
|
15
|
+
href: string,
|
|
16
|
+
pathname: string,
|
|
17
|
+
search: string,
|
|
18
|
+
hash: string,
|
|
19
|
+
host: string,
|
|
20
|
+
hostname: string,
|
|
21
|
+
port: string,
|
|
22
|
+
protocol: string,
|
|
23
|
+
origin: string,
|
|
24
|
+
reload: () => void,
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @description The env object - refers to the env variable either set in config or through the process.env
|
|
28
|
+
* @type {Object} [env]
|
|
29
|
+
*/
|
|
30
|
+
var env:{
|
|
31
|
+
[key: string]: any
|
|
32
|
+
}
|
|
33
|
+
var history: {
|
|
34
|
+
pushState: (state: any, title: string, url: string) => void,
|
|
35
|
+
replaceState: (state: any, title: string, url: string) => void,
|
|
36
|
+
go: (delta: number) => void,
|
|
37
|
+
back: () => void,
|
|
38
|
+
forward: () => void,
|
|
39
|
+
}
|
|
40
|
+
var localStorage: {
|
|
41
|
+
getItem: (key: string) => string,
|
|
42
|
+
setItem: (key: string, value: string) => void,
|
|
43
|
+
removeItem: (key: string) => void,
|
|
44
|
+
clear: () => void,
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @description The window object - used to manipulate the browser window
|
|
48
|
+
* @property {string} location.href - The URL of the current page
|
|
49
|
+
* @property {string} location.pathname - The path of the current page
|
|
50
|
+
* @property {string} location.search - The query string of the current page
|
|
51
|
+
* @property {string} location.hash - The hash of the current page
|
|
52
|
+
* @property {string} location.host - The host of the current page
|
|
53
|
+
* @property {string} location.hostname - The hostname of the current page
|
|
54
|
+
* @property {string} location.port - The port of the current page
|
|
55
|
+
* @property {string} location.protocol - The protocol of the current page
|
|
56
|
+
* @property {string} location.origin - The origin of the current page
|
|
57
|
+
* @property {Function} location.reload - Reloads the current page
|
|
58
|
+
* @property {Object} history - The history object
|
|
59
|
+
* @property {Function} history.pushState - Pushes a new state to the history object
|
|
60
|
+
*/
|
|
61
|
+
var window: {
|
|
62
|
+
location: {
|
|
63
|
+
href: string,
|
|
64
|
+
/**
|
|
65
|
+
* @property {string} location.pathname - The path of the current page
|
|
66
|
+
*/
|
|
67
|
+
pathname: string,
|
|
68
|
+
search: string,
|
|
69
|
+
hash: string,
|
|
70
|
+
host: string,
|
|
71
|
+
hostname: string,
|
|
72
|
+
port: string,
|
|
73
|
+
protocol: string,
|
|
74
|
+
origin: string,
|
|
75
|
+
reload: () => void,
|
|
76
|
+
},
|
|
77
|
+
history: {
|
|
78
|
+
pushState: (state: any, title: string, url: string) => void,
|
|
79
|
+
replaceState: (state: any, title: string, url: string) => void,
|
|
80
|
+
go: (delta: number) => void,
|
|
81
|
+
back: () => void,
|
|
82
|
+
forward: () => void,
|
|
83
|
+
},
|
|
84
|
+
localStorage: {
|
|
85
|
+
getItem: (key: string) => string,
|
|
86
|
+
setItem: (key: string, value: string) => void,
|
|
87
|
+
removeItem: (key: string) => void,
|
|
88
|
+
clear: () => void,
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
};
|
|
92
|
+
var preRender: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @type {Object}
|
|
95
|
+
* @description The file object
|
|
96
|
+
* @property {string} name - The name of the file
|
|
97
|
+
* @property {string} filetype - The type of the file
|
|
98
|
+
* @property {string} dataUrl - The data url of the file
|
|
99
|
+
* @property {string} text - The text content of the file
|
|
100
|
+
* @property {string} fileUrl - The file url
|
|
101
|
+
* @property {number} filesize - The file size
|
|
102
|
+
* @property {Blob} blob - The file blob
|
|
103
|
+
* @property {number} lastModified - The last modified date
|
|
104
|
+
* @property {string} mimetype - The file mimetype
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
const requirePath: (path: string) => any;
|
|
108
|
+
|
|
109
|
+
const useFile: (file: string) => {
|
|
110
|
+
name: string,
|
|
111
|
+
type: string,
|
|
112
|
+
lastModified:{
|
|
113
|
+
date: string,
|
|
114
|
+
time: string,
|
|
115
|
+
parsed: string,
|
|
116
|
+
},
|
|
117
|
+
size: number,
|
|
118
|
+
fileContent: string,
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @description HTMLTextNode is a global interface that represents a text node
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
interface HTMLTextNode{
|
|
125
|
+
nodeType: number,
|
|
126
|
+
textContent: string,
|
|
127
|
+
toString: () => string,
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @description HTMLElement is a global interface that represents an HTML element
|
|
131
|
+
*/
|
|
132
|
+
interface HTMLElement{
|
|
133
|
+
tagName: string,
|
|
134
|
+
id: string,
|
|
135
|
+
nodeType: number,
|
|
136
|
+
classList:{
|
|
137
|
+
add: (className: string) => void,
|
|
138
|
+
remove: (className: string) => void,
|
|
139
|
+
toggle: (className: string) => void,
|
|
140
|
+
contains: (className: string) => boolean,
|
|
141
|
+
}
|
|
142
|
+
props: {
|
|
143
|
+
[key: string]: string,
|
|
144
|
+
}
|
|
145
|
+
children: HTMLElement[],
|
|
146
|
+
outerHTML: string,
|
|
147
|
+
innerHTML: string,
|
|
148
|
+
textContent: string,
|
|
149
|
+
firstChild: HTMLElement | HTMLTextNode | null,
|
|
150
|
+
style?: {
|
|
151
|
+
|
|
152
|
+
display: string,
|
|
153
|
+
position: string,
|
|
154
|
+
top: string,
|
|
155
|
+
left: string,
|
|
156
|
+
right: string,
|
|
157
|
+
bottom: string,
|
|
158
|
+
width: string,
|
|
159
|
+
height: string,
|
|
160
|
+
maxWidth: string,
|
|
161
|
+
maxHeight: string,
|
|
162
|
+
minWidth: string,
|
|
163
|
+
minHeight: string,
|
|
164
|
+
margin: string,
|
|
165
|
+
marginTop: string,
|
|
166
|
+
marginRight: string,
|
|
167
|
+
marginBottom: string,
|
|
168
|
+
marginLeft: string,
|
|
169
|
+
padding: string,
|
|
170
|
+
paddingTop: string,
|
|
171
|
+
paddingRight: string,
|
|
172
|
+
paddingBottom: string,
|
|
173
|
+
paddingLeft: string,
|
|
174
|
+
overflow: string,
|
|
175
|
+
zIndex: string,
|
|
176
|
+
cursor: string,
|
|
177
|
+
textAlign: string,
|
|
178
|
+
fontSize: string,
|
|
179
|
+
fontWeight: string,
|
|
180
|
+
fontStyle: string,
|
|
181
|
+
textDecoration: string,
|
|
182
|
+
lineHeight: string,
|
|
183
|
+
letterSpacing: string,
|
|
184
|
+
textTransform: string,
|
|
185
|
+
backgroundColor: string,
|
|
186
|
+
backgroundImage: string,
|
|
187
|
+
backgroundSize: string,
|
|
188
|
+
backgroundPosition: string,
|
|
189
|
+
backgroundRepeat: string,
|
|
190
|
+
backgroundAttachment: string,
|
|
191
|
+
backgroundClip: string,
|
|
192
|
+
backgroundOrigin: string,
|
|
193
|
+
backgroundBlendMode: string,
|
|
194
|
+
boxShadow: string,
|
|
195
|
+
transition: string,
|
|
196
|
+
transform: string,
|
|
197
|
+
transformOrigin: string,
|
|
198
|
+
transformStyle: string,
|
|
199
|
+
perspective: string,
|
|
200
|
+
perspectiveOrigin: string,
|
|
201
|
+
backfaceVisibility: string,
|
|
202
|
+
filter: string,
|
|
203
|
+
backdropFilter: string,
|
|
204
|
+
mixBlendMode: string,
|
|
205
|
+
border: string,
|
|
206
|
+
borderTop: string,
|
|
207
|
+
borderRight: string,
|
|
208
|
+
borderBottom: string,
|
|
209
|
+
borderLeft: string,
|
|
210
|
+
borderStyle: string,
|
|
211
|
+
borderTopStyle: string,
|
|
212
|
+
borderRightStyle: string,
|
|
213
|
+
borderBottomStyle: string,
|
|
214
|
+
borderLeftStyle: string,
|
|
215
|
+
borderColor: string,
|
|
216
|
+
borderTopColor: string,
|
|
217
|
+
borderRightColor: string,
|
|
218
|
+
borderBottomColor: string,
|
|
219
|
+
borderLeftColor: string,
|
|
220
|
+
borderRadius: string,
|
|
221
|
+
borderTopLeftRadius: string,
|
|
222
|
+
borderTopRightRadius: string,
|
|
223
|
+
borderBottomRightRadius: string,
|
|
224
|
+
borderBottomLeftRadius: string,
|
|
225
|
+
borderWidth: string,
|
|
226
|
+
borderTopWidth: string,
|
|
227
|
+
borderRightWidth: string,
|
|
228
|
+
borderBottomWidth: string,
|
|
229
|
+
borderLeftWidth: string,
|
|
230
|
+
|
|
231
|
+
[key: string]: string,
|
|
232
|
+
}
|
|
233
|
+
attributes: {
|
|
234
|
+
[key: string]: string,
|
|
235
|
+
},
|
|
236
|
+
events: [],
|
|
237
|
+
toString: () => string,
|
|
238
|
+
getAttribute: (attr: string) => string | null,
|
|
239
|
+
setAttribute: (attr: string, value: string) => void,
|
|
240
|
+
appendChild: (child: HTMLElement) => void,
|
|
241
|
+
prepend: (child: HTMLElement) => void,
|
|
242
|
+
append: (...child: HTMLElement[]) => void,
|
|
243
|
+
insertBefore: (node1: HTMLElement, node2: HTMLElement) => void,
|
|
244
|
+
removeChild: (child: HTMLElement) => void,
|
|
245
|
+
querySelector: (selector: string) => HTMLElement | null,
|
|
246
|
+
querySelectorAll: (selector: string) => HTMLElement[],
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
let states = []
|
|
250
|
+
|
|
251
|
+
export const useState = (initialState: any) => {
|
|
252
|
+
let state = initialState
|
|
253
|
+
let setState = (newState: any) => {
|
|
254
|
+
state = newState
|
|
255
|
+
}
|
|
256
|
+
states.push({state, setState})
|
|
257
|
+
return [state, setState]
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export const useReducer = (reducer: any, initialState: any) => {
|
|
261
|
+
let state = initialState
|
|
262
|
+
let dispatch = (action: any) => {
|
|
263
|
+
state = reducer(state, action)
|
|
264
|
+
}
|
|
265
|
+
states.push({state, dispatch})
|
|
266
|
+
return [state, dispatch]
|
|
267
|
+
}
|
|
268
|
+
let refs = []
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
export const useRef = <T>(defaultValue: T) => {
|
|
272
|
+
if(!globalThis.isNotFirstRun) {
|
|
273
|
+
console.warn(`⚠️ Note: useRef in the server environment will not work like it does in the client, you cannot store the reference in a variable within mounted!
|
|
274
|
+
`)
|
|
275
|
+
}
|
|
276
|
+
let refKey = "${Math.random().toString(36).substring(7).replace('.', '').replace('\d', '')}"
|
|
277
|
+
let ref = {name: refKey, current: defaultValue}
|
|
278
|
+
refs.push(ref)
|
|
279
|
+
return ref
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @description The mounted function is called when the component is mounted based on pregenerated keys
|
|
284
|
+
* @param callback {Function}
|
|
285
|
+
* @param parent {Function}
|
|
286
|
+
*/
|
|
287
|
+
export const Mounted = (callback: Function, parent: Function) => {
|
|
288
|
+
callback()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
let effects = []
|
|
292
|
+
/**
|
|
293
|
+
* Use this to perform DOM mutations. This is the primary method you use to update the user interface in response to event handlers and server responses.
|
|
294
|
+
* Prefer the standard `useEffect` when possible to avoid blocking visual updates.
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
export const useEffect = (callback: Function, dependencies: any[]) => {
|
|
298
|
+
if(!effects.includes(callback)){
|
|
299
|
+
effects.push({callback, dependencies})
|
|
300
|
+
}
|
|
301
|
+
let deps = effects.find((effect: any) => effect.callback === callback).dependencies
|
|
302
|
+
if(deps){
|
|
303
|
+
deps.forEach((dep: any) => {
|
|
304
|
+
if(dep !== dependencies[0]){
|
|
305
|
+
callback()
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}else{
|
|
309
|
+
callback()
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
globalThis.window = {
|
|
314
|
+
location: {
|
|
315
|
+
href: '',
|
|
316
|
+
pathname: '',
|
|
317
|
+
search: '',
|
|
318
|
+
hash: '',
|
|
319
|
+
host: '',
|
|
320
|
+
hostname: '',
|
|
321
|
+
port: '',
|
|
322
|
+
protocol: '',
|
|
323
|
+
origin: '',
|
|
324
|
+
reload: () => {}
|
|
325
|
+
},
|
|
326
|
+
history: {
|
|
327
|
+
pushState: (state: any, title: string, url: string) => {},
|
|
328
|
+
replaceState: (state: any, title: string, url: string) => {},
|
|
329
|
+
go: (delta: number) => {},
|
|
330
|
+
back: () => {},
|
|
331
|
+
forward: () => {},
|
|
332
|
+
},
|
|
333
|
+
localStorage: {
|
|
334
|
+
getItem: (key: string) => '',
|
|
335
|
+
setItem: (key: string, value: string) => {},
|
|
336
|
+
removeItem: (key: string) => {},
|
|
337
|
+
clear: () => {},
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export const render = (element: any, container: any) => {
|
|
342
|
+
container.appendChild(element)
|
|
343
|
+
}
|
|
344
|
+
export default Element
|
package/package.json
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaderjs",
|
|
3
|
-
"description": "A
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"description": "A reactive framework for building fast and scalable web applications",
|
|
4
|
+
"version": "1.4.2",
|
|
5
|
+
"main": "vader.js",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Malikwhitten67",
|
|
8
|
+
"email": "malikwhitterb@gmail.com"
|
|
8
9
|
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"react",
|
|
11
|
-
"reactive",
|
|
12
|
-
"nextjs",
|
|
13
|
-
"pages router",
|
|
14
|
-
"bun.js",
|
|
15
|
-
"severside generation",
|
|
16
|
-
"spa",
|
|
17
|
-
"vanillajs",
|
|
18
|
-
"vanilla js"
|
|
19
|
-
],
|
|
20
|
-
"type": "module",
|
|
21
10
|
"license": "MIT",
|
|
22
|
-
"homepage": "https://vader-js.pages.dev",
|
|
23
11
|
"repository": {
|
|
24
12
|
"type": "git",
|
|
25
13
|
"url": "https://github.com/Postr-Inc/Vader.js"
|
|
26
14
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
15
|
+
"type": "module",
|
|
16
|
+
"bin":{
|
|
17
|
+
"vader":"./vader.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"ws": "latest"
|
|
30
21
|
},
|
|
31
|
-
"
|
|
32
|
-
"playwright": "latest",
|
|
33
|
-
"source-map": "latest",
|
|
22
|
+
"devDependencies": {
|
|
34
23
|
"ws": "latest"
|
|
35
24
|
}
|
|
36
|
-
}
|
|
25
|
+
}
|