{"id":45278187,"url":"https://github.com/ersinkoc/plugin","last_synced_at":"2026-02-21T02:04:11.330Z","repository":{"id":332860105,"uuid":"1135269220","full_name":"ersinkoc/Plugin","owner":"ersinkoc","description":"      Micro-kernel plugin system for the OXOG ecosystem with typed events, lifecycle hooks, and dependency resolution.","archived":false,"fork":false,"pushed_at":"2026-01-25T00:01:57.000Z","size":264,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-25T12:45:50.442Z","etag":null,"topics":["kernel","plugin"],"latest_commit_sha":null,"homepage":"http://plugin.oxog.dev/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ersinkoc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-15T21:42:50.000Z","updated_at":"2026-01-25T00:02:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ersinkoc/Plugin","commit_stats":null,"previous_names":["ersinkoc/plugin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ersinkoc/Plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ersinkoc%2FPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ersinkoc%2FPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ersinkoc%2FPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ersinkoc%2FPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ersinkoc","download_url":"https://codeload.github.com/ersinkoc/Plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ersinkoc%2FPlugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29671513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kernel","plugin"],"created_at":"2026-02-21T02:03:58.299Z","updated_at":"2026-02-21T02:04:11.321Z","avatar_url":"https://github.com/ersinkoc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @oxog/plugin\n\n[![npm version](https://badge.fury.io/js/%40oxog%2Fplugin.svg)](https://www.npmjs.com/package/@oxog/plugin)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003e Micro-kernel plugin system for the @oxog ecosystem with typed events, lifecycle hooks, and dependency resolution.\n\n**@oxog/plugin** is the heart of the @oxog ecosystem. It provides the core micro-kernel implementation that all other @oxog packages build upon.\n\n## Features\n\n- **Plugin Lifecycle** - `install` → `init` → `destroy` with full async support\n- **Typed Events** - Type-safe event bus for inter-plugin communication\n- **Dependency Resolution** - Automatic topological sorting of plugins\n- **Error Boundaries** - Configurable strategies: isolate, fail-fast, collect\n- **Context Management** - Shared state between plugins\n- **Dynamic Plugins** - Add, remove, replace, and reload at runtime\n- **Fluent API** - Chainable method calls\n- **Zero Dependencies** - Only `@oxog/types` at runtime\n- **Universal** - Works in Node.js \u003e= 18 and modern browsers\n- **Tiny Bundle** - \u003c 4KB gzipped core, \u003c 6KB total\n\n## Installation\n\n```bash\nnpm install @oxog/plugin\n```\n\n## Quick Start\n\n```typescript\nimport { createKernel } from '@oxog/plugin';\n\n// Create a kernel\nconst kernel = createKernel();\n\n// Define a plugin\nconst loggerPlugin = {\n  name: 'logger',\n  version: '1.0.0',\n  install(kernel) {\n    kernel.log = (...args) =\u003e console.log('[LOG]', ...args);\n  }\n};\n\n// Register and initialize\nkernel.use(loggerPlugin);\nawait kernel.init();\n\n// Use the plugin\n(kernel as any).log('Hello, World!');\n\n// Cleanup\nawait kernel.destroy();\n```\n\n## Documentation\n\nFor full documentation, examples, and API reference, visit [plugin.oxog.dev](https://plugin.oxog.dev).\n\n### Examples\n\n- [01 - Basic Kernel](./examples/01-basic-kernel)\n- [02 - Plugin Registration](./examples/02-plugin-registration)\n- [03 - Lifecycle Hooks](./examples/03-lifecycle-hooks)\n- [04 - Typed Events](./examples/04-typed-events)\n- [05 - Wildcard Events](./examples/05-wildcard-events)\n- [06 - Dependencies](./examples/06-dependencies)\n- [07 - Error Handling](./examples/07-error-handling)\n- [08 - Context Sharing](./examples/08-context-sharing)\n- [09 - Plugin Factories](./examples/09-plugin-factories)\n- [10 - Dynamic Plugins](./examples/10-dynamic-plugins)\n- [11 - Plugin Queries](./examples/11-plugin-queries)\n- [12 - Kernel Events](./examples/12-kernel-events)\n- [13 - Error Strategies](./examples/13-error-strategies)\n- [14 - Replace \u0026 Reload](./examples/14-replace-reload)\n- [15 - Real-World App](./examples/15-real-world-app)\n\n## API Reference\n\n### `createKernel\u003cTContext, TEvents\u003e(options?)`\n\nCreates a new micro-kernel instance.\n\n**Options:**\n- `context` - Initial shared context\n- `errorStrategy` - 'isolate' | 'fail-fast' | 'collect'\n- `onError` - Global error handler\n- `onBeforeInit`, `onAfterInit` - Init lifecycle hooks\n- `onBeforeDestroy`, `onAfterDestroy` - Destroy lifecycle hooks\n\n**Returns:** `KernelInstance\u003cTContext, TEvents\u003e`\n\n### KernelInstance Methods\n\n| Method | Description |\n|--------|-------------|\n| `use(plugin)` | Register a plugin |\n| `useAll(plugins[])` | Register multiple plugins |\n| `init()` | Initialize all plugins |\n| `destroy()` | Destroy all plugins |\n| `waitForPlugin(name)` | Wait for plugin initialization |\n| `waitForAll()` | Wait for all pending inits |\n| `getPlugin(name)` | Get a plugin by name |\n| `hasPlugin(name)` | Check if plugin exists |\n| `listPlugins()` | Get all plugins |\n| `getPluginNames()` | Get all plugin names |\n| `getDependencyGraph()` | Get dependency graph |\n| `on(event, handler)` | Subscribe to event |\n| `once(event, handler)` | Subscribe once |\n| `emit(event, payload)` | Emit event |\n| `off(event, handler)` | Unsubscribe |\n| `onWildcard(handler)` | Subscribe to all events |\n| `onPattern(pattern, handler)` | Subscribe to pattern |\n| `getContext()` | Get shared context |\n| `updateContext(partial)` | Shallow update context |\n| `deepUpdateContext(partial)` | Deep merge context |\n| `unregister(name)` | Remove plugin |\n| `replace(plugin)` | Replace plugin |\n| `reload(name)` | Reload plugin |\n\n## Plugin Interface\n\n```typescript\ninterface Plugin\u003cTContext\u003e {\n  name: string;\n  version: string;\n  dependencies?: string[];\n\n  install(kernel: Kernel\u003cTContext\u003e): void;\n  onInit?(context: TContext): MaybePromise\u003cvoid\u003e;\n  onDestroy?(): MaybePromise\u003cvoid\u003e;\n  onError?(error: Error): void;\n}\n```\n\n## License\n\n[MIT](LICENSE) © Ersin Koç\n\n## Links\n\n- [GitHub](https://github.com/ersinkoc/plugin)\n- [Website](https://plugin.oxog.dev)\n- [Documentation](https://plugin.oxog.dev)\n- [npm](https://www.npmjs.com/package/@oxog/plugin)\n\n---\n\nMade with ❤️ by Ersin Koç\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fersinkoc%2Fplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fersinkoc%2Fplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fersinkoc%2Fplugin/lists"}