elegance-js 2.1.23 → 2.1.26
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/client/effect.d.ts +27 -0
- package/dist/client/effect.js +37 -0
- package/dist/client/eventListener.d.ts +39 -0
- package/dist/client/eventListener.js +52 -0
- package/dist/client/loadHook.d.ts +34 -0
- package/dist/client/loadHook.js +52 -0
- package/dist/client/observer.d.ts +36 -0
- package/dist/client/observer.js +66 -0
- package/dist/client/runtime.d.ts +105 -0
- package/dist/client/runtime.js +620 -0
- package/dist/client/state.d.ts +40 -0
- package/dist/client/state.js +110 -0
- package/dist/compilation/compiler.d.ts +155 -0
- package/dist/compilation/compiler.js +1153 -0
- package/dist/components/ClientComponent.d.ts +22 -0
- package/dist/components/ClientComponent.js +55 -0
- package/dist/components/Link.d.ts +16 -1
- package/dist/components/Link.js +22 -0
- package/dist/components/Portal.d.ts +2 -0
- package/dist/components/Portal.js +2 -0
- package/dist/elements/element.d.ts +87 -0
- package/dist/elements/element.js +33 -0
- package/dist/elements/element_list.d.ts +7 -0
- package/dist/elements/element_list.js +65 -0
- package/dist/elements/raw.d.ts +14 -0
- package/dist/elements/raw.js +78 -0
- package/dist/elements/specific_props.d.ts +750 -0
- package/dist/global.d.ts +221 -327
- package/dist/index.d.ts +15 -3
- package/dist/index.js +11 -0
- package/dist/server/layout.d.ts +34 -3
- package/dist/server/layout.js +6 -0
- package/dist/server/log.d.ts +12 -0
- package/dist/server/log.js +64 -0
- package/dist/server/page.d.ts +32 -0
- package/dist/server/page.js +6 -0
- package/dist/server/runtime.d.ts +6 -0
- package/dist/server/runtime.js +72 -0
- package/dist/server/server.d.ts +103 -11
- package/dist/server/server.js +709 -0
- package/package.json +13 -13
- package/scripts/bootstrap.js +37 -273
- package/scripts/bootstrap_files/elegance.txt +40 -0
- package/scripts/bootstrap_files/index.txt +3 -0
- package/scripts/bootstrap_files/layout.txt +46 -0
- package/scripts/bootstrap_files/middleware.txt +18 -0
- package/scripts/bootstrap_files/page.txt +123 -0
- package/scripts/bootstrap_files/route.txt +6 -0
- package/scripts/elegance_dev.ts +40 -0
- package/scripts/elegance_prod.ts +40 -0
- package/scripts/elegance_static.ts +24 -0
- package/scripts/prod.js +9 -26
- package/scripts/run.js +13 -0
- package/scripts/static.js +13 -0
- package/dist/build.d.ts +0 -2
- package/dist/build.mjs +0 -202
- package/dist/client/client.d.ts +0 -1
- package/dist/client/client.mjs +0 -574
- package/dist/client/processPageElements.d.ts +0 -1
- package/dist/client/processPageElements.mjs +0 -117
- package/dist/client/render.d.ts +0 -1
- package/dist/client/render.mjs +0 -40
- package/dist/client/watcher.d.ts +0 -1
- package/dist/client/watcher.mjs +0 -26
- package/dist/compilation/compilation.d.ts +0 -139
- package/dist/compilation/compilation.mjs +0 -751
- package/dist/compilation/compiler_process.d.ts +0 -3
- package/dist/compilation/compiler_process.mjs +0 -102
- package/dist/compilation/dynamic_compiler.d.ts +0 -10
- package/dist/compilation/dynamic_compiler.mjs +0 -93
- package/dist/compile_docs.mjs +0 -34
- package/dist/components/Link.mjs +0 -65
- package/dist/global.mjs +0 -0
- package/dist/helpers/ObjectAttributeType.d.ts +0 -7
- package/dist/helpers/ObjectAttributeType.mjs +0 -11
- package/dist/helpers/camelToKebab.d.ts +0 -1
- package/dist/helpers/camelToKebab.mjs +0 -6
- package/dist/index.mjs +0 -3
- package/dist/internal/deprecate.d.ts +0 -1
- package/dist/internal/deprecate.mjs +0 -7
- package/dist/log.d.ts +0 -10
- package/dist/log.mjs +0 -38
- package/dist/server/generateHTMLTemplate.d.ts +0 -12
- package/dist/server/generateHTMLTemplate.mjs +0 -41
- package/dist/server/layout.mjs +0 -19
- package/dist/server/loadHook.d.ts +0 -30
- package/dist/server/loadHook.mjs +0 -50
- package/dist/server/observe.d.ts +0 -19
- package/dist/server/observe.mjs +0 -16
- package/dist/server/render.d.ts +0 -5
- package/dist/server/render.mjs +0 -61
- package/dist/server/server.mjs +0 -429
- package/dist/server/state.d.ts +0 -61
- package/dist/server/state.mjs +0 -146
- package/dist/shared/bindServerElements.mjs +0 -3
- package/dist/shared/serverElements.d.ts +0 -11
- package/dist/shared/serverElements.mjs +0 -164
- package/scripts/dev.js +0 -33
- package/scripts/export.js +0 -20
- package/scripts/ts-arc-dev.js +0 -9
- package/scripts/ts-arc-prod.js +0 -9
- /package/dist/{compile_docs.d.ts → elements/specific_props.js} +0 -0
- /package/dist/{shared/bindServerElements.d.ts → global.js} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { serveProject, compileEntireProject, setCompilerOptions, } 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: true,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const { allLayouts, allPages, allStatusCodePages, compiledStaticLayouts, compiledStaticPages, } = await compileEntireProject();
|
|
20
|
+
|
|
21
|
+
execSync(`npx @tailwindcss/cli -i ${path.join(pagesDirectory, "input.css")} -o ${path.join(outputDirectory, "DIST", "index.css")} --minify`);
|
|
22
|
+
|
|
23
|
+
await serveProject({
|
|
24
|
+
port: 3000,
|
|
25
|
+
hostname: "0.0.0.0",
|
|
26
|
+
|
|
27
|
+
allowDynamic: true,
|
|
28
|
+
allowStatusCodePages: true,
|
|
29
|
+
serveAPI: true,
|
|
30
|
+
|
|
31
|
+
allLayouts,
|
|
32
|
+
allStatusCodePages,
|
|
33
|
+
allPages,
|
|
34
|
+
|
|
35
|
+
builtStaticPages: compiledStaticPages,
|
|
36
|
+
builtStaticLayouts: compiledStaticLayouts,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
runtime();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { serveProject, compileEntireProject, setCompilerOptions, } 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
|
+
|
|
19
|
+
await compileEntireProject();
|
|
20
|
+
|
|
21
|
+
execSync(`npx @tailwindcss/cli -i ${path.join(pagesDirectory, "input.css")} -o ${path.join(outputDirectory, "DIST", "index.css")} --minify`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
runtime();
|
package/scripts/prod.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { startEleganceRuntime } from "elegance-js";
|
|
4
|
+
import { join, dirname } from "path";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
path: "./public",
|
|
15
|
-
},
|
|
16
|
-
server: {
|
|
17
|
-
runServer: true,
|
|
18
|
-
port: 3000,
|
|
19
|
-
},
|
|
20
|
-
hotReload: undefined,
|
|
21
|
-
postCompile: () => {
|
|
22
|
-
if (child !== undefined) {
|
|
23
|
-
child.kill('SIGKILL');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const childProcess = execSync("npx @tailwindcss/cli -i \"./index.css\" -o \"../.elegance/dist/index.css\" --cwd \"./pages\" --minify=true")
|
|
27
|
-
|
|
28
|
-
child = childProcess;
|
|
29
|
-
},
|
|
30
|
-
})
|
|
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
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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);
|
|
@@ -0,0 +1,13 @@
|
|
|
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);
|
package/dist/build.d.ts
DELETED
package/dist/build.mjs
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import child_process from "node:child_process";
|
|
5
|
-
import http from "http";
|
|
6
|
-
import { startServer } from "./server/server";
|
|
7
|
-
import { log, setQuiet } from "./log";
|
|
8
|
-
import { populateServerMaps, setCompilationOptions } from "./compilation/compilation";
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = path.dirname(__filename);
|
|
11
|
-
const packageDir = path.resolve(__dirname, "..");
|
|
12
|
-
const builderPath = path.resolve(packageDir, "dist", "compilation", "compiler_process.mjs");
|
|
13
|
-
const yellow = (text) => {
|
|
14
|
-
return `\x1B[38;2;238;184;68m${text}`;
|
|
15
|
-
};
|
|
16
|
-
const bold = (text) => {
|
|
17
|
-
return `\x1B[1m${text}`;
|
|
18
|
-
};
|
|
19
|
-
const white = (text) => {
|
|
20
|
-
return `\x1B[38;2;255;247;229m${text}`;
|
|
21
|
-
};
|
|
22
|
-
const green = (text) => {
|
|
23
|
-
return `\x1B[38;2;65;224;108m${text}`;
|
|
24
|
-
};
|
|
25
|
-
const finishLog = (...text) => {
|
|
26
|
-
log.info(text.map((text2) => `${text2}\x1B[0m`).join(""));
|
|
27
|
-
};
|
|
28
|
-
let options = process.env.OPTIONS;
|
|
29
|
-
const getAllSubdirectories = (dir, baseDir = dir) => {
|
|
30
|
-
let directories = [];
|
|
31
|
-
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
32
|
-
for (const item of items) {
|
|
33
|
-
if (item.isDirectory()) {
|
|
34
|
-
const fullPath = path.join(dir, item.name);
|
|
35
|
-
const relativePath = path.relative(baseDir, fullPath);
|
|
36
|
-
directories.push(relativePath);
|
|
37
|
-
directories = directories.concat(getAllSubdirectories(fullPath, baseDir));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return directories;
|
|
41
|
-
};
|
|
42
|
-
let child = void 0;
|
|
43
|
-
let isBuilding = false;
|
|
44
|
-
const runBuild = (filepath, DIST_DIR) => {
|
|
45
|
-
const optionsString = JSON.stringify(options);
|
|
46
|
-
if (isBuilding) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (child !== void 0) {
|
|
50
|
-
child.removeAllListeners();
|
|
51
|
-
child.kill("SIGKILL");
|
|
52
|
-
}
|
|
53
|
-
child = child_process.spawn("node", ["--import", "ts-arc/register", filepath], {
|
|
54
|
-
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
55
|
-
env: {
|
|
56
|
-
...process.env,
|
|
57
|
-
DIST_DIR,
|
|
58
|
-
OPTIONS: optionsString,
|
|
59
|
-
PACKAGE_PATH: packageDir,
|
|
60
|
-
DO_BUILD: "true"
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
process.env.OPTIONS = optionsString;
|
|
64
|
-
process.env.DIST_DIR = DIST_DIR;
|
|
65
|
-
child.on("error", () => {
|
|
66
|
-
log.error("Failed to start child process.");
|
|
67
|
-
});
|
|
68
|
-
child.on("exit", () => {
|
|
69
|
-
isBuilding = false;
|
|
70
|
-
log.info("Builder process complete");
|
|
71
|
-
});
|
|
72
|
-
child.on("message", (message) => {
|
|
73
|
-
const { data } = message;
|
|
74
|
-
if (data === "hard-reload") {
|
|
75
|
-
httpStream?.write(`data: hard-reload
|
|
76
|
-
|
|
77
|
-
`);
|
|
78
|
-
} else if (data === "soft-reload") {
|
|
79
|
-
httpStream?.write(`data: reload
|
|
80
|
-
|
|
81
|
-
`);
|
|
82
|
-
} else if (data === "compile-finish") {
|
|
83
|
-
isBuilding = false;
|
|
84
|
-
if (options.postCompile) {
|
|
85
|
-
finishLog(
|
|
86
|
-
white("Calling post-compile hook..")
|
|
87
|
-
);
|
|
88
|
-
options.postCompile();
|
|
89
|
-
}
|
|
90
|
-
} else if (data === "set-pages-and-layouts") {
|
|
91
|
-
const { pageMap, layoutMap } = JSON.parse(message.content);
|
|
92
|
-
populateServerMaps(new Map(pageMap), new Map(layoutMap));
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
const build = (DIST_DIR) => {
|
|
97
|
-
runBuild(builderPath, DIST_DIR);
|
|
98
|
-
setCompilationOptions(options, DIST_DIR);
|
|
99
|
-
};
|
|
100
|
-
let isTimedOut = false;
|
|
101
|
-
const currentWatchers = [];
|
|
102
|
-
let httpStream;
|
|
103
|
-
const registerListener = async () => {
|
|
104
|
-
const server = http.createServer((req, res) => {
|
|
105
|
-
if (req.url === "/events") {
|
|
106
|
-
finishLog(white("Client listening for changes.."));
|
|
107
|
-
res.writeHead(200, {
|
|
108
|
-
"Content-Type": "text/event-stream",
|
|
109
|
-
"Cache-Control": "no-cache",
|
|
110
|
-
"Connection": "keep-alive",
|
|
111
|
-
"Transfer-Encoding": "chunked",
|
|
112
|
-
"X-Accel-Buffering": "no",
|
|
113
|
-
"Content-Encoding": "none",
|
|
114
|
-
"Access-Control-Allow-Origin": "*",
|
|
115
|
-
"Access-Control-Allow-Methods": "*",
|
|
116
|
-
"Access-Control-Allow-Headers": "*"
|
|
117
|
-
});
|
|
118
|
-
httpStream = res;
|
|
119
|
-
httpStream.write(`data: ping
|
|
120
|
-
|
|
121
|
-
`);
|
|
122
|
-
} else {
|
|
123
|
-
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
124
|
-
res.end("Not Found");
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
server.listen(options.hotReload.port, () => {
|
|
128
|
-
finishLog(bold(green("Hot-Reload server online!")));
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
const compile = async (props) => {
|
|
132
|
-
options = props;
|
|
133
|
-
setQuiet(options.quiet ?? false);
|
|
134
|
-
const watch = options.hotReload !== void 0;
|
|
135
|
-
const BUILD_FLAG = path.join(options.outputDirectory, "ELEGANCE_BUILD_FLAG");
|
|
136
|
-
if (!fs.existsSync(options.outputDirectory)) {
|
|
137
|
-
fs.mkdirSync(options.outputDirectory, { recursive: true });
|
|
138
|
-
fs.writeFileSync(
|
|
139
|
-
path.join(BUILD_FLAG),
|
|
140
|
-
"This file marks this directory as one containing an Elegance Build.",
|
|
141
|
-
"utf-8"
|
|
142
|
-
);
|
|
143
|
-
} else {
|
|
144
|
-
if (!fs.existsSync(BUILD_FLAG)) {
|
|
145
|
-
throw `The output directory already exists, but is not an Elegance Build directory.`;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const DIST_DIR = path.join(props.outputDirectory, "dist");
|
|
149
|
-
if (!fs.existsSync(DIST_DIR)) {
|
|
150
|
-
fs.mkdirSync(DIST_DIR, { recursive: true });
|
|
151
|
-
}
|
|
152
|
-
build(DIST_DIR);
|
|
153
|
-
if (options.server != void 0 && options.server.runServer == true) {
|
|
154
|
-
startServer({
|
|
155
|
-
root: options.server.root ?? DIST_DIR,
|
|
156
|
-
environment: options.environment,
|
|
157
|
-
port: options.server.port ?? 3e3,
|
|
158
|
-
host: options.server.host ?? "localhost",
|
|
159
|
-
DIST_DIR,
|
|
160
|
-
pagesDirectory: options.pagesDirectory
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
if (watch) {
|
|
164
|
-
await registerListener();
|
|
165
|
-
for (const watcher of currentWatchers) {
|
|
166
|
-
watcher.close();
|
|
167
|
-
}
|
|
168
|
-
let extra = [];
|
|
169
|
-
if (options.hotReload?.extraWatchDirectories) {
|
|
170
|
-
const dirs = options.hotReload?.extraWatchDirectories ?? [];
|
|
171
|
-
if (dirs.length !== 0) {
|
|
172
|
-
for (const dir of dirs) {
|
|
173
|
-
const subdirs = getAllSubdirectories(dir).map((f) => path.join(dir, f));
|
|
174
|
-
extra.push(...subdirs);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
const pagesSubDirs = getAllSubdirectories(options.pagesDirectory).map((f) => path.join(options.pagesDirectory, f));
|
|
179
|
-
const subdirectories = [...pagesSubDirs, options.pagesDirectory, ...extra];
|
|
180
|
-
finishLog(yellow("Hot-Reload Watching Subdirectories: "), ...subdirectories.join(", "));
|
|
181
|
-
const watcherFn = async () => {
|
|
182
|
-
if (isTimedOut) return;
|
|
183
|
-
isTimedOut = true;
|
|
184
|
-
process.stdout.write("\x1Bc");
|
|
185
|
-
setTimeout(async () => {
|
|
186
|
-
build(DIST_DIR);
|
|
187
|
-
isTimedOut = false;
|
|
188
|
-
}, 100);
|
|
189
|
-
};
|
|
190
|
-
for (const directory of subdirectories) {
|
|
191
|
-
const watcher = fs.watch(
|
|
192
|
-
directory,
|
|
193
|
-
{},
|
|
194
|
-
watcherFn
|
|
195
|
-
);
|
|
196
|
-
currentWatchers.push(watcher);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
export {
|
|
201
|
-
compile
|
|
202
|
-
};
|
package/dist/client/client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../shared/bindServerElements";
|