Releases: molszanski/iti
0.8.0 - Better API Naming, Better Types & SSR Support 🎉
🚀 TL;DR
- no breaking changes
- rename API so it makes more sense
- add sync mode for react that would enable better SSR / Server Components flow
- fix some bugs
- improve types
- add more tests
- add type tests
- improve type performance
🚀 Major Changes
API Renaming (Better semantics)
The API has been renamed from "containers" to "items" to better reflect what we're actually managing. All old methods still work and are marked as deprecated.
Core Library:
getContainerSet()→getItems()subscribeToContainerSet()→subscribeToItems()subscribeToContainer()→subscribeToItem()
React Hooks:
getContainerSetHooks()→getContainerHooks()useContainer()→useItem()useContainerSet()→useItems()
✨ New Features
1. Synchronous API for SSR
// New sync methods for better SSR support
const item = container.getSync("myService")
const items = container.getItemsSync(["serviceA", "serviceB"])2. Enhanced React SSR Support
The useItems hook now intelligently handles SSR by returning cached values synchronously when available, preventing hydration mismatches.
🔧 Improvements
- ✅ Migrated from Jest to Vitest (faster tests, better ESM support)
- ✅ Better TypeScript type performance
- ✅ More tests
- ✅ Add tests for TS types with @arktype/attest
- ✅ Improved ESM/CJS dual package interop
- ✅ Added Astro playground example
- ✅ More comprehensive type tests
📖 Quick Migration
// Core library
- await container.getContainerSet(['a', 'b'])
+ await container.getItems(['a', 'b'])
// React
- const { useContainer, useContainerSet } = getContainerSetHooks(Context)
+ const { useItem, useItems } = getContainerHooks(Context)⚠️ Breaking Changes
None! All old APIs are deprecated but still fully functional. Migrate at your own pace.
📦 What's Changed
- Rename API so it makes more sense
- Add sync mode for React (better SSR / Server Components)
- Fix bugs and improve types
- Add more tests and type tests
- Improve type performance
Full Changelog: v0.7.0...v0.8.0
0.7.0 - ESM / CJS
What's Changed
- Improved ESM and CJS / Node.js support
- Migrated to vitest for a better ESM support
0.5.0
What's Changed
- add container disposal support by @molszanski in #26
- add destructuring support by @molszanski in #24
- init website by @molszanski in #29
- project cleanup by @molszanski in #28
- Cleanup by @molszanski in #30
- Healthy repo by @molszanski in #32
Container Disposal
basic usage
import { createContainer } from "iti"
container = createContainer()
.add({ a: () => "123" })
.addDisposer({ a: () => {} })
container.get("a") === "123" // true
await container.disposeAll() // Promise<void>async case
const container = createContainer()
.add(() => ({
dbConnection: async () => {
/** connect to db and return an instance */
},
}))
.addDisposer({
// ↓ `db` is a resolved value of a `dbConnection` token. Pretty handy
dbConnection: (db) => db.close(),
})
const db = await container.get("dbConnection")
await container.disposeAll()Much Better Ts performance
Some huge projects consumed too much RAM and had some perf limits:
i18next/react-i18next#1417
TS2589: Type instantiation is excessively deep and possibly infinite
This was one of know issues:
https://itijs.org/docs/patterns-and-tips#known-issues
I believe that the issue is solved with this release
Full Changelog: 0.4.2...0.5.0
0.4.2
What's Changed
- adds a yarn workspace setup and extracts react to a separate package by @molszanski in #12
- Develop by @molszanski in #13
- update project name by @molszanski in #14
- Develop by @molszanski in #15
- Bump version by @molszanski in #16
- Develop by @molszanski in #17
- Beta by @molszanski in #18
- Update deps by @molszanski in #19
Full Changelog: 0.2.0...0.4.2
0.2.0
0.2.0 adds containerRequested, containerCreated and containerRemoved events
const kitchenApp = new RootContainer((ctx) => ({
// you can use tokens (`oven`, `kitchen`) here and later on
oven: async () => ovenContainer(),
kitchen: async () => kitchenContainer(await ctx.oven()),
}))
kitchenApp.on("containerCreated", (event) => {
console.log(`event: 'containerCreated' ~~> token: '${event.key}'`)
// `event.container` is also avaliable here
})
kitchenApp.on("containerRequested", (event) => {
console.log(`event: 'containerRequested' ~~> token: '${event.key}' `)
})
kitchenApp.on("containerRemoved", (event) => {
console.log(`event: 'containerRemoved' ~~> token: '${event.key}' `)
})
await kitchenApp.containers.kitchen
// event: 'containerRequested' ~~> token: 'kitchen'
// event: 'containerRequested' ~~> token: 'oven'
// event: 'containerCreated' ~~> token: 'oven'
// event: 'containerCreated' ~~> token: 'kitchen'
// Notice how oven was created before kitchen.
// This is because kitcen depends on ovenWhat's Changed
- adds container set and container set react hooks by @molszanski in #2
- Add jest and type tests by @molszanski in #3
- Reduces size, refactors core and removes dead code and improves API with overloads by @molszanski in #5
- removes
containerSetNewhook by @molszanski in #6 - updates docs by @molszanski in #7
- updates docs by @molszanski in #9
- adds new events by @molszanski in #8
Full Changelog: https://github.com/molszanski/snow-splash/commits/0.2.0