Skip to content

Releases: molszanski/iti

0.8.0 - Better API Naming, Better Types & SSR Support 🎉

09 Oct 08:04
584822a

Choose a tag to compare

🚀 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

18 Nov 09:25
97bbc1e

Choose a tag to compare

What's Changed

0.5.0

08 Oct 01:08

Choose a tag to compare

What's Changed

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

24 Jul 15:28

Choose a tag to compare

What's Changed

Full Changelog: 0.2.0...0.4.2

0.2.0

01 Feb 22:29

Choose a tag to compare

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 oven

What's Changed

Full Changelog: https://github.com/molszanski/snow-splash/commits/0.2.0