Add Svelte 5 support via /svelte subpath export#13
Open
MathiasWP wants to merge 1 commit into
Open
Conversation
Exposes createVirtualizer (rune-based hook) and <Warper> .svelte component to Svelte 5 consumers without pulling React into their import graph. - Subpath export @itsmeadarsh/warper/svelte (single package) - React and Svelte are both optional peer deps via peerDependenciesMeta - Shared core: TypedArray buffer pools extracted to core/buffers.ts so both adapters reuse the zero-allocation hot path - types/ split into core (framework-agnostic) and react (React-only) - Idiomatic Svelte 5: $state.raw for the range object, @Attach attachments instead of use: actions, on() from svelte/events for the scroll listener, style: directives for dynamic style values, typed Snippet<[number]> children Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds Svelte 5 as a first-class adapter alongside the existing React one, via the subpath export
@itsmeadarsh/warper/svelte. The Svelte build does not pull React into its import graph — bothreactandsvelteare now optional peer deps.createVirtualizer(rune-based hook) +<Warper>.sveltecomponent, mirroring the React hook + component surface.react/hooks/useVirtualizer.tsintocore/buffers.tsso both adapters reuse the same hot-path scratch space.types/core.tsis framework-agnostic;types/react.tsholds the React-only types.types/index.tsre-exports both, so existing React imports are unchanged.build:sveltescript runs@sveltejs/packagewith a dedicatedtsconfig.svelte.json, emittingdist/svelte/with.svelte.d.tstypes..svelte-kit/(scratch dir fromsvelte-package) is gitignored.Idiomatic Svelte 5 choices (verified against svelte.dev docs)
$state.rawfor therangeobject — TypedArray-backed views are reassigned wholesale, so deep proxy reactivity would be pure overhead.@attachattachments (Svelte 5.29+) instead ofuse:actions for the scroll container.on()fromsvelte/eventsfor the scroll listener.style:directives for dynamic style values (height / transform); static styles stay in a singlestyleattribute.Snippet<[number]>children;{@render children(itemIndex)}.$effectfor lifecycle (consumers needing non-component usage can wrap in$effect.root).Test plan
bun installsucceeds; no React-related warnings in a Svelte-only consumer environment.bun run buildproducesdist/svelte/index.js,components/Warper.svelte,hooks/createVirtualizer.svelte.jsplus matching.d.tsfiles.@itsmeadarsh/warper) still builds and the existing examples (bun run example:listetc.) still run.{ Warper, createVirtualizer }from@itsmeadarsh/warper/svelte, render 1M rows, verify scroll,range.itemsupdates,scrollToIndexworks.🤖 Generated with Claude Code