baraqex 1.0.43 → 1.0.45
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/README_WASM.md +472 -0
- package/bin/baraqex.js +1 -1
- package/dist/browser.js +1 -1067
- package/dist/browser.js.map +4 -4
- package/dist/index.js +28 -1087
- package/dist/index.js.map +4 -4
- package/dist/{server/index.js → server.js} +21 -249
- package/dist/server.js.map +7 -0
- package/package.json +49 -58
- package/templates/ssr-template/index.html +35 -0
- package/templates/ssr-template/package-lock.json +2665 -446
- package/templates/ssr-template/package.json +20 -14
- package/templates/ssr-template/src/App.tsx +65 -42
- package/templates/ssr-template/src/client.tsx +2 -10
- package/templates/wasm/package-lock.json +3169 -2710
- package/templates/wasm/package.json +9 -12
- package/templates/wasm/src/App.tsx +50 -19
- package/templates/wasm/vite.config.ts +24 -59
- package/dist/api/hello.d.ts +0 -3
- package/dist/api/hello.d.ts.map +0 -1
- package/dist/api/users/[id].d.ts +0 -5
- package/dist/api/users/[id].d.ts.map +0 -1
- package/dist/browser.d.ts +0 -29
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.package.json +0 -4
- package/dist/frontend/components/WasmLoader.d.ts +0 -2
- package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
- package/dist/frontend/hooks/useWasm.d.ts +0 -2
- package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
- package/dist/frontend/index.d.ts +0 -2
- package/dist/frontend/index.d.ts.map +0 -1
- package/dist/index.d.ts +0 -34
- 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/server/api-router.d.ts +0 -16
- package/dist/server/api-router.d.ts.map +0 -1
- package/dist/server/auth.d.ts +0 -25
- package/dist/server/auth.d.ts.map +0 -1
- package/dist/server/database.d.ts +0 -22
- package/dist/server/database.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -115
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js.map +0 -7
- package/dist/server/middleware.d.ts +0 -11
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/package.json +0 -4
- package/dist/server/templates.d.ts +0 -31
- package/dist/server/templates.d.ts.map +0 -1
- package/dist/server/types.d.ts +0 -69
- package/dist/server/types.d.ts.map +0 -1
- package/dist/server/utils.d.ts +0 -70
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/wasm.d.ts +0 -29
- package/dist/server/wasm.d.ts.map +0 -1
- package/dist/server-renderer.d.ts +0 -5
- package/dist/server-renderer.d.ts.map +0 -1
- package/dist/wasm.d.ts +0 -51
- package/dist/wasm.d.ts.map +0 -1
- package/templates/wasm/src/index.html +0 -14
- package/templates/wasm/src/main.tsx +0 -5
- package/templates/wasm/src/wasm-loader.ts +0 -119
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,MAAM;QACd,EAAE,EAAE,UAAU;YACZ,YAAY,EAAE,GAAG,CAAC;YAClB,GAAG,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,QAAQ,KAAK,IAAI,CAAC;SAC/C,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB;CACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Baraqex WASM Template</title>
|
|
8
|
-
<script src="/wasm_exec.js"></script>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id="root"></div>
|
|
12
|
-
<script type="module" src="/main.tsx"></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-only WASM loader for the WASM template
|
|
3
|
-
* This is a simplified version that works in the browser without server dependencies
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export interface WasmOptions {
|
|
7
|
-
debug?: boolean;
|
|
8
|
-
onLoad?: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let wasmReady = false;
|
|
12
|
-
let wasmError: string | null = null;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Load Go WASM module in the browser
|
|
16
|
-
*/
|
|
17
|
-
export async function loadGoWasm(wasmPath: string, options: WasmOptions = {}): Promise<void> {
|
|
18
|
-
if (wasmReady) return;
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
if (options.debug) {
|
|
22
|
-
console.log('[WASM] Loading WASM from:', wasmPath);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Check if Go runtime is available
|
|
26
|
-
if (typeof (window as any).Go !== 'function') {
|
|
27
|
-
throw new Error('Go WASM runtime not found. Make sure wasm_exec.js is loaded.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Create Go instance
|
|
31
|
-
const go = new (window as any).Go();
|
|
32
|
-
|
|
33
|
-
if (options.debug) {
|
|
34
|
-
console.log('[WASM] Go runtime created, loading WASM binary...');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Load WASM binary
|
|
38
|
-
const response = await fetch(wasmPath);
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
throw new Error(`Failed to fetch WASM file: ${response.status} ${response.statusText}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const wasmBytes = await response.arrayBuffer();
|
|
44
|
-
const wasmModule = await WebAssembly.instantiate(wasmBytes, go.importObject);
|
|
45
|
-
|
|
46
|
-
if (options.debug) {
|
|
47
|
-
console.log('[WASM] WASM module instantiated, starting Go runtime...');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Start Go runtime (this runs main() function)
|
|
51
|
-
go.run(wasmModule.instance);
|
|
52
|
-
|
|
53
|
-
// Give Go time to initialize and register functions
|
|
54
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
55
|
-
|
|
56
|
-
if (options.debug) {
|
|
57
|
-
console.log('[WASM] Scanning for Go functions...');
|
|
58
|
-
const goFunctions = Object.keys(window as any).filter(key =>
|
|
59
|
-
key.startsWith('go') && typeof (window as any)[key] === 'function'
|
|
60
|
-
);
|
|
61
|
-
console.log('[WASM] Available functions:', goFunctions);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
wasmReady = true;
|
|
65
|
-
wasmError = null;
|
|
66
|
-
|
|
67
|
-
if (options.onLoad) {
|
|
68
|
-
options.onLoad();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (options.debug) {
|
|
72
|
-
console.log('[WASM] Go WASM loaded successfully!');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
} catch (error) {
|
|
76
|
-
wasmError = error instanceof Error ? error.message : 'Unknown WASM loading error';
|
|
77
|
-
console.error('[WASM] Failed to load:', error);
|
|
78
|
-
throw error;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Call a Go WASM function in the browser
|
|
84
|
-
*/
|
|
85
|
-
export function callWasmFunction(funcName: string, ...args: any[]): any {
|
|
86
|
-
if (!wasmReady) {
|
|
87
|
-
throw new Error('WASM not ready. Call loadGoWasm() first.');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const func = (window as any)[funcName];
|
|
91
|
-
if (typeof func !== 'function') {
|
|
92
|
-
throw new Error(`Function ${funcName} not found. Available functions: ${getWasmFunctions().join(', ')}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return func(...args);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Check if WASM is ready
|
|
100
|
-
*/
|
|
101
|
-
export function isWasmReady(): boolean {
|
|
102
|
-
return wasmReady;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get all available Go WASM functions
|
|
107
|
-
*/
|
|
108
|
-
export function getWasmFunctions(): string[] {
|
|
109
|
-
return Object.keys(window as any).filter(key =>
|
|
110
|
-
key.startsWith('go') && typeof (window as any)[key] === 'function'
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get WASM loading error if any
|
|
116
|
-
*/
|
|
117
|
-
export function getWasmError(): string | null {
|
|
118
|
-
return wasmError;
|
|
119
|
-
}
|