atollic 0.0.2
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/README.md +432 -0
- package/dist/adapter.d.ts +39 -0
- package/dist/adapter.js +0 -0
- package/dist/adapters/solid.d.ts +10 -0
- package/dist/adapters/solid.js +37 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.js +113 -0
- package/dist/head.d.ts +14 -0
- package/dist/head.js +7 -0
- package/dist/html/index.d.ts +2 -0
- package/dist/html/index.js +2 -0
- package/dist/html/jsx-dev-runtime.d.ts +3 -0
- package/dist/html/jsx-dev-runtime.js +7 -0
- package/dist/html/jsx-runtime.d.ts +5 -0
- package/dist/html/jsx-runtime.js +61 -0
- package/dist/html/types.d.ts +559 -0
- package/dist/html/types.js +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/server-DhToIUB0.js +14 -0
- package/dist/server.d.ts +14 -0
- package/dist/servers/elysia.d.ts +29 -0
- package/dist/servers/elysia.js +12 -0
- package/dist/servers/hono.d.ts +2 -0
- package/dist/servers/hono.js +15 -0
- package/dist/shared-CfRCLggd.js +23 -0
- package/dist/shared.d.ts +13 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +313 -0
- package/package.json +127 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export declare function atollic(): Elysia<"", {
|
|
3
|
+
decorator: {};
|
|
4
|
+
store: {};
|
|
5
|
+
derive: {};
|
|
6
|
+
resolve: {};
|
|
7
|
+
}, {
|
|
8
|
+
typebox: {};
|
|
9
|
+
error: {};
|
|
10
|
+
}, {
|
|
11
|
+
schema: {};
|
|
12
|
+
standaloneSchema: {};
|
|
13
|
+
macro: {};
|
|
14
|
+
macroFn: {};
|
|
15
|
+
parser: {};
|
|
16
|
+
response: {};
|
|
17
|
+
}, {}, {
|
|
18
|
+
derive: {};
|
|
19
|
+
resolve: {};
|
|
20
|
+
schema: {};
|
|
21
|
+
standaloneSchema: {};
|
|
22
|
+
response: {};
|
|
23
|
+
}, {
|
|
24
|
+
derive: {};
|
|
25
|
+
resolve: {};
|
|
26
|
+
schema: {};
|
|
27
|
+
standaloneSchema: {};
|
|
28
|
+
response: {};
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as e, i as t, n } from "../shared-CfRCLggd.js";
|
|
2
|
+
import { t as r } from "../server-DhToIUB0.js";
|
|
3
|
+
import { Elysia as i } from "elysia";
|
|
4
|
+
//#region src/servers/elysia.ts
|
|
5
|
+
function a() {
|
|
6
|
+
return new i({ name: "atollic" }).mapResponse({ as: "global" }, (i) => {
|
|
7
|
+
let a = i.response ?? i.responseValue, o = n(a);
|
|
8
|
+
if (o && (t(o) || Array.isArray(a))) return new Response(e(o, r()), { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { a as atollic };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as e, i as t } from "../shared-CfRCLggd.js";
|
|
2
|
+
import { t as n } from "../server-DhToIUB0.js";
|
|
3
|
+
//#region src/servers/hono.ts
|
|
4
|
+
function r() {
|
|
5
|
+
return async (r, i) => {
|
|
6
|
+
if (await i(), !(r.res.headers.get("content-type") || "").includes("text/html")) return;
|
|
7
|
+
let a = await r.res.text();
|
|
8
|
+
t(a) && (r.res = new Response(e(a, n()), {
|
|
9
|
+
status: r.res.status,
|
|
10
|
+
headers: r.res.headers
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { r as atollic };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/shared.ts
|
|
2
|
+
var e = /<meta\s+name="atollic-head"\s*\/?>/;
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = t.replace(e, n);
|
|
5
|
+
return r === t ? t.includes("</head>") ? t.replace("</head>", ` ${n}\n</head>`) : t : r;
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
return e && typeof e == "object" && "t" in e && typeof e.t == "string" ? e.t : Array.isArray(e) ? e.flat(Infinity).map((e) => typeof e == "string" ? e : e && typeof e == "object" && "t" in e ? e.t : "").join("") || null : typeof e == "string" ? e : null;
|
|
9
|
+
}
|
|
10
|
+
function r(e) {
|
|
11
|
+
let t = e.trimStart();
|
|
12
|
+
return t.startsWith("<html") && !t.startsWith("<!DOCTYPE") ? `<!DOCTYPE html>\n${e}` : e;
|
|
13
|
+
}
|
|
14
|
+
function i(e) {
|
|
15
|
+
let t = e.trimStart();
|
|
16
|
+
return t.startsWith("<!DOCTYPE") || t.startsWith("<html");
|
|
17
|
+
}
|
|
18
|
+
function a(e, n) {
|
|
19
|
+
let i = r(e);
|
|
20
|
+
return n && (i = t(i, n)), i;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { a, i, n, t as r, r as t };
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Replace <Head /> marker with tags, or fall back to </head> injection. */
|
|
2
|
+
export declare function injectHead(html: string, tags: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Extract HTML from Solid's SSR output format.
|
|
5
|
+
* Handles `{t: "<html>"}` objects and arrays of fragments.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractHtml(value: unknown): string | null;
|
|
8
|
+
/** Prepend DOCTYPE if the string looks like HTML but is missing it. */
|
|
9
|
+
export declare function ensureDoctype(html: string): string;
|
|
10
|
+
/** Check if a string looks like a full HTML document. */
|
|
11
|
+
export declare function isHtmlDocument(value: string): boolean;
|
|
12
|
+
/** Ensure DOCTYPE and inject production assets if available. */
|
|
13
|
+
export declare function processHtml(body: string, assets: string | undefined): string;
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin for atollic.
|
|
3
|
+
*
|
|
4
|
+
* - Boots a fetch-based server as dev-server middleware (via Vite's SSR loader).
|
|
5
|
+
* - Discovers island components via `"use client"` directives and generates
|
|
6
|
+
* a client entry.
|
|
7
|
+
* - Delegates SSR rendering and client hydration to framework adapters.
|
|
8
|
+
* - Injects the client runtime + Vite HMR client into HTML responses.
|
|
9
|
+
* - Sends a custom HMR event on server-side file changes so the client
|
|
10
|
+
* can refetch + morph the page without a full reload.
|
|
11
|
+
*/
|
|
12
|
+
import type { Plugin } from "vite";
|
|
13
|
+
import type { FrameworkAdapter } from "./adapter.js";
|
|
14
|
+
export interface AtollicOptions {
|
|
15
|
+
/** Path to the file that default-exports a fetch function: (req: Request) => Response */
|
|
16
|
+
entry: string;
|
|
17
|
+
/** Framework adapters. Islands use the first adapter by default. */
|
|
18
|
+
frameworks?: FrameworkAdapter[];
|
|
19
|
+
/** Additional modules to externalize from the SSR build (not bundled). */
|
|
20
|
+
external?: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function atollic(options: AtollicOptions): Plugin[];
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./shared-CfRCLggd.js";
|
|
2
|
+
import { readFileSync as i } from "node:fs";
|
|
3
|
+
import { glob as a, readFile as o } from "node:fs/promises";
|
|
4
|
+
import { basename as s, dirname as c, extname as l, relative as u, resolve as d } from "node:path";
|
|
5
|
+
import { fileURLToPath as f } from "node:url";
|
|
6
|
+
import { transformWithOxc as p } from "vite";
|
|
7
|
+
//#region src/vite.ts
|
|
8
|
+
var m = c(f(import.meta.url)), h = "virtual:atollic/client", g = `\0${h}`, _ = "virtual:atollic/prod-entry", v = `\0${_}`, y = "virtual:atollic/fw-", b = "atollic:reload", x = "?raw-island", S = /\.[jt]sx?$/, C = /\.[jt]sx$/, w = /\.css($|\?)/;
|
|
9
|
+
function T(e) {
|
|
10
|
+
let t = e.replace(/^\s*(\/\*[\s\S]*?\*\/\s*|\/\/[^\n]*\n\s*)*/g, "").match(/^["']use client(?::(\w+))?["']/);
|
|
11
|
+
return t ? {
|
|
12
|
+
hasDirective: !0,
|
|
13
|
+
framework: t[1]
|
|
14
|
+
} : { hasDirective: !1 };
|
|
15
|
+
}
|
|
16
|
+
function E(e) {
|
|
17
|
+
return e.replace(/^["']use client(?::\w+)?["'];?\s*/m, "");
|
|
18
|
+
}
|
|
19
|
+
function D(e, t) {
|
|
20
|
+
let n = [], r = E(e), i = r.match(/export\s+default\s+(?:function|class)\s+([A-Z]\w*)/);
|
|
21
|
+
i ? n.push({
|
|
22
|
+
exportName: "default",
|
|
23
|
+
islandName: i[1]
|
|
24
|
+
}) : /export\s+default\s/.test(r) && n.push({
|
|
25
|
+
exportName: "default",
|
|
26
|
+
islandName: t
|
|
27
|
+
});
|
|
28
|
+
for (let e of r.matchAll(/export\s+(?:function|const|let|var|class)\s+([A-Z][A-Za-z0-9]*)/g)) n.push({
|
|
29
|
+
exportName: e[1],
|
|
30
|
+
islandName: e[1]
|
|
31
|
+
});
|
|
32
|
+
return n;
|
|
33
|
+
}
|
|
34
|
+
function O(e, t, n, r) {
|
|
35
|
+
let i = [...n].map((e) => `import "${e}";`).join("\n"), a = [...t].map((e) => `import "/${u(r, e)}";`).join("\n"), o = /* @__PURE__ */ new Map();
|
|
36
|
+
for (let [t, n] of Object.entries(e)) {
|
|
37
|
+
let e = n.adapter.name;
|
|
38
|
+
o.has(e) || o.set(e, []), o.get(e).push([t, n]);
|
|
39
|
+
}
|
|
40
|
+
let s = "import { registerIsland, registerFramework, initRuntime } from \"atollic/client\";\n";
|
|
41
|
+
s += `${i}\n`, s += `${a}\n\n`;
|
|
42
|
+
for (let [e, t] of o) {
|
|
43
|
+
let n = `${y}${e}`;
|
|
44
|
+
s += `import { hydrateIsland as __hydrate_${e}, renderIsland as __render_${e} } from "${n}";\n`, s += `registerFramework("${e}", __hydrate_${e}, __render_${e});\n\n`;
|
|
45
|
+
for (let [n, i] of t) {
|
|
46
|
+
let t = `/${u(r, i.absPath)}`;
|
|
47
|
+
i.exportName === "default" ? s += ` registerIsland("${n}", "${e}", () => import("${t}"));\n` : s += ` registerIsland("${n}", "${e}", () => import("${t}").then(m => ({ default: m.${i.exportName} })));\n`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return s += "\ninitRuntime();\n", s;
|
|
51
|
+
}
|
|
52
|
+
function k(e) {
|
|
53
|
+
let t = new URL(e.url ?? "/", `http://${e.headers.host || "localhost"}`), n = new Headers();
|
|
54
|
+
for (let [t, r] of Object.entries(e.headers)) if (r) if (Array.isArray(r)) for (let e of r) n.append(t, e);
|
|
55
|
+
else n.set(t, r);
|
|
56
|
+
let r = {
|
|
57
|
+
method: e.method,
|
|
58
|
+
headers: n
|
|
59
|
+
};
|
|
60
|
+
return e.method !== "GET" && e.method !== "HEAD" && (r.body = new ReadableStream({ start(t) {
|
|
61
|
+
e.on("data", (e) => t.enqueue(e)), e.on("end", () => t.close()), e.on("error", (e) => t.error(e));
|
|
62
|
+
} }), r.duplex = "half"), new Request(t, r);
|
|
63
|
+
}
|
|
64
|
+
function A(e, t) {
|
|
65
|
+
let n = [];
|
|
66
|
+
if (t) for (let e of t) n.push(`<link rel="stylesheet" href="${e}">`);
|
|
67
|
+
for (let t of e) t.hydrationScript && n.push(t.hydrationScript);
|
|
68
|
+
return n.push(`<script type="module">import "${h}";<\/script>`), n.join("\n ");
|
|
69
|
+
}
|
|
70
|
+
function j(e, t) {
|
|
71
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
72
|
+
function i(t) {
|
|
73
|
+
if (r.has(t)) return;
|
|
74
|
+
r.add(t);
|
|
75
|
+
let a = e.moduleGraph.getModuleById(t);
|
|
76
|
+
if (a) {
|
|
77
|
+
w.test(a.url) && n.add(a.url);
|
|
78
|
+
for (let e of a.ssrImportedModules) i(e.id ?? e.url);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let a = e.moduleGraph.getModuleById(t);
|
|
82
|
+
return a && i(a.id ?? a.url), n;
|
|
83
|
+
}
|
|
84
|
+
function M(u) {
|
|
85
|
+
let f = u.frameworks ?? [], w = f[0], M = "", N = {}, P = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), I = "", L = 3e3, R = null, z = "", B = !1, V = null;
|
|
86
|
+
function H(e) {
|
|
87
|
+
return e ? f.find((t) => t.name === e) : w;
|
|
88
|
+
}
|
|
89
|
+
function U() {
|
|
90
|
+
if (!R) return;
|
|
91
|
+
let e = R.moduleGraph.getModuleById(g);
|
|
92
|
+
e && R.moduleGraph.invalidateModule(e);
|
|
93
|
+
}
|
|
94
|
+
function W(e, t) {
|
|
95
|
+
N[t] || (N[t] = e, U());
|
|
96
|
+
}
|
|
97
|
+
function G(e, t, n) {
|
|
98
|
+
let r = D(t, s(e, l(e)));
|
|
99
|
+
for (let t of r) W({
|
|
100
|
+
absPath: e,
|
|
101
|
+
exportName: t.exportName,
|
|
102
|
+
adapter: n
|
|
103
|
+
}, t.islandName);
|
|
104
|
+
}
|
|
105
|
+
let K = {
|
|
106
|
+
name: "atollic",
|
|
107
|
+
enforce: "pre",
|
|
108
|
+
sharedDuringBuild: !0,
|
|
109
|
+
config(e, t) {
|
|
110
|
+
let n = { resolve: { alias: {
|
|
111
|
+
"atollic/client": d(m, "client.js"),
|
|
112
|
+
"atollic/jsx-runtime": d(m, "html/jsx-runtime.js"),
|
|
113
|
+
"atollic/jsx-dev-runtime": d(m, "html/jsx-dev-runtime.js")
|
|
114
|
+
} } };
|
|
115
|
+
return t.command === "build" && (n.ssr = { noExternal: !0 }, n.builder = {}, n.build = {
|
|
116
|
+
manifest: !0,
|
|
117
|
+
outDir: "dist/client"
|
|
118
|
+
}, n.environments = {
|
|
119
|
+
client: { build: { rollupOptions: { input: { client: h } } } },
|
|
120
|
+
ssr: { build: {
|
|
121
|
+
outDir: "dist/server",
|
|
122
|
+
copyPublicDir: !1,
|
|
123
|
+
rollupOptions: {
|
|
124
|
+
input: { app: _ },
|
|
125
|
+
external: ["bun", ...u.external ?? []]
|
|
126
|
+
}
|
|
127
|
+
} }
|
|
128
|
+
}), n;
|
|
129
|
+
},
|
|
130
|
+
async buildApp(e) {
|
|
131
|
+
await e.build(e.environments.client);
|
|
132
|
+
let t = d(M, "dist/client/.vite/manifest.json"), n = JSON.parse(await o(t, "utf-8")), r = n.client ?? n["virtual:atollic/client"], i = [];
|
|
133
|
+
for (let e of Object.values(n)) if (e.css) for (let t of e.css) i.push(`<link rel="stylesheet" href="/${t}">`);
|
|
134
|
+
for (let e of f) e.hydrationScript && i.push(e.hydrationScript);
|
|
135
|
+
r && i.push(`<script type="module" src="/${r.file}"><\/script>`), z = i.join("\n "), await e.build(e.environments.ssr);
|
|
136
|
+
},
|
|
137
|
+
async configResolved(e) {
|
|
138
|
+
M = e.root, I = d(M, u.entry), L = e.server.port ?? 3e3;
|
|
139
|
+
},
|
|
140
|
+
async buildStart() {
|
|
141
|
+
if (B) return;
|
|
142
|
+
B = !0;
|
|
143
|
+
let e = /import\s+['"]([^'"]+\.css)['"]/g, t = /import\s.*?from\s+['"](\.\.?\/[^'"]+)['"]/g, n = /* @__PURE__ */ new Set();
|
|
144
|
+
function r(t, n) {
|
|
145
|
+
let r = T(n);
|
|
146
|
+
if (r.hasDirective) if (C.test(t)) {
|
|
147
|
+
let e = H(r.framework);
|
|
148
|
+
e ? G(t, n, e) : r.framework && console.warn(`[atollic] Unknown framework "${r.framework}" in ${t}`);
|
|
149
|
+
} else P.add(t);
|
|
150
|
+
for (let t of n.matchAll(e)) F.add(t[1]);
|
|
151
|
+
}
|
|
152
|
+
for await (let e of a("**/*.{ts,tsx,js,jsx}", {
|
|
153
|
+
cwd: M,
|
|
154
|
+
exclude: ["node_modules/**", "dist/**"]
|
|
155
|
+
})) {
|
|
156
|
+
let t = d(M, e);
|
|
157
|
+
n.add(t);
|
|
158
|
+
try {
|
|
159
|
+
r(t, await o(t, "utf-8"));
|
|
160
|
+
} catch {}
|
|
161
|
+
}
|
|
162
|
+
async function i(e) {
|
|
163
|
+
if (!n.has(e)) {
|
|
164
|
+
n.add(e);
|
|
165
|
+
try {
|
|
166
|
+
let a = await o(e, "utf-8");
|
|
167
|
+
r(e, a);
|
|
168
|
+
for (let s of a.matchAll(t)) {
|
|
169
|
+
let t = s[1].replace(/\.js$/, ""), a = d(c(e), t);
|
|
170
|
+
for (let e of [
|
|
171
|
+
a,
|
|
172
|
+
`${a}.ts`,
|
|
173
|
+
`${a}.tsx`,
|
|
174
|
+
`${a}.js`,
|
|
175
|
+
`${a}/index.ts`,
|
|
176
|
+
`${a}/index.tsx`
|
|
177
|
+
]) try {
|
|
178
|
+
let t = await o(e, "utf-8");
|
|
179
|
+
n.has(e) || (n.add(e), r(e, t), await i(e));
|
|
180
|
+
break;
|
|
181
|
+
} catch {}
|
|
182
|
+
}
|
|
183
|
+
} catch {}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
await i(I);
|
|
187
|
+
},
|
|
188
|
+
resolveId(e) {
|
|
189
|
+
if (e === h) return g;
|
|
190
|
+
if (e === _) return v;
|
|
191
|
+
if (e.startsWith(y)) return `\0${e}`;
|
|
192
|
+
if (e.endsWith(x)) return `${e.slice(0, -11)}${x}`;
|
|
193
|
+
},
|
|
194
|
+
load(e, t) {
|
|
195
|
+
if (e === g) return O(N, P, F, M);
|
|
196
|
+
if (e === v) return `import { resolve, join } from "node:path";
|
|
197
|
+
import { setProductionAssets } from "${d(m, "index.js")}";
|
|
198
|
+
setProductionAssets(${JSON.stringify(z)});
|
|
199
|
+
import handler from "${I}";
|
|
200
|
+
|
|
201
|
+
const clientDir = resolve(import.meta.dirname, "..", "client");
|
|
202
|
+
const port = process.env.PORT || ${L};
|
|
203
|
+
|
|
204
|
+
Bun.serve({
|
|
205
|
+
port,
|
|
206
|
+
async fetch(req) {
|
|
207
|
+
const url = new URL(req.url);
|
|
208
|
+
const filePath = join(clientDir, url.pathname);
|
|
209
|
+
if (url.pathname !== "/" && !url.pathname.endsWith("/")) {
|
|
210
|
+
const file = Bun.file(filePath);
|
|
211
|
+
if (await file.exists()) return new Response(file);
|
|
212
|
+
}
|
|
213
|
+
return handler(req);
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
console.log(\`Listening on http://localhost:\${port}\`);
|
|
217
|
+
`;
|
|
218
|
+
if (e.startsWith("\0" + y)) {
|
|
219
|
+
let t = e.slice(("\0" + y).length), n = f.find((e) => e.name === t);
|
|
220
|
+
if (n) return n.clientRuntime;
|
|
221
|
+
}
|
|
222
|
+
if (e.endsWith(x)) {
|
|
223
|
+
let t = e.slice(0, -11);
|
|
224
|
+
try {
|
|
225
|
+
return E(i(t, "utf-8"));
|
|
226
|
+
} catch {}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (!(!t?.ssr || !S.test(e))) try {
|
|
230
|
+
let t = i(e, "utf-8"), n = T(t);
|
|
231
|
+
if (n.hasDirective) {
|
|
232
|
+
if (!C.test(e)) return P.add(e), U(), "export default {};";
|
|
233
|
+
let r = H(n.framework);
|
|
234
|
+
if (!r) {
|
|
235
|
+
n.framework && console.warn(`[atollic] Unknown framework "${n.framework}" in ${e}`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
let i = D(t, s(e, l(e)));
|
|
239
|
+
for (let t of i) W({
|
|
240
|
+
absPath: e,
|
|
241
|
+
exportName: t.exportName,
|
|
242
|
+
adapter: r
|
|
243
|
+
}, t.islandName);
|
|
244
|
+
let a = `${e}${x}`;
|
|
245
|
+
return r.ssrStub(a, i);
|
|
246
|
+
}
|
|
247
|
+
} catch {}
|
|
248
|
+
},
|
|
249
|
+
configureServer(i) {
|
|
250
|
+
R = i, i.middlewares.use(async (a, o, s) => {
|
|
251
|
+
let c = a.url || "";
|
|
252
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules") || c.startsWith("/__") || /\.\w+($|\?)/.test(c)) return s();
|
|
253
|
+
try {
|
|
254
|
+
let l = await i.ssrLoadModule(I), u = l.default ?? l.handler;
|
|
255
|
+
if (typeof u != "function") return console.error("[atollic] Entry must default-export a fetch function: (req: Request) => Response"), s();
|
|
256
|
+
let d = await u(k(a));
|
|
257
|
+
if (d.status === 404) return s();
|
|
258
|
+
let p = await d.text(), m = d.headers.get("content-type") || "";
|
|
259
|
+
if (m.includes("application/json")) try {
|
|
260
|
+
let e = t(JSON.parse(p));
|
|
261
|
+
e && (p = e, m = "");
|
|
262
|
+
} catch {}
|
|
263
|
+
let h = e(p);
|
|
264
|
+
!m.includes("text/html") && h && (m = "text/html; charset=utf-8"), h && (p = r(p), V ||= j(i, I), p = n(p, A(f, V)), p = await i.transformIndexHtml(c, p));
|
|
265
|
+
let g = {};
|
|
266
|
+
for (let [e, t] of d.headers) g[e] = t;
|
|
267
|
+
m ? g["content-type"] = m : g["content-type"] ||= "text/html; charset=utf-8", o.writeHead(d.status, g), o.end(p);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
e instanceof Error && i.ssrFixStacktrace(e), console.error("[atollic]", e), s(e);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
handleHotUpdate({ file: e, server: t }) {
|
|
274
|
+
if (V = null, !e.endsWith(".ts") && !e.endsWith(".tsx")) return;
|
|
275
|
+
try {
|
|
276
|
+
if (T(i(e, "utf-8")).hasDirective) return;
|
|
277
|
+
} catch {}
|
|
278
|
+
let n = t.moduleGraph.getModulesByFile(e);
|
|
279
|
+
if (n) for (let e of n) t.moduleGraph.invalidateModule(e);
|
|
280
|
+
return t.ws.send({
|
|
281
|
+
type: "custom",
|
|
282
|
+
event: b
|
|
283
|
+
}), [];
|
|
284
|
+
}
|
|
285
|
+
}, q = /@jsxImportSource\s+(\S+)/, J = {
|
|
286
|
+
name: "atollic:jsx-pre-transform",
|
|
287
|
+
enforce: "pre",
|
|
288
|
+
async transform(e, t) {
|
|
289
|
+
if (!/\.[jt]sx$/.test(t)) return;
|
|
290
|
+
let n = e.match(q);
|
|
291
|
+
if (n) {
|
|
292
|
+
let e = n[1];
|
|
293
|
+
for (let t of f) if (e.includes(t.name)) return;
|
|
294
|
+
}
|
|
295
|
+
let r = await p(e, t, { jsx: {
|
|
296
|
+
runtime: "automatic",
|
|
297
|
+
importSource: "atollic"
|
|
298
|
+
} });
|
|
299
|
+
return {
|
|
300
|
+
code: r.code,
|
|
301
|
+
map: r.map
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}, Y = [];
|
|
305
|
+
for (let e of f) e.plugins && Y.push(...e.plugins());
|
|
306
|
+
return [
|
|
307
|
+
J,
|
|
308
|
+
...Y,
|
|
309
|
+
K
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
export { M as atollic };
|
package/package.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atollic",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Island architecture for WinterCG-compatible runtimes. Bring-your-own server (Elysia, Hono, …) and UI framework, powered by Vite.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wintercg",
|
|
7
|
+
"islands",
|
|
8
|
+
"island-architecture",
|
|
9
|
+
"vite",
|
|
10
|
+
"ssr",
|
|
11
|
+
"hydration",
|
|
12
|
+
"elysia",
|
|
13
|
+
"hono"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/awilderink/atollic.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/awilderink/atollic/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/awilderink/atollic#readme",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev:elysia": "bunx --bun vite --config examples/elysia/vite.config.ts",
|
|
27
|
+
"dev:hono": "bunx --bun vite --config examples/hono/vite.config.ts",
|
|
28
|
+
"build": "vite build && tsc",
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"typecheck": "tsc --noEmit && tsc --noEmit --project examples/elysia/tsconfig.json && tsc --noEmit --project examples/hono/tsconfig.json",
|
|
32
|
+
"format": "biome format --write .",
|
|
33
|
+
"lint": "biome lint .",
|
|
34
|
+
"check": "biome check --write ."
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./vite": {
|
|
42
|
+
"types": "./dist/vite.d.ts",
|
|
43
|
+
"import": "./dist/vite.js"
|
|
44
|
+
},
|
|
45
|
+
"./client": {
|
|
46
|
+
"types": "./dist/client.d.ts",
|
|
47
|
+
"import": "./dist/client.js"
|
|
48
|
+
},
|
|
49
|
+
"./adapter": {
|
|
50
|
+
"types": "./dist/adapter.d.ts",
|
|
51
|
+
"import": "./dist/adapter.js"
|
|
52
|
+
},
|
|
53
|
+
"./head": {
|
|
54
|
+
"types": "./dist/head.d.ts",
|
|
55
|
+
"import": "./dist/head.js"
|
|
56
|
+
},
|
|
57
|
+
"./solid": {
|
|
58
|
+
"types": "./dist/adapters/solid.d.ts",
|
|
59
|
+
"import": "./dist/adapters/solid.js"
|
|
60
|
+
},
|
|
61
|
+
"./elysia": {
|
|
62
|
+
"types": "./dist/servers/elysia.d.ts",
|
|
63
|
+
"import": "./dist/servers/elysia.js"
|
|
64
|
+
},
|
|
65
|
+
"./hono": {
|
|
66
|
+
"types": "./dist/servers/hono.d.ts",
|
|
67
|
+
"import": "./dist/servers/hono.js"
|
|
68
|
+
},
|
|
69
|
+
"./jsx-runtime": {
|
|
70
|
+
"types": "./dist/html/jsx-runtime.d.ts",
|
|
71
|
+
"import": "./dist/html/jsx-runtime.js"
|
|
72
|
+
},
|
|
73
|
+
"./jsx-dev-runtime": {
|
|
74
|
+
"types": "./dist/html/jsx-dev-runtime.d.ts",
|
|
75
|
+
"import": "./dist/html/jsx-dev-runtime.js"
|
|
76
|
+
},
|
|
77
|
+
"./html": {
|
|
78
|
+
"types": "./dist/html/index.d.ts",
|
|
79
|
+
"import": "./dist/html/index.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"files": [
|
|
83
|
+
"dist/*.js",
|
|
84
|
+
"dist/*.d.ts",
|
|
85
|
+
"dist/adapters/*.js",
|
|
86
|
+
"dist/adapters/*.d.ts",
|
|
87
|
+
"dist/servers/*.js",
|
|
88
|
+
"dist/servers/*.d.ts",
|
|
89
|
+
"dist/html/*.js",
|
|
90
|
+
"dist/html/*.d.ts"
|
|
91
|
+
],
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"idiomorph": "^0.7.4"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"elysia": "^1.4.27",
|
|
97
|
+
"hono": "^4.0.0",
|
|
98
|
+
"solid-js": "^1.9.11",
|
|
99
|
+
"vite": "^8.0.0",
|
|
100
|
+
"vite-plugin-solid": "^2.11.11"
|
|
101
|
+
},
|
|
102
|
+
"peerDependenciesMeta": {
|
|
103
|
+
"elysia": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"hono": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"solid-js": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"vite-plugin-solid": {
|
|
113
|
+
"optional": true
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"devDependencies": {
|
|
117
|
+
"@biomejs/biome": "^2.4.7",
|
|
118
|
+
"@types/node": "^25.5.0",
|
|
119
|
+
"bun-types": "^1.3.11",
|
|
120
|
+
"elysia": "^1.4.28",
|
|
121
|
+
"hono": "^4.12.9",
|
|
122
|
+
"solid-js": "^1.9.11",
|
|
123
|
+
"typescript": "^5.9.3",
|
|
124
|
+
"vite": "^8.0.3",
|
|
125
|
+
"vite-plugin-solid": "^2.11.11"
|
|
126
|
+
}
|
|
127
|
+
}
|