baraqex 1.0.35 → 1.0.36
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.js +635 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.package.json +4 -0
- package/dist/index.js +2024 -33
- package/dist/index.js.map +7 -1
- package/dist/server/index.js +1357 -432
- package/dist/server/index.js.map +7 -1
- package/dist/server/package.json +4 -0
- package/dist/wasm.js +86 -104
- package/dist/wasm.js.map +7 -1
- package/package.json +102 -86
- package/templates/ssr-template/esbuild.config.js +32 -3
- package/templates/ssr-template/package-lock.json +33 -1018
- package/templates/ssr-template/package.json +1 -0
- package/templates/ssr-template/src/App.tsx +1 -1
- package/dist/frontend/components/WasmLoader.d.ts +0 -1
- package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
- package/dist/frontend/components/WasmLoader.js +0 -2
- package/dist/frontend/components/WasmLoader.js.map +0 -1
- package/dist/frontend/hooks/useWasm.d.ts +0 -1
- package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
- package/dist/frontend/hooks/useWasm.js +0 -2
- package/dist/frontend/hooks/useWasm.js.map +0 -1
- package/dist/frontend/index.d.ts +0 -1
- package/dist/frontend/index.d.ts.map +0 -1
- package/dist/frontend/index.js +0 -2
- package/dist/frontend/index.js.map +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.d.ts.map +0 -1
- package/dist/renderComponent.d.ts +0 -9
- package/dist/renderComponent.d.ts.map +0 -1
- package/dist/renderComponent.js +0 -39
- package/dist/renderComponent.js.map +0 -1
- package/dist/server/api-router.d.ts +0 -16
- package/dist/server/api-router.d.ts.map +0 -1
- package/dist/server/api-router.js +0 -121
- package/dist/server/api-router.js.map +0 -1
- package/dist/server/auth.d.ts +0 -33
- package/dist/server/auth.d.ts.map +0 -1
- package/dist/server/auth.js +0 -74
- package/dist/server/auth.js.map +0 -1
- package/dist/server/database.d.ts +0 -25
- package/dist/server/database.d.ts.map +0 -1
- package/dist/server/database.js +0 -109
- package/dist/server/database.js.map +0 -1
- package/dist/server/index.d.ts +0 -117
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/middleware.d.ts +0 -12
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/middleware.js +0 -46
- package/dist/server/middleware.js.map +0 -1
- package/dist/server/server.d.ts +0 -10
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -81
- package/dist/server/server.js.map +0 -1
- package/dist/server/templates.d.ts +0 -31
- package/dist/server/templates.d.ts.map +0 -1
- package/dist/server/templates.js +0 -208
- package/dist/server/templates.js.map +0 -1
- package/dist/server/types.d.ts +0 -67
- package/dist/server/types.d.ts.map +0 -1
- package/dist/server/types.js +0 -2
- package/dist/server/types.js.map +0 -1
- package/dist/server/utils.d.ts +0 -71
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/utils.js +0 -165
- package/dist/server/utils.js.map +0 -1
- package/dist/server/wasm.d.ts +0 -29
- package/dist/server/wasm.d.ts.map +0 -1
- package/dist/server/wasm.js +0 -208
- package/dist/server/wasm.js.map +0 -1
- package/dist/server-renderer.d.ts +0 -5
- package/dist/server-renderer.d.ts.map +0 -1
- package/dist/server-renderer.js +0 -27
- package/dist/server-renderer.js.map +0 -1
- package/dist/wasm.d.ts +0 -51
- package/dist/wasm.d.ts.map +0 -1
package/dist/server/utils.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
/**
|
|
3
|
-
* Utility functions for server-side operations
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Safely parse JSON with error handling
|
|
7
|
-
*/
|
|
8
|
-
export declare function safeJsonParse<T>(json: string, fallback: T): T;
|
|
9
|
-
/**
|
|
10
|
-
* Generate a secure random token
|
|
11
|
-
*/
|
|
12
|
-
export declare function generateToken(length?: number): string;
|
|
13
|
-
/**
|
|
14
|
-
* Hash a string using SHA-256
|
|
15
|
-
*/
|
|
16
|
-
export declare function hashString(input: string, salt?: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Get pagination parameters from request
|
|
19
|
-
*/
|
|
20
|
-
export declare function getPagination(req: Request): {
|
|
21
|
-
page: number;
|
|
22
|
-
limit: number;
|
|
23
|
-
skip: number;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Standard success response format
|
|
27
|
-
*/
|
|
28
|
-
export declare function sendSuccess<T>(res: Response, data: T, message?: string): Response;
|
|
29
|
-
/**
|
|
30
|
-
* Standard error response format
|
|
31
|
-
*/
|
|
32
|
-
export declare function sendError(res: Response, message?: string, statusCode?: number, errors?: any): Response;
|
|
33
|
-
/**
|
|
34
|
-
* Validate required fields in request body
|
|
35
|
-
*/
|
|
36
|
-
export declare function validateFields(req: Request, requiredFields: string[]): {
|
|
37
|
-
valid: boolean;
|
|
38
|
-
missing: string[];
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Handle file upload validation
|
|
42
|
-
*/
|
|
43
|
-
export declare function validateFileUpload(file: any, // Using 'any' to avoid the Express.Multer dependency
|
|
44
|
-
options?: {
|
|
45
|
-
maxSize?: number;
|
|
46
|
-
allowedTypes?: string[];
|
|
47
|
-
}): {
|
|
48
|
-
valid: boolean;
|
|
49
|
-
error?: string;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Get server environment information
|
|
53
|
-
*/
|
|
54
|
-
export declare function getEnvironmentInfo(): Record<string, any>;
|
|
55
|
-
/**
|
|
56
|
-
* Check if a directory is empty
|
|
57
|
-
*/
|
|
58
|
-
export declare function isDirectoryEmpty(dirPath: string): Promise<boolean>;
|
|
59
|
-
/**
|
|
60
|
-
* Create directory if it doesn't exist
|
|
61
|
-
*/
|
|
62
|
-
export declare function ensureDirectory(dirPath: string): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Write JSON to file
|
|
65
|
-
*/
|
|
66
|
-
export declare function writeJsonFile(filePath: string, data: any): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Read JSON from file
|
|
69
|
-
*/
|
|
70
|
-
export declare function readJsonFile<T>(filePath: string, defaultValue: T): Promise<T>;
|
|
71
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK5C;;GAEG;AAEH;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAM7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,MAAW,GAAG,MAAM,CAEnE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAgBzF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,MAAkB,GAAG,QAAQ,CAM5F;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,QAAQ,EACb,OAAO,GAAE,MAA4B,EACrC,UAAU,GAAE,MAAY,EACxB,MAAM,CAAC,EAAE,GAAG,GACX,QAAQ,CAMV;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,cAAc,EAAE,MAAM,EAAE,GACvB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAUvC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,GAAG,EAAE,qDAAqD;AAChE,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACL;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAyBpC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CASxD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQxE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOnF"}
|
package/dist/server/utils.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
/**
|
|
5
|
-
* Utility functions for server-side operations
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Safely parse JSON with error handling
|
|
9
|
-
*/
|
|
10
|
-
export function safeJsonParse(json, fallback) {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(json);
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
return fallback;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generate a secure random token
|
|
20
|
-
*/
|
|
21
|
-
export function generateToken(length = 32) {
|
|
22
|
-
return crypto.randomBytes(length).toString('hex');
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Hash a string using SHA-256
|
|
26
|
-
*/
|
|
27
|
-
export function hashString(input, salt = '') {
|
|
28
|
-
return crypto.createHash('sha256').update(input + salt).digest('hex');
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get pagination parameters from request
|
|
32
|
-
*/
|
|
33
|
-
export function getPagination(req) {
|
|
34
|
-
const page = Math.max(1, parseInt(req.query.page) || 1);
|
|
35
|
-
const rawLimit = parseInt(req.query.limit);
|
|
36
|
-
// If no limit is provided or limit is 0/invalid, use default of 20
|
|
37
|
-
// If limit is provided and valid, enforce min of 1 and max of 100
|
|
38
|
-
let limit;
|
|
39
|
-
if (isNaN(rawLimit) || rawLimit <= 0) {
|
|
40
|
-
limit = 20; // Default limit
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
limit = Math.max(1, Math.min(100, rawLimit));
|
|
44
|
-
}
|
|
45
|
-
const skip = (page - 1) * limit;
|
|
46
|
-
return { page, limit, skip };
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Standard success response format
|
|
50
|
-
*/
|
|
51
|
-
export function sendSuccess(res, data, message = 'Success') {
|
|
52
|
-
return res.json({
|
|
53
|
-
success: true,
|
|
54
|
-
message,
|
|
55
|
-
data
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Standard error response format
|
|
60
|
-
*/
|
|
61
|
-
export function sendError(res, message = 'An error occurred', statusCode = 400, errors) {
|
|
62
|
-
return res.status(statusCode).json({
|
|
63
|
-
success: false,
|
|
64
|
-
message,
|
|
65
|
-
errors: errors || undefined
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Validate required fields in request body
|
|
70
|
-
*/
|
|
71
|
-
export function validateFields(req, requiredFields) {
|
|
72
|
-
const missing = requiredFields.filter(field => {
|
|
73
|
-
const value = req.body[field];
|
|
74
|
-
return value === undefined || value === null || value === '';
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
valid: missing.length === 0,
|
|
78
|
-
missing
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Handle file upload validation
|
|
83
|
-
*/
|
|
84
|
-
export function validateFileUpload(file, // Using 'any' to avoid the Express.Multer dependency
|
|
85
|
-
options = {}) {
|
|
86
|
-
if (!file) {
|
|
87
|
-
return { valid: false, error: 'No file provided' };
|
|
88
|
-
}
|
|
89
|
-
// Check file size
|
|
90
|
-
if (options.maxSize && file.size > options.maxSize) {
|
|
91
|
-
return {
|
|
92
|
-
valid: false,
|
|
93
|
-
error: `File too large. Maximum size allowed is ${options.maxSize / 1024 / 1024}MB`
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
// Check file type
|
|
97
|
-
if (options.allowedTypes && options.allowedTypes.length > 0) {
|
|
98
|
-
const fileType = file.mimetype;
|
|
99
|
-
if (!options.allowedTypes.includes(fileType)) {
|
|
100
|
-
return {
|
|
101
|
-
valid: false,
|
|
102
|
-
error: `Invalid file type. Allowed types: ${options.allowedTypes.join(', ')}`
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return { valid: true };
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get server environment information
|
|
110
|
-
*/
|
|
111
|
-
export function getEnvironmentInfo() {
|
|
112
|
-
return {
|
|
113
|
-
nodeVersion: process.version,
|
|
114
|
-
platform: process.platform,
|
|
115
|
-
arch: process.arch,
|
|
116
|
-
memory: process.memoryUsage(),
|
|
117
|
-
uptime: process.uptime(),
|
|
118
|
-
env: process.env.NODE_ENV || 'development'
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Check if a directory is empty
|
|
123
|
-
*/
|
|
124
|
-
export async function isDirectoryEmpty(dirPath) {
|
|
125
|
-
try {
|
|
126
|
-
const files = await fs.readdir(dirPath);
|
|
127
|
-
return files.length === 0;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
// Directory doesn't exist or can't be read
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Create directory if it doesn't exist
|
|
136
|
-
*/
|
|
137
|
-
export async function ensureDirectory(dirPath) {
|
|
138
|
-
try {
|
|
139
|
-
await fs.access(dirPath);
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
// Directory doesn't exist, create it
|
|
143
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Write JSON to file
|
|
148
|
-
*/
|
|
149
|
-
export async function writeJsonFile(filePath, data) {
|
|
150
|
-
await ensureDirectory(path.dirname(filePath));
|
|
151
|
-
await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf8');
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Read JSON from file
|
|
155
|
-
*/
|
|
156
|
-
export async function readJsonFile(filePath, defaultValue) {
|
|
157
|
-
try {
|
|
158
|
-
const data = await fs.readFile(filePath, 'utf8');
|
|
159
|
-
return safeJsonParse(data, defaultValue);
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
return defaultValue;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/server/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAI,IAAY,EAAE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IACnD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qCAAqC;QACrC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,IAAS;IAC7D,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,QAAgB,EAAE,YAAe;IACrE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,aAAa,CAAI,IAAI,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,YAAY,CAAC;IACtB,CAAC;AACH,CAAC"}
|
package/dist/server/wasm.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { GoWasmInstance, GoWasmOptions } from '../server/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Initialize the Node.js environment for running Go WASM modules
|
|
4
|
-
*/
|
|
5
|
-
export declare function initNodeWasm(): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Load a Go WASM module from a file path for server-side usage
|
|
8
|
-
*/
|
|
9
|
-
export declare function loadGoWasmFromFile(wasmFilePath: string, options?: GoWasmOptions): Promise<GoWasmInstance>;
|
|
10
|
-
/**
|
|
11
|
-
* Call a Go WASM function in Node.js environment
|
|
12
|
-
*/
|
|
13
|
-
export declare function callWasmFunction(funcName: string, ...args: any[]): any;
|
|
14
|
-
/**
|
|
15
|
-
* Check if Go WASM is ready in Node.js
|
|
16
|
-
*/
|
|
17
|
-
export declare function isWasmReady(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Get all available Go WASM functions in Node.js
|
|
20
|
-
*/
|
|
21
|
-
export declare function getWasmFunctions(): string[];
|
|
22
|
-
declare global {
|
|
23
|
-
var Go: new () => {
|
|
24
|
-
importObject: any;
|
|
25
|
-
run: (instance: WebAssembly.Instance) => Promise<void>;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export type { GoWasmInstance, GoWasmOptions };
|
|
29
|
-
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/server/wasm.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnE;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAclD;AAuED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CA+GzB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAOtE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAK3C;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,EAAE,EAAE,UAAU;QAChB,YAAY,EAAE,GAAG,CAAC;QAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACxD,CAAC;CACH;AAED,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/server/wasm.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side Go WASM integration for Node.js
|
|
3
|
-
* Uses the standard Go WASM runtime (wasm_exec.js)
|
|
4
|
-
*/
|
|
5
|
-
import fs from 'fs/promises';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { pathToFileURL } from 'url';
|
|
8
|
-
// Global flag to ensure we only initialize WASM once
|
|
9
|
-
let initialized = false;
|
|
10
|
-
/**
|
|
11
|
-
* Initialize the Node.js environment for running Go WASM modules
|
|
12
|
-
*/
|
|
13
|
-
export async function initNodeWasm() {
|
|
14
|
-
if (initialized)
|
|
15
|
-
return;
|
|
16
|
-
try {
|
|
17
|
-
// Global WASM environment setup for Node.js
|
|
18
|
-
globalThis.TextEncoder = globalThis.TextEncoder || TextEncoder;
|
|
19
|
-
globalThis.TextDecoder = globalThis.TextDecoder || TextDecoder;
|
|
20
|
-
// Mark as initialized
|
|
21
|
-
initialized = true;
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error('[WASM] Failed to initialize Node.js WASM environment:', error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Load Go WASM runtime from wasm_exec.js file
|
|
30
|
-
*/
|
|
31
|
-
async function loadGoRuntime(goWasmPath) {
|
|
32
|
-
if (typeof global.Go === 'function') {
|
|
33
|
-
return global.Go;
|
|
34
|
-
}
|
|
35
|
-
// Try to find wasm_exec.js or wasm_exec.cjs
|
|
36
|
-
const possiblePaths = [
|
|
37
|
-
goWasmPath,
|
|
38
|
-
'./wasm_exec.cjs',
|
|
39
|
-
'./wasm_exec.js',
|
|
40
|
-
'./public/wasm_exec.cjs',
|
|
41
|
-
'./public/wasm_exec.js',
|
|
42
|
-
'./src/wasm_exec.cjs',
|
|
43
|
-
'./src/wasm_exec.js',
|
|
44
|
-
path.join(process.cwd(), 'wasm_exec.cjs'),
|
|
45
|
-
path.join(process.cwd(), 'wasm_exec.js'),
|
|
46
|
-
path.join(process.cwd(), 'public', 'wasm_exec.cjs'),
|
|
47
|
-
path.join(process.cwd(), 'public', 'wasm_exec.js'),
|
|
48
|
-
path.join(process.cwd(), 'src', 'wasm_exec.cjs'),
|
|
49
|
-
path.join(process.cwd(), 'src', 'wasm_exec.js')
|
|
50
|
-
].filter(Boolean);
|
|
51
|
-
for (const wasmExecPath of possiblePaths) {
|
|
52
|
-
try {
|
|
53
|
-
const resolvedPath = path.resolve(wasmExecPath);
|
|
54
|
-
// Check if file exists using fs.stat instead of fs.access
|
|
55
|
-
try {
|
|
56
|
-
const stats = await fs.stat(resolvedPath);
|
|
57
|
-
if (!stats.isFile()) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (statError) {
|
|
62
|
-
continue; // File doesn't exist, try next path
|
|
63
|
-
}
|
|
64
|
-
// Load the Go runtime using dynamic import with file:// URL
|
|
65
|
-
const wasmExecUrl = pathToFileURL(resolvedPath).href;
|
|
66
|
-
// Clear global.Go to ensure fresh import
|
|
67
|
-
if (global.Go) {
|
|
68
|
-
delete global.Go;
|
|
69
|
-
}
|
|
70
|
-
// Import the module
|
|
71
|
-
await import(wasmExecUrl);
|
|
72
|
-
if (typeof global.Go === 'function') {
|
|
73
|
-
console.log(`[WASM] Loaded Go runtime from: ${resolvedPath}`);
|
|
74
|
-
return global.Go;
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
console.warn(`[WASM] File found but Go class not exported: ${resolvedPath}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
console.warn(`[WASM] Error loading from ${wasmExecPath}:`, error.message);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
throw new Error('[WASM] Could not find wasm_exec.js. Please ensure you have the Go WASM runtime file available.\n' +
|
|
86
|
-
'You can get it from: https://github.com/golang/go/blob/master/misc/wasm/wasm_exec.js\n' +
|
|
87
|
-
`Searched paths: ${possiblePaths.join(', ')}`);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Load a Go WASM module from a file path for server-side usage
|
|
91
|
-
*/
|
|
92
|
-
export async function loadGoWasmFromFile(wasmFilePath, options = {}) {
|
|
93
|
-
try {
|
|
94
|
-
// Initialize Node.js WASM environment
|
|
95
|
-
await initNodeWasm();
|
|
96
|
-
if (options.debug) {
|
|
97
|
-
console.log('[WASM] Loading WASM from file:', wasmFilePath);
|
|
98
|
-
}
|
|
99
|
-
// Load the standard Go runtime
|
|
100
|
-
const GoRuntime = await loadGoRuntime(options.goWasmPath);
|
|
101
|
-
const go = new GoRuntime();
|
|
102
|
-
// Load WASM binary
|
|
103
|
-
const wasmBuffer = await fs.readFile(wasmFilePath);
|
|
104
|
-
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
105
|
-
// The updated wasm_exec.js provides imports under 'gojs' instead of 'go'
|
|
106
|
-
// Create imports object with the correct structure
|
|
107
|
-
const baseImports = go.importObject;
|
|
108
|
-
const finalImportObject = {
|
|
109
|
-
...baseImports,
|
|
110
|
-
...options.importObject
|
|
111
|
-
};
|
|
112
|
-
if (options.debug) {
|
|
113
|
-
console.log('[WASM] Available import modules:', Object.keys(finalImportObject));
|
|
114
|
-
// Debug each module's functions
|
|
115
|
-
for (const [moduleName, moduleExports] of Object.entries(finalImportObject)) {
|
|
116
|
-
if (typeof moduleExports === 'object' && moduleExports !== null) {
|
|
117
|
-
const exportNames = Object.keys(moduleExports);
|
|
118
|
-
console.log(`[WASM] ${moduleName} import functions:`, exportNames);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Instantiate the WASM module
|
|
123
|
-
const instance = await WebAssembly.instantiate(wasmModule, finalImportObject);
|
|
124
|
-
if (options.debug) {
|
|
125
|
-
console.log('[WASM] WASM instance created, starting Go runtime...');
|
|
126
|
-
}
|
|
127
|
-
// Initialize Go runtime - this will run the main function
|
|
128
|
-
// The go.run() method returns a promise that resolves when the program exits
|
|
129
|
-
const runPromise = go.run(instance);
|
|
130
|
-
if (options.debug) {
|
|
131
|
-
console.log('[WASM] Go runtime started, waiting for initialization...');
|
|
132
|
-
}
|
|
133
|
-
// Give Go runtime time to initialize and register functions
|
|
134
|
-
// Don't wait for the program to finish, just wait for functions to be registered
|
|
135
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
136
|
-
if (options.debug) {
|
|
137
|
-
console.log('[WASM] Scanning global object for Go functions...');
|
|
138
|
-
}
|
|
139
|
-
// Extract exported functions from global scope
|
|
140
|
-
const functions = {};
|
|
141
|
-
const globalObj = global;
|
|
142
|
-
// Scan for Go functions
|
|
143
|
-
const allKeys = Object.getOwnPropertyNames(globalObj);
|
|
144
|
-
const goKeys = allKeys.filter(key => key.startsWith('go'));
|
|
145
|
-
if (options.debug) {
|
|
146
|
-
console.log('[WASM] All keys starting with "go":', goKeys);
|
|
147
|
-
}
|
|
148
|
-
for (const key of goKeys) {
|
|
149
|
-
if (typeof globalObj[key] === 'function') {
|
|
150
|
-
functions[key] = globalObj[key];
|
|
151
|
-
if (options.debug) {
|
|
152
|
-
console.log(`[WASM] Found function: ${key}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const wasmInstance = {
|
|
157
|
-
instance,
|
|
158
|
-
module: wasmModule,
|
|
159
|
-
exports: instance.exports,
|
|
160
|
-
functions
|
|
161
|
-
};
|
|
162
|
-
// Run onLoad callback if provided
|
|
163
|
-
if (options.onLoad) {
|
|
164
|
-
options.onLoad(wasmInstance);
|
|
165
|
-
}
|
|
166
|
-
if (options.debug) {
|
|
167
|
-
console.log(`[WASM] Module loaded successfully with ${Object.keys(functions).length} functions`);
|
|
168
|
-
console.log('[WASM] Final function list:', Object.keys(functions));
|
|
169
|
-
}
|
|
170
|
-
// Don't await the runPromise - let the Go program finish in the background
|
|
171
|
-
// The functions are already registered and available
|
|
172
|
-
runPromise.catch((error) => {
|
|
173
|
-
if (options.debug) {
|
|
174
|
-
console.log('[WASM] Go program finished with error:', error);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
return wasmInstance;
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
console.error('[WASM] Failed to load Go WASM module:', error);
|
|
181
|
-
throw error;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Call a Go WASM function in Node.js environment
|
|
186
|
-
*/
|
|
187
|
-
export function callWasmFunction(funcName, ...args) {
|
|
188
|
-
const func = global[funcName];
|
|
189
|
-
if (typeof func !== 'function') {
|
|
190
|
-
throw new Error(`Function ${funcName} not found. Make sure the WASM module is loaded.`);
|
|
191
|
-
}
|
|
192
|
-
return func(...args);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Check if Go WASM is ready in Node.js
|
|
196
|
-
*/
|
|
197
|
-
export function isWasmReady() {
|
|
198
|
-
const globalObj = global;
|
|
199
|
-
return Object.keys(globalObj).some(key => key.startsWith('go') && typeof globalObj[key] === 'function');
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Get all available Go WASM functions in Node.js
|
|
203
|
-
*/
|
|
204
|
-
export function getWasmFunctions() {
|
|
205
|
-
const globalObj = global;
|
|
206
|
-
return Object.keys(globalObj).filter(key => key.startsWith('go') && typeof globalObj[key] === 'function');
|
|
207
|
-
}
|
|
208
|
-
//# sourceMappingURL=wasm.js.map
|
package/dist/server/wasm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../src/server/wasm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,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MAAM,IAAI,GAAI,MAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,kDAAkD,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,SAAS,GAAG,MAAa,CAAC;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACvC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,UAAU,CAC7D,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,MAAa,CAAC;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACzC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,UAAU,CAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-renderer.d.ts","sourceRoot":"","sources":["../src/server-renderer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM,CAuBrD"}
|
package/dist/server-renderer.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side rendering utilities
|
|
3
|
-
*/
|
|
4
|
-
export function renderToString(component) {
|
|
5
|
-
try {
|
|
6
|
-
// Basic server-side rendering - this is a simplified implementation
|
|
7
|
-
if (typeof component === 'function') {
|
|
8
|
-
const result = component();
|
|
9
|
-
if (typeof result === 'string') {
|
|
10
|
-
return result;
|
|
11
|
-
}
|
|
12
|
-
if (result && typeof result === 'object') {
|
|
13
|
-
return JSON.stringify(result);
|
|
14
|
-
}
|
|
15
|
-
return String(result || '');
|
|
16
|
-
}
|
|
17
|
-
if (typeof component === 'string') {
|
|
18
|
-
return component;
|
|
19
|
-
}
|
|
20
|
-
return String(component || '');
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
console.error('Error in renderToString:', error);
|
|
24
|
-
return '<div>Error rendering component</div>';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=server-renderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-renderer.js","sourceRoot":"","sources":["../src/server-renderer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,cAAc,CAAC,SAAc;IAC3C,IAAI,CAAC;QACH,oEAAoE;QACpE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAC3B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACzC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,sCAAsC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
package/dist/wasm.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebAssembly integration for Frontend Hamroun
|
|
3
|
-
* Works in both browser and Node.js environments
|
|
4
|
-
*/
|
|
5
|
-
export interface GoWasmOptions {
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
goWasmPath?: string;
|
|
8
|
-
importObject?: any;
|
|
9
|
-
onLoad?: (instance: GoWasmInstance) => void;
|
|
10
|
-
}
|
|
11
|
-
export interface GoWasmInstance {
|
|
12
|
-
instance: WebAssembly.Instance;
|
|
13
|
-
module: WebAssembly.Module;
|
|
14
|
-
exports: WebAssembly.Exports;
|
|
15
|
-
functions: Record<string, Function>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Load Go WASM module in the browser (like your working frontend code)
|
|
19
|
-
*/
|
|
20
|
-
export declare function loadGoWasm(wasmUrl: string, options?: GoWasmOptions): Promise<GoWasmInstance>;
|
|
21
|
-
/**
|
|
22
|
-
* Call a Go WASM function (like your frontend code's callWasmFunction)
|
|
23
|
-
*/
|
|
24
|
-
export declare function callWasmFunction(funcName: string, ...args: any[]): any;
|
|
25
|
-
/**
|
|
26
|
-
* Check if Go WASM is ready (like your frontend code's wasmReady state)
|
|
27
|
-
*/
|
|
28
|
-
export declare function isWasmReady(): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Get all available Go WASM functions
|
|
31
|
-
*/
|
|
32
|
-
export declare function getWasmFunctions(): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Hook for React components (like your frontend code's useEffect pattern)
|
|
35
|
-
*/
|
|
36
|
-
export declare function useGoWasm(wasmUrl: string, options?: GoWasmOptions): {
|
|
37
|
-
loadWasm: () => Promise<GoWasmInstance>;
|
|
38
|
-
callFunction: typeof callWasmFunction;
|
|
39
|
-
isReady: typeof isWasmReady;
|
|
40
|
-
getFunctions: typeof getWasmFunctions;
|
|
41
|
-
};
|
|
42
|
-
declare global {
|
|
43
|
-
interface Window {
|
|
44
|
-
Go: new () => {
|
|
45
|
-
importObject: any;
|
|
46
|
-
run: (instance: WebAssembly.Instance) => void;
|
|
47
|
-
};
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=wasm.d.ts.map
|
package/dist/wasm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC;IAC/B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAwEzB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAWtE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CASrC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAQ3C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;;;;;EAarE;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,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