Upload 3 files
Browse files- exocore-web/build.js +92 -0
- exocore-web/index.js +0 -0
- exocore-web/tsconfig.json +21 -0
exocore-web/build.js
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const path = require('path');
|
3 |
+
const axios = require('axios');
|
4 |
+
const { build } = require('esbuild');
|
5 |
+
const { solidPlugin } = require('esbuild-plugin-solid');
|
6 |
+
|
7 |
+
const publicDir = path.resolve(__dirname, 'public');
|
8 |
+
const publicDirSrc = path.resolve(publicDir, 'src');
|
9 |
+
|
10 |
+
if (!fs.existsSync(publicDirSrc)) {
|
11 |
+
fs.mkdirSync(publicDirSrc, { recursive: true });
|
12 |
+
}
|
13 |
+
|
14 |
+
let lastTimestamps = {};
|
15 |
+
|
16 |
+
function getJSXFiles() {
|
17 |
+
return fs.readdirSync(publicDir)
|
18 |
+
.filter(file => file.endsWith('.jsx'))
|
19 |
+
.map(file => path.join(publicDir, file));
|
20 |
+
}
|
21 |
+
|
22 |
+
async function buildJSX(entryPoints) {
|
23 |
+
try {
|
24 |
+
await build({
|
25 |
+
entryPoints,
|
26 |
+
outdir: publicDirSrc,
|
27 |
+
bundle: true,
|
28 |
+
format: 'esm',
|
29 |
+
plugins: [solidPlugin()],
|
30 |
+
jsx: 'automatic',
|
31 |
+
jsxImportSource: 'solid-js',
|
32 |
+
minify: false,
|
33 |
+
sourcemap: true,
|
34 |
+
splitting: false,
|
35 |
+
treeShaking: true,
|
36 |
+
logLevel: 'silent',
|
37 |
+
});
|
38 |
+
} catch (err) {}
|
39 |
+
}
|
40 |
+
|
41 |
+
function hasChanged(files) {
|
42 |
+
let changed = false;
|
43 |
+
for (const file of files) {
|
44 |
+
const stat = fs.statSync(file);
|
45 |
+
const last = lastTimestamps[file] || 0;
|
46 |
+
if (stat.mtimeMs > last) {
|
47 |
+
lastTimestamps[file] = stat.mtimeMs;
|
48 |
+
changed = true;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
return changed;
|
52 |
+
}
|
53 |
+
|
54 |
+
async function downloadMainAndPackage() {
|
55 |
+
try {
|
56 |
+
const mainUrl = 'https://raw.githubusercontent.com/Exocore-Organization/exocore-web/main/main.js';
|
57 |
+
const packageUrl = 'https://raw.githubusercontent.com/Exocore-Organization/exocore-web/refs/heads/main/package.json';
|
58 |
+
|
59 |
+
const mainPath = path.join(__dirname, '../main.js');
|
60 |
+
const packagePath = path.join(__dirname, '../package.json');
|
61 |
+
|
62 |
+
const [mainResponse, pkgResponse] = await Promise.all([
|
63 |
+
axios.get(mainUrl),
|
64 |
+
axios.get(packageUrl),
|
65 |
+
]);
|
66 |
+
|
67 |
+
fs.writeFileSync(mainPath, mainResponse.data, 'utf8');
|
68 |
+
console.log("✅ main.js successfully saved to ../main.js");
|
69 |
+
|
70 |
+
fs.writeFileSync(packagePath, JSON.stringify(pkgResponse.data, null, 2), 'utf8');
|
71 |
+
console.log("✅ package.json successfully saved to ../package.json");
|
72 |
+
} catch (err) {
|
73 |
+
console.error("❌ Failed to download main.js or package.json:", err.message);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
(async () => {
|
78 |
+
await downloadMainAndPackage();
|
79 |
+
|
80 |
+
const jsxFiles = getJSXFiles();
|
81 |
+
if (jsxFiles.length === 0) return;
|
82 |
+
|
83 |
+
console.log(`[ESBuild] JSX loaded: ${jsxFiles.length} files.`);
|
84 |
+
await buildJSX(jsxFiles);
|
85 |
+
|
86 |
+
setInterval(async () => {
|
87 |
+
const files = getJSXFiles();
|
88 |
+
if (hasChanged(files)) {
|
89 |
+
await buildJSX(files);
|
90 |
+
}
|
91 |
+
}, 1000);
|
92 |
+
})();
|
exocore-web/index.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
exocore-web/tsconfig.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "ESNEXT",
|
4 |
+
"module": "CommonJS",
|
5 |
+
"allowJs": true,
|
6 |
+
"checkJs": true,
|
7 |
+
"noEmit": true,
|
8 |
+
"esModuleInterop": true,
|
9 |
+
"resolveJsonModule": true,
|
10 |
+
"types": ["node"],
|
11 |
+
"strict": true,
|
12 |
+
"strictNullChecks": true,
|
13 |
+
"noUncheckedIndexedAccess": true,
|
14 |
+
"noUnusedLocals": true,
|
15 |
+
"noImplicitAny": true,
|
16 |
+
"moduleResolution": "Node",
|
17 |
+
"typeRoots": ["./node_modules/@types"],
|
18 |
+
"jsx": "preserve",
|
19 |
+
"jsxImportSource": "solid-js"
|
20 |
+
}
|
21 |
+
}
|