feat(kida,preact,query,react,router,store,svelte,svelte-kit): support of injectable classes was added#133
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
=======================================
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. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands Nano Kit’s dependency injection model to support class-based injectables (in addition to function tokens), and updates framework integrations, types, tests, and documentation to use the new Injectable token concept.
Changes:
- Introduces class-based injectable support in
kidaviaInjectable+Injectable$. - Replaces
InjectionFactoryusages withInjectableacross React/Preact/Svelte integrations and related fixtures. - Updates SSR dehydration-related APIs/types and documentation to reflect “injectable tokens” terminology.
Reviewed changes
Copilot reviewed 19 out of 19 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” to “injectable tokens”. |
| website/src/content/docs/store/core-concepts.mdx | Updates DI docs and adds “Class Tokens” section; example code updated. |
| website/src/content/docs/examples/weather.mdx | Minor wording update around DI description. |
| packages/svelte/test/ProviderFixture.svelte | Updates test fixture types from InjectionFactory to Injectable. |
| packages/svelte/test/IsolateFixture.svelte | Updates test fixture types from InjectionFactory to Injectable. |
| packages/svelte/src/core.ts | Updates getInject signature/docs to accept Injectable. |
| packages/svelte-kit/src/dehydration.ts | Updates dehydration API to accept a plain store-list factory. |
| packages/store/src/tasks.ts | Updates DI-related docstrings to “injectable factory”. |
| packages/router/src/router.types.ts | Replaces InjectionFactory-based aliases with plain factory types and updates comments. |
| packages/react/src/dehydration.tsx | Updates dehydration API types and related comments. |
| packages/react/src/core.tsx | Updates useInject / injectHook to accept Injectable. |
| packages/query/src/settings/hydratable.ts | Doc comment tweak (“inject” → “resolve”). |
| packages/query/src/ClientContext.ts | Doc comment wording update around DI context. |
| packages/preact/src/core.tsx | Updates useInject / injectHook to accept Injectable. |
| packages/kida/src/di.ts | Implements Injectable token type, class instantiation support, and Injectable$ base class. |
| packages/kida/src/di.spec.ts | Adds tests verifying class-based injection behavior. |
| packages/kida/README.md | Updates DI documentation and adds a class-based injectable example. |
| packages/kida/eslint.config.js | Disables no-extraneous-class (review suggests scoping instead of global disable). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… of injectable classes was added
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+61
to
66
| export function useInject<T>(injectable: Injectable<T>): T { | ||
| const currentContext = useInjectionContext() | ||
| const dependency = useMemo( | ||
| () => inject(factory, currentContext), | ||
| [currentContext, factory] | ||
| () => inject(injectable, currentContext), | ||
| [currentContext, injectable] | ||
| ) |
Comment on lines
+62
to
67
| export function useInject<T>(injectable: Injectable<T>): T { | ||
| const currentContext = useInjectionContext() | ||
| const dependency = useMemo( | ||
| () => inject(factory, currentContext), | ||
| [currentContext, factory] | ||
| () => inject(injectable, currentContext), | ||
| [currentContext, injectable] | ||
| ) |
Comment on lines
+95
to
97
| export function getInject<T>(injectable: Injectable<T>): T { | ||
| return inject(injectable, getInjectionContext()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.