@absolutejs/absolute 0.5.5 → 0.6.0
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/index.js +67 -58
- package/dist/index.js.map +10 -9
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/plugins/pageRouterPlugin.d.ts +1 -1
- package/dist/src/types.d.ts +1 -5
- package/dist/src/utils/updateScriptTags.d.ts +0 -8
- package/eslint.config.mjs +203 -0
- package/package.json +12 -3
- package/build/HomeIndex.paddd8c9.js +0 -20725
- package/build/NotAuthorizedIndex.7em4g7an.js +0 -20717
- package/build/ProtectedIndex.k3vgnatp.js +0 -22282
- package/build/TestingIndex.j74ezacm.js +0 -33877
- package/build/assets/favicon.ico +0 -0
- package/build/assets/jpeg/mercadolibre-logo.jpeg +0 -0
- package/build/assets/jpeg/yahoo-Icon.jpeg +0 -0
- package/build/assets/png/Facebook_Logo_Primary.png +0 -0
- package/build/assets/png/LI-In-Bug.png +0 -0
- package/build/assets/png/LINE_Brand_icon.png +0 -0
- package/build/assets/png/Okta_Wordmark_Black_S.png +0 -0
- package/build/assets/png/Polar_logo_black_web.png +0 -0
- package/build/assets/png/SLA-Slack-from-Salesforce-logo.png +0 -0
- package/build/assets/png/Synology_logo_Standard.png +0 -0
- package/build/assets/png/Zoom_Logo_Bloom_RGB.png +0 -0
- package/build/assets/png/naver-btnD_icon_circle.png +0 -0
- package/build/assets/png/naver-btnG_icon_circle.png +0 -0
- package/build/assets/png/osu!logo.png +0 -0
- package/build/assets/png/twitter-logo-black.png +0 -0
- package/build/assets/svg/42-logo.svg +0 -1
- package/build/assets/svg/DA_Alert_Color-Logo.svg +0 -27
- package/build/assets/svg/Figma-Icon-(Full-color).svg +0 -7
- package/build/assets/svg/GitHub_Invertocat_Dark.svg +0 -14
- package/build/assets/svg/Microsoft-Entra-ID-color-icon.svg +0 -9
- package/build/assets/svg/PATREON_SYMBOL_1_BLACK_RGB.svg +0 -8
- package/build/assets/svg/Reddit_Icon_FullColor.svg +0 -142
- package/build/assets/svg/amazoncognito-logo.svg +0 -1
- package/build/assets/svg/anilist-logo.svg +0 -1
- package/build/assets/svg/apple-logo.svg +0 -1
- package/build/assets/svg/atlassian-logo.svg +0 -1
- package/build/assets/svg/auth0-logo.svg +0 -1
- package/build/assets/svg/authentik-logo.svg +0 -1
- package/build/assets/svg/autodesk-logo.svg +0 -1
- package/build/assets/svg/battlenet-logo.svg +0 -1
- package/build/assets/svg/bitbucket-logo.svg +0 -1
- package/build/assets/svg/box-logo.svg +0 -1
- package/build/assets/svg/bungie-logo.svg +0 -1
- package/build/assets/svg/coinbase-logo.svg +0 -1
- package/build/assets/svg/discord-logo.svg +0 -1
- package/build/assets/svg/dribbble-logo.svg +0 -1
- package/build/assets/svg/dropbox-logo.svg +0 -1
- package/build/assets/svg/epicgames-logo.svg +0 -1
- package/build/assets/svg/etsy-logo.svg +0 -1
- package/build/assets/svg/gitea-logo.svg +0 -1
- package/build/assets/svg/gitlab-logo.svg +0 -1
- package/build/assets/svg/google-logo.svg +0 -7
- package/build/assets/svg/intuit-logo.svg +0 -4
- package/build/assets/svg/kakao-logo.svg +0 -1
- package/build/assets/svg/keycloak-logo.svg +0 -1
- package/build/assets/svg/kick-logo.svg +0 -1
- package/build/assets/svg/lichess-logo.svg +0 -1
- package/build/assets/svg/linear-logo.svg +0 -1
- package/build/assets/svg/logomark_black.svg +0 -25
- package/build/assets/svg/mastadon-logo-purple.svg +0 -10
- package/build/assets/svg/mercadopago-logo.svg +0 -1
- package/build/assets/svg/myanimelist-logo.svg +0 -1
- package/build/assets/svg/notion-logo.svg +0 -1
- package/build/assets/svg/rgb-tiltify22_mark_blue.svg +0 -3
- package/build/assets/svg/roblox-logo.svg +0 -1
- package/build/assets/svg/salesforce-logo.svg +0 -1
- package/build/assets/svg/shikimori-logo.svg +0 -1
- package/build/assets/svg/spotify-Primary_Logo_Green_RGB.svg +0 -1
- package/build/assets/svg/start.gg_Icon_RGB.svg +0 -15
- package/build/assets/svg/strava-logo.svg +0 -1
- package/build/assets/svg/tiktok-logo.svg +0 -1
- package/build/assets/svg/twitch-glitch_flat_purple.svg +0 -21
- package/build/assets/svg/vk-logo.svg +0 -1
- package/build/assets/svg/workos-logo-color.svg +0 -21
- package/build/assets/svg/yandex-icon_grad_circ.svg +0 -20
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ var SECONDS_IN_A_MINUTE = 60;
|
|
|
4
4
|
var MILLISECONDS_IN_A_SECOND = 1000;
|
|
5
5
|
var MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
|
|
6
6
|
var MINUTES_IN_AN_HOUR = 60;
|
|
7
|
-
var
|
|
8
|
-
var MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR *
|
|
7
|
+
var HOURS_IN_DAY = 24;
|
|
8
|
+
var MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
|
|
9
9
|
var TIME_PRECISION = 2;
|
|
10
|
+
var TWO_THIRDS = 2 / 3;
|
|
10
11
|
var DEFAULT_PORT = 3000;
|
|
11
12
|
// src/core/build.ts
|
|
12
13
|
import { rm, mkdir, writeFile as writeFile2 } from "fs/promises";
|
|
@@ -18,25 +19,22 @@ var {$, build: bunBuild, Glob: Glob2 } = globalThis.Bun;
|
|
|
18
19
|
import { readFile, writeFile } from "fs/promises";
|
|
19
20
|
var {Glob } = globalThis.Bun;
|
|
20
21
|
var updateScriptTags = async (manifest, htmlDir) => {
|
|
21
|
-
const
|
|
22
|
+
const glob = new Glob("*.html");
|
|
22
23
|
const htmlFiles = [];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})) {
|
|
27
|
-
htmlFiles.push(file);
|
|
28
|
-
}
|
|
29
|
-
for (const filePath of htmlFiles) {
|
|
30
|
-
let content = await readFile(filePath, "utf8");
|
|
31
|
-
for (const [scriptName, newPath] of Object.entries(manifest)) {
|
|
32
|
-
const escapedScriptName = scriptName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
33
|
-
const regex = new RegExp(`(<script[^>]+src=["'])(/?(?:.*\\/)?${escapedScriptName})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`, "g");
|
|
34
|
-
content = content.replace(regex, (_, prefix, _oldBase, _ext, suffix) => {
|
|
35
|
-
return `${prefix}${newPath}${suffix}`;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
await writeFile(filePath, content, "utf8");
|
|
24
|
+
const fileIterator = glob.scan({ absolute: true, cwd: htmlDir });
|
|
25
|
+
for await (const filePath of fileIterator) {
|
|
26
|
+
htmlFiles.push(filePath);
|
|
39
27
|
}
|
|
28
|
+
const tasks = htmlFiles.map(async (filePath) => {
|
|
29
|
+
const original = await readFile(filePath, "utf8");
|
|
30
|
+
const updated = Object.entries(manifest).reduce((html, [scriptName, newPath]) => {
|
|
31
|
+
const esc = scriptName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
32
|
+
const regex = new RegExp(`(<script[^>]+src=["'])(/?(?:.*/)?${esc})(?:\\.[^."'/]+)?(\\.js)(["'][^>]*>)`, "g");
|
|
33
|
+
return html.replace(regex, (_, prefix, __, ___, suffix) => `${prefix}${newPath}${suffix}`);
|
|
34
|
+
}, original);
|
|
35
|
+
await writeFile(filePath, updated, "utf8");
|
|
36
|
+
});
|
|
37
|
+
await Promise.all(tasks);
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
// src/core/build.ts
|
|
@@ -44,32 +42,48 @@ var build = async ({
|
|
|
44
42
|
buildDirectory = "build",
|
|
45
43
|
assetsDirectory,
|
|
46
44
|
reactDirectory,
|
|
47
|
-
|
|
45
|
+
htmlDirectory,
|
|
48
46
|
htmxDirectory,
|
|
49
47
|
tailwind
|
|
50
48
|
}) => {
|
|
51
49
|
const start = performance.now();
|
|
52
50
|
const projectRoot = cwd();
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
await
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
const buildDirectoryAbsolute = join(projectRoot, buildDirectory);
|
|
52
|
+
const assetsDirectoryAbsolute = assetsDirectory && join(projectRoot, assetsDirectory);
|
|
53
|
+
const reactIndexesDirectory = reactDirectory && join(projectRoot, reactDirectory, "indexes");
|
|
54
|
+
const reactPagesDirectory = reactDirectory && join(projectRoot, reactDirectory, "pages");
|
|
55
|
+
const htmlPagesDirectory = htmlDirectory && join(projectRoot, htmlDirectory, "pages");
|
|
56
|
+
const htmlScriptsDirectory = htmlDirectory && join(projectRoot, htmlDirectory, "scripts");
|
|
57
|
+
const htmxDirectoryAbsolute = htmxDirectory && join(projectRoot, htmxDirectory);
|
|
58
|
+
await rm(buildDirectoryAbsolute, { force: true, recursive: true });
|
|
59
|
+
await mkdir(buildDirectoryAbsolute);
|
|
60
|
+
reactPagesDirectory && reactIndexesDirectory && await generateReactIndexFiles(reactPagesDirectory, reactIndexesDirectory);
|
|
61
|
+
assetsDirectoryAbsolute && await $`cp -R ${assetsDirectoryAbsolute} ${buildDirectoryAbsolute}`;
|
|
62
|
+
if (htmlPagesDirectory) {
|
|
63
|
+
await mkdir(join(buildDirectoryAbsolute, "html", "pages"), {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
await $`cp -R ${htmlPagesDirectory} ${join(buildDirectoryAbsolute, "html")}`;
|
|
67
|
+
}
|
|
68
|
+
if (htmxDirectoryAbsolute) {
|
|
69
|
+
await mkdir(join(buildDirectoryAbsolute, "htmx"));
|
|
70
|
+
await $`cp -R ${htmxDirectoryAbsolute} ${join(buildDirectoryAbsolute)}`;
|
|
71
|
+
}
|
|
72
|
+
if (tailwind) {
|
|
73
|
+
await $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join(buildDirectoryAbsolute, tailwind.output)}`;
|
|
74
|
+
}
|
|
75
|
+
const reactEntryPaths = reactIndexesDirectory && await scanEntryPoints(reactIndexesDirectory, "*.tsx");
|
|
76
|
+
const htmlEntryPaths = htmlScriptsDirectory && await scanEntryPoints(htmlScriptsDirectory, "*.{js,ts}");
|
|
77
|
+
const entryPaths = [...reactEntryPaths || [], ...htmlEntryPaths || []];
|
|
64
78
|
if (entryPaths.length === 0) {
|
|
65
|
-
console.warn("No entry points found, skipping
|
|
79
|
+
console.warn("No entry points found, skipping building manifest");
|
|
66
80
|
return null;
|
|
67
81
|
}
|
|
68
82
|
const { logs, outputs } = await bunBuild({
|
|
69
83
|
entrypoints: entryPaths,
|
|
70
84
|
format: "esm",
|
|
71
85
|
naming: `[dir]/[name].[hash].[ext]`,
|
|
72
|
-
outdir:
|
|
86
|
+
outdir: buildDirectoryAbsolute,
|
|
73
87
|
target: "bun"
|
|
74
88
|
}).catch((error) => {
|
|
75
89
|
console.error("Build failed:", error);
|
|
@@ -83,22 +97,10 @@ var build = async ({
|
|
|
83
97
|
else if (log.level === "info" || log.level === "debug")
|
|
84
98
|
console.info(log);
|
|
85
99
|
});
|
|
86
|
-
assetsDirAbsolute && await $`cp -R ${assetsDirAbsolute} ${buildDirAbsolute}`;
|
|
87
|
-
if (htmlDirAbsolute) {
|
|
88
|
-
await mkdir(join(buildDirAbsolute, "html"));
|
|
89
|
-
await $`cp -R ${htmlDirAbsolute} ${join(buildDirAbsolute)}`;
|
|
90
|
-
}
|
|
91
|
-
if (htmxDirAbsolute) {
|
|
92
|
-
await mkdir(join(buildDirAbsolute, "htmx"));
|
|
93
|
-
await $`cp -R ${htmxDirAbsolute} ${join(buildDirAbsolute)}`;
|
|
94
|
-
}
|
|
95
|
-
if (tailwind) {
|
|
96
|
-
await $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join(buildDirAbsolute, tailwind.output)}`;
|
|
97
|
-
}
|
|
98
100
|
const manifest = outputs.reduce((acc, artifact) => {
|
|
99
101
|
let relativePath = artifact.path;
|
|
100
|
-
if (relativePath.startsWith(
|
|
101
|
-
relativePath = relativePath.slice(
|
|
102
|
+
if (relativePath.startsWith(buildDirectoryAbsolute)) {
|
|
103
|
+
relativePath = relativePath.slice(buildDirectoryAbsolute.length);
|
|
102
104
|
}
|
|
103
105
|
relativePath = relativePath.replace(/^\/+/, "");
|
|
104
106
|
const baseName = relativePath.split("/").pop();
|
|
@@ -109,10 +111,10 @@ var build = async ({
|
|
|
109
111
|
throw new Error(`Expected hash delimiter ${hashDelimiter} in ${baseName}`);
|
|
110
112
|
}
|
|
111
113
|
const [fileName] = baseName.split(hashDelimiter);
|
|
112
|
-
acc[fileName] =
|
|
114
|
+
acc[fileName] = `/${relativePath}`;
|
|
113
115
|
return acc;
|
|
114
116
|
}, {});
|
|
115
|
-
|
|
117
|
+
htmlPagesDirectory && await updateScriptTags(manifest, join(buildDirectoryAbsolute, "html", "pages"));
|
|
116
118
|
const end = performance.now();
|
|
117
119
|
const durationMs = end - start;
|
|
118
120
|
let duration;
|
|
@@ -126,12 +128,12 @@ var build = async ({
|
|
|
126
128
|
console.log(`Build completed in ${duration}`);
|
|
127
129
|
return manifest;
|
|
128
130
|
};
|
|
129
|
-
var generateReactIndexFiles = async (
|
|
130
|
-
await rm(
|
|
131
|
-
await mkdir(
|
|
131
|
+
var generateReactIndexFiles = async (reactPagesDirectory, reactIndexesDirectory) => {
|
|
132
|
+
await rm(reactIndexesDirectory, { force: true, recursive: true });
|
|
133
|
+
await mkdir(reactIndexesDirectory);
|
|
132
134
|
const pagesGlob = new Glob2("*.*");
|
|
133
135
|
const files = [];
|
|
134
|
-
for await (const file of pagesGlob.scan({ cwd:
|
|
136
|
+
for await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {
|
|
135
137
|
files.push(file);
|
|
136
138
|
}
|
|
137
139
|
const promises = files.map(async (file) => {
|
|
@@ -144,7 +146,7 @@ var generateReactIndexFiles = async (reactPagesDirAbsolute, reactIndexDirAbsolut
|
|
|
144
146
|
`hydrateRoot(document, <${componentName} />);`
|
|
145
147
|
].join(`
|
|
146
148
|
`);
|
|
147
|
-
return writeFile2(join(
|
|
149
|
+
return writeFile2(join(reactIndexesDirectory, `${componentName}Index.tsx`), content);
|
|
148
150
|
});
|
|
149
151
|
await Promise.all(promises);
|
|
150
152
|
};
|
|
@@ -157,8 +159,9 @@ var scanEntryPoints = async (dir, pattern) => {
|
|
|
157
159
|
return entryPaths;
|
|
158
160
|
};
|
|
159
161
|
// src/core/pageHandlers.ts
|
|
162
|
+
var {file } = globalThis.Bun;
|
|
160
163
|
import { createElement } from "react";
|
|
161
|
-
import { renderToReadableStream } from "react-dom/server
|
|
164
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
162
165
|
var handleReactPageRequest = async (pageComponent, index) => {
|
|
163
166
|
const page = createElement(pageComponent);
|
|
164
167
|
const stream = await renderToReadableStream(page, {
|
|
@@ -168,7 +171,7 @@ var handleReactPageRequest = async (pageComponent, index) => {
|
|
|
168
171
|
headers: { "Content-Type": "text/html" }
|
|
169
172
|
});
|
|
170
173
|
};
|
|
171
|
-
var handleHTMLPageRequest = (html) =>
|
|
174
|
+
var handleHTMLPageRequest = (html) => file(html);
|
|
172
175
|
// src/plugins/networkingPlugin.ts
|
|
173
176
|
import { argv } from "process";
|
|
174
177
|
var {env } = globalThis.Bun;
|
|
@@ -206,22 +209,28 @@ var networkingPlugin = (app) => app.listen({
|
|
|
206
209
|
console.log(`Server started on http://${host}:${port}`);
|
|
207
210
|
}
|
|
208
211
|
});
|
|
212
|
+
// src/plugins/pageRouterPlugin.ts
|
|
213
|
+
var pageRouterPlugin = () => {
|
|
214
|
+
console.log("Page Router Plugin Not Implemented Yet");
|
|
215
|
+
};
|
|
209
216
|
export {
|
|
210
217
|
updateScriptTags,
|
|
218
|
+
pageRouterPlugin,
|
|
211
219
|
networkingPlugin,
|
|
212
220
|
handleReactPageRequest,
|
|
213
221
|
handleHTMLPageRequest,
|
|
214
222
|
getLocalIPAddress,
|
|
215
223
|
build,
|
|
224
|
+
TWO_THIRDS,
|
|
216
225
|
TIME_PRECISION,
|
|
217
226
|
SECONDS_IN_A_MINUTE,
|
|
218
227
|
MINUTES_IN_AN_HOUR,
|
|
219
228
|
MILLISECONDS_IN_A_SECOND,
|
|
220
229
|
MILLISECONDS_IN_A_MINUTE,
|
|
221
230
|
MILLISECONDS_IN_A_DAY,
|
|
222
|
-
|
|
231
|
+
HOURS_IN_DAY,
|
|
223
232
|
DEFAULT_PORT
|
|
224
233
|
};
|
|
225
234
|
|
|
226
|
-
//# debugId=
|
|
235
|
+
//# debugId=91F881ADF50A880064756E2164756E21
|
|
227
236
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/constants.ts", "../src/core/build.ts", "../src/utils/updateScriptTags.ts", "../src/core/pageHandlers.ts", "../src/plugins/networkingPlugin.ts", "../src/utils/networking.ts"],
|
|
3
|
+
"sources": ["../src/constants.ts", "../src/core/build.ts", "../src/utils/updateScriptTags.ts", "../src/core/pageHandlers.ts", "../src/plugins/networkingPlugin.ts", "../src/utils/networking.ts", "../src/plugins/pageRouterPlugin.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export const SECONDS_IN_A_MINUTE = 60;\nexport const MILLISECONDS_IN_A_SECOND = 1000;\nexport const MILLISECONDS_IN_A_MINUTE =\n\tMILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;\nexport const MINUTES_IN_AN_HOUR = 60;\nexport const
|
|
6
|
-
"import { rm, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, basename } from \"node:path\";\nimport { cwd, exit } from \"node:process\";\nimport { $, build as bunBuild, Glob } from \"bun\";\nimport {\n\tMILLISECONDS_IN_A_MINUTE,\n\tMILLISECONDS_IN_A_SECOND,\n\tTIME_PRECISION\n} from \"../constants\";\nimport {
|
|
7
|
-
"
|
|
8
|
-
"import {
|
|
9
|
-
"import { argv } from \"node:process\";\nimport { env } from \"bun\";\nimport { Elysia } from \"elysia\";\nimport {
|
|
10
|
-
"import os from \"os\";\n\nexport const getLocalIPAddress = () => {\n\tconst interfaces = os.networkInterfaces();\n\tconst addresses = Object.values(interfaces)\n\t\t.flat()\n\t\t.filter(\n\t\t\t(iface): iface is os.NetworkInterfaceInfo => iface !== undefined\n\t\t);\n\tconst ipAddress = addresses.find(\n\t\t(iface) => iface.family === \"IPv4\" && !iface.internal\n\t);\n\n\tif (ipAddress) return ipAddress.address; // Return the first non-internal IPv4 address\n\n\tconsole.warn(\"No IP address found, falling back to localhost\");\n\n\treturn \"localhost\"; // Fallback to localhost if no IP found\n};\n"
|
|
5
|
+
"export const SECONDS_IN_A_MINUTE = 60;\nexport const MILLISECONDS_IN_A_SECOND = 1000;\nexport const MILLISECONDS_IN_A_MINUTE =\n\tMILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;\nexport const MINUTES_IN_AN_HOUR = 60;\nexport const HOURS_IN_DAY = 24;\nexport const MILLISECONDS_IN_A_DAY =\n\tMILLISECONDS_IN_A_SECOND *\n\tSECONDS_IN_A_MINUTE *\n\tMINUTES_IN_AN_HOUR *\n\tHOURS_IN_DAY;\nexport const TIME_PRECISION = 2;\nexport const TWO_THIRDS = 2 / 3;\nexport const DEFAULT_PORT = 3000;\n",
|
|
6
|
+
"import { rm, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, basename } from \"node:path\";\nimport { cwd, exit } from \"node:process\";\nimport { $, build as bunBuild, Glob } from \"bun\";\nimport {\n\tMILLISECONDS_IN_A_MINUTE,\n\tMILLISECONDS_IN_A_SECOND,\n\tTIME_PRECISION\n} from \"../constants\";\nimport { BuildConfig } from \"../types\";\nimport { updateScriptTags } from \"../utils/updateScriptTags\";\n\nexport const build = async ({\n\tbuildDirectory = \"build\",\n\tassetsDirectory,\n\treactDirectory,\n\thtmlDirectory,\n\thtmxDirectory,\n\ttailwind\n}: BuildConfig) => {\n\tconst start = performance.now();\n\n\tconst projectRoot = cwd();\n\tconst buildDirectoryAbsolute = join(projectRoot, buildDirectory);\n\tconst assetsDirectoryAbsolute =\n\t\tassetsDirectory && join(projectRoot, assetsDirectory);\n\tconst reactIndexesDirectory =\n\t\treactDirectory && join(projectRoot, reactDirectory, \"indexes\");\n\tconst reactPagesDirectory =\n\t\treactDirectory && join(projectRoot, reactDirectory, \"pages\");\n\tconst htmlPagesDirectory =\n\t\thtmlDirectory && join(projectRoot, htmlDirectory, \"pages\");\n\tconst htmlScriptsDirectory =\n\t\thtmlDirectory && join(projectRoot, htmlDirectory, \"scripts\");\n\tconst htmxDirectoryAbsolute =\n\t\thtmxDirectory && join(projectRoot, htmxDirectory);\n\n\tawait rm(buildDirectoryAbsolute, { force: true, recursive: true });\n\tawait mkdir(buildDirectoryAbsolute);\n\n\tvoid (\n\t\treactPagesDirectory &&\n\t\treactIndexesDirectory &&\n\t\t(await generateReactIndexFiles(\n\t\t\treactPagesDirectory,\n\t\t\treactIndexesDirectory\n\t\t))\n\t);\n\n\tvoid (\n\t\tassetsDirectoryAbsolute &&\n\t\t(await $`cp -R ${assetsDirectoryAbsolute} ${buildDirectoryAbsolute}`)\n\t);\n\n\tif (htmlPagesDirectory) {\n\t\tawait mkdir(join(buildDirectoryAbsolute, \"html\", \"pages\"), {\n\t\t\trecursive: true\n\t\t});\n\t\tawait $`cp -R ${htmlPagesDirectory} ${join(buildDirectoryAbsolute, \"html\")}`;\n\t}\n\n\tif (htmxDirectoryAbsolute) {\n\t\tawait mkdir(join(buildDirectoryAbsolute, \"htmx\"));\n\t\tawait $`cp -R ${htmxDirectoryAbsolute} ${join(buildDirectoryAbsolute)}`;\n\t}\n\n\tif (tailwind) {\n\t\tawait $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join(buildDirectoryAbsolute, tailwind.output)}`;\n\t}\n\n\tconst reactEntryPaths =\n\t\treactIndexesDirectory &&\n\t\t(await scanEntryPoints(reactIndexesDirectory, \"*.tsx\"));\n\n\tconst htmlEntryPaths =\n\t\thtmlScriptsDirectory &&\n\t\t(await scanEntryPoints(htmlScriptsDirectory, \"*.{js,ts}\"));\n\n\tconst entryPaths = [...(reactEntryPaths || []), ...(htmlEntryPaths || [])];\n\n\tif (entryPaths.length === 0) {\n\t\tconsole.warn(\"No entry points found, skipping building manifest\");\n\n\t\treturn null;\n\t}\n\n\tconst { logs, outputs } = await bunBuild({\n\t\tentrypoints: entryPaths,\n\t\tformat: \"esm\",\n\t\tnaming: `[dir]/[name].[hash].[ext]`,\n\t\toutdir: buildDirectoryAbsolute,\n\t\ttarget: \"bun\"\n\t}).catch((error) => {\n\t\tconsole.error(\"Build failed:\", error);\n\t\texit(1);\n\t});\n\n\tlogs.forEach((log) => {\n\t\tif (log.level === \"error\") console.error(log);\n\t\telse if (log.level === \"warning\") console.warn(log);\n\t\telse if (log.level === \"info\" || log.level === \"debug\")\n\t\t\tconsole.info(log);\n\t});\n\n\tconst manifest = outputs.reduce<Record<string, string>>((acc, artifact) => {\n\t\tlet relativePath = artifact.path;\n\n\t\tif (relativePath.startsWith(buildDirectoryAbsolute)) {\n\t\t\trelativePath = relativePath.slice(buildDirectoryAbsolute.length);\n\t\t}\n\n\t\trelativePath = relativePath.replace(/^\\/+/, \"\");\n\n\t\tconst baseName = relativePath.split(\"/\").pop();\n\t\tif (!baseName) return acc;\n\n\t\tconst hashDelimiter = `.${artifact.hash}.`;\n\t\tif (!baseName.includes(hashDelimiter)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected hash delimiter ${hashDelimiter} in ${baseName}`\n\t\t\t);\n\t\t}\n\n\t\tconst [fileName] = baseName.split(hashDelimiter);\n\t\tacc[fileName] = `/${relativePath}`;\n\n\t\treturn acc;\n\t}, {});\n\n\tvoid (\n\t\thtmlPagesDirectory &&\n\t\t(await updateScriptTags(\n\t\t\tmanifest,\n\t\t\tjoin(buildDirectoryAbsolute, \"html\", \"pages\")\n\t\t))\n\t);\n\n\tconst end = performance.now();\n\tconst durationMs = end - start;\n\tlet duration;\n\tif (durationMs < MILLISECONDS_IN_A_SECOND) {\n\t\tduration = `${durationMs.toFixed(TIME_PRECISION)}ms`;\n\t} else if (durationMs < MILLISECONDS_IN_A_MINUTE) {\n\t\tduration = `${(durationMs / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;\n\t} else {\n\t\tduration = `${(durationMs / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;\n\t}\n\tconsole.log(`Build completed in ${duration}`);\n\n\treturn manifest;\n};\n\nconst generateReactIndexFiles = async (\n\treactPagesDirectory: string,\n\treactIndexesDirectory: string\n) => {\n\tawait rm(reactIndexesDirectory, { force: true, recursive: true });\n\tawait mkdir(reactIndexesDirectory);\n\n\tconst pagesGlob = new Glob(\"*.*\");\n\tconst files: string[] = [];\n\tfor await (const file of pagesGlob.scan({ cwd: reactPagesDirectory })) {\n\t\tfiles.push(file);\n\t}\n\tconst promises = files.map(async (file) => {\n\t\tconst fileName = basename(file);\n\t\tconst [componentName] = fileName.split(\".\");\n\t\tconst content = [\n\t\t\t`import { hydrateRoot } from 'react-dom/client';`,\n\t\t\t`import { ${componentName} } from '../pages/${componentName}';\\n`,\n\t\t\t`hydrateRoot(document, <${componentName} />);`\n\t\t].join(\"\\n\");\n\n\t\treturn writeFile(\n\t\t\tjoin(reactIndexesDirectory, `${componentName}Index.tsx`),\n\t\t\tcontent\n\t\t);\n\t});\n\tawait Promise.all(promises);\n};\n\nconst scanEntryPoints = async (dir: string, pattern: string) => {\n\tconst entryPaths: string[] = [];\n\tconst glob = new Glob(pattern);\n\tfor await (const file of glob.scan({ absolute: true, cwd: dir })) {\n\t\tentryPaths.push(file);\n\t}\n\n\treturn entryPaths;\n};\n",
|
|
7
|
+
"import { readFile, writeFile } from \"node:fs/promises\";\nimport { Glob } from \"bun\";\n\nexport const updateScriptTags = async (\n\tmanifest: Record<string, string>,\n\thtmlDir: string\n) => {\n\tconst glob = new Glob(\"*.html\");\n\tconst htmlFiles: string[] = [];\n\tconst fileIterator = glob.scan({ absolute: true, cwd: htmlDir });\n\tfor await (const filePath of fileIterator) {\n\t\thtmlFiles.push(filePath);\n\t}\n\n\tconst tasks = htmlFiles.map(async (filePath) => {\n\t\tconst original = await readFile(filePath, \"utf8\");\n\t\tconst updated = Object.entries(manifest).reduce(\n\t\t\t(html, [scriptName, newPath]) => {\n\t\t\t\tconst esc = scriptName.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t\t\t\tconst regex = new RegExp(\n\t\t\t\t\t`(<script[^>]+src=[\"'])(/?(?:.*/)?${esc})(?:\\\\.[^.\"'/]+)?(\\\\.js)([\"'][^>]*>)`,\n\t\t\t\t\t\"g\"\n\t\t\t\t);\n\n\t\t\t\treturn html.replace(\n\t\t\t\t\tregex,\n\t\t\t\t\t(_, prefix, __, ___, suffix) =>\n\t\t\t\t\t\t`${prefix}${newPath}${suffix}`\n\t\t\t\t);\n\t\t\t},\n\t\t\toriginal\n\t\t);\n\n\t\tawait writeFile(filePath, updated, \"utf8\");\n\t});\n\n\tawait Promise.all(tasks);\n};\n",
|
|
8
|
+
"import { file } from \"bun\";\nimport { ComponentType, createElement } from \"react\";\nimport { renderToReadableStream } from \"react-dom/server\";\n\nexport const handleReactPageRequest = async (\n\tpageComponent: ComponentType,\n\tindex: string\n) => {\n\tconst page = createElement(pageComponent);\n\tconst stream = await renderToReadableStream(page, {\n\t\tbootstrapModules: [index]\n\t});\n\n\treturn new Response(stream, {\n\t\theaders: { \"Content-Type\": \"text/html\" }\n\t});\n};\n\nexport const handleHTMLPageRequest = (html: string) => file(html);\n",
|
|
9
|
+
"import { argv } from \"node:process\";\nimport { env } from \"bun\";\nimport { Elysia } from \"elysia\";\nimport { DEFAULT_PORT } from \"../constants\";\nimport { getLocalIPAddress } from \"../utils/networking\";\n\nlet host = env.HOST ?? \"localhost\";\nconst port = env.PORT ?? DEFAULT_PORT;\nlet localIP: string | undefined;\n\nconst args = argv;\nconst hostFlag = args.includes(\"--host\");\n\nif (hostFlag) {\n\tlocalIP = getLocalIPAddress();\n\thost = \"0.0.0.0\";\n}\n\nexport const networkingPlugin = (app: Elysia) =>\n\tapp.listen(\n\t\t{\n\t\t\thostname: host,\n\t\t\tport: port\n\t\t},\n\t\t() => {\n\t\t\t//TODO: I dont think this works properly\n\t\t\tif (hostFlag) {\n\t\t\t\tconsole.log(`Server started on http://localhost:${port}`);\n\t\t\t\tconsole.log(\n\t\t\t\t\t`Server started on network: http://${localIP}:${port}`\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.log(`Server started on http://${host}:${port}`);\n\t\t\t}\n\t\t}\n\t);\n",
|
|
10
|
+
"import os from \"os\";\n\nexport const getLocalIPAddress = () => {\n\tconst interfaces = os.networkInterfaces();\n\tconst addresses = Object.values(interfaces)\n\t\t.flat()\n\t\t.filter(\n\t\t\t(iface): iface is os.NetworkInterfaceInfo => iface !== undefined\n\t\t);\n\tconst ipAddress = addresses.find(\n\t\t(iface) => iface.family === \"IPv4\" && !iface.internal\n\t);\n\n\tif (ipAddress) return ipAddress.address; // Return the first non-internal IPv4 address\n\n\tconsole.warn(\"No IP address found, falling back to localhost\");\n\n\treturn \"localhost\"; // Fallback to localhost if no IP found\n};\n",
|
|
11
|
+
"export const pageRouterPlugin = () => {\n\tconsole.log(\"Page Router Plugin Not Implemented Yet\");\n};\n"
|
|
11
12
|
],
|
|
12
|
-
"mappings": ";;AAAO,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,2BACZ,2BAA2B;AACrB,IAAM,qBAAqB;AAC3B,IAAM,
|
|
13
|
-
"debugId": "
|
|
13
|
+
"mappings": ";;AAAO,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AACjC,IAAM,2BACZ,2BAA2B;AAC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Q,IAAI,wCAAwC;AAAA;",
|
|
14
|
+
"debugId": "91F881ADF50A880064756E2164756E21",
|
|
14
15
|
"names": []
|
|
15
16
|
}
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export declare const SECONDS_IN_A_MINUTE = 60;
|
|
|
2
2
|
export declare const MILLISECONDS_IN_A_SECOND = 1000;
|
|
3
3
|
export declare const MILLISECONDS_IN_A_MINUTE: number;
|
|
4
4
|
export declare const MINUTES_IN_AN_HOUR = 60;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const HOURS_IN_DAY = 24;
|
|
6
6
|
export declare const MILLISECONDS_IN_A_DAY: number;
|
|
7
7
|
export declare const TIME_PRECISION = 2;
|
|
8
|
+
export declare const TWO_THIRDS: number;
|
|
8
9
|
export declare const DEFAULT_PORT = 3000;
|
package/dist/src/core/build.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BuildConfig } from "../types";
|
|
2
|
-
export declare const build: ({ buildDirectory, assetsDirectory, reactDirectory,
|
|
2
|
+
export declare const build: ({ buildDirectory, assetsDirectory, reactDirectory, htmlDirectory, htmxDirectory, tailwind }: BuildConfig) => Promise<Record<string, string> | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const pageRouterPlugin: () => void;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type HTMLScriptOption = "ts" | "js" | "ts+ssr" | "js+ssr" | undefined;
|
|
2
1
|
export type BuildConfig = {
|
|
3
2
|
buildDirectory?: string;
|
|
4
3
|
assetsDirectory?: string;
|
|
@@ -7,10 +6,7 @@ export type BuildConfig = {
|
|
|
7
6
|
angularDirectory?: string;
|
|
8
7
|
astroDirectory?: string;
|
|
9
8
|
svelteDirectory?: string;
|
|
10
|
-
|
|
11
|
-
directory?: string;
|
|
12
|
-
scriptingOption: HTMLScriptOption;
|
|
13
|
-
};
|
|
9
|
+
htmlDirectory?: string;
|
|
14
10
|
htmxDirectory?: string;
|
|
15
11
|
tailwind?: {
|
|
16
12
|
input: string;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Updates <script> tags in all HTML files within htmlDir.
|
|
3
|
-
* For each script tag whose src file base (with or without a hash) is a key in the manifest,
|
|
4
|
-
* the src attribute is replaced with the new hashed file path.
|
|
5
|
-
*
|
|
6
|
-
* @param manifest - An object mapping script base names to the new file path.
|
|
7
|
-
* @param htmlDir - The directory that contains the HTML files.
|
|
8
|
-
*/
|
|
9
1
|
export declare const updateScriptTags: (manifest: Record<string, string>, htmlDir: string) => Promise<void>;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// eslint.config.mjs
|
|
2
|
+
import { dirname } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import pluginJs from "@eslint/js";
|
|
5
|
+
import stylisticTs from "@stylistic/eslint-plugin-ts";
|
|
6
|
+
import tsParser from "@typescript-eslint/parser";
|
|
7
|
+
import { defineConfig } from "eslint/config";
|
|
8
|
+
import absolutePlugin from "eslint-plugin-absolute";
|
|
9
|
+
import importPlugin from "eslint-plugin-import";
|
|
10
|
+
import promisePlugin from "eslint-plugin-promise";
|
|
11
|
+
import securityPlugin from "eslint-plugin-security";
|
|
12
|
+
import globals from "globals";
|
|
13
|
+
import tseslint from "typescript-eslint";
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
|
|
17
|
+
export default defineConfig([
|
|
18
|
+
{
|
|
19
|
+
ignores: [
|
|
20
|
+
"dist/**",
|
|
21
|
+
"example/build/**",
|
|
22
|
+
"tailwind.config.ts",
|
|
23
|
+
"postcss.config.ts"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
pluginJs.configs.recommended,
|
|
28
|
+
|
|
29
|
+
...tseslint.configs.recommended,
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
files: ["**/*.{ts,tsx}"],
|
|
33
|
+
languageOptions: {
|
|
34
|
+
globals: globals.browser,
|
|
35
|
+
parser: tsParser,
|
|
36
|
+
parserOptions: {
|
|
37
|
+
createDefaultProgram: true,
|
|
38
|
+
project: "./tsconfig.json",
|
|
39
|
+
tsconfigRootDir: __dirname
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
files: ["**/*.{ts,tsx}"],
|
|
46
|
+
plugins: { "@stylistic/ts": stylisticTs },
|
|
47
|
+
rules: {
|
|
48
|
+
"@stylistic/ts/padding-line-between-statements": [
|
|
49
|
+
"error",
|
|
50
|
+
{ blankLine: "always", next: "return", prev: "*" }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
files: ["**/*.{js,mjs,cjs,ts,tsx,jsx}"],
|
|
57
|
+
ignores: ["node_modules/**"],
|
|
58
|
+
languageOptions: {
|
|
59
|
+
globals: globals.browser
|
|
60
|
+
},
|
|
61
|
+
plugins: {
|
|
62
|
+
absolute: absolutePlugin,
|
|
63
|
+
import: importPlugin,
|
|
64
|
+
promise: promisePlugin,
|
|
65
|
+
security: securityPlugin
|
|
66
|
+
},
|
|
67
|
+
rules: {
|
|
68
|
+
"absolute/explicit-object-types": "error",
|
|
69
|
+
"absolute/localize-react-props": "error",
|
|
70
|
+
"absolute/max-depth-extended": ["error", 1],
|
|
71
|
+
"absolute/max-jsxnesting": ["error", 5],
|
|
72
|
+
"absolute/min-var-length": [
|
|
73
|
+
"error",
|
|
74
|
+
{ allowedVars: ["_", "id", "db", "OK"], minLength: 3 }
|
|
75
|
+
],
|
|
76
|
+
"absolute/no-explicit-return-type": "error",
|
|
77
|
+
"absolute/no-type-cast": "error",
|
|
78
|
+
"absolute/no-useless-function": "error",
|
|
79
|
+
"absolute/sort-exports": [
|
|
80
|
+
"error",
|
|
81
|
+
{
|
|
82
|
+
caseSensitive: true,
|
|
83
|
+
natural: true,
|
|
84
|
+
order: "asc",
|
|
85
|
+
variablesBeforeFunctions: true
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"absolute/sort-keys-fixable": [
|
|
89
|
+
"error",
|
|
90
|
+
{
|
|
91
|
+
caseSensitive: true,
|
|
92
|
+
natural: true,
|
|
93
|
+
order: "asc",
|
|
94
|
+
variablesBeforeFunctions: true
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
98
|
+
"consistent-return": "error",
|
|
99
|
+
eqeqeq: "error",
|
|
100
|
+
"func-style": [
|
|
101
|
+
"error",
|
|
102
|
+
"expression",
|
|
103
|
+
{ allowArrowFunctions: true }
|
|
104
|
+
],
|
|
105
|
+
"import/no-cycle": "error",
|
|
106
|
+
"import/no-default-export": "error",
|
|
107
|
+
"import/no-relative-packages": "error",
|
|
108
|
+
"import/no-unused-modules": ["error", { missingExports: true }],
|
|
109
|
+
"import/order": ["error", { alphabetize: { order: "asc" } }],
|
|
110
|
+
"no-await-in-loop": "error",
|
|
111
|
+
"no-debugger": "error",
|
|
112
|
+
"no-duplicate-case": "error",
|
|
113
|
+
"no-duplicate-imports": "error",
|
|
114
|
+
"no-else-return": "error",
|
|
115
|
+
"no-empty-function": "error",
|
|
116
|
+
"no-empty-pattern": "error",
|
|
117
|
+
"no-empty-static-block": "error",
|
|
118
|
+
"no-fallthrough": "error",
|
|
119
|
+
"no-floating-decimal": "error",
|
|
120
|
+
"no-global-assign": "error",
|
|
121
|
+
"no-implicit-coercion": "error",
|
|
122
|
+
"no-implicit-globals": "error",
|
|
123
|
+
"no-loop-func": "error",
|
|
124
|
+
"no-magic-numbers": [
|
|
125
|
+
"warn",
|
|
126
|
+
{ detectObjects: false, enforceConst: true, ignore: [0, 1, 2] }
|
|
127
|
+
],
|
|
128
|
+
"no-misleading-character-class": "error",
|
|
129
|
+
"no-nested-ternary": "error",
|
|
130
|
+
"no-new-native-nonconstructor": "error",
|
|
131
|
+
"no-new-wrappers": "error",
|
|
132
|
+
"no-param-reassign": "error",
|
|
133
|
+
"no-restricted-imports": [
|
|
134
|
+
"error",
|
|
135
|
+
{
|
|
136
|
+
paths: [
|
|
137
|
+
{
|
|
138
|
+
importNames: ["default"],
|
|
139
|
+
message:
|
|
140
|
+
"Import only named React exports for tree-shaking.",
|
|
141
|
+
name: "react"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
importNames: ["default"],
|
|
145
|
+
message: "Import only the required Bun exports.",
|
|
146
|
+
name: "bun"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"no-return-await": "error",
|
|
152
|
+
"no-shadow": "error",
|
|
153
|
+
"no-undef": "error",
|
|
154
|
+
"no-unneeded-ternary": "error",
|
|
155
|
+
"no-unreachable": "error",
|
|
156
|
+
"no-useless-assignment": "error",
|
|
157
|
+
"no-useless-concat": "error",
|
|
158
|
+
"no-useless-return": "error",
|
|
159
|
+
"no-var": "error",
|
|
160
|
+
"prefer-arrow-callback": "error",
|
|
161
|
+
"prefer-const": "error",
|
|
162
|
+
"prefer-destructuring": [
|
|
163
|
+
"error",
|
|
164
|
+
{ array: true, object: true },
|
|
165
|
+
{ enforceForRenamedProperties: false }
|
|
166
|
+
],
|
|
167
|
+
"prefer-template": "error",
|
|
168
|
+
"promise/always-return": "warn",
|
|
169
|
+
"promise/avoid-new": "warn",
|
|
170
|
+
"promise/catch-or-return": "error",
|
|
171
|
+
"promise/no-callback-in-promise": "warn",
|
|
172
|
+
"promise/no-nesting": "warn",
|
|
173
|
+
"promise/no-promise-in-callback": "warn",
|
|
174
|
+
"promise/no-return-wrap": "error",
|
|
175
|
+
"promise/param-names": "error"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
files: ["eslint.config.mjs", "src/constants.ts"],
|
|
180
|
+
rules: {
|
|
181
|
+
"no-magic-numbers": "off"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
files: ["eslint.config.mjs"],
|
|
186
|
+
rules: {
|
|
187
|
+
"import/no-default-export": "off"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
files: [
|
|
192
|
+
"src/utils/index.ts",
|
|
193
|
+
"src/plugins/index.ts",
|
|
194
|
+
"src/core/index.ts",
|
|
195
|
+
"src/index.ts",
|
|
196
|
+
"example/**/indexes/*",
|
|
197
|
+
"example/html/scripts/*"
|
|
198
|
+
],
|
|
199
|
+
rules: {
|
|
200
|
+
"import/no-unused-modules": "off"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absolutejs/absolute",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A fullstack meta-framework for building web applications with TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "rm -rf dist && bun build src/index.ts --outdir dist --sourcemap --target=bun --external react --external react-dom --external elysia && tsc --emitDeclarationOnly --project tsconfig.json",
|
|
15
15
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
|
-
"format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css,json}\"",
|
|
16
|
+
"format": "prettier --write \"./**/*.{js,jsx,ts,tsx,css,json,mjs,md}\"",
|
|
17
|
+
"lint": "eslint ./",
|
|
18
|
+
"typecheck": "bun run tsc --noEmit",
|
|
17
19
|
"dev": "bun run --watch example/server.ts",
|
|
18
20
|
"release": "bun run format && bun run build && bun publish"
|
|
19
21
|
},
|
|
@@ -37,6 +39,13 @@
|
|
|
37
39
|
"svelte": "4.2.15",
|
|
38
40
|
"tailwindcss": "4.1.7",
|
|
39
41
|
"typescript": "5.7.2",
|
|
40
|
-
"vue": "3.4.26"
|
|
42
|
+
"vue": "3.4.26",
|
|
43
|
+
"@stylistic/eslint-plugin-ts": "4.2.0",
|
|
44
|
+
"eslint": "9.26.0",
|
|
45
|
+
"eslint-plugin-absolute": "0.0.3",
|
|
46
|
+
"eslint-plugin-import": "2.31.0",
|
|
47
|
+
"eslint-plugin-promise": "7.2.1",
|
|
48
|
+
"eslint-plugin-security": "3.0.1",
|
|
49
|
+
"typescript-eslint": "8.32.0"
|
|
41
50
|
}
|
|
42
51
|
}
|