-
-
Notifications
You must be signed in to change notification settings - Fork 926
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
v3 proposal #2982
base: main
Are you sure you want to change the base?
v3 proposal #2982
Commits on Sep 26, 2024
-
Configuration menu - View commit details
-
Copy full SHA for c636c2f - Browse repository at this point
Copy the full SHA c636c2fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e97cc9 - Browse repository at this point
Copy the full SHA 3e97cc9View commit details -
Configuration menu - View commit details
-
Copy full SHA for f07feb9 - Browse repository at this point
Copy the full SHA f07feb9View commit details -
Add duplicate key check, deduplicate code, use ES6
Perf is somewhat improved in spots, but generally the same otherwise.
Configuration menu - View commit details
-
Copy full SHA for f291d28 - Browse repository at this point
Copy the full SHA f291d28View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0106367 - Browse repository at this point
Copy the full SHA 0106367View commit details -
Cuts only about 2% of the bundle, but removes a pretty bad pain point in the code. Plus, inserting arbitrary HTML outside a container is usually a recipe for disaster in terms of styling.
Configuration menu - View commit details
-
Copy full SHA for c3e90f5 - Browse repository at this point
Copy the full SHA c3e90f5View commit details
Commits on Sep 27, 2024
-
Configuration menu - View commit details
-
Copy full SHA for ca65f7a - Browse repository at this point
Copy the full SHA ca65f7aView commit details
Commits on Oct 2, 2024
-
Configuration menu - View commit details
-
Copy full SHA for e9fad45 - Browse repository at this point
Copy the full SHA e9fad45View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2707de3 - Browse repository at this point
Copy the full SHA 2707de3View commit details -
Configuration menu - View commit details
-
Copy full SHA for ae28e2a - Browse repository at this point
Copy the full SHA ae28e2aView commit details -
Move state object creation to hyperscript
It's simpler that way and I don't have to condition it.
Configuration menu - View commit details
-
Copy full SHA for 7aca843 - Browse repository at this point
Copy the full SHA 7aca843View commit details -
Move
m.render
out of initialization closureIt's redundant and has been for ages. A v3 increment gives me the ability to minimize surprise.
Configuration menu - View commit details
-
Copy full SHA for b724902 - Browse repository at this point
Copy the full SHA b724902View commit details
Commits on Oct 3, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3ade35c - Browse repository at this point
Copy the full SHA 3ade35cView commit details -
Migrate
m.buildPathname
tom.p
and remove the path params argumen……t from the router
Configuration menu - View commit details
-
Copy full SHA for a452105 - Browse repository at this point
Copy the full SHA a452105View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8c619c3 - Browse repository at this point
Copy the full SHA 8c619c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1b0818e - Browse repository at this point
Copy the full SHA 1b0818eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6caacf2 - Browse repository at this point
Copy the full SHA 6caacf2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 57edf21 - Browse repository at this point
Copy the full SHA 57edf21View commit details -
Toss the "route" part of the router
People can just use equality and regexps as needed.
Configuration menu - View commit details
-
Copy full SHA for 6b3c7b3 - Browse repository at this point
Copy the full SHA 6b3c7b3View commit details -
Merge
Vnode
with the hyperscript moduleAlso, rename it `m` to make dev stack traces a little more readable, and remove a useless layer of indirection.
Configuration menu - View commit details
-
Copy full SHA for ccea9a1 - Browse repository at this point
Copy the full SHA ccea9a1View commit details -
Configuration menu - View commit details
-
Copy full SHA for dae2208 - Browse repository at this point
Copy the full SHA dae2208View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3668dc7 - Browse repository at this point
Copy the full SHA 3668dc7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 03fd640 - Browse repository at this point
Copy the full SHA 03fd640View commit details -
Configuration menu - View commit details
-
Copy full SHA for eb0031c - Browse repository at this point
Copy the full SHA eb0031cView commit details -
Make the event dictionary a proper class
This makes that class fully monomorphic and also a bit safer.
Configuration menu - View commit details
-
Copy full SHA for b04519d - Browse repository at this point
Copy the full SHA b04519dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8fbc46a - Browse repository at this point
Copy the full SHA 8fbc46aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1418bd3 - Browse repository at this point
Copy the full SHA 1418bd3View commit details -
Add
m.tracked
utility for tracking delayed removalsThe long comment at the top of it explains the motivation.
Configuration menu - View commit details
-
Copy full SHA for 13c2e63 - Browse repository at this point
Copy the full SHA 13c2e63View commit details -
Configuration menu - View commit details
-
Copy full SHA for cd20a00 - Browse repository at this point
Copy the full SHA cd20a00View commit details -
It's now been made redundant with `m.tracked`.
Configuration menu - View commit details
-
Copy full SHA for 454f8e7 - Browse repository at this point
Copy the full SHA 454f8e7View commit details
Commits on Oct 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 60de2e1 - Browse repository at this point
Copy the full SHA 60de2e1View commit details -
Dropping a premature abstraction, and I have perf concerns. This new version should hopefully avoid needing arguments allocation
Configuration menu - View commit details
-
Copy full SHA for 1efdb78 - Browse repository at this point
Copy the full SHA 1efdb78View commit details -
Configuration menu - View commit details
-
Copy full SHA for 537f828 - Browse repository at this point
Copy the full SHA 537f828View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9070429 - Browse repository at this point
Copy the full SHA 9070429View commit details -
Drop
oninit
, replace all remaining lifecycle methods withm.layout
If you remember v0.2, you'll recognize the API here. Thing is, this tries to be a little more rigorous with it by making it a proper vnode instead of just a magic attribute. Also, as these are the last remaining magic attributes (and `m.route.link` just returns the needed attributes itself), `m.censor` is gone.
Configuration menu - View commit details
-
Copy full SHA for 5c2bf31 - Browse repository at this point
Copy the full SHA 5c2bf31View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2942ea5 - Browse repository at this point
Copy the full SHA 2942ea5View commit details -
Add
m.init
andm.use
convenience utilities, simplify fragments, f……ix a renderer bug
Configuration menu - View commit details
-
Copy full SHA for 168b403 - Browse repository at this point
Copy the full SHA 168b403View commit details -
Migrate components to simple functions and closures
Part of this meant moving children to an attribute property. I've also added a translation layer of sorts so one can pass them through to DOM vnodes and them "just work", even though the internal structure separates attributes and children. All in all, this should hopefully result in a lot less memory usage and some faster app load times.
Configuration menu - View commit details
-
Copy full SHA for b168f74 - Browse repository at this point
Copy the full SHA b168f74View commit details -
Configuration menu - View commit details
-
Copy full SHA for d652f98 - Browse repository at this point
Copy the full SHA d652f98View commit details -
Configuration menu - View commit details
-
Copy full SHA for bd09d8a - Browse repository at this point
Copy the full SHA bd09d8aView commit details
Commits on Oct 5, 2024
-
They weren't actually testing the update flow, only reliably the create flow. Also, they weren't testing `m.mount`, or `m.redraw` in their totality, which is honestly a very important thing to test.
Configuration menu - View commit details
-
Copy full SHA for 933d4b5 - Browse repository at this point
Copy the full SHA 933d4b5View commit details -
Simplify the keyed diff fuzzer
It shouldn't be testing particular implementation details, just that it works. Also, this one's more likely to exhaustively hit every possibility.
Configuration menu - View commit details
-
Copy full SHA for d7d8bef - Browse repository at this point
Copy the full SHA d7d8befView commit details -
Configuration menu - View commit details
-
Copy full SHA for 67a30f4 - Browse repository at this point
Copy the full SHA 67a30f4View commit details -
Split code + tests, move source into dedicated directory
Aims to ease discoverability. Plus, it's a bit easier to navigate.
Configuration menu - View commit details
-
Copy full SHA for 84b0950 - Browse repository at this point
Copy the full SHA 84b0950View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49ec364 - Browse repository at this point
Copy the full SHA 49ec364View commit details
Commits on Oct 6, 2024
-
Knock out all the intermediate closures, do a better job cleaning up,…
… revise a few more things
Configuration menu - View commit details
-
Copy full SHA for 55a8071 - Browse repository at this point
Copy the full SHA 55a8071View commit details -
Try to get a better profile view
Didn't fully think through that experiment of file loading - it doesn't also load Mithril, among other things. Also, remove some redundant conditionals in `src/core.js`.
Configuration menu - View commit details
-
Copy full SHA for c0821cb - Browse repository at this point
Copy the full SHA c0821cbView commit details
Commits on Oct 11, 2024
-
Improve bundle size, move to type masks to boost performance
- `function foo(...) {...}` to `var foo = (...) => {...}` saved a fair bit of space. I also replaced other ES5 `function` functions with arrow functions where possible. - I inlined several functions. Turns out Terser wasn't inlining them properly (they were getting nonsensically inlined as IIFEs), and it was causing performance to suffer. - I dropped the `contenteditable` code, since that was only needed to handle the since-dropped `m.trust`. - I switched from tag names to type masks. This enabled several optimizations. - Size: I switched from a `switch` to function tables for create and update. Now, it just hinges on how well the CPU predicts it, and modern desktop CPUs very much can chase such multi-level indirect branches. - Size: I could blend single-key diffs with element and component tag name diffs, for better performance. - Performance: By using an expando bit, I've avoided needing to read the current namespace in some pretty hot loops, including in `setAttr`. - Performance: In `setAttr` and other places, I've merged as many as 4 tag comparisons to a single bit comparison. - I truncated the vnode properties to single letters. This resulted in a moderate savings. - I moved `redraw` to a return value of `m.mount` and also passed it via a context value to components so they can deal with non-global redraws. - I re-split `m.layout`. I also swapped out the benchmark library for something I rolled myself, and used that to set up the benchmarks. Benchmark.js isn't maintained anymore, its built-in output wasn't all that great, and it was forcing me to use globals where I otherwise didn't really need to, so I decided to roll some statistics stuff myself and make something simple. And while I was at it, I simplified the benchmark code by a lot. I also ripped out the select/option Chrome bug workaround - it doesn't seem to replicate anymore. Removing that brought a slight boost to attribute setting performance and enabled me to factor that code out to something a lot simpler. Try this page for example: ```html <!doctype html> <select> <option value="foo">Foo</option> <option value="bar">Bar</option> <option value="baz">Baz</option> </select> <script> var select = document.querySelector("select") console.log("s", select.selectedIndex, select.value) select.onchange = select.onclick = select.onblur = () => { console.log("c", select.selectedIndex, select.value) } var second = select.children[1] setInterval(() => { console.log("i", select.selectedIndex, select.value) second.value = "bar" console.log("i", select.selectedIndex, select.value) }, 5000) </script> ```
Configuration menu - View commit details
-
Copy full SHA for 210d997 - Browse repository at this point
Copy the full SHA 210d997View commit details -
Switch from
m.layout
signal outm.remove
, merge create/update cal……lbacks Also re-added the `vnode === old` optimization, out of necessity for other utilities (there's a long code comment explaining why). Before this `m.layout` change, code would've looked like this: ```js // For libraries that bind state to the element itself function ThirdParty(attrs, old) { return m("div", m.layout((elem, signal) => { // Do DOM initialization Library.initialize(elem) // Schedule DOM cleanup signal.onabort = () => Library.dispose(elem) })) } // For libraries that return an instance function ThirdParty() { return m("div", m.layout((elem, signal) => { // Do DOM initialization let instance = new Library(elem) // Schedule DOM cleanup signal.onabort = () => instance.dispose() })) } ``` The problem with this is it makes logic that only needs to care about removal a lot more complicated than it otherwise needs to be. (See `src/std/init.js` for a concrete example of this, and how this change simplifies those use cases a lot.) It also requires not only an extra closure that necessarily has to lay around until removal, but an entire `AbortController`, so this change ultimately saves a little over 200 bytes per layout/remove pair. (If you have a lot of such elements, this could be noticeable.) After this change, third-party integration code (the other main motivator for `m.layout` in the first place) would look something like this: ```js // For libraries that bind state to the element itself function ThirdParty(attrs, old) { return m("div", [ // Do DOM initialization !old && m.layout((elem) => Library.initialize(elem)), // Schedule DOM cleanup m.remove((elem) => Library.dispose(elem)), ]) } // For libraries that return an instance function ThirdParty() { let instance return (attrs, old) => m("div", [ // Do DOM initialization !old && m.layout((elem) => instance = new Library(elem)), // Schedule DOM cleanup m.remove(() => instance.dispose()), ]) } ``` It was already possible to initialize an element outside of its scope by saving a reference to it: ```js function ThirdParty(attrs, old) { let label, root return [ label = m("label", "Some text"), root = m("div.library"), m.layout((elem, signal) => { let instance = new Library(root.d, label.d) signal.onabort = () => instance.dispose() }), ] } ``` This change makes that a little cleaner to wire up: ```js function ThirdParty() { let instance return (attrs, old) => { let label, root return [ label = m("label", "Some text"), root = m("div.library"), !old && m.layout(() => instance = new Library(root.d, label.d)), m.remove(() => instance.dispose()), ] } } ``` It also fits in a JSX world a little more nicely, but this wasn't something I was specifically seeking out: ```jsx // Old unified function ThirdParty() { return <div> {m.layout((elem, signal) => { let instance = new Library(elem) signal.onabort = () => instance.dispose() })} </div> } // Old split function ThirdParty(attrs, old) { let label, root return <> {label = <label>Some text</label>} {root = <div class="library" />} {m.layout((elem, signal) => { let instance = new Library(root.d, label.d) signal.onabort = () => instance.dispose() })} </> } // New unified function ThirdParty() { let instance return (attrs, old) => <div> {!old && m.layout((elem) => instance = new Library(elem))} {m.remove(() => instance.dispose())} </div> } // New split function ThirdParty() { let instance return (attrs, old) => { let label, root return <> {label = <label>Some text</label>} {root = <div class="library" />} {!old && m.layout(() => instance = new Library(root.d, label.d))} {m.remove(() => instance.dispose())} </> } } ```
Configuration menu - View commit details
-
Copy full SHA for 044d1b8 - Browse repository at this point
Copy the full SHA 044d1b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8ddc288 - Browse repository at this point
Copy the full SHA 8ddc288View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21085ce - Browse repository at this point
Copy the full SHA 21085ceView commit details -
Optimize stream, remove deprecated bit, simplify
combine
- Did some baseline optimization to it to reduce overhead and memory requirements. Won't be too much of a deal with smaller apps, but users using a lot of streams will appreciate the reduced overhead. - Removed the runtime-deprecated `Stream.HALT`. - Dropped the source list from `Stream.combine` callbacks' operands. It's almost always available in context anyways.
Configuration menu - View commit details
-
Copy full SHA for beaad3b - Browse repository at this point
Copy the full SHA beaad3bView commit details -
This prepares for future possible render flags, like a "remove on error" flag that might get exposed in the future to enable userland error boundaries.
Configuration menu - View commit details
-
Copy full SHA for 84472c4 - Browse repository at this point
Copy the full SHA 84472c4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 70cc05b - Browse repository at this point
Copy the full SHA 70cc05bView commit details
Commits on Oct 12, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 1cf9de3 - Browse repository at this point
Copy the full SHA 1cf9de3View commit details -
Add bi-edge debouncing + throttling rate limiters
Proper debouncing and throttling is easy to screw up, and the usual implementations that invoke a provided callback don't compose well. Instead, this provides functions that return promises you can filter on. This is far more composable and far easier to use. Also, the thing people usually do in a pinch, leading edge throttling, is usually the wrong thing to do. For example, if you're implementing an interactive search, you want the first to go immediately, but still incrementally update while the user is typing.
Configuration menu - View commit details
-
Copy full SHA for 455765a - Browse repository at this point
Copy the full SHA 455765aView commit details -
Also made some small (but needed) changes to the entry points and minified scripts. No specific tests for the error handling yet aside from the existing error-related tests that needed to change. But here's the going idea: error boundaries can be done in userland. Users would do something like this: ```js function slurpContext(context) { const chain = [] while (context !== null && context !== Object.prototype) { chain.push(context) context = Object.getPrototypeOf(context) } return chain.reduceRight((a, b) => Object.defineProperties(a, Object.getOwnPropertyDescriptors(b)), {}) } function ErrorBoundary(attrs, _, context) { return m("div.boundary", [ m.layout((dom) => { try { m.render(dom, m.set(slurpContext(context), attrs.view()), { render: context.render, removeOnThrow: true, }) } catch (e) { attrs.onerror(e) } }), m.remove((dom) => m.render(dom, null)), ]) } ```
Configuration menu - View commit details
-
Copy full SHA for 118d748 - Browse repository at this point
Copy the full SHA 118d748View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4137f97 - Browse repository at this point
Copy the full SHA 4137f97View commit details -
Configuration menu - View commit details
-
Copy full SHA for 313d004 - Browse repository at this point
Copy the full SHA 313d004View commit details -
`finally` is apparently really slow. This improved benchmarks by about 3-4x, bringing them back to roughly what they were when I first cut the branch.
Configuration menu - View commit details
-
Copy full SHA for 726e79f - Browse repository at this point
Copy the full SHA 726e79fView commit details -
Ensure
is
is always set in custom elementsThis matches HTML more closely, and makes for a much better experience with custom elements.
Configuration menu - View commit details
-
Copy full SHA for 2a60973 - Browse repository at this point
Copy the full SHA 2a60973View commit details -
Normalize the render vnode input to a single unitary vnode, not an array
It's more predictable that way, and I expect this to break approximately nobody. (If anything, it's likely to *unbreak* some users, as they may have been assuming this to have been the case from the beginning.)
Configuration menu - View commit details
-
Copy full SHA for f48beca - Browse repository at this point
Copy the full SHA f48becaView commit details -
Configuration menu - View commit details
-
Copy full SHA for b889448 - Browse repository at this point
Copy the full SHA b889448View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3b7788b - Browse repository at this point
Copy the full SHA 3b7788bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 95897a3 - Browse repository at this point
Copy the full SHA 95897a3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 966d1c0 - Browse repository at this point
Copy the full SHA 966d1c0View commit details -
Some point along the way, this got erroneously changed and saved.
Configuration menu - View commit details
-
Copy full SHA for 30e5ed1 - Browse repository at this point
Copy the full SHA 30e5ed1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 86b3c31 - Browse repository at this point
Copy the full SHA 86b3c31View commit details -
Stop displaying size in the README
It's going to unnecessarily complicate the release process, especially now that artifacts aren't saved to the repo anymore.
Configuration menu - View commit details
-
Copy full SHA for 2872ca2 - Browse repository at this point
Copy the full SHA 2872ca2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9099bcc - Browse repository at this point
Copy the full SHA 9099bccView commit details
Commits on Oct 20, 2024
-
Unrestrict a bunch of actually valid syntax
I clearly didn't check this bit properly
Configuration menu - View commit details
-
Copy full SHA for 1fb5104 - Browse repository at this point
Copy the full SHA 1fb5104View commit details -
Add
m.match
, optimizem.p
a tonDid some math and some benchmarking and...it's actually a potential perf bottleneck for apps and so I had to optimize it a ton. Also rolled some new benchmarks for it.
Configuration menu - View commit details
-
Copy full SHA for c5c4b2f - Browse repository at this point
Copy the full SHA c5c4b2fView commit details -
Remove some useless
Object.assign
sWithin the hyperscript side, it's a significant (roughly 10%) perf boost.
Configuration menu - View commit details
-
Copy full SHA for fa39b98 - Browse repository at this point
Copy the full SHA fa39b98View commit details -
Configuration menu - View commit details
-
Copy full SHA for 310a32b - Browse repository at this point
Copy the full SHA 310a32bView commit details -
Configuration menu - View commit details
-
Copy full SHA for b33349a - Browse repository at this point
Copy the full SHA b33349aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3da7a1d - Browse repository at this point
Copy the full SHA 3da7a1dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 01fc41e - Browse repository at this point
Copy the full SHA 01fc41eView commit details
Commits on Oct 21, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 9dd8d17 - Browse repository at this point
Copy the full SHA 9dd8d17View commit details -
Boost
m.p
performance by a lotTurns out this was way more perf-sensitive than I initially thought. Also included a long comment to explain everything, as it's not immediately obvious just looking at it that it'd be perf-sensitive.
Configuration menu - View commit details
-
Copy full SHA for fee0cca - Browse repository at this point
Copy the full SHA fee0ccaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 451aa18 - Browse repository at this point
Copy the full SHA 451aa18View commit details
Commits on Oct 29, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 36d4cb3 - Browse repository at this point
Copy the full SHA 36d4cb3View commit details
Commits on Oct 30, 2024
-
Address some feedback around naming and (indirectly)
m.key
, optimiz……e `m.use` `m.use` is specially designed to be used a fair amount, and simulating it is relatively slow, so it's worth making a built-in. `m.key` -> `m.keyed` provides for a simpler interface, one that you don't have to type `key` out explicitly for anymore. (Most frameworks require you to explicitly add a "key" attribute, while this approaches it more like a glorified `Map`.)
Configuration menu - View commit details
-
Copy full SHA for 2e75897 - Browse repository at this point
Copy the full SHA 2e75897View commit details -
It's very common to want context and not care about attributes. What's *not* common is wanting the old attributes and not the new. So that's what this optimizes for.
Configuration menu - View commit details
-
Copy full SHA for 5018ad0 - Browse repository at this point
Copy the full SHA 5018ad0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5d79b07 - Browse repository at this point
Copy the full SHA 5d79b07View commit details -
Configuration menu - View commit details
-
Copy full SHA for f99850e - Browse repository at this point
Copy the full SHA f99850eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0c99734 - Browse repository at this point
Copy the full SHA 0c99734View commit details -
Configuration menu - View commit details
-
Copy full SHA for 814261f - Browse repository at this point
Copy the full SHA 814261fView commit details -
Configuration menu - View commit details
-
Copy full SHA for cd26097 - Browse repository at this point
Copy the full SHA cd26097View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8cafcfe - Browse repository at this point
Copy the full SHA 8cafcfeView commit details
Commits on Oct 31, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 953665e - Browse repository at this point
Copy the full SHA 953665eView commit details -
Bring back
m.request
- it's too useful.It mostly delegates to `fetch`. Also, kill `m.withProgress` as that only existed because there was no `m.request`.
Configuration menu - View commit details
-
Copy full SHA for 3220a25 - Browse repository at this point
Copy the full SHA 3220a25View commit details