elegance-js 2.1.37 → 3.0.1

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.
Files changed (138) hide show
  1. package/README.md +90 -4
  2. package/bin/bootstrap.js +18 -0
  3. package/bin/run.js +2 -0
  4. package/dist/build/common.d.ts +147 -0
  5. package/dist/build/common.d.ts.map +1 -0
  6. package/dist/build/common.js +599 -0
  7. package/dist/build/dev.d.ts +2 -0
  8. package/dist/build/dev.d.ts.map +1 -0
  9. package/dist/build/dev.js +234 -0
  10. package/dist/build/prod.d.ts +2 -0
  11. package/dist/build/prod.d.ts.map +1 -0
  12. package/dist/build/prod.js +212 -0
  13. package/dist/build/render.d.ts +29 -0
  14. package/dist/build/render.d.ts.map +1 -0
  15. package/dist/build/render.js +234 -0
  16. package/dist/client.d.ts +13 -0
  17. package/dist/client.d.ts.map +1 -0
  18. package/dist/client.js +677 -0
  19. package/dist/config.d.ts +7 -0
  20. package/dist/config.d.ts.map +1 -0
  21. package/dist/config.js +80 -0
  22. package/dist/constants.d.ts +10 -0
  23. package/dist/constants.d.ts.map +1 -0
  24. package/dist/constants.js +20 -0
  25. package/dist/elements.d.ts +2 -0
  26. package/dist/elements.d.ts.map +1 -0
  27. package/dist/elements.js +14 -0
  28. package/dist/error.d.ts +20 -0
  29. package/dist/error.d.ts.map +1 -0
  30. package/dist/error.js +123 -0
  31. package/dist/globals.d.ts +6 -0
  32. package/dist/globals.d.ts.map +1 -0
  33. package/dist/globals.js +106 -0
  34. package/dist/logger.d.ts +32 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/logger.js +72 -0
  37. package/dist/page-tools.d.ts +19 -0
  38. package/dist/page-tools.d.ts.map +1 -0
  39. package/dist/page-tools.js +141 -0
  40. package/dist/processing/oxc.d.ts +17 -0
  41. package/dist/processing/oxc.d.ts.map +1 -0
  42. package/dist/processing/oxc.js +938 -0
  43. package/dist/processing/taglist.d.ts +2 -0
  44. package/dist/processing/taglist.d.ts.map +1 -0
  45. package/dist/processing/taglist.js +215 -0
  46. package/dist/processing/tsx.d.ts +2 -0
  47. package/dist/processing/tsx.d.ts.map +1 -0
  48. package/dist/processing/tsx.js +131 -0
  49. package/dist/run.d.ts +3 -0
  50. package/dist/run.d.ts.map +1 -0
  51. package/dist/run.js +147 -0
  52. package/dist/server/dev.d.ts +2 -0
  53. package/dist/server/dev.d.ts.map +1 -0
  54. package/dist/server/dev.js +10 -0
  55. package/dist/server/prod.d.ts +2 -0
  56. package/dist/server/prod.d.ts.map +1 -0
  57. package/dist/server/prod.js +42 -0
  58. package/dist/server/security.d.ts +64 -0
  59. package/dist/server/security.d.ts.map +1 -0
  60. package/dist/server/security.js +120 -0
  61. package/dist/server/server.d.ts +73 -99
  62. package/dist/server/server.d.ts.map +1 -0
  63. package/dist/server/server.js +830 -680
  64. package/dist/types/component.d.ts +85 -0
  65. package/dist/types/component.d.ts.map +1 -0
  66. package/dist/types/component.js +0 -0
  67. package/dist/types/config.d.ts +12 -0
  68. package/dist/types/config.d.ts.map +1 -0
  69. package/dist/types/config.js +0 -0
  70. package/dist/types/elements.d.ts +412 -0
  71. package/dist/types/elements.d.ts.map +1 -0
  72. package/dist/types/elements.js +0 -0
  73. package/dist/types/index.d.ts +9 -0
  74. package/dist/types/index.d.ts.map +1 -0
  75. package/dist/types/index.js +5 -0
  76. package/dist/types/jsx.d.ts +976 -0
  77. package/dist/types/jsx.d.ts.map +1 -0
  78. package/dist/types/jsx.js +0 -0
  79. package/dist/types/server-actions.d.ts +60 -0
  80. package/dist/types/server-actions.d.ts.map +1 -0
  81. package/dist/types/server-actions.js +0 -0
  82. package/dist/user-utils.d.ts +23 -0
  83. package/dist/user-utils.d.ts.map +1 -0
  84. package/dist/user-utils.js +61 -0
  85. package/package.json +48 -27
  86. package/dist/client/effect.d.ts +0 -27
  87. package/dist/client/effect.js +0 -37
  88. package/dist/client/eventListener.d.ts +0 -39
  89. package/dist/client/eventListener.js +0 -52
  90. package/dist/client/loadHook.d.ts +0 -34
  91. package/dist/client/loadHook.js +0 -52
  92. package/dist/client/observer.d.ts +0 -36
  93. package/dist/client/observer.js +0 -66
  94. package/dist/client/runtime.d.ts +0 -105
  95. package/dist/client/runtime.js +0 -624
  96. package/dist/client/state.d.ts +0 -40
  97. package/dist/client/state.js +0 -110
  98. package/dist/compilation/compiler.d.ts +0 -163
  99. package/dist/compilation/compiler.js +0 -1164
  100. package/dist/components/ClientComponent.d.ts +0 -22
  101. package/dist/components/ClientComponent.js +0 -55
  102. package/dist/components/Link.d.ts +0 -16
  103. package/dist/components/Link.js +0 -21
  104. package/dist/components/Portal.d.ts +0 -2
  105. package/dist/components/Portal.js +0 -2
  106. package/dist/elements/element.d.ts +0 -87
  107. package/dist/elements/element.js +0 -33
  108. package/dist/elements/element_list.d.ts +0 -7
  109. package/dist/elements/element_list.js +0 -65
  110. package/dist/elements/raw.d.ts +0 -14
  111. package/dist/elements/raw.js +0 -78
  112. package/dist/elements/specific_props.d.ts +0 -750
  113. package/dist/elements/specific_props.js +0 -1
  114. package/dist/global.d.ts +0 -229
  115. package/dist/global.js +0 -1
  116. package/dist/index.d.ts +0 -16
  117. package/dist/index.js +0 -12
  118. package/dist/server/layout.d.ts +0 -34
  119. package/dist/server/layout.js +0 -6
  120. package/dist/server/log.d.ts +0 -12
  121. package/dist/server/log.js +0 -64
  122. package/dist/server/page.d.ts +0 -32
  123. package/dist/server/page.js +0 -6
  124. package/dist/server/runtime.d.ts +0 -6
  125. package/dist/server/runtime.js +0 -92
  126. package/scripts/bootstrap.js +0 -95
  127. package/scripts/bootstrap_files/elegance.txt +0 -40
  128. package/scripts/bootstrap_files/index.txt +0 -3
  129. package/scripts/bootstrap_files/layout.txt +0 -46
  130. package/scripts/bootstrap_files/middleware.txt +0 -18
  131. package/scripts/bootstrap_files/page.txt +0 -123
  132. package/scripts/bootstrap_files/route.txt +0 -6
  133. package/scripts/elegance_dev.ts +0 -42
  134. package/scripts/elegance_prod.ts +0 -42
  135. package/scripts/elegance_static.ts +0 -26
  136. package/scripts/prod.js +0 -13
  137. package/scripts/run.js +0 -13
  138. package/scripts/static.js +0 -13
@@ -1,3 +0,0 @@
1
- import { startEleganceRuntime } from "elegance-js";
2
-
3
- startEleganceRuntime("./elegance.ts");
@@ -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
- }
@@ -1,6 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from "http";
2
-
3
- export async function GET(req: IncomingMessage, res: ServerResponse) {
4
- res.statusCode = 403;
5
- res.end("You're not allowed!! Shoo!");
6
- }
@@ -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();
@@ -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);