baraqex 1.0.44 → 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.
Files changed (60) hide show
  1. package/README_WASM.md +472 -0
  2. package/dist/browser.js +1 -422
  3. package/dist/browser.js.map +4 -4
  4. package/dist/index.js +31 -421
  5. package/dist/index.js.map +4 -4
  6. package/dist/{server/index.js → server.js} +21 -114
  7. package/dist/server.js.map +7 -0
  8. package/package.json +48 -57
  9. package/templates/ssr-template/package-lock.json +2 -2
  10. package/templates/ssr-template/src/App.tsx +1 -1
  11. package/templates/ssr-template/src/client.tsx +1 -1
  12. package/templates/ssr-template/src/server.ts +1 -1
  13. package/templates/wasm/package-lock.json +3169 -2710
  14. package/templates/wasm/package.json +9 -12
  15. package/templates/wasm/src/App.tsx +50 -19
  16. package/templates/wasm/vite.config.ts +24 -59
  17. package/dist/api/hello.d.ts +0 -3
  18. package/dist/api/hello.d.ts.map +0 -1
  19. package/dist/api/users/[id].d.ts +0 -5
  20. package/dist/api/users/[id].d.ts.map +0 -1
  21. package/dist/browser.d.ts +0 -29
  22. package/dist/browser.d.ts.map +0 -1
  23. package/dist/browser.package.json +0 -4
  24. package/dist/frontend/components/WasmLoader.d.ts +0 -2
  25. package/dist/frontend/components/WasmLoader.d.ts.map +0 -1
  26. package/dist/frontend/hooks/useWasm.d.ts +0 -2
  27. package/dist/frontend/hooks/useWasm.d.ts.map +0 -1
  28. package/dist/frontend/index.d.ts +0 -2
  29. package/dist/frontend/index.d.ts.map +0 -1
  30. package/dist/index.d.ts +0 -34
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/renderComponent.d.ts +0 -9
  33. package/dist/renderComponent.d.ts.map +0 -1
  34. package/dist/server/api-router.d.ts +0 -16
  35. package/dist/server/api-router.d.ts.map +0 -1
  36. package/dist/server/auth.d.ts +0 -25
  37. package/dist/server/auth.d.ts.map +0 -1
  38. package/dist/server/database.d.ts +0 -22
  39. package/dist/server/database.d.ts.map +0 -1
  40. package/dist/server/index.d.ts +0 -115
  41. package/dist/server/index.d.ts.map +0 -1
  42. package/dist/server/index.js.map +0 -7
  43. package/dist/server/middleware.d.ts +0 -11
  44. package/dist/server/middleware.d.ts.map +0 -1
  45. package/dist/server/package.json +0 -4
  46. package/dist/server/templates.d.ts +0 -31
  47. package/dist/server/templates.d.ts.map +0 -1
  48. package/dist/server/types.d.ts +0 -69
  49. package/dist/server/types.d.ts.map +0 -1
  50. package/dist/server/utils.d.ts +0 -70
  51. package/dist/server/utils.d.ts.map +0 -1
  52. package/dist/server/wasm.d.ts +0 -29
  53. package/dist/server/wasm.d.ts.map +0 -1
  54. package/dist/server-renderer.d.ts +0 -5
  55. package/dist/server-renderer.d.ts.map +0 -1
  56. package/dist/wasm.d.ts +0 -51
  57. package/dist/wasm.d.ts.map +0 -1
  58. package/templates/wasm/src/index.html +0 -14
  59. package/templates/wasm/src/main.tsx +0 -5
  60. package/templates/wasm/src/wasm-loader.ts +0 -119
@@ -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
- }