elegance-js 2.1.35 → 2.1.37
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/dist/compilation/compiler.d.ts +6 -1
- package/dist/compilation/compiler.js +4 -0
- package/dist/elements/specific_props.d.ts +1 -1
- package/dist/server/runtime.js +9 -4
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/scripts/bootstrap_files/layout.txt +2 -2
- package/scripts/bootstrap_files/page.txt +8 -8
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* This file contains the functions used by compiler_process to compile pages.
|
|
3
3
|
*/
|
|
4
4
|
import { AnyElement, SpecialElementOption } from "../elements/element";
|
|
5
|
+
import { FSWatcher } from "fs";
|
|
5
6
|
import { PageInformation } from "../server/page";
|
|
6
7
|
import { LayoutInformation, LayoutProps } from "../server/layout";
|
|
7
8
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -133,7 +134,11 @@ declare function compileLayout(layoutInformation: LayoutInformation, allLayouts:
|
|
|
133
134
|
req?: IncomingMessage;
|
|
134
135
|
res?: ServerResponse;
|
|
135
136
|
}): Promise<CompiledLayout>;
|
|
136
|
-
declare function createRecursiveWatcher(targetDir: string, callback: (path: string) => Promise<void>):
|
|
137
|
+
declare function createRecursiveWatcher(targetDir: string, callback: (path: string) => Promise<void>): {
|
|
138
|
+
watchers: Map<string, FSWatcher>;
|
|
139
|
+
timeouts: Map<string, NodeJS.Timeout>;
|
|
140
|
+
unregisterWatcher: (path: string) => void;
|
|
141
|
+
};
|
|
137
142
|
/**
|
|
138
143
|
* Run the general compilation process for the project.
|
|
139
144
|
* This compiles all static-pages & static-layouts, as well as gathers a list of every page (dynamic and static) & layout (dynamic and static).
|
|
@@ -1108,6 +1108,7 @@ function createRecursiveWatcher(targetDir, callback) {
|
|
|
1108
1108
|
catch (e) { }
|
|
1109
1109
|
}
|
|
1110
1110
|
registerWatcher(targetDir);
|
|
1111
|
+
return { watchers, timeouts, unregisterWatcher };
|
|
1111
1112
|
}
|
|
1112
1113
|
/**
|
|
1113
1114
|
* Run the general compilation process for the project.
|
|
@@ -1123,6 +1124,7 @@ async function compileEntireProject() {
|
|
|
1123
1124
|
return;
|
|
1124
1125
|
};
|
|
1125
1126
|
formattedLog(LogLevel.DEBUG, "Compiling project..");
|
|
1127
|
+
const start = performance.now();
|
|
1126
1128
|
// This is used to restart us if we crash, via an FS watcher.
|
|
1127
1129
|
process.send?.(JSON.stringify({ message: "set-compiler-options", content: JSON.stringify(compilerOptions) }));
|
|
1128
1130
|
process.on("uncaughtException", gracefulErr);
|
|
@@ -1140,6 +1142,8 @@ async function compileEntireProject() {
|
|
|
1140
1142
|
cpSync(compilerOptions.publicDirectory, getDistDir(), { recursive: true, });
|
|
1141
1143
|
process.off("uncaughtException", gracefulErr);
|
|
1142
1144
|
process.off("unhandledRejection", gracefulErr);
|
|
1145
|
+
const end = performance.now();
|
|
1146
|
+
formattedLog(LogLevel.INFO, `Finished building in: ${Math.round(end - start)}ms`);
|
|
1143
1147
|
return {
|
|
1144
1148
|
allPages,
|
|
1145
1149
|
allLayouts,
|
|
@@ -524,7 +524,7 @@ export type SpecificPropsMap = {
|
|
|
524
524
|
polyline: {
|
|
525
525
|
points?: MaybeSpecial<string>;
|
|
526
526
|
};
|
|
527
|
-
|
|
527
|
+
stop: {
|
|
528
528
|
offset?: MaybeSpecial<string | number>;
|
|
529
529
|
stopColor?: MaybeSpecial<string>;
|
|
530
530
|
stopOpacity?: MaybeSpecial<string | number>;
|
package/dist/server/runtime.js
CHANGED
|
@@ -48,11 +48,16 @@ function restartEleganceRuntime() {
|
|
|
48
48
|
child.on("exit", (code) => {
|
|
49
49
|
if (code === 0)
|
|
50
50
|
return;
|
|
51
|
-
formattedLog(LogLevel.ERROR, "
|
|
52
|
-
createRecursiveWatcher(compilerOptions.pagesDirectory, async (path) => {
|
|
53
|
-
|
|
51
|
+
formattedLog(LogLevel.ERROR, "Waiting for file changes..");
|
|
52
|
+
const { watchers } = createRecursiveWatcher(compilerOptions.pagesDirectory, async (path) => {
|
|
53
|
+
deleteWatchers();
|
|
54
54
|
restartEleganceRuntime();
|
|
55
55
|
});
|
|
56
|
+
function deleteWatchers() {
|
|
57
|
+
for (const [_, watcher] of watchers) {
|
|
58
|
+
watcher.close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
56
61
|
});
|
|
57
62
|
child.on("message", (raw) => {
|
|
58
63
|
const { message, content } = JSON.parse(raw);
|
|
@@ -69,7 +74,7 @@ function restartEleganceRuntime() {
|
|
|
69
74
|
if (!serverIsActive) {
|
|
70
75
|
serverIsActive = true;
|
|
71
76
|
server.listen(4000, () => {
|
|
72
|
-
formattedLog(LogLevel.
|
|
77
|
+
formattedLog(LogLevel.DEBUG, "Hot-reload server listening on port 4000");
|
|
73
78
|
});
|
|
74
79
|
}
|
|
75
80
|
for (const client of clients) {
|
package/dist/server/server.js
CHANGED
|
@@ -546,7 +546,7 @@ async function serveProject(startupServerOptions) {
|
|
|
546
546
|
if (compilerOptions.doHotReload) {
|
|
547
547
|
process.send?.(JSON.stringify({ message: "hot-reload-finish" }));
|
|
548
548
|
}
|
|
549
|
-
formattedLog(LogLevel.INFO, `
|
|
549
|
+
formattedLog(LogLevel.INFO, `Website Live at: http://${serverOptions.hostname}:${port}/`);
|
|
550
550
|
});
|
|
551
551
|
return {
|
|
552
552
|
port,
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LayoutParams, loadHook, observer, state } from "elegance-js";
|
|
2
2
|
|
|
3
3
|
function Header() {
|
|
4
4
|
const pathname = state("");
|
|
@@ -24,7 +24,7 @@ function Header() {
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function layout(child:
|
|
27
|
+
export function layout({ child }: LayoutParams) {
|
|
28
28
|
return html(
|
|
29
29
|
body({
|
|
30
30
|
class: "bg-black text-white h-screen w-screen grid grid-cols-1 p-4 gap-4 grid-rows-[auto_1fr]",
|
|
@@ -4,16 +4,16 @@ function Counter() {
|
|
|
4
4
|
const counter = state(0);
|
|
5
5
|
|
|
6
6
|
return div({
|
|
7
|
-
|
|
7
|
+
className: "flex flex-col"
|
|
8
8
|
},
|
|
9
9
|
div({
|
|
10
|
-
|
|
10
|
+
className: "flex gap-2"
|
|
11
11
|
},
|
|
12
12
|
button({
|
|
13
13
|
onClick: eventListener((_, counter) => {
|
|
14
14
|
counter.value--;
|
|
15
15
|
}, [counter]),
|
|
16
|
-
|
|
16
|
+
className: "w-max hover:scale-120 hover:duration-200 p-2 rounded-sm bg-gray-400 text-black"
|
|
17
17
|
},
|
|
18
18
|
"Less!",
|
|
19
19
|
),
|
|
@@ -21,7 +21,7 @@ function Counter() {
|
|
|
21
21
|
onClick: eventListener((_, counter) => {
|
|
22
22
|
counter.value++;
|
|
23
23
|
}, [counter]),
|
|
24
|
-
|
|
24
|
+
className: "w-max hover:scale-120 hover:duration-200 p-2 rounded-sm bg-gray-400 text-black"
|
|
25
25
|
},
|
|
26
26
|
"More!",
|
|
27
27
|
),
|
|
@@ -50,12 +50,12 @@ function NameList() {
|
|
|
50
50
|
|
|
51
51
|
return div(
|
|
52
52
|
h3({
|
|
53
|
-
|
|
53
|
+
className: "font-semibold"
|
|
54
54
|
},
|
|
55
55
|
"My favourite people:",
|
|
56
56
|
),
|
|
57
57
|
div({
|
|
58
|
-
|
|
58
|
+
className: "grid grid-rows-2 grid-cols-2 w-max gap-2 font-mono",
|
|
59
59
|
},
|
|
60
60
|
names.reactiveMap((name) => p(name))
|
|
61
61
|
)
|
|
@@ -87,7 +87,7 @@ function SlowComponent() {
|
|
|
87
87
|
|
|
88
88
|
button({
|
|
89
89
|
disabled: observer((s) => s === undefined ? true : false, [slowData]),
|
|
90
|
-
|
|
90
|
+
className: "disabled:opacity-30",
|
|
91
91
|
onClick: eventListener((_, slowData) => {
|
|
92
92
|
slowData.value = undefined;
|
|
93
93
|
}, [slowData]),
|
|
@@ -106,7 +106,7 @@ function SlowComponent() {
|
|
|
106
106
|
|
|
107
107
|
export function page() {
|
|
108
108
|
return div({
|
|
109
|
-
|
|
109
|
+
className: "bg-gray-950 border-2 border-gray-900 p-4 flex flex-col gap-8"
|
|
110
110
|
},
|
|
111
111
|
Counter(),
|
|
112
112
|
|