Releases: anIcedAntFA/ctc
@ngockhoi96/ctc@0.3.0
Minor Changes
-
✨
9d6603dThanks @anIcedAntFA! - ## Rich Clipboard APIAdds full support for writing and reading rich content (HTML + plain-text pairs) using the Clipboard Items API, with framework adapters for React, Vue, and Svelte.
@ngockhoi96/ctcNew exports:
copyRichContent(content, options?)— Writes aRichContentobject ({ html, plain }) to the clipboard usingClipboardItem. Automatically guards for SSR. CallsonErrorwithRICH_CLIPBOARD_NOT_SUPPORTEDwhen the Clipboard Items API is unavailable.readRichContent()— Reads the richest available MIME type from the clipboard (text/htmlif present, falling back totext/plain). ReturnsRichContent | null.isRichClipboardSupported()— ReturnstruewhenClipboardItemis available in the current environment.RichContenttype —{ html: string; plain: string }shape used by the rich clipboard API.RICH_CLIPBOARD_NOT_SUPPORTEDerror code added toErrorCode.
@ngockhoi96/ctc-reactNew exports:
useCopyRichContent(options?)— React hook that wrapscopyRichContent. Returns{ copyRich, copied, error, reset }. Mirrors theuseCopyToClipboardAPI shape for consistency.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-vueNew exports:
useCopyRichContent(options?)— Vue 3 composable wrappingcopyRichContent. Returns{ copyRich, copied, error, reset }as refs. Mirrors theuseCopyToClipboardcomposable API shape.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-svelteNew exports:
copyRichAction— Svelte action (use:copyRichAction) that copies rich content on the target element's click event.CopyRichActionParamstype.useCopyRichContent()(via/runessubpath) — Svelte 5 runes-based hook returning reactive{ copyRich, copied, error, reset }state.useCopyRichContent()(via/storessubpath) — Svelte 4 stores-based equivalent using writable stores.UseCopyRichContentOptionsandUseCopyRichContentResulttypes (available on both subpaths).
Fix:
/runessubpath export (exports["./runes"]) now correctly points to the compileddist/runes.mjsinstead of the raw TypeScript source file.
All packages also received updated npm
keywordsanddescriptionfields for better discoverability.
@ngockhoi96/ctc-vue@1.0.0
Major Changes
-
💥
9d6603dThanks @anIcedAntFA! - ## Rich Clipboard APIAdds full support for writing and reading rich content (HTML + plain-text pairs) using the Clipboard Items API, with framework adapters for React, Vue, and Svelte.
@ngockhoi96/ctcNew exports:
copyRichContent(content, options?)— Writes aRichContentobject ({ html, plain }) to the clipboard usingClipboardItem. Automatically guards for SSR. CallsonErrorwithRICH_CLIPBOARD_NOT_SUPPORTEDwhen the Clipboard Items API is unavailable.readRichContent()— Reads the richest available MIME type from the clipboard (text/htmlif present, falling back totext/plain). ReturnsRichContent | null.isRichClipboardSupported()— ReturnstruewhenClipboardItemis available in the current environment.RichContenttype —{ html: string; plain: string }shape used by the rich clipboard API.RICH_CLIPBOARD_NOT_SUPPORTEDerror code added toErrorCode.
@ngockhoi96/ctc-reactNew exports:
useCopyRichContent(options?)— React hook that wrapscopyRichContent. Returns{ copyRich, copied, error, reset }. Mirrors theuseCopyToClipboardAPI shape for consistency.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-vueNew exports:
useCopyRichContent(options?)— Vue 3 composable wrappingcopyRichContent. Returns{ copyRich, copied, error, reset }as refs. Mirrors theuseCopyToClipboardcomposable API shape.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-svelteNew exports:
copyRichAction— Svelte action (use:copyRichAction) that copies rich content on the target element's click event.CopyRichActionParamstype.useCopyRichContent()(via/runessubpath) — Svelte 5 runes-based hook returning reactive{ copyRich, copied, error, reset }state.useCopyRichContent()(via/storessubpath) — Svelte 4 stores-based equivalent using writable stores.UseCopyRichContentOptionsandUseCopyRichContentResulttypes (available on both subpaths).
Fix:
/runessubpath export (exports["./runes"]) now correctly points to the compileddist/runes.mjsinstead of the raw TypeScript source file.
All packages also received updated npm
keywordsanddescriptionfields for better discoverability.
Patch Changes
- Updated dependencies [
9d6603d]:- @ngockhoi96/ctc@0.3.0
@ngockhoi96/ctc-svelte@1.0.0
Major Changes
-
💥
9d6603dThanks @anIcedAntFA! - ## Rich Clipboard APIAdds full support for writing and reading rich content (HTML + plain-text pairs) using the Clipboard Items API, with framework adapters for React, Vue, and Svelte.
@ngockhoi96/ctcNew exports:
copyRichContent(content, options?)— Writes aRichContentobject ({ html, plain }) to the clipboard usingClipboardItem. Automatically guards for SSR. CallsonErrorwithRICH_CLIPBOARD_NOT_SUPPORTEDwhen the Clipboard Items API is unavailable.readRichContent()— Reads the richest available MIME type from the clipboard (text/htmlif present, falling back totext/plain). ReturnsRichContent | null.isRichClipboardSupported()— ReturnstruewhenClipboardItemis available in the current environment.RichContenttype —{ html: string; plain: string }shape used by the rich clipboard API.RICH_CLIPBOARD_NOT_SUPPORTEDerror code added toErrorCode.
@ngockhoi96/ctc-reactNew exports:
useCopyRichContent(options?)— React hook that wrapscopyRichContent. Returns{ copyRich, copied, error, reset }. Mirrors theuseCopyToClipboardAPI shape for consistency.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-vueNew exports:
useCopyRichContent(options?)— Vue 3 composable wrappingcopyRichContent. Returns{ copyRich, copied, error, reset }as refs. Mirrors theuseCopyToClipboardcomposable API shape.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-svelteNew exports:
copyRichAction— Svelte action (use:copyRichAction) that copies rich content on the target element's click event.CopyRichActionParamstype.useCopyRichContent()(via/runessubpath) — Svelte 5 runes-based hook returning reactive{ copyRich, copied, error, reset }state.useCopyRichContent()(via/storessubpath) — Svelte 4 stores-based equivalent using writable stores.UseCopyRichContentOptionsandUseCopyRichContentResulttypes (available on both subpaths).
Fix:
/runessubpath export (exports["./runes"]) now correctly points to the compileddist/runes.mjsinstead of the raw TypeScript source file.
All packages also received updated npm
keywordsanddescriptionfields for better discoverability.
Patch Changes
- Updated dependencies [
9d6603d]:- @ngockhoi96/ctc@0.3.0
@ngockhoi96/ctc-react@1.0.0
Major Changes
-
💥
9d6603dThanks @anIcedAntFA! - ## Rich Clipboard APIAdds full support for writing and reading rich content (HTML + plain-text pairs) using the Clipboard Items API, with framework adapters for React, Vue, and Svelte.
@ngockhoi96/ctcNew exports:
copyRichContent(content, options?)— Writes aRichContentobject ({ html, plain }) to the clipboard usingClipboardItem. Automatically guards for SSR. CallsonErrorwithRICH_CLIPBOARD_NOT_SUPPORTEDwhen the Clipboard Items API is unavailable.readRichContent()— Reads the richest available MIME type from the clipboard (text/htmlif present, falling back totext/plain). ReturnsRichContent | null.isRichClipboardSupported()— ReturnstruewhenClipboardItemis available in the current environment.RichContenttype —{ html: string; plain: string }shape used by the rich clipboard API.RICH_CLIPBOARD_NOT_SUPPORTEDerror code added toErrorCode.
@ngockhoi96/ctc-reactNew exports:
useCopyRichContent(options?)— React hook that wrapscopyRichContent. Returns{ copyRich, copied, error, reset }. Mirrors theuseCopyToClipboardAPI shape for consistency.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-vueNew exports:
useCopyRichContent(options?)— Vue 3 composable wrappingcopyRichContent. Returns{ copyRich, copied, error, reset }as refs. Mirrors theuseCopyToClipboardcomposable API shape.UseCopyRichContentOptionsandUseCopyRichContentResulttypes.
Fix: Added
typescondition to theexportsmap, fixing TypeScript module resolution undermoduleResolution: "bundler"and"node16".@ngockhoi96/ctc-svelteNew exports:
copyRichAction— Svelte action (use:copyRichAction) that copies rich content on the target element's click event.CopyRichActionParamstype.useCopyRichContent()(via/runessubpath) — Svelte 5 runes-based hook returning reactive{ copyRich, copied, error, reset }state.useCopyRichContent()(via/storessubpath) — Svelte 4 stores-based equivalent using writable stores.UseCopyRichContentOptionsandUseCopyRichContentResulttypes (available on both subpaths).
Fix:
/runessubpath export (exports["./runes"]) now correctly points to the compileddist/runes.mjsinstead of the raw TypeScript source file.
All packages also received updated npm
keywordsanddescriptionfields for better discoverability.
Patch Changes
- Updated dependencies [
9d6603d]:- @ngockhoi96/ctc@0.3.0
@ngockhoi96/ctc-vue@0.1.0
Minor Changes
-
✨
e9257f4Thanks @anIcedAntFA! - feat(vue): initial release of@ngockhoi96/ctc-vue— Vue 3 composable for clipboard copyIntroduces the first stable API for the Vue 3 adapter package. Built on top of
@ngockhoi96/ctccore with full Vue reactivity integration via shallow refs, auto-reset timer, and structured error handling.New export:
useCopyToClipboardfunction useCopyToClipboard( initText?: string, options?: UseCopyToClipboardOptions ): UseCopyToClipboardResult;
A Vue 3 composable that wraps
copyToClipboardfrom@ngockhoi96/ctcand managescopied/erroras VueShallowRefvalues.Parameters:
initText— Text to copy. Optional at init; can be overridden percopy()call.options.timeout— Milliseconds beforecopiedauto-resets tofalseafter a successful copy. Defaults to2000. Set to0to disable auto-reset.options.onError— Callback receiving aBrowserUtilsErroron failure (inherited fromClipboardOptions).
Returns
{ copy, copied, error, reset }:Field Type Description copy(text?: string) => Promise<boolean>Trigger a copy. Per-call textoverridesinitText. Returnstrueon success.copiedShallowRef<boolean>trueimmediately after a successful copy; auto-resets aftertimeoutms. Unwrapped automatically in templates.errorShallowRef<BrowserUtilsError | null>Structured error from the most recent failed attempt. Cleared to nullat the start of eachcopy()call.reset() => voidImmediately resets copied.valuetofalse,error.valuetonull, and cancels any pending auto-reset timer.Example:
<script setup lang="ts"> import { useCopyToClipboard } from "@ngockhoi96/ctc-vue"; const { copy, copied, error } = useCopyToClipboard("Hello, world!", { timeout: 1500, }); </script> <template> <button @click="copy()" :disabled="copied"> {{ copied ? "Copied!" : "Copy" }} </button> <span v-if="error">Failed: {{ error.code }}</span> </template>
New types exported
UseCopyToClipboardOptions— Options interface extendingClipboardOptionsUseCopyToClipboardResult— Return shape of the composable
Re-exports from
@ngockhoi96/ctccore for convenience:BrowserUtilsError,ClipboardOptions,ErrorCode,OnErrorCallback
Peer dependencies
@ngockhoi96/ctc >= 0.1.0vue >= 3.0.0 < 4.0.0
SSR safety
The composable is SSR-safe.
copyToClipboardfrom core returnsfalseimmediately in non-browser environments.onUnmountedis a no-op on the server — no timer cleanup issues in Nuxt SSR or similar environments.
@ngockhoi96/ctc-svelte@0.1.0
Minor Changes
-
✨
e9257f4Thanks @anIcedAntFA! - feat(svelte): initial release of@ngockhoi96/ctc-svelte— Svelte action and reactive helpers for clipboard copyIntroduces the first stable API for the Svelte adapter package. Built on top of
@ngockhoi96/ctccore and ships three complementary exports — pick the one that fits your code style.New export:
copyAction(default subpath)A Svelte action for declarative copy-on-click buttons. No
copiedstate to manage — just bind text and listen for events.<script lang="ts"> import { copyAction } from "@ngockhoi96/ctc-svelte"; </script> <button use:copyAction={{ text: "Hello, world!" }} on:ctc:copy={(e) => console.log("copied", e.detail.text)} on:ctc:error={(e) => console.error(e.detail.error)} > Copy </button>
Parameters (
CopyActionParams):Param Type Description params.textstringText copied on click. Reactive — update()rebinds on change.params.onErrorOnErrorCallback | undefinedOptional callback invoked with a structured error on failure. Dispatched events (bubble):
Event Detail When ctc:copy{ text: string }Fired after a successful clipboard write. ctc:error{ error: BrowserUtilsError }Fired when the copy operation fails. New export:
useCopyToClipboardvia/stores(Svelte 4 + 5)import { useCopyToClipboard } from "@ngockhoi96/ctc-svelte/stores"; function useCopyToClipboard( initText?: string, options?: UseCopyToClipboardOptions ): UseCopyToClipboardResult;
Returns
copiedanderrorasReadablestores. Subscribe with$copied/$errorin templates, or read synchronously viaget()fromsvelte/store.Returns
{ copy, copied, error, reset }:Field Type Description copy(text?: string) => Promise<boolean>Trigger a copy. Per-call textoverridesinitText. Returnstrueon success.copiedReadable<boolean>trueimmediately after a successful copy; auto-resets aftertimeoutms.errorReadable<BrowserUtilsError | null>Structured error from the most recent failed attempt. Cleared to nullat the start of eachcopy()call.reset() => voidResets copiedanderror, cancels any pending auto-reset timer.New export:
useCopyToClipboardvia/runes(Svelte 5 only)import { useCopyToClipboard } from "@ngockhoi96/ctc-svelte/runes";
Returns a reactive object with
copiedanderroras$state-backed getters. Idiomatic Svelte 5 — read directly in templates and$effectwithout.valueor$prefix. Uses$effectfor automatic timer cleanup on component destroy.Example:
<script lang="ts"> import { useCopyToClipboard } from "@ngockhoi96/ctc-svelte/runes"; const ctc = useCopyToClipboard("Hello, world!", { timeout: 1500 }); </script> <button onclick={() => ctc.copy()} disabled={ctc.copied}> {ctc.copied ? "Copied!" : "Copy"} </button> {#if ctc.error} <span>Failed: {ctc.error.code}</span> {/if}
Note: Do not destructure
copied/errorinto localconstbindings outside a reactive scope — the getters preserve reactivity, plain destructuring snapshots the value.Compatibility
Export Svelte 4 Svelte 5 copyActionyes yes useCopyToClipboard(stores)yes yes useCopyToClipboard(runes)no yes New types exported
CopyActionParams— Params for thecopyActionSvelte actionUseCopyToClipboardOptions— Options interface extendingClipboardOptionsUseCopyToClipboardResult— Return shape ofuseCopyToClipboard
Re-exports from
@ngockhoi96/ctccore for convenience:BrowserUtilsError,ClipboardOptions,ErrorCode,OnErrorCallback
Peer dependencies
@ngockhoi96/ctc >= 0.1.0svelte >= 4.0.0
v0.2.1
Patch Changes
-
0bd932fThanks @anIcedAntFA! - Fixexportsmap missingtypescondition for TypeScript consumers.TypeScript consumers using
moduleResolution: nodenextorbundlernow correctly resolve declarations via the"types"condition in theexportsmap for both the root"."and"./clipboard"subpath, instead of falling back to the CJS.d.ctsfile.
v0.2.0
Minor Changes
-
6b75f83Thanks @anIcedAntFA! - Initial public release of@ngockhoi96/ctc.Includes a complete, tree-shakeable clipboard utilities module:
copyToClipboard(text, options?)— copy text via modern Clipboard API, returnsbooleanreadFromClipboard()— read text from clipboard, returnsstring | nullcopyToClipboardLegacy(text, options?)— explicit execCommand fallback for HTTP/legacy browsersisClipboardSupported()— detect Clipboard API write availabilityisClipboardReadSupported()— detect Clipboard API read availability- Typed
BrowserUtilsErrorwith specific error codes via optionalonErrorcallback - SSR-safe: all exports importable in Node.js without crashing
- Zero runtime dependencies, bundle < 1 KB gzip, ES2020+ output (ESM + CJS +
.d.ts)