Compare commits
1 Commits
master
...
wasd-keybi
Author | SHA1 | Date | |
---|---|---|---|
fcdeb85457 |
11
README.md
11
README.md
@ -1,11 +0,0 @@
|
||||
|
||||
Run in an empty directory to setup basic files:
|
||||
```
|
||||
deno run -Ar https://gitea.hptrow.me/SethTrowbridge/gale/raw/branch/master/scripts/scaffold.ts
|
||||
```
|
||||
|
||||
- `deno task work` starts the dev server
|
||||
- `deno task scan` scans the deno.json for type declaration files (be sure to then restart the Deno language server)
|
||||
- `deno task html` creates an index.html for use when static file hosting (the dev serve will create its own index.html if none exists in the file system)
|
||||
|
||||
`entry` in the import map points to the starting file
|
44
app.js
44
app.js
@ -1,4 +1,6 @@
|
||||
const {DOM, Tag, H} = Gale({
|
||||
import {PosCSS} from "./keys.js";
|
||||
|
||||
const {DOM} = Gale({
|
||||
Button: {
|
||||
padding: "20px",
|
||||
background: "orange",
|
||||
@ -7,39 +9,17 @@ const {DOM, Tag, H} = Gale({
|
||||
}
|
||||
},
|
||||
Outline: {
|
||||
border: "2px solid orange"
|
||||
},
|
||||
Window:{
|
||||
height: "100vh",
|
||||
border: "2px solid black",
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "end",
|
||||
justifyContent: "center",
|
||||
gap: "10px"
|
||||
},
|
||||
Ability:{
|
||||
width: "50px",
|
||||
height: "50px",
|
||||
background: "red",
|
||||
transition: "all 0.4s",
|
||||
":hover":{
|
||||
transform:"scale(1.1)"
|
||||
position: "relative",
|
||||
border: "2px solid orange",
|
||||
padding: "20px"
|
||||
}
|
||||
},
|
||||
Orange:{
|
||||
background:"orange"
|
||||
}
|
||||
}, "abilities");
|
||||
});
|
||||
|
||||
const UI =()=>
|
||||
function App()
|
||||
{
|
||||
return H.Window(
|
||||
H.Ability({class:Tag("Ability", "Orange")}),
|
||||
H.Ability(),
|
||||
H.Ability(),
|
||||
H.Ability.Orange(),
|
||||
)
|
||||
return ()=> {
|
||||
return DOM.h1.Outline({id:"Move", style:PosCSS(10)}, "title");
|
||||
}
|
||||
}
|
||||
|
||||
van.add(document.body, UI());
|
||||
van.add(document.body, App());
|
20
deno.json
20
deno.json
@ -1,18 +1,10 @@
|
||||
{
|
||||
"compilerOptions":
|
||||
{
|
||||
"compilerOptions": {
|
||||
"checkJs": true,
|
||||
"lib": ["deno.window", "DOM"],
|
||||
"types": ["./dist/core.d.ts"]
|
||||
},
|
||||
"tasks":
|
||||
{
|
||||
"work": "deno run -Ar ./scripts/dev_server.ts",
|
||||
"scan": "deno run -Ar ./scripts/refresh_types.ts",
|
||||
"html": "deno run -Ar ./scripts/scaffold.ts --html"
|
||||
},
|
||||
"imports":
|
||||
{
|
||||
"entry":"./app.js"
|
||||
"lib": [
|
||||
"deno.window",
|
||||
"DOM"
|
||||
],
|
||||
"types": ["./types.d.ts"]
|
||||
}
|
||||
}
|
95
deno.lock
95
deno.lock
@ -1,95 +0,0 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@std/media-types@*": "1.1.0"
|
||||
},
|
||||
"jsr": {
|
||||
"@std/media-types@1.1.0": {
|
||||
"integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4"
|
||||
}
|
||||
},
|
||||
"redirects": {
|
||||
"https://deno.land/std/path/mod.ts": "https://deno.land/std@0.224.0/path/mod.ts"
|
||||
},
|
||||
"remote": {
|
||||
"https://deno.land/std@0.224.0/assert/assert.ts": "09d30564c09de846855b7b071e62b5974b001bb72a4b797958fe0660e7849834",
|
||||
"https://deno.land/std@0.224.0/assert/assertion_error.ts": "ba8752bd27ebc51f723702fac2f54d3e94447598f54264a6653d6413738a8917",
|
||||
"https://deno.land/std@0.224.0/path/_common/assert_path.ts": "dbdd757a465b690b2cc72fc5fb7698c51507dec6bfafce4ca500c46b76ff7bd8",
|
||||
"https://deno.land/std@0.224.0/path/_common/basename.ts": "569744855bc8445f3a56087fd2aed56bdad39da971a8d92b138c9913aecc5fa2",
|
||||
"https://deno.land/std@0.224.0/path/_common/common.ts": "ef73c2860694775fe8ffcbcdd387f9f97c7a656febf0daa8c73b56f4d8a7bd4c",
|
||||
"https://deno.land/std@0.224.0/path/_common/constants.ts": "dc5f8057159f4b48cd304eb3027e42f1148cf4df1fb4240774d3492b5d12ac0c",
|
||||
"https://deno.land/std@0.224.0/path/_common/dirname.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8",
|
||||
"https://deno.land/std@0.224.0/path/_common/format.ts": "92500e91ea5de21c97f5fe91e178bae62af524b72d5fcd246d6d60ae4bcada8b",
|
||||
"https://deno.land/std@0.224.0/path/_common/from_file_url.ts": "d672bdeebc11bf80e99bf266f886c70963107bdd31134c4e249eef51133ceccf",
|
||||
"https://deno.land/std@0.224.0/path/_common/glob_to_reg_exp.ts": "6cac16d5c2dc23af7d66348a7ce430e5de4e70b0eede074bdbcf4903f4374d8d",
|
||||
"https://deno.land/std@0.224.0/path/_common/normalize.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8",
|
||||
"https://deno.land/std@0.224.0/path/_common/normalize_string.ts": "33edef773c2a8e242761f731adeb2bd6d683e9c69e4e3d0092985bede74f4ac3",
|
||||
"https://deno.land/std@0.224.0/path/_common/relative.ts": "faa2753d9b32320ed4ada0733261e3357c186e5705678d9dd08b97527deae607",
|
||||
"https://deno.land/std@0.224.0/path/_common/strip_trailing_separators.ts": "7024a93447efcdcfeaa9339a98fa63ef9d53de363f1fbe9858970f1bba02655a",
|
||||
"https://deno.land/std@0.224.0/path/_common/to_file_url.ts": "7f76adbc83ece1bba173e6e98a27c647712cab773d3f8cbe0398b74afc817883",
|
||||
"https://deno.land/std@0.224.0/path/_interface.ts": "8dfeb930ca4a772c458a8c7bbe1e33216fe91c253411338ad80c5b6fa93ddba0",
|
||||
"https://deno.land/std@0.224.0/path/_os.ts": "8fb9b90fb6b753bd8c77cfd8a33c2ff6c5f5bc185f50de8ca4ac6a05710b2c15",
|
||||
"https://deno.land/std@0.224.0/path/basename.ts": "7ee495c2d1ee516ffff48fb9a93267ba928b5a3486b550be73071bc14f8cc63e",
|
||||
"https://deno.land/std@0.224.0/path/common.ts": "03e52e22882402c986fe97ca3b5bb4263c2aa811c515ce84584b23bac4cc2643",
|
||||
"https://deno.land/std@0.224.0/path/constants.ts": "0c206169ca104938ede9da48ac952de288f23343304a1c3cb6ec7625e7325f36",
|
||||
"https://deno.land/std@0.224.0/path/dirname.ts": "85bd955bf31d62c9aafdd7ff561c4b5fb587d11a9a5a45e2b01aedffa4238a7c",
|
||||
"https://deno.land/std@0.224.0/path/extname.ts": "593303db8ae8c865cbd9ceec6e55d4b9ac5410c1e276bfd3131916591b954441",
|
||||
"https://deno.land/std@0.224.0/path/format.ts": "6ce1779b0980296cf2bc20d66436b12792102b831fd281ab9eb08fa8a3e6f6ac",
|
||||
"https://deno.land/std@0.224.0/path/from_file_url.ts": "911833ae4fd10a1c84f6271f36151ab785955849117dc48c6e43b929504ee069",
|
||||
"https://deno.land/std@0.224.0/path/glob_to_regexp.ts": "7f30f0a21439cadfdae1be1bf370880b415e676097fda584a63ce319053b5972",
|
||||
"https://deno.land/std@0.224.0/path/is_absolute.ts": "4791afc8bfd0c87f0526eaa616b0d16e7b3ab6a65b62942e50eac68de4ef67d7",
|
||||
"https://deno.land/std@0.224.0/path/is_glob.ts": "a65f6195d3058c3050ab905705891b412ff942a292bcbaa1a807a74439a14141",
|
||||
"https://deno.land/std@0.224.0/path/join.ts": "ae2ec5ca44c7e84a235fd532e4a0116bfb1f2368b394db1c4fb75e3c0f26a33a",
|
||||
"https://deno.land/std@0.224.0/path/join_globs.ts": "5b3bf248b93247194f94fa6947b612ab9d3abd571ca8386cf7789038545e54a0",
|
||||
"https://deno.land/std@0.224.0/path/mod.ts": "f6bd79cb08be0e604201bc9de41ac9248582699d1b2ee0ab6bc9190d472cf9cd",
|
||||
"https://deno.land/std@0.224.0/path/normalize.ts": "4155743ccceeed319b350c1e62e931600272fad8ad00c417b91df093867a8352",
|
||||
"https://deno.land/std@0.224.0/path/normalize_glob.ts": "cc89a77a7d3b1d01053b9dcd59462b75482b11e9068ae6c754b5cf5d794b374f",
|
||||
"https://deno.land/std@0.224.0/path/parse.ts": "77ad91dcb235a66c6f504df83087ce2a5471e67d79c402014f6e847389108d5a",
|
||||
"https://deno.land/std@0.224.0/path/posix/_util.ts": "1e3937da30f080bfc99fe45d7ed23c47dd8585c5e473b2d771380d3a6937cf9d",
|
||||
"https://deno.land/std@0.224.0/path/posix/basename.ts": "d2fa5fbbb1c5a3ab8b9326458a8d4ceac77580961b3739cd5bfd1d3541a3e5f0",
|
||||
"https://deno.land/std@0.224.0/path/posix/common.ts": "26f60ccc8b2cac3e1613000c23ac5a7d392715d479e5be413473a37903a2b5d4",
|
||||
"https://deno.land/std@0.224.0/path/posix/constants.ts": "93481efb98cdffa4c719c22a0182b994e5a6aed3047e1962f6c2c75b7592bef1",
|
||||
"https://deno.land/std@0.224.0/path/posix/dirname.ts": "76cd348ffe92345711409f88d4d8561d8645353ac215c8e9c80140069bf42f00",
|
||||
"https://deno.land/std@0.224.0/path/posix/extname.ts": "e398c1d9d1908d3756a7ed94199fcd169e79466dd88feffd2f47ce0abf9d61d2",
|
||||
"https://deno.land/std@0.224.0/path/posix/format.ts": "185e9ee2091a42dd39e2a3b8e4925370ee8407572cee1ae52838aed96310c5c1",
|
||||
"https://deno.land/std@0.224.0/path/posix/from_file_url.ts": "951aee3a2c46fd0ed488899d024c6352b59154c70552e90885ed0c2ab699bc40",
|
||||
"https://deno.land/std@0.224.0/path/posix/glob_to_regexp.ts": "76f012fcdb22c04b633f536c0b9644d100861bea36e9da56a94b9c589a742e8f",
|
||||
"https://deno.land/std@0.224.0/path/posix/is_absolute.ts": "cebe561ad0ae294f0ce0365a1879dcfca8abd872821519b4fcc8d8967f888ede",
|
||||
"https://deno.land/std@0.224.0/path/posix/is_glob.ts": "8a8b08c08bf731acf2c1232218f1f45a11131bc01de81e5f803450a5914434b9",
|
||||
"https://deno.land/std@0.224.0/path/posix/join.ts": "7fc2cb3716aa1b863e990baf30b101d768db479e70b7313b4866a088db016f63",
|
||||
"https://deno.land/std@0.224.0/path/posix/join_globs.ts": "a9475b44645feddceb484ee0498e456f4add112e181cb94042cdc6d47d1cdd25",
|
||||
"https://deno.land/std@0.224.0/path/posix/mod.ts": "2301fc1c54a28b349e20656f68a85f75befa0ee9b6cd75bfac3da5aca9c3f604",
|
||||
"https://deno.land/std@0.224.0/path/posix/normalize.ts": "baeb49816a8299f90a0237d214cef46f00ba3e95c0d2ceb74205a6a584b58a91",
|
||||
"https://deno.land/std@0.224.0/path/posix/normalize_glob.ts": "9c87a829b6c0f445d03b3ecadc14492e2864c3ebb966f4cea41e98326e4435c6",
|
||||
"https://deno.land/std@0.224.0/path/posix/parse.ts": "09dfad0cae530f93627202f28c1befa78ea6e751f92f478ca2cc3b56be2cbb6a",
|
||||
"https://deno.land/std@0.224.0/path/posix/relative.ts": "3907d6eda41f0ff723d336125a1ad4349112cd4d48f693859980314d5b9da31c",
|
||||
"https://deno.land/std@0.224.0/path/posix/resolve.ts": "08b699cfeee10cb6857ccab38fa4b2ec703b0ea33e8e69964f29d02a2d5257cf",
|
||||
"https://deno.land/std@0.224.0/path/posix/to_file_url.ts": "7aa752ba66a35049e0e4a4be5a0a31ac6b645257d2e031142abb1854de250aaf",
|
||||
"https://deno.land/std@0.224.0/path/posix/to_namespaced_path.ts": "28b216b3c76f892a4dca9734ff1cc0045d135532bfd9c435ae4858bfa5a2ebf0",
|
||||
"https://deno.land/std@0.224.0/path/relative.ts": "ab739d727180ed8727e34ed71d976912461d98e2b76de3d3de834c1066667add",
|
||||
"https://deno.land/std@0.224.0/path/resolve.ts": "a6f977bdb4272e79d8d0ed4333e3d71367cc3926acf15ac271f1d059c8494d8d",
|
||||
"https://deno.land/std@0.224.0/path/to_file_url.ts": "88f049b769bce411e2d2db5bd9e6fd9a185a5fbd6b9f5ad8f52bef517c4ece1b",
|
||||
"https://deno.land/std@0.224.0/path/to_namespaced_path.ts": "b706a4103b104cfadc09600a5f838c2ba94dbcdb642344557122dda444526e40",
|
||||
"https://deno.land/std@0.224.0/path/windows/_util.ts": "d5f47363e5293fced22c984550d5e70e98e266cc3f31769e1710511803d04808",
|
||||
"https://deno.land/std@0.224.0/path/windows/basename.ts": "6bbc57bac9df2cec43288c8c5334919418d784243a00bc10de67d392ab36d660",
|
||||
"https://deno.land/std@0.224.0/path/windows/common.ts": "26f60ccc8b2cac3e1613000c23ac5a7d392715d479e5be413473a37903a2b5d4",
|
||||
"https://deno.land/std@0.224.0/path/windows/constants.ts": "5afaac0a1f67b68b0a380a4ef391bf59feb55856aa8c60dfc01bd3b6abb813f5",
|
||||
"https://deno.land/std@0.224.0/path/windows/dirname.ts": "33e421be5a5558a1346a48e74c330b8e560be7424ed7684ea03c12c21b627bc9",
|
||||
"https://deno.land/std@0.224.0/path/windows/extname.ts": "165a61b00d781257fda1e9606a48c78b06815385e7d703232548dbfc95346bef",
|
||||
"https://deno.land/std@0.224.0/path/windows/format.ts": "bbb5ecf379305b472b1082cd2fdc010e44a0020030414974d6029be9ad52aeb6",
|
||||
"https://deno.land/std@0.224.0/path/windows/from_file_url.ts": "ced2d587b6dff18f963f269d745c4a599cf82b0c4007356bd957cb4cb52efc01",
|
||||
"https://deno.land/std@0.224.0/path/windows/glob_to_regexp.ts": "e45f1f89bf3fc36f94ab7b3b9d0026729829fabc486c77f414caebef3b7304f8",
|
||||
"https://deno.land/std@0.224.0/path/windows/is_absolute.ts": "4a8f6853f8598cf91a835f41abed42112cebab09478b072e4beb00ec81f8ca8a",
|
||||
"https://deno.land/std@0.224.0/path/windows/is_glob.ts": "8a8b08c08bf731acf2c1232218f1f45a11131bc01de81e5f803450a5914434b9",
|
||||
"https://deno.land/std@0.224.0/path/windows/join.ts": "8d03530ab89195185103b7da9dfc6327af13eabdcd44c7c63e42e27808f50ecf",
|
||||
"https://deno.land/std@0.224.0/path/windows/join_globs.ts": "a9475b44645feddceb484ee0498e456f4add112e181cb94042cdc6d47d1cdd25",
|
||||
"https://deno.land/std@0.224.0/path/windows/mod.ts": "2301fc1c54a28b349e20656f68a85f75befa0ee9b6cd75bfac3da5aca9c3f604",
|
||||
"https://deno.land/std@0.224.0/path/windows/normalize.ts": "78126170ab917f0ca355a9af9e65ad6bfa5be14d574c5fb09bb1920f52577780",
|
||||
"https://deno.land/std@0.224.0/path/windows/normalize_glob.ts": "9c87a829b6c0f445d03b3ecadc14492e2864c3ebb966f4cea41e98326e4435c6",
|
||||
"https://deno.land/std@0.224.0/path/windows/parse.ts": "08804327b0484d18ab4d6781742bf374976de662f8642e62a67e93346e759707",
|
||||
"https://deno.land/std@0.224.0/path/windows/relative.ts": "3e1abc7977ee6cc0db2730d1f9cb38be87b0ce4806759d271a70e4997fc638d7",
|
||||
"https://deno.land/std@0.224.0/path/windows/resolve.ts": "8dae1dadfed9d46ff46cc337c9525c0c7d959fb400a6308f34595c45bdca1972",
|
||||
"https://deno.land/std@0.224.0/path/windows/to_file_url.ts": "40e560ee4854fe5a3d4d12976cef2f4e8914125c81b11f1108e127934ced502e",
|
||||
"https://deno.land/std@0.224.0/path/windows/to_namespaced_path.ts": "4ffa4fb6fae321448d5fe810b3ca741d84df4d7897e61ee29be961a6aac89a4c"
|
||||
}
|
||||
}
|
14
dist/core.js
vendored
14
dist/core.js
vendored
@ -1,14 +0,0 @@
|
||||
//van
|
||||
{let e,t,r,o,n,l,s,i,f,h,w,a,d,u,_,c,S,g,y,b,m,v,j,x,O;s=Object.getPrototypeOf,f={},h=s(i={isConnected:1}),w=s(s),a=(e,t,r,o)=>(e??(setTimeout(r,o),new Set)).add(t),d=(e,t,o)=>{let n=r;r=t;try{return e(o)}catch(e){return console.error(e),o}finally{r=n}},u=e=>e.filter(e=>e.t?.isConnected),_=e=>n=a(n,e,()=>{for(let e of n)e.o=u(e.o),e.l=u(e.l);n=l},1e3),c={get val(){return r?.i?.add(this),this.rawVal},get oldVal(){return r?.i?.add(this),this.h},set val(o){r?.u?.add(this),o!==this.rawVal&&(this.rawVal=o,this.o.length+this.l.length?(t?.add(this),e=a(e,this,x)):this.h=o)}},S=e=>({__proto__:c,rawVal:e,h:e,o:[],l:[]}),g=(e,t)=>{let r={i:new Set,u:new Set},n={f:e},l=o;o=[];let s=d(e,r,t);s=(s??document).nodeType?s:new Text(s);for(let e of r.i)r.u.has(e)||(_(e),e.o.push(n));for(let e of o)e.t=s;return o=l,n.t=s},y=(e,t=S(),r)=>{let n={i:new Set,u:new Set},l={f:e,s:t};l.t=r??o?.push(l)??i,t.val=d(e,n,t.rawVal);for(let e of n.i)n.u.has(e)||(_(e),e.l.push(l));return t},b=(e,...t)=>{for(let r of t.flat(1/0)){let t=s(r??0),o=t===c?g(()=>r.val):t===w?g(r):r;o!=l&&e.append(o)}return e},m=(e,t,...r)=>{let[{is:o,...n},...i]=s(r[0]??0)===h?r:[{},...r],a=e?document.createElementNS(e,t,{is:o}):document.createElement(t,{is:o});for(let[e,r]of Object.entries(n)){let o=t=>t?Object.getOwnPropertyDescriptor(t,e)??o(s(t)):l,n=t+","+e,i=f[n]??=o(s(a))?.set??0,h=e.startsWith("on")?(t,r)=>{let o=e.slice(2);a.removeEventListener(o,r),a.addEventListener(o,t)}:i?i.bind(a):a.setAttribute.bind(a,e),d=s(r??0);e.startsWith("on")||d===w&&(r=y(r),d=c),d===c?g(()=>(h(r.val,r.h),a)):h(r)}return b(a,i)},v=e=>({get:(t,r)=>m.bind(l,e,r)}),j=(e,t)=>t?t!==e&&e.replaceWith(t):e.remove(),x=()=>{let r=0,o=[...e].filter(e=>e.rawVal!==e.h);do{t=new Set;for(let e of new Set(o.flatMap(e=>e.l=u(e.l))))y(e.f,e.s,e.t),e.t=l}while(++r<100&&(o=[...t]).length);let n=[...e].filter(e=>e.rawVal!==e.h);e=l;for(let e of new Set(n.flatMap(e=>e.o=u(e.o))))j(e.t,g(e.f,e.t)),e.t=l;for(let e of n)e.h=e.rawVal},O={tags:new Proxy(e=>new Proxy(m,v(e)),v()),hydrate:(e,t)=>j(e,g(t,e)),add:b,state:S,derive:y},window.van=O;}
|
||||
|
||||
//vanx
|
||||
{let e,t,r,{fromEntries:o,entries:l,keys:n,hasOwn:f,getPrototypeOf:a}=Object,{get:i,set:y,deleteProperty:c,ownKeys:s}=Reflect,{state:m,derive:d,add:u}=van,b=1e3,w=Symbol(),A=Symbol(),S=Symbol(),_=Symbol(),g=Symbol(),p=Symbol(),P=e=>(e[A]=1,e),v=e=>e instanceof Object&&!(e instanceof Function)&&!e[p],h=e=>{if(e?.[A]){let t=m();return d(()=>{let r=e();v(t.rawVal)&&v(r)?B(t.rawVal,r):t.val=x(r)}),t}return m(x(e))},F=e=>{let t=Array.isArray(e)?[]:{__proto__:a(e)};for(let[r,o]of l(e))t[r]=h(o);return t[S]=[],t[_]=m(1),t},O={get:(e,t,r)=>t===w?e:f(e,t)?Array.isArray(e)&&"length"===t?(e[_].val,e.length):e[t].val:i(e,t,r),set:(e,o,l,n)=>f(e,o)?Array.isArray(e)&&"length"===o?(l!==e.length&&++e[_].val,e.length=l,1):(e[o].val=x(l),1):o in e?y(e,o,l,n):y(e,o,h(l))&&(++e[_].val,C(e).forEach(E.bind(t,n,o,e[o],r)),1),deleteProperty:(e,t)=>(c(e,t)&&R(e,t),++e[_].val),ownKeys:e=>(e[_].val,s(e))},x=e=>!v(e)||e[w]?e:new Proxy(F(e),O),D=e=>(e[p]=1,e),j=e=>e[w],K=a(m()),N=e=>new Proxy(e,{get:(e,t,r)=>a(e[t]??0)===K?{val:k(e[t].rawVal)}:i(e,t,r)}),k=e=>e?.[w]?new Proxy(N(e[w]),O):e,C=e=>e[S]=e[S].filter(e=>e.t.isConnected),E=(e,t,r,o,{t:l,f:f})=>{let a=Array.isArray(e),i=a?Number(t):t;u(l,()=>l[g][t]=f(r,()=>delete e[t],i)),a&&!o&&i!==e.length-1&&l.insertBefore(l.lastChild,l[g][n(e).find(e=>Number(e)>i)])},R=(e,t)=>{for(let r of C(e)){let e=r.t[g];e[t]?.remove(),delete e[t]}},T=r=>(e??(setTimeout(()=>(e.forEach(C),e=t),b),e=new Set)).add(r),q=(e,t,r)=>{let o={t:e instanceof Function?e():e,f:r},n=t[w];o.t[g]={},n[S].push(o),T(n);for(let[e,r]of l(n))E(t,e,r,1,o);return o.t},z=(e,t)=>{for(let[r,o]of l(t)){let t=e[r];v(t)&&v(o)?z(t,o):e[r]=o}for(let r in e)f(t,r)||delete e[r];let r=n(t),o=Array.isArray(e);if(o||n(e).some((e,t)=>e!==r[t])){let l=e[w];if(o)e.length=t.length;else{++l[_].val;let e={...l};for(let e of r)delete l[e];for(let t of r)l[t]=e[t]}for(let{t:e}of C(l)){let{firstChild:t,[g]:o}=e;for(let l of r)t===o[l]?t=t.nextSibling:e.insertBefore(o[l],t)}}return e},B=(e,n)=>{r=1;try{return z(e,n instanceof Function?Array.isArray(e)?n(e.filter(e=>1)):o(n(l(e))):n)}finally{r=t}},G=e=>Array.isArray(e)?e.filter(e=>1).map(G):v(e)?o(l(e).map(([e,t])=>[e,G(t)])):e;window.vanX={calc:P,reactive:x,noreactive:D,stateFields:j,raw:k,list:q,replace:B,compact:G}}
|
||||
|
||||
//Store
|
||||
vanX.Store=(e,t)=>{const a=localStorage.getItem(t),r=vanX.reactive(a?JSON.parse(a):e);return van.derive((()=>localStorage.setItem(t,JSON.stringify(vanX.compact(r))))),r};
|
||||
|
||||
//gale
|
||||
globalThis.Gale=(e,t="")=>{const n=(e,t,s)=>`${e}{${Object.keys(t).map((e=>{const r=t[e];switch(e[0]){case"@":return n(`@media(max-width:${e.substring(1)})`,r,s);case":":return n(`&${e}`,r,s);case".":return n(`${e}${s}`,r,s);case"^":return n(`&:hover .${e.substring(1)}${s}`,r,s)}return`${e.replace(/([a-z])([A-Z])/g,"$1-$2")}: ${r};`})).join("\n")}}`,s=(e,t)=>{const n=t.lastIndexOf(e)+e.length;return n?t.substring(n):t},r=e=>{const t=van.tags[e];let n=[];const s=new Proxy(((...e)=>{const s=t(...e);return s.className=n.join(a+" ")+a+" "+s.className,n=[],s}),{get:(e,t)=>(n.push(t.substring(t.lastIndexOf(".")+1)),s)});return s},a=t?"_"+t:"",c=Object.keys(e).map((t=>n("."+t+a,e[t],a))).join("\n");return globalThis.document?.head.insertAdjacentHTML("beforeend",`<style data-sheet="${a}">${c}</style>`),{Tag:(...e)=>e.map((e=>s("^",s(".",e)))).join(a+" ")+a,CSS:c,DOM:new Proxy({},{get:(e,t)=>r(t)}),H:new Proxy({},{get:(e,t)=>r("div")[t]})}};
|
||||
|
||||
//boot
|
||||
((t="/")=>{fetch(t+"deno.json").then((t=>t.json())).then((e=>{const n=(t,e)=>{let n=document.createElement("script");n.type=t,n.textContent=e,document.head.appendChild(n)},o=e.imports;for(let e in o){const n=o[e];n.startsWith("./")&&(o[e]=t+n.substring(2))}n("importmap",JSON.stringify({imports:o})),n("module",'import "entry"; ')}))})();
|
9
dist/index.html
vendored
9
dist/index.html
vendored
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- css reset --><style>*{margin:0;padding:0;box-sizing:border-box;}html, body{height:100%;width:100%;font-family:Arial, sans-serif;line-height:1.6;}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img, video{max-width:100%;height:auto;}a{text-decoration:none;color:inherit;}ul, ol{list-style:none;}button, input, textarea{font-family:inherit;font-size:inherit;line-height:inherit;border:none;background:none;padding:0;margin:0;outline:none;}table{border-collapse:collapse;width:100%;}</style>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
77
gale.js
Normal file
77
gale.js
Normal file
@ -0,0 +1,77 @@
|
||||
const KeyQuery = "@";
|
||||
const KeyPseudo = ":";
|
||||
const KeyChild = ".";
|
||||
const KeyGroup = "^";
|
||||
|
||||
/** @type {Gale.Tier} */
|
||||
const Tier=(selector, obj)=>
|
||||
{
|
||||
const styles = Object.keys(obj).map((key)=>
|
||||
{
|
||||
const value = obj[key];
|
||||
switch(key[0])
|
||||
{
|
||||
case KeyQuery :
|
||||
return Tier(`@media(max-width:${key.substring(KeyQuery.length)})`, value);
|
||||
case KeyPseudo :
|
||||
return Tier(`&${key}`, value);
|
||||
case KeyChild :
|
||||
return Tier(`${key}`, value);
|
||||
case KeyGroup :
|
||||
return Tier(`&:hover .${key.substring(KeyGroup.length)}`, value);
|
||||
}
|
||||
return `${ key.replace(/([a-z])([A-Z])/g, '$1-$2') }: ${value};`
|
||||
});
|
||||
return `${selector}{${styles.join("\n")}}`;
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
/** @type {Gale.CreateSheet} */
|
||||
const Gale = (sheet)=>
|
||||
{
|
||||
const id = i ? "_"+i : "";
|
||||
i++;
|
||||
const css = Object.keys(sheet).map(key=>Tier("."+key, sheet[key])).join(`\n`);
|
||||
globalThis.document?.head.insertAdjacentHTML("beforeend", `<style data-sheet="${i}">${css}</style>`);
|
||||
const classes =(...args)=>{
|
||||
/** @type {(needle:string, str:string)=>string} */
|
||||
const extractLast =(needle, str)=>{
|
||||
const ind = str.lastIndexOf(needle)+needle.length;
|
||||
return ind ? str.substring(ind) : str;
|
||||
}
|
||||
return args.map((arg)=>extractLast(KeyGroup, extractLast(KeyChild, arg))).join(id+" ")+id;
|
||||
}
|
||||
|
||||
let pending = false;
|
||||
let mentioned = [];
|
||||
const collector = new Proxy(
|
||||
(...args)=>
|
||||
{
|
||||
const element = van.tags[pending](...args);
|
||||
element.className = mentioned.join(" ");
|
||||
return element;
|
||||
},
|
||||
{
|
||||
get(_, prop)
|
||||
{
|
||||
mentioned.push(prop.substring(prop.lastIndexOf(".")+1));
|
||||
return collector;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
classes.CSS = css;
|
||||
classes.DOM = new Proxy(
|
||||
{},
|
||||
{get(_, prop)
|
||||
{
|
||||
pending = prop;
|
||||
mentioned = [];
|
||||
return collector;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return classes;
|
||||
}
|
89
index.html
89
index.html
@ -1,11 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- css reset --><style>*{margin:0;padding:0;box-sizing:border-box;}html, body{height:100%;width:100%;font-family:Arial, sans-serif;line-height:1.6;}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img, video{max-width:100%;height:auto;}a{text-decoration:none;color:inherit;}ul, ol{list-style:none;}button, input, textarea{font-family:inherit;font-size:inherit;line-height:inherit;border:none;background:none;padding:0;margin:0;outline:none;}table{border-collapse:collapse;width:100%;}</style>
|
||||
<script src="./dist/core.js"></script>
|
||||
<script src="./src/gale.js"></script>
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body></body>
|
||||
<body>
|
||||
<script src="https://vanjs.org/code/van-1.5.3.nomodule.min.js"></script>
|
||||
<script>
|
||||
//@ts-check
|
||||
// hmr
|
||||
const HMR = globalThis.HMR = {
|
||||
Time: 0,
|
||||
/** @type {Record<string, string>} */
|
||||
Temp:{},
|
||||
Tick()
|
||||
{
|
||||
for(const k in HMR.Temp)
|
||||
{
|
||||
sessionStorage.setItem(k, HMR.Temp[k]);
|
||||
}
|
||||
HMR.Temp = {};
|
||||
HMR.Time = 0;
|
||||
},
|
||||
/** @type {(key:string, value:string)=>void} */
|
||||
Save(key, value)
|
||||
{
|
||||
this.Temp[key] = value;
|
||||
if(!this.Time)
|
||||
{
|
||||
this.Time = setTimeout(this.Tick, 500);
|
||||
}
|
||||
console.log("SAVE", key, value);
|
||||
},
|
||||
/** @type {(key:string)=>string|null} */
|
||||
Load(key)
|
||||
{
|
||||
const value = sessionStorage.getItem(key);
|
||||
console.log("LOAD", key, value);
|
||||
return value;
|
||||
},
|
||||
|
||||
/** @type {string|undefined} */
|
||||
_ID: undefined,
|
||||
_index: 0,
|
||||
/** @type {(id:string|undefined = undefined)=>void} */
|
||||
StartID(id)
|
||||
{
|
||||
this._index = 0;
|
||||
this._ID = id;
|
||||
},
|
||||
NextID()
|
||||
{
|
||||
return this._ID ? this._ID + "_" + (this._index++) + "_" : "";
|
||||
}
|
||||
}
|
||||
|
||||
//bind Van
|
||||
const origninalState = globalThis.van.state;
|
||||
globalThis.van.state =(value, key="")=>
|
||||
{
|
||||
const type = typeof value;
|
||||
let reader =d=>d;
|
||||
let writer =d=>d?.toString() || null;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case "boolean" :
|
||||
reader =(data)=> data === "true"; break;
|
||||
case "number" :
|
||||
reader = parseFloat; break;
|
||||
case "object" :
|
||||
reader = JSON.parse;
|
||||
writer = JSON.stringify;
|
||||
break;
|
||||
}
|
||||
|
||||
const fullKey = "HMR_" + HMR.NextID() + key;
|
||||
const stringValue = HMR.Load(fullKey);
|
||||
const signal = origninalState((stringValue ? reader(stringValue) : value));
|
||||
van.derive(()=>HMR.Save(fullKey, writer(signal.val)));
|
||||
|
||||
return signal;
|
||||
};
|
||||
|
||||
</script>
|
||||
<script src="./gale.js"></script>
|
||||
<script type="module" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
48
keys.js
Normal file
48
keys.js
Normal file
@ -0,0 +1,48 @@
|
||||
const Move = {
|
||||
Keys: ["w", "d", "s", "a"],
|
||||
Pair: [ 2, 3, 0, 1 ],
|
||||
Axis: [ 1, 0, 1, 0 ],
|
||||
Magn: [-1, 1, 1, -1 ],
|
||||
Down: [ 0, 0, 0, 0 ],
|
||||
Move: [0, 0],
|
||||
};
|
||||
|
||||
/** @type {Van.state<[x:number, y:number]>} */
|
||||
export const Pos = van.state(Move.Move);
|
||||
|
||||
/** @type {(scale:number)=>string} */
|
||||
export const PosCSS =(scale)=> `left:${Pos.val[0]*scale}px; top:${Pos.val[1]*scale}px;`;
|
||||
|
||||
function handleDown({key})
|
||||
{
|
||||
const index = Move.Keys.indexOf(key);
|
||||
if(index != -1)
|
||||
{
|
||||
Move.Down[index] = 1;
|
||||
Move.Move[Move.Axis[index]] = Move.Magn[index];
|
||||
Pos.val = [...Move.Move];
|
||||
}
|
||||
|
||||
}
|
||||
function handleUp({key})
|
||||
{
|
||||
const index = Move.Keys.indexOf(key);
|
||||
if(index != -1)
|
||||
{
|
||||
const indexInv = Move.Pair[index];
|
||||
Move.Down[index] = 0;
|
||||
if(Move.Down[indexInv])
|
||||
{
|
||||
Move.Move[Move.Axis[indexInv]] = Move.Magn[indexInv];
|
||||
}
|
||||
else
|
||||
{
|
||||
Move.Move[Move.Axis[index]] = 0;
|
||||
}
|
||||
Pos.val = [...Move.Move];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.body.addEventListener("keydown", handleDown);
|
||||
document.body.addEventListener("keyup", handleUp);
|
@ -1,6 +0,0 @@
|
||||
const bundle = await fetch(import.meta.resolve("../dist/core.js")).then(r=>r.text());
|
||||
const index = await fetch(import.meta.resolve("../dist/index.html")).then(r=>r.text());
|
||||
export const HTML = index.replace(`</head>`, `<script>${bundle}</script></head>`);
|
||||
export const Root = import.meta.resolve("../");
|
||||
export const Load =async(file:string)=> await fetch(Root + file).then(resp=>resp.text());
|
||||
export const Save =async(text:string, name:string)=> await Deno.writeTextFile(name, text);
|
@ -1,73 +0,0 @@
|
||||
import { contentType } from "jsr:@std/media-types";
|
||||
import {HTML} from "./assemble_files.ts";
|
||||
|
||||
// Parse the port from the command-line arguments, defaulting to 8000
|
||||
const port = parseInt(Deno.args[0] || "8000", 10);
|
||||
const sockets: WebSocket[] = [];
|
||||
const devinc = await fetch(import.meta.resolve("../src/dev.js")).then(r=>r.text());
|
||||
|
||||
let html: string;
|
||||
try {
|
||||
html = Deno.readTextFileSync("./index.html");
|
||||
} catch (_) {
|
||||
html = HTML;
|
||||
}
|
||||
html = html.replace("</head>", `<script>${devinc}</script></head>`);
|
||||
|
||||
function extension(path: string): string {
|
||||
// Remove trailing slash if it exists
|
||||
const normalizedPath = path.endsWith("/") ? path.slice(0, -1) : path;
|
||||
// Get the last part of the path
|
||||
const lastPart = normalizedPath.split("/").pop() || "";
|
||||
// Check if the last part contains a "."
|
||||
return lastPart.split(".")[1] || "";
|
||||
}
|
||||
|
||||
// Start the HTTP server using Deno.serve
|
||||
Deno.serve({ port }, async (req: Request) => {
|
||||
const url = new URL(req.url);
|
||||
|
||||
// Handle WebSocket connections
|
||||
if (url.pathname === "/ws") {
|
||||
const { socket, response } = Deno.upgradeWebSocket(req);
|
||||
sockets.push(socket);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Serve static files or the predefined HTML for non-file routes
|
||||
const path = new URL(req.url).pathname;
|
||||
const ext = extension(path);
|
||||
|
||||
// Serve the predefined HTML for non-file routes
|
||||
if (!ext) {
|
||||
return new Response(html, {
|
||||
headers: { "Content-Type": "text/html" },
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const file = await Deno.open("." + path, { read: true });
|
||||
return new Response(file.readable, {
|
||||
headers: { "Content-Type": contentType(ext) || "application/javascript" },
|
||||
});
|
||||
} catch (err) {
|
||||
if (err instanceof Deno.errors.NotFound) {
|
||||
return new Response("File not found", { status: 404 });
|
||||
} else {
|
||||
return new Response("Internal server error", { status: 500 });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Start watching for file changes
|
||||
const watcher = Deno.watchFs(".");
|
||||
for await (const event of watcher) {
|
||||
if (event.kind === "modify") {
|
||||
for (const ws of sockets) {
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send("reload");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
import { resolve, toFileUrl } from "https://deno.land/std/path/mod.ts";
|
||||
|
||||
async function main()
|
||||
{
|
||||
// Read and parse the deno.json file
|
||||
const denoJson = JSON.parse(await Deno.readTextFile("./deno.json"));
|
||||
|
||||
// Check if compilerOptions and types are defined
|
||||
if (denoJson.compilerOptions?.types) {
|
||||
const types:string[] = denoJson.compilerOptions.types;
|
||||
|
||||
// Iterate over each type file and cache it
|
||||
for (const typeFile of types) {
|
||||
let lookup:string = typeFile;
|
||||
if(!typeFile.startsWith("http"))
|
||||
{
|
||||
lookup = toFileUrl(resolve(Deno.cwd(), typeFile)).href;
|
||||
}
|
||||
console.log(`Scan found types: ${lookup}`);
|
||||
await import(lookup); // This will cache the file
|
||||
}
|
||||
|
||||
console.log("Scan complete; be sure to restart the Deno Language Server!!");
|
||||
|
||||
} else {
|
||||
console.log("No types found in compilerOptions.");
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Error:", error);
|
||||
Deno.exit(1);
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
import { parseArgs } from "jsr:@std/cli/parse-args";
|
||||
import {HTML, Save, Load, Root} from "./assemble_files.ts";
|
||||
|
||||
const args = parseArgs(Deno.args);
|
||||
if(args.html)
|
||||
{
|
||||
Save(HTML, "index.html");
|
||||
}
|
||||
else
|
||||
{
|
||||
const config = await Load("deno.json");
|
||||
Save(config.replaceAll("./scripts/", Root+"scripts/").replaceAll("./dist/", Root+"dist/"), "deno.json");
|
||||
Save(await Load("app.js"), "app.js");
|
||||
}
|
43
shadow.html
43
shadow.html
@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Shadow DOM Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<script>
|
||||
// Define the custom web component
|
||||
class APP extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// Attach a shadow root to the custom element
|
||||
const shadowRoot = this.attachShadow({ mode: 'open' });
|
||||
|
||||
// Add custom markup and styles to the shadow root
|
||||
shadowRoot.innerHTML = `
|
||||
<style>
|
||||
.shadow-content {
|
||||
color: white;
|
||||
background-color: black;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
<div class="shadow-content">
|
||||
This is content inside the shadow root of a web component.
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
// Register the custom element
|
||||
customElements.define('gale-app', APP);
|
||||
</script>
|
||||
|
||||
<gale-app></gale-app>
|
||||
</body>
|
||||
</html>
|
15
src/boot.js
15
src/boot.js
@ -1,15 +0,0 @@
|
||||
(
|
||||
(root="/")=>fetch(root+"deno.json")
|
||||
.then(text=>text.json())
|
||||
.then(json=>{
|
||||
const n=(t,e)=>{let n=document.createElement("script");n.type=t,n.textContent=e,document.head.appendChild(n)};
|
||||
const imports = json.imports;
|
||||
for(let n in imports)
|
||||
{
|
||||
const path=imports[n];
|
||||
path.startsWith("./")&&(imports[n]=root+path.substring(2))
|
||||
}
|
||||
n("importmap",JSON.stringify({imports})),
|
||||
n("module",'import "entry"; ')
|
||||
})
|
||||
)();
|
33
src/dev.js
33
src/dev.js
@ -1,33 +0,0 @@
|
||||
// added in devmode to index.html
|
||||
|
||||
new WebSocket('ws://'+window.location.host+'/ws').addEventListener('message',e=>e.data==='reload'&&window.location.reload());
|
||||
|
||||
vanX.Store =(obj, key)=>
|
||||
{
|
||||
let checkInit = JSON.stringify(obj);
|
||||
let checkStore = localStorage.getItem(key+"check");
|
||||
localStorage.setItem(key+"check", checkInit);
|
||||
|
||||
let recallJSON;
|
||||
if(checkInit == checkStore)
|
||||
{
|
||||
let recallText = localStorage.getItem(key);
|
||||
try
|
||||
{
|
||||
recallJSON = JSON.parse(recallText) || obj;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
recallJSON = obj;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
recallJSON = obj;
|
||||
}
|
||||
|
||||
const store = vanX.reactive( recallJSON );
|
||||
van.derive(() => localStorage.setItem(key, JSON.stringify(vanX.compact(store))));
|
||||
return store;
|
||||
}
|
89
src/gale.js
89
src/gale.js
@ -1,89 +0,0 @@
|
||||
/** @type {Gale.CreateSheet} */
|
||||
globalThis.Gale = (sheet, hash="")=>
|
||||
{
|
||||
const KeyQuery = "@";
|
||||
const KeyState = ":";
|
||||
const KeyChild = ".";
|
||||
const KeyGroup = "^";
|
||||
|
||||
/** @type {Gale.Tier} */
|
||||
const Tier=(selector, obj, suffix)=>
|
||||
{
|
||||
const styles = Object.keys(obj).map((key)=>
|
||||
{
|
||||
const value = obj[key];
|
||||
switch(key[0])
|
||||
{
|
||||
case KeyQuery :
|
||||
return Tier(`@media(max-width:${key.substring(KeyQuery.length)})`, value, suffix);
|
||||
case KeyState :
|
||||
return Tier(`&${key}`, value, suffix);
|
||||
case KeyChild :
|
||||
return Tier(`${key}${suffix}`, value, suffix);
|
||||
case KeyGroup :
|
||||
return Tier(`&:hover .${key.substring(KeyGroup.length)}${suffix}`, value, suffix);
|
||||
}
|
||||
return `${ key.replace(/([a-z])([A-Z])/g, '$1-$2') }: ${value};`
|
||||
});
|
||||
|
||||
return `${selector}{${styles.join("\n")}}`;
|
||||
}
|
||||
|
||||
/** @type {(needle:string, str:string)=>string} */
|
||||
const extractLast =(needle, str)=>{
|
||||
const ind = str.lastIndexOf(needle)+needle.length;
|
||||
return ind ? str.substring(ind) : str;
|
||||
}
|
||||
|
||||
const collect =(tagName)=>
|
||||
{
|
||||
const pending = van.tags[tagName];
|
||||
let mentioned = [];
|
||||
const collector = new Proxy(
|
||||
(...args)=>
|
||||
{
|
||||
const element = pending(...args);
|
||||
element.className = mentioned.join(id+" ")+id + " " + element.className;
|
||||
mentioned = [];
|
||||
return element;
|
||||
},
|
||||
{
|
||||
get(_, prop)
|
||||
{
|
||||
mentioned.push(prop.substring(prop.lastIndexOf(".")+1));
|
||||
return collector;
|
||||
}
|
||||
}
|
||||
);
|
||||
return collector;
|
||||
}
|
||||
|
||||
const id = hash ? "_"+hash : "";
|
||||
const css = Object.keys(sheet).map(key=>Tier("."+key+id, sheet[key], id)).join(`\n`);
|
||||
globalThis.document?.head.insertAdjacentHTML("beforeend", `<style data-sheet="${id}">${css}</style>`);
|
||||
|
||||
return {
|
||||
Tag(...args){
|
||||
return args.map((arg)=>extractLast(KeyGroup, extractLast(KeyChild, arg))).join(id+" ")+id;
|
||||
},
|
||||
CSS: css,
|
||||
DOM: new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, prop)
|
||||
{
|
||||
return collect(prop)
|
||||
}
|
||||
}
|
||||
),
|
||||
H: new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, prop)
|
||||
{
|
||||
return collect("div")[prop]
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
28
dist/core.d.ts → types.d.ts
vendored
28
dist/core.d.ts → types.d.ts
vendored
@ -62,42 +62,30 @@ declare global
|
||||
readonly noreactive: <T extends object>(obj: T) => T
|
||||
readonly stateFields: <T extends object>(obj: T) => VanX.StateOf<T>
|
||||
readonly raw: <T extends object>(obj: T) => T
|
||||
readonly list: <T extends object, ElementType extends Element>(
|
||||
container: (() => ElementType) | ElementType,
|
||||
items: T,itemFunc: (v: Van.State<VanX.ValueType<T>>, deleter: () => void, k: VanX.KeyType<T>) => Node
|
||||
) => ElementType
|
||||
readonly list: <T extends object, ElementType extends Element>(container: (() => ElementType) | ElementType, items: T,itemFunc: (v: Van.State<VanX.ValueType<T>>, deleter: () => void, k: VanX.KeyType<T>) => Node) => ElementType
|
||||
readonly replace: <T extends object>(obj: T, replacement: VanX.ReplacementFunc<T> | T) => T
|
||||
readonly compact: <T extends object>(obj: T) => T
|
||||
// my addition
|
||||
readonly Store: <T extends object>(obj:T, key:string)=>T
|
||||
};
|
||||
|
||||
namespace Gale {
|
||||
type KeyQuery = "@";
|
||||
type KeyState = ":";
|
||||
type KeyPseudo = ":";
|
||||
type KeyChild = ".";
|
||||
type KeyGroup = "^";
|
||||
type UserStyles = Partial<CSSStyleDeclaration> & {[key: `${KeyQuery|KeyState|KeyChild|KeyGroup}${string}`]: UserStyles }
|
||||
type UserStyles = Partial<CSSStyleDeclaration> & {[key: `${KeyQuery|KeyPseudo|KeyChild|KeyGroup}${string}`]: UserStyles }
|
||||
type UserSheet = Record<string, UserStyles>
|
||||
type CollectKeys<Obj> = {[Key in keyof Obj]: Obj[Key] extends object ? Key | CollectKeys<Obj[Key]> : Key }[keyof Obj]
|
||||
type FilterKeys<Keys> = Keys extends `${KeyChild|KeyGroup}${infer Rest}` ? Keys : never
|
||||
type CrossMultiply<A, B> = A extends string ? B extends string ? `${A}${B}` : never : never
|
||||
type CrossMultiplyRecord<Rec> = keyof Rec | { [K in keyof Rec]: K extends string ? CrossMultiply<K, FilterKeys<CollectKeys<Rec[K]>>> : never }[keyof Rec]
|
||||
type Tier = (selector:string, obj:UserStyles, suffix:string)=>string;
|
||||
type CreateSheet = <T extends UserSheet>(sheet:UserSheet&T, hash?:string)=>{
|
||||
Tag:(...args:CrossMultiplyRecord<T>[])=>string,
|
||||
CSS:string,
|
||||
DOM:Elemental<CrossMultiplyRecord<T>>,
|
||||
H:Circular<CrossMultiplyRecord<T>, Van.TagFunc<HTMLDivElement>>
|
||||
}
|
||||
type Tier = (selector:string, obj:UserStyles)=>string;
|
||||
type CreateSheet = <T extends UserSheet>(sheet:UserSheet&T)=> ((...args:CrossMultiplyRecord<T>[])=>string)&{CSS:string, DOM:Elemental<CrossMultiplyRecord<T>>}
|
||||
|
||||
|
||||
type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Van.TagFunc<HTMLElementTagNameMap[K]>&Circular<T, Van.TagFunc<HTMLElementTagNameMap[K]>>}
|
||||
|
||||
type Circular<Keys extends string, Func> = {
|
||||
[K in Keys]: Circular<Keys, Func>&Func
|
||||
type Elemental<T extends string> = {[K in keyof HTMLElementTagNameMap]: Circular<T, K>}
|
||||
type Circular<Keys extends string, ElementName extends keyof HTMLElementTagNameMap> = {
|
||||
[K in Keys]: Circular<Keys, ElementName>&Van.TagFunc<HTMLElementTagNameMap[ElementName]>;
|
||||
};
|
||||
|
||||
}
|
||||
const Gale:Gale.CreateSheet
|
||||
}
|
Loading…
Reference in New Issue
Block a user