feat!: Release 5.0.0#79
Open
untemps wants to merge 9 commits into
Open
Conversation
BREAKING CHANGE: wait() now clears internal state synchronously before the Promise resolves, instead of relying on .finally() for deferred cleanup.
Before:
const { node } = await obs.wait('#foo')
obs.isObserving // true — observer still running at this point
After:
const { node } = await obs.wait('#foo')
obs.isObserving // false — cleared before promise settles
Affected scenarios:
- Code checking obs.isObserving === true after await obs.wait() must update that expectation to false.
- Code calling obs.clear() after wait() resolves continues to work (no-op).
- Code relying on the timeout timer firing after resolution: cleanup now happens at resolution time, not when the timer would have expired.
BREAKING CHANGE: DOMObserverErrors constants and DOMObserverErrorCode type are removed. All throws and rejections now use typed Error subclasses. Consumers who matched on error message strings must migrate to instanceof checks. Error messages no longer carry [TIMEOUT]/[ABORT]/[EVENTS]/[TARGET] prefixes. The AbortSignal rejection path (DOMException, name: 'AbortError') is unchanged.
BREAKING CHANGE: OnEventCallback and FilterCallback now receive a single EventPayload object instead of three positional arguments.
Before:
obs.watch('#foo', (node, event, options) => { ... })
obs.watch('#foo', (node, event, options) => { ... }, { filter: (node, event, options) => ... })
After:
obs.watch('#foo', ({ node, event, options }) => { ... })
obs.watch('#foo', ({ node, event, options }) => { ... }, { filter: ({ node, event, options }) => ... }
Migration is mechanical: wrap the parameter list in braces.
The EventPayload type is exported for explicit annotation.
…#75) BREAKING CHANGE: EventPayload and WaitResult are now type aliases, not interfaces. Code using `extends EventPayload`, `extends WaitResult`, or `implements` either type must migrate to intersection types: // Before interface MyPayload extends EventPayload { extra: string } // After type MyPayload = EventPayload & { extra: string } Code that accesses `options?.attributeName` defensively continues to compile without changes.
…const (#76) BREAKING CHANGE: Static class properties removed. Migration: DOMObserver.ADD → DOMObserverEvent.ADD DOMObserver.EXIST → DOMObserverEvent.EXIST DOMObserver.REMOVE → DOMObserverEvent.REMOVE DOMObserver.CHANGE → DOMObserverEvent.CHANGE DOMObserver.EVENTS → DOMObserverEvents type DOMObserverEvent → type DOMObserverEventValue A global find-and-replace handles most cases. The type rename only affects code that references DOMObserverEvent as a TypeScript type (not as a value).
… export (#77) BREAKING CHANGE: The DOMObserver class is no longer exported. Migration: import { DOMObserver } from '@untemps/dom-observer' const obs = new DOMObserver() let obs: DOMObserver → import { createDOMObserver, type DOMObserverInstance } from '@untemps/dom-observer' const obs = createDOMObserver() let obs: DOMObserverInstance
BREAKING CHANGE: Three methods and three types renamed. Migration: .watch(target, cb, opts) → .observe(target, cb, opts) .wait(target, opts) → .observeOnce(target, opts) .clear() → .disconnect() WatchOptions → ObserveOptions WaitOptions → ObserveOnceOptions WaitResult → ObserveOnceResult
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Promotes the
betabranch to a stable5.0.0release. This PR contains all breaking changes accumulated across the beta cycle, with automation commits (chore(release): X.X.X-beta.Y) stripped from the history.Changes
feat: Auto-disconnect observer afterobserveOnce()resolves (feat(wait)!: Auto-disconnect observer after wait() resolves #70)feat: Replace magic string errors with typed Error subclasses (feat(errors)!: Replace magic string errors with typed Error subclasses #71)feat: Change callback signature to singleEventPayloadobject (feat(watch)!: Change callback signature to single payload object #72)feat: Make callback payload a discriminated union based on event type (feat(types)!: Make callback payload a discriminated union based on event type #75)feat: Replace static class properties with exportedDOMObserverEventconst (feat(events)!: Replace static class properties with exported DOMObserverEvent const #76)feat: ExposecreateDOMObserver()factory and removeDOMObserverclass export (feat!: Expose createDOMObserver() factory and remove DOMObserver class export #77)feat: Renamewatch/wait/cleartoobserve/observeOnce/disconnect(feat!: Rename watch/wait/clear to observe/observeOnce/disconnect #78)Typed errors —
DOMObserverErrorsconstants removed. Useinstanceofchecks.Callback signature — Single
EventPayloadobject replaces positional arguments.Event constants — Static class properties removed.
Factory API —
DOMObserverclass no longer exported.Method renames
Test plan
.d.tsdeclarations