UNPKG

@small-web/kitten

Version:

Type-safe global Kitten namespace.

403 lines (216 loc) 13.2 kB
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [6.2.2] - 2026-02-19 ### Fixed: - Type errors when compiling with tsc. ### Updated: - ws module types to latest from @types/ws (8.18) – inlined and patched to export `BufferLike` type. - @types/markdown-it to latest version (14.1.2) - @types/node to latest available LTS version (24.10.13) ### Removed: - Separate .mts file in ws module types. ## [6.2.1] - 2026-02-10 ### Changed: - Rename `changeToKeypath` method to `keypathForChange`. Although this is technically a breaking change, given the previous release has been out only a few hours, I’m releasing it as a patch. ## [6.2.0] - 2026-02-10 ### Added: - `kitten.utils.db` namespace with `changeToKeypath` method that converts a JSDB change event string into the dot-separated keypath of the changed property for ease of authoring when listening for events on JSDB tables (e.g., when you want to use the keypath in a `switch` statement). ## [6.1.0] - 2025-05-04 ### Improved: - Updated Kitten Icons from version 6.0.0 to 6.1.0. The `categories` and `tags` objects are no longer enumerable so they don’t pollute the `kitten.icons` namespace (e.g., when you’re iterating through all icons). You can still refer to them directly. The recommended practice is the use the `categories` and `tags` objects during authoring to help you find the right icon but to reference icons directly from the root `kitten.icons` namespace in your code. ## [6.0.0] - 2025-05-02 ### Breaking change: - Updated Kitten Icons from version 5 to 6. The icon catalog is now a flat hash table and not sharded alphabetically. ## [5.5.1] - 2024-04-09 ### Improved: - Uses newly-generated types in Kitten Icons package. ## [5.5.0] - 2024-04-07 ### Added: - Type information for new `kitten.icons` object. ## [5.4.2] - 2025-04-01 ### Fixed: - Previous fix. Instead of erroneously altering the interface of `kitten.html`, `KittenPage`’s `send()` method now accepts a promise to keep the type system happy. ## [5.4.1] - 2025-04-01 ### Fixed: - Added `BufferLike` to `kitten.html` interface so it can be used without warnings or casting with the `send()` call on Kitten page instances. ## [5.4.0] - 2025-03-31 ### Changed: - Regular `kitten.html` tagged template strings as well as the `html()` render methods of `KittenComponent` and `KittenPage` instances may now all be asynchronous. ## [5.3.0] - 2025-03-28 ### Fixed: - Now properly types `html()` render function on `KittenPage` instances as either returning a value or a promise (either sync or async). ## [5.2.0] - 2025-01-30 ### Added: All missing type information for `KittenRequest` and `KittenResponse` interfaces (the methods injected via Kitten middleware into Polka’s request and response objects): #### KittenRequest - `is()`: check for request type. e.g., `request.is('html')` or `request.is('json')` (you can also use the full mimetype). #### KittenResponse - `json()`: JSON.stringify passed data and end response with inline JSON. - `jsonFile()`: JSON.stringify passed data and end response with JSON attachment and optional file name. - `file()`: end response with passed file data and optional file name and mime type. - `withCode()`: end response with passed status code and optional body. ## [5.1.0] - 2025-01-27 ### Added: Type information for: - `remove()` method on `KittenComponent` class. - `isAttached` property on `KittenComponent` class. - `isConnected` property on `KittenComponent` class. ### Updated: - `send()` method signature on `MessageSender` to include second argument (`swapTarget`). ## [5.0.0] - 2025-01-27 ### Breaking changes - `KittenComponent` class’s static `connectedTo()` method’s signature is now limited to accepting a `data` object as the second argument. ### Changed: - `KittenPage`’s `send()` instance method now accepts a second argument (`swapTarget`), which is an object that can contain one of `before`, `after`, `asFirstChildOf`, and `asLastChildOf` properties. The value is the CSS selector of the element in the DOM that the component is to be inserted relative to. ### Added: - `KittenComponent`’s new `data` property - `KittenComponent`’s new `onLoad()` handler (optional hook) ### Improved: - Method documentation; including updated behaviour of `onConnect()` handlers now getting called when a component is added to the component hierarchy of a connected page. (Previously, it would only be called for components that were already on the page on initial render, when the page first connected.) ## [4.0.10] - 2025-01-15 ### Fixed: - `KittenComponent` class’s static `connectedTo()` method’s signature to allow subclasses to add parameters to signature. ## [4.0.9] - 2025-01-15 ### Added: - Missing `requests`, `pages`, and `utils` properties on global `kitten` reference. ## [4.0.8] - 2025-01-15 ### Added: - Missing `addChild()` method on `KittenComponent` class. ## [4.0.7] - 2025-01-15 ### Added: - Missing `id` and `redirectToAfterSignIn` properties on `Session` class. ## [4.0.6] - 2025-01-15 ### Fixed: - `html()` render function signature in `KittenComponent` type information. ### Added: - Exports for `KittenComponent` and `KittenPage` types. ## [4.0.5] - 2025-01-15 ### Fixed: - Add file extensions to all relative import paths so types work when `--moduleResolution` is set to `node16` or `nodenext` in Kitten project’s _jsconfig.json_. ## [4.0.4] - 2025-01-14 ### Updated: - `Session` class type information now reflects that it extends `EventEmitter` (from `node:events`). ([#11](https://codeberg.org/kitten/globals/issues/11)) ## [4.0.3] - 2025-01-14 ### Added: - Type information for `Session.challenge` ([#10](https://codeberg.org/kitten/globals/issues/10)) ## [4.0.2] - 2025-01-14 ### Fixed: - All static warnings/errors in types file (and thus in project). - Formatting (indentation issues). ### Changed: - `KittenPage.data` from `{}` to type `Record<string, any>` ([#6](https://codeberg.org/kitten/globals/issues/6)) ### Added: - `kitten.crypto.random32ByteTokenInHex` ([#7](https://codeberg.org/kitten/globals/issues/7)) - `session`, `request`, and `response` properties to `KittenPage` ([#8](https://codeberg.org/kitten/globals/issues/8)) - Missing type information for `kitten._db`, the project-specific internal Kitten database ([#9](https://codeberg.org/kitten/globals/issues/9)) ## [4.0.1] - 2025-01-14 ### Fixed: - Add missing `Page` reference to global `kitten` object. ## [4.0.0] - 2025-01-14 ### Breaking changes: - `PageSocket` and `UnconnectedPage` have been removed, replaced with global `kitten.Page` export of new `KittenPage` class. ([#5](https://codeberg.org/kitten/globals/issues/5)) - `KittenComponent` has been updated to reflect its latest implementation in Kitten. ### Fixed: - The examples in README have been updated to reflect modern Kitten syntax. ### Improved: - Added links to relevant reference documentation and tutorials on Kitten web site. ## [3.1.1] - 2024-08-28 ### Changed: - Cast `Upload` type to instance not type/class as it is not intended to be instantiated or extended in Kitten apps. (We have to choose between having it be seen as an instance or type/class due to this TypeScript bug: https://github.com/jsdoc/jsdoc/issues/1349#issuecomment-1725400751. Having it seen as an instance should thus work properly for the intended usage.) ## [3.1.0] - 2024-08-28 ### Added: - Type definitions for new `updateOnEvent()` and `sendUpdatedComponentToPage()` methods on `kitten.Component` instances. - `UnconnectedPage` and `PageSocket` definitions, which are the types of the `page` property initially received by your default page route before the socket has connected and the one received by your `onConnect()` handler when it has. They both carry references to the page’s `id` and `data` objects so you can use them to share page data between the initial page render and future page updates via [Kitten’s Streaming HTML workflow](https://kitten.small-web.org/tutorials/streaming-html/). ## [3.0.4] - 2024-08-27 ### Fixed: - Added missing type information for `kitten.crypto` module. ## [3.0.3] - 2024-08-27 ### Fixed: - Added missing type information for `component` accessor on `kitten.Component`. - Fix type errors on `yaml` module and markdown-it export. - Add @types/node to fix warning in ws types. - Remove unused (inlined) `ParsedURL` and `Trouter` type definitions in Polka types. - Fixed multiple exports issue in inlined Polka types. ## [3.0.2] - 2024-07-30 ### Fixed: - Added missing type information for `connectedTo()` method on `kitten.Component`. ## [3.0.1] - 2024-07-30 ### Fixed: - Methods that return the result of a `kitten.html` tagged template string are now correctly marked as returning either a string or an array of strings. ## [3.0.0] - 2024-07-30 ### Breaking changes: - __Removes copy of Upload class.__ The latest Kitten now exposes the Upload class globally itself and this library just wraps it (as it should). ### Added: Type definitions for: - `kitten.Component` - `kitten.md` - `kitten.yaml` - `kitten.slugify` - `kitten.paths` - `kitten._db.settings` - `kitten.app` - `kitten.deploy` - `kitten.libraries.htmxIdiomorph` - `kitten.deprecationWarnings` - `kitten.appRepository` - `kitten.automaticUpdates` - `kitten.package` ### Fixed: - Added missing `length` method to `Uploads` type. ## [2.10.2] - 2023-11-26 __Fix:__ Reference `version` correctly (from under `kitten` namespace). __Add:__ All `version` properties and methods from new Version class. ## [2.10.1] - 2023-11-16 __Change:__ The `version.date` property is now a `Date` instance instead of a string date stamp. ## [2.10.0] - 2023-11-16 __Add:__ `version` property that has current Kitten version information. ## [2.9.0] - 2023-11-03 __Add:__ `downloadPath` property that serves an uploaded file using `content-disposition: attachment` instead of the default `content-disposition: inline` used by the `resourcePath` property. ## [2.8.1] - 2023-11-01 __Change:__ Include concrete class implementation of Upload instead of just its type definition as it is required when storing Upload instances in custom databases in Kitten apps. ## [2.8.0] - 2023-10-31 __Add:__ Add `resourcePath` property and `delete()` method to `Upload` type. ## [2.7.1] - 2023-10-30 __Fix:__ Reference to `uploads` object now targets `_db`, as it should, instead of `db`. ## [2.7.0] - 2023-10-27 __Add:__ `kitten.uploads` `delete()` method. ## [2.6.0] - 2023-10-27 __Add:__ `Upload` type. ## [2.5.2] - 2023-10-27 __Fix:__ Upload type field name (`name``fileName`). ## [2.5.1] - 2023-10-21 __Fix:__ Method signatures for `KittenRequest`. ## [2.5.0] - 2023-10-04 __Add:__ Type information for Kitten internal uploads table (exposed publicly at `kitten.uploads`). ## [2.4.0] - 2023-09-20 __Change:__ Remove `Session` and `Upload` classes; they do not need to be public. __Add:__ Type definitions for `KittenRequest`, `KittenPostRequest`, and `KittenResponse`. You can now take advantage of type safe request and response objects in your routes using these definitions. ## [2.3.2] - 2023-09-20 __Fix:__ Do not export `SessionInstance` and `UploadInstance` types as they are types, not values. ## [2.3.1] - 2023-09-19 __Fix:__ Use @typedefs to properly declare `SessionInstance` and `UploadInstance` classes. ## [2.3.0] - 2023-09-19 Add type safety for internal `_db` database and also expose `Session` and `Upload` classes and, [due to an unfortunate limitation of JSDoc](https://github.com/jsdoc/jsdoc/issues/1349#issuecomment-1725400751), `SessionInstance` and `UploadInstance` types as well. ## [2.2.0] - 2023-09-06 Add `domain`, `port`, `databaseDirectory`, `projectIdentifier`, `WebSocket`, and `Session` to default export. Previously, these were kept out of the default export to reduce clutter during authoring but it actually leads to errors as the expectation is that the default export contents match the totality of the individually-exported objects. The only exception to this at the moment is that the legacy all-uppercase library and page contants are not included in the default export as these are deprecated and included for now only for backwards compatibility. ## [2.1.0] - 2023-09-04 Add new Kitten internal `_db` database reference. ## [2.0.0] - 2023-08-23 __Breaking change:__ Use new `kitten` namespace. ## [1.2.0] - 2023-07-22 Add Events (global EventDispatcher instance). ## [1.1.0] - 2023-04-17 Page slot constants. ### Changed - Export [page slot constants](https://codeberg.org/kitten/app#special-page-slots) under `PAGE` object. ## [1.0.1] - 2023-04-14 Add types file to make TypeScript language server (LSP) happy. ### Changed - Add types for TypeScript Language Server. ## [1.0.0] - 2023-04-14 Initial release.