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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "afront",
3
- "version": "1.0.29",
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": "webpack serve --config webpack.dev.js",
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
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import ReactDOM, { hydrateRoot } from "react-dom/client";
3
3
  import App from "./App";
4
4
  import { BrowserRouter } from "react-router";
5
+ import "./browserLogger";
5
6
 
6
7
  const container = document.getElementById("asggen");
7
8
 
package/webpack.dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const htmlWebpackPlugin = require("html-webpack-plugin");
2
- const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
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: true,
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
- // Dev server: send a permissive CSP header to avoid blocking during development.
22
- // This header is intentionally more permissive than the production meta tag.
23
- "Content-Security-Policy": "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com"
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: `${__dirname}/dev`,
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
- "default-src": ["'self'"],
119
- "script-src": ["'self'"],
120
- "style-src": ["'self'", "https://fonts.googleapis.com", "'unsafe-hashes'"],
121
- "style-src-elem": ["'self'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"],
122
- "font-src": ["'self'", "https://fonts.gstatic.com"]
123
- }, {
124
- hashingMethod: 'sha256',
125
- hashEnabled: { 'script-src': true, 'style-src': true }
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
  };