Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Example Helia Angular #425

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Nkovaturient
Copy link

Issue: #308 #309

Description:
Properly configured, setup and resolved Helia to work seamlessly within the Angular application while maintaining good development practices and build optimization.

Uses isPlatformBrowser() to check if code is running in browser environment
Gracefully handles SSR by preventing Helia initialization on server
Disables WebTransport to avoid Chrome crashes
BehaviorSubject: Stores and emits the current Helia initialization status-rxjs utilities

Fixes and Updates
Handles initialization states and errors properly
The key changes address:

  • Server-side rendering compatibility
  • Chrome crashing issues
  • Module resolution errors
  • Type safety
  • Error handling

1)ERROR NoValidAddressesError: no valid addresses were provided for transports [@libp2p/websockets]
fix: configure the WebSocket transport with proper addresses.
1.Listen for incoming WebSocket connections
2. Connect to bootstrap nodes for peer discovery
3.Properly encrypt connections
4.Handle multiple streams

2)Error committing text: Error: UnixFS failed to initialize at _HeliaService.<anonymous> (helia.service.ts:85:13) at Generator.next (<anonymous>)
fix: Properly wait for Helia initialization before attempting operations
Add better error handling throughout the application
Show initialization status and errors to the user

3)Type '() => StreamMuxerFactory' is not assignable to type 'StreamMuxerFactory'.
fix: Adding type annotation : any to the underscore parameter
Double-invoking yamux with ()() to get the actual muxer instance
This adds as any to force the type system to accept the yamux configuration. While not ideal, it should work around the type mismatch between different versions of the libp2p interfaces.

4)Error fetching committed text: ReferenceError: Buffer is not defined at _CommitTextService.
fix: Since Buffer isn't available in browsers, used Uint8Array instead

Conclusion:

Screenshot (474)

Screenshot (475)

@paschal533
Copy link

Hi @Nkovaturient,

Great work! Everything functions perfectly, and the implementation looks solid. However, I have a few suggestions to enhance the PR further:

  1. Dependencies: Please install @angular/platform-server and @angular/ssr. For some reason, they are missing from the package.json file.

  2. Readme Update: Could you update the README.md to match the format used in the Helia-Angular-Readme?

  3. CI Workflow: In the .github/workflows/ci.yml file, please add helia-angular under the projects section, as shown in this ci.yml example.

  4. Favicon: It would be great to update the favicon to Helia's logo. You can find it here: Helia Favicon.

The components look good to me, but @SgtPooki will provide additional feedback on the component structure and styling.

Overall, you've done an excellent job here. Keep up the great work 👏

@Nkovaturient
Copy link
Author

Thanks a lot for reviewing and suggesting required changes clearly @paschal533 ,
I have modified as desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants