{"_id":"@atom-forge/svelte-helpers","_rev":"3-5e8a7a16e5fef7cc97ab847e95ea9a71","name":"@atom-forge/svelte-helpers","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@atom-forge/svelte-helpers","version":"0.0.1","keywords":["svelte","helpers","utilities"],"author":{"name":"Gergely Laborci"},"license":"SEE LICENSE IN LICENSE","_id":"@atom-forge/svelte-helpers@0.0.1","maintainers":[{"name":"laborci","email":"gergely@laborci.hu"}],"dist":{"shasum":"ad27ffdb77aedb57b6c935a8b4e94bf183ac83f3","tarball":"https://registry.npmjs.org/@atom-forge/svelte-helpers/-/svelte-helpers-0.0.1.tgz","fileCount":14,"integrity":"sha512-5Gir6Ciz9xSgoJerWoJJZguK+kLou8GbctMxrvw1ePBBZLxWR9tLmdzsrnpXEL9dqxhTUlpBy9KZvLi7RoUYQA==","signatures":[{"sig":"MEYCIQCPgaHXtRQTmsUIDSAUy377Y9HIFh2zPfjRE6j1BOaIugIhALzSabrlU7J1omolrsPC4qEbwfrTQY1OW51XNpGmxKzZ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9700},"type":"module","types":"./dist/index.d.ts","svelte":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js","default":"./dist/index.js"}},"scripts":{"dev":"vite dev","build":"vite build && bun run prepack","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","package":"svelte-package","prepack":"svelte-kit sync && svelte-package && publint","prepare":"svelte-kit sync || echo ''","preview":"vite preview","release":"bun publish","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"},"_npmUser":{"name":"laborci","email":"gergely@laborci.hu"},"_npmVersion":"11.4.2","description":"Svelte helper utilities, types and components","directories":{},"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.1","svelte":"^5.51.0","publint":"^0.3.15","typescript":"^5.9.3","svelte-check":"^4.4.2","@sveltejs/kit":"^2.50.2","@sveltejs/package":"^2.5.7","@sveltejs/adapter-auto":"^7.0.0","@sveltejs/vite-plugin-svelte":"^6.2.4"},"peerDependencies":{"svelte":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte-helpers_0.0.1_1775476611889_0.54683981862257","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@atom-forge/svelte-helpers","version":"0.0.2","keywords":["svelte","helpers","utilities"],"author":{"url":"https://github.com/laborci","name":"Gergely Laborci"},"license":"MIT","_id":"@atom-forge/svelte-helpers@0.0.2","maintainers":[{"name":"laborci","email":"gergely@laborci.hu"}],"homepage":"https://github.com/atom-forge/svelte-helpers#readme","bugs":{"url":"https://github.com/atom-forge/svelte-helpers/issues"},"dist":{"shasum":"806c19c88d6b42b8e661806f478ea6e89256878e","tarball":"https://registry.npmjs.org/@atom-forge/svelte-helpers/-/svelte-helpers-0.0.2.tgz","fileCount":14,"integrity":"sha512-vxMHDQOmkQ7pJIDle9BBD/kUbJksdH+uoA2yuFtk6gKdxNgPsThJSZCKlWNZuXGPQfrWkWX6DwbP41Qy7lD5Fw==","signatures":[{"sig":"MEYCIQCWh+leMQcB4ILOeVDDn1qdrB/4USdgOm0ypkpMEfb0eQIhAONgautV86+gduD0CF0Ru5fU20ZoCe9zJHCCem+VU4Zg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@atom-forge%2fsvelte-helpers@0.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":9839},"type":"module","types":"./dist/index.d.ts","svelte":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js","default":"./dist/index.js"}},"gitHead":"8b72cab02827c3f7816208848567b10f89a48f25","scripts":{"dev":"vite dev","build":"vite build && bun run prepack","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","package":"svelte-package","prepack":"(svelte-kit sync || true) && svelte-package && publint","prepare":"svelte-kit sync || echo ''","preview":"vite preview","release":"bun publish","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:778b1c17-645d-4368-9dc6-ae0b41907c17"}},"repository":{"url":"git+https://github.com/atom-forge/svelte-helpers.git","type":"git"},"_npmVersion":"11.13.0","description":"Svelte helper utilities, types and components","directories":{},"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.1","svelte":"^5.51.0","publint":"^0.3.15","typescript":"^5.9.3","svelte-check":"^4.4.2","@sveltejs/kit":"^2.50.2","@sveltejs/package":"^2.5.7","@sveltejs/adapter-auto":"^7.0.0","@sveltejs/vite-plugin-svelte":"^6.2.4"},"peerDependencies":{"svelte":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte-helpers_0.0.2_1780309452639_0.5225531561111094","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@atom-forge/svelte-helpers","version":"0.0.3","author":{"name":"Gergely Laborci","url":"https://github.com/laborci"},"repository":{"type":"git","url":"git+https://github.com/atom-forge/svelte-helpers.git"},"description":"Svelte helper utilities, types and components","license":"MIT","scripts":{"dev":"vite dev","build":"vite build && bun run prepack","preview":"vite preview","prepare":"svelte-kit sync || echo ''","prepack":"(svelte-kit sync || true) && svelte-package && publint","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","package":"svelte-package","prepublishOnly":"bun run prepack","release":"npm publish --access public","pub-check":"bun run scripts/pub-check.ts","pub":"bun run scripts/pub.ts"},"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js","default":"./dist/index.js"}},"peerDependencies":{"svelte":"^5.0.0"},"devDependencies":{"@sveltejs/adapter-auto":"^7.0.0","@sveltejs/kit":"^2.50.2","@sveltejs/package":"^2.5.7","@sveltejs/vite-plugin-svelte":"^6.2.4","publint":"^0.3.15","svelte":"^5.51.0","svelte-check":"^4.4.2","typescript":"^5.9.3","vite":"^7.3.1"},"keywords":["svelte","helpers","utilities"],"gitHead":"bca004784db11ff9b3853e20baaac14422068ec9","_id":"@atom-forge/svelte-helpers@0.0.3","bugs":{"url":"https://github.com/atom-forge/svelte-helpers/issues"},"homepage":"https://github.com/atom-forge/svelte-helpers#readme","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-b4H8c6apg/ctqudfMR6TYEzmflKsPHSgzg8avvBNuCsGC+Y2lGz2VnRvcPlru11tITZBx2TMn8M3jl3fm+Nrug==","shasum":"f1770c28b22edb1d1668906c7d1e004f40e15af3","tarball":"https://registry.npmjs.org/@atom-forge/svelte-helpers/-/svelte-helpers-0.0.3.tgz","fileCount":15,"unpackedSize":10325,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@atom-forge%2fsvelte-helpers@0.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICJPqQeQNW+5DPObRNFCRhCj1CF+0j7MKDd1tdSskvhTAiB+HGWFJQh1ZFalNN/kPnuHk95s9MzCRdDQZ+RcKySoYw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:778b1c17-645d-4368-9dc6-ae0b41907c17"}},"directories":{},"maintainers":[{"name":"laborci","email":"gergely@laborci.hu"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svelte-helpers_0.0.3_1787833482335_0.09415097830421004"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-06T11:56:51.792Z","modified":"2026-08-27T12:24:43.383Z","0.0.1":"2026-04-06T11:56:52.031Z","0.0.2":"2026-06-01T10:24:12.755Z","0.0.3":"2026-08-27T12:24:42.488Z"},"bugs":{"url":"https://github.com/atom-forge/svelte-helpers/issues"},"author":{"name":"Gergely Laborci","url":"https://github.com/laborci"},"license":"MIT","homepage":"https://github.com/atom-forge/svelte-helpers#readme","keywords":["svelte","helpers","utilities"],"repository":{"type":"git","url":"git+https://github.com/atom-forge/svelte-helpers.git"},"description":"Svelte helper utilities, types and components","maintainers":[{"name":"laborci","email":"gergely@laborci.hu"}],"readme":"# @atom-forge/svelte-helpers\n\nSvelte helper utilities, types, and components for building type-safe Svelte 5 applications.\n\n## Installation\n\n```bash\nbun add @atom-forge/svelte-helpers\n```\n\n---\n\n## Types\n\n### ClassProp\nStandard type for components that accept external CSS classes.\n```ts\nlet { class: classes }: ClassProp = $props();\nconst cls = $derived(twMerge('base-styles', classes));\n```\n\n### AnyProp\nFor extra HTML attributes to be spread onto elements (`...props`). Always place at the end of the intersection.\n```ts\nlet { class: classes, ...props }: ClassProp & AnyProp = $props();\n// ...\n<input {...props} class={cls} />\n```\n\n### ChildrenProp / ChildrenPropOptional\nConsistent naming for snippet props.\n```ts\n// Required children snippet\nlet { children }: ChildrenProp = $props();\n\n// Optional children snippet\nlet { children }: ChildrenPropOptional = $props();\n\n// Parameterized snippet\nlet { children }: ChildrenProp<[Item]> = $props();\n```\n\n### XOR\nEnforce mutually exclusive props instead of string unions for better type safety.\n```ts\n// small OR compact, but not both\ntype Props = XOR<{ small: true }, { compact: true }, {}>;\n\n// 3+ exclusive variants\ntype ButtonProps = XOR<{ primary: true }, { secondary: true }, { ghost: true }, {}>;\n```\n\n### AtLeastOne\nEnsures that at least one of the properties in an object is provided.\n```ts\ntype LabelOrIcon = AtLeastOne<{ label: string; icon: IconDefinition }>;\n```\n\n---\n\n## Utilities\n\n### variantMap\nBoolean props are simpler in templates; `variantMap` returns the string value for internal logic. Works best when combined with `XOR` or `AtLeastOne` prop types.\n```ts\nconst { small, compact, ...props } = $props();\nconst size = untrack(() => variantMap({ small, compact }, 'normal'));\n// Returns 'small' | 'compact' | 'normal'\n```\n\n### debounce / debounceAsync\nStandard utilities to limit function execution rate.\n```ts\nconst handleInput = debounce((val) => {\n    console.log(val);\n}, 300);\n\nconst search = debounceAsync(async (query) => {\n    return await api.fetch(query);\n}, 500);\n```\n\n### as\nTypeCast helper for Svelte templates and snippets. The TypeScript `as` keyword is not allowed inside Svelte template expressions — use this helper to restore type safety inline.\n\n**Primitive shorthands** — for inline use in templates:\n```svelte\n{@const on = as.boolean(td[k])}\n{@const label = as.string(item.value)}\n{@render list(as.array<string>(items))}\n```\n\nAvailable shorthands: `as.string`, `as.number`, `as.boolean`, `as.array`, `as.object`, `as.function`, `as.any`, `as.unknown`.\n\n**Generic usage** — for custom interfaces inline:\n```ts\nconst user = as<{ name: string; age: number }>(userData);\n```\n\n**Script-side casters** — recommended for complex or frequently reused types:\n```ts\nimport { as } from '@atom-forge/svelte-helpers';\n\nconst toTask = as<{ title: string; done: boolean }>;\nconst toKey  = as<keyof TableData>;\n```\n```svelte\n{@const task = toTask(_task)}\n{@const on   = as.boolean(td[toKey(k)])}\n```\n\n**Snippet parameter typing** — use a script-side caster instead of inline type annotations in snippet params:\n```svelte\n<script lang=\"ts\">\n  import { as } from '@atom-forge/svelte-helpers';\n  const itemArgType = as<{ title: string }>;\n</script>\n\n{#snippet item(_task)}\n  {@const task = itemArgType(_task)}\n  {task.title}\n{/snippet}\n```\n\n---\n\n## Components\n\n### RenderSnippet\nA helper component to safely render snippets dynamically. Especially useful when an API expects a **Component** — you can pass `RenderSnippet` wrapping your snippet.\n```svelte\n<RenderSnippet {snippet} args={{ item, index }} />\n```\n","readmeFilename":"README.md"}