Skip to content

✨ node-first Api with middleware over Context - #18

Closed
cowboyd wants to merge 1 commit into
mainfrom
tree-api
Closed

cowboyd wants to merge 1 commit into
mainfrom
tree-api

Conversation

@cowboyd

@cowboyd cowboyd commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Context can carry values through a tree, but Bombshell also needs behavior that can be extended within a subtree. Built-in elements, third-party elements, rendering policies, and framework integrations should all be able to participate in semantic operations without subclassing a central object or modifying the core implementation. A node-first API with inherited middleware makes that extension mechanism uniform across every subsystem added later.

Middleware remains correctly composed when a child already has local behavior and an ancestor is extended afterward. That property is essential for independently installed plugins and framework roots: extensions can be assembled in any practical order without duplicating inherited middleware or losing child-specific behavior.

import { createApi } from './core.ts';

const MeasureApi = createApi('measure', {
	measure(_node): number {
		return 0;
	},
});

MeasureApi.around(subtree, {
	measure([node], next) {
		return next(node) + 1;
	},
});

This PR adds createApi(), node-first invocation, and inherited around() middleware to the internal UI core. Tests verify middleware ordering, delegation, subtree inheritance, late ancestor installation, and composition with middleware already installed on descendants.

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

commit: 41100c6

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments, thanks in advance Charles 💜

Comment thread packages/ui/src/core/api.ts Resolved
Comment thread packages/ui/src/core/api.ts Resolved
Comment thread packages/ui/src/core/api.ts Resolved

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's wait for other peeps to catch up @cowboyd 😄

@43081j

43081j commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Just noting I would like to review before we merge too 👍 I'll take a look tomorrow

Comment thread packages/ui/src/core/api.ts Outdated
@@ -0,0 +1,167 @@
// oxlint-disable no-explicit-any

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not, as it just means we're starting with a low bar.

use unknown where you genuinely don't know what the type is, and use never where you're trying to store/accept variable functions.

here's an example

@cowboyd

cowboyd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

closing out in favor of a DOM based substrate. See #37

@cowboyd cowboyd closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants