elegance-js 2.1.36 → 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.
|
@@ -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).
|
|
@@ -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
|
@@ -49,9 +49,15 @@ function restartEleganceRuntime() {
|
|
|
49
49
|
if (code === 0)
|
|
50
50
|
return;
|
|
51
51
|
formattedLog(LogLevel.ERROR, "Waiting for file changes..");
|
|
52
|
-
createRecursiveWatcher(compilerOptions.pagesDirectory, async (path) => {
|
|
52
|
+
const { watchers } = createRecursiveWatcher(compilerOptions.pagesDirectory, async (path) => {
|
|
53
|
+
deleteWatchers();
|
|
53
54
|
restartEleganceRuntime();
|
|
54
55
|
});
|
|
56
|
+
function deleteWatchers() {
|
|
57
|
+
for (const [_, watcher] of watchers) {
|
|
58
|
+
watcher.close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
55
61
|
});
|
|
56
62
|
child.on("message", (raw) => {
|
|
57
63
|
const { message, content } = JSON.parse(raw);
|
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
|
|