{"id":"mrkirdid/kirnet","name":"kirnet","scope":"mrkirdid","platform":"roblox","description":"Mirrored from the Wally registry.","version":"3.0.0","latest":"3.0.0","versions":["1.2.0","1.2.1","1.2.2","1.9.0","1.9.1","1.9.2","1.9.3","1.9.4","1.9.5","1.9.6","3.0.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{"evaera/promise":{"version":"^4.0.0","alias":"Promise"}},"integrity":"077d838537e3214104f8cecedf4828f3b6ab22136d081084c8012bf0ed761426","likes":0,"downloads":0,"install":"forest install mrkirdid/kirnet","url":"https://forest.dev/p/roblox/mrkirdid/kirnet","files":"https://api.forest.dev/ai/package/roblox/mrkirdid/kirnet/files","readme":"﻿# KirNet\n\nKirNet is a services-first networking library for Roblox. Register services on the server, fetch them with `GetService()` on the client, and get typed, direction-safe networking with minimal API surface.\n\n## Why KirNet\n\n- Services only. No framework lifecycle, controller system, or startup ceremony.\n- Three building blocks: `CreateSignal`, `CreateFunction`, `CreateVariable`.\n- Runtime guardrails. Wrong-side and wrong-method calls error immediately.\n- Instance passthrough. Send Instances, userdata, or any unsupported type alongside compressed data — no errors, no workarounds.\n- Efficient transport. Buffers, optional batching, compression, lossy numeric payloads, and rate limiting are built in.\n- Replicated variables. `CreateVariable(value)` auto-syncs server state to clients.\n- Tooling. The companion `kirnet-type-gen` VS Code extension generates typed `GetService()` wrappers and string completions.\n\n## Install\n\nAdd KirNet to your `wally.toml`:\n\n```toml\n[dependencies]\nKirNet = \"mrkirdid/kirnet@3.0.0\"\n```\n\nThen install packages:\n\n```bash\nwally install\n```\n\nYour require path depends on your package alias and Rojo mapping. In a typical shared package setup:\n\n```luau\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal KirNet = require(ReplicatedStorage.Packages.KirNet)\n```\n\n## Quick Start\n\n### Server\n\n```luau\n--!strict\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal KirNet = require(ReplicatedStorage.Packages.KirNet)\n\nlocal ChatService = KirNet.RegisterService(\"ChatService\", {\n\t-- Server → client broadcast\n\tMessageSent = KirNet.CreateSignal({ direction = \"server\" }) :: KirNet.ServerSignal<string>,\n\n\t-- Client → server input\n\tSendMessage = KirNet.CreateSignal({ direction = \"client\" }) :: KirNet.ClientSignal<string>,\n\n\t-- Client calls, server responds\n\tGetHistory = KirNet.CreateFunction(function(player: Player, channel: string): { string }\n\t\treturn { \"Welcome to \" .. channel, \"Have fun.\" }\n\tend),\n\n\t-- Replicated variable (auto-syncs to clients)\n\tEnabled = KirNet.CreateVariable(true),\n})\n\nChatService.SendMessage:OnServerEvent(function(player, text)\n\tChatService.MessageSent:FireAll(player.Name .. \": \" .. text)\nend)\n\n-- Variables can be changed anytime — clients update automatically\nChatService.Enabled:Set(false)\n\nreturn ChatService\n```\n\n### Client\n\n```luau\n--!strict\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal KirNet = require(ReplicatedStorage.Packages.KirNet)\n\nlocal ChatService = KirNet.GetService(\"ChatService\")\n\nChatService.MessageSent:Connect(function(message)\n\tprint(message)\nend)\n\nChatService.SendMessage:FireServer(\"hello from the client\")\n\nlocal history = ChatService.GetHistory:Call(\"general\")\nprint(history[1])\n\n-- Read replicated variable\nprint(ChatService.Enabled:Get())\n\n-- React to variable changes\nChatService.Enabled:OnChanged(function(newValue, oldValue)\n\tprint(\"Chat enabled:\", newValue)\nend)\n```\n\n`GetService()` yields until the service is available. Pass a timeout if you want it to fail early:\n\n```luau\nlocal ChatService = KirNet.GetService(\"ChatService\", 5)\n```\n\n## API\n\n```luau\n-- Signals\nKirNet.CreateSignal(options?)                  -- bidirectional by default\nKirNet.CreateSignal({ direction = \"server\" })  -- server → client only\nKirNet.CreateSignal({ direction = \"client\" })  -- client → server only\n\n-- Functions\nKirNet.CreateFunction(handler?, options?)\n\n-- Variables\nKirNet.CreateVariable(initialValue)\n\n-- Service management\nKirNet.RegisterService(name, definition)   -- server only\nKirNet.GetService(name, timeout?)          -- client or server\n\n-- Utilities\nKirNet.UseMiddleware(fn)\nKirNet.SetDebug(enabled)\n```\n\n### Signal Direction\n\n| Direction | Server API | Client API | Use it for |\n| --- | --- | --- | --- |\n| `nil` (bidirectional) | `Fire`, `FireAll`, `FireExcept`, `FireList`, `OnServerEvent` | `FireServer`, `Connect`, `Once`, `Wait`, `Disconnect` | Rare bidirectional channels |\n| `\"server\"` | `Fire`, `FireAll`, `FireExcept`, `FireList` | `Connect`, `Once`, `Wait`, `Disconnect` | Broadcasts, state pushes |\n| `\"client\"` | `OnServerEvent` | `FireServer` | Input, actions, requests |\n\n### Variable API\n\n| Method | Side | Description |\n| --- | --- | --- |\n| `:Get()` | Both | Returns the current value |\n| `:Set(value)` | Server | Updates and replicates to all clients |\n| `:OnChanged(callback)` | Both | Fires `callback(newValue, oldValue)` on change |\n\n### Exported Types\n\n- `KirNet.ServerSignal<T...>`\n- `KirNet.ClientSignal<T...>`\n- `KirNet.Signal<T...>`\n- `KirNet.ServerFunction<TReturn>`\n- `KirNet.Variable<T>`\n- `KirNet.SignalOptions`\n- `KirNet.MiddlewareContext`\n- `KirNet.MiddlewareFn`\n\n## Options\n\nAll signal and function constructors accept the same options table:\n\n```luau\nKirNet.CreateSignal({\n\tdirection = \"client\",\n\tbatched = false,\n\tlossy = false,\n\tprecision = 2,\n\trateLimit = 15,\n\tcompressionThreshold = 64,\n})\n```\n\n| Option | What it does |\n| --- | --- |\n| `direction` | `\"server\"`, `\"client\"`, or omit for bidirectional. |\n| `batched` | Groups multiple server-to-client fires in the same frame into one packet. |\n| `lossy` | Uses reduced-precision numeric encoding to cut bandwidth. |\n| `precision` | Decimal precision used when `lossy` is enabled. |\n| `compressionThreshold` | Compresses payloads above this byte size when compression saves space. |\n| `rateLimit` | Limits incoming client-to-server traffic per player per second. |\n\n## Instance & Userdata Passthrough\n\nKirNet automatically handles unsupported types like `Instance` or userdata. If a value can't be buffer-encoded, it's sent alongside the buffer as a passthrough value and correctly reassembled on the other side. No configuration needed.\n\n```luau\n-- This just works — the Part is sent as a passthrough, the string is buffer-encoded\nMySignal:FireAll(\"hit\", workspace.Part, 42)\n```\n\n## Middleware\n\nMiddleware runs on every remote call in registration order. Inspect payloads, mutate them, or abort by not invoking `next()`.\n\n```luau\nKirNet.UseMiddleware(function(context, next)\n\tprint(context.direction, context.service, context.name)\n\tnext(context)\nend)\n```\n\n`context` contains: `name`, `service`, `player`, `payload`, `direction` (`\"c2s\"` or `\"s2c\"`).\n\n## VS Code Type Generator\n\nThe `kirnet-type-gen` extension makes KirNet fully typed in your editor.\n\nIt can:\n\n- Generate a typed KirNet wrapper for `GetService(\"ServiceName\")`\n- Autocomplete service names inside `GetService(\"...\")`\n- Regenerate types on save and on startup\n- Initialize a `kirnet.toml` config with `KirNet: Init`\n- Enable/disable per project with `KirNet: Enable` / `KirNet: Disable`\n- Jump to service definitions, list services, scaffold new services\n\n### Setup\n\n1. Open a workspace that contains `default.project.json`.\n2. Install the extension from `kirnet-type-gen/`.\n3. Run `KirNet: Init` from the Command Palette to create a `kirnet.toml`.\n4. Save a service file — types regenerate automatically.\n\n## Example Project\n\nThe `Example/` folder is a complete Rojo + Wally sample project.\n\n## Repository Layout\n\n- `src/` — runtime package source\n- `init.luau` — package re-export entrypoint\n- `default.project.json` — Rojo mapping for the package\n- `kirnet-type-gen/` — VS Code extension\n- `Example/` — example Roblox project\n\n## License\n\nKirNet is released under the MIT License. See `LICENSE`.","readmeTruncated":false}