elegance-js 3.0.7 → 3.0.9
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/config.d.ts.map +1 -1
- package/dist/config.js +8 -2
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +14 -0
- package/dist/processing/oxc.d.ts.map +1 -1
- package/dist/processing/oxc.js +21 -15
- package/dist/run.d.ts +3 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +8 -2
- package/dist/server/server.d.ts +4 -4
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +8 -8
- package/dist/types/config.d.ts +4 -0
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +2 -3
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,CAAC,CAAC,IAAI;KAClB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAChD,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACf,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/B,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,kBAAkB,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,KAAK,YAAY,CAAC,CAAC,IAAI;KAClB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAChD,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACf,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC/B,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,kBAAkB,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAyGvD,wBAAsB,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAM7D"}
|
package/dist/config.js
CHANGED
|
@@ -33,14 +33,20 @@ const defaultConfig = {
|
|
|
33
33
|
},
|
|
34
34
|
output: {
|
|
35
35
|
outputDirectory: ".elegance",
|
|
36
|
-
pagesDirectory: "pages"
|
|
36
|
+
pagesDirectory: "pages",
|
|
37
|
+
publicDirectory: "public"
|
|
37
38
|
},
|
|
38
39
|
server: {
|
|
39
40
|
port: 3e3,
|
|
40
41
|
serveAPI: true,
|
|
41
42
|
allowDynamicPages: true,
|
|
42
43
|
allowStatusCodePages: true
|
|
43
|
-
}
|
|
44
|
+
},
|
|
45
|
+
console: {
|
|
46
|
+
suppressEleganceLogs: false,
|
|
47
|
+
clearConsoleOnRebuilds: true
|
|
48
|
+
},
|
|
49
|
+
runtime: {}
|
|
44
50
|
};
|
|
45
51
|
let userConfig;
|
|
46
52
|
async function loadConfig() {
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,IAAI,OAAO,EAAE,MAAM,CAAC;AAC3B,eAAO,IAAI,QAAQ,EAAE,MAAM,CAAC;AAC5B,eAAO,IAAI,SAAS,EAAE,MAAM,CAAC;AAC7B,eAAO,IAAI,SAAS,EAAE,MAAM,CAAC;AAE7B,wBAAsB,SAAS,kBAQ9B"}
|
package/dist/logger.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export declare const c: {
|
|
|
12
12
|
readonly white: "\u001B[37m";
|
|
13
13
|
readonly gray: "\u001B[90m";
|
|
14
14
|
};
|
|
15
|
+
export type ConsoleOptions = {
|
|
16
|
+
suppressEleganceLogs?: boolean;
|
|
17
|
+
clearConsoleOnRebuilds?: boolean;
|
|
18
|
+
};
|
|
15
19
|
export type ColorKey = keyof typeof c;
|
|
16
20
|
export interface LogOptions {
|
|
17
21
|
/** A secondary, dimmed line printed beneath the message. */
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC;;;;;;;;;;;;;CAaJ,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAA;AAID,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,CAAA;AAkBrC,MAAM,WAAW,UAAU;IACvB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB;AAsBD,eAAO,MAAM,MAAM;cACF,MAAM,SAAS,UAAU,GAAG,IAAI;iBAChC,MAAM,SAAS,UAAU,GAAG,IAAI;cAChC,MAAM,SAAS,UAAU,GAAG,IAAI;eAChC,MAAM,SAAS,UAAU,GAAG,IAAI;eAChC,MAAM,SAAS,UAAU,GAAG,IAAI;WAEtC,IAAI;oBAQK,MAAM,GAAG,IAAI;eAclB,MAAM,SAAS,MAAM,UAAS,QAAQ,GAAY,IAAI;CAQpE,CAAA"}
|
package/dist/logger.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getConfig } from "./config.js";
|
|
1
2
|
const c = {
|
|
2
3
|
reset: "\x1B[0m",
|
|
3
4
|
bold: "\x1B[1m",
|
|
@@ -12,6 +13,7 @@ const c = {
|
|
|
12
13
|
white: "\x1B[37m",
|
|
13
14
|
gray: "\x1B[90m"
|
|
14
15
|
};
|
|
16
|
+
const config = await getConfig();
|
|
15
17
|
function paint(text, ...styles) {
|
|
16
18
|
return styles.map((k) => c[k]).join("") + text + c.reset;
|
|
17
19
|
}
|
|
@@ -24,6 +26,9 @@ const LEVELS = {
|
|
|
24
26
|
};
|
|
25
27
|
const MSG_INDENT = " ";
|
|
26
28
|
function emit(level, msg, opts = {}) {
|
|
29
|
+
if (config.console.suppressEleganceLogs) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
27
32
|
const { icon, badge, color } = LEVELS[level];
|
|
28
33
|
const fn = level === "error" ? console.error : console.log;
|
|
29
34
|
const ts = opts.timestamp ? paint((/* @__PURE__ */ new Date()).toTimeString().slice(0, 8), "gray") + " " : "";
|
|
@@ -50,9 +55,15 @@ const logger = {
|
|
|
50
55
|
emit("debug", msg, opts);
|
|
51
56
|
},
|
|
52
57
|
gap() {
|
|
58
|
+
if (config.console.suppressEleganceLogs) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
53
61
|
console.log("");
|
|
54
62
|
},
|
|
55
63
|
divider(label) {
|
|
64
|
+
if (config.console.suppressEleganceLogs) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
56
67
|
const W = 54;
|
|
57
68
|
if (label) {
|
|
58
69
|
const dashes = "\u2500".repeat(Math.max(2, W - label.length - 4));
|
|
@@ -62,6 +73,9 @@ const logger = {
|
|
|
62
73
|
}
|
|
63
74
|
},
|
|
64
75
|
field(key, value, color = "cyan") {
|
|
76
|
+
if (config.console.suppressEleganceLogs) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
65
79
|
const k = paint(key.padEnd(10), color);
|
|
66
80
|
console.log(` ${MSG_INDENT}${k} ${value}`);
|
|
67
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxc.d.ts","sourceRoot":"","sources":["../../src/processing/oxc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oxc.d.ts","sourceRoot":"","sources":["../../src/processing/oxc.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,IAAI;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACvB;AAwGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CActE;AAyFD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAuBhE;AA+mBD,wBAAgB,eAAe,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAQ/C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA0BzD;AAwSD,wBAAgB,oBAAoB,CAChC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACjB,MAAM,CAiDR;AAgHD,wBAAgB,8BAA8B,CAC1C,aAAa,EAAI,MAAM,EACvB,eAAe,EAAE,MAAM,EAAE,GAC1B,IAAI,CAEN;AAED,wBAAgB,uBAAuB,CACnC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,EACrB,eAAe,EAAE,MAAM,EAAE,GAC1B,MAAM,CA0CR"}
|
package/dist/processing/oxc.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { parseSync } from "oxc-parser";
|
|
2
2
|
import { ALL_TAGS } from "./taglist.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import { isBuiltin } from "node:module";
|
|
5
4
|
import { richError } from "../error.js";
|
|
6
5
|
const ALL_TAGS_SET = new Set(ALL_TAGS);
|
|
7
6
|
const CHILD_KEYS = {
|
|
@@ -431,28 +430,32 @@ If that is not the case, remove the reference that cause their inclusion.`,
|
|
|
431
430
|
});
|
|
432
431
|
}
|
|
433
432
|
}
|
|
433
|
+
const forcedImports = /* @__PURE__ */ new Set();
|
|
434
434
|
{
|
|
435
435
|
const programComments = ast.comments ?? [];
|
|
436
436
|
const allowedImports = /* @__PURE__ */ new Set();
|
|
437
437
|
for (const comment of programComments) {
|
|
438
438
|
if (comment.type !== "Line") continue;
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
439
|
+
const trimmed = comment.value.trim();
|
|
440
|
+
if (trimmed === "!allow-bundling") {
|
|
441
|
+
const afterComment = comment.end;
|
|
442
|
+
const annotatedNode = body.find((n) => n.start >= afterComment);
|
|
443
|
+
if (annotatedNode && annotatedNode.type === "ImportDeclaration") {
|
|
444
|
+
allowedImports.add(annotatedNode);
|
|
445
|
+
}
|
|
446
|
+
} else if (trimmed === "!force-bundling") {
|
|
447
|
+
const afterComment = comment.end;
|
|
448
|
+
const annotatedNode = body.find((n) => n.start >= afterComment);
|
|
449
|
+
if (annotatedNode && annotatedNode.type === "ImportDeclaration") {
|
|
450
|
+
forcedImports.add(annotatedNode);
|
|
451
|
+
}
|
|
444
452
|
}
|
|
445
453
|
}
|
|
446
454
|
const violations = [];
|
|
447
455
|
for (const node of body) {
|
|
448
456
|
if (node.type !== "ImportDeclaration") continue;
|
|
449
457
|
const specs = node.specifiers ?? [];
|
|
450
|
-
if (specs.length === 0)
|
|
451
|
-
if (!allowedImports.has(node)) {
|
|
452
|
-
violations.push({ importNode: node });
|
|
453
|
-
}
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
458
|
+
if (specs.length === 0) continue;
|
|
456
459
|
const hasReachable = specs.some((s) => reachable.has(s.local.name));
|
|
457
460
|
if (!hasReachable) continue;
|
|
458
461
|
if (!allowedImports.has(node)) {
|
|
@@ -496,13 +499,16 @@ Every import that survives into the client bundle must be explicitly allowed.`,
|
|
|
496
499
|
for (const node of body) {
|
|
497
500
|
if (node.type === "ImportDeclaration") {
|
|
498
501
|
const specs = node.specifiers ?? [];
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (specs.length === 0 && isBuiltin(node.source.value)) {
|
|
502
|
+
if (specs.length === 0) {
|
|
503
|
+
if (!forcedImports.has(node)) {
|
|
502
504
|
removalEdits.push({ start: node.start, end: trailingEnd(node.end), replacement: "" });
|
|
503
505
|
}
|
|
504
506
|
continue;
|
|
505
507
|
}
|
|
508
|
+
const reachableSpecs = specs.filter((s) => reachable.has(s.local.name));
|
|
509
|
+
if (reachableSpecs.length === specs.length) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
506
512
|
if (reachableSpecs.length === 0) {
|
|
507
513
|
removalEdits.push({ start: node.start, end: trailingEnd(node.end), replacement: "" });
|
|
508
514
|
} else {
|
package/dist/run.d.ts
CHANGED
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";AASA,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
package/dist/run.js
CHANGED
|
@@ -5,9 +5,12 @@ import { join, dirname } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { watch } from "node:fs";
|
|
7
7
|
import { logger } from "./logger.js";
|
|
8
|
+
import { loadPaths } from "./constants.js";
|
|
9
|
+
await loadPaths();
|
|
10
|
+
import { PAGES_DIR } from "./constants.js";
|
|
11
|
+
import { getConfig } from "./config.js";
|
|
8
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
13
|
const __dirname = dirname(__filename);
|
|
10
|
-
const PAGES_DIR = join(process.cwd(), "pages");
|
|
11
14
|
const BUILD_DEV_ENTRY = join(__dirname, "build", "dev.js");
|
|
12
15
|
const BUILD_PROD_ENTRY = join(__dirname, "build", "prod.js");
|
|
13
16
|
const SERVER_DEV_ENTRY = join(__dirname, "server", "dev.js");
|
|
@@ -107,7 +110,10 @@ async function startServer() {
|
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
112
|
async function cycle() {
|
|
110
|
-
|
|
113
|
+
const config = await getConfig();
|
|
114
|
+
if (config.console.suppressEleganceLogs === false && config.console.clearConsoleOnRebuilds === true) {
|
|
115
|
+
process.stdout.write("\x1Bc");
|
|
116
|
+
}
|
|
111
117
|
if (serverProcess && !serverProcess.killed) {
|
|
112
118
|
serverProcess.kill("SIGTERM");
|
|
113
119
|
await new Promise((resolve) => serverProcess.once("exit", resolve));
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
2
|
import type { CompiledRoute, Manifest, CacheKey } from "../build/common";
|
|
3
3
|
export type ServerOptions = {
|
|
4
|
-
serveAPI
|
|
5
|
-
allowDynamicPages
|
|
6
|
-
allowStatusCodePages
|
|
7
|
-
port
|
|
4
|
+
serveAPI?: boolean;
|
|
5
|
+
allowDynamicPages?: boolean;
|
|
6
|
+
allowStatusCodePages?: boolean;
|
|
7
|
+
port?: number;
|
|
8
8
|
};
|
|
9
9
|
interface ApiRouteModule {
|
|
10
10
|
GET?: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiB1E,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAc,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiB1E,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAc,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAkBrF,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,EAAc,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAK,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,IAAI,CAAC,EAAkB,MAAM,CAAC;CACjC,CAAC;AASF,UAAU,cAAc;IACpB,GAAG,CAAC,EAAK,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,IAAI,CAAC,EAAI,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,C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,GAAG,IAAW,CAAC;AA+CzE,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4BtD;AAED,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,MAAM,GAChB,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAgD5E;AA2BD,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IACjE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,WAAW,EAAK,YAAY,EAAE,CAAC;CAClC,CAAC,CA6ED;AAED,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAU5F;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAwBhG;AAsCD,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAsmBrC,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAyB3C"}
|
package/dist/server/server.js
CHANGED
|
@@ -18,11 +18,8 @@ import { getConfig } from "../config.js";
|
|
|
18
18
|
import { createSecurityHeaders } from "./security.js";
|
|
19
19
|
import { isRichError, printError, richError } from "../error.js";
|
|
20
20
|
import { logger } from "../logger.js";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const config = await getConfig();
|
|
24
|
-
return config.server;
|
|
25
|
-
}
|
|
21
|
+
const config = await getConfig();
|
|
22
|
+
await loadPaths();
|
|
26
23
|
let serverOptions;
|
|
27
24
|
const IS_DEV = process.env.ELEGANCE_DEV_MODE === "dev";
|
|
28
25
|
class LRU {
|
|
@@ -77,8 +74,8 @@ const BROTLI_PARAMS = { params: { [zlibConstants.BROTLI_PARAM_QUALITY]: 4 } };
|
|
|
77
74
|
const BODY_TIMEOUT_MS = parseInt(process.env.BODY_TIMEOUT_MS ?? "10000", 10);
|
|
78
75
|
let SECURITY_HEADERS;
|
|
79
76
|
async function initSecurityHeaders() {
|
|
80
|
-
const
|
|
81
|
-
SECURITY_HEADERS = createSecurityHeaders(
|
|
77
|
+
const config2 = await getConfig();
|
|
78
|
+
SECURITY_HEADERS = createSecurityHeaders(config2.security);
|
|
82
79
|
}
|
|
83
80
|
function buildCachedFileHeaders(mime, etag, rawLen, gzipLen, brotliLen, cacheControl = "public, max-age=31536000, immutable") {
|
|
84
81
|
const base = {
|
|
@@ -826,7 +823,10 @@ async function startMainServer() {
|
|
|
826
823
|
throw new Error("Could not find an available port");
|
|
827
824
|
}
|
|
828
825
|
async function serve() {
|
|
829
|
-
serverOptions =
|
|
826
|
+
serverOptions = config.server;
|
|
827
|
+
if (config.runtime.init) {
|
|
828
|
+
await import(config.runtime.init);
|
|
829
|
+
}
|
|
830
830
|
const manifest = JSON.parse(
|
|
831
831
|
await readFile(join(OUT_DIR, "paths.json"), "utf-8")
|
|
832
832
|
);
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { OutputOptions } from "../constants";
|
|
2
2
|
import type { SecurityHeadersOptions } from "../server/security";
|
|
3
3
|
import type { ServerOptions } from "../server/server";
|
|
4
|
+
import type { ConsoleOptions } from "../logger";
|
|
5
|
+
import type { RuntimeOptions } from "../run";
|
|
4
6
|
declare global {
|
|
5
7
|
type EleganceConfig = {
|
|
6
8
|
security?: SecurityHeadersOptions;
|
|
7
9
|
output?: OutputOptions;
|
|
8
10
|
server?: ServerOptions;
|
|
11
|
+
console?: ConsoleOptions;
|
|
12
|
+
runtime?: RuntimeOptions;
|
|
9
13
|
};
|
|
10
14
|
}
|
|
11
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,CAAC,MAAM,CAAC;IACX,KAAK,cAAc,GAAG;QAClB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;QAClC,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,OAAO,CAAC,EAAE,cAAc,CAAC;QACzB,OAAO,CAAC,EAAE,cAAc,CAAC;KAC5B,CAAC;CACL;AAED,OAAO,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elegance-js",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/user-utils.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"./run": {
|
|
29
29
|
"types": "./dist/run.d.ts",
|
|
30
30
|
"import": "./dist/run.js",
|
|
31
|
-
"default": "./dist/run.js"
|
|
32
|
-
"require": "./dist/run.js"
|
|
31
|
+
"default": "./dist/run.js"
|
|
33
32
|
}
|
|
34
33
|
},
|
|
35
34
|
"author": "vqldemar <npm-elegance@val.sh> (https://github.com/valdemar-dev)",
|