From 8bab28a0ad5915af114390f7345c097bc36984b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2026 10:17:15 +0000 Subject: [PATCH] chore(release): version packages --- .changeset/antispam-encoded-names.md | 5 ---- .changeset/api-fixes.md | 5 ---- .changeset/browser-fixes.md | 5 ---- .changeset/dependency-version-from.md | 5 ---- .changeset/dom-listeners-fixes.md | 15 ------------ .changeset/node-fixes.md | 10 -------- .changeset/react-fixes.md | 16 ------------- .changeset/utils-fixes.md | 16 ------------- .changeset/utils-more-fixes.md | 17 -------------- .changeset/utils-root-exports.md | 5 ---- packages/api/CHANGELOG.md | 8 +++++++ packages/api/package.json | 2 +- packages/browser/CHANGELOG.md | 9 ++++++++ packages/browser/package.json | 2 +- packages/dom/CHANGELOG.md | 18 +++++++++++++++ packages/dom/package.json | 2 +- packages/node/CHANGELOG.md | 15 ++++++++++++ packages/node/package.json | 2 +- packages/react/CHANGELOG.md | 22 ++++++++++++++++++ packages/react/package.json | 2 +- packages/utils/CHANGELOG.md | 33 +++++++++++++++++++++++++++ packages/utils/package.json | 2 +- 22 files changed, 111 insertions(+), 105 deletions(-) delete mode 100644 .changeset/antispam-encoded-names.md delete mode 100644 .changeset/api-fixes.md delete mode 100644 .changeset/browser-fixes.md delete mode 100644 .changeset/dependency-version-from.md delete mode 100644 .changeset/dom-listeners-fixes.md delete mode 100644 .changeset/node-fixes.md delete mode 100644 .changeset/react-fixes.md delete mode 100644 .changeset/utils-fixes.md delete mode 100644 .changeset/utils-more-fixes.md delete mode 100644 .changeset/utils-root-exports.md diff --git a/.changeset/antispam-encoded-names.md b/.changeset/antispam-encoded-names.md deleted file mode 100644 index 83427552..00000000 --- a/.changeset/antispam-encoded-names.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@knitkode/react": patch ---- - -`decodeForm` only reads the encoded input names and ignores the plain (honeypot) ones explicitly, instead of relying on `decode` mangling them. It keeps working with the `decode` of this release, which leaves non encoded text as it is. diff --git a/.changeset/api-fixes.md b/.changeset/api-fixes.md deleted file mode 100644 index 996cbd58..00000000 --- a/.changeset/api-fixes.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@knitkode/api": patch ---- - -Fix the requests URL, which got a double slash with an endpoint starting with `/` or a base URL ending with one, and let the headers passed to a request override the client ones (the client headers used to win). diff --git a/.changeset/browser-fixes.md b/.changeset/browser-fixes.md deleted file mode 100644 index 017b31e7..00000000 --- a/.changeset/browser-fixes.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@knitkode/browser": patch ---- - -Fix `navigateToHash`, which doubled the `?` of the current query string (`/page??a=1#hash`), and make the storage helpers (`storageClient`, `storage`, `createStorage`) return stored falsy values (`0`, `false`, `""`) instead of `null` or the default, and apply falsy defaults in `getAll`. diff --git a/.changeset/dependency-version-from.md b/.changeset/dependency-version-from.md deleted file mode 100644 index 2615bd0d..00000000 --- a/.changeset/dependency-version-from.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@knitkode/node": patch ---- - -`getDependencyVersion` accepts a `{ from }` option with the directory to resolve the dependency from, e.g. `getDependencyVersion("next", { from: "./apps/web" })` or `getDependencyVersion("next", "major", { from })`. By default it now resolves from the current working directory instead of from where `@knitkode/node` is installed, so it finds the project's own dependencies with strict `node_modules` layouts such as pnpm's. diff --git a/.changeset/dom-listeners-fixes.md b/.changeset/dom-listeners-fixes.md deleted file mode 100644 index 967c9300..00000000 --- a/.changeset/dom-listeners-fixes.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -"@knitkode/dom": patch ---- - -Fix the event helpers and a few DOM utilities: - -- The unbind functions returned by `on`, `listenScroll`, `listenScrollDebounced` and `listenScrollThrottled` remove listeners added with capture (they used to do nothing), and `once(el, type, fn, true)` fires only once. -- `unlisten` matches callbacks by reference instead of by their source code, removes only the matching listener (it used to drop every listener of a type that had just one), and can remove a `listenOnce` listener given its original callback. A new function with the same body as the registered one no longer removes it. -- Delegated listeners: a `listenOnce` callback no longer makes the next listener skip the event, and listeners with a selector no longer throw for events fired on `window` or `document`. -- `getListeners` returns copies, mutating them no longer changes the registry. -- `addClass` and `removeClass` called without a class name do nothing instead of throwing. -- `getScrollbarWidth(element)` returns the element's scrollbar width (`offsetWidth - clientWidth`). -- `isNodeList` returns `false` for array-like plain objects. -- `listenLoaded` called after the `DOMContentLoaded` event still runs its handler (asynchronously). -- `getOffset` no longer subtracts the element's own scroll position, only its offset parents'. diff --git a/.changeset/node-fixes.md b/.changeset/node-fixes.md deleted file mode 100644 index 45d8d07d..00000000 --- a/.changeset/node-fixes.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -"@knitkode/node": patch ---- - -Fix several helpers: - -- `fsMoveAndRestoreTemporaryPaths` and `fsMoveAndRestoreTemporaryPathsSync` move the paths out of the destination while the callback runs (they used to copy them), always restore them, even when the callback throws or a path is missing, and run the callback once when there are no paths (it used to run twice). -- `fsFindUpSync` also searches the `stopAt` directory and the file system root. -- `fsWrite` and `fsWriteSync` only drop the leading blank lines, keeping the indentation of the first line. -- `swcCreateTransform` maps root imports of nested libraries without a double slash (`@org/ui/Button`, it used to give `@org/ui//Button`), and `swcTransformsKit` only rewrites root imports, the sub paths of the `@knitkode/*` packages being entry points already. diff --git a/.changeset/react-fixes.md b/.changeset/react-fixes.md deleted file mode 100644 index 565f05b9..00000000 --- a/.changeset/react-fixes.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -"@knitkode/react": patch ---- - -Fix hooks, components and the calendar: - -- `classed` keeps the text after the last interpolation, and its ref and event handlers are typed with the element type. -- `createUseMediaQueryWidth` supports the `"@md"` shorthand (same as `"@min-md"`). -- `extendComponent` applies its default props on React 19. -- `useMeasure` reports the size changes of every instance's element, `useFixedOffset` computes the offset with the given selector, and both work where `ResizeObserver` is missing. -- `useSmoothScroll` subtracts the fixed offset for numeric targets too, and never scrolls below 0. -- `NoJs` swaps `no-js` for `js` without breaking the other classes. Its inline script changed: update its hash if a Content-Security-Policy allows it by hash. -- `Meta` allows zooming when `zoom` is set. -- `useFocus` returns a tuple and accepts the element type, `useInterval` accepts a `null` delay. -- Calendar: hiding a calendar no longer hides the events of the other ones, the default components no longer pass `$` props to the DOM (no more React warnings), multi-day events keep free rows (no more overlaps and duplicate keys), timed events show on their last day, all-day Google events show on the right day in every timezone, events of calendars missing from `calendarsMap` are shown instead of crashing, and the default navigation title is visible. -- `useCalendar` merges the given `events` with the fetched ones, calls `onError` for failing calendars, shows the Google calendar names in `calendarsMap`, switches view from the displayed range, keeps the clicked event on "today" and no longer mutates the given calendars and dates. diff --git a/.changeset/utils-fixes.md b/.changeset/utils-fixes.md deleted file mode 100644 index 2cb3fc07..00000000 --- a/.changeset/utils-fixes.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -"@knitkode/utils": patch ---- - -Fix several helpers: - -- `isExternalUrl` compares against the given `currentUrl` (it used to always fall back to `location.href`) and works outside the browser. It only matches URLs starting with `http(s)://`, compares hosts case-insensitively and supports hosts without a dot such as `localhost`. -- `isServerNow` and `isBrowserNow` no longer throw where `window` is not declared, like in Node.js. -- `round` rounds when `decimals` is falsy (`round(1.7)` is `2`, it used to truncate to `1`). With `trailingZeroes` it returns the formatted string (`round(1.2, 2, true)` is `"1.20"`), the only way to keep the zeroes. -- `ensureInt` truncates numbers like it already did with strings (`ensureInt(1.9)` is `1`, it used to round to `2`). Non numeric input gives `NaN`. -- `slugify` replaces underscores and the other punctuation with the separator (`slugify("foo_bar")` is `"foo-bar"`). -- `removeAccents` keeps the case of the replaced letters (`"École"` gives `"Ecole"`, it used to give `"ecole"`). -- `titleCase` capitalises words starting with any letter (`"élan vital"` gives `"Élan Vital"`). -- `isFloat(Infinity)` is `false`. -- The `Split` type matches the runtime for empty strings and trailing delimiters (`split("a,", ",")` is typed `["a", ""]`). -- `encode` encodes line breaks and characters from code point 1000 up (`€`, CJK, emoji), which it used to corrupt, and `decode` reverses them. The output of the other characters is unchanged, and `decode` still reads values encoded by previous versions. diff --git a/.changeset/utils-more-fixes.md b/.changeset/utils-more-fixes.md deleted file mode 100644 index 2146a728..00000000 --- a/.changeset/utils-more-fixes.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -"@knitkode/utils": patch ---- - -Fix more helpers: - -- `throttle` passes its arguments to the throttled function (it used to throw or drop them), which also fixes the throttled listeners of `@knitkode/dom`. -- Cookies: `setCookie` applies the default `path=/` and writes `expires` (days or `Date`) correctly, so `removeCookie` really removes the cookie. `setCookie` no longer throws where `document` is not declared. -- `getNonce` returns `null` instead of throwing where `__webpack_nonce__` is not declared. -- `objectFlat` keeps `null` values instead of throwing, `objectMergeWithDefaults` no longer mutates the defaults and applies `deleteIfNull` to nested objects, `objectSortByKeysMatching` always puts the matching key first. -- `removeDuplicatesByKey` compares values with `SameValueZero` (`1` and `"1"` are different, keys like `"toString"` are kept). -- `chunkByChunks` returns the requested number of chunks in unbalanced mode, `chunkBySize` with a size below 1 returns the whole array (it used to loop forever). -- `createPalette` keeps the order of the given shades. -- URLs: `buildUrlQueryString` encodes the keys too, `getUrlQueryParams` ignores the hash and decodes the keys, `getUrlHashPathname` strips the `#` and the leading slashes, `getParamAsInt` returns the fallback for non numeric values, `parseURL` returns `null` for invalid ports. -- `debouncePromise` with `isImmediate` settles the promises of the calls made during the wait, with the immediate call result. -- `invariant` is typed as an assertion and its messages follow the documented `[lib:prefix]: message` format (`"Invariant failed"` without a message). -- Types: `Defer()` type-checks as documented and `Deferred` has its `promise`, `ArrayOfAll` resolves to `"Incomplete"` for incomplete lists. diff --git a/.changeset/utils-root-exports.md b/.changeset/utils-root-exports.md deleted file mode 100644 index 46221ce0..00000000 --- a/.changeset/utils-root-exports.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@knitkode/utils": patch ---- - -Export `changeCaseCapital`, `changeCaseNone`, `changeCasePascalSnake`, `removeDuplicates` and `render` from the package root. They were only available from their own subpaths (e.g. `@knitkode/utils/render`), which still work. diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md index 91cf93f0..de1a303d 100644 --- a/packages/api/CHANGELOG.md +++ b/packages/api/CHANGELOG.md @@ -1,5 +1,13 @@ # @knitkode/api +## 3.0.1 + +### Patch Changes + +- [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95) Thanks [@kuus](https://github.com/kuus)! - Fix the requests URL, which got a double slash with an endpoint starting with `/` or a base URL ending with one, and let the headers passed to a request override the client ones (the client headers used to win). +- Updated dependencies [[`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95), [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143), [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899)]: + - @knitkode/utils@3.0.1 + ## 3.0.0 ### Major Changes diff --git a/packages/api/package.json b/packages/api/package.json index e23c42da..5679af74 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/api", - "version": "3.0.0", + "version": "3.0.1", "description": "Type-safe API client factory with optional SWR hooks and Next.js API response helpers.", "keywords": [ "knitkode", diff --git a/packages/browser/CHANGELOG.md b/packages/browser/CHANGELOG.md index 4eb60677..152e9461 100644 --- a/packages/browser/CHANGELOG.md +++ b/packages/browser/CHANGELOG.md @@ -1,5 +1,14 @@ # @knitkode/browser +## 3.0.1 + +### Patch Changes + +- [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95) Thanks [@kuus](https://github.com/kuus)! - Fix `navigateToHash`, which doubled the `?` of the current query string (`/page??a=1#hash`), and make the storage helpers (`storageClient`, `storage`, `createStorage`) return stored falsy values (`0`, `false`, `""`) instead of `null` or the default, and apply falsy defaults in `getAll`. +- Updated dependencies [[`a04e3ff`](https://github.com/knitkode/kit/commit/a04e3ffbd88d6ee664b3e22546c2e6d66bdd851a), [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95), [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143), [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899)]: + - @knitkode/dom@3.0.1 + - @knitkode/utils@3.0.1 + ## 3.0.0 ### Major Changes diff --git a/packages/browser/package.json b/packages/browser/package.json index 1d234185..2043b506 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/browser", - "version": "3.0.0", + "version": "3.0.1", "description": "Browser helpers: URL search and hash navigation, storage clients, gtag, device detection, zoned dates.", "keywords": [ "knitkode", diff --git a/packages/dom/CHANGELOG.md b/packages/dom/CHANGELOG.md index 3f2617fa..ac4bc25c 100644 --- a/packages/dom/CHANGELOG.md +++ b/packages/dom/CHANGELOG.md @@ -1,5 +1,23 @@ # @knitkode/dom +## 3.0.1 + +### Patch Changes + +- [`a04e3ff`](https://github.com/knitkode/kit/commit/a04e3ffbd88d6ee664b3e22546c2e6d66bdd851a) Thanks [@kuus](https://github.com/kuus)! - Fix the event helpers and a few DOM utilities: + + - The unbind functions returned by `on`, `listenScroll`, `listenScrollDebounced` and `listenScrollThrottled` remove listeners added with capture (they used to do nothing), and `once(el, type, fn, true)` fires only once. + - `unlisten` matches callbacks by reference instead of by their source code, removes only the matching listener (it used to drop every listener of a type that had just one), and can remove a `listenOnce` listener given its original callback. A new function with the same body as the registered one no longer removes it. + - Delegated listeners: a `listenOnce` callback no longer makes the next listener skip the event, and listeners with a selector no longer throw for events fired on `window` or `document`. + - `getListeners` returns copies, mutating them no longer changes the registry. + - `addClass` and `removeClass` called without a class name do nothing instead of throwing. + - `getScrollbarWidth(element)` returns the element's scrollbar width (`offsetWidth - clientWidth`). + - `isNodeList` returns `false` for array-like plain objects. + - `listenLoaded` called after the `DOMContentLoaded` event still runs its handler (asynchronously). + - `getOffset` no longer subtracts the element's own scroll position, only its offset parents'. +- Updated dependencies [[`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95), [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143), [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899)]: + - @knitkode/utils@3.0.1 + ## 3.0.0 ### Major Changes diff --git a/packages/dom/package.json b/packages/dom/package.json index d4d9a778..ec7bffc8 100644 --- a/packages/dom/package.json +++ b/packages/dom/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/dom", - "version": "3.0.0", + "version": "3.0.1", "description": "Tiny, tree-shakeable DOM helpers: selectors, event delegation, scroll and resize listeners, measurements.", "keywords": [ "knitkode", diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 65dad545..2faa655f 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -1,5 +1,20 @@ # @knitkode/node +## 3.0.1 + +### Patch Changes + +- [`1ad3640`](https://github.com/knitkode/kit/commit/1ad3640499d3efd829475f90409d56f19b503573) Thanks [@kuus](https://github.com/kuus)! - `getDependencyVersion` accepts a `{ from }` option with the directory to resolve the dependency from, e.g. `getDependencyVersion("next", { from: "./apps/web" })` or `getDependencyVersion("next", "major", { from })`. By default it now resolves from the current working directory instead of from where `@knitkode/node` is installed, so it finds the project's own dependencies with strict `node_modules` layouts such as pnpm's. + +- [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95) Thanks [@kuus](https://github.com/kuus)! - Fix several helpers: + + - `fsMoveAndRestoreTemporaryPaths` and `fsMoveAndRestoreTemporaryPathsSync` move the paths out of the destination while the callback runs (they used to copy them), always restore them, even when the callback throws or a path is missing, and run the callback once when there are no paths (it used to run twice). + - `fsFindUpSync` also searches the `stopAt` directory and the file system root. + - `fsWrite` and `fsWriteSync` only drop the leading blank lines, keeping the indentation of the first line. + - `swcCreateTransform` maps root imports of nested libraries without a double slash (`@org/ui/Button`, it used to give `@org/ui//Button`), and `swcTransformsKit` only rewrites root imports, the sub paths of the `@knitkode/*` packages being entry points already. +- Updated dependencies [[`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95), [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143), [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899)]: + - @knitkode/utils@3.0.1 + ## 3.0.0 ### Major Changes diff --git a/packages/node/package.json b/packages/node/package.json index 57994b3e..c14644bf 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/node", - "version": "3.0.0", + "version": "3.0.1", "description": "Node.js helpers: file system utilities, dependency version lookup and SWC modularize-imports transforms.", "keywords": [ "knitkode", diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index 4b96cc7c..f2b7a3df 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,27 @@ # @knitkode/react +## 3.0.1 + +### Patch Changes + +- [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95) Thanks [@kuus](https://github.com/kuus)! - `decodeForm` only reads the encoded input names and ignores the plain (honeypot) ones explicitly, instead of relying on `decode` mangling them. It keeps working with the `decode` of this release, which leaves non encoded text as it is. + +- [`f1c0e3a`](https://github.com/knitkode/kit/commit/f1c0e3a7e23acc7af5f35e48b34b0554d07ac35e) Thanks [@kuus](https://github.com/kuus)! - Fix hooks, components and the calendar: + + - `classed` keeps the text after the last interpolation, and its ref and event handlers are typed with the element type. + - `createUseMediaQueryWidth` supports the `"@md"` shorthand (same as `"@min-md"`). + - `extendComponent` applies its default props on React 19. + - `useMeasure` reports the size changes of every instance's element, `useFixedOffset` computes the offset with the given selector, and both work where `ResizeObserver` is missing. + - `useSmoothScroll` subtracts the fixed offset for numeric targets too, and never scrolls below 0. + - `NoJs` swaps `no-js` for `js` without breaking the other classes. Its inline script changed: update its hash if a Content-Security-Policy allows it by hash. + - `Meta` allows zooming when `zoom` is set. + - `useFocus` returns a tuple and accepts the element type, `useInterval` accepts a `null` delay. + - Calendar: hiding a calendar no longer hides the events of the other ones, the default components no longer pass `$` props to the DOM (no more React warnings), multi-day events keep free rows (no more overlaps and duplicate keys), timed events show on their last day, all-day Google events show on the right day in every timezone, events of calendars missing from `calendarsMap` are shown instead of crashing, and the default navigation title is visible. + - `useCalendar` merges the given `events` with the fetched ones, calls `onError` for failing calendars, shows the Google calendar names in `calendarsMap`, switches view from the displayed range, keeps the clicked event on "today" and no longer mutates the given calendars and dates. +- Updated dependencies [[`a04e3ff`](https://github.com/knitkode/kit/commit/a04e3ffbd88d6ee664b3e22546c2e6d66bdd851a), [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95), [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143), [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899)]: + - @knitkode/dom@3.0.1 + - @knitkode/utils@3.0.1 + ## 3.0.0 ### Major Changes diff --git a/packages/react/package.json b/packages/react/package.json index 65f4d10b..8cd1e8fc 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/react", - "version": "3.0.0", + "version": "3.0.1", "description": "React hooks and components: scroll, resize and measure hooks, polymorphic helpers, a headless calendar and form antispam.", "keywords": [ "knitkode", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index dde8ccc5..213f2a34 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,38 @@ # @knitkode/utils +## 3.0.1 + +### Patch Changes + +- [`113cd75`](https://github.com/knitkode/kit/commit/113cd754ba6cf9497752643541defcceebf34a95) Thanks [@kuus](https://github.com/kuus)! - Fix several helpers: + + - `isExternalUrl` compares against the given `currentUrl` (it used to always fall back to `location.href`) and works outside the browser. It only matches URLs starting with `http(s)://`, compares hosts case-insensitively and supports hosts without a dot such as `localhost`. + - `isServerNow` and `isBrowserNow` no longer throw where `window` is not declared, like in Node.js. + - `round` rounds when `decimals` is falsy (`round(1.7)` is `2`, it used to truncate to `1`). With `trailingZeroes` it returns the formatted string (`round(1.2, 2, true)` is `"1.20"`), the only way to keep the zeroes. + - `ensureInt` truncates numbers like it already did with strings (`ensureInt(1.9)` is `1`, it used to round to `2`). Non numeric input gives `NaN`. + - `slugify` replaces underscores and the other punctuation with the separator (`slugify("foo_bar")` is `"foo-bar"`). + - `removeAccents` keeps the case of the replaced letters (`"École"` gives `"Ecole"`, it used to give `"ecole"`). + - `titleCase` capitalises words starting with any letter (`"élan vital"` gives `"Élan Vital"`). + - `isFloat(Infinity)` is `false`. + - The `Split` type matches the runtime for empty strings and trailing delimiters (`split("a,", ",")` is typed `["a", ""]`). + - `encode` encodes line breaks and characters from code point 1000 up (`€`, CJK, emoji), which it used to corrupt, and `decode` reverses them. The output of the other characters is unchanged, and `decode` still reads values encoded by previous versions. + +- [`89e3ba6`](https://github.com/knitkode/kit/commit/89e3ba66f33f8b5c8b7ecc2350d5dadbfd6bc143) Thanks [@kuus](https://github.com/kuus)! - Fix more helpers: + + - `throttle` passes its arguments to the throttled function (it used to throw or drop them), which also fixes the throttled listeners of `@knitkode/dom`. + - Cookies: `setCookie` applies the default `path=/` and writes `expires` (days or `Date`) correctly, so `removeCookie` really removes the cookie. `setCookie` no longer throws where `document` is not declared. + - `getNonce` returns `null` instead of throwing where `__webpack_nonce__` is not declared. + - `objectFlat` keeps `null` values instead of throwing, `objectMergeWithDefaults` no longer mutates the defaults and applies `deleteIfNull` to nested objects, `objectSortByKeysMatching` always puts the matching key first. + - `removeDuplicatesByKey` compares values with `SameValueZero` (`1` and `"1"` are different, keys like `"toString"` are kept). + - `chunkByChunks` returns the requested number of chunks in unbalanced mode, `chunkBySize` with a size below 1 returns the whole array (it used to loop forever). + - `createPalette` keeps the order of the given shades. + - URLs: `buildUrlQueryString` encodes the keys too, `getUrlQueryParams` ignores the hash and decodes the keys, `getUrlHashPathname` strips the `#` and the leading slashes, `getParamAsInt` returns the fallback for non numeric values, `parseURL` returns `null` for invalid ports. + - `debouncePromise` with `isImmediate` settles the promises of the calls made during the wait, with the immediate call result. + - `invariant` is typed as an assertion and its messages follow the documented `[lib:prefix]: message` format (`"Invariant failed"` without a message). + - Types: `Defer()` type-checks as documented and `Deferred` has its `promise`, `ArrayOfAll` resolves to `"Incomplete"` for incomplete lists. + +- [`b131ad6`](https://github.com/knitkode/kit/commit/b131ad61ba1956a5efb1f2a0ad00c76870da8899) Thanks [@kuus](https://github.com/kuus)! - Export `changeCaseCapital`, `changeCaseNone`, `changeCasePascalSnake`, `removeDuplicates` and `render` from the package root. They were only available from their own subpaths (e.g. `@knitkode/utils/render`), which still work. + ## 3.0.0 ### Major Changes diff --git a/packages/utils/package.json b/packages/utils/package.json index 98996666..3835beb9 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@knitkode/utils", - "version": "3.0.0", + "version": "3.0.1", "description": "Tree-shakeable TypeScript utilities: type guards, object and array helpers, case conversion, URL and cookie helpers.", "keywords": [ "knitkode",