elegance-js 2.1.37 → 3.0.0
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/bin/bootstrap.js +18 -0
- package/bin/run.js +2 -0
- package/dist/build/common.d.ts +147 -0
- package/dist/build/common.d.ts.map +1 -0
- package/dist/build/common.js +599 -0
- package/dist/build/dev.d.ts +2 -0
- package/dist/build/dev.d.ts.map +1 -0
- package/dist/build/dev.js +234 -0
- package/dist/build/prod.d.ts +2 -0
- package/dist/build/prod.d.ts.map +1 -0
- package/dist/build/prod.js +212 -0
- package/dist/build/render.d.ts +29 -0
- package/dist/build/render.d.ts.map +1 -0
- package/dist/build/render.js +234 -0
- package/dist/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +677 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +80 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +20 -0
- package/dist/elements.d.ts +2 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +14 -0
- package/dist/error.d.ts +20 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +123 -0
- package/dist/globals.d.ts +6 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +106 -0
- package/dist/logger.d.ts +32 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +72 -0
- package/dist/page-tools.d.ts +19 -0
- package/dist/page-tools.d.ts.map +1 -0
- package/dist/page-tools.js +141 -0
- package/dist/processing/oxc.d.ts +17 -0
- package/dist/processing/oxc.d.ts.map +1 -0
- package/dist/processing/oxc.js +938 -0
- package/dist/processing/taglist.d.ts +2 -0
- package/dist/processing/taglist.d.ts.map +1 -0
- package/dist/processing/taglist.js +215 -0
- package/dist/processing/tsx.d.ts +2 -0
- package/dist/processing/tsx.d.ts.map +1 -0
- package/dist/processing/tsx.js +131 -0
- package/dist/run.d.ts +3 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +147 -0
- package/dist/server/dev.d.ts +2 -0
- package/dist/server/dev.d.ts.map +1 -0
- package/dist/server/dev.js +10 -0
- package/dist/server/prod.d.ts +2 -0
- package/dist/server/prod.d.ts.map +1 -0
- package/dist/server/prod.js +42 -0
- package/dist/server/security.d.ts +64 -0
- package/dist/server/security.d.ts.map +1 -0
- package/dist/server/security.js +120 -0
- package/dist/server/server.d.ts +73 -99
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +830 -680
- package/dist/types/component.d.ts +85 -0
- package/dist/types/component.d.ts.map +1 -0
- package/dist/types/component.js +0 -0
- package/dist/types/config.d.ts +12 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +0 -0
- package/dist/types/elements.d.ts +412 -0
- package/dist/types/elements.d.ts.map +1 -0
- package/dist/types/elements.js +0 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/jsx.d.ts +976 -0
- package/dist/types/jsx.d.ts.map +1 -0
- package/dist/types/jsx.js +0 -0
- package/dist/types/server-actions.d.ts +60 -0
- package/dist/types/server-actions.d.ts.map +1 -0
- package/dist/types/server-actions.js +0 -0
- package/dist/user-utils.d.ts +23 -0
- package/dist/user-utils.d.ts.map +1 -0
- package/dist/user-utils.js +61 -0
- package/package.json +47 -28
- package/README.md +0 -4
- package/dist/client/effect.d.ts +0 -27
- package/dist/client/effect.js +0 -37
- package/dist/client/eventListener.d.ts +0 -39
- package/dist/client/eventListener.js +0 -52
- package/dist/client/loadHook.d.ts +0 -34
- package/dist/client/loadHook.js +0 -52
- package/dist/client/observer.d.ts +0 -36
- package/dist/client/observer.js +0 -66
- package/dist/client/runtime.d.ts +0 -105
- package/dist/client/runtime.js +0 -624
- package/dist/client/state.d.ts +0 -40
- package/dist/client/state.js +0 -110
- package/dist/compilation/compiler.d.ts +0 -163
- package/dist/compilation/compiler.js +0 -1164
- package/dist/components/ClientComponent.d.ts +0 -22
- package/dist/components/ClientComponent.js +0 -55
- package/dist/components/Link.d.ts +0 -16
- package/dist/components/Link.js +0 -21
- package/dist/components/Portal.d.ts +0 -2
- package/dist/components/Portal.js +0 -2
- package/dist/elements/element.d.ts +0 -87
- package/dist/elements/element.js +0 -33
- package/dist/elements/element_list.d.ts +0 -7
- package/dist/elements/element_list.js +0 -65
- package/dist/elements/raw.d.ts +0 -14
- package/dist/elements/raw.js +0 -78
- package/dist/elements/specific_props.d.ts +0 -750
- package/dist/elements/specific_props.js +0 -1
- package/dist/global.d.ts +0 -229
- package/dist/global.js +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -12
- package/dist/server/layout.d.ts +0 -34
- package/dist/server/layout.js +0 -6
- package/dist/server/log.d.ts +0 -12
- package/dist/server/log.js +0 -64
- package/dist/server/page.d.ts +0 -32
- package/dist/server/page.js +0 -6
- package/dist/server/runtime.d.ts +0 -6
- package/dist/server/runtime.js +0 -92
- package/scripts/bootstrap.js +0 -95
- package/scripts/bootstrap_files/elegance.txt +0 -40
- package/scripts/bootstrap_files/index.txt +0 -3
- package/scripts/bootstrap_files/layout.txt +0 -46
- package/scripts/bootstrap_files/middleware.txt +0 -18
- package/scripts/bootstrap_files/page.txt +0 -123
- package/scripts/bootstrap_files/route.txt +0 -6
- package/scripts/elegance_dev.ts +0 -42
- package/scripts/elegance_prod.ts +0 -42
- package/scripts/elegance_static.ts +0 -26
- package/scripts/prod.js +0 -13
- package/scripts/run.js +0 -13
- package/scripts/static.js +0 -13
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { LayoutParams, loadHook, observer, state } from "elegance-js";
|
|
2
|
-
|
|
3
|
-
function Header() {
|
|
4
|
-
const pathname = state("");
|
|
5
|
-
|
|
6
|
-
loadHook((pathname) => {
|
|
7
|
-
pathname.value = window.location.pathname;
|
|
8
|
-
|
|
9
|
-
const id = eleganceClient.onNavigate((newPathname) => {
|
|
10
|
-
pathname.value = newPathname;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return () => eleganceClient.removeNavigationCallback(id);
|
|
14
|
-
}, [pathname])
|
|
15
|
-
|
|
16
|
-
return div({
|
|
17
|
-
class: "px-4 py-2 w-max rounded-md bg-green-400 text-black"
|
|
18
|
-
},
|
|
19
|
-
"Currently visiting: ",
|
|
20
|
-
|
|
21
|
-
span({
|
|
22
|
-
innerText: observer(pathname)
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function layout({ child }: LayoutParams) {
|
|
28
|
-
return html(
|
|
29
|
-
body({
|
|
30
|
-
class: "bg-black text-white h-screen w-screen grid grid-cols-1 p-4 gap-4 grid-rows-[auto_1fr]",
|
|
31
|
-
},
|
|
32
|
-
Header(),
|
|
33
|
-
|
|
34
|
-
child,
|
|
35
|
-
),
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function metadata() {
|
|
40
|
-
return [
|
|
41
|
-
link({
|
|
42
|
-
rel: "stylesheet",
|
|
43
|
-
href: "/index.css",
|
|
44
|
-
}),
|
|
45
|
-
]
|
|
46
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
2
|
-
|
|
3
|
-
async function middleware(req: IncomingMessage, res: ServerResponse, next: () => void) {
|
|
4
|
-
if (Math.random() > 0.3) {
|
|
5
|
-
res.statusCode = 401;
|
|
6
|
-
res.end("Sorry, you're not getting into this page, cause you're not logged in!");
|
|
7
|
-
|
|
8
|
-
next();
|
|
9
|
-
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
next();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
middleware,
|
|
18
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { ClientComponent, eventListener, loadHook, observer, state } from "elegance-js";
|
|
2
|
-
|
|
3
|
-
function Counter() {
|
|
4
|
-
const counter = state(0);
|
|
5
|
-
|
|
6
|
-
return div({
|
|
7
|
-
className: "flex flex-col"
|
|
8
|
-
},
|
|
9
|
-
div({
|
|
10
|
-
className: "flex gap-2"
|
|
11
|
-
},
|
|
12
|
-
button({
|
|
13
|
-
onClick: eventListener((_, counter) => {
|
|
14
|
-
counter.value--;
|
|
15
|
-
}, [counter]),
|
|
16
|
-
className: "w-max hover:scale-120 hover:duration-200 p-2 rounded-sm bg-gray-400 text-black"
|
|
17
|
-
},
|
|
18
|
-
"Less!",
|
|
19
|
-
),
|
|
20
|
-
button({
|
|
21
|
-
onClick: eventListener((_, counter) => {
|
|
22
|
-
counter.value++;
|
|
23
|
-
}, [counter]),
|
|
24
|
-
className: "w-max hover:scale-120 hover:duration-200 p-2 rounded-sm bg-gray-400 text-black"
|
|
25
|
-
},
|
|
26
|
-
"More!",
|
|
27
|
-
),
|
|
28
|
-
),
|
|
29
|
-
|
|
30
|
-
div(
|
|
31
|
-
"The counter is at: ",
|
|
32
|
-
span({ innerText: observer(counter), })
|
|
33
|
-
),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function NameList() {
|
|
38
|
-
const names = state(["Lisa", "John", "Mary", "Mike"]);
|
|
39
|
-
|
|
40
|
-
loadHook((names) => {
|
|
41
|
-
const intervalId = setInterval(() => {
|
|
42
|
-
names.value.sort(() => Math.random() - 0.5);
|
|
43
|
-
names.triggerObservers();
|
|
44
|
-
}, 1000);
|
|
45
|
-
|
|
46
|
-
return () => {
|
|
47
|
-
clearInterval(intervalId);
|
|
48
|
-
};
|
|
49
|
-
}, [names]);
|
|
50
|
-
|
|
51
|
-
return div(
|
|
52
|
-
h3({
|
|
53
|
-
className: "font-semibold"
|
|
54
|
-
},
|
|
55
|
-
"My favourite people:",
|
|
56
|
-
),
|
|
57
|
-
div({
|
|
58
|
-
className: "grid grid-rows-2 grid-cols-2 w-max gap-2 font-mono",
|
|
59
|
-
},
|
|
60
|
-
names.reactiveMap((name) => p(name))
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function SlowComponent() {
|
|
66
|
-
const slowData = state<undefined | number>(undefined);
|
|
67
|
-
|
|
68
|
-
loadHook((slowData) => {
|
|
69
|
-
const id = Date.now().toString();
|
|
70
|
-
|
|
71
|
-
let timeoutId: NodeJS.Timeout;
|
|
72
|
-
|
|
73
|
-
slowData.observe(id, (value) => {
|
|
74
|
-
if (value !== undefined) return;
|
|
75
|
-
|
|
76
|
-
timeoutId = setTimeout(() => {
|
|
77
|
-
slowData.value = Math.random() * 100;
|
|
78
|
-
}, Math.random() * 1000 * 2 + 1);
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
return () => {
|
|
82
|
-
clearTimeout(timeoutId);
|
|
83
|
-
}
|
|
84
|
-
}, [slowData]);
|
|
85
|
-
|
|
86
|
-
return div(
|
|
87
|
-
|
|
88
|
-
button({
|
|
89
|
-
disabled: observer((s) => s === undefined ? true : false, [slowData]),
|
|
90
|
-
className: "disabled:opacity-30",
|
|
91
|
-
onClick: eventListener((_, slowData) => {
|
|
92
|
-
slowData.value = undefined;
|
|
93
|
-
}, [slowData]),
|
|
94
|
-
}, "Refresh"),
|
|
95
|
-
|
|
96
|
-
ClientComponent((slowData) => {
|
|
97
|
-
if (!slowData.value) {
|
|
98
|
-
return div("Waiting for slow data..");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return div("Slow Component gave result: ", slowData.value);
|
|
102
|
-
}, [slowData]),
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function page() {
|
|
108
|
-
return div({
|
|
109
|
-
className: "bg-gray-950 border-2 border-gray-900 p-4 flex flex-col gap-8"
|
|
110
|
-
},
|
|
111
|
-
Counter(),
|
|
112
|
-
|
|
113
|
-
NameList(),
|
|
114
|
-
|
|
115
|
-
SlowComponent(),
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function metadata() {
|
|
120
|
-
return [
|
|
121
|
-
title("This is a demo page!"),
|
|
122
|
-
]
|
|
123
|
-
}
|
package/scripts/elegance_dev.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import { serveProject, compileEntireProject, setCompilerOptions, LogLevel, } from "elegance-js";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
async function runtime() {
|
|
6
|
-
const pagesDirectory = path.resolve("./pages");
|
|
7
|
-
const publicDirectory = path.resolve("./public");
|
|
8
|
-
const outputDirectory = path.resolve(".elegance");
|
|
9
|
-
|
|
10
|
-
setCompilerOptions({
|
|
11
|
-
pagesDirectory: pagesDirectory,
|
|
12
|
-
publicDirectory: publicDirectory,
|
|
13
|
-
outputDirectory: outputDirectory,
|
|
14
|
-
environment: "development",
|
|
15
|
-
|
|
16
|
-
doHotReload: true,
|
|
17
|
-
|
|
18
|
-
logLevel: LogLevel.INFO,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const { allLayouts, allPages, allStatusCodePages, compiledStaticLayouts, compiledStaticPages, } = await compileEntireProject();
|
|
22
|
-
|
|
23
|
-
execSync(`npx @tailwindcss/cli -i ${path.join(pagesDirectory, "input.css")} -o ${path.join(outputDirectory, "DIST", "index.css")}`);
|
|
24
|
-
|
|
25
|
-
await serveProject({
|
|
26
|
-
port: 3000,
|
|
27
|
-
hostname: "0.0.0.0",
|
|
28
|
-
|
|
29
|
-
allowDynamic: true,
|
|
30
|
-
allowStatusCodePages: true,
|
|
31
|
-
serveAPI: true,
|
|
32
|
-
|
|
33
|
-
allLayouts,
|
|
34
|
-
allStatusCodePages,
|
|
35
|
-
allPages,
|
|
36
|
-
|
|
37
|
-
builtStaticPages: compiledStaticPages,
|
|
38
|
-
builtStaticLayouts: compiledStaticLayouts,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
runtime();
|
package/scripts/elegance_prod.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import { serveProject, compileEntireProject, setCompilerOptions, LogLevel, } from "elegance-js";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
async function runtime() {
|
|
6
|
-
const pagesDirectory = path.resolve("./pages");
|
|
7
|
-
const publicDirectory = path.resolve("./public");
|
|
8
|
-
const outputDirectory = path.resolve(".elegance");
|
|
9
|
-
|
|
10
|
-
setCompilerOptions({
|
|
11
|
-
pagesDirectory: pagesDirectory,
|
|
12
|
-
publicDirectory: publicDirectory,
|
|
13
|
-
outputDirectory: outputDirectory,
|
|
14
|
-
environment: "production",
|
|
15
|
-
|
|
16
|
-
doHotReload: false,
|
|
17
|
-
|
|
18
|
-
logLevel: LogLevel.INFO,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const { allLayouts, allPages, allStatusCodePages, compiledStaticLayouts, compiledStaticPages, } = await compileEntireProject();
|
|
22
|
-
|
|
23
|
-
execSync(`npx @tailwindcss/cli -i ${path.join(pagesDirectory, "input.css")} -o ${path.join(outputDirectory, "DIST", "index.css")} --minify`);
|
|
24
|
-
|
|
25
|
-
await serveProject({
|
|
26
|
-
port: 3000,
|
|
27
|
-
hostname: "0.0.0.0",
|
|
28
|
-
|
|
29
|
-
allowDynamic: true,
|
|
30
|
-
allowStatusCodePages: true,
|
|
31
|
-
serveAPI: true,
|
|
32
|
-
|
|
33
|
-
allLayouts,
|
|
34
|
-
allStatusCodePages,
|
|
35
|
-
allPages,
|
|
36
|
-
|
|
37
|
-
builtStaticPages: compiledStaticPages,
|
|
38
|
-
builtStaticLayouts: compiledStaticLayouts,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
runtime();
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import { serveProject, compileEntireProject, setCompilerOptions, LogLevel, } from "elegance-js";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
async function runtime() {
|
|
6
|
-
const pagesDirectory = path.resolve("./pages");
|
|
7
|
-
const publicDirectory = path.resolve("./public");
|
|
8
|
-
const outputDirectory = path.resolve(".elegance");
|
|
9
|
-
|
|
10
|
-
setCompilerOptions({
|
|
11
|
-
pagesDirectory: pagesDirectory,
|
|
12
|
-
publicDirectory: publicDirectory,
|
|
13
|
-
outputDirectory: outputDirectory,
|
|
14
|
-
environment: "production",
|
|
15
|
-
|
|
16
|
-
doHotReload: false,
|
|
17
|
-
|
|
18
|
-
logLevel: LogLevel.INFO,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
await compileEntireProject();
|
|
22
|
-
|
|
23
|
-
execSync(`npx @tailwindcss/cli -i ${path.join(pagesDirectory, "input.css")} -o ${path.join(outputDirectory, "DIST", "index.css")} --minify`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
runtime();
|
package/scripts/prod.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { startEleganceRuntime } from "elegance-js";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const runtimePath = join(__dirname, "elegance_prod.ts");
|
|
12
|
-
|
|
13
|
-
startEleganceRuntime(runtimePath);
|
package/scripts/run.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { startEleganceRuntime } from "elegance-js";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const runtimePath = join(__dirname, "elegance_dev.ts");
|
|
12
|
-
|
|
13
|
-
startEleganceRuntime(runtimePath);
|
package/scripts/static.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { startEleganceRuntime } from "elegance-js";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const runtimePath = join(__dirname, "elegance_static.ts");
|
|
12
|
-
|
|
13
|
-
startEleganceRuntime(runtimePath);
|