@tltdsh/mx 1.5.0 → 1.6.1
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/AGENTS.md +0 -16
- package/CLAUDE.md +0 -16
- package/README.md +2 -2
- package/mx.d.ts +8 -3
- package/mx.min.js +1 -1
- package/mx.mjs +1 -1
- package/package.json +1 -1
- package/skill/ui-mx.js +3 -5
package/AGENTS.md
CHANGED
|
@@ -111,22 +111,6 @@ if (this.$state.items.length) this.$({ hasItems: true });
|
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
-
## Reserved Tag Names
|
|
115
|
-
|
|
116
|
-
mx keeps two plain-object caches, one for the proxy's tag functions and one for tag names, and both inherit `Object.prototype` methods. Don't use any of these as component names:
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
toString, valueOf, constructor, hasOwnProperty, isPrototypeOf,
|
|
120
|
-
propertyIsEnumerable, toLocaleString, __defineGetter__,
|
|
121
|
-
__defineSetter__, __lookupGetter__, __lookupSetter__, __proto__
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Property access returns the inherited method instead of a tag function: `mx.toString()` renders the text `"[object Function]"`, and `mx.valueOf()` or `mx.hasOwnProperty()` throw a `TypeError`. The call form `mx('toString')` throws `InvalidCharacterError` at `createElement` time. `define('toString', ...)` registers under the wrong key.
|
|
125
|
-
|
|
126
|
-
Tag/component names only - **attribute** names are safe: the reconciler tracks attrs by own-key checks (`Object.hasOwn`), so `{ toString: 'x' }` sets and removes cleanly, and attrs objects with an own `constructor` key are still recognized as attrs.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
114
|
## Checklist for New Components
|
|
131
115
|
|
|
132
116
|
1. `define('kebab-name', { $(props) {} })` - kebab-case only in define()
|
package/CLAUDE.md
CHANGED
|
@@ -111,22 +111,6 @@ if (this.$state.items.length) this.$({ hasItems: true });
|
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
-
## Reserved Tag Names
|
|
115
|
-
|
|
116
|
-
mx keeps two plain-object caches, one for the proxy's tag functions and one for tag names, and both inherit `Object.prototype` methods. Don't use any of these as component names:
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
toString, valueOf, constructor, hasOwnProperty, isPrototypeOf,
|
|
120
|
-
propertyIsEnumerable, toLocaleString, __defineGetter__,
|
|
121
|
-
__defineSetter__, __lookupGetter__, __lookupSetter__, __proto__
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Property access returns the inherited method instead of a tag function: `mx.toString()` renders the text `"[object Function]"`, and `mx.valueOf()` or `mx.hasOwnProperty()` throw a `TypeError`. The call form `mx('toString')` throws `InvalidCharacterError` at `createElement` time. `define('toString', ...)` registers under the wrong key.
|
|
125
|
-
|
|
126
|
-
Tag/component names only - **attribute** names are safe: the reconciler tracks attrs by own-key checks (`Object.hasOwn`), so `{ toString: 'x' }` sets and removes cleanly, and attrs objects with an own `constructor` key are still recognized as attrs.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
114
|
## Checklist for New Components
|
|
131
115
|
|
|
132
116
|
1. `define('kebab-name', { $(props) {} })` - kebab-case only in define()
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tltdsh/mx)
|
|
4
4
|
[](https://bundlejs.com/?q=@tltdsh/mx)
|
|
5
|
-
[](https://mxjs.dev)
|
|
6
6
|
[](https://opensource.org/license/0bsd)
|
|
7
7
|
|
|
8
8
|
A DOM reconciliation engine for building user interfaces in plain JavaScript, from a single widget to a large platform. It is **under 1KB** with brotli, has four API names and no dependencies, and needs no virtual DOM or build step, so the whole library fits in an AI context window.
|
|
@@ -26,7 +26,7 @@ A DOM reconciliation engine for building user interfaces in plain JavaScript, fr
|
|
|
26
26
|
### Pinned version
|
|
27
27
|
|
|
28
28
|
```html
|
|
29
|
-
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.6.1/mx.min.js"></script>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### npm / yarn / bun
|
package/mx.d.ts
CHANGED
|
@@ -159,6 +159,14 @@ interface MxHTMLAttrs {
|
|
|
159
159
|
'aria-modal'?: boolean | 'true' | 'false';
|
|
160
160
|
'aria-roledescription'?: string;
|
|
161
161
|
|
|
162
|
+
// ARIA composite widgets cluster (accessibility)
|
|
163
|
+
// aria-relevant is a space-separated token list; absent means "additions text".
|
|
164
|
+
'aria-activedescendant'?: string;
|
|
165
|
+
'aria-description'?: string;
|
|
166
|
+
'aria-details'?: string;
|
|
167
|
+
'aria-keyshortcuts'?: string;
|
|
168
|
+
'aria-relevant'?: 'additions' | 'removals' | 'text' | 'all' | 'additions text' | (string & {});
|
|
169
|
+
|
|
162
170
|
// Loading
|
|
163
171
|
fetchpriority?: 'high' | 'low' | 'auto';
|
|
164
172
|
|
|
@@ -748,9 +756,6 @@ declare global {
|
|
|
748
756
|
*/
|
|
749
757
|
$attrs(attrs: MxAttrs): this;
|
|
750
758
|
|
|
751
|
-
/** Alias for removeAttribute (used internally) */
|
|
752
|
-
R(name: string): void;
|
|
753
|
-
|
|
754
759
|
/** Component state - merged via Object.assign on each $() call */
|
|
755
760
|
$state: Record<string, any>;
|
|
756
761
|
|
package/mx.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(l,i){let f=Object.assign,d={__proto__:null,value:1,selected:1,checked:1},R=components={},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[!1,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=l=>s[l]||=l.replace(/[A-Z]/g,'-$&').toLowerCase(),s={},$=(l,n={})=>new Proxy(l,{get:(_,i)=>n[i]||=l.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(l.createElement(i),R[i]):l.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,l={})=>{R[w(i)]=l;if(l.$)l.$$||=l.$,l.$=function(i){let _=l.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((l,i,..._)=>(l=n(w(l)),i?.__proto__==Object.prototype&&!i?.nodeType?l.$?l.$(i):l.render(..._).$attrs(i):l.render(i,..._),l)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,l=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;l&&l!=_&&l[g]!=f;l=$)$=l.nextSibling,i.removeChild(l);l!=_&&(l?.nextSibling==_?i.removeChild(l):i.insertBefore(_,l)),l=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(l?.[g]?(e||M(e=f),l[g]!=f):l)?!$?l.splitText?l.data!=''+_&&(l.data=''+_):l.replaceWith(l=new Text(_)):$!=l.localName&&l.replaceWith(l=n($,R)):l=i.insertBefore($?n($,R):new Text(_),l);if($)if(l.$)l[A]=0,l.$(w);else{let R=l[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(l[i]=null,l.
|
|
1
|
+
!function(l,i){let f=Object.assign,d={__proto__:null,value:1,selected:1,checked:1},R=components={__proto__:null},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[!1,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=l=>s[l]||=l.replace(/[A-Z]/g,'-$&').toLowerCase(),s={__proto__:null},$=(l,n={__proto__:null})=>new Proxy(l,{get:(_,i)=>n[i]||=l.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(l.createElement(i),R[i]):l.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,l={})=>{R[w(i)]=l;if(l.$)l.$$||=l.$,l.$=function(i){let _=l.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((l,i,..._)=>(l=n(w(l)),i?.__proto__==Object.prototype&&!i?.nodeType?l.$?l.$(i):l.render(..._).$attrs(i):l.render(i,..._),l)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,l=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;l&&l!=_&&l[g]!=f;l=$)$=l.nextSibling,i.removeChild(l);l!=_&&(l?.nextSibling==_?i.removeChild(l):i.insertBefore(_,l)),l=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(l?.[g]?(e||M(e=f),l[g]!=f):l)?!$?l.splitText?l.data!=''+_&&(l.data=''+_):l.replaceWith(l=new Text(_)):$!=l.localName&&l.replaceWith(l=n($,R)):l=i.insertBefore($?n($,R):new Text(_),l);if($)if(l.$)l[A]=0,l.$(w);else{let R=l[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(l[i]=null,l.removeAttribute(i))):(d[i]?l[i]='':R[i]?.call&&(l[i]=null),l.removeAttribute(i),delete R[i]));l.render(...m);for(let i in w)_=w[i],i[0]=='.'?(R[i]=_,l[i=i.slice(1)]===_||(l[i]=_)):i in R&&R[i]===_?d[i]&&(l[i]===_||(l[i]=_)):_!=null&!1!==_?(_.call?l[i]=_:(d[i]&&(l[i]===_||(l[i]=_)),l.setAttribute(i,_)),R[i]=_):(d[i]?l[i]==''||(l[i]=''):R[i]?.call&&(l[i]=null),l.removeAttribute(i),delete R[i])}l=l.nextSibling}for(let $;l;l=$)$=l.nextSibling,i.removeChild(l);return this},i.$attrs=function(l,i,_){for(i in l)_=l[i],i[0]=='.'?this[i.slice(1)]=_:_!=null&!1!==_?(_.call?this[i]=_:this.setAttribute(i,_)):this.removeAttribute(i);return this},mx=$((l,i,..._)=>(l=w(l),_=i?.__proto__==Object.prototype&&!i?.nodeType?[l,i,_]:[l,null,[i,..._]],_._=1,_))}(document,Element.prototype)
|
package/mx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
let mx, dom, define, components;
|
|
2
|
-
!function(l,i){let f=Object.assign,d={__proto__:null,value:1,selected:1,checked:1},R=components={},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[!1,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=l=>s[l]||=l.replace(/[A-Z]/g,'-$&').toLowerCase(),s={},$=(l,n={})=>new Proxy(l,{get:(_,i)=>n[i]||=l.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(l.createElement(i),R[i]):l.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,l={})=>{R[w(i)]=l;if(l.$)l.$$||=l.$,l.$=function(i){let _=l.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((l,i,..._)=>(l=n(w(l)),i?.__proto__==Object.prototype&&!i?.nodeType?l.$?l.$(i):l.render(..._).$attrs(i):l.render(i,..._),l)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,l=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;l&&l!=_&&l[g]!=f;l=$)$=l.nextSibling,i.removeChild(l);l!=_&&(l?.nextSibling==_?i.removeChild(l):i.insertBefore(_,l)),l=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(l?.[g]?(e||M(e=f),l[g]!=f):l)?!$?l.splitText?l.data!=''+_&&(l.data=''+_):l.replaceWith(l=new Text(_)):$!=l.localName&&l.replaceWith(l=n($,R)):l=i.insertBefore($?n($,R):new Text(_),l);if($)if(l.$)l[A]=0,l.$(w);else{let R=l[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(l[i]=null,l.
|
|
2
|
+
!function(l,i){let f=Object.assign,d={__proto__:null,value:1,selected:1,checked:1},R=components={__proto__:null},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[!1,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=l=>s[l]||=l.replace(/[A-Z]/g,'-$&').toLowerCase(),s={__proto__:null},$=(l,n={__proto__:null})=>new Proxy(l,{get:(_,i)=>n[i]||=l.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(l.createElement(i),R[i]):l.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,l={})=>{R[w(i)]=l;if(l.$)l.$$||=l.$,l.$=function(i){let _=l.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((l,i,..._)=>(l=n(w(l)),i?.__proto__==Object.prototype&&!i?.nodeType?l.$?l.$(i):l.render(..._).$attrs(i):l.render(i,..._),l)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,l=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;l&&l!=_&&l[g]!=f;l=$)$=l.nextSibling,i.removeChild(l);l!=_&&(l?.nextSibling==_?i.removeChild(l):i.insertBefore(_,l)),l=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(l?.[g]?(e||M(e=f),l[g]!=f):l)?!$?l.splitText?l.data!=''+_&&(l.data=''+_):l.replaceWith(l=new Text(_)):$!=l.localName&&l.replaceWith(l=n($,R)):l=i.insertBefore($?n($,R):new Text(_),l);if($)if(l.$)l[A]=0,l.$(w);else{let R=l[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(l[i]=null,l.removeAttribute(i))):(d[i]?l[i]='':R[i]?.call&&(l[i]=null),l.removeAttribute(i),delete R[i]));l.render(...m);for(let i in w)_=w[i],i[0]=='.'?(R[i]=_,l[i=i.slice(1)]===_||(l[i]=_)):i in R&&R[i]===_?d[i]&&(l[i]===_||(l[i]=_)):_!=null&!1!==_?(_.call?l[i]=_:(d[i]&&(l[i]===_||(l[i]=_)),l.setAttribute(i,_)),R[i]=_):(d[i]?l[i]==''||(l[i]=''):R[i]?.call&&(l[i]=null),l.removeAttribute(i),delete R[i])}l=l.nextSibling}for(let $;l;l=$)$=l.nextSibling,i.removeChild(l);return this},i.$attrs=function(l,i,_){for(i in l)_=l[i],i[0]=='.'?this[i.slice(1)]=_:_!=null&!1!==_?(_.call?this[i]=_:this.setAttribute(i,_)):this.removeAttribute(i);return this},mx=$((l,i,..._)=>(l=w(l),_=i?.__proto__==Object.prototype&&!i?.nodeType?[l,i,_]:[l,null,[i,..._]],_._=1,_))}(document,Element.prototype)
|
|
3
3
|
export { mx, dom, define, components };
|
package/package.json
CHANGED
package/skill/ui-mx.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
((doc, P, comps) => {
|
|
2
|
-
comps = components = {};
|
|
2
|
+
comps = components = { __proto__: null };
|
|
3
3
|
define = (name, obj = {}) => {
|
|
4
4
|
if (obj.$) {
|
|
5
5
|
obj.$$ ||= obj.$;
|
|
@@ -40,8 +40,6 @@
|
|
|
40
40
|
return element;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
P.R = P.removeAttribute;
|
|
44
|
-
|
|
45
43
|
P.$attrs = function(attrs, key, value) {
|
|
46
44
|
for (key in attrs) {
|
|
47
45
|
value = attrs[key];
|
|
@@ -224,8 +222,8 @@
|
|
|
224
222
|
return this;
|
|
225
223
|
};
|
|
226
224
|
|
|
227
|
-
let tagCacheObject = {},
|
|
228
|
-
toProxy = (fn, cache = {}) => new Proxy(fn, {
|
|
225
|
+
let tagCacheObject = { __proto__: null },
|
|
226
|
+
toProxy = (fn, cache = { __proto__: null }) => new Proxy(fn, {
|
|
229
227
|
get(_, tagAlias) { return cache[tagAlias] ||= fn.bind(0, tagAlias) }
|
|
230
228
|
}),
|
|
231
229
|
toTag = tagAlias => tagCacheObject[tagAlias] ||= tagAlias.replace(/[A-Z]/g, '-$&').toLowerCase();
|