@slotkitjs/types
v0.3.0
Published
TypeScript type definitions for SlotKit plugin system
Maintainers
Readme
@slotkitjs/types
TypeScript type definitions for the SlotKit plugin system.
Overview
This package provides type-only exports for the SlotKit plugin system, allowing plugins to import type definitions without creating runtime dependencies on implementation code.
Installation
npm install @slotkitjs/types
# or
pnpm add @slotkitjs/types
# or
yarn add @slotkitjs/typesUsage
Importing Service Contracts
import type { IAuthService, IHttpClient } from '@slotkitjs/types/contracts'
// Use types without importing implementations
const authService = context.services.get<IAuthService>('IAuthService')Importing Event Types
import type { AuthLoginEvent, AuthLogoutEvent } from '@slotkitjs/types/events'
// Type-safe event handling
context.events.on<AuthLoginEvent>('auth:login', (event) => {
console.log('User logged in:', event.payload.userId)
})Importing Core Types
import type {
ServiceContainer,
EventBus,
ExtensionRegistry,
PluginContext
} from '@slotkitjs/types/core'Package Structure
/contracts- Service contract interfaces/events- Event type definitions/core- Core system type definitions
Benefits
- No Runtime Dependencies: Import types without bundling implementation code
- Type Safety: Full TypeScript type checking across plugin boundaries
- Decoupling: Plugins depend only on interfaces, not implementations
- Versioning: Type definitions can be versioned independently
License
MIT
