- @___@ I dont know why i named that lol
- Extendsion : waterx
- Css support : Yes
- Typescript : No
- Autocomplete : No
- Language: The Water language
- Caching using RAM (Variable)
- Caching using file (Cache file)
- Caching using database :>>
var prebuildHTML = {}
var prebuildJS = {}
#hard
The code belike worker.js:
const Cacheing_Html = async () => {
console.log("Wait")
const cache = await caches.open("v1");
console.log(link)
const response = await fetch(`/html/${link}`);
const data = await response.json();
console.log(data)
if(link == "index") {
cache.put(`/`, new Response(data.html));
cache.put(`/html/${link}`, new Response(JSON.stringify(data)));
} else {
cache.put(`/${link}`, new Response(data.html));
cache.put(`/html/${link}`, new Response(JSON.stringify(data)));
}
const response2 = await fetch(`/js/${link}`);
const data2 = await response2.json();
cache.put(`/js/${link}`, new Response(JSON.stringify(data2)));
}
self.addEventListener('fetch', (event) => {
const url = event.request.url;
var parts = url.split("/"); // split the URL by /
var lastPart;
if (parts.length === 2) { // check if the array has only one element
lastPart = "index"; // return the string "index" as the last part
} else {
lastPart = parts.pop(); // get the last element of the array
if (lastPart === "") { // check if the last element is empty
lastPart = parts.pop(); // pop again to get the previous element
}
}
console.log(lastPart); // index
if (lastPart == "index" || lastPart == link) {
event.respondWith(caches.open("v1").then((cache) => {
return cacheFirst(event.request.url);
}));
} else {
}
});
#hard
I dont know how but yeah.
#hard
yeah I dont know why I using -----
var javascriptPart = content.split("-----")[0]
var htmlPart = content.split("-----")[1]
Just simple regex matching
var components = htmlPart.match(/=?{\S+?}/gm);
const title_head = title[0].split(":")[1].trim()
Who no what I did
List of work todo:
- Thinking about when to send it (Hmm) ✅ 2024-01-25
- When to populate in client to aim for best performance ✅ 2024-01-25
- Remove the heck ----- ✅ 2024-01-25
- Write Css
- Caching using file
- Adding title metadata ✅ 2024-01-25 #normal
- Adding javascript function inline ✅ 2024-01-25 #normal
- Cached (The hardest thing todo) ✅ 2024-01-25 #hard
#hard
#normal
- Damn it easy as this:
function hydrate(filename_or_path) {
const data = complie(parse("index.waterx"), "index.waterx")
// if(!prebuildHTML["index.langx"]) {
prebuildHTML["index.waterx"] = data[0]
prebuildJS["index.waterx"] = data[1]
// }
const js = data[2]
return js
}
function Increase() {
a++;
}
<div>
<h1>{a}</h1>
<button onClick={Increase}>Click me</button>
</div>
All the variable which appear in the HTML code as {} Will be populate into span tag
Added soon