-
-
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 c947ba6 - Browse repository at this point
Copy the full SHA c947ba6View commit details -
Configuration menu - View commit details
-
Copy full SHA for d252b40 - Browse repository at this point
Copy the full SHA d252b40View commit details -
Configuration menu - View commit details
-
Copy full SHA for 73a3e86 - Browse repository at this point
Copy the full SHA 73a3e86View 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 d0cc706 - Browse repository at this point
Copy the full SHA d0cc706View commit details -
Configuration menu - View commit details
-
Copy full SHA for b160a35 - Browse repository at this point
Copy the full SHA b160a35View 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 f9c6e2c - Browse repository at this point
Copy the full SHA f9c6e2cView commit details
Commits on Sep 27, 2024
-
Configuration menu - View commit details
-
Copy full SHA for ef0ccbf - Browse repository at this point
Copy the full SHA ef0ccbfView commit details
Commits on Oct 2, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 1da9a6a - Browse repository at this point
Copy the full SHA 1da9a6aView commit details -
Configuration menu - View commit details
-
Copy full SHA for f79bb20 - Browse repository at this point
Copy the full SHA f79bb20View commit details -
Configuration menu - View commit details
-
Copy full SHA for c0d5898 - Browse repository at this point
Copy the full SHA c0d5898View 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 777542f - Browse repository at this point
Copy the full SHA 777542fView 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 bd9f393 - Browse repository at this point
Copy the full SHA bd9f393View commit details
Commits on Oct 3, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 630ee9b - Browse repository at this point
Copy the full SHA 630ee9bView 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 64f9587 - Browse repository at this point
Copy the full SHA 64f9587View commit details -
Configuration menu - View commit details
-
Copy full SHA for a483ea0 - Browse repository at this point
Copy the full SHA a483ea0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 39fdb30 - Browse repository at this point
Copy the full SHA 39fdb30View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3477794 - Browse repository at this point
Copy the full SHA 3477794View commit details -
Configuration menu - View commit details
-
Copy full SHA for 518daf7 - Browse repository at this point
Copy the full SHA 518daf7View 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 e6af29e - Browse repository at this point
Copy the full SHA e6af29eView 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 82fc993 - Browse repository at this point
Copy the full SHA 82fc993View commit details -
Configuration menu - View commit details
-
Copy full SHA for ee40de5 - Browse repository at this point
Copy the full SHA ee40de5View commit details -
Configuration menu - View commit details
-
Copy full SHA for a454328 - Browse repository at this point
Copy the full SHA a454328View commit details -
Configuration menu - View commit details
-
Copy full SHA for df363e5 - Browse repository at this point
Copy the full SHA df363e5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 26d71a1 - Browse repository at this point
Copy the full SHA 26d71a1View 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 bfb35f9 - Browse repository at this point
Copy the full SHA bfb35f9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 038cbce - Browse repository at this point
Copy the full SHA 038cbceView commit details -
Configuration menu - View commit details
-
Copy full SHA for bb8e4b4 - Browse repository at this point
Copy the full SHA bb8e4b4View 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 1ec7ddc - Browse repository at this point
Copy the full SHA 1ec7ddcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 48933cb - Browse repository at this point
Copy the full SHA 48933cbView commit details -
It's now been made redundant with `m.tracked`.
Configuration menu - View commit details
-
Copy full SHA for 9bf6d1f - Browse repository at this point
Copy the full SHA 9bf6d1fView commit details
Commits on Oct 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for e3edcc3 - Browse repository at this point
Copy the full SHA e3edcc3View 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 73a0d32 - Browse repository at this point
Copy the full SHA 73a0d32View commit details -
Configuration menu - View commit details
-
Copy full SHA for c3333c6 - Browse repository at this point
Copy the full SHA c3333c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for c8e48cd - Browse repository at this point
Copy the full SHA c8e48cdView 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 df0eaeb - Browse repository at this point
Copy the full SHA df0eaebView commit details -
Configuration menu - View commit details
-
Copy full SHA for b0419a6 - Browse repository at this point
Copy the full SHA b0419a6View 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 1d9f287 - Browse repository at this point
Copy the full SHA 1d9f287View 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 bf21066 - Browse repository at this point
Copy the full SHA bf21066View commit details -
Configuration menu - View commit details
-
Copy full SHA for 91695c6 - Browse repository at this point
Copy the full SHA 91695c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 618b335 - Browse repository at this point
Copy the full SHA 618b335View 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 eebab6c - Browse repository at this point
Copy the full SHA eebab6cView 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 4a29a67 - Browse repository at this point
Copy the full SHA 4a29a67View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9331d49 - Browse repository at this point
Copy the full SHA 9331d49View 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 0dad38c - Browse repository at this point
Copy the full SHA 0dad38cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 34588d1 - Browse repository at this point
Copy the full SHA 34588d1View 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 e2c51b3 - Browse repository at this point
Copy the full SHA e2c51b3View 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 2ad80c7 - Browse repository at this point
Copy the full SHA 2ad80c7View 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 1836602 - Browse repository at this point
Copy the full SHA 1836602View 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 183cc6f - Browse repository at this point
Copy the full SHA 183cc6fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 93dc6df - Browse repository at this point
Copy the full SHA 93dc6dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for c2b6820 - Browse repository at this point
Copy the full SHA c2b6820View 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 a047b30 - Browse repository at this point
Copy the full SHA a047b30View 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 6da068b - Browse repository at this point
Copy the full SHA 6da068bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ff0edc - Browse repository at this point
Copy the full SHA 6ff0edcView commit details
Commits on Oct 12, 2024
-
Configuration menu - View commit details
-
Copy full SHA for d63ed0f - Browse repository at this point
Copy the full SHA d63ed0fView 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 4d5904c - Browse repository at this point
Copy the full SHA 4d5904cView 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 f3a6f9a - Browse repository at this point
Copy the full SHA f3a6f9aView commit details -
Configuration menu - View commit details
-
Copy full SHA for d741b3d - Browse repository at this point
Copy the full SHA d741b3dView commit details -
Configuration menu - View commit details
-
Copy full SHA for d6b6bda - Browse repository at this point
Copy the full SHA d6b6bdaView 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 c196356 - Browse repository at this point
Copy the full SHA c196356View 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 2aab01d - Browse repository at this point
Copy the full SHA 2aab01dView 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 94ed948 - Browse repository at this point
Copy the full SHA 94ed948View commit details -
Configuration menu - View commit details
-
Copy full SHA for 374729d - Browse repository at this point
Copy the full SHA 374729dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ab0a28d - Browse repository at this point
Copy the full SHA ab0a28dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 33a13cc - Browse repository at this point
Copy the full SHA 33a13ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for cad3725 - Browse repository at this point
Copy the full SHA cad3725View commit details -
Some point along the way, this got erroneously changed and saved.
Configuration menu - View commit details
-
Copy full SHA for 024150a - Browse repository at this point
Copy the full SHA 024150aView commit details -
Configuration menu - View commit details
-
Copy full SHA for c13a7f6 - Browse repository at this point
Copy the full SHA c13a7f6View 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 6e50918 - Browse repository at this point
Copy the full SHA 6e50918View commit details -
Configuration menu - View commit details
-
Copy full SHA for 472e59e - Browse repository at this point
Copy the full SHA 472e59eView commit details