Skip to content

Nexus-Studio-CEO/CSOP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 CSOP - Client-Side Orchestration Protocol

npm version npm downloads License: MIT GitHub stars

Enterprise-grade client-side orchestration protocol for modern web applications

CSOP provides a unified interface for managing browser capabilities (storage, compute, sync) with enterprise-grade reliability, performance, and developer experience.

✨ Features

  • πŸ—„οΈ Unified Storage - IndexedDB wrapper with simple API
  • ⚑ Web Workers - Parallel computation with worker pool management
  • πŸ”„ Real-time Sync - WebSocket/Server-Sent Events integration
  • 🎯 Type-Safe - Full TypeScript support (coming soon)
  • πŸ§ͺ Tested - Comprehensive test suite
  • πŸ“¦ Lightweight - < 10KB gzipped
  • 🌐 CDN Ready - Available via unpkg and jsDelivr

πŸ“¦ Installation

NPM (Recommended)

npm install @tryboy869/csop

Yarn

yarn add @tryboy869/csop

PNPM

pnpm add @tryboy869/csop

CDN

unpkg

<script type="module">
  import { CSOP } from 'https://unpkg.com/@tryboy869/csop@0.1.0';
</script>

jsDelivr

<script type="module">
  import { CSOP } from 'https://cdn.jsdelivr.net/npm/@tryboy869/csop@0.1.0';
</script>

πŸš€ Quick Start

Basic Usage

import { CSOP } from '@tryboy869/csop';

// Initialize CSOP
const csop = new CSOP();
await csop.init();

// Use storage capability
const storage = csop.getCapability('storage');
await storage.set('user', { name: 'John', role: 'admin' });
const user = await storage.get('user');
console.log(user); // { name: 'John', role: 'admin' }

With Configuration

import { CSOP } from '@tryboy869/csop';

const csop = new CSOP({
  storage: {
    dbName: 'myapp',
    version: 1
  },
  compute: {
    maxWorkers: 4
  }
});

await csop.init();

πŸ“š API Documentation

Core API

new CSOP(config?)

Creates a new CSOP instance with optional configuration.

const csop = new CSOP({
  storage: { dbName: 'myapp' },
  compute: { maxWorkers: 4 },
  sync: { endpoint: 'wss://api.example.com' }
});

csop.init(): Promise<void>

Initializes all registered capabilities.

await csop.init();

csop.getCapability(name: string): Capability

Retrieves a registered capability.

const storage = csop.getCapability('storage');

Storage Capability

storage.set(key: string, value: any): Promise<void>

Stores a value in IndexedDB.

await storage.set('settings', { theme: 'dark', lang: 'en' });

storage.get(key: string): Promise<any>

Retrieves a value from IndexedDB.

const settings = await storage.get('settings');

storage.delete(key: string): Promise<void>

Deletes a value from IndexedDB.

await storage.delete('settings');

storage.clear(): Promise<void>

Clears all data from IndexedDB.

await storage.clear();

Compute Capability

compute.execute(task: Function, data: any): Promise<any>

Executes a task in a Web Worker.

const result = await compute.execute((data) => {
  return data.numbers.reduce((a, b) => a + b, 0);
}, { numbers: [1, 2, 3, 4, 5] });

console.log(result); // 15

Sync Capability

sync.connect(): Promise<void>

Establishes a real-time connection.

await sync.connect();

sync.subscribe(channel: string, callback: Function): void

Subscribes to a channel for real-time updates.

sync.subscribe('updates', (data) => {
  console.log('Received:', data);
});

🌐 CDN Usage

CSOP is available on multiple CDNs for easy integration without a build step.

unpkg (Recommended)

<!DOCTYPE html>
<html>
<head>
  <title>CSOP Example</title>
</head>
<body>
  <script type="module">
    import { CSOP } from 'https://unpkg.com/@tryboy869/csop@0.1.0';
    
    const csop = new CSOP();
    await csop.init();
    
    const storage = csop.getCapability('storage');
    await storage.set('message', 'Hello from CDN!');
    const message = await storage.get('message');
    console.log(message);
  </script>
</body>
</html>

jsDelivr

<script type="module">
  import { CSOP } from 'https://cdn.jsdelivr.net/npm/@tryboy869/csop@0.1.0';
  // Your code here
</script>

πŸ”§ Advanced Configuration

Custom Storage Database

const csop = new CSOP({
  storage: {
    dbName: 'myapp-db',
    version: 2,
    stores: ['users', 'posts', 'settings']
  }
});

Worker Pool Configuration

const csop = new CSOP({
  compute: {
    maxWorkers: navigator.hardwareConcurrency || 4,
    timeout: 30000 // 30 seconds
  }
});

Real-time Sync Configuration

const csop = new CSOP({
  sync: {
    endpoint: 'wss://api.example.com/realtime',
    reconnect: true,
    reconnectDelay: 1000
  }
});

πŸ§ͺ Testing

CSOP includes a comprehensive test suite.

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

πŸ—οΈ Project Structure

CSOP/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ csop.js           # Core orchestrator
β”‚   β”œβ”€β”€ validation.js     # Input validation
β”‚   β”œβ”€β”€ errors.js         # Error codes
β”‚   β”œβ”€β”€ utils.js          # Utilities
β”‚   └── capabilities/
β”‚       β”œβ”€β”€ storage.js    # IndexedDB capability
β”‚       β”œβ”€β”€ compute.js    # Web Workers capability
β”‚       └── sync.js       # Real-time sync capability
β”œβ”€β”€ test/
β”‚   └── runner.js         # Test suite
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
└── LICENSE

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

DAOUDA Abdoul Anzize - Nexus Studio

πŸ”— Links

πŸ™ Acknowledgments

  • Built with ❀️ by Nexus Studio
  • Powered by modern web standards (IndexedDB, Web Workers, WebSockets)
  • AI-assisted development with Groq Llama 3.3

Made with ❀️ for the JavaScript community

About

Client-Side Orchestration Protocol ( this protocol let you build fullstack app without deploy it on servers cloud )

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors