diff --git a/.changeset/little-penguins-jam.md b/.changeset/little-penguins-jam.md new file mode 100644 index 00000000..29622995 --- /dev/null +++ b/.changeset/little-penguins-jam.md @@ -0,0 +1,5 @@ +--- +'@svelte-put/copy': patch +--- + +re-expose public typedef (following https://github.com/Rich-Harris/dts-buddy/pull/82) diff --git a/packages/copy/src/copy.action.js b/packages/copy/src/copy.action.js index 777761d6..6e63e745 100644 --- a/packages/copy/src/copy.action.js +++ b/packages/copy/src/copy.action.js @@ -6,8 +6,8 @@ import { copyToClipboard } from './copy.helpers.js'; * Copy text to clipboard on `click` event * @template {keyof HTMLElementEventMap} K * @param {HTMLElement} node - HTMLElement to register action - * @param {import('./public.js').CopyParameter} parameter - svelte action parameters - * @returns {import('./public.js').CopyReturn} + * @param {import('./types.public').CopyParameter} parameter - svelte action parameters + * @returns {import('./types.public').CopyReturn} */ export function copy(node, parameter = {}) { let { trigger, enabled, text, events, synthetic } = resolveConfig(node, parameter); @@ -16,7 +16,7 @@ export function copy(node, parameter = {}) { async function handler(e) { const rText = await text({ node, trigger, event: e }); copyToClipboard(rText); - /** @type {import('./public').CopyDetail} */ + /** @type {import('./types.public').CopyDetail} */ const detail = { text: rText }; node.dispatchEvent(new CustomEvent('copied', { detail })); if (synthetic) { @@ -38,7 +38,7 @@ export function copy(node, parameter = {}) { let offs = []; function addEvents() { if (trigger) { - offs = events.map((event) => on(trigger, event, handler)); + offs = events.map((event) => on(trigger, /** @type {K} */(event), handler)); } } @@ -67,11 +67,11 @@ export function copy(node, parameter = {}) { * @package * @template {keyof HTMLElementEventMap} K * @param {HTMLElement} node - * @param {import('./public').CopyParameter} param + * @param {import('./types.public').CopyParameter} param * @returns {{ * trigger: HTMLElement; * enabled: boolean; - * text: import('./public.js').TextResolver; + * text: import('./types.public').TextResolver; * events: K[] | "click"[]; * synthetic: boolean; * }} @@ -81,13 +81,14 @@ function resolveConfig(node, param = {}) { const text = typeof param.text === 'function' ? param.text - : /** @type {import('./public.js').TextResolver} */ (() => param.text ?? node.innerText); + : /** @type {import('./types.public').TextResolver} */ (() => param.text ?? node.innerText); const events = typeof param.event === 'string' ? [param.event] : param.event ?? ['click']; return { trigger, enabled, text, events, synthetic }; } /** * Deprecated, use `CopyParameter` and `CopyConfig` instead - * @typedef {import('./public').CopyConfig} CopyParameters + * @typedef {import('./types.public').CopyConfig} CopyParameters * @template {keyof HTMLElementEventMap} K */ + diff --git a/packages/copy/src/index.js b/packages/copy/src/index.js index 1e66ccf8..95fc7f6c 100644 --- a/packages/copy/src/index.js +++ b/packages/copy/src/index.js @@ -2,3 +2,5 @@ export * from './copy.action.js'; export * from './copy.helpers.js'; +export * from './types.public.js'; + diff --git a/packages/copy/src/public.d.ts b/packages/copy/src/types.public.d.ts similarity index 100% rename from packages/copy/src/public.d.ts rename to packages/copy/src/types.public.d.ts diff --git a/packages/copy/src/types.public.js b/packages/copy/src/types.public.js new file mode 100644 index 00000000..710b17ee --- /dev/null +++ b/packages/copy/src/types.public.js @@ -0,0 +1,3 @@ +/** to provide typing only, see types.public.d.ts */ +export {}; +