baraqex 1.0.40 → 1.0.43
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/dist/browser.d.ts +16 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +51 -169
- package/dist/browser.js.map +4 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -15
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/templates/ssr-template/esbuild.config.js +19 -2
- package/templates/ssr-template/package-lock.json +8 -8
- package/templates/ssr-template/package.json +1 -1
- package/templates/ssr-template/src/client.tsx +10 -3
- package/templates/ssr-template/src/server.ts +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -5,10 +5,25 @@
|
|
|
5
5
|
export * from 'frontend-hamroun';
|
|
6
6
|
export { loadGoWasm, callWasmFunction, isWasmReady, getWasmFunctions, useGoWasm } from './wasm.js';
|
|
7
7
|
export type { GoWasmOptions, GoWasmInstance } from './wasm.js';
|
|
8
|
-
export
|
|
8
|
+
export declare function generateDocument(content: string, options?: any): string;
|
|
9
|
+
export declare function generateErrorPage(statusCode: number, message: string): string;
|
|
10
|
+
export declare function generateLoadingPage(message?: string): string;
|
|
9
11
|
export declare function renderToString(content: any): string;
|
|
10
12
|
export declare function generateToken(length?: number): string;
|
|
11
13
|
export declare function safeJsonParse<T>(json: string, fallback: T): T;
|
|
12
14
|
export declare const isBrowser: boolean;
|
|
13
15
|
export declare const isNode = false;
|
|
16
|
+
export declare const Server: null;
|
|
17
|
+
export declare const createServer: null;
|
|
18
|
+
export declare const createDevServer: null;
|
|
19
|
+
export declare const createProductionServer: null;
|
|
20
|
+
export declare const Database: null;
|
|
21
|
+
export declare const AuthService: null;
|
|
22
|
+
export declare const ApiRouter: null;
|
|
23
|
+
export declare const requestLogger: null;
|
|
24
|
+
export declare const errorHandler: null;
|
|
25
|
+
export declare const notFoundHandler: null;
|
|
26
|
+
export declare const rateLimit: null;
|
|
27
|
+
export declare const initNodeWasm: null;
|
|
28
|
+
export declare const loadGoWasmFromFile: null;
|
|
14
29
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGnG,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGnG,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAI/D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,GAAQ,GAAG,MAAM,CAiB3E;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ7E;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,MAAqB,GAAG,MAAM,CAa1E;AAYD,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,MAAM,CAanD;AAGD,wBAAgB,aAAa,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAWzD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAM7D;AAGD,eAAO,MAAM,SAAS,SAAgC,CAAC;AACvD,eAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,MAAM,MAAO,CAAC;AAC3B,eAAO,MAAM,YAAY,MAAO,CAAC;AACjC,eAAO,MAAM,eAAe,MAAO,CAAC;AACpC,eAAO,MAAM,sBAAsB,MAAO,CAAC;AAC3C,eAAO,MAAM,QAAQ,MAAO,CAAC;AAC7B,eAAO,MAAM,WAAW,MAAO,CAAC;AAChC,eAAO,MAAM,SAAS,MAAO,CAAC;AAC9B,eAAO,MAAM,aAAa,MAAO,CAAC;AAClC,eAAO,MAAM,YAAY,MAAO,CAAC;AACjC,eAAO,MAAM,eAAe,MAAO,CAAC;AACpC,eAAO,MAAM,SAAS,MAAO,CAAC;AAC9B,eAAO,MAAM,YAAY,MAAO,CAAC;AACjC,eAAO,MAAM,kBAAkB,MAAO,CAAC"}
|
package/dist/browser.js
CHANGED
|
@@ -981,194 +981,50 @@ function useGoWasm(wasmUrl, options = {}) {
|
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
983
|
|
|
984
|
-
// src/
|
|
984
|
+
// src/browser.ts
|
|
985
985
|
function generateDocument(content, options = {}) {
|
|
986
|
-
const {
|
|
987
|
-
title = "Frontend Hamroun App",
|
|
988
|
-
description = "",
|
|
989
|
-
lang = "en",
|
|
990
|
-
charset = "UTF-8",
|
|
991
|
-
viewport = "width=device-width, initial-scale=1.0",
|
|
992
|
-
scripts = [],
|
|
993
|
-
styles = [],
|
|
994
|
-
meta = {},
|
|
995
|
-
bodyClasses = "",
|
|
996
|
-
htmlAttrs = {},
|
|
997
|
-
bodyAttrs = {},
|
|
998
|
-
initialData = {},
|
|
999
|
-
componentName = ""
|
|
1000
|
-
} = options;
|
|
1001
|
-
const htmlAttributes = Object.entries(htmlAttrs).map(([key, value]) => `${key}="${escapeHtml(value)}"`).join(" ");
|
|
1002
|
-
const bodyAttributes = Object.entries(bodyAttrs).map(([key, value]) => `${key}="${escapeHtml(value)}"`).join(" ");
|
|
1003
|
-
const metaTags = [
|
|
1004
|
-
`<meta charset="${charset}">`,
|
|
1005
|
-
`<meta name="viewport" content="${viewport}">`,
|
|
1006
|
-
description ? `<meta name="description" content="${escapeHtml(description)}">` : ""
|
|
1007
|
-
];
|
|
1008
|
-
Object.entries(meta).forEach(([name, content2]) => {
|
|
1009
|
-
metaTags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(content2)}">`);
|
|
1010
|
-
});
|
|
1011
|
-
const scriptTags = scripts.map((src) => {
|
|
1012
|
-
if (src.startsWith("<script")) {
|
|
1013
|
-
return src;
|
|
1014
|
-
}
|
|
1015
|
-
return `<script src="${escapeHtml(src)}" ${src.endsWith(".js") ? 'type="module"' : ""} defer><\/script>`;
|
|
1016
|
-
});
|
|
1017
|
-
const styleTags = styles.map((href) => {
|
|
1018
|
-
if (href.startsWith("<style")) {
|
|
1019
|
-
return href;
|
|
1020
|
-
}
|
|
1021
|
-
return `<link rel="stylesheet" href="${escapeHtml(href)}">`;
|
|
1022
|
-
});
|
|
1023
|
-
const initialDataScript = Object.keys(initialData).length > 0 ? `<script id="__APP_DATA__" type="application/json">${escapeHtml(JSON.stringify(initialData))}<\/script>` : "";
|
|
986
|
+
const { title = "App", description = "", styles = [], scripts = [] } = options;
|
|
1024
987
|
return `<!DOCTYPE html>
|
|
1025
|
-
<html lang="
|
|
988
|
+
<html lang="en">
|
|
1026
989
|
<head>
|
|
1027
|
-
|
|
990
|
+
<meta charset="UTF-8">
|
|
991
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1028
992
|
<title>${escapeHtml(title)}</title>
|
|
1029
|
-
${
|
|
993
|
+
${description ? `<meta name="description" content="${escapeHtml(description)}">` : ""}
|
|
994
|
+
${styles.map((href) => `<link rel="stylesheet" href="${escapeHtml(href)}">`).join("\n ")}
|
|
1030
995
|
</head>
|
|
1031
|
-
<body
|
|
1032
|
-
<div id="app-root"
|
|
1033
|
-
${
|
|
1034
|
-
${scriptTags.join("\n ")}
|
|
996
|
+
<body>
|
|
997
|
+
<div id="app-root">${content}</div>
|
|
998
|
+
${scripts.map((src) => `<script src="${escapeHtml(src)}" defer><\/script>`).join("\n ")}
|
|
1035
999
|
</body>
|
|
1036
1000
|
</html>`;
|
|
1037
1001
|
}
|
|
1038
|
-
function generateErrorPage(statusCode, message
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
401: "Unauthorized",
|
|
1042
|
-
403: "Forbidden",
|
|
1043
|
-
404: "Not Found",
|
|
1044
|
-
500: "Internal Server Error"
|
|
1045
|
-
};
|
|
1046
|
-
const title = `${statusCode} - ${errorMessages[statusCode] || "Error"}`;
|
|
1047
|
-
const isDev = false;
|
|
1048
|
-
const errorDetails = isDev && error ? `
|
|
1049
|
-
<div class="error-details">
|
|
1050
|
-
<pre>${escapeHtml(error.stack || error.message)}</pre>
|
|
1051
|
-
</div>
|
|
1052
|
-
` : "";
|
|
1053
|
-
const content = `
|
|
1054
|
-
<div class="error-container">
|
|
1002
|
+
function generateErrorPage(statusCode, message) {
|
|
1003
|
+
return generateDocument(`
|
|
1004
|
+
<div style="text-align: center; padding: 2rem;">
|
|
1055
1005
|
<h1>${statusCode}</h1>
|
|
1056
|
-
<h2>${escapeHtml(errorMessages[statusCode] || "Error")}</h2>
|
|
1057
1006
|
<p>${escapeHtml(message)}</p>
|
|
1058
|
-
|
|
1059
|
-
<a href="/" class="home-link">Back to Home</a>
|
|
1007
|
+
<a href="/">Back to Home</a>
|
|
1060
1008
|
</div>
|
|
1061
|
-
|
|
1062
|
-
const styles = [`<style>
|
|
1063
|
-
body {
|
|
1064
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
1065
|
-
display: flex;
|
|
1066
|
-
justify-content: center;
|
|
1067
|
-
align-items: center;
|
|
1068
|
-
min-height: 100vh;
|
|
1069
|
-
margin: 0;
|
|
1070
|
-
background-color: #f7f7f7;
|
|
1071
|
-
color: #333;
|
|
1072
|
-
}
|
|
1073
|
-
.error-container {
|
|
1074
|
-
text-align: center;
|
|
1075
|
-
padding: 2rem;
|
|
1076
|
-
border-radius: 8px;
|
|
1077
|
-
background-color: white;
|
|
1078
|
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
1079
|
-
max-width: 600px;
|
|
1080
|
-
width: 100%;
|
|
1081
|
-
}
|
|
1082
|
-
h1 {
|
|
1083
|
-
font-size: 6rem;
|
|
1084
|
-
margin: 0;
|
|
1085
|
-
color: #e74c3c;
|
|
1086
|
-
}
|
|
1087
|
-
h2 {
|
|
1088
|
-
margin-top: 0;
|
|
1089
|
-
margin-bottom: 1rem;
|
|
1090
|
-
color: #333;
|
|
1091
|
-
}
|
|
1092
|
-
.error-details {
|
|
1093
|
-
text-align: left;
|
|
1094
|
-
margin: 2rem 0;
|
|
1095
|
-
padding: 1rem;
|
|
1096
|
-
background-color: #f8f8f8;
|
|
1097
|
-
border-radius: 4px;
|
|
1098
|
-
overflow: auto;
|
|
1099
|
-
}
|
|
1100
|
-
pre {
|
|
1101
|
-
margin: 0;
|
|
1102
|
-
font-family: monospace;
|
|
1103
|
-
font-size: 0.85rem;
|
|
1104
|
-
white-space: pre-wrap;
|
|
1105
|
-
}
|
|
1106
|
-
.home-link {
|
|
1107
|
-
display: inline-block;
|
|
1108
|
-
margin-top: 1.5rem;
|
|
1109
|
-
padding: 0.75rem 1.5rem;
|
|
1110
|
-
background-color: #3498db;
|
|
1111
|
-
color: white;
|
|
1112
|
-
text-decoration: none;
|
|
1113
|
-
border-radius: 4px;
|
|
1114
|
-
transition: background-color 0.2s;
|
|
1115
|
-
}
|
|
1116
|
-
.home-link:hover {
|
|
1117
|
-
background-color: #2980b9;
|
|
1118
|
-
}
|
|
1119
|
-
</style>`];
|
|
1120
|
-
return generateDocument(content, {
|
|
1121
|
-
title,
|
|
1122
|
-
description: `Error ${statusCode}: ${errorMessages[statusCode] || "Error"}`,
|
|
1123
|
-
bodyClasses: "error-page",
|
|
1124
|
-
styles
|
|
1125
|
-
});
|
|
1009
|
+
`, { title: `Error ${statusCode}` });
|
|
1126
1010
|
}
|
|
1127
1011
|
function generateLoadingPage(message = "Loading...") {
|
|
1128
|
-
|
|
1129
|
-
<div
|
|
1130
|
-
<div
|
|
1012
|
+
return generateDocument(`
|
|
1013
|
+
<div style="text-align: center; padding: 2rem;">
|
|
1014
|
+
<div style="display: inline-block; width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #3498db; border-radius: 50%; animation: spin 1s linear infinite;"></div>
|
|
1131
1015
|
<p>${escapeHtml(message)}</p>
|
|
1016
|
+
<style>
|
|
1017
|
+
@keyframes spin {
|
|
1018
|
+
0% { transform: rotate(0deg); }
|
|
1019
|
+
100% { transform: rotate(360deg); }
|
|
1020
|
+
}
|
|
1021
|
+
</style>
|
|
1132
1022
|
</div>
|
|
1133
|
-
|
|
1134
|
-
const styles = [`<style>
|
|
1135
|
-
body {
|
|
1136
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
1137
|
-
display: flex;
|
|
1138
|
-
justify-content: center;
|
|
1139
|
-
align-items: center;
|
|
1140
|
-
min-height: 100vh;
|
|
1141
|
-
margin: 0;
|
|
1142
|
-
background-color: #f7f7f7;
|
|
1143
|
-
color: #333;
|
|
1144
|
-
}
|
|
1145
|
-
.loading-container {
|
|
1146
|
-
text-align: center;
|
|
1147
|
-
}
|
|
1148
|
-
.spinner {
|
|
1149
|
-
width: 50px;
|
|
1150
|
-
height: 50px;
|
|
1151
|
-
border: 5px solid rgba(0, 0, 0, 0.1);
|
|
1152
|
-
border-radius: 50%;
|
|
1153
|
-
border-top-color: #3498db;
|
|
1154
|
-
animation: spin 1s ease-in-out infinite;
|
|
1155
|
-
margin: 0 auto 20px;
|
|
1156
|
-
}
|
|
1157
|
-
@keyframes spin {
|
|
1158
|
-
to { transform: rotate(360deg); }
|
|
1159
|
-
}
|
|
1160
|
-
</style>`];
|
|
1161
|
-
return generateDocument(content, {
|
|
1162
|
-
title: "Loading",
|
|
1163
|
-
bodyClasses: "loading-page",
|
|
1164
|
-
styles
|
|
1165
|
-
});
|
|
1023
|
+
`, { title: "Loading" });
|
|
1166
1024
|
}
|
|
1167
1025
|
function escapeHtml(text) {
|
|
1168
1026
|
return String(text).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1169
1027
|
}
|
|
1170
|
-
|
|
1171
|
-
// src/browser.ts
|
|
1172
1028
|
function renderToString(content) {
|
|
1173
1029
|
if (typeof content === "string") {
|
|
1174
1030
|
return content;
|
|
@@ -1203,22 +1059,42 @@ function safeJsonParse(json, fallback) {
|
|
|
1203
1059
|
}
|
|
1204
1060
|
var isBrowser = typeof window !== "undefined";
|
|
1205
1061
|
var isNode = false;
|
|
1062
|
+
var Server = null;
|
|
1063
|
+
var createServer = null;
|
|
1064
|
+
var createDevServer = null;
|
|
1065
|
+
var createProductionServer = null;
|
|
1066
|
+
var Database = null;
|
|
1067
|
+
var AuthService = null;
|
|
1068
|
+
var ApiRouter = null;
|
|
1069
|
+
var requestLogger = null;
|
|
1070
|
+
var errorHandler = null;
|
|
1071
|
+
var notFoundHandler = null;
|
|
1072
|
+
var rateLimit = null;
|
|
1073
|
+
var initNodeWasm = null;
|
|
1074
|
+
var loadGoWasmFromFile = null;
|
|
1206
1075
|
console.log("Baraqex - Browser version loaded");
|
|
1207
1076
|
export {
|
|
1077
|
+
ApiRouter,
|
|
1078
|
+
AuthService,
|
|
1208
1079
|
Component,
|
|
1080
|
+
Database,
|
|
1209
1081
|
Fragment,
|
|
1210
1082
|
LifecycleEvents,
|
|
1211
1083
|
Link,
|
|
1212
1084
|
Redirect,
|
|
1213
1085
|
Route,
|
|
1214
1086
|
RouterProvider,
|
|
1087
|
+
Server,
|
|
1215
1088
|
StoreProvider,
|
|
1216
1089
|
Switch,
|
|
1217
1090
|
batchUpdates,
|
|
1218
1091
|
callWasmFunction,
|
|
1219
1092
|
createContext,
|
|
1093
|
+
createDevServer,
|
|
1220
1094
|
createElement,
|
|
1221
1095
|
createEventBus,
|
|
1096
|
+
createProductionServer,
|
|
1097
|
+
createServer,
|
|
1222
1098
|
createStore,
|
|
1223
1099
|
diff,
|
|
1224
1100
|
emitAppDestroyed,
|
|
@@ -1231,6 +1107,7 @@ export {
|
|
|
1231
1107
|
emitComponentMounted,
|
|
1232
1108
|
emitComponentUnmounted,
|
|
1233
1109
|
emitComponentUpdated,
|
|
1110
|
+
errorHandler,
|
|
1234
1111
|
globalEventBus as eventBus,
|
|
1235
1112
|
generateDocument,
|
|
1236
1113
|
generateErrorPage,
|
|
@@ -1238,6 +1115,7 @@ export {
|
|
|
1238
1115
|
generateToken,
|
|
1239
1116
|
getWasmFunctions,
|
|
1240
1117
|
hydrate,
|
|
1118
|
+
initNodeWasm,
|
|
1241
1119
|
isBrowser,
|
|
1242
1120
|
isNode,
|
|
1243
1121
|
isWasmReady,
|
|
@@ -1245,7 +1123,9 @@ export {
|
|
|
1245
1123
|
jsx as jsxDEV,
|
|
1246
1124
|
jsx as jsxs,
|
|
1247
1125
|
loadGoWasm,
|
|
1126
|
+
loadGoWasmFromFile,
|
|
1248
1127
|
logger,
|
|
1128
|
+
notFoundHandler,
|
|
1249
1129
|
onAppDestroyed,
|
|
1250
1130
|
onAppError,
|
|
1251
1131
|
onAppInit,
|
|
@@ -1256,8 +1136,10 @@ export {
|
|
|
1256
1136
|
onComponentMounted,
|
|
1257
1137
|
onComponentUnmounted,
|
|
1258
1138
|
onComponentUpdated,
|
|
1139
|
+
rateLimit,
|
|
1259
1140
|
render,
|
|
1260
1141
|
renderToString,
|
|
1142
|
+
requestLogger,
|
|
1261
1143
|
safeJsonParse,
|
|
1262
1144
|
shouldComponentUpdate,
|
|
1263
1145
|
thunk,
|