ajo 0.0.9 → 0.0.12

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.min.js ADDED
@@ -0,0 +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||=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,t,r)}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(e,t(n));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(t.contains?.(document.activeElement)){const r=t.nextSibling;for(;n&&n!==t;){const i=n.nextSibling;e.insertBefore(n,r),n=i}}else e.insertBefore(t,n)},C=e=>{for(const n of e.children)C(n);for(const n of y.get(e)??[])n(e)};return L(re);})();
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "ajo",
3
- "version": "0.0.9",
3
+ "version": "0.0.12",
4
4
  "description": "ajo is a JavaScript view library for building user interfaces",
5
5
  "type": "module",
6
6
  "module": "index.js",
7
7
  "main": "index.cjs",
8
+ "unpkg": "index.min.js",
8
9
  "exports": {
9
10
  ".": {
10
11
  "import": "./index.js",
@@ -12,12 +13,16 @@
12
13
  "browser": "./index.min.js"
13
14
  }
14
15
  },
16
+ "files": [
17
+ "index.js",
18
+ "index.min.js"
19
+ ],
15
20
  "scripts": {
16
21
  "build": "npm run build:require && npm run build:browser",
17
22
  "build:require": "esbuild --format=cjs --out-extension:.js=.cjs --outdir=. index.js",
18
23
  "build:browser": "esbuild --format=iife --out-extension:.js=.min.js --outdir=. --global-name=ajo --minify index.js",
19
- "release": "npm run build && npm t && git commit -am \"$npm_package_version\" && git tag $npm_package_version && git push && git push --tags && npm publish",
20
- "test": "uvu"
24
+ "release": "npm test && git commit -am \"$npm_package_version\" && git tag $npm_package_version && git push && git push --tags && npm publish",
25
+ "test": "npm run build && uvu"
21
26
  },
22
27
  "repository": "cristianfalcone/ajo",
23
28
  "author": "Cristian Falcone",
package/index.test.js DELETED
@@ -1,63 +0,0 @@
1
- import 'backdom/register'
2
- import { suite } from 'uvu'
3
- import * as assert from 'uvu/assert'
4
- import { component, h, render } from './index.js'
5
-
6
- let it
7
-
8
- // ----------------------------------------------------------------------------
9
-
10
- it = suite('h')
11
-
12
- it('should create empty vnode', () => {
13
- const vnode = h('div')
14
- assert.equal(vnode, { nodeName: 'div', children: null })
15
- })
16
-
17
- it('should create vnode with props', () => {
18
- assert.equal(h('div', { id: 'app' }), { nodeName: 'div', children: null, id: 'app' })
19
- })
20
-
21
- it('should create vnode with one string child', () => {
22
- assert.equal(h('div', null, 'foo'), { nodeName: 'div', children: 'foo' })
23
- })
24
-
25
- it('should create vnode with one vnode child', () => {
26
- const child = h('span')
27
- const vnode = h('div', null, child)
28
- assert.equal(vnode.children, { nodeName: 'span', children: null })
29
- })
30
-
31
- it('should allow children as prop', () => {
32
- const child = h('span')
33
- const vnode = h('div', { children: child })
34
- assert.equal(vnode.children, { nodeName: 'span', children: null })
35
- })
36
-
37
- it.run()
38
-
39
- // ----------------------------------------------------------------------------
40
-
41
- it = suite('render')
42
-
43
- it('should render a vnode', () => {
44
- const host = document.createElement('div')
45
- render(h('div', { foo: 'bar' }, 'foobar'), host)
46
- assert.snapshot(host.innerHTML, '<div foo="bar">foobar</div>')
47
- })
48
-
49
- it('should render a stateless component', () => {
50
- const host = document.createElement('div')
51
- const Foo = ({ foo, children }) => h('div', { foo }, children)
52
- render(h(Foo, { foo: 'bar' }, h('span', null, 'foobar')), host)
53
- assert.snapshot(host.innerHTML, '<div foo="bar"><span>foobar</span></div>')
54
- })
55
-
56
- it('should render a stateful component', () => {
57
- const host = document.createElement('div')
58
- const Foo = component(() => ({ foo, children }) => h('div', { foo }, children))
59
- render(h(Foo, { is: 'foo-component', foo: 'bar' }, h('span', null, 'foobar')), host)
60
- assert.snapshot(host.innerHTML, '<foo-component><div foo="bar"><span>foobar</span></div></foo-component>')
61
- })
62
-
63
- it.run()