UNPKG

circuit-bricks

Version:

A modular, Lego-style SVG circuit component system for React (ALPHA - Not for production use)

111 lines (109 loc) 3.37 kB
"use client"; "use strict"; const require_ic = require('./ic-DFHJiT6Z.cjs'); //#region src/registry/server.ts const serverComponentRegistry = {}; /** * Initialize the server-side registry with built-in components */ function initializeServerRegistry() { if (Object.keys(serverComponentRegistry).length > 0) return; const components = [ require_ic.resistor_default, require_ic.capacitor_default, require_ic.ground_default, require_ic.switch_default, require_ic.battery_default, require_ic.voltage_source_default, require_ic.diode_default, require_ic.transistor_npn_default, require_ic.led_default, require_ic.ic_default ]; for (const schema of components) try { const validationResult = require_ic.validateComponentSchema(schema); if (validationResult.success) serverComponentRegistry[schema.id] = schema; else console.warn(`Failed to validate component schema ${schema.id}:`, validationResult.error); } catch (error) { console.warn(`Failed to register component ${schema.id}:`, error); } } /** * Register a component schema in the server-side registry */ function registerServerComponent(schema) { initializeServerRegistry(); const validationResult = require_ic.validateComponentSchema(schema); if (!validationResult.success) throw new Error(`Invalid component schema: ${validationResult.error}`); if (serverComponentRegistry[schema.id]) console.warn(`Component with ID ${schema.id} already exists in server registry. Overwriting.`); serverComponentRegistry[schema.id] = schema; } /** * Get a component schema from the server-side registry by ID */ function getServerComponentSchema(id) { initializeServerRegistry(); return serverComponentRegistry[id]; } /** * Get all component schemas in the server-side registry */ function getAllServerComponents() { initializeServerRegistry(); return Object.values(serverComponentRegistry); } /** * Get component schemas by category from the server-side registry */ function getServerComponentsByCategory(category) { initializeServerRegistry(); return Object.values(serverComponentRegistry).filter((schema) => schema.category === category); } /** * Get all unique categories from the server-side registry */ function getServerCategories() { initializeServerRegistry(); const allComponents = getAllServerComponents(); const categories = [...new Set(allComponents.map((schema) => schema.category))]; return categories.sort(); } var server_default = serverComponentRegistry; //#endregion Object.defineProperty(exports, 'getAllServerComponents', { enumerable: true, get: function () { return getAllServerComponents; } }); Object.defineProperty(exports, 'getServerCategories', { enumerable: true, get: function () { return getServerCategories; } }); Object.defineProperty(exports, 'getServerComponentSchema', { enumerable: true, get: function () { return getServerComponentSchema; } }); Object.defineProperty(exports, 'getServerComponentsByCategory', { enumerable: true, get: function () { return getServerComponentsByCategory; } }); Object.defineProperty(exports, 'registerServerComponent', { enumerable: true, get: function () { return registerServerComponent; } }); Object.defineProperty(exports, 'server_default', { enumerable: true, get: function () { return server_default; } }); //# sourceMappingURL=server-BjGSQsdb.cjs.map