UNPKG

@vladimirdukelic/revolutionary-ui-factory

Version:

Revolutionary UI Factory System v2 - Generate ANY UI component for ANY framework with 60-95% code reduction

264 lines 9.55 kB
"use strict"; /** * Marketplace Client for Revolutionary UI Factory * Handles marketplace component browsing, search, and installation */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mockComponents = exports.MarketplaceClient = void 0; const fs = __importStar(require("fs/promises")); const path = __importStar(require("path")); const auth_manager_1 = require("./auth-manager"); const chalk_1 = __importDefault(require("chalk")); class MarketplaceClient { cache = new Map(); /** * Search marketplace components */ async search(options = {}) { // Check cache const cacheKey = JSON.stringify(options); if (this.cache.has(cacheKey)) { return this.cache.get(cacheKey); } // Make API request const response = await auth_manager_1.AuthManager.apiRequest('/marketplace/search', { method: 'POST', body: JSON.stringify(options) }); if (!response) { throw new Error('Failed to search marketplace'); } const data = await response.json(); // Cache results this.cache.set(cacheKey, data.components); return data.components; } /** * Get component details */ async getComponent(componentId) { const response = await auth_manager_1.AuthManager.apiRequest(`/marketplace/components/${componentId}`); if (!response) { throw new Error('Failed to get component details'); } return await response.json(); } /** * Install a marketplace component */ async install(componentId, options = {}) { // Get component details const component = await this.getComponent(componentId); // Get component code const response = await auth_manager_1.AuthManager.apiRequest(`/marketplace/components/${componentId}/download`, { method: 'POST', body: JSON.stringify({ framework: options.framework, styling: options.styling, typescript: options.typescript }) }); if (!response) { throw new Error('Failed to download component'); } const { files } = await response.json(); // Save files const outputDir = options.outputDir || './src/components'; for (const file of files) { const filePath = path.join(outputDir, file.path); const dir = path.dirname(filePath); // Ensure directory exists await fs.mkdir(dir, { recursive: true }); // Write file await fs.writeFile(filePath, file.content, 'utf-8'); console.log(chalk_1.default.green(`✅ Created ${file.path}`)); } // Install dependencies if needed if (component.dependencies && component.dependencies.length > 0) { console.log(chalk_1.default.cyan('\n📦 Installing dependencies...')); const { execSync } = require('child_process'); try { execSync(`npm install ${component.dependencies.join(' ')}`, { stdio: 'inherit', cwd: process.cwd() }); } catch (error) { console.log(chalk_1.default.yellow('⚠️ Failed to install dependencies automatically')); console.log(chalk_1.default.gray('Please run: npm install ' + component.dependencies.join(' '))); } } // Track installation await auth_manager_1.AuthManager.apiRequest(`/marketplace/components/${componentId}/install`, { method: 'POST' }); } /** * Get popular components */ async getPopular(limit = 10) { return this.search({ sortBy: 'downloads', limit }); } /** * Get recently updated components */ async getRecent(limit = 10) { return this.search({ sortBy: 'updated', limit }); } /** * Get components by category */ async getByCategory(category, limit = 20) { return this.search({ category, limit }); } /** * Get featured components */ async getFeatured() { const response = await auth_manager_1.AuthManager.apiRequest('/marketplace/featured'); if (!response) { throw new Error('Failed to get featured components'); } return await response.json(); } } exports.MarketplaceClient = MarketplaceClient; // Mock data for development exports.mockComponents = [ { id: 'advanced-data-table', name: 'Advanced Data Table', description: 'Feature-rich data table with sorting, filtering, pagination, and export', category: 'tables', framework: ['react', 'vue'], styling: ['tailwind', 'css'], author: 'Revolutionary UI', downloads: 15420, rating: 4.8, price: 0, screenshots: ['/screenshots/data-table-1.png'], features: ['Virtual scrolling', 'Column resizing', 'Row selection', 'Export to CSV/Excel'], dependencies: [], version: '2.1.0', updatedAt: '2025-07-28', tags: ['table', 'data', 'grid'] }, { id: 'multi-step-form', name: 'Multi-Step Form Wizard', description: 'Beautiful multi-step form with validation and progress tracking', category: 'forms', framework: ['react', 'vue', 'angular'], styling: ['tailwind', 'styled-components'], author: 'Revolutionary UI', downloads: 12350, rating: 4.9, price: 0, screenshots: ['/screenshots/form-wizard-1.png'], features: ['Step validation', 'Progress bar', 'Save & continue', 'Custom themes'], dependencies: ['react-hook-form', 'zod'], version: '1.5.0', updatedAt: '2025-07-25', tags: ['form', 'wizard', 'validation'] }, { id: 'dashboard-layout', name: 'Admin Dashboard Layout', description: 'Complete admin dashboard with sidebar, header, and responsive layout', category: 'dashboards', framework: ['react', 'vue'], styling: ['tailwind'], author: 'Revolutionary UI', downloads: 23500, rating: 4.7, price: 0, screenshots: ['/screenshots/dashboard-1.png'], features: ['Responsive sidebar', 'Dark mode', 'Breadcrumbs', 'User menu'], dependencies: [], version: '3.0.0', updatedAt: '2025-07-20', tags: ['dashboard', 'admin', 'layout'] }, { id: 'kanban-board-pro', name: 'Kanban Board Pro', description: 'Drag-and-drop Kanban board with swimlanes and custom cards', category: 'data-display', framework: ['react'], styling: ['tailwind', 'css'], author: 'UI Masters', downloads: 8900, rating: 4.6, price: 29, screenshots: ['/screenshots/kanban-1.png'], features: ['Drag & drop', 'Swimlanes', 'Custom cards', 'Filters'], dependencies: ['@dnd-kit/sortable'], version: '2.0.0', updatedAt: '2025-07-22', tags: ['kanban', 'board', 'drag-drop'] }, { id: 'calendar-scheduler', name: 'Calendar & Scheduler', description: 'Full-featured calendar with event management and scheduling', category: 'calendars', framework: ['react', 'vue'], styling: ['tailwind'], author: 'Revolutionary UI', downloads: 11200, rating: 4.8, price: 0, screenshots: ['/screenshots/calendar-1.png'], features: ['Month/Week/Day views', 'Event drag & drop', 'Recurring events', 'Timezone support'], dependencies: ['date-fns'], version: '1.8.0', updatedAt: '2025-07-18', tags: ['calendar', 'scheduler', 'events'] } ]; //# sourceMappingURL=marketplace-client.js.map