-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VNode.children should allow more range. #17
Comments
An example of where this is used is @virtualstate/kdl where the representation does not need to be modified to be used with a generic KDL query. |
The input & output of the above, with no {
source: "name",
options: {
attribute: "value",
value: 1
},
children: [
{
type: "main",
children: [
{
$$type: "section",
props: {
id: "main-section"
},
children: {
async *[Symbol.asyncIterator]() {
yield [
{
type: "h1",
children: [
"hello",
"world"
]
},
"whats up"
]
}
}
}
]
}
]
}
This tree could then be queried section[prop(id) = "main-section"] h1
To maintain complete consistency, the current |
https://github.com/virtualstate/focus is an implementation that supports any (within the defined keys, open a PR if you know allowing for const multiTree = {
source: "name",
options: {
attribute: "value",
value: 1,
},
children: [
{
type: "main",
children: [
{
$$type: "section",
props: {
id: "main-section",
},
children: {
async *[Symbol.asyncIterator]() {
yield [
{
type: "h1",
children: ["hello", "world"],
},
"whats up",
];
},
},
},
<footer id="foot">Footer content</footer>,
proxyH("test-proxy", { id: "test-proxy" }, "test"),
staticH("test-static", { id: "test-static" }, "test"),
staticH(
async function* Component(props: unknown) {
yield `component 1 ${JSON.stringify({ props })}`;
},
{ id: "component" }
),
],
},
],
}; This is generic jsx, the input defines how the output will look like. This completely drops the concept of |
fringe will be: import { h as f, ProxyContext, children as fChildren, isStaticChildNode } from "@virtualstate/focus";
/* some children implementation that maps scalar */
async function *children(node: unknown) {
for await (const snapshot of fChildren(node)) {
yield snapshot.map(source => isStaticChildNode(value) ? scalar(source): source)
}
}
function scalar(value: unknown) {
return f(value, { ...options, [ProxyContext]: { scalar() { return true } } });
}
export function h(source?: unknown, options?: Record<string | symbol, unknown>, ...children: unknown[]) {
return f(source, { ...options, [ProxyContext]: { children } }, ...children);
} Once this has been verified working, semver minor can happen with a full replacement, focus will become included into this repo After minor, Examples referencing scalars will be dropped |
It may be beneficial for the options of |
|
🚀 Feature Proposal
Update the type signature of VNode to
This opens up compatibility, an introduces "scalar" values as immediately represented values with no abstraction.
I believe this would also reduce the requirement to understand why we might want to wrap these (which was only to maintain a type definition, which may be easier to do now!)
Motivation
Currently children is transformed to maintain a consistent reading pattern, if read functions are provided through #16 there is less of a reason to enforce that children must be wrapped nodes for no gain.
Example
These native representations should require zero transformation from the implementation of @virtualstate/fringe, and instead now can be directly read using read functions instead.
Read functions should include a function that creates a consistent node with a strict type, however it should not be needed in the majority of cases.
The text was updated successfully, but these errors were encountered: