{"_id":"@adaptive-bundle/svelte","_rev":"3-50fc7571d84d442d122810290f073c34","name":"@adaptive-bundle/svelte","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@adaptive-bundle/svelte","version":"0.1.0","_id":"@adaptive-bundle/svelte@0.1.0","maintainers":[{"name":"pizanjavier","email":"javierpicatoste@gmail.com"}],"dist":{"shasum":"d57072319baf506f197d53d681c500c2f405c13e","tarball":"https://registry.npmjs.org/@adaptive-bundle/svelte/-/svelte-0.1.0.tgz","fileCount":5,"integrity":"sha512-How4xCjl0EpwVNqtauamanqQttMqdaud06StsEo1QXpbnc/Zc1HyKBO45hZ6tk7ytQ4yeMK0sPnUqlKpOM7pbQ==","signatures":[{"sig":"MEUCIQDs+n0TS3saFvdurOEfFXx7cXnlBL3wO0k7W84oRJuUEQIgCNzXXidmpKQ9JwaoZsZhdd+j5MO9fUoH92Qjl0aPHRU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8751},"main":"./dist/index.cjs","type":"module","_from":"file:adaptive-bundle-svelte-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"lint":"eslint src/","test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"pizanjavier","email":"javierpicatoste@gmail.com"},"_resolved":"/tmp/3dce5d156391dcc3a7dd43a36474ec72/adaptive-bundle-svelte-0.1.0.tgz","_integrity":"sha512-How4xCjl0EpwVNqtauamanqQttMqdaud06StsEo1QXpbnc/Zc1HyKBO45hZ6tk7ytQ4yeMK0sPnUqlKpOM7pbQ==","_npmVersion":"10.8.2","description":"Svelte adapter for Adaptive — adaptive() API and stores","directories":{},"sideEffects":false,"_nodeVersion":"20.20.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"svelte":"^4.2.0","@adaptive-bundle/core":"0.1.0"},"peerDependencies":{"svelte":">=4.0.0","@adaptive-bundle/core":"0.1.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte_0.1.0_1773826278753_0.1902666962814905","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@adaptive-bundle/svelte","version":"0.2.0","keywords":["adaptive-loading","device-aware","bundle-optimization","performance","adaptive-bundle","svelte","sveltekit","lazy-loading","conditional-rendering","code-splitting","stores","readable-store"],"license":"MIT","_id":"@adaptive-bundle/svelte@0.2.0","maintainers":[{"name":"pizanjavier","email":"javierpicatoste@gmail.com"}],"homepage":"https://github.com/Pizanjavier/adaptive/tree/main/packages/svelte","bugs":{"url":"https://github.com/Pizanjavier/adaptive/issues"},"dist":{"shasum":"a982139a1e18a382c9a6e72e44aba4b2efa78a34","tarball":"https://registry.npmjs.org/@adaptive-bundle/svelte/-/svelte-0.2.0.tgz","fileCount":7,"integrity":"sha512-p9jCUXQkAwr+gAT5MqJHloqBWsabyCqCo6zfSNr1R+f0gcPsbagCN8uPBSi/56YR/Ps92M4orVLfR0aw/uoStA==","signatures":[{"sig":"MEUCIQDXgqPfV5xJZxxujiU19vamPhtuWLaRpEvpWLShEAzKGgIgBWLO7p8imFPWuN8jvpn0l3n3DMQqfSOQxbnzA6h2FvY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13535},"main":"./dist/index.cjs","type":"module","_from":"file:adaptive-bundle-svelte-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"scripts":{"lint":"eslint src/","test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"pizanjavier","email":"javierpicatoste@gmail.com"},"_resolved":"/tmp/15926d7d9c7b60a1077b4fcb0e839671/adaptive-bundle-svelte-0.2.0.tgz","_integrity":"sha512-p9jCUXQkAwr+gAT5MqJHloqBWsabyCqCo6zfSNr1R+f0gcPsbagCN8uPBSi/56YR/Ps92M4orVLfR0aw/uoStA==","repository":{"url":"git+https://github.com/Pizanjavier/adaptive.git","type":"git","directory":"packages/svelte"},"_npmVersion":"10.8.2","description":"Svelte adapter for adaptive loading — ship different components to high and low-end devices with adaptive() stores and context.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"svelte":"^4.2.0","@adaptive-bundle/core":"0.2.0"},"peerDependencies":{"svelte":">=4.0.0","@adaptive-bundle/core":"0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte_0.2.0_1773904495791_0.6305464571079875","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@adaptive-bundle/svelte","publishConfig":{"access":"public"},"version":"0.3.0","description":"Svelte adapter for adaptive loading — ship different components to high and low-end devices with adaptive() stores and context.","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"peerDependencies":{"svelte":">=4.0.0","@adaptive-bundle/core":"0.2.0"},"devDependencies":{"svelte":"^4.2.0","@adaptive-bundle/core":"0.2.0"},"sideEffects":false,"keywords":["adaptive-loading","device-aware","bundle-optimization","performance","adaptive-bundle","svelte","sveltekit","lazy-loading","conditional-rendering","code-splitting","stores","readable-store"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Pizanjavier/adaptive.git","directory":"packages/svelte"},"homepage":"https://github.com/Pizanjavier/adaptive/tree/main/packages/svelte","bugs":{"url":"https://github.com/Pizanjavier/adaptive/issues"},"scripts":{"build":"tsup","test":"vitest run","lint":"eslint src/","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@adaptive-bundle/svelte@0.3.0","_integrity":"sha512-3PImPoOh4tDNxInQ2Qggl5ka+gB+wJKJzYaRZCAIJL3/wbHVZ2GnDo2SFNey//CKlPoYw4nR/0Gc/HlV3ZkUwQ==","_resolved":"/tmp/3717d1d13ab1e040de33b3d2aea058b4/adaptive-bundle-svelte-0.3.0.tgz","_from":"file:adaptive-bundle-svelte-0.3.0.tgz","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-3PImPoOh4tDNxInQ2Qggl5ka+gB+wJKJzYaRZCAIJL3/wbHVZ2GnDo2SFNey//CKlPoYw4nR/0Gc/HlV3ZkUwQ==","shasum":"b2e73297f665d592b5033d049f8996e4219e82ab","tarball":"https://registry.npmjs.org/@adaptive-bundle/svelte/-/svelte-0.3.0.tgz","fileCount":7,"unpackedSize":16046,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHTvu1YmxcLf8peo9LisSCr+wBqJ0DZok4OpgJNoAjWIAiEA4CL/Se3amjEKV202xx9sgiVaLfNGn0jqS93tQnpTiWA="}]},"_npmUser":{"name":"pizanjavier","email":"javierpicatoste@gmail.com"},"directories":{},"maintainers":[{"name":"pizanjavier","email":"javierpicatoste@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svelte_0.3.0_1773927514289_0.14941735857847993"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-18T09:31:18.550Z","modified":"2026-03-19T13:38:34.541Z","0.1.0":"2026-03-18T09:31:18.900Z","0.2.0":"2026-03-19T07:14:55.938Z","0.3.0":"2026-03-19T13:38:34.437Z"},"bugs":{"url":"https://github.com/Pizanjavier/adaptive/issues"},"license":"MIT","homepage":"https://github.com/Pizanjavier/adaptive/tree/main/packages/svelte","keywords":["adaptive-loading","device-aware","bundle-optimization","performance","adaptive-bundle","svelte","sveltekit","lazy-loading","conditional-rendering","code-splitting","stores","readable-store"],"repository":{"type":"git","url":"git+https://github.com/Pizanjavier/adaptive.git","directory":"packages/svelte"},"description":"Svelte adapter for adaptive loading — ship different components to high and low-end devices with adaptive() stores and context.","maintainers":[{"name":"pizanjavier","email":"javierpicatoste@gmail.com"}],"readme":"# @adaptive-bundle/svelte\n\nSvelte adapter for adaptive loading. Ship different components to high-end and low-end devices with `adaptive()` stores and Svelte context.\n\n[![npm](https://img.shields.io/npm/v/@adaptive-bundle/svelte)](https://www.npmjs.com/package/@adaptive-bundle/svelte)\n\n## Install\n\n```bash\npnpm add @adaptive-bundle/svelte @adaptive-bundle/core\npnpm add -D @adaptive-bundle/vite-plugin\n```\n\n## Adaptive Boundaries\n\n### Two-Variant Pattern\n\n```svelte\n<script>\nimport { adaptive } from '@adaptive-bundle/svelte';\n\nconst MapView = adaptive({\n  high: () => import('./MapboxMap.svelte'),\n  low: () => import('./StaticMap.svelte'),\n});\n</script>\n\n{#if $MapView}\n  <svelte:component this={$MapView} center={[40, -3]} zoom={12} />\n{/if}\n```\n\n`adaptive()` returns a Svelte `Readable` store that lazily loads the correct variant on first subscription.\n\n### Exclusion Pattern\n\n```ts\nconst MapView = adaptive({\n  component: () => import('./MapboxMap.svelte'),\n});\n// Returns null on low-tier devices\n```\n\n### Three-Tier Mode\n\n```ts\nconst Chart = adaptive({\n  high: () => import('./AnimatedChart.svelte'),\n  medium: () => import('./StaticChart.svelte'),\n  low: () => import('./ChartTable.svelte'),\n  thresholds: { high: 0.65, low: 0.35 },\n});\n```\n\n## Loading Strategies\n\n| Strategy             | Behavior                                                             |\n| -------------------- | -------------------------------------------------------------------- |\n| `viewport` (default) | Load on first render                                                 |\n| `eager`              | Preload at definition time                                           |\n| `lazy`               | Returns a `LazyReadable` — import deferred until `.load()` is called |\n\n```svelte\n<script>\nimport { adaptive, viewportAction } from '@adaptive-bundle/svelte';\n\n// Eager: preload immediately\nconst Metrics = adaptive({\n  high: () => import('./AnimatedMetrics.svelte'),\n  low: () => import('./StaticMetrics.svelte'),\n  loading: 'eager',\n});\n\n// Lazy: defer until scrolled into view\nconst Scene = adaptive({\n  high: () => import('./ThreeScene.svelte'),\n  low: () => import('./StaticScene.svelte'),\n  loading: 'lazy',\n});\n</script>\n\n<!-- Use viewportAction to trigger lazy loading -->\n<div use:viewportAction={() => Scene.load()}>\n  {#if $Scene}\n    <svelte:component this={$Scene} />\n  {/if}\n</div>\n```\n\nThe `viewportAction` Svelte action uses `IntersectionObserver` with a 200px root margin. SSR safe: calls `loadFn` immediately when `IntersectionObserver` is unavailable.\n\n## Stores\n\n```ts\nimport { tierStore, deviceProfileStore, networkAwareStore } from '@adaptive-bundle/svelte';\n\n$tierStore; // 'high' | 'low' | 'medium'\n$deviceProfileStore; // full DeviceProfile\n$networkAwareStore; // { shouldDefer, effectiveType }\n```\n\n## Context\n\nShare the device profile across a component tree:\n\n```ts\nimport { setAdaptiveContext, getAdaptiveContext } from '@adaptive-bundle/svelte';\n\n// In a parent component\nsetAdaptiveContext();\n\n// In any child component\nconst profile = getAdaptiveContext();\n```\n\n## Part of Adaptive Bundle\n\nThis is the Svelte adapter for the [Adaptive Bundle](https://github.com/Pizanjavier/adaptive) monorepo. Requires [`@adaptive-bundle/core`](https://www.npmjs.com/package/@adaptive-bundle/core) as a peer dependency and Svelte 4+. For build-time chunk splitting, add [`@adaptive-bundle/vite-plugin`](https://www.npmjs.com/package/@adaptive-bundle/vite-plugin).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}