gowm 1.0.6 โ†’ 1.0.7

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.md CHANGED
@@ -1,24 +1,30 @@
1
- # GoWM - Go Wasm Manager
1
+ # GoWM - Go WebAssembly Manager
2
2
 
3
3
  <div align="center">
4
4
  <img src="./logo.png" alt="GoWM Logo" width="200" />
5
5
 
6
- <p><strong>GoWM</strong> simplifies the integration of Go WebAssembly modules into your JavaScript projects.</p>
6
+ <p><strong>GoWM</strong> simplifies the integration of Go WebAssembly modules into your JavaScript projects with support for GitHub repositories, React hooks, and Vue composables.</p>
7
+
8
+ <p>
9
+ <a href="https://www.npmjs.com/package/gowm"><img src="https://img.shields.io/npm/v/gowm.svg" alt="npm version"></a>
10
+ <a href="https://github.com/benoitpetit/gowm/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/gowm.svg" alt="license"></a>
11
+ <a href="https://www.npmjs.com/package/gowm"><img src="https://img.shields.io/npm/dm/gowm.svg" alt="downloads"></a>
12
+ </p>
7
13
  </div>
8
14
 
9
15
  ## โœจ Features
10
16
 
11
- - ๐Ÿš€ **Unified interface** for loading Go WASM modules
12
- - ๐Ÿ”ง **Node.js and browser support** with automatic detection
13
- - โš›๏ธ **Built-in React hooks** (`useWasm`, `useWasmFromGitHub`)
14
- - ๐Ÿ–– **Vue.js composables** for Vue 3 (`useWasm`, `useWasmFromGitHub`, `useMultipleWasm`)
15
- - ๐Ÿ“ฆ **GitHub repository loading** with automatic WASM file resolution
16
- - ๐Ÿท๏ธ **Branch and tag support** for precise version control
17
- - ๐Ÿ›ก๏ธ **Robust error handling** and function detection
18
- - ๐Ÿงน **Automatic memory management** and resource cleanup
19
- - ๐Ÿ“Š **Statistics and monitoring** for loaded modules
20
- - ๐Ÿ”„ **Synchronous and asynchronous calls** with `call()` and `callAsync()`
21
- - ๐ŸŽฏ **Singleton API** and GoWM class for different use cases
17
+ - ๐Ÿš€ **Unified Interface** - Load Go WASM modules from local files or GitHub repositories
18
+ - ๐Ÿ”ง **Cross-Platform** - Full support for Node.js and browser environments
19
+ - โš›๏ธ **React Integration** - Built-in hooks (`useWasm`, `useWasmFromGitHub`)
20
+ - ๐Ÿ–– **Vue 3 Support** - Reactive composables with automatic cleanup
21
+ - ๐Ÿ“ฆ **GitHub Direct Loading** - Load WASM modules directly from GitHub repositories
22
+ - ๐Ÿท๏ธ **Version Control** - Support for branches, tags, and specific commits
23
+ - ๐Ÿ›ก๏ธ **Error Handling** - Robust error handling and automatic retries
24
+ - ๐Ÿงน **Memory Management** - Automatic resource cleanup and memory management
25
+ - ๐Ÿ“Š **Module Statistics** - Built-in monitoring and performance metrics
26
+ - ๐Ÿ”„ **Flexible Calls** - Both synchronous and asynchronous function calls
27
+ - ๐ŸŽฏ **Multiple APIs** - Singleton API and class-based approach
22
28
 
23
29
  ## ๐Ÿ“ฅ Installation
24
30
 
@@ -26,42 +32,44 @@
26
32
  npm install gowm
27
33
  # or
28
34
  yarn add gowm
35
+ # or
36
+ pnpm add gowm
29
37
  ```
30
38
 
31
39
  ## ๐Ÿš€ Quick Start
32
40
 
33
- ### Node.js
41
+ ### Basic Usage (Node.js)
34
42
 
35
43
  ```javascript
36
44
  const { load, loadFromGitHub } = require('gowm');
37
45
 
38
46
  async function example() {
39
47
  try {
40
- // Load a WASM module from local file
41
- const math = await load('./math.wasm', { name: 'math' });
48
+ // Load from local file
49
+ const localWasm = await load('./math.wasm', { name: 'math' });
42
50
 
43
- // Or load directly from GitHub repository
44
- const githubMath = await loadFromGitHub('awesome-org/wasm-math', {
51
+ // Load directly from GitHub repository
52
+ const githubWasm = await loadFromGitHub('awesome-org/wasm-math', {
45
53
  name: 'github-math',
46
54
  branch: 'main'
47
55
  });
48
56
 
49
57
  // Call functions
50
- const result = math.call('add', 5, 3);
51
- console.log('5 + 3 =', result);
58
+ const result = localWasm.call('add', 5, 3);
59
+ console.log('5 + 3 =', result); // 8
52
60
 
53
- // Async call
54
- const asyncResult = await githubMath.callAsync('multiply', 4, 7);
55
- console.log('4 * 7 =', asyncResult);
61
+ // Async calls
62
+ const asyncResult = await githubWasm.callAsync('multiply', 4, 7);
63
+ console.log('4 * 7 =', asyncResult); // 28
56
64
 
57
- // Check if a function exists
58
- if (math.hasFunction('subtract')) {
59
- console.log('Function subtract is available');
65
+ // Check available functions
66
+ if (localWasm.hasFunction('subtract')) {
67
+ console.log('subtract function is available');
60
68
  }
61
69
 
62
- // Get statistics
63
- const stats = math.getStats();
64
- console.log('Functions:', stats.functions);
70
+ // Get module statistics
71
+ const stats = localWasm.getStats();
72
+ console.log('Available functions:', stats.functions);
65
73
 
66
74
  } catch (error) {
67
75
  console.error('Error:', error);
@@ -71,7 +79,7 @@ async function example() {
71
79
  example();
72
80
  ```
73
81
 
74
- ### React
82
+ ### React Integration
75
83
 
76
84
  ```jsx
77
85
  import React, { useState } from 'react';
@@ -90,7 +98,7 @@ function CalculatorComponent() {
90
98
  const sum = await wasm.callAsync('add', 10, 20);
91
99
  setResult(sum);
92
100
  } catch (err) {
93
- console.error('Calculation error:', err);
101
+ console.error('Calculation failed:', err);
94
102
  }
95
103
  }
96
104
  };
@@ -107,18 +115,18 @@ function CalculatorComponent() {
107
115
  }
108
116
  ```
109
117
 
110
- ### Vue.js
118
+ ### Vue 3 Integration
111
119
 
112
120
  ```vue
113
121
  <template>
114
122
  <div class="calculator">
115
123
  <div v-if="loading">Loading WASM module from GitHub...</div>
116
- <div v-else-if="error">Error: {{ error.message }}</div>
124
+ <div v-else-if="error" class="error">Error: {{ error.message }}</div>
117
125
  <div v-else>
118
126
  <input v-model.number="num1" type="number" placeholder="First number" />
119
127
  <input v-model.number="num2" type="number" placeholder="Second number" />
120
128
  <button @click="calculate">Calculate {{ num1 }} + {{ num2 }}</button>
121
- <div v-if="result !== null">Result: {{ result }}</div>
129
+ <div v-if="result !== null" class="result">Result: {{ result }}</div>
122
130
  </div>
123
131
  </div>
124
132
  </template>
@@ -156,17 +164,18 @@ export default {
156
164
  </script>
157
165
  ```
158
166
 
159
- ### Loading from GitHub
167
+ ## ๐Ÿ™ GitHub Repository Loading
168
+
169
+ GoWM excels at loading WASM modules directly from GitHub repositories with intelligent file discovery:
160
170
 
161
171
  ```javascript
162
172
  const { loadFromGitHub } = require('gowm');
163
173
 
164
- async function useGitHubLibrary() {
165
- try {
166
- // Basic loading - tries common filenames automatically
174
+ async function examples() {
175
+ // Basic loading - automatic file discovery
167
176
  const math = await loadFromGitHub('awesome-org/wasm-math');
168
177
 
169
- // Advanced loading with options
178
+ // Advanced loading with specific options
170
179
  const imageProcessor = await loadFromGitHub('image-corp/wasm-image', {
171
180
  branch: 'develop', // Use develop branch
172
181
  path: 'dist', // Look in dist folder
@@ -185,31 +194,36 @@ async function useGitHubLibrary() {
185
194
  'https://github.com/org/repo',
186
195
  { filename: 'module.wasm' }
187
196
  );
188
-
189
- const result = math.call('add', 10, 20);
190
- console.log('Result:', result);
191
- } catch (error) {
192
- console.error('GitHub loading error:', error);
193
- }
194
197
  }
195
198
  ```
196
199
 
200
+ ### Automatic File Discovery
201
+
202
+ GoWM automatically searches for WASM files in common locations:
203
+
204
+ - **Root directory**: `main.wasm`, `index.wasm`, `{repo-name}.wasm`
205
+ - **Common folders**: `wasm/`, `dist/`, `build/`
206
+ - **GitHub releases**: Searches release assets for WASM files
207
+ - **Custom paths**: Respects your specified path and filename
208
+
197
209
  ## ๐Ÿ“š API Reference
198
210
 
199
- ### load(wasmPath, options)
211
+ ### Core Functions
200
212
 
201
- Loads a WASM module from a local file.
213
+ #### `load(wasmPath, options)`
214
+
215
+ Loads a WASM module from a local file or URL.
202
216
 
203
217
  **Parameters:**
204
- - `wasmPath` (string): Path to the .wasm file
218
+ - `wasmPath` (string): Path to the .wasm file or URL
205
219
  - `options` (object, optional):
206
- - `name` (string): Module name (default: 'default')
220
+ - `name` (string): Module identifier (default: 'default')
207
221
  - `goRuntimePath` (string): Custom path to wasm_exec.js
208
222
  - `preInit` (boolean): Pre-initialize the module (default: true)
209
223
 
210
224
  **Returns:** Promise<WasmBridge>
211
225
 
212
- ### loadFromGitHub(githubRepo, options)
226
+ #### `loadFromGitHub(githubRepo, options)`
213
227
 
214
228
  Loads a WASM module from a GitHub repository with automatic file resolution.
215
229
 
@@ -224,14 +238,9 @@ Loads a WASM module from a GitHub repository with automatic file resolution.
224
238
  - `goRuntimePath` (string): Custom path to wasm_exec.js
225
239
  - `preInit` (boolean): Pre-initialize the module (default: true)
226
240
 
227
- **Automatic resolution:** Tries multiple common locations:
228
- - `main.wasm`, `index.wasm`, `{repo-name}.wasm`
229
- - `wasm/`, `dist/`, `build/` directories
230
- - GitHub releases (if available)
231
-
232
241
  **Returns:** Promise<WasmBridge>
233
242
 
234
- ### get(name)
243
+ #### `get(name)`
235
244
 
236
245
  Retrieves an already loaded module by name.
237
246
 
@@ -240,338 +249,259 @@ Retrieves an already loaded module by name.
240
249
 
241
250
  **Returns:** WasmBridge | null
242
251
 
243
- ### Utility Functions
244
-
245
- - `listModules()`: List all loaded modules
246
- - `getStats()`: Get statistics for all modules
247
- - `unload(name)`: Unload a specific module
248
- - `unloadAll()`: Unload all modules
249
- - `isLoaded(name)`: Check if a module is loaded
250
- - `getTotalMemoryUsage()`: Get total memory usage across all modules
251
-
252
- ### WasmBridge
252
+ ### WasmBridge Methods
253
253
 
254
- Main interface for interacting with a loaded WASM module.
254
+ #### `call(funcName, ...args)`
255
255
 
256
- #### Methods
256
+ Calls a WASM function synchronously.
257
257
 
258
- - `call(funcName, ...args)`: Synchronous call to a Go WASM function
259
- - `callAsync(funcName, ...args)`: Asynchronous call (returns a Promise)
260
- - `hasFunction(funcName)`: Check if a function exists in the module
261
- - `getAvailableFunctions()`: Get list of available functions
262
- - `registerCallback(name, callback)`: Register a JavaScript callback accessible from Go
263
- - `unregisterCallback(name)`: Remove a JavaScript callback
264
- - `createBuffer(data)`: Create a buffer for data transfer (Float64Array, Uint8Array, string)
265
- - `getStats()`: Get module statistics (functions, callbacks, memory)
258
+ **Parameters:**
259
+ - `funcName` (string): Name of the function to call
260
+ - `...args`: Function arguments
266
261
 
267
- ### Vue.js Composables
262
+ **Returns:** Function result
268
263
 
269
- #### useWasm(wasmPath, options)
264
+ #### `callAsync(funcName, ...args)`
270
265
 
271
- Vue 3 composable for loading and using a WASM module with reactivity.
266
+ Calls a WASM function asynchronously.
272
267
 
273
268
  **Parameters:**
274
- - `wasmPath` (string|Ref<string>): Path to the .wasm file
275
- - `options` (object|Ref<object>, optional): Loading options
269
+ - `funcName` (string): Name of the function to call
270
+ - `...args`: Function arguments
276
271
 
277
- **Returns:**
278
- ```javascript
279
- {
280
- wasm: Ref<WasmBridge | null>,
281
- loading: Ref<boolean>,
282
- error: Ref<Error | null>,
283
- reload: () => void
284
- }
285
- ```
272
+ **Returns:** Promise<Function result>
286
273
 
287
- #### useWasmFromGitHub(githubRepo, options)
274
+ #### `hasFunction(funcName)`
288
275
 
289
- Vue 3 composable for loading a WASM module from GitHub.
276
+ Checks if a function exists in the WASM module.
290
277
 
291
278
  **Parameters:**
292
- - `githubRepo` (string|Ref<string>): GitHub repository
293
- - `options` (object|Ref<object>, optional): GitHub loading options
279
+ - `funcName` (string): Function name to check
294
280
 
295
- **Returns:** Same interface as `useWasm`
281
+ **Returns:** boolean
296
282
 
297
- #### useMultipleWasm(modules)
283
+ #### `getAvailableFunctions()`
298
284
 
299
- Vue 3 composable for loading multiple WASM modules.
285
+ Gets a list of all available functions in the module.
300
286
 
301
- **Parameters:**
302
- - `modules` (Array|Ref<Array>): Array of module configurations
287
+ **Returns:** string[]
303
288
 
304
- **Configuration object:**
305
- ```javascript
306
- {
307
- name: string, // Required: Module name
308
- path?: string, // Optional: Local file path
309
- github?: string, // Optional: GitHub repository
310
- options?: LoadOptions // Optional: Loading options
311
- }
312
- ```
289
+ #### `getStats()`
313
290
 
314
- #### useMultipleWasmFromGitHub(githubRepos)
291
+ Gets module statistics and information.
315
292
 
316
- Vue 3 composable for loading multiple WASM modules from GitHub repositories.
293
+ **Returns:** Object with statistics
317
294
 
318
- **Parameters:**
319
- - `githubRepos` (Array|Ref<Array>): Array of GitHub repository configurations
295
+ #### `cleanup()`
320
296
 
321
- **Configuration object:**
322
- ```javascript
323
- {
324
- name: string, // Required: Module name
325
- repo: string, // Required: GitHub repository
326
- branch?: string, // Optional: Git branch
327
- tag?: string, // Optional: Git tag
328
- path?: string, // Optional: Path in repository
329
- filename?: string, // Optional: Specific filename
330
- options?: GitHubLoadOptions // Optional: Additional options
331
- }
332
- ```
297
+ Manually clean up module resources.
333
298
 
334
- **Returns:**
335
- ```javascript
336
- {
337
- modules: Ref<Record<string, WasmBridge>>,
338
- loading: Ref<boolean>, // Global loading state
339
- errors: Ref<Record<string, Error>>, // Errors by module
340
- reload: () => void
341
- }
342
- ```
299
+ **Returns:** void
343
300
 
344
- ### React Hooks
301
+ ### Utility Functions
345
302
 
346
- #### useWasm(wasmPath, options)
303
+ - `listModules()`: List all loaded modules
304
+ - `getStats()`: Get statistics for all modules
305
+ - `unload(name)`: Unload a specific module
306
+ - `unloadAll()`: Unload all modules
307
+ - `isLoaded(name)`: Check if a module is loaded
308
+ - `getTotalMemoryUsage()`: Get total memory usage
347
309
 
348
- React hook for loading and using a WASM module.
310
+ ## โš›๏ธ React Hooks
349
311
 
350
- **Parameters:**
351
- - `wasmPath` (string): Path to the .wasm file
352
- - `options` (object, optional): Loading options
312
+ ### `useWasm(wasmPath, options)`
353
313
 
354
- **Returns:**
355
- ```javascript
356
- {
357
- wasm: WasmBridge | null,
358
- loading: boolean,
359
- error: Error | null
314
+ Hook for loading local WASM modules.
315
+
316
+ ```jsx
317
+ import { useWasm } from 'gowm/hooks/useWasm';
318
+
319
+ function MyComponent() {
320
+ const { wasm, loading, error } = useWasm('./my-module.wasm', {
321
+ name: 'myModule'
322
+ });
323
+
324
+ // Use wasm when loaded
360
325
  }
361
326
  ```
362
327
 
363
- #### useWasmFromGitHub(githubRepo, options)
328
+ ### `useWasmFromGitHub(githubRepo, options)`
364
329
 
365
- React hook for loading a WASM module from GitHub.
330
+ Hook for loading WASM modules from GitHub.
366
331
 
367
- **Parameters:**
368
- - `githubRepo` (string): GitHub repository
369
- - `options` (object, optional): GitHub loading options
332
+ ```jsx
333
+ import { useWasmFromGitHub } from 'gowm/hooks/useWasm';
370
334
 
371
- **Returns:** Same interface as `useWasm`
335
+ function MyComponent() {
336
+ const { wasm, loading, error } = useWasmFromGitHub('org/repo', {
337
+ branch: 'main',
338
+ name: 'myModule'
339
+ });
340
+ }
341
+ ```
372
342
 
373
- #### useMultipleWasmFromGitHub(githubRepos, options)
343
+ ### `useMultipleWasmFromGitHub(githubRepos, options)`
374
344
 
375
- React hook for loading multiple WASM modules from GitHub repositories.
345
+ Hook for loading multiple WASM modules from GitHub.
376
346
 
377
- **Parameters:**
378
- - `githubRepos` (Array): Array of GitHub repository configurations
379
- - `options` (object, optional): Global loading options
347
+ ```jsx
348
+ import { useMultipleWasmFromGitHub } from 'gowm/hooks/useWasm';
380
349
 
381
- **Returns:**
382
- ```javascript
383
- {
384
- modules: Record<string, WasmBridge>,
385
- loading: boolean,
386
- errors: Record<string, Error>,
387
- reload: () => void
350
+ function MyComponent() {
351
+ const { modules, loading, errors, reload } = useMultipleWasmFromGitHub([
352
+ { name: 'math', repo: 'org/math-wasm' },
353
+ { name: 'image', repo: 'org/image-wasm', branch: 'dev' }
354
+ ]);
388
355
  }
389
356
  ```
390
357
 
391
- ## ๐Ÿ”ง Go Integration
358
+ ## ๐Ÿ–– Vue 3 Composables
392
359
 
393
- ### Basic Go Function Export
360
+ ### `useWasm(wasmPath, options)`
394
361
 
395
- ```go
396
- package main
362
+ Composable for loading local WASM modules.
397
363
 
398
- import (
399
- "syscall/js"
400
- )
401
-
402
- func add(this js.Value, p []js.Value) interface{} {
403
- if len(p) != 2 {
404
- return js.ValueOf("Error: two arguments required")
405
- }
406
-
407
- a := p[0].Float()
408
- b := p[1].Float()
409
- return js.ValueOf(a + b)
410
- }
411
-
412
- func multiply(this js.Value, p []js.Value) interface{} {
413
- if len(p) != 2 {
414
- return js.ValueOf("Error: two arguments required")
415
- }
416
-
417
- a := p[0].Float()
418
- b := p[1].Float()
419
- return js.ValueOf(a * b)
420
- }
364
+ ```vue
365
+ <script>
366
+ import { useWasm } from 'gowm/composables/useWasm';
421
367
 
422
- func main() {
423
- c := make(chan struct{}, 0)
424
-
425
- // Export functions to JavaScript
426
- js.Global().Set("add", js.FuncOf(add))
427
- js.Global().Set("multiply", js.FuncOf(multiply))
428
-
429
- // Signal readiness
430
- js.Global().Set("__gowm_ready", js.ValueOf(true))
431
-
432
- <-c
368
+ export default {
369
+ setup() {
370
+ const { wasm, loading, error, reload } = useWasm('./my-module.wasm');
371
+ return { wasm, loading, error, reload };
372
+ }
433
373
  }
374
+ </script>
434
375
  ```
435
376
 
436
- ### Building and Publishing WASM
377
+ ### `useWasmFromGitHub(githubRepo, options)`
437
378
 
438
- ```bash
439
- # Build WASM
440
- GOOS=js GOARCH=wasm go build -o main.wasm main.go
441
-
442
- # Create GitHub repository structure
443
- mkdir my-wasm-lib
444
- cd my-wasm-lib
445
- cp main.wasm .
446
- cp $(go env GOROOT)/misc/wasm/wasm_exec.js .
447
-
448
- # Push to GitHub
449
- git init
450
- git add .
451
- git commit -m "Initial WASM module"
452
- git remote add origin https://github.com/username/my-wasm-lib.git
453
- git push -u origin main
454
-
455
- # Create a release (optional)
456
- git tag v1.0.0
457
- git push --tags
458
- ```
379
+ Composable for loading WASM modules from GitHub.
459
380
 
460
- ## ๐Ÿ“ Project Structure
381
+ ```vue
382
+ <script>
383
+ import { useWasmFromGitHub } from 'gowm/composables/useWasm';
461
384
 
385
+ export default {
386
+ setup() {
387
+ const { wasm, loading, error } = useWasmFromGitHub('org/repo', {
388
+ tag: 'v1.0.0'
389
+ });
390
+ return { wasm, loading, error };
391
+ }
392
+ }
393
+ </script>
462
394
  ```
463
- examples/
464
- โ”œโ”€โ”€ math-wasm/ # Go math library example
465
- โ”œโ”€โ”€ image-wasm/ # Image processing example
466
- โ”œโ”€โ”€ basic-usage.js # Basic Node.js usage
467
- โ”œโ”€โ”€ advanced-usage.js # Advanced features demo
468
- โ”œโ”€โ”€ github-usage.js # GitHub loading examples
469
- โ”œโ”€โ”€ react-calculator.jsx # React example
470
- โ”œโ”€โ”€ vue-calculator.vue # Vue.js example
471
- โ””โ”€โ”€ browser-demo.html # Browser demo
472
-
473
- src/
474
- โ”œโ”€โ”€ index.js # Main entry point
475
- โ”œโ”€โ”€ loader.js # WASM module loader
476
- โ”œโ”€โ”€ bridge.js # WASM-JavaScript bridge
477
- โ”œโ”€โ”€ browser.js # Browser-specific code
478
- โ””โ”€โ”€ loader-browser.js # Browser loader
479
-
480
- composables/
481
- โ””โ”€โ”€ useWasm.js # Vue 3 composables
482
-
483
- hooks/
484
- โ””โ”€โ”€ useWasm.js # React hooks
485
-
486
- types/
487
- โ””โ”€โ”€ index.d.ts # TypeScript definitions
488
- ```
489
-
490
- ## ๐Ÿงช Testing
491
-
492
- ```bash
493
- # Run all tests
494
- npm test
495
395
 
496
- # Run specific tests
497
- npm run test:basic
498
- npm run test:advanced
499
- npm run test:wasm
500
- npm run test:image
396
+ ### `useMultipleWasm(modules)`
501
397
 
502
- # Test GitHub loading
503
- node examples/github-usage.js
398
+ Composable for loading multiple WASM modules.
504
399
 
505
- # Build examples
506
- npm run build:examples
400
+ ```vue
401
+ <script>
402
+ import { useMultipleWasm } from 'gowm/composables/useWasm';
507
403
 
508
- # Start browser demo
509
- npm run demo:browser
404
+ export default {
405
+ setup() {
406
+ const { modules, loading, errors } = useMultipleWasm([
407
+ { name: 'local', path: './local.wasm' },
408
+ { name: 'github', github: 'org/repo' }
409
+ ]);
410
+ return { modules, loading, errors };
411
+ }
412
+ }
413
+ </script>
510
414
  ```
511
415
 
512
- ## โšก Performance Tips
513
-
514
- - Use `preInit: true` for better performance (default)
515
- - Reuse module instances when possible
516
- - Clean up modules when done: `bridge.cleanup()`
517
- - Monitor memory usage with `getTotalMemoryUsage()`
518
- - Use specific branches/tags for stable versions
519
- - Cache GitHub repositories locally when possible
416
+ ## ๐ŸŒ Browser Usage
417
+
418
+ For browser environments, use the ES6 module version:
419
+
420
+ ```html
421
+ <!DOCTYPE html>
422
+ <html>
423
+ <head>
424
+ <script type="module">
425
+ import { loadFromGitHub } from './node_modules/gowm/src/browser.js';
426
+
427
+ async function init() {
428
+ const wasm = await loadFromGitHub('org/wasm-module');
429
+ const result = wasm.call('myFunction', 42);
430
+ console.log(result);
431
+ }
432
+
433
+ init();
434
+ </script>
435
+ </head>
436
+ <body>
437
+ <h1>GoWM Browser Example</h1>
438
+ </body>
439
+ </html>
440
+ ```
520
441
 
521
- ## ๐Ÿ› ๏ธ TypeScript Support
442
+ ## ๐Ÿ”„ Migration from Deprecated Features
522
443
 
523
- GoWM includes comprehensive TypeScript definitions:
444
+ ### NPM Package Loading (Deprecated)
524
445
 
525
- - `LoadOptions`: Module loading options
526
- - `GitHubLoadOptions`: GitHub-specific loading options
527
- - `WasmBridge`: Main bridge interface
528
- - `ModuleStats`: Statistics interface
529
- - `UseWasmResult`: Hook return types
530
- - `VueWasmResult`: Composable return types
531
- - `GitHubRepoConfig`: GitHub repository configuration
446
+ **โš ๏ธ IMPORTANT:** NPM package loading is deprecated and will be removed in future versions. Please migrate to GitHub repository loading for better reliability and performance.
532
447
 
533
- ### Error Handling
448
+ **Old way (deprecated):**
449
+ ```javascript
450
+ // โŒ Deprecated - will be removed
451
+ const math = await loadFromNPM('my-wasm-package');
452
+ ```
534
453
 
454
+ **New way (recommended):**
535
455
  ```javascript
536
- try {
537
- const math = await loadFromGitHub('myorg/wasm-math');
538
- const result = math.call('add', 5, 3);
539
- } catch (error) {
540
- console.error('WASM call error:', error.message);
541
- }
456
+ // โœ… Recommended approach
457
+ const math = await loadFromGitHub('myorg/my-wasm-package');
542
458
  ```
543
459
 
544
- ## ๐Ÿ”„ Migration from NPM
460
+ ### Migration Benefits
545
461
 
546
- The NPM loading system is now deprecated in favor of GitHub loading:
462
+ - **Better reliability**: Direct access to source repositories
463
+ - **Version control**: Use specific branches, tags, or commits
464
+ - **Faster loading**: No NPM registry overhead
465
+ - **Always up-to-date**: Access latest releases immediately
466
+ - **Better caching**: Browser and CDN optimization
547
467
 
548
- ```javascript
549
- // โŒ Old (deprecated)
550
- const math = await loadFromNPM('my-wasm-math');
468
+ ## ๐Ÿ“Š Examples
551
469
 
552
- // โœ… New (recommended)
553
- const math = await loadFromGitHub('myorg/wasm-math');
554
- ```
470
+ Check out the `/examples` directory for comprehensive examples:
555
471
 
556
- ### Benefits of GitHub Loading
472
+ - **Node.js examples**: Basic and advanced usage
473
+ - **React examples**: Complete React applications
474
+ - **Vue examples**: Vue 3 application templates
475
+ - **Browser examples**: Vanilla JavaScript implementations
476
+ - **Framework examples**: Integration with popular frameworks
557
477
 
558
- - โœ… **Direct repository access** - No NPM publishing required
559
- - โœ… **Branch and tag support** - Use specific versions
560
- - โœ… **Custom file paths** - Flexible repository structure
561
- - โœ… **Release asset support** - Load from GitHub releases
562
- - โœ… **Automatic file discovery** - Smart filename detection
563
- - โœ… **Version control integration** - Direct Git integration
478
+ ## ๐Ÿค Contributing
564
479
 
565
- ## ๐Ÿ“„ License
480
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
566
481
 
567
- MIT License - see [LICENSE](LICENSE) file for details.
482
+ ### Development Setup
568
483
 
569
- ## ๐Ÿค Contributing
484
+ ```bash
485
+ git clone https://github.com/benoitpetit/gowm.git
486
+ cd gowm
487
+ npm install
488
+ npm test
489
+ ```
490
+
491
+ ## ๐Ÿ“„ License
570
492
 
571
- Contributions are welcome! Please read our contributing guidelines and submit pull requests.
493
+ MIT License - see the [LICENSE](LICENSE) file for details.
572
494
 
573
495
  ## ๐Ÿ”— Links
574
496
 
575
- - [GitHub Repository](https://github.com/benoitpetit/gowm)
576
497
  - [NPM Package](https://www.npmjs.com/package/gowm)
577
- - [Go WebAssembly Documentation](https://github.com/golang/go/wiki/WebAssembly)
498
+ - [GitHub Repository](https://github.com/benoitpetit/gowm)
499
+ - [Documentation](https://github.com/benoitpetit/gowm/blob/main/README.md)
500
+ - [Examples](https://github.com/benoitpetit/gowm/tree/main/examples)
501
+
502
+ ---
503
+
504
+ <div align="center">
505
+ <p>Made with โค๏ธ by <a href="https://github.com/benoitpetit">@devbyben</a></p>
506
+ <p>โญ Star us on GitHub if this project helped you!</p>
507
+ </div>