ajo 0.0.14 → 0.0.15
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/index.cjs +4 -4
- package/index.js +4 -4
- package/index.min.js +1 -1
- package/license +15 -0
- package/package.json +1 -1
- package/readme.md +7 -4
package/index.cjs
CHANGED
|
@@ -59,13 +59,13 @@ const Fragment = ({ children }) => children, h = (nodeName, props, ...children)
|
|
|
59
59
|
for (node = child; node; node = node.nextSibling)
|
|
60
60
|
if (node.localName == nodeName)
|
|
61
61
|
break;
|
|
62
|
-
node
|
|
63
|
-
key != null && (byKey
|
|
62
|
+
node ??= document.createElement(nodeName);
|
|
63
|
+
key != null && (byKey ??= keyed.set(host, /* @__PURE__ */ new Map())).set(key, node);
|
|
64
64
|
update(props, node);
|
|
65
65
|
!(skip || block != null && every(deps.get(node), deps.set(node, block))) && render(children, node);
|
|
66
66
|
isFn(ref) && ref(node);
|
|
67
67
|
}
|
|
68
|
-
node === child ? child = child.nextSibling : before(host,
|
|
68
|
+
node === child ? child = child.nextSibling : before(host, node, child);
|
|
69
69
|
}
|
|
70
70
|
while (child) {
|
|
71
71
|
const next = child.nextSibling;
|
|
@@ -153,7 +153,7 @@ const wm = () => {
|
|
|
153
153
|
host.setAttribute(name, value);
|
|
154
154
|
}
|
|
155
155
|
cache.set(host, props);
|
|
156
|
-
}, before = (host,
|
|
156
|
+
}, before = (host, node, child) => {
|
|
157
157
|
if (node.contains?.(document.activeElement)) {
|
|
158
158
|
const ref = node.nextSibling;
|
|
159
159
|
while (child && child !== node) {
|
package/index.js
CHANGED
|
@@ -32,9 +32,9 @@ export const
|
|
|
32
32
|
if (key != null && (node = byKey?.get(key)));
|
|
33
33
|
else for (node = child; node; node = node.nextSibling) if (node.localName == nodeName) break
|
|
34
34
|
|
|
35
|
-
node
|
|
35
|
+
node ??= document.createElement(nodeName)
|
|
36
36
|
|
|
37
|
-
key != null && (byKey
|
|
37
|
+
key != null && (byKey ??= keyed.set(host, new Map)).set(key, node)
|
|
38
38
|
|
|
39
39
|
update(props, node)
|
|
40
40
|
|
|
@@ -43,7 +43,7 @@ export const
|
|
|
43
43
|
isFn(ref) && ref(node)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
node === child ? child = child.nextSibling : before(host,
|
|
46
|
+
node === child ? child = child.nextSibling : before(host, node, child)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
while (child) {
|
|
@@ -178,7 +178,7 @@ const
|
|
|
178
178
|
cache.set(host, props)
|
|
179
179
|
},
|
|
180
180
|
|
|
181
|
-
before = (host,
|
|
181
|
+
before = (host, node, child) => {
|
|
182
182
|
if (node.contains?.(document.activeElement)) {
|
|
183
183
|
|
|
184
184
|
const ref = node.nextSibling
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ajo=(()=>{var d=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var I=(e,n)=>{for(var t in n)d(e,t,{get:n[t],enumerable:!0})},K=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of O(n))!W.call(e,i)&&i!==t&&d(e,i,{get:()=>n[i],enumerable:!(r=F(n,i))||r.enumerable});return e};var L=e=>K(d({},"__esModule",{value:!0}),e);var re={};I(re,{Fragment:()=>Z,cleanup:()=>J,clx:()=>P,component:()=>q,consume:()=>G,h:()=>A,intercept:()=>H,keb:()=>R,propagate:()=>E,provide:()=>D,refresh:()=>j,render:()=>c,stx:()=>Q});const Z=({children:e})=>e,A=(e,n,...t)=>(t=t.length==0?null:t.length==1?t[0]:t,{children:t,...n,nodeName:e}),q=e=>({is:n,key:t,host:r,ref:i,...l})=>A(n??e.is??"div",{key:t,...e.host,...r,skip:!0,ref:o=>(j(o,l,e),f(i)&&i(o))}),c=(e,n)=>{let t=n.firstChild,r,i=x.get(n);for(e of m(e,n)){if(typeof e=="string"){for(r=t;r&&r.nodeType!=3;r=r.nextSibling);r?r.data!==e&&(r.data=e):r=document.createTextNode(e)}else if(e instanceof Node)r=e;else{const{key:l,nodeName:o,skip:M,block:p,children:z,ref:b,...B}=e;if(!(l!=null&&(r=i?.get(l))))for(r=t;r&&r.localName!=o;r=r.nextSibling);r
|
|
1
|
+
var ajo=(()=>{var d=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var I=(e,n)=>{for(var t in n)d(e,t,{get:n[t],enumerable:!0})},K=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of O(n))!W.call(e,i)&&i!==t&&d(e,i,{get:()=>n[i],enumerable:!(r=F(n,i))||r.enumerable});return e};var L=e=>K(d({},"__esModule",{value:!0}),e);var re={};I(re,{Fragment:()=>Z,cleanup:()=>J,clx:()=>P,component:()=>q,consume:()=>G,h:()=>A,intercept:()=>H,keb:()=>R,propagate:()=>E,provide:()=>D,refresh:()=>j,render:()=>c,stx:()=>Q});const Z=({children:e})=>e,A=(e,n,...t)=>(t=t.length==0?null:t.length==1?t[0]:t,{children:t,...n,nodeName:e}),q=e=>({is:n,key:t,host:r,ref:i,...l})=>A(n??e.is??"div",{key:t,...e.host,...r,skip:!0,ref:o=>(j(o,l,e),f(i)&&i(o))}),c=(e,n)=>{let t=n.firstChild,r,i=x.get(n);for(e of m(e,n)){if(typeof e=="string"){for(r=t;r&&r.nodeType!=3;r=r.nextSibling);r?r.data!==e&&(r.data=e):r=document.createTextNode(e)}else if(e instanceof Node)r=e;else{const{key:l,nodeName:o,skip:M,block:p,children:z,ref:b,...B}=e;if(!(l!=null&&(r=i?.get(l))))for(r=t;r&&r.localName!=o;r=r.nextSibling);r??=document.createElement(o),l!=null&&(i??=x.set(n,new Map)).set(l,r),ne(B,r),!(M||p!=null&&U(S.get(r),S.set(r,p)))&&c(z,r),f(b)&&b(r)}r===t?t=t.nextSibling:te(n,r,t)}for(;t;){const l=t.nextSibling;n.removeChild(t).nodeType==1&&C(t),t=l}},j=(e,n,t)=>{try{t&&!f(t)&&s("Setup",t,u),n=n?v.set(e,{...t?.props,...n}):v.get(e)??{},c((N.get(e)??N.set(e,t(n,e)))(n,e),e)}catch(r){E(e,r)}},D=(e,n,t)=>(g.get(e)??g.set(e,new Map)).set(n,t),G=(e,n,t)=>{let r;for(;e;){if((r=g.get(e))&&r.has(n))return r.get(n);e=e.parentNode}return t},H=(e,n)=>{f(n)||s("Interceptor",n,u),$.set(e,n)},E=(e,n)=>{for(let t;e;e=e.parentNode)if(t=$.get(e))return c(t(n),e);throw n},J=(e,n)=>{f(n)||s("Cleaner",n,u),(y.get(e)??y.set(e,new Set)).add(n)},P=e=>T(e).filter(n=>e[n]).join(" ")||null,Q=e=>Y(e).map(n=>n.join(":")).join(";")||null,R=e=>T(e).reduce((n,t)=>(n[t.replace(h,ee).toLowerCase()]=e[t],n),{}),a=()=>{const e=new WeakMap,{set:n}=e;return e.set=(t,r)=>(n.call(e,t,r),r),e},s=(e,n,t)=>{throw new TypeError(`Expected ${e} to be of type ${t}, got ${typeof n} instead`)},U=(e,n)=>e===n||w(e)&&w(n)&&e.length==n.length&&e.every((t,r)=>t===n[r]),V=(e,{name:n,value:t})=>(e[n]=t,e),X=e=>_(e).reduce(V,{}),f=e=>typeof e==u,{keys:T,entries:Y}=Object,{isArray:w,from:_}=Array,u="function",h=/([a-z0-9])([A-Z])/g,ee="$1-$2",x=a(),S=a(),v=a(),N=a(),g=a(),$=a(),y=a(),k=a(),m=function*(e,n){let t,r="";for(e of f(e?.[Symbol.iterator])?e:[e])if(!(e==null||(t=typeof e)=="boolean")){if(t=="string"||t=="number"){r+=e;continue}if("nodeName"in Object(e)){if(f(e.nodeName)){yield*m(e.nodeName(e,n),n);continue}r&&(yield r,r=""),yield e;continue}f(e[Symbol.iterator])?yield*m(e,n):r+=e}r&&(yield r)},ne=(e,n)=>{const t=k.get(n)??(n.hasAttributes()?X(n.attributes):{});for(const r in{...t,...e}){let i=e[r];if(i!==t[r]){if(r.startsWith("set:")){n[r.slice(4)]=i;continue}if(i===!0)i="";else if(i==null||i===!1){n.removeAttribute(r);continue}n.setAttribute(r,i)}}k.set(n,e)},te=(e,n,t)=>{if(n.contains?.(document.activeElement)){const r=n.nextSibling;for(;t&&t!==n;){const i=t.nextSibling;e.insertBefore(t,r),t=i}}else e.insertBefore(n,t)},C=e=>{for(const n of e.children)C(n);for(const n of y.get(e)??[])n(e)};return L(re);})();
|
package/license
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022, Cristian Falcone, @cristianfalcone
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
14
|
+
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# ajo
|
|
2
2
|
ajo is a JavaScript view library for building user interfaces
|
|
3
3
|
|
|
4
|
-
##
|
|
4
|
+
## install
|
|
5
5
|
|
|
6
6
|
```sh
|
|
7
7
|
npm install ajo
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## render JSX to a DOM element
|
|
11
11
|
|
|
12
12
|
```jsx
|
|
13
13
|
/** @jsx h */
|
|
@@ -18,7 +18,7 @@ document.body.innerHTML = '<div>Hello World</div>'
|
|
|
18
18
|
render(<div>Goodbye World</div>, document.body)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## stateless component
|
|
22
22
|
|
|
23
23
|
```jsx
|
|
24
24
|
/** @jsx h */
|
|
@@ -29,7 +29,7 @@ const Greet = ({ name }) => <div>Hello {name}</div>
|
|
|
29
29
|
render(<Greet name="World" />, document.body)
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## stateful component
|
|
33
33
|
|
|
34
34
|
```jsx
|
|
35
35
|
/** @jsx h */
|
|
@@ -52,3 +52,6 @@ const Counter = component(({ start = 0 }, host) => {
|
|
|
52
52
|
|
|
53
53
|
render(<Counter start={1} />, document.body)
|
|
54
54
|
```
|
|
55
|
+
|
|
56
|
+
## acknowledgments
|
|
57
|
+
ajo takes heavy inspiration from [Incremental DOM](https://github.com/google/incremental-dom) and [Crank.js](https://github.com/bikeshaving/crank)
|