diff --git a/CHANGELOG.md b/CHANGELOG.md index 84df9b87..434b85cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format ## [Unreleased] +## [v3.0.0-beta.1](https://github.com/studiometa/js-toolkit/compare/3.0.0-beta.0..3.0.0-beta.1) (2024-11-18) + +### Fixed + +- Fix importing the services in SSR context ([#540](https://github.com/studiometa/js-toolkit/pull/540), [69c8d2b9](https://github.com/studiometa/js-toolkit/commit/69c8d2b9)) + ## [v3.0.0-beta.0](https://github.com/studiometa/js-toolkit/compare/3.0.0-alpha.12..3.0.0-beta.0) (2024-11-16) ### Changed diff --git a/package-lock.json b/package-lock.json index 17bcd27b..7d39b4aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@studiometa/js-toolkit-workspace", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@studiometa/js-toolkit-workspace", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "workspaces": [ "packages/*" ], @@ -21593,7 +21593,7 @@ }, "packages/demo": { "name": "@studiometa/js-toolkit-demo", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "dependencies": { "@studiometa/ui": "^1.0.0-alpha.12", "tailwindcss": "^3.4.14" @@ -21612,7 +21612,7 @@ }, "packages/docs": { "name": "@studiometa/js-toolkit-docs", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "dependencies": { "@studiometa/tailwind-config": "^2.1.0", "tailwindcss": "^3.4.14", @@ -21621,7 +21621,7 @@ }, "packages/js-toolkit": { "name": "@studiometa/js-toolkit", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "license": "MIT", "dependencies": { "@motionone/easing": "^10.18.0", @@ -21630,7 +21630,7 @@ }, "packages/tests": { "name": "@studiometa/js-toolkit-tests", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "dependencies": { "@happy-dom/global-registrator": "^15.11.0", "@jest/fake-timers": "^29.7.0", diff --git a/package.json b/package.json index 82bfa575..5b9154e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@studiometa/js-toolkit-workspace", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "private": true, "type": "module", "workspaces": [ diff --git a/packages/demo/package.json b/packages/demo/package.json index 26aafb0c..bafc8009 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -1,6 +1,6 @@ { "name": "@studiometa/js-toolkit-demo", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "private": true, "type": "module", "scripts": { diff --git a/packages/docs/package.json b/packages/docs/package.json index dfb7c1bb..ed0c51b9 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,6 +1,6 @@ { "name": "@studiometa/js-toolkit-docs", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "type": "module", "private": true, "scripts": { diff --git a/packages/js-toolkit/package.json b/packages/js-toolkit/package.json index bcb5e06f..519169e7 100644 --- a/packages/js-toolkit/package.json +++ b/packages/js-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@studiometa/js-toolkit", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "description": "A set of useful little bits of JavaScript to boost your project! 🚀", "publishConfig": { "access": "public" diff --git a/packages/js-toolkit/services/AbstractService.ts b/packages/js-toolkit/services/AbstractService.ts index 474a2949..3784966f 100644 --- a/packages/js-toolkit/services/AbstractService.ts +++ b/packages/js-toolkit/services/AbstractService.ts @@ -1,5 +1,3 @@ -import { isFunction } from '../utils/index.js'; - export interface ServiceInterface { /** * Remove a function from the resize service by its key. @@ -23,7 +21,7 @@ export interface ServiceInterface { * Service configuration of events to be attached to targets. */ export type ServiceConfig = [ - EventTarget | ((instance: AbstractService) => EventTarget), + ((instance: AbstractService) => EventTarget), [string, AddEventListenerOptions?][], ][]; @@ -147,7 +145,7 @@ export class AbstractService { */ __manageEvents(mode: 'add' | 'remove') { for (const [target, events] of this.constructor.config) { - const resolvedTarget = isFunction(target) ? target(this) : target; + const resolvedTarget = target(this); for (const [type, options] of events) { resolvedTarget[`${mode}EventListener`](type, this, options); } diff --git a/packages/js-toolkit/services/DragService.ts b/packages/js-toolkit/services/DragService.ts index 3d2e43b7..aef384bc 100644 --- a/packages/js-toolkit/services/DragService.ts +++ b/packages/js-toolkit/services/DragService.ts @@ -77,7 +77,7 @@ export class DragService extends AbstractService { ], ], [ - window, + () => window, [ ['pointerup', PASSIVE_EVENT_OPTIONS], ['touchend', PASSIVE_EVENT_OPTIONS], diff --git a/packages/js-toolkit/services/KeyService.ts b/packages/js-toolkit/services/KeyService.ts index 8b409062..21a2473a 100644 --- a/packages/js-toolkit/services/KeyService.ts +++ b/packages/js-toolkit/services/KeyService.ts @@ -28,7 +28,7 @@ export interface KeyServiceProps { export type KeyServiceInterface = ServiceInterface; export class KeyService extends AbstractService { - static config: ServiceConfig = [[document, [['keydown'], ['keyup']]]]; + static config: ServiceConfig = [[() => document, [['keydown'], ['keyup']]]]; previousEvent: Event | null = null; diff --git a/packages/js-toolkit/services/LoadService.ts b/packages/js-toolkit/services/LoadService.ts index 3a268be1..239db743 100644 --- a/packages/js-toolkit/services/LoadService.ts +++ b/packages/js-toolkit/services/LoadService.ts @@ -8,7 +8,7 @@ export interface LoadServiceProps { export type LoadServiceInterface = ServiceInterface; export class LoadService extends AbstractService { - static config: ServiceConfig = [[window, [['load']]]]; + static config: ServiceConfig = [[() => window, [['load']]]]; props: LoadServiceProps = { time: performance.now(), diff --git a/packages/js-toolkit/services/PointerService.ts b/packages/js-toolkit/services/PointerService.ts index 3999c1a2..8608ada6 100644 --- a/packages/js-toolkit/services/PointerService.ts +++ b/packages/js-toolkit/services/PointerService.ts @@ -19,7 +19,7 @@ export type PointerServiceInterface = ServiceInterface; export class PointerService extends AbstractService { static config: ServiceConfig = [ [ - document, + () => document, [ ['mouseenter', ONCE_CAPTURE_EVENT_OPTIONS], ['mousemove', PASSIVE_CAPTURE_EVENT_OPTIONS], diff --git a/packages/js-toolkit/services/ResizeService.ts b/packages/js-toolkit/services/ResizeService.ts index fe98ca32..c6e87d08 100644 --- a/packages/js-toolkit/services/ResizeService.ts +++ b/packages/js-toolkit/services/ResizeService.ts @@ -20,7 +20,7 @@ export type ResizeServiceInterface extends AbstractService { - static config: ServiceConfig = [[window, [['resize']]]]; + static config: ServiceConfig = [[() => window, [['resize']]]]; breakpoints: T; diff --git a/packages/js-toolkit/services/ScrollService.ts b/packages/js-toolkit/services/ScrollService.ts index 0c2a8b93..b3b53552 100644 --- a/packages/js-toolkit/services/ScrollService.ts +++ b/packages/js-toolkit/services/ScrollService.ts @@ -31,7 +31,7 @@ export interface ScrollServiceProps { export type ScrollServiceInterface = ServiceInterface; export class ScrollService extends AbstractService { - static config: ServiceConfig = [[document, [['scroll', PASSIVE_CAPTURE_EVENT_OPTIONS]]]]; + static config: ServiceConfig = [[() => document, [['scroll', PASSIVE_CAPTURE_EVENT_OPTIONS]]]]; props: ScrollServiceProps = { x: window.scrollX, diff --git a/packages/tests/package.json b/packages/tests/package.json index 2ce66fab..6e7bcfc8 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -1,6 +1,6 @@ { "name": "@studiometa/js-toolkit-tests", - "version": "3.0.0-beta.0", + "version": "3.0.0-beta.1", "private": true, "type": "module", "scripts": {