@iconoma/studio 0.0.4 → 0.0.6
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 +9 -9
- package/dist/client/index.html +19 -19
- package/dist/server.js +70 -65
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Iconoma Studio!
|
|
2
|
-
|
|
3
|
-
This is the Iconoma Studio, if you want to use Iconoma go to [https://github.com/Theryston/iconoma](https://github.com/Theryston/iconoma). But to start Iconoma Studio programmatically:
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { createServer } from "@iconoma/studio";
|
|
7
|
-
|
|
8
|
-
const { url, close } = await createServer({ port });
|
|
9
|
-
```
|
|
1
|
+
# Iconoma Studio!
|
|
2
|
+
|
|
3
|
+
This is the Iconoma Studio, if you want to use Iconoma go to [https://github.com/Theryston/iconoma](https://github.com/Theryston/iconoma). But to start Iconoma Studio programmatically:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createServer } from "@iconoma/studio";
|
|
7
|
+
|
|
8
|
+
const { url, close } = await createServer({ port });
|
|
9
|
+
```
|
package/dist/client/index.html
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta http-equiv="Content-Language" content="en" />
|
|
6
|
-
<link rel="icon" href="/favicon.ico" />
|
|
7
|
-
<meta
|
|
8
|
-
name="viewport"
|
|
9
|
-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
|
10
|
-
/>
|
|
11
|
-
<title>Iconoma Studio</title>
|
|
12
|
-
<!--app-head-->
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta http-equiv="Content-Language" content="en" />
|
|
6
|
+
<link rel="icon" href="/favicon.ico" />
|
|
7
|
+
<meta
|
|
8
|
+
name="viewport"
|
|
9
|
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
|
10
|
+
/>
|
|
11
|
+
<title>Iconoma Studio</title>
|
|
12
|
+
<!--app-head-->
|
|
13
13
|
<script type="module" crossorigin src="/assets/index-7c_AX7XK.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-Bdj-eDET.css">
|
|
15
|
-
</head>
|
|
16
|
-
<body>
|
|
17
|
-
<div id="root">
|
|
18
|
-
<!--app-html-->
|
|
19
|
-
</div>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root">
|
|
18
|
+
<!--app-html-->
|
|
19
|
+
</div>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
package/dist/server.js
CHANGED
|
@@ -10,72 +10,77 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
11
|
const isProduction = __filename.endsWith(".js");
|
|
12
12
|
const templateHtml = isProduction
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
? await fs.readFile(path.join(__dirname, "client", "index.html"), "utf-8")
|
|
14
|
+
: "";
|
|
15
15
|
export async function createServer({ port } = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
app.use("*all", async (req, res) => {
|
|
37
|
-
try {
|
|
38
|
-
const url = req.originalUrl;
|
|
39
|
-
let template;
|
|
40
|
-
let render;
|
|
41
|
-
if (!isProduction) {
|
|
42
|
-
if (!vite) return res.status(500).end("Internal Server Error");
|
|
43
|
-
template = await fs.readFile("./index.html", "utf-8");
|
|
44
|
-
template = await vite.transformIndexHtml(url, template);
|
|
45
|
-
render = (await vite.ssrLoadModule("/src/entry-server.tsx")).render;
|
|
46
|
-
} else {
|
|
47
|
-
template = templateHtml;
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
render = (await import("./server/entry-server.js")).render;
|
|
50
|
-
}
|
|
51
|
-
const rendered = await render(url);
|
|
52
|
-
const html = template
|
|
53
|
-
.replace(`<!--app-head-->`, rendered.head ?? "")
|
|
54
|
-
.replace(`<!--app-html-->`, rendered.html ?? "");
|
|
55
|
-
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
vite?.ssrFixStacktrace(e);
|
|
58
|
-
console.log(e.stack);
|
|
59
|
-
res.status(500).end(e.stack);
|
|
16
|
+
if (!port) {
|
|
17
|
+
port = await getPort({ port: [4545, 4546, 4547, 4548, 4549, 5173] });
|
|
18
|
+
}
|
|
19
|
+
const app = express();
|
|
20
|
+
app.use("/api", apiRoutes);
|
|
21
|
+
let vite;
|
|
22
|
+
if (!isProduction) {
|
|
23
|
+
const { createServer } = await import("vite");
|
|
24
|
+
vite = await createServer({
|
|
25
|
+
server: { middlewareMode: true },
|
|
26
|
+
appType: "custom",
|
|
27
|
+
base: "/",
|
|
28
|
+
});
|
|
29
|
+
app.use(vite.middlewares);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const compression = (await import("compression")).default;
|
|
33
|
+
const sirv = (await import("sirv")).default;
|
|
34
|
+
app.use(compression());
|
|
35
|
+
app.use("/", sirv(path.join(__dirname, "client"), { extensions: [] }));
|
|
60
36
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
app.use("*all", async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
const url = req.originalUrl;
|
|
40
|
+
let template;
|
|
41
|
+
let render;
|
|
42
|
+
if (!isProduction) {
|
|
43
|
+
if (!vite)
|
|
44
|
+
return res.status(500).end("Internal Server Error");
|
|
45
|
+
template = await fs.readFile("./index.html", "utf-8");
|
|
46
|
+
template = await vite.transformIndexHtml(url, template);
|
|
47
|
+
render = (await vite.ssrLoadModule("/src/entry-server.tsx")).render;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
template = templateHtml;
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
render = (await import("./server/entry-server.js")).render;
|
|
53
|
+
}
|
|
54
|
+
const rendered = await render(url);
|
|
55
|
+
const html = template
|
|
56
|
+
.replace(`<!--app-head-->`, rendered.head ?? "")
|
|
57
|
+
.replace(`<!--app-html-->`, rendered.html ?? "");
|
|
58
|
+
res.status(200).set({ "Content-Type": "text/html" }).send(html);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
vite?.ssrFixStacktrace(e);
|
|
62
|
+
console.log(e.stack);
|
|
63
|
+
res.status(500).end(e.stack);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const url = `http://localhost:${port}`;
|
|
67
|
+
const httpServer = http.createServer(app);
|
|
68
|
+
await new Promise((resolve, reject) => {
|
|
69
|
+
httpServer.once("error", reject);
|
|
70
|
+
httpServer.listen(port, "localhost", () => resolve());
|
|
71
|
+
});
|
|
72
|
+
async function close() {
|
|
73
|
+
if (vite) {
|
|
74
|
+
try {
|
|
75
|
+
await vite.close();
|
|
76
|
+
}
|
|
77
|
+
catch { }
|
|
78
|
+
vite = undefined;
|
|
79
|
+
}
|
|
80
|
+
await new Promise((resolve) => httpServer.close(() => resolve()));
|
|
74
81
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
return { url, close };
|
|
83
|
+
}
|
|
84
|
+
if (!isProduction) {
|
|
85
|
+
createServer().then(({ url }) => console.log(`Server started at ${url}`));
|
|
78
86
|
}
|
|
79
|
-
// if (!isProduction) {
|
|
80
|
-
createServer().then(({ url }) => console.log(`Server started at ${url}`));
|
|
81
|
-
// }
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iconoma/studio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"private": false,
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/theryston/iconoma.git"
|
|
13
|
-
},
|
|
10
|
+
"repository": "github:Theryston/iconoma",
|
|
14
11
|
"homepage": "https://github.com/theryston/iconoma",
|
|
15
12
|
"keywords": [
|
|
16
13
|
"oclif",
|
|
@@ -59,8 +56,7 @@
|
|
|
59
56
|
"react-router": "^7.11.0",
|
|
60
57
|
"sirv": "^3.0.2",
|
|
61
58
|
"svgo": "^4.0.0",
|
|
62
|
-
"zod": "^3.25.76"
|
|
63
|
-
"@iconoma/ui": "0.0.1"
|
|
59
|
+
"zod": "^3.25.76"
|
|
64
60
|
},
|
|
65
61
|
"devDependencies": {
|
|
66
62
|
"@types/canvas-confetti": "^1.9.0",
|
|
@@ -72,8 +68,8 @@
|
|
|
72
68
|
"ts-add-js-extension": "^1.6.6",
|
|
73
69
|
"vite": "^7.3.0",
|
|
74
70
|
"tsx": "^4.21.0",
|
|
75
|
-
"@iconoma/
|
|
76
|
-
"@iconoma/
|
|
71
|
+
"@iconoma/eslint-config": "^0.0.0",
|
|
72
|
+
"@iconoma/typescript-config": "0.0.0"
|
|
77
73
|
},
|
|
78
74
|
"exports": {
|
|
79
75
|
".": "./dist/server.js"
|