Skip to content

Releases: knitkode/kit

@knitkode/utils@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • 113cd75 Thanks @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 Thanks @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 Thanks @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.

@knitkode/react@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • 113cd75 Thanks @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 Thanks @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, 113cd75, 89e3ba6, b131ad6]:

    • @knitkode/dom@3.0.1
    • @knitkode/utils@3.0.1

@knitkode/node@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • 1ad3640 Thanks @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 Thanks @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, 89e3ba6, b131ad6]:

    • @knitkode/utils@3.0.1

@knitkode/dom@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • a04e3ff Thanks @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, 89e3ba6, b131ad6]:

    • @knitkode/utils@3.0.1

@knitkode/browser@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • 113cd75 Thanks @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, 113cd75, 89e3ba6, b131ad6]:
    • @knitkode/dom@3.0.1
    • @knitkode/utils@3.0.1

@knitkode/api@3.0.1

Choose a tag to compare

@github-actions github-actions released this 10 Oct 11:52
28a0bb8

Patch Changes

  • 113cd75 Thanks @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, 89e3ba6, b131ad6]:
    • @knitkode/utils@3.0.1

@knitkode/utils@3.0.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:19
11c1f22

Major Changes

  • 2f0b11e Thanks @kuus! - First release under the @knitkode npm scope. These packages were previously published as @koine/* (last version 2.0.0-beta.217). Follow the migration guide to upgrade.

    • Packages are renamed from @koine/<name> to @knitkode/<name>. @koine/i18n and @koine/next are not part of kit: internationalization now lives in the separate Koine project.
    • Packages are ESM-only, with no CommonJS builds. Bundlers need no changes. Node.js can still require() them from 20.19 / 22.12. TypeScript users need moduleResolution set to bundler, node16 or nodenext.
    • Only the documented entry points can be imported: the package root and one subpath per module, e.g. @knitkode/utils/isArray. The old *.cjs.js and *.esm.js files and internal paths are gone.
    • Renamed exports: KoineComponent → KitComponent, KoineComponentProps → KitComponentProps, KoineCalendar* → KitCalendar* (@knitkode/react), the global Koine.Api namespace → Kit.Api (@knitkode/api/typings), swcTransformsKoine → swcTransformsKit (@knitkode/node/swc).
    • Removed subpaths: @koine/api/swr/createSwrApi (use @knitkode/api/swr), @koine/api/swr-mutation/createSwrApi (use @knitkode/api/swr-mutation) and the empty @koine/utils/without.
    • @knitkode/dom exports the EventCallback and ListenEvent types (from the package root) used by listen, listenOnce, unlisten and getListeners. Their declarations used to reference these types without shipping them.
    • @knitkode/api/typings now resolves under node16 and nodenext module resolution.
    • Packages are MIT licensed and published from CI with npm provenance.

@knitkode/react@3.0.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:19
11c1f22

Major Changes

  • 2f0b11e Thanks @kuus! - First release under the @knitkode npm scope. These packages were previously published as @koine/* (last version 2.0.0-beta.217). Follow the migration guide to upgrade.

    • Packages are renamed from @koine/<name> to @knitkode/<name>. @koine/i18n and @koine/next are not part of kit: internationalization now lives in the separate Koine project.
    • Packages are ESM-only, with no CommonJS builds. Bundlers need no changes. Node.js can still require() them from 20.19 / 22.12. TypeScript users need moduleResolution set to bundler, node16 or nodenext.
    • Only the documented entry points can be imported: the package root and one subpath per module, e.g. @knitkode/utils/isArray. The old *.cjs.js and *.esm.js files and internal paths are gone.
    • Renamed exports: KoineComponent → KitComponent, KoineComponentProps → KitComponentProps, KoineCalendar* → KitCalendar* (@knitkode/react), the global Koine.Api namespace → Kit.Api (@knitkode/api/typings), swcTransformsKoine → swcTransformsKit (@knitkode/node/swc).
    • Removed subpaths: @koine/api/swr/createSwrApi (use @knitkode/api/swr), @koine/api/swr-mutation/createSwrApi (use @knitkode/api/swr-mutation) and the empty @koine/utils/without.
    • @knitkode/dom exports the EventCallback and ListenEvent types (from the package root) used by listen, listenOnce, unlisten and getListeners. Their declarations used to reference these types without shipping them.
    • @knitkode/api/typings now resolves under node16 and nodenext module resolution.
    • Packages are MIT licensed and published from CI with npm provenance.

Patch Changes

  • 2f0b11e Thanks @kuus! - KitCalendarDaygridTable passes key to its week rows and day cells as a prop of its own instead of inside spread props, fixing React's "A props object containing a "key" prop is being spread into JSX" warning. The TableBodyCell and TableBodyCellDate slot props now declare the children they receive.
  • Updated dependencies [2f0b11e]:
    • @knitkode/dom@3.0.0
    • @knitkode/utils@3.0.0

@knitkode/node@3.0.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:19
11c1f22

Major Changes

  • 2f0b11e Thanks @kuus! - First release under the @knitkode npm scope. These packages were previously published as @koine/* (last version 2.0.0-beta.217). Follow the migration guide to upgrade.

    • Packages are renamed from @koine/<name> to @knitkode/<name>. @koine/i18n and @koine/next are not part of kit: internationalization now lives in the separate Koine project.
    • Packages are ESM-only, with no CommonJS builds. Bundlers need no changes. Node.js can still require() them from 20.19 / 22.12. TypeScript users need moduleResolution set to bundler, node16 or nodenext.
    • Only the documented entry points can be imported: the package root and one subpath per module, e.g. @knitkode/utils/isArray. The old *.cjs.js and *.esm.js files and internal paths are gone.
    • Renamed exports: KoineComponent → KitComponent, KoineComponentProps → KitComponentProps, KoineCalendar* → KitCalendar* (@knitkode/react), the global Koine.Api namespace → Kit.Api (@knitkode/api/typings), swcTransformsKoine → swcTransformsKit (@knitkode/node/swc).
    • Removed subpaths: @koine/api/swr/createSwrApi (use @knitkode/api/swr), @koine/api/swr-mutation/createSwrApi (use @knitkode/api/swr-mutation) and the empty @koine/utils/without.
    • @knitkode/dom exports the EventCallback and ListenEvent types (from the package root) used by listen, listenOnce, unlisten and getListeners. Their declarations used to reference these types without shipping them.
    • @knitkode/api/typings now resolves under node16 and nodenext module resolution.
    • Packages are MIT licensed and published from CI with npm provenance.

Patch Changes

  • 2f0b11e Thanks @kuus! - getDependencyVersion reads the dependency's own package.json instead of the first one above its entry file. Dual packages that ship nested package.json files, like glob's dist/commonjs/package.json, no longer return -1. Subpath specifiers such as react-dom/client resolve to their package version.
  • Updated dependencies [2f0b11e]:
    • @knitkode/utils@3.0.0

@knitkode/dom@3.0.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:19
11c1f22

Major Changes

  • 2f0b11e Thanks @kuus! - First release under the @knitkode npm scope. These packages were previously published as @koine/* (last version 2.0.0-beta.217). Follow the migration guide to upgrade.

    • Packages are renamed from @koine/<name> to @knitkode/<name>. @koine/i18n and @koine/next are not part of kit: internationalization now lives in the separate Koine project.
    • Packages are ESM-only, with no CommonJS builds. Bundlers need no changes. Node.js can still require() them from 20.19 / 22.12. TypeScript users need moduleResolution set to bundler, node16 or nodenext.
    • Only the documented entry points can be imported: the package root and one subpath per module, e.g. @knitkode/utils/isArray. The old *.cjs.js and *.esm.js files and internal paths are gone.
    • Renamed exports: KoineComponent → KitComponent, KoineComponentProps → KitComponentProps, KoineCalendar* → KitCalendar* (@knitkode/react), the global Koine.Api namespace → Kit.Api (@knitkode/api/typings), swcTransformsKoine → swcTransformsKit (@knitkode/node/swc).
    • Removed subpaths: @koine/api/swr/createSwrApi (use @knitkode/api/swr), @koine/api/swr-mutation/createSwrApi (use @knitkode/api/swr-mutation) and the empty @koine/utils/without.
    • @knitkode/dom exports the EventCallback and ListenEvent types (from the package root) used by listen, listenOnce, unlisten and getListeners. Their declarations used to reference these types without shipping them.
    • @knitkode/api/typings now resolves under node16 and nodenext module resolution.
    • Packages are MIT licensed and published from CI with npm provenance.

Patch Changes

  • Updated dependencies [2f0b11e]:
    • @knitkode/utils@3.0.0