From 448a250cf6340b88658c9e6eb5fbb208b705807b Mon Sep 17 00:00:00 2001 From: Danish Arora Date: Tue, 9 Sep 2025 18:21:12 +0530 Subject: [PATCH] feat: npm --- packages/core/.npmignore | 69 ++++++++++++++++++++ packages/core/README.md | 127 +++++++++++++++++++++++++++++++++++++ packages/core/package.json | 34 ++++++++-- 3 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 packages/core/.npmignore create mode 100644 packages/core/README.md diff --git a/packages/core/.npmignore b/packages/core/.npmignore new file mode 100644 index 0000000..eb29c46 --- /dev/null +++ b/packages/core/.npmignore @@ -0,0 +1,69 @@ +# Source files +src/ +tsconfig.json + +# Development files +*.test.ts +*.test.js +*.spec.ts +*.spec.js +__tests__/ +test/ + +# Build artifacts (keep dist/) +*.tsbuildinfo + +# Development dependencies +node_modules/ + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo + +# OS files +.DS_Store +Thumbs.db + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Environment files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Git +.git/ +.gitignore + +# Documentation (keep README.md) +docs/ +*.md +!README.md + +# CI/CD +.github/ +.gitlab-ci.yml +.travis.yml +.circleci/ + +# Linting +.eslintrc* +.prettierrc* +.eslintignore +.prettierignore + +# Coverage +coverage/ +.nyc_output/ + +# Temporary files +tmp/ +temp/ diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 0000000..1386d8d --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1,127 @@ +# @opchan/core + +Core package for OpChan - A decentralized forum built on Bitcoin Ordinals and Waku protocol. + +## Features + +- **Waku Integration**: Complete Waku protocol implementation for decentralized messaging +- **Bitcoin/Ethereum Wallet Support**: Multi-chain wallet integration with Reown AppKit +- **Forum Operations**: Cell creation, posts, comments, and voting system +- **Relevance Scoring**: Sophisticated algorithm for content ranking +- **Moderation System**: Cell-based moderation capabilities +- **Key Delegation**: Browser key generation for improved UX +- **Local Storage**: IndexedDB integration for offline-first experience +- **TypeScript**: Full TypeScript support with comprehensive type definitions + +## Installation + +```bash +npm install @opchan/core +``` + +## Usage + +### Basic Setup + +```typescript +import { WakuNodeManager, ForumActions, LocalDatabase } from '@opchan/core'; + +// Initialize Waku node +const wakuManager = new WakuNodeManager(); +await wakuManager.initialize(); + +// Initialize local database +const db = new LocalDatabase(); +await db.initialize(); + +// Create forum actions +const forumActions = new ForumActions(wakuManager, db); +``` + +### Creating a Cell + +```typescript +import { ForumActions } from '@opchan/core'; + +const cell = await forumActions.createCell( + 'My Cell', + 'Description of my cell', + 'https://example.com/icon.png' // optional +); +``` + +### Creating Posts and Comments + +```typescript +// Create a post +const post = await forumActions.createPost( + cellId, + 'Post Title', + 'Post content here' +); + +// Create a comment +const comment = await forumActions.createComment( + postId, + 'Comment content here' +); +``` + +### Voting System + +```typescript +// Vote on a post +await forumActions.votePost(postId, true); // upvote +await forumActions.votePost(postId, false); // downvote + +// Vote on a comment +await forumActions.voteComment(commentId, true); +``` + +### Wallet Integration + +```typescript +import { createWalletConfig } from '@opchan/core/wallet'; + +const config = createWalletConfig({ + projectId: 'your-project-id', + // ... other wallet configuration +}); +``` + +## API Reference + +### Core Classes + +- **WakuNodeManager**: Manages Waku node lifecycle and connections +- **ForumActions**: Handles all forum operations (create, vote, moderate) +- **LocalDatabase**: IndexedDB wrapper for local data persistence +- **RelevanceCalculator**: Calculates content relevance scores +- **BookmarkService**: Manages user bookmarks +- **UserIdentityService**: Handles user identity and verification + +### Types + +- **Cell**: Forum cell/board structure +- **Post**: Forum post structure +- **Comment**: Comment structure +- **User**: User identity and verification status +- **Vote**: Voting system types + +## Requirements + +- Node.js 18+ +- Modern browser with IndexedDB support +- Bitcoin or Ethereum wallet (for posting) + +## License + +MIT + +## Contributing + +Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository. + +## Support + +For questions and support, please open an issue on our GitHub repository. diff --git a/packages/core/package.json b/packages/core/package.json index 87a228f..133e47f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { - "name": "@opchan/core", + "name": "opchan-core", "version": "1.0.0", - "description": "Core package for opchan", + "description": "Core package for OpChan - A decentralized forum built on Waku protocol", "type": "module", "main": "dist/index.js", "module": "dist/index.js", @@ -13,8 +13,32 @@ } }, "files": [ - "dist" + "dist", + "README.md" ], + "keywords": [ + "opchan", + "waku", + "bitcoin", + "ordinals", + "ethereum", + "decentralized", + "forum", + "p2p", + "blockchain", + "cryptocurrency" + ], + "author": "OpChan Team", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/waku-org/OpChan.git", + "directory": "packages/core" + }, + "bugs": { + "url": "https://github.com/waku-org/OpChan/issues" + }, + "homepage": "https://github.com/waku-org/OpChan#readme", "scripts": { "build": "tsc", "dev": "tsc --watch", @@ -22,7 +46,9 @@ "lint": "eslint src --ext .ts,.tsx", "lint:fix": "eslint src --ext .ts,.tsx --fix", "check": "tsc --noEmit && eslint src --ext .ts,.tsx && prettier --check src", - "fix": "prettier --write src && eslint src --ext .ts,.tsx --fix" + "fix": "prettier --write src && eslint src --ext .ts,.tsx --fix", + "prepublishOnly": "npm run build", + "prepack": "npm run build" }, "devDependencies": { "@types/node": "^20.0.0",