xplorajs 0.1.8 → 0.1.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/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.js +12 -9
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.js +29 -16
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +22 -6
- package/dist/commands/start.js.map +1 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const { Command } = require("commander");
|
|
3
|
+
const { build } = require("./commands/build");
|
|
4
|
+
const { dev } = require("./commands/dev");
|
|
5
|
+
const { start } = require("./commands/start");
|
|
6
6
|
const program = new Command();
|
|
7
7
|
program.name("xplorajs").description("Xplora.js CLI tool").version("0.0.0");
|
|
8
8
|
program.command("dev").description("Start development server").action(dev);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nconst { Command } = require(\"commander\");\nconst { build } = require(\"./commands/build\");\nconst { dev } = require(\"./commands/dev\");\nconst { start } = require(\"./commands/start\");\n\nconst program = new Command();\n\nprogram.name(\"xplorajs\").description(\"Xplora.js CLI tool\").version(\"0.0.0\");\n\nprogram.command(\"dev\").description(\"Start development server\").action(dev);\n\nprogram.command(\"build\").description(\"Build for production\").action(build);\n\nprogram.command(\"start\").description(\"Start production server\").action(start);\n\nprogram.parse();\n"],"names":["Command","require","build","dev","start","program","name","description","version","command","action","parse"],"mappings":";AACA,MAAM,EAAEA,OAAO,EAAE,GAAGC,QAAQ;AAC5B,MAAM,EAAEC,KAAK,EAAE,GAAGD,QAAQ;AAC1B,MAAM,EAAEE,GAAG,EAAE,GAAGF,QAAQ;AACxB,MAAM,EAAEG,KAAK,EAAE,GAAGH,QAAQ;AAE1B,MAAMI,UAAU,IAAIL;AAEpBK,QAAQC,IAAI,CAAC,YAAYC,WAAW,CAAC,sBAAsBC,OAAO,CAAC;AAEnEH,QAAQI,OAAO,CAAC,OAAOF,WAAW,CAAC,4BAA4BG,MAAM,CAACP;AAEtEE,QAAQI,OAAO,CAAC,SAASF,WAAW,CAAC,wBAAwBG,MAAM,CAACR;AAEpEG,QAAQI,OAAO,CAAC,SAASF,WAAW,CAAC,2BAA2BG,MAAM,CAACN;AAEvEC,QAAQM,KAAK"}
|
package/dist/commands/build.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const { mkdir, readFile, writeFile } = require("node:fs/promises");
|
|
2
|
+
const { dirname, join } = require("node:path");
|
|
3
|
+
const { glob } = require("fast-glob");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const { generateStaticPage } = require("xplorajs-react");
|
|
6
6
|
function convertToRoute(filePath) {
|
|
7
7
|
const relativePath = filePath.replace("src/app/", "");
|
|
8
8
|
const path = relativePath.replace(/\.tsx$/, "").replace(/\/page$/, "").replace(/\[([^\]]+)\]/g, ":$1");
|
|
@@ -16,9 +16,9 @@ function convertToRoute(filePath) {
|
|
|
16
16
|
}
|
|
17
17
|
async function processPage(page, route) {
|
|
18
18
|
try {
|
|
19
|
-
const
|
|
20
|
-
const PageComponent =
|
|
21
|
-
const getStaticProps =
|
|
19
|
+
const module1 = await import(join(process.cwd(), page));
|
|
20
|
+
const PageComponent = module1.default;
|
|
21
|
+
const getStaticProps = module1.getStaticProps;
|
|
22
22
|
let props = {};
|
|
23
23
|
if (getStaticProps) {
|
|
24
24
|
const result = await getStaticProps();
|
|
@@ -35,7 +35,7 @@ async function processPage(page, route) {
|
|
|
35
35
|
console.error(`Error processing ${page}:`, error);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
async function build() {
|
|
39
39
|
console.log("Building application...");
|
|
40
40
|
await mkdir(join(process.cwd(), "dist"), {
|
|
41
41
|
recursive: true
|
|
@@ -59,5 +59,8 @@ export async function build() {
|
|
|
59
59
|
console.log("Build completed!");
|
|
60
60
|
console.log("Routes:", routes.map((r)=>r.path).join("\n"));
|
|
61
61
|
}
|
|
62
|
+
module.exports = {
|
|
63
|
+
build
|
|
64
|
+
};
|
|
62
65
|
|
|
63
66
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["const { mkdir, readFile, writeFile } = require(\"node:fs/promises\");\nconst { dirname, join } = require(\"node:path\");\nconst { glob } = require(\"fast-glob\");\nconst React = require(\"react\");\nconst { generateStaticPage } = require(\"xplorajs-react\");\n\ninterface Route {\n\tpath: string;\n\tfile: string;\n\tisDynamic: boolean;\n\tparams: string[];\n}\n\nfunction convertToRoute(filePath: string): Route {\n\tconst relativePath = filePath.replace(\"src/app/\", \"\");\n\tconst path = relativePath\n\t\t.replace(/\\.tsx$/, \"\")\n\t\t.replace(/\\/page$/, \"\")\n\t\t.replace(/\\[([^\\]]+)\\]/g, \":$1\");\n\n\tconst params = (relativePath.match(/\\[([^\\]]+)\\]/g) || []).map((param) =>\n\t\tparam.slice(1, -1),\n\t);\n\n\treturn {\n\t\tpath: path === \"page\" ? \"/\" : `/${path}`,\n\t\tfile: filePath,\n\t\tisDynamic: params.length > 0,\n\t\tparams,\n\t};\n}\n\nasync function processPage(page: string, route: Route) {\n\ttry {\n\t\tconst module = await import(join(process.cwd(), page));\n\t\tconst PageComponent = module.default;\n\n\t\tconst getStaticProps = module.getStaticProps;\n\t\tlet props = {};\n\n\t\tif (getStaticProps) {\n\t\t\tconst result = await getStaticProps();\n\t\t\tprops = result.props;\n\t\t}\n\n\t\tconst outputPath = join(process.cwd(), \"dist\", route.path, \"index.html\");\n\t\tawait generateStaticPage({\n\t\t\tcomponent: React.createElement(PageComponent, props),\n\t\t\toutputPath,\n\t\t\tprops,\n\t\t});\n\n\t\tconsole.log(`Generated ${outputPath}`);\n\t} catch (error) {\n\t\tconsole.error(`Error processing ${page}:`, error);\n\t}\n}\n\nasync function build() {\n\tconsole.log(\"Building application...\");\n\n\tawait mkdir(join(process.cwd(), \"dist\"), { recursive: true });\n\n\tconst pages = await glob(\"src/app/**/*.tsx\", {\n\t\tignore: [\"**/node_modules/**\"],\n\t});\n\n\tconst routes: Route[] = [];\n\n\tfor (const page of pages) {\n\t\tconst route = convertToRoute(page);\n\t\troutes.push(route);\n\t\tawait processPage(page, route);\n\t}\n\n\tconst routesConfig = {\n\t\troutes,\n\t\tgeneratedAt: new Date().toISOString(),\n\t};\n\n\tawait writeFile(\n\t\tjoin(process.cwd(), \".xplora\", \"routes.json\"),\n\t\tJSON.stringify(routesConfig, null, 2),\n\t);\n\n\tconsole.log(\"Build completed!\");\n\tconsole.log(\"Routes:\", routes.map((r) => r.path).join(\"\\n\"));\n}\n\nmodule.exports = { build };\n"],"names":["mkdir","readFile","writeFile","require","dirname","join","glob","React","generateStaticPage","convertToRoute","filePath","relativePath","replace","path","params","match","map","param","slice","file","isDynamic","length","processPage","page","route","module","process","cwd","PageComponent","default","getStaticProps","props","result","outputPath","component","createElement","console","log","error","build","recursive","pages","ignore","routes","push","routesConfig","generatedAt","Date","toISOString","JSON","stringify","r","exports"],"mappings":"AAAA,MAAM,EAAEA,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,QAAQ;AAC/C,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAE,GAAGF,QAAQ;AAClC,MAAM,EAAEG,IAAI,E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AQC,GAAG,IAAI,SAAS;QAAEa,WAAW;IAAK;IAE3D,MAAMC,QAAQ,MAAMnC,KAAK,oBAAoB;QAC5CoC,QAAQ;YAAC;SAAqB;IAC/B;IAEA,MAAMC,SAAkB,EAAE;IAE1B,KAAK,MAAMpB,QAAQkB,MAAO;QACzB,MAAMjB,QAAQf,eAAec;QAC7BoB,OAAOC,IAAI,CAACpB;QACZ,MAAMF,YAAYC,MAAMC;IACzB;IAEA,MAAMqB,eAAe;QACpBF;QACAG,aAAa,IAAIC,OAAOC,WAAW;IACpC;IAEA,MAAM9C,UACLG,KAAKqB,QAAQC,GAAG,IAAI,WAAW,gBAC/BsB,KAAKC,SAAS,CAACL,cAAc,MAAM;IAGpCT,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC,WAAWM,OAAO3B,GAAG,CAAC,CAACmC,IAAMA,EAAEtC,IAAI,EAAER,IAAI,CAAC;AACvD;AAEAoB,OAAO2B,OAAO,GAAG;IAAEb;AAAM"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const { readFileSync } = require("node:fs");
|
|
2
|
+
const { join } = require("node:path");
|
|
3
|
+
const { serve } = require("bun");
|
|
4
|
+
const { watch } = require("chokidar");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const type = require("react");
|
|
7
|
+
const { WebSocketServer } = require("ws");
|
|
8
|
+
const { renderToStream } = require("xplorajs-react");
|
|
9
|
+
const { build } = require("./build");
|
|
9
10
|
const pages = new Map();
|
|
10
11
|
async function loadPages() {
|
|
11
12
|
pages.clear();
|
|
12
13
|
const routes = await loadRoutes();
|
|
13
14
|
for (const route of routes){
|
|
14
15
|
const abs = join(process.cwd(), route.file);
|
|
15
|
-
delete
|
|
16
|
-
pages.set(route.path, (
|
|
16
|
+
delete require.cache?.[abs];
|
|
17
|
+
pages.set(route.path, require(abs).default);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
async function loadRoutes() {
|
|
@@ -25,7 +26,7 @@ async function loadRoutes() {
|
|
|
25
26
|
return [];
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
async function dev() {
|
|
29
30
|
console.log("Starting development server...");
|
|
30
31
|
const wss = new WebSocketServer({
|
|
31
32
|
port: 3001
|
|
@@ -50,15 +51,24 @@ export async function dev() {
|
|
|
50
51
|
});
|
|
51
52
|
await build();
|
|
52
53
|
await loadPages();
|
|
53
|
-
|
|
54
|
+
const config = {
|
|
54
55
|
port: 3000,
|
|
56
|
+
hmr: true
|
|
57
|
+
};
|
|
58
|
+
serve({
|
|
59
|
+
port: config.port,
|
|
60
|
+
development: true,
|
|
55
61
|
async fetch (req) {
|
|
56
|
-
const url = new URL(req.url)
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
const url = new URL(req.url);
|
|
63
|
+
const path = url.pathname;
|
|
64
|
+
if (path === "/") {
|
|
65
|
+
return new Response("Hello from XploraJS!");
|
|
66
|
+
}
|
|
67
|
+
if (path.startsWith("/assets/")) {
|
|
68
|
+
const f = Bun.file(join(process.cwd(), "dist", path));
|
|
59
69
|
if (await f.exists()) return new Response(f);
|
|
60
70
|
}
|
|
61
|
-
const Page = pages.get(
|
|
71
|
+
const Page = pages.get(path);
|
|
62
72
|
if (!Page) return new Response("Not Found", {
|
|
63
73
|
status: 404
|
|
64
74
|
});
|
|
@@ -117,5 +127,8 @@ export async function dev() {
|
|
|
117
127
|
});
|
|
118
128
|
console.log("Development server running at http://localhost:3000");
|
|
119
129
|
}
|
|
130
|
+
module.exports = {
|
|
131
|
+
dev
|
|
132
|
+
};
|
|
120
133
|
|
|
121
134
|
//# sourceMappingURL=dev.js.map
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["const { readFileSync } = require(\"node:fs\");\nconst { join } = require(\"node:path\");\nconst { serve } = require(\"bun\");\nconst { watch } = require(\"chokidar\");\nconst React = require(\"react\");\nconst type = require(\"react\");\nconst { WebSocketServer } = require(\"ws\");\nconst { renderToStream } = require(\"xplorajs-react\");\nconst { build } = require(\"./build\");\n\nconst pages = new Map();\n\nasync function loadPages() {\n pages.clear();\n const routes = await loadRoutes();\n\n for (const route of routes) {\n const abs = join(process.cwd(), route.file);\n delete require.cache?.[abs];\n pages.set(route.path, require(abs).default);\n }\n}\n\nasync function loadRoutes() {\n try {\n const routesPath = join(process.cwd(), \".xplora\", \"routes.json\");\n const routesContent = readFileSync(routesPath, \"utf-8\");\n return JSON.parse(routesContent).routes;\n } catch {\n return [];\n }\n}\n\nasync function dev() {\n console.log(\"Starting development server...\");\n\n const wss = new WebSocketServer({ port: 3001 });\n\n const watcher = watch([\"src/**/*\"], {\n ignored: /(^|[\\/\\\\])\\../,\n persistent: true,\n });\n\n watcher.on(\"change\", async (path) => {\n console.log(`File ${path} has been changed`);\n await build();\n await loadPages();\n\n for (const client of wss.clients) {\n if (client.readyState === WebSocket.OPEN) {\n client.send(JSON.stringify({ type: \"reload\" }));\n }\n }\n });\n\n await build();\n await loadPages();\n\n const config = {\n port: 3000,\n hmr: true,\n };\n\n serve({\n port: config.port,\n development: true,\n async fetch(req) {\n const url = new URL(req.url);\n const path = url.pathname;\n\n if (path === \"/\") {\n return new Response(\"Hello from XploraJS!\");\n }\n\n if (path.startsWith(\"/assets/\")) {\n const f = Bun.file(join(process.cwd(), \"dist\", path));\n if (await f.exists()) return new Response(f);\n }\n\n const Page = pages.get(path);\n if (!Page) return new Response(\"Not Found\", { status: 404 });\n\n const stream = await renderToStream(React.createElement(Page));\n\n const head = `<!DOCTYPE html><html><head>\n\t\t\t\t<meta charset=\"utf-8\"/>\n\t\t\t\t<link rel=\"stylesheet\" href=\"/assets/style.css\"/>\n\t\t\t\t<script>window.process={env:{NODE_ENV:\"development\"}};</script>\n\t\t\t\t</head><body><div id=\"root\">`;\n\n const foot = `</div>\n\t\t\t\t<script type=\"module\">\n\t\t\t\t\timport * as RefreshRuntime from \"https://esm.sh/react-refresh@0.17.0/runtime\";\n\t\t\t\t\tif (window.process?.env?.NODE_ENV === \"development\") {\n\t\t\t\t\t\tconsole.log(\"Fast refresh runtime loaded in development mode\");\n\t\t\t\t\t}\n\t\t\t\t\tRefreshRuntime.injectIntoGlobalHook(window);\n\t\t\t\t\twindow.$RefreshReg$=()=>{};\n\t\t\t\t\twindow.$RefreshSig$=()=>t=>t;\n\t\t\t\t</script>\n\t\t\t\t<script>\n\t\t\t\t\tconst ws=new WebSocket(\"ws://localhost:3001\");\n\t\t\t\t\tws.onmessage=async e=>{\n\t\t\t\t\t\tif(e.data===\"css\"){\n\t\t\t\t\t\t\tdocument.querySelectorAll('link[rel=\"stylesheet\"]').forEach(l=>l.href=\"/assets/style.css?v=\"+Date.now());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(e.data===\"reload\"){\n\t\t\t\t\t\t\tconsole.log(\"Reloading...\");\n\t\t\t\t\t\t\tlocation.reload();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t</script>\n\t\t\t</body></html>`;\n\n return new Response(\n new ReadableStream({\n start(ctrl) {\n ctrl.enqueue(new TextEncoder().encode(head));\n if (typeof stream === \"string\") {\n ctrl.enqueue(new TextEncoder().encode(stream));\n } else {\n stream.pipeTo(\n new WritableStream({\n write(c) {\n ctrl.enqueue(c);\n },\n close() {\n ctrl.enqueue(new TextEncoder().encode(foot));\n ctrl.close();\n },\n }),\n );\n }\n },\n }),\n { headers: { \"Content-Type\": \"text/html; charset=utf-8\" } },\n );\n },\n });\n\n console.log(\"Development server running at http://localhost:3000\");\n}\n\nmodule.exports = { dev };\n"],"names":["readFileSync","require","join","serve","watch","React","type","WebSocketServer","renderToStream","build","pages","Map","loadPages","clear","routes","loadRoutes","route","abs","process","cwd","file","cache","set","path","default","routesPath","routesContent","JSON","parse","dev","console","log","wss","port","watcher","ignored","persistent","on","client","clients","readyState","WebSocket","OPEN","send","stringify","config","hmr","development","fetch","req","url","URL","pathname","Response","startsWith","f","Bun","exists","Page","get","status","stream","createElement","head","foot","ReadableStream","start","ctrl","enqueue","TextEncoder","encode","pipeTo","WritableStream","write","c","close","headers","module","exports"],"mappings":"AAAA,MAAM,EAAEA,YAAY,EAAE,GAAGC,QAAQ;AACjC,MAAM,EAAEC,IAAI,EAAE,GAAGD,QAAQ;AACzB,MAAM,EAAEE,KAAK,EAAE,GAAGF,QAAQ;AAC1B,MAAM,EAAEG,KAAK,EAAE,GAAGH,QAAQ;AAC1B,MAAMI,QAAQJ,QAAQ;AACtB,MAAMK,OAAOL,QAAQ;AACrB,MAAM,EAAEM,eAAe,EAAE,GAAGN,QAAQ;AACpC,MAAM,EAAEO,cAAc,EAAE,GAAGP,QAAQ;AACnC,MAAM,EAAEQ,KAAK,EAAE,GAAGR,QAAQ;AAE1B,MAAMS,QAAQ,IAAIC;AAElB,eAAeC;IACbF,MAAMG,KAAK;IACX,MAAMC,SAAS,MAAMC;IAErB,KAAK,MAAMC,SAASF,OAAQ;QAC1B,MAAMG,MAAMf,KAAKgB,QAAQC,GAAG,IAAIH,MAAMI,IAAI;QAC1C,OAAOnB,QAAQoB,KAAK,EAAE,CAACJ,IAAI;QAC3BP,MAAMY,GAAG,CAACN,MAAMO,IAAI,EAAEtB,QAAQgB,KAAKO,OAAO;IAC5C;AACF;AAEA,eAAeT;IACb,IAAI;QACF,MAAMU,aAAavB,KAAKgB,QAAQC,GAAG,IAAI,WAAW;QAClD,MAAMO,gBAAgB1B,aAAayB,YAAY;QAC/C,OAAOE,KAAKC,KAAK,CAACF,eAAeZ,MAAM;IACzC,EAAE,OAAM;QACN,OAAO,EAAE;IACX;AACF;AAEA,eAAee;IACbC,QAAQC,GAAG,CAAC;IAEZ,MAAMC,MAA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IX,SACT,IAAIY,eAAe;gBACjBC,OAAMC,IAAI;oBACRA,KAAKC,OAAO,CAAC,IAAIC,cAAcC,MAAM,CAACP;oBACtC,IAAI,OAAOF,WAAW,UAAU;wBAC9BM,KAAKC,OAAO,CAAC,IAAIC,cAAcC,MAAM,CAACT;oBACxC,OAAO;wBACLA,OAAOU,MAAM,CACX,IAAIC,eAAe;4BACjBC,OAAMC,CAAC;gCACLP,KAAKC,OAAO,CAACM;4BACf;4BACAC;gCACER,KAAKC,OAAO,CAAC,IAAIC,cAAcC,MAAM,CAACN;gCACtCG,KAAKQ,KAAK;4BACZ;wBACF;oBAEJ;gBACF;YACF,IACA;gBAAEC,SAAS;oBAAE,gBAAgB;gBAA2B;YAAE;QAE9D;IACF;IAEA9C,QAAQC,GAAG,CAAC;AACd;AAEA8C,OAAOC,OAAO,GAAG;IAAEjD;AAAI"}
|
package/dist/commands/start.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
const { serve } = require("bun");
|
|
2
|
+
const { readFileSync } = require("node:fs");
|
|
3
|
+
const { join } = require("node:path");
|
|
4
|
+
async function start() {
|
|
2
5
|
console.log("Starting production server...");
|
|
3
|
-
const
|
|
4
|
-
port: 3000
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const config = {
|
|
7
|
+
port: 3000
|
|
8
|
+
};
|
|
9
|
+
serve({
|
|
10
|
+
port: config.port,
|
|
11
|
+
async fetch (req) {
|
|
12
|
+
const url = new URL(req.url);
|
|
13
|
+
const path = url.pathname;
|
|
14
|
+
if (path === "/") {
|
|
15
|
+
return new Response("Hello from XploraJS!");
|
|
16
|
+
}
|
|
17
|
+
return new Response("Not found", {
|
|
18
|
+
status: 404
|
|
19
|
+
});
|
|
7
20
|
}
|
|
8
21
|
});
|
|
9
|
-
console.log(
|
|
22
|
+
console.log("Production server running at http://localhost:3000");
|
|
10
23
|
}
|
|
24
|
+
module.exports = {
|
|
25
|
+
start
|
|
26
|
+
};
|
|
11
27
|
|
|
12
28
|
//# sourceMappingURL=start.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/start.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/commands/start.ts"],"sourcesContent":["const { serve } = require(\"bun\");\n\nconst { readFileSync } = require(\"node:fs\");\nconst { join } = require(\"node:path\");\n\nasync function start() {\n console.log(\"Starting production server...\");\n\n const config = {\n port: 3000,\n };\n\n serve({\n port: config.port,\n async fetch(req: Request) {\n const url = new URL(req.url);\n const path = url.pathname;\n\n if (path === \"/\") {\n return new Response(\"Hello from XploraJS!\");\n }\n\n return new Response(\"Not found\", { status: 404 });\n },\n });\n\n console.log(\"Production server running at http://localhost:3000\");\n}\n\nmodule.exports = { start };\n"],"names":["serve","require","readFileSync","join","start","console","log","config","port","fetch","req","url","URL","path","pathname","Response","status","module","exports"],"mappings":"AAAA,MAAM,EAAEA,KAAK,EAAE,GAAGC,QAAQ;AAE1B,MAAM,EAAEC,YAAY,EAAE,GAAGD,QAAQ;AACjC,MAAM,EAAEE,IAAI,EAAE,GAAGF,QAAQ;AAEzB,eAAeG;IACbC,QAAQC,GAAG,CAAC;IAEZ,MAAMC,SAAS;QACbC,MAAM;IACR;IAEAR,MAAM;QACJQ,MAAMD,OAAOC,IAAI;QACjB,MAAMC,OAAMC,GAAY;YACtB,MAAMC,MAAM,IAAIC,IAAIF,IAAIC,GAAG;YAC3B,MAAME,OAAOF,IAAIG,QAAQ;YAEzB,IAAID,SAAS,KAAK;gBAChB,OAAO,IAAIE,SAAS;YACtB;YAEA,OAAO,IAAIA,SAAS,aAAa;gBAAEC,QAAQ;YAAI;QACjD;IACF;IAEAX,QAAQC,GAAG,CAAC;AACd;AAEAW,OAAOC,OAAO,GAAG;IAAEd;AAAM"}
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function defineConfig(config) {
|
|
2
2
|
return {
|
|
3
3
|
dev: {
|
|
4
4
|
port: 3000,
|
|
@@ -18,5 +18,9 @@ export function defineConfig(config) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
module.exports = {
|
|
22
|
+
XploraConfig,
|
|
23
|
+
defineConfig
|
|
24
|
+
};
|
|
21
25
|
|
|
22
26
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["interface XploraConfig {\n\tdev?: {\n\t\tport?: number;\n\t\thmr?: boolean;\n\t};\n\tstatic?: {\n\t\toutputDir?: string;\n\t\trevalidate?: number;\n\t\tfallback?: boolean;\n\t};\n\tbuild?: {\n\t\tminify?: boolean;\n\t\tsourcemap?: boolean;\n\t};\n}\n\nfunction defineConfig(config: XploraConfig): XploraConfig {\n\treturn {\n\t\tdev: {\n\t\t\tport: 3000,\n\t\t\thmr: true,\n\t\t\t...config.dev,\n\t\t},\n\t\tstatic: {\n\t\t\toutputDir: \"./dist\",\n\t\t\trevalidate: 3600,\n\t\t\tfallback: false,\n\t\t\t...config.static,\n\t\t},\n\t\tbuild: {\n\t\t\tminify: true,\n\t\t\tsourcemap: true,\n\t\t\t...config.build,\n\t\t},\n\t};\n}\n\nmodule.exports = {\n\tXploraConfig,\n\tdefineConfig,\n};\n"],"names":["defineConfig","config","dev","port","hmr","static","outputDir","revalidate","fallback","build","minify","sourcemap","module","exports","XploraConfig"],"mappings":"AAgBA,SAASA,aAAaC,MAAoB;IACzC,OAAO;QACNC,KAAK;YACJC,MAAM;YACNC,KAAK;YACL,GAAGH,OAAOC,GAAG;QACd;QACAG,QAAQ;YACPC,WAAW;YACXC,YAAY;YACZC,UAAU;YACV,GAAGP,OAAOI,MAAM;QACjB;QACAI,OAAO;YACNC,QAAQ;YACRC,WAAW;YACX,GAAGV,OAAOQ,KAAK;QAChB;IACD;AACD;AAEAG,OAAOC,OAAO,GAAG;IAChBC;IACAd;AACD"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["const { XploraConfig, defineConfig } = require(\"./config\");\n\nmodule.exports = {\n\tXploraConfig,\n\tdefineConfig,\n};\n"],"names":["XploraConfig","defineConfig","require","module","exports"],"mappings":"AAAA,MAAM,EAAEA,YAAY,EAAEC,YAAY,EAAE,GAAGC,QAAQ;AAE/CC,OAAOC,OAAO,GAAG;IAChBJ;IACAC;AACD"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xplorajs",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.9",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
5
|
"types": "dist/index.d.ts",
|
|
8
6
|
"bin": {
|
|
9
|
-
"xplorajs": "./dist/cli.
|
|
7
|
+
"xplorajs": "./dist/cli.js"
|
|
10
8
|
},
|
|
11
9
|
"files": [
|
|
12
10
|
"dist",
|