vaderjs 1.5.3 → 1.5.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/document/index.ts +35 -31
- package/index.ts +4 -3
- package/main.js +11 -12
- package/package.json +2 -3
package/document/index.ts
CHANGED
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
export const document = (element: any) => {
|
|
1
|
+
export const document = (element: any) => {
|
|
2
2
|
let type = element.type;
|
|
3
|
-
let el = `<${type}
|
|
3
|
+
let el = type === null ? `` : `<${type}`
|
|
4
|
+
console.log(el)
|
|
4
5
|
let attributes = element.props;
|
|
5
6
|
let children = element.children;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (key === "className") {
|
|
12
|
-
el += ` class="${attributes[key]}"`;
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
if (key === "style") {
|
|
16
|
-
// convert style object to string
|
|
17
|
-
let styles = attributes[key];
|
|
18
|
-
let styleString = "";
|
|
19
|
-
// convert camelCase to kebab-case
|
|
20
|
-
for (let style in styles) {
|
|
21
|
-
let kebabStyle = style.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
22
|
-
styleString += `${kebabStyle}:${styles[style]};`;
|
|
7
|
+
if(type != null){
|
|
8
|
+
for (let key in attributes) {
|
|
9
|
+
if(key === "key"){
|
|
10
|
+
el += ` key="${attributes[key]}"`;
|
|
11
|
+
continue;
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
if (key === "className") {
|
|
14
|
+
el += ` class="${attributes[key]}"`;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (key === "style") {
|
|
18
|
+
// convert style object to string
|
|
19
|
+
let styles = attributes[key];
|
|
20
|
+
let styleString = "";
|
|
21
|
+
// convert camelCase to kebab-case
|
|
22
|
+
for (let style in styles) {
|
|
23
|
+
let kebabStyle = style.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
24
|
+
styleString += `${kebabStyle}:${styles[style]};`;
|
|
25
|
+
}
|
|
26
|
+
el += ` style="${styleString}"`;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
//@ts-ignore
|
|
30
|
+
if (key.startsWith("on")){
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
el += ` ${key}="${attributes[key]}"`;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
el += type === null ? `` : `>`
|
|
35
38
|
for (let i = 0;i < children.length; i++) {
|
|
36
39
|
let child = children[i];
|
|
40
|
+
console.log(child)
|
|
37
41
|
if (Array.isArray(child)) {
|
|
38
42
|
child.forEach((c) => {
|
|
39
43
|
el += document(c);
|
|
@@ -48,6 +52,6 @@ export const document = (element: any) => {
|
|
|
48
52
|
el += child;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
el += `</${type}
|
|
55
|
+
el += type === null ? `` : `</${type}>`
|
|
52
56
|
return el;
|
|
53
57
|
}
|
package/index.ts
CHANGED
|
@@ -76,8 +76,8 @@ export const useEffect = (callback:any, dependencies: any[]) => {
|
|
|
76
76
|
|
|
77
77
|
export const Fragment = (props: any, children: any) => {
|
|
78
78
|
return {
|
|
79
|
-
type: "div",
|
|
80
|
-
props:
|
|
79
|
+
type: isServer ? null : "div",
|
|
80
|
+
props:{},
|
|
81
81
|
children: children || [],
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -105,7 +105,8 @@ export const e = (element, props, ...children) => {
|
|
|
105
105
|
let firstEl = instance.render({key: instance.key, children: children, ...props});
|
|
106
106
|
instance.children = children;
|
|
107
107
|
if (!firstEl) firstEl = {type: "div", props: {key: instance.key, children: [], ...props}, children: []};
|
|
108
|
-
firstEl.props = {key: instance.key,
|
|
108
|
+
firstEl.props = {key: instance.key, ...props};
|
|
109
|
+
firstEl.children = children;
|
|
109
110
|
return firstEl;
|
|
110
111
|
default:
|
|
111
112
|
return { type: element, props: props || {}, children: children || [] };
|
package/main.js
CHANGED
|
@@ -267,17 +267,16 @@ await handleFiles()
|
|
|
267
267
|
globalThis.clients = []
|
|
268
268
|
|
|
269
269
|
if (mode === 'development') {
|
|
270
|
-
const watcher = fs.watch(path.join(process.cwd() + '/
|
|
271
|
-
const publicWatcher = fs.watch(path.join(process.cwd() + '/public'), { recursive: true })
|
|
272
|
-
const srcWatcher = fs.watch(path.join(process.cwd() + '/src'), { recursive: true })
|
|
270
|
+
const watcher = fs.watch(path.join(process.cwd() + '/'), { recursive: true })
|
|
273
271
|
let isBuilding = false; // Flag to track build status
|
|
274
272
|
|
|
275
273
|
// Initialize a variable to hold the timeout ID
|
|
276
274
|
let debounceTimeout;
|
|
277
275
|
|
|
278
276
|
// Function to handle file changes with debounce
|
|
279
|
-
const handleFileChangeDebounced = async () => {
|
|
280
|
-
|
|
277
|
+
const handleFileChangeDebounced = async (change, file) => {
|
|
278
|
+
if(file.endsWith('.tsx') || file.endsWith('.jsx')){
|
|
279
|
+
clearTimeout(debounceTimeout);
|
|
281
280
|
debounceTimeout = setTimeout(async () => {
|
|
282
281
|
if (!isBuilding) { // Check if not already building
|
|
283
282
|
isBuilding = true; // Set build flag to true
|
|
@@ -294,12 +293,11 @@ if (mode === 'development') {
|
|
|
294
293
|
}
|
|
295
294
|
}
|
|
296
295
|
}, 500);
|
|
296
|
+
}
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
// Event listeners with debounced handling
|
|
300
|
-
|
|
301
|
-
watcher.on('change', handleFileChangeDebounced);
|
|
302
|
-
srcWatcher.on('change', handleFileChangeDebounced);
|
|
299
|
+
// Event listeners with debounced handling
|
|
300
|
+
watcher.on('change', handleFileChangeDebounced);
|
|
303
301
|
let server = Bun.serve({
|
|
304
302
|
port: port || 8080,
|
|
305
303
|
websocket: {
|
|
@@ -321,7 +319,7 @@ if (mode === 'development') {
|
|
|
321
319
|
|
|
322
320
|
let url = new URL(req.url)
|
|
323
321
|
if (url.pathname.includes('.')) {
|
|
324
|
-
let p = url.pathname.replaceAll("%5B", "[").replaceAll("%5D", "]")
|
|
322
|
+
let p = url.pathname.replaceAll("%5B", "[").replaceAll("%5D", "]")
|
|
325
323
|
let file = await Bun.file(path.join(process.cwd() + '/dist' + p))
|
|
326
324
|
if (!await file.exists()) return new Response('Not found', { status: 404 })
|
|
327
325
|
return new Response(await file.text(), {
|
|
@@ -343,9 +341,10 @@ if (mode === 'development') {
|
|
|
343
341
|
}
|
|
344
342
|
let p = route.pathname;
|
|
345
343
|
let base = path.dirname(route.filePath)
|
|
346
|
-
base = base.replace(
|
|
344
|
+
base = base.replace(/\\/g, '/')
|
|
345
|
+
base = base.replace(path.join(process.cwd() + '/app').replace(/\\/g, '/'), '')
|
|
347
346
|
base = base.replace(/\\/g, '/').replace('/app', '/dist')
|
|
348
|
-
base = process.cwd() + "/dist/" + base
|
|
347
|
+
base = process.cwd() + "/dist/" + base
|
|
349
348
|
let data = await Bun.file(path.join(base, 'index.html')).text()
|
|
350
349
|
if (mode == "development") {
|
|
351
350
|
return new Response(data + `
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaderjs",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "A simple and powerful JavaScript library for building modern web applications.",
|
|
5
|
-
"main": "./main.js",
|
|
3
|
+
"version": "1.5.5",
|
|
4
|
+
"description": "A simple and powerful JavaScript library for building modern web applications.",
|
|
6
5
|
"bin": {
|
|
7
6
|
"vaderjs": "./main.js"
|
|
8
7
|
},
|