Skip to content

feat!: InjectionContext to Injector is renamed, Injectable base class is added#132

Closed
dangreen wants to merge 1 commit into
mainfrom
di-renaming
Closed

feat!: InjectionContext to Injector is renamed, Injectable base class is added#132
dangreen wants to merge 1 commit into
mainfrom
di-renaming

Conversation

@dangreen
Copy link
Copy Markdown
Member

@dangreen dangreen commented Jun 1, 2026

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 47.61905% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.85%. Comparing base (9115a66) to head (5852522).

Files with missing lines Patch % Lines
packages/svelte-kit/src/dehydration.ts 40.90% 12 Missing and 1 partial ⚠️
packages/react/src/dehydration.tsx 44.44% 4 Missing and 1 partial ⚠️
packages/nanoviews/src/component/context.ts 66.66% 0 Missing and 1 partial ⚠️
packages/next-router/src/server.tsx 0.00% 1 Missing ⚠️
packages/router/src/head.ts 50.00% 0 Missing and 1 partial ⚠️
packages/svelte-ssr/src/client.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #132   +/-   ##
=======================================
  Coverage   83.85%   83.85%           
=======================================
  Files         135      135           
  Lines        2949     2949           
  Branches      550      550           
=======================================
  Hits         2473     2473           
  Misses        338      338           
  Partials      138      138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a breaking rename/refactor of Nano Kit’s DI surface area by renaming InjectionContextInjector, renaming “factories” to “invocable tokens” (function or class tokens), and introducing an Injectable base class to support class-based DI tokens across core packages and integrations.

Changes:

  • Rename DI primitives and APIs across packages (InjectionContextInjector, provider/component/hook/setter/getter names updated accordingly).
  • Add class-token support via InjectionToken + Injectable, updating inject/run/provide behavior and documentation.
  • Update SSR / dehydration / hydration flows and all framework integrations (React/Preact/Svelte/SvelteKit/Next) + examples and docs to the new DI naming.

Reviewed changes

Copilot reviewed 120 out of 120 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/src/content/docs/tutorial/prepare-for-ssr.mdx Updates SSR tutorial wording from factories/contexts to tokens/injectors.
website/src/content/docs/store/testing.mdx Updates testing docs to construct/use Injector.
website/src/content/docs/store/ssr.mdx Updates store SSR docs to refer to Injector and InjectorProvider.
website/src/content/docs/store/core-concepts.mdx Updates DI core concepts to tokens/injectors; adds Injectable class-token section.
website/src/content/docs/ssr/locale.mdx Updates locale SSR docs to use Injector.
website/src/content/docs/ssr/index.mdx Updates SSR adapter example to use data.injector.
website/src/content/docs/ssr/cookies.mdx Updates cookie SSR docs to use Injector.
website/src/content/docs/router/testing.mdx Updates router testing docs to use Injector/InjectorProvider.
website/src/content/docs/router/ssr.mdx Updates router SSR docs to refer to request Injector.
website/src/content/docs/router/advanced.mdx Updates advanced router docs for optional Injector parameter.
website/src/content/docs/query/ssr.mdx Updates query SSR docs to reference “current injector”.
website/src/content/docs/query/advanced.mdx Updates tasks() docs to reference “current injector”.
website/src/content/docs/platform/web.mdx Updates platform-web docs examples to use Injector.
website/src/content/docs/integrations/svelte.mdx Renames Svelte DI API to setInjector and updates terminology.
website/src/content/docs/integrations/svelte-ssr.mdx Updates Svelte SSR integration examples to use setInjector/injector.
website/src/content/docs/integrations/svelte-router.mdx Updates Svelte router integration docs to injector-based DI.
website/src/content/docs/integrations/svelte-kit.mdx Updates SvelteKit integration docs for dehydration/hydration injector naming.
website/src/content/docs/integrations/react.mdx Updates React integration docs to InjectorProvider/useInjector wording.
website/src/content/docs/integrations/react-ssr.mdx Updates React SSR integration example to injector-based provider.
website/src/content/docs/integrations/react-router.mdx Updates React router integration docs to injector-based DI.
website/src/content/docs/integrations/preact.mdx Updates Preact integration docs to InjectorProvider naming.
website/src/content/docs/integrations/preact-ssr.mdx Updates Preact SSR integration example to injector-based provider.
website/src/content/docs/integrations/preact-router.mdx Updates Preact router integration docs to injector-based DI.
website/src/content/docs/integrations/next-router.mdx Updates Next router docs to Injector usage in SSR helpers.
website/src/content/docs/examples/weather.mdx Updates example narrative to avoid “injection context” terminology.
packages/svelte/test/ProviderFixture.svelte Updates Svelte test fixture props/types to injector/token terminology.
packages/svelte/test/IsolateFixture.svelte Updates Svelte isolate fixture to use setInjector.
packages/svelte/src/core.ts Renames Svelte DI context APIs (getInjector/setInjector) and token typing.
packages/svelte/src/core.spec.ts Updates Svelte core tests to new token/injector naming.
packages/svelte-ssr/src/renderer/index.ts Updates Svelte SSR renderer to call setInjector(data.injector).
packages/svelte-ssr/src/client.js Updates Svelte SSR client entry to use setInjector/injector.
packages/svelte-ssr/README.md Updates Svelte SSR README snippets to setInjector/injector.
packages/svelte-router/test/PreloadableContextFixture.svelte Updates router fixture to accept injector providers and call setInjector.
packages/svelte-router/test/AriaCurrentContextFixture.svelte Updates aria-current fixture to accept injector providers and call setInjector.
packages/svelte-router/src/preloadable.ts Updates comments to “injector context”.
packages/svelte-router/src/preloadable.spec.ts Updates test fixture props from context to injector.
packages/svelte-router/src/link.ts Updates comments to “injector context”.
packages/svelte-router/src/hooks.ts Updates hook docs/comments to “injector context”.
packages/svelte-router/src/core.ts Switches router core to use getInjector() and pass injector into head sync.
packages/svelte-router/src/aria-current.ts Updates comments to “injector context”.
packages/svelte-router/src/aria-current.spec.ts Updates aria-current tests to pass injector providers.
packages/svelte-kit/test/RehydrationFixture.svelte Updates fixture to call setHydrationInjector.
packages/svelte-kit/test/HydrationFixture.svelte Updates fixture to call setHydrationInjector.
packages/svelte-kit/test/EmptyHydrationFixture.svelte Updates fixture to call setHydrationInjector.
packages/svelte-kit/src/index.ts Updates re-export to setHydrationInjector naming.
packages/svelte-kit/src/hydration.ts Renames hydration API to injector terminology and uses getInjector/setInjector.
packages/svelte-kit/src/hydration.spec.ts Updates test wording for hydration injector.
packages/svelte-kit/src/dehydration.ts Renames request-scoped dehydration context to injector and updates APIs accordingly.
packages/svelte-kit/src/dehydration.spec.ts Updates dehydration tests to new injector APIs.
packages/svelte-kit/README.md Updates SvelteKit README examples to injector terminology.
packages/store/src/tasks.ts Updates DI comments from “factory” to “token”.
packages/store/src/hydration.ts Updates store hydration/dehydration to accept Injector instead of InjectionContext.
packages/store/src/hydration.spec.ts Updates store hydration tests to construct/use Injector.
packages/ssr/test/app/virtual-renderer.js Updates SSR test renderer to use data.injector.
packages/ssr/test/app/renderer.js Updates SSR test renderer to use data.injector.
packages/ssr/src/renderer/renderer.types.ts Renames render payload field to injector: Injector.
packages/ssr/src/renderer/renderer.ts Updates SSR renderer implementation to create/use Injector throughout.
packages/ssr/src/client/index.ts Updates client ready() to return an Injector.
packages/ssr/README.md Updates SSR README snippets to use injector.
packages/router/src/router.types.ts Removes InjectionFactory type usage in router public types in favor of plain functions.
packages/router/src/head.ts Updates head sync API to accept an optional Injector for DI resolution.
packages/react/src/hydration.tsx Renames React hydration provider implementation to injector-based API.
packages/react/src/hydration.spec.tsx Updates hydration tests to wrap with InjectorProvider.
packages/react/src/dehydration.tsx Updates RSC dehydration helpers to use request-scoped Injector.
packages/react/src/dehydration.spec.tsx Updates dehydration tests to wrap with InjectorProvider.
packages/react/src/core.tsx Renames React DI core to InjectorProvider/useInjector and token typing.
packages/react/src/core.spec.tsx Updates React DI core tests to injector/token naming.
packages/react-ssr/src/renderer/index.tsx Updates React SSR renderer to wrap app with InjectorProvider.
packages/react-ssr/src/client.jsx Updates React SSR client entry to use InjectorProvider and injector.
packages/react-ssr/README.md Updates React SSR README examples to injector terminology.
packages/react-router/src/preloadable.ts Updates comment terminology to “injector context”.
packages/react-router/src/preloadable.spec.tsx Updates tests to use InjectorProvider.
packages/react-router/src/link.tsx Updates comment terminology to “injector context”.
packages/react-router/src/hooks.ts Updates hook comments to “injector context”.
packages/react-router/src/core.tsx Updates head sync to use useInjector() and pass injector through.
packages/react-router/src/aria-current.ts Updates comment terminology to “injector context”.
packages/react-router/src/aria-current.spec.tsx Updates tests to use InjectorProvider.
packages/query/src/settings/ssr.ts Updates SSR setting docs/comments to “injector context”.
packages/query/src/settings/hydratable.ts Updates docs/comments to resolve dependencies from injector.
packages/query/src/settings/hydratable.spec.ts Updates tests to use Injector.
packages/query/src/ClientContext.ts Updates docs/comment about tasks runner injection source.
packages/preact/src/hydration.tsx Renames Preact hydration provider implementation to injector-based API.
packages/preact/src/hydration.spec.tsx Updates hydration tests to wrap with InjectorProvider.
packages/preact/src/core.tsx Renames Preact DI core to InjectorProvider/useInjector and token typing.
packages/preact/src/core.spec.tsx Updates Preact DI core tests to injector/token naming.
packages/preact-ssr/src/renderer/index.tsx Updates Preact SSR renderer to wrap app with InjectorProvider.
packages/preact-ssr/src/client.jsx Updates Preact SSR client entry to use InjectorProvider and injector.
packages/preact-ssr/README.md Updates Preact SSR README examples to injector terminology.
packages/preact-router/src/preloadable.ts Updates comment terminology to “injector context”.
packages/preact-router/src/preloadable.spec.tsx Updates tests to use InjectorProvider.
packages/preact-router/src/link.tsx Updates comment terminology to “injector context”.
packages/preact-router/src/hooks.ts Updates hook comments to “injector context”.
packages/preact-router/src/core.tsx Updates head sync to use useInjector() and pass injector through.
packages/preact-router/src/aria-current.ts Updates comment terminology to “injector context”.
packages/preact-router/src/aria-current.spec.tsx Updates tests to use InjectorProvider.
packages/platform-web/src/cookieStore/di.ts Updates DI token docs to reference injector.
packages/next-router/src/utils.ts Updates redirect helper to accept Injector.
packages/next-router/src/server.tsx Updates Next server integration to call setDehydrationInjector.
packages/next-router/src/provider.tsx Updates Next navigation provider to use InjectorProvider.
packages/next-router/src/link.tsx Updates link docs/comment to “injector context”.
packages/next-router/src/hooks.ts Updates hook to read from useInjector().
packages/nanoviews/src/internals/effects.ts Switches nanoviews DI binding helper to use getInjector.
packages/nanoviews/src/component/context.ts Renames nanoviews context runner to use Injector + getInjector.
packages/kida/src/di.ts Introduces Injector, InjectionToken, and Injectable with class-token instantiation support.
packages/kida/src/di.spec.ts Updates DI tests and adds coverage for class-based injectables.
packages/kida/README.md Updates DI docs to tokens/injector terminology and shows Injectable usage.
packages/kida/eslint.config.js Disables @typescript-eslint/no-extraneous-class (supports Injectable pattern).
examples/weather/svelte-nano_kit-di/src/App.svelte Updates example to call setInjector().
examples/weather/react-nano_kit-di/src/main.tsx Updates example to wrap with InjectorProvider.
examples/session/svelte-kit-nano_kit-ssr/src/routes/+page.svelte Updates example to call setHydrationInjector.
examples/session/svelte-kit-nano_kit-ssr/src/routes/+layout.svelte Updates example root layout hydration to injector terminology.
examples/session/svelte-kit-nano_kit-ssr/src/routes/+layout.server.ts Updates example server layout to set dehydration injector and return injectorRef.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/locations/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/location/[id]/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/episodes/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/episode/[id]/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/characters/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/character/[id]/+page.svelte Updates example page hydration to setHydrationInjector.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/+layout.svelte Updates example root layout hydration to injector terminology.
examples/rick-and-morty/svelte-kit-nano_kit-ssr/src/routes/+layout.server.ts Updates example server layout to set dehydration injector and return injectorRef.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 56 to 61
if (!existingHydrator || !reuse) {
setInjectionContext([
...context,
setInjector([
...injector,
provide(Hydrator$, hydrator)
])
}
Comment on lines 54 to 56
if (existingHydrator && reuse) {
return children
}
Comment on lines 53 to 55
if (existingHydrator && reuse) {
return children
}
@dangreen dangreen closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants