chore(examples) prepare examples; cleanup
This commit is contained in:
@@ -11,6 +11,23 @@
|
|||||||
<title>Document</title>
|
<title>Document</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div data-ctra="SimpleButton">
|
||||||
|
<button type="button" data-ctra-on="click:increase:counter">
|
||||||
|
This is a simple Counter:
|
||||||
|
<span data-ctra-var="counter:int:0:10">0</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-ctra="List" id="cards">
|
||||||
|
<div data-ctra="Card">
|
||||||
|
<h1 data-ctra-var="title">Title</h1>
|
||||||
|
<p data-ctra-var="description">Description</p>
|
||||||
|
</div>
|
||||||
|
<button type="button" data-ctra-on="click/duplicate/prev/#cards">
|
||||||
|
Add Card
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="./main.js" type="module"></script>
|
<script src="./main.js" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,15 +1,36 @@
|
|||||||
|
import { unlinkSync } from 'node:fs';
|
||||||
|
const transpiler = Bun.Transpiler({
|
||||||
|
loader: 'cjs',
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
port: Bun.env.BUN_PORT || Bun.env.APP_PORT || 3000,
|
port: Bun.env.BUN_PORT || Bun.env.APP_PORT || 3000,
|
||||||
async fetch(req) {
|
async fetch(req) {
|
||||||
|
const magicKey = Math.random().toString(36).substring(2, 10);
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
if (url.pathname == '/main.js') {
|
if (url.pathname == '/main.js') {
|
||||||
await Bun.build({
|
const path = `./.cache/`;
|
||||||
|
const filename = `${magicKey}.js`;
|
||||||
|
const file = Bun.file(`${path}/${filename}`);
|
||||||
|
const result = await Bun.build({
|
||||||
entrypoints: ['./src/main.js'],
|
entrypoints: ['./src/main.js'],
|
||||||
outdir: '.',
|
outdir: path,
|
||||||
|
target: 'browser',
|
||||||
|
splitting: true,
|
||||||
|
naming: `[dir]/${filename}`,
|
||||||
});
|
});
|
||||||
return new Response(Bun.file('./main.js'), {
|
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
const resp = new Response(file, {
|
||||||
headers: { 'Cache-Control': 'no-cache' },
|
headers: { 'Cache-Control': 'no-cache' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
unlinkSync(`${path}/${filename}`);
|
||||||
|
}, 400);
|
||||||
|
|
||||||
|
return resp;
|
||||||
}
|
}
|
||||||
if (url.pathname == '/') return new Response(Bun.file('./index.html'));
|
if (url.pathname == '/') return new Response(Bun.file('./index.html'));
|
||||||
return new Response('ERR 404: Not Found', { status: 404 });
|
return new Response('ERR 404: Not Found', { status: 404 });
|
||||||
|
|||||||
@@ -34,12 +34,9 @@ class Cetra extends Emitter {
|
|||||||
if (typeof value == 'undefined') {
|
if (typeof value == 'undefined') {
|
||||||
value = Cetra.#defaultSettings.get(key);
|
value = Cetra.#defaultSettings.get(key);
|
||||||
}
|
}
|
||||||
this.#internals
|
this.#internals.get('settings').set(key, value);
|
||||||
.get('settings')
|
|
||||||
.set(key, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const [key, cb] of options) {
|
for (const [key, cb] of options) {
|
||||||
if (!key.startsWith('on') || typeof cb != 'function') continue;
|
if (!key.startsWith('on') || typeof cb != 'function') continue;
|
||||||
this.on(key, cb);
|
this.on(key, cb);
|
||||||
|
|||||||
Reference in New Issue
Block a user