@tltdsh/mx 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/README.md +2 -2
- package/mx.d.ts +2 -1
- package/mx.min.js +1 -1
- package/mx.mjs +1 -1
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -13,7 +13,7 @@ When transferring from React/Vue/Svelte, read [mxjs.dev/what-mx-is-not](https://
|
|
|
13
13
|
| Rule | Do | Don't |
|
|
14
14
|
|------|----|-------|
|
|
15
15
|
| Component definition | `$(props) {}` (method shorthand) | `$: function(props) {}` - legacy |
|
|
16
|
-
| Component name | `define('my-widget', {...})` kebab-case
|
|
16
|
+
| Component name | `define('my-widget', {...})` kebab-case (camelCase also works — auto-converts to kebab) | Mismatched names between define and call site |
|
|
17
17
|
| Call site | `mx.myWidget()` camelCase | `mx.MyWidget()` - PascalCase gives `-my-widget` (invalid) |
|
|
18
18
|
| State updates | `this.$({ key: value })` | `this.$state.key = value` - bypasses the merge, forbidden |
|
|
19
19
|
| Empty re-render | Pass actual changed data: `this.$({ key: newValue })` | `this.$({})` with empty object - code smell |
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mx.js
|
|
2
2
|
|
|
3
|
-
Sub-1KB reactive DOM reconciliation engine for building massive platforms and user interfaces at scale. **
|
|
3
|
+
Sub-1KB reactive DOM reconciliation engine for building massive platforms and user interfaces at scale. **770 bytes** brotli. 4 globals, zero dependencies, no virtual DOM, no build step. Small enough to fit in an AI context window.
|
|
4
4
|
|
|
5
5
|
**Full documentation & live playground: [mxjs.dev](https://mxjs.dev)**
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ Sub-1KB reactive DOM reconciliation engine for building massive platforms and us
|
|
|
21
21
|
### Pinned version
|
|
22
22
|
|
|
23
23
|
```html
|
|
24
|
-
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.2.
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.2.6/mx.min.js"></script>
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### npm / yarn / bun
|
package/mx.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ interface MxHTMLAttrs {
|
|
|
99
99
|
part?: string;
|
|
100
100
|
exportparts?: string;
|
|
101
101
|
is?: string;
|
|
102
|
+
blocking?: 'render';
|
|
102
103
|
|
|
103
104
|
// Popover
|
|
104
105
|
popover?: 'auto' | 'manual' | boolean;
|
|
@@ -634,7 +635,7 @@ interface DomProxy extends DomHTMLTags {
|
|
|
634
635
|
|
|
635
636
|
/**
|
|
636
637
|
* Register a component by name. The `$` function becomes the render function.
|
|
637
|
-
* Name
|
|
638
|
+
* Name auto-converts camelCase to kebab-case, same as mx/dom call sites.
|
|
638
639
|
*
|
|
639
640
|
* @example
|
|
640
641
|
* define('counter', {
|
package/mx.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(
|
|
1
|
+
!function($,l,_,d){let R="http://www.w3.org/2000/svg",t={selected:1,value:1,checked:1},n={},w=$=>n[$]||=$.replace(/[A-Z]/g,"-$&").toLowerCase(),i=Object.assign,m=$=>new Proxy($,{get:(l,_)=>$.bind(0,_)}),g=(l,t)=>!t&"svg"!=l?i($.createElement(l),_[l]):$.createElementNS(R,l);define=(l,$={})=>{if($.$){$.$$||=$.$;$.$=function(l){let _=$.$$.call(this,i(this.$state||={},l));return this.render(..._?._?[_]:_||[])}}_[w(l)]=$};_=components={},l.render=function(...i){let l=this,_=R==l.namespaceURI,$=l.firstChild;for(let R of i){let m,w,v;if(R==null|!1===R)continue;if(R._)[m,w,v]=R;else if(R.nodeType){$!=R&&($?$.replaceWith(R):l.append(R)),$=R.nextSibling;continue}if($)!m?$.localName?$.replaceWith($=new Text(R)):R+""!=$.data&&($.data=R):m!=$.localName&&$.replaceWith($=g(m,_));else if(m)l.append($=g(m,_));else{l.append(R);continue}if(m){if($.$)$._$=0,$.$(w);else{$.render(...v);let _=$._$||={},g=$._$$||={},i=d=-~d;for(let l in _){w&&l in w||((l[0]=="."?t[l.slice(1)]&&delete g[l.slice(1)]:(t[l]&&(delete g[l],$[l]=""),$.R(l))),delete _[l])}for(let l in w){let R=w[l];_[l]===R?l[0]=="."?($[l.slice(1)]=R,g[l.slice(1)]=i):t[l]?($[l]=R,g[l]=i):R?.call&&(g[l]=i):l[0]=="."?($[l.slice(1)]=R,g[l.slice(1)]=i,_[l]=R):R!=null&!1!==R?(R.call?($[l]=R,g[l]=i):(t[l]?($[l]=R,g[l]=i):delete g[l],$.setAttribute(l,R)),_[l]=R):(t[l]&&(delete g[l],$[l]=""),$.R(l),delete _[l])}for(let l in g)i-g[l]&&(delete g[l],$[l]=null)}}$=$.nextSibling}for(let l;$;$=l)l=$.nextSibling,$.remove();return this},l.R=l.removeAttribute,l.$attrs=function($,l,R){for(l in $)R=$[l],l[0]=="."?this[l.slice(1)]=R:R!=null&!1!==R?(R.call?this[l]=R:this.setAttribute(l,R)):this.R(l);return this},mx=m(($,l,..._)=>{$=w($);let t=l?.constructor==Object&&!l?.nodeType?[$,l,_]:[$,null,[l,..._]];t._=1;return t}),dom=m(($,l,..._)=>{$=w($);let t=g($);l?.constructor==Object&&!l?.nodeType?t.$?t.$(l):t.$attrs(l).render(..._):t.render(l,..._);return t})}(document,Element.prototype)
|
package/mx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var mx, dom, define, components;
|
|
2
|
-
!function(
|
|
2
|
+
!function($,l,_,d){let R="http://www.w3.org/2000/svg",t={selected:1,value:1,checked:1},n={},w=$=>n[$]||=$.replace(/[A-Z]/g,"-$&").toLowerCase(),i=Object.assign,m=$=>new Proxy($,{get:(l,_)=>$.bind(0,_)}),g=(l,t)=>!t&"svg"!=l?i($.createElement(l),_[l]):$.createElementNS(R,l);define=(l,$={})=>{if($.$){$.$$||=$.$;$.$=function(l){let _=$.$$.call(this,i(this.$state||={},l));return this.render(..._?._?[_]:_||[])}}_[w(l)]=$};_=components={},l.render=function(...i){let l=this,_=R==l.namespaceURI,$=l.firstChild;for(let R of i){let m,w,v;if(R==null|!1===R)continue;if(R._)[m,w,v]=R;else if(R.nodeType){$!=R&&($?$.replaceWith(R):l.append(R)),$=R.nextSibling;continue}if($)!m?$.localName?$.replaceWith($=new Text(R)):R+""!=$.data&&($.data=R):m!=$.localName&&$.replaceWith($=g(m,_));else if(m)l.append($=g(m,_));else{l.append(R);continue}if(m){if($.$)$._$=0,$.$(w);else{$.render(...v);let _=$._$||={},g=$._$$||={},i=d=-~d;for(let l in _){w&&l in w||((l[0]=="."?t[l.slice(1)]&&delete g[l.slice(1)]:(t[l]&&(delete g[l],$[l]=""),$.R(l))),delete _[l])}for(let l in w){let R=w[l];_[l]===R?l[0]=="."?($[l.slice(1)]=R,g[l.slice(1)]=i):t[l]?($[l]=R,g[l]=i):R?.call&&(g[l]=i):l[0]=="."?($[l.slice(1)]=R,g[l.slice(1)]=i,_[l]=R):R!=null&!1!==R?(R.call?($[l]=R,g[l]=i):(t[l]?($[l]=R,g[l]=i):delete g[l],$.setAttribute(l,R)),_[l]=R):(t[l]&&(delete g[l],$[l]=""),$.R(l),delete _[l])}for(let l in g)i-g[l]&&(delete g[l],$[l]=null)}}$=$.nextSibling}for(let l;$;$=l)l=$.nextSibling,$.remove();return this},l.R=l.removeAttribute,l.$attrs=function($,l,R){for(l in $)R=$[l],l[0]=="."?this[l.slice(1)]=R:R!=null&!1!==R?(R.call?this[l]=R:this.setAttribute(l,R)):this.R(l);return this},mx=m(($,l,..._)=>{$=w($);let t=l?.constructor==Object&&!l?.nodeType?[$,l,_]:[$,null,[l,..._]];t._=1;return t}),dom=m(($,l,..._)=>{$=w($);let t=g($);l?.constructor==Object&&!l?.nodeType?t.$?t.$(l):t.$attrs(l).render(..._):t.render(l,..._);return t})}(document,Element.prototype)
|
|
3
3
|
export { mx, dom, define, components };
|