afront 1.0.29 → 1.0.30
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/package.json +5 -3
- package/src/browserLogger.js +47 -0
- package/src/index.js +1 -0
- package/webpack.dev.js +56 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "afront",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "AFront is a front-end JavaScript library designed to create seamless server-side rendered (SSSR) websites.",
|
|
5
5
|
"main": "webpack.dev.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build:ssr": "webpack --config webpack.ssr.prod.js",
|
|
9
9
|
"build:alt": "webpack --config webpack.build-prod.js && webpack --config webpack.post-prod-static.js --stats-error-details",
|
|
10
10
|
"prod:ssr": "node build-prod-ssr/ssr.prod.js",
|
|
11
|
-
"start": "
|
|
11
|
+
"start": "node afront.js",
|
|
12
12
|
"static": "node server.js"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
@@ -55,12 +55,14 @@
|
|
|
55
55
|
"html-inline-css-webpack-plugin": "^1.11.2",
|
|
56
56
|
"ignore-styles": "^5.0.1",
|
|
57
57
|
"loader-utils": "^3.3.1",
|
|
58
|
+
"open": "^11.0.0",
|
|
58
59
|
"react-router": "^7.12.0",
|
|
59
60
|
"readline-sync": "^1.4.10",
|
|
60
61
|
"semver": "^7.7.4",
|
|
61
62
|
"styled-components": "^6.1.13",
|
|
62
63
|
"terser-webpack-plugin": "^5.3.10",
|
|
63
|
-
"tmp": "^0.2.3"
|
|
64
|
+
"tmp": "^0.2.3",
|
|
65
|
+
"ws": "^8.19.0"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@babel/cli": "^7.28.3",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
if (process.env.NODE_ENV === "development") {
|
|
2
|
+
const socket = new WebSocket("ws://localhost:9797");
|
|
3
|
+
|
|
4
|
+
function send(level, args) {
|
|
5
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
6
|
+
socket.send(
|
|
7
|
+
JSON.stringify({
|
|
8
|
+
level,
|
|
9
|
+
message: args
|
|
10
|
+
.map((a) =>
|
|
11
|
+
typeof a === "object"
|
|
12
|
+
? JSON.stringify(a, null, 2)
|
|
13
|
+
: String(a)
|
|
14
|
+
)
|
|
15
|
+
.join(" "),
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const originalLog = console.log;
|
|
22
|
+
const originalWarn = console.warn;
|
|
23
|
+
const originalError = console.error;
|
|
24
|
+
|
|
25
|
+
console.log = (...args) => {
|
|
26
|
+
originalLog(...args);
|
|
27
|
+
send("info", args);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
console.warn = (...args) => {
|
|
31
|
+
originalWarn(...args);
|
|
32
|
+
send("warn", args);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
console.error = (...args) => {
|
|
36
|
+
originalError(...args);
|
|
37
|
+
send("error", args);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
window.addEventListener("error", (event) => {
|
|
41
|
+
console.error("Unhandled Error:", event.error || event.message);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
45
|
+
console.error("Unhandled Promise Rejection:", event.reason);
|
|
46
|
+
});
|
|
47
|
+
}
|
package/src/index.js
CHANGED
package/webpack.dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const htmlWebpackPlugin = require("html-webpack-plugin");
|
|
2
|
-
const CspHtmlWebpackPlugin = require(
|
|
2
|
+
const CspHtmlWebpackPlugin = require("csp-html-webpack-plugin");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
5
5
|
const TerserWebpackPlugin = require("terser-webpack-plugin");
|
|
@@ -10,22 +10,49 @@ module.exports = {
|
|
|
10
10
|
mode: "development",
|
|
11
11
|
entry: "./src/index.js",
|
|
12
12
|
devtool: "cheap-module-source-map",
|
|
13
|
+
stats: "errors-warnings",
|
|
14
|
+
|
|
15
|
+
infrastructureLogging: {
|
|
16
|
+
level: "warn",
|
|
17
|
+
},
|
|
18
|
+
|
|
13
19
|
devServer: {
|
|
14
20
|
static: {
|
|
15
21
|
directory: path.join(__dirname, "dev"),
|
|
16
22
|
},
|
|
17
23
|
port: 9999,
|
|
18
|
-
open:
|
|
24
|
+
open: false,
|
|
19
25
|
historyApiFallback: true,
|
|
26
|
+
client: {
|
|
27
|
+
logging: "none",
|
|
28
|
+
overlay: {
|
|
29
|
+
errors: true,
|
|
30
|
+
warnings: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
devMiddleware: {
|
|
35
|
+
stats: "errors-warnings",
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// 🔥 THIS hides "Project is running at" etc
|
|
39
|
+
setupMiddlewares: (middlewares, devServer) => {
|
|
40
|
+
devServer.logger.info = () => {};
|
|
41
|
+
return middlewares;
|
|
42
|
+
},
|
|
20
43
|
headers: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
44
|
+
"Content-Security-Policy": `
|
|
45
|
+
default-src 'self';
|
|
46
|
+
script-src 'self' 'unsafe-inline';
|
|
47
|
+
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
|
|
48
|
+
font-src 'self' https://fonts.gstatic.com;
|
|
49
|
+
connect-src 'self' ws://localhost:9797 ws://localhost:9999;
|
|
50
|
+
`.replace(/\n/g, ""),
|
|
51
|
+
},
|
|
25
52
|
},
|
|
26
53
|
output: {
|
|
27
54
|
filename: "[name].bundle.js",
|
|
28
|
-
path:
|
|
55
|
+
path: path.resolve(__dirname, "dev"),
|
|
29
56
|
publicPath: "/",
|
|
30
57
|
clean: true,
|
|
31
58
|
},
|
|
@@ -114,15 +141,27 @@ module.exports = {
|
|
|
114
141
|
};
|
|
115
142
|
},
|
|
116
143
|
}),
|
|
117
|
-
new CspHtmlWebpackPlugin(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
new CspHtmlWebpackPlugin(
|
|
145
|
+
{
|
|
146
|
+
"default-src": ["'self'"],
|
|
147
|
+
"script-src": ["'self'"],
|
|
148
|
+
"style-src": [
|
|
149
|
+
"'self'",
|
|
150
|
+
"https://fonts.googleapis.com",
|
|
151
|
+
"'unsafe-hashes'",
|
|
152
|
+
],
|
|
153
|
+
"style-src-elem": [
|
|
154
|
+
"'self'",
|
|
155
|
+
"https://fonts.googleapis.com",
|
|
156
|
+
"https://fonts.gstatic.com",
|
|
157
|
+
],
|
|
158
|
+
"font-src": ["'self'", "https://fonts.gstatic.com"],
|
|
159
|
+
"connect-src": ["'self'", "ws://localhost:9797", "ws://localhost:9999"],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
hashingMethod: "sha256",
|
|
163
|
+
hashEnabled: { "script-src": true, "style-src": true },
|
|
164
|
+
},
|
|
165
|
+
),
|
|
127
166
|
],
|
|
128
167
|
};
|