rasengan 1.0.0-beta.19 → 1.0.0-beta.20

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.
Files changed (36) hide show
  1. package/lib/esm/server/utils/handleRequest.js +7 -3
  2. package/package.json +3 -3
  3. package/lib/cjs/cli/dirname.js +0 -16
  4. package/lib/cjs/cli/index.js +0 -160
  5. package/lib/cjs/config/index.js +0 -140
  6. package/lib/cjs/config/type.js +0 -2
  7. package/lib/cjs/core/components/index.js +0 -184
  8. package/lib/cjs/core/index.js +0 -6
  9. package/lib/cjs/core/interfaces.js +0 -189
  10. package/lib/cjs/core/types.js +0 -2
  11. package/lib/cjs/decorators/index.js +0 -1
  12. package/lib/cjs/decorators/route.js +0 -24
  13. package/lib/cjs/decorators/router.js +0 -38
  14. package/lib/cjs/decorators/types.js +0 -2
  15. package/lib/cjs/entries/entry-client.js +0 -40
  16. package/lib/cjs/entries/entry-server.js +0 -80
  17. package/lib/cjs/hooks/index.js +0 -0
  18. package/lib/cjs/index.js +0 -30
  19. package/lib/cjs/routing/components/index.js +0 -119
  20. package/lib/cjs/routing/index.js +0 -26
  21. package/lib/cjs/routing/interfaces.js +0 -94
  22. package/lib/cjs/routing/types.js +0 -2
  23. package/lib/cjs/routing/utils/index.js +0 -433
  24. package/lib/cjs/scripts/copy-extra-files.js +0 -28
  25. package/lib/cjs/scripts/generate-package-json.js +0 -28
  26. package/lib/cjs/scripts/refresh-hack.js +0 -24
  27. package/lib/cjs/server/functions/netlify/functions/api.js +0 -48
  28. package/lib/cjs/server/functions/netlify/netlify.toml +0 -26
  29. package/lib/cjs/server/functions/vercel/api/index.js +0 -52
  30. package/lib/cjs/server/functions/vercel/vercel.json +0 -16
  31. package/lib/cjs/server/utils/createFetchRequest.js +0 -40
  32. package/lib/cjs/server/utils/getIp.js +0 -35
  33. package/lib/cjs/server/utils/handleError.js +0 -42
  34. package/lib/cjs/server/utils/handleRequest.js +0 -179
  35. package/lib/cjs/server/utils/index.js +0 -15
  36. package/lib/cjs/server/utils/log.js +0 -128
@@ -36,10 +36,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import fs from "node:fs/promises";
38
38
  import fsSync from "node:fs";
39
- import path, { join } from "node:path";
39
+ import path, { dirname, join } from "node:path";
40
40
  import { createStaticHandler, createStaticRouter, } from "react-router-dom/server.js";
41
41
  // @ts-ignore
42
42
  import { createFetchRequest } from "rasengan";
43
+ import { fileURLToPath } from "node:url";
44
+ var __filename = fileURLToPath(import.meta.url);
45
+ var __dirname = dirname(__filename);
43
46
  // Create server for production only
44
47
  export default function handleRequest(req, res) {
45
48
  var _a;
@@ -49,11 +52,12 @@ export default function handleRequest(req, res) {
49
52
  switch (_b.label) {
50
53
  case 0:
51
54
  console.log({
52
- cwd: process.cwd()
55
+ cwd: process.cwd(),
56
+ __dirname: __dirname
53
57
  });
54
58
  // read dir
55
59
  console.log({
56
- readdir: fsSync.readdirSync(process.cwd()),
60
+ readdir: fsSync.readdirSync(__dirname),
57
61
  readdir2: fsSync.readdirSync(join(process.cwd(), "..")),
58
62
  readdir3: fsSync.readdirSync(join(process.cwd(), "..", "..")),
59
63
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.19",
4
+ "version": "1.0.0-beta.20",
5
5
  "description": "The modern frontend framework for React",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "require": {
18
18
  "types": "./lib/types/index.d.ts",
19
- "default": "./lib/cjs/index.js"
19
+ "default": "./lib/esm/index.js"
20
20
  },
21
21
  "types": "./lib/types/index.d.ts",
22
22
  "default": "./lib/esm/index.js"
@@ -46,7 +46,7 @@
46
46
  "build": "npm run build:client && npm run build:server",
47
47
  "build:client": "vite build --ssrManifest --outDir dist/client",
48
48
  "build:server": "vite build --ssr node_modules/rasengan/lib/esm/entries/entry-server.js --outDir dist/server",
49
- "compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
49
+ "compile": "tsc -b ./tsconfig.esm.json ./tsconfig.types.json",
50
50
  "build:lib:clean": "rm -rf ./lib",
51
51
  "build:lib:all": "npm-run-all build:lib:clean compile && node ./src/scripts/copy-extra-files.js",
52
52
 
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var node_url_1 = require("node:url");
4
- var node_path_1 = require("node:path");
5
- function getDirname() {
6
- if (typeof exports === 'object' && typeof module !== 'undefined') {
7
- return __dirname;
8
- }
9
- else {
10
- // @ts-ignore
11
- var __filename_1 = (0, node_url_1.fileURLToPath)(import.meta.url);
12
- var __dirname_1 = (0, node_path_1.dirname)(__filename_1);
13
- return __dirname_1;
14
- }
15
- }
16
- exports.default = getDirname();
@@ -1,160 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __assign = (this && this.__assign) || function () {
4
- __assign = Object.assign || function(t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
- t[p] = s[p];
9
- }
10
- return t;
11
- };
12
- return __assign.apply(this, arguments);
13
- };
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
30
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
- var __importDefault = (this && this.__importDefault) || function (mod) {
51
- return (mod && mod.__esModule) ? mod : { "default": mod };
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- var chalk_1 = __importDefault(require("chalk"));
55
- var commander_1 = require("commander");
56
- var execa_1 = require("execa");
57
- // Config
58
- // @ts-ignore
59
- var rasengan_config_js_1 = __importDefault(require("../../../../../rasengan.config.js"));
60
- var program = new commander_1.Command();
61
- program
62
- .name(chalk_1.default.blue("rasengan"))
63
- .version("1.0.0", "-v, --version", "Output the current version number");
64
- // Handle the dev command
65
- program
66
- .command("dev")
67
- .option("-p <port>")
68
- .description("Start development server")
69
- .action(function (_a) {
70
- var port = _a.p;
71
- return __awaiter(void 0, void 0, void 0, function () {
72
- var convertedPort;
73
- return __generator(this, function (_b) {
74
- convertedPort = Number(port);
75
- // Checking port
76
- if (port &&
77
- (isNaN(convertedPort) || convertedPort < 0 || convertedPort > 65535)) {
78
- console.log("");
79
- console.log(chalk_1.default.red("Please provide a valid port number between 0-65535"));
80
- console.log("");
81
- process.exit(1);
82
- }
83
- (0, execa_1.execa)("node", ["node_modules/rasengan/server"], {
84
- stdio: "inherit",
85
- env: __assign(__assign({}, process.env), { PORT: convertedPort ? convertedPort.toString() : undefined }),
86
- });
87
- return [2 /*return*/];
88
- });
89
- });
90
- });
91
- // Handle the build command
92
- program
93
- .command("build")
94
- .description("Build the project")
95
- .action(function () {
96
- (0, execa_1.execa)("npm", ["run", "build"], {
97
- cwd: "node_modules/rasengan",
98
- stdio: "inherit", // Pipe child process output to the parent process
99
- });
100
- });
101
- // Handle the prebuild command
102
- program
103
- .command("prepare")
104
- .description("Prepare the project")
105
- .action(function () {
106
- var _a, _b;
107
- // Displaying the message
108
- console.log("");
109
- console.log(chalk_1.default.blue("Preparing your project for production..."));
110
- console.log("");
111
- // Checking the config file in order to know about hosting strategy
112
- var server = rasengan_config_js_1.default.server;
113
- var hostingStrategy = (_b = (_a = server === null || server === void 0 ? void 0 : server.production) === null || _a === void 0 ? void 0 : _a.hosting) !== null && _b !== void 0 ? _b : "custom";
114
- if (hostingStrategy === "vercel") {
115
- // Displaying the message
116
- console.log("Your project is configured to be hosted on ".concat(chalk_1.default.bold.blue(hostingStrategy), "\n"));
117
- // Copying the api folder to the root directory
118
- (0, execa_1.execa)("cp", ["-r", "node_modules/rasengan/lib/esm/server/functions/vercel/api", "."], {
119
- stdio: "inherit",
120
- });
121
- // Copying the vercel.json file to the root directory
122
- (0, execa_1.execa)("cp", ["node_modules/rasengan/lib/esm/server/functions/vercel/vercel.json", "."], {
123
- stdio: "inherit",
124
- });
125
- }
126
- else if (hostingStrategy === "netlify") {
127
- // Displaying the message
128
- console.log("Your project is configured to be hosted on ".concat(chalk_1.default.bold.blue(hostingStrategy), "\n"));
129
- // create a netlify folder at the root
130
- (0, execa_1.execa)("mkdir", ["-p", "netlify"], {
131
- stdio: "inherit",
132
- });
133
- // Copying the netlify folder to the root directory
134
- (0, execa_1.execa)("cp", [
135
- "-r",
136
- "node_modules/rasengan/lib/esm/server/functions/netlify/functions",
137
- "./netlify",
138
- ], {
139
- stdio: "inherit",
140
- });
141
- // Copying the netlify.toml file to the root directory
142
- (0, execa_1.execa)("cp", ["node_modules/rasengan/lib/esm/server/functions/netlify/netlify.toml", "."], {
143
- stdio: "inherit",
144
- });
145
- }
146
- });
147
- // Handle the start command
148
- program
149
- .command("start")
150
- .description("Start the project in production mode")
151
- .action(function () { return __awaiter(void 0, void 0, void 0, function () {
152
- return __generator(this, function (_a) {
153
- (0, execa_1.execa)("npm", ["run", "preview"], {
154
- cwd: "node_modules/rasengan",
155
- stdio: "inherit", // Pipe child process output to the parent process
156
- });
157
- return [2 /*return*/];
158
- });
159
- }); });
160
- program.parse(process.argv);
@@ -1,140 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.adaptPath = exports.defineConfig = void 0;
13
- /**
14
- * Function to define the config for the app
15
- * It will be used by vite.config.ts and other files in other to configure the app
16
- * @param {AppConfig} loadedConfig
17
- */
18
- var defineConfig = function (loadedConfig) {
19
- var _a, _b, _c, _d, _e, _f, _g, _h;
20
- var reactStrictMode = loadedConfig.reactStrictMode, server = loadedConfig.server, vite = loadedConfig.vite;
21
- // Define default values for vite config coming from loadedConfig.vite
22
- var defaultViteConfig = {
23
- plugins: (vite === null || vite === void 0 ? void 0 : vite.plugins) || [],
24
- optimizeDeps: {
25
- exclude: ((_a = vite === null || vite === void 0 ? void 0 : vite.optimizeDeps) === null || _a === void 0 ? void 0 : _a.exclude) || [],
26
- include: ((_b = vite === null || vite === void 0 ? void 0 : vite.optimizeDeps) === null || _b === void 0 ? void 0 : _b.include) || [],
27
- },
28
- css: {
29
- postcss: ((_c = vite === null || vite === void 0 ? void 0 : vite.css) === null || _c === void 0 ? void 0 : _c.postcss) || undefined,
30
- },
31
- build: {
32
- external: ((_d = vite === null || vite === void 0 ? void 0 : vite.build) === null || _d === void 0 ? void 0 : _d.external) || [],
33
- },
34
- resolve: {
35
- alias: ((_e = vite === null || vite === void 0 ? void 0 : vite.resolve) === null || _e === void 0 ? void 0 : _e.alias) || [],
36
- },
37
- };
38
- // Define default values for server config coming from loadedConfig.server
39
- var defaultServerConfig = {
40
- development: {
41
- port: ((_f = server === null || server === void 0 ? void 0 : server.development) === null || _f === void 0 ? void 0 : _f.port) || undefined,
42
- open: ((_g = server === null || server === void 0 ? void 0 : server.development) === null || _g === void 0 ? void 0 : _g.open) || false,
43
- },
44
- production: {
45
- hosting: ((_h = server === null || server === void 0 ? void 0 : server.production) === null || _h === void 0 ? void 0 : _h.hosting) || "custom",
46
- },
47
- };
48
- try {
49
- var config = {
50
- reactStrictMode: reactStrictMode === undefined ? true : reactStrictMode,
51
- server: defaultServerConfig,
52
- vite: {
53
- plugins: defaultViteConfig.plugins,
54
- optimizeDeps: {
55
- exclude: __spreadArray([
56
- "node:http",
57
- "node-fetch"
58
- ], defaultViteConfig.optimizeDeps.exclude, true),
59
- include: __spreadArray([
60
- "react-fast-compare",
61
- "invariant",
62
- "shallowequal",
63
- "react-dom/client",
64
- "react-dom",
65
- "react",
66
- "react-router-dom",
67
- "react-helmet-async"
68
- ], defaultViteConfig.optimizeDeps.include, true),
69
- },
70
- css: {
71
- postcss: defaultViteConfig.css.postcss,
72
- },
73
- build: {
74
- external: defaultViteConfig.build.external,
75
- },
76
- resolve: {
77
- // concat two arrays
78
- alias: __spreadArray([
79
- {
80
- find: "@/",
81
- replacement: "src/",
82
- }
83
- ], defaultViteConfig.resolve.alias, true),
84
- },
85
- appType: "custom",
86
- },
87
- // More config options...
88
- };
89
- return config;
90
- }
91
- catch (error) {
92
- console.error(error);
93
- return {
94
- reactStrictMode: true,
95
- vite: {
96
- optimizeDeps: {
97
- exclude: ["node:http", "node-fetch"],
98
- include: [
99
- "react-fast-compare",
100
- "invariant",
101
- "shallowequal",
102
- "react-dom/client",
103
- "react-dom",
104
- "react",
105
- "react-router-dom",
106
- "react-helmet-async",
107
- ],
108
- },
109
- appType: "custom",
110
- resolve: {
111
- alias: [
112
- {
113
- find: "@/",
114
- replacement: "src/",
115
- },
116
- ],
117
- },
118
- },
119
- };
120
- }
121
- };
122
- exports.defineConfig = defineConfig;
123
- /**
124
- * Function to adapt the path for dev and prod
125
- * @param {string | Array<string>} paths
126
- */
127
- var adaptPath = function (paths) {
128
- // Check if we are in dev mode or prod
129
- var isProduction = process.env.NODE_ENV === "production";
130
- var prefix = isProduction ? "./../../" : "";
131
- // Chech if the path is an array
132
- var isArray = Array.isArray(paths);
133
- // If the path is an array
134
- if (isArray) {
135
- return paths.map(function (path) { return "".concat(process.cwd(), "/").concat(prefix).concat(path); });
136
- }
137
- // If the path is a string
138
- return "".concat(process.cwd(), "/").concat(prefix).concat(paths);
139
- };
140
- exports.adaptPath = adaptPath;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,184 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
- if (k2 === undefined) k2 = k;
30
- var desc = Object.getOwnPropertyDescriptor(m, k);
31
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
- desc = { enumerable: true, get: function() { return m[k]; } };
33
- }
34
- Object.defineProperty(o, k2, desc);
35
- }) : (function(o, m, k, k2) {
36
- if (k2 === undefined) k2 = k;
37
- o[k2] = m[k];
38
- }));
39
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
40
- Object.defineProperty(o, "default", { enumerable: true, value: v });
41
- }) : function(o, v) {
42
- o["default"] = v;
43
- });
44
- var __importStar = (this && this.__importStar) || function (mod) {
45
- if (mod && mod.__esModule) return mod;
46
- var result = {};
47
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
- __setModuleDefault(result, mod);
49
- return result;
50
- };
51
- var __importDefault = (this && this.__importDefault) || function (mod) {
52
- return (mod && mod.__esModule) ? mod : { "default": mod };
53
- };
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.DefaultLayout = exports.Scripts = exports.Body = exports.Heads = exports.ErrorBoundary = exports.PageToRender = exports.Component = void 0;
56
- var jsx_runtime_1 = require("react/jsx-runtime");
57
- var react_1 = __importDefault(require("react"));
58
- var index_js_1 = require("../../routing/utils/index.js");
59
- var react_router_dom_1 = require("react-router-dom");
60
- var HelmetAsync = __importStar(require("react-helmet-async"));
61
- // @ts-ignore
62
- var H = HelmetAsync.default ? HelmetAsync.default : HelmetAsync;
63
- /**
64
- * App component that represent the entry point of the application
65
- */
66
- var Component = function (_a) {
67
- var AppRouter = _a.router, _b = _a.children, children = _b === void 0 ? undefined : _b;
68
- // Return children if they exist
69
- if (children)
70
- return children;
71
- var Router = null;
72
- // Otherwise, get the router and return it
73
- Router = (0, index_js_1.getRouter)(AppRouter);
74
- return (0, jsx_runtime_1.jsx)(Router, {});
75
- };
76
- exports.Component = Component;
77
- /**
78
- * Page component that defines title and description to a page
79
- */
80
- var PageToRender = function (_a) {
81
- var _b, _c;
82
- var Page = _a.page, data = _a.data, layoutMetadata = _a.layoutMetadata;
83
- // Get the page props
84
- var props = data.props || {};
85
- // get params
86
- var params = (0, react_router_dom_1.useParams)();
87
- var finalProps = __assign(__assign({}, props), { params: params });
88
- // Generate meta tags
89
- var metaTags = react_1.default.useMemo(function () {
90
- var metadatas = [];
91
- if (Page.metadata)
92
- metadatas.push(Page.metadata);
93
- if (layoutMetadata)
94
- metadatas.push(layoutMetadata);
95
- return (0, index_js_1.generateMetadata)(metadatas);
96
- }, []);
97
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsxs)(H.Helmet, { children: [metaTags.map(function (meta) { return meta; }), (0, jsx_runtime_1.jsx)("meta", { name: "description", content: ((_b = Page.metadata) === null || _b === void 0 ? void 0 : _b.description) || "" }), (0, jsx_runtime_1.jsx)("title", { children: ((_c = Page.metadata) === null || _c === void 0 ? void 0 : _c.title) || Page.name })] }), (0, jsx_runtime_1.jsx)(Page, __assign({}, finalProps))] }));
98
- };
99
- exports.PageToRender = PageToRender;
100
- /**
101
- * Error fallback component that will be displayed if an error occurs
102
- */
103
- var ErrorBoundary = /** @class */ (function (_super) {
104
- __extends(ErrorBoundary, _super);
105
- function ErrorBoundary() {
106
- var _this = _super !== null && _super.apply(this, arguments) || this;
107
- _this.state = { hasError: false, error: null, info: null };
108
- return _this;
109
- }
110
- ErrorBoundary.prototype.componentDidCatch = function (error, info) {
111
- this.setState({ hasError: true, error: error, info: info });
112
- };
113
- ErrorBoundary.prototype.render = function () {
114
- var _a = this.state, error = _a.error, info = _a.info;
115
- if (this.state.hasError) {
116
- return (0, jsx_runtime_1.jsx)(ErrorFallbackComponent, { error: error, info: info });
117
- }
118
- // @ts-ignore
119
- return this.props.children;
120
- };
121
- return ErrorBoundary;
122
- }(react_1.default.Component));
123
- exports.ErrorBoundary = ErrorBoundary;
124
- /**
125
- * Error fallback component that will be displayed if an error occurs
126
- */
127
- var ErrorFallbackComponent = function (_a) {
128
- var error = _a.error, info = _a.info;
129
- return ((0, jsx_runtime_1.jsx)("div", { style: {
130
- width: "calc(100% - 80px)",
131
- height: "calc(100vh - 80px)",
132
- padding: "40px",
133
- backgroundColor: "#fff",
134
- }, children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { style: { fontSize: "2rem" }, children: "Something went wrong" }), (0, jsx_runtime_1.jsx)("p", { children: error.toString() }), (0, jsx_runtime_1.jsx)("div", { style: {
135
- width: "100%",
136
- height: "auto",
137
- borderRadius: 10,
138
- padding: "20px",
139
- marginTop: "10px",
140
- backgroundColor: "#f0f0f0",
141
- }, children: (0, jsx_runtime_1.jsx)("p", { children: info.componentStack }) })] }) }));
142
- };
143
- /**
144
- * Head component
145
- * @params data - Helmet context
146
- * @returns
147
- */
148
- var Heads = function (_a) {
149
- var data = _a.data, _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c, _d = _a.styles, styles = _d === void 0 ? "" : _d;
150
- if (!data)
151
- return null;
152
- return ((0, jsx_runtime_1.jsxs)("head", { children: [children, data.helmet && data.helmet.meta.toComponent({}), data.helmet && data.helmet.title.toComponent({}), bootstrap && ((0, jsx_runtime_1.jsx)("script", { type: "module", src: bootstrap, defer: true })), styles && ((0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", crossOrigin: "", type: "text/css", href: styles }))] }));
153
- };
154
- exports.Heads = Heads;
155
- /**
156
- * Body component
157
- */
158
- var Body = function (_a) {
159
- var _b = _a.children, children = _b === void 0 ? undefined : _b;
160
- return ((0, jsx_runtime_1.jsxs)("body", { children: [(0, jsx_runtime_1.jsx)("noscript", { dangerouslySetInnerHTML: {
161
- __html: "<b>Enable JavaScript to run this app.</b>",
162
- } }), (0, jsx_runtime_1.jsx)("div", { id: "root", children: "rasengan-body-app" }), children] }));
163
- };
164
- exports.Body = Body;
165
- /**
166
- * Scripts component
167
- */
168
- var Scripts = function (_a) {
169
- var _b = _a.children, children = _b === void 0 ? undefined : _b, _c = _a.bootstrap, bootstrap = _c === void 0 ? "" : _c;
170
- var folder = "esm";
171
- if (typeof exports === "object" && typeof module !== "undefined") {
172
- folder = "cjs";
173
- }
174
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [bootstrap === "" && ((0, jsx_runtime_1.jsx)("script", { type: "module", src: "/node_modules/rasengan/lib/".concat(folder, "/entries/entry-client.js"), defer: true })), children] }));
175
- };
176
- exports.Scripts = Scripts;
177
- /**
178
- * Default layout component
179
- */
180
- var DefaultLayout = function () {
181
- return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.Outlet, {}) }));
182
- };
183
- exports.DefaultLayout = DefaultLayout;
184
- DefaultLayout.path = "/";
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Scripts = exports.Body = void 0;
4
- var index_js_1 = require("./components/index.js");
5
- Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return index_js_1.Body; } });
6
- Object.defineProperty(exports, "Scripts", { enumerable: true, get: function () { return index_js_1.Scripts; } });