webc.site 0.1.19 → 0.1.22

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/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /_.css
2
+ /x.js
3
+ /apple-touch-icon.png
4
+ /favicon-96x96.png
5
+ /favicon.ico
6
+ /favicon.svg
7
+ /site.webmanifest
8
+ /web-app-manifest-192x192.png
9
+ /web-app-manifest-512x512.png
package/.nojekyll ADDED
@@ -0,0 +1 @@
1
+ # Disable Jekyll processing on GitHub Pages
package/README.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  同时支持无打包直接引用的使用方式,及配合 vite 等构建器打包的构建。
12
12
 
13
+ 点击组件右上角的『在线调试』可以调试无打包的组件。
14
+
15
+ 如基于 vite 构建器打包项目,
16
+
13
17
  ## 初衷
14
18
 
15
19
  人工智能开发前端,比较大的问题是调试。
package/Scroll.js CHANGED
@@ -1,3 +1 @@
1
- import { On as A, D as I, newEl as H } from "./x.js";(()=>{let{round:h,max:b,min:D}=Math,a=(r,l,...p)=>{let c=H(r);if(l)c.setAttribute("part",l);return c.append(...p),c},k=(r,l,p)=>{let c=r.toLowerCase(),f=l.toLowerCase(),_="client"+r,y="scroll"+r,d="scroll"+l,w="client"+p;return(s)=>{let C,m,g,v=-1,P=s.firstElementChild,u=a("i","si"),o=a("b","bar",u),T=(e=u[_])=>{let t=s[_],i=P[y];return[i-t,b(1,t-e-6),e,t,i]},E=(e)=>{if(!o.parentNode)return;let[t,i]=T(e),n=b(0,D(s[d],t));if(v!=-1&&v!=n)o.style.opacity=1,clearTimeout(C),C=setTimeout(()=>o.style.opacity=0,1000);v=n,u.style[f]=3+h(i*n/t)+"px"},G=(e)=>{if(m)return;let t=I.body;t.setPointerCapture(e.pointerId),t.classList.add("drag"),o.part.add("drag");let i=e[w],n=()=>{t.classList.remove("drag"),o.part.remove("drag"),x(),m=null},x=A(t,{pointermove:(R)=>{let[z,B]=T();s[d]+=h(z*(R[w]-i)/B),i=R[w]},pointerup:n,lostpointercapture:n});m=n},S=(e)=>{let t=o.getBoundingClientRect(),i=t[f],[n,x,R]=T();s[d]=h(n*b(D((e[w]-i-3-R/2)/x,1),0)),G(e)},N=[A(o,{pointerdown:S}),A(u,{pointerdown:(e)=>{e.stopPropagation(),G(e)}}),A(s,{scroll:E.bind(null,void 0)})],L=new ResizeObserver(()=>{clearTimeout(g),g=setTimeout(()=>{let[,,,e,t]=T();if(e<t){if(o.parentNode!=s)s.appendChild(o);let n=b(16,h(e*e/t));u.style[c]=n+"px",E(n)}else if(o.parentNode)o.remove()},200)}),X=()=>{if(clearTimeout(C),clearTimeout(g),N.forEach((e)=>e()),m)m();if(L.disconnect(),o.parentNode)o.remove()};return o.style.opacity=0,[s,P].forEach((e)=>L.observe(e)),X}};[["v","Height","Top","Y","flex-direction:column;width:100%;min-height:100%"],["h","Width","Left","X","min-width:100%;width:max-content;height:100%"]].map(([r,l,p,c,f])=>{let _=k(l,p,c);customElements.define(r+"-scroll",class extends HTMLElement{connectedCallback(){let y=a("b","",a("slot")),d=a("b","scroll",y);y.style.cssText="display:flex;"+f,this.attachShadow({mode:"open"}).appendChild(d),this._unbind=_(d)}disconnectedCallback(){this._unbind?.()}})})})();
2
-
3
-
1
+ import { On as e, D as t, newEl as o } from "./x.js";(()=>{let{round:l,max:i,min:r}=Math,n="drag",s=(e,t,...l)=>{let i=o(e);return t&&i.setAttribute("part",t),i.append(...l),i};[["v","Height","Top","Y","flex-direction:column;width:100%;min-height:100%"],["h","Width","Left","X","min-width:100%;width:max-content;height:100%"]].map(([o,a,d,c,p])=>{let m,u,h,b,f,y,v=(m=a.toLowerCase(),u=d.toLowerCase(),h="client"+a,b="scroll"+a,f="scroll"+d,y="client"+c,o=>{let a,d,c,p=-1,v=o.firstElementChild,w=s("i","si"),x=s("b","bar",w),C=(e=w[h])=>{let t=o[h],l=v[b];return[l-t,i(1,t-e-6),e,t,l]},T=e=>{if(!x.parentNode)return;let[t,n]=C(e),s=i(0,r(o[f],t));-1!=p&&p!=s&&(x.style.opacity=1,clearTimeout(a),a=setTimeout(()=>x.style.opacity=0,1e3)),p=s,w.style[u]=3+l(n*s/t)+"px"},g=i=>{if(d)return;let r=t.body;r.setPointerCapture(i.pointerId),r.classList.add(n),x.part.add(n);let s=i[y],a=()=>{r.classList.remove(n),x.part.remove(n),c(),d=null},c=e(r,{pointermove:e=>{let[t,i]=C();o[f]+=l(t*(e[y]-s)/i),s=e[y]},pointerup:a,lostpointercapture:a});d=a},L=[e(x,{pointerdown:e=>{let t=x.getBoundingClientRect()[u],[n,s,a]=C();o[f]=l(n*i(r((e[y]-t-3-a/2)/s,1),0)),g(e)}}),e(w,{pointerdown:e=>{e.stopPropagation(),g(e)}}),e(o,{scroll:T.bind(null,void 0)})],E=new ResizeObserver(()=>{clearTimeout(c),c=setTimeout(()=>{let[,,,e,t]=C();if(e<t){x.parentNode!=o&&o.appendChild(x);let r=i(16,l(e*e/t));w.style[m]=r+"px",T(r)}else x.parentNode&&x.remove()},200)});return x.style.opacity=0,[o,v].forEach(e=>E.observe(e)),()=>{clearTimeout(a),clearTimeout(c),L.forEach(e=>e()),d&&d(),E.disconnect(),x.parentNode&&x.remove()}});customElements.define(o+"-scroll",class extends HTMLElement{connectedCallback(){let e=s("b","",s("slot")),t=s("b","scroll",e);e.style.cssText="display:flex;"+p,this.attachShadow({mode:"open"}).appendChild(t),this._unbind=v(t)}disconnectedCallback(){this._unbind?.()}})})})();
package/Scroll.js.map CHANGED
@@ -1,10 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../com/Scroll/Scroll.js"],
4
- "sourcesContent": [
5
- "import { On } from \"x/On.js\";\nimport { D, newEl } from \"x/dom.js\";\n\n(() => {\n const { round, max, min } = Math,\n PART = \"part\",\n BAR = \"bar\",\n SI = \"si\",\n DRAG = \"drag\",\n PX = \"px\",\n mk = (tag, part, ...kids) => {\n const e = newEl(tag);\n if (part) e.setAttribute(PART, part);\n e.append(...kids);\n return e;\n },\n mkScroll = (size, pos, axis) => {\n const style_size = size.toLowerCase(),\n style_pos = pos.toLowerCase(),\n client_size = \"client\" + size,\n scroll_size = \"scroll\" + size,\n scroll_pos = \"scroll\" + pos,\n client_pos = \"client\" + axis;\n return (ct) => {\n let timer_bar,\n ptr_unbind,\n timer_resize,\n pre_st = -1;\n const m = ct.firstElementChild,\n si = mk(\"i\", SI),\n bar = mk(\"b\", BAR, si),\n getGeo = (sih = si[client_size]) => {\n const ch = ct[client_size],\n sh = m[scroll_size];\n return [sh - ch, max(1, ch - sih - 6), sih, ch, sh];\n },\n updateTop = (h) => {\n if (!bar.parentNode) return;\n const [ds, db] = getGeo(h),\n st = max(0, min(ct[scroll_pos], ds));\n if (pre_st != -1 && pre_st != st) {\n bar.style.opacity = 1;\n clearTimeout(timer_bar);\n timer_bar = setTimeout(() => (bar.style.opacity = 0), 1e3);\n }\n pre_st = st;\n si.style[style_pos] = 3 + round((db * st) / ds) + PX;\n },\n onDown = (e) => {\n if (ptr_unbind) return;\n const bd = D.body;\n bd.setPointerCapture(e.pointerId);\n bd.classList.add(DRAG);\n bar.part.add(DRAG);\n let pre = e[client_pos];\n const detach = () => {\n bd.classList.remove(DRAG);\n bar.part.remove(DRAG);\n un_ptr();\n ptr_unbind = null;\n },\n un_ptr = On(bd, {\n pointermove: (e) => {\n const [ds, db] = getGeo();\n ct[scroll_pos] += round((ds * (e[client_pos] - pre)) / db);\n pre = e[client_pos];\n },\n pointerup: detach,\n lostpointercapture: detach,\n });\n ptr_unbind = detach;\n },\n onClick = (e) => {\n const rect = bar.getBoundingClientRect(),\n top = rect[style_pos],\n [ds, db, sih] = getGeo();\n ct[scroll_pos] = round(ds * max(min((e[client_pos] - top - 3 - sih / 2) / db, 1), 0));\n onDown(e);\n },\n unbind = [\n On(bar, { pointerdown: onClick }),\n On(si, {\n pointerdown: (e) => {\n e.stopPropagation();\n onDown(e);\n },\n }),\n On(ct, { scroll: updateTop.bind(null, undefined) }),\n ],\n ob = new ResizeObserver(() => {\n clearTimeout(timer_resize);\n timer_resize = setTimeout(() => {\n const [, , , ch, sh] = getGeo(),\n is_turn = ch < sh;\n if (is_turn) {\n if (bar.parentNode != ct) ct.appendChild(bar);\n const h = max(16, round((ch * ch) / sh));\n si.style[style_size] = h + PX;\n updateTop(h);\n } else if (bar.parentNode) {\n bar.remove();\n }\n }, 200);\n }),\n destroy = () => {\n clearTimeout(timer_bar);\n clearTimeout(timer_resize);\n unbind.forEach((f) => f());\n if (ptr_unbind) ptr_unbind();\n ob.disconnect();\n if (bar.parentNode) bar.remove();\n };\n bar.style.opacity = 0;\n [ct, m].forEach((i) => ob.observe(i));\n return destroy;\n };\n };\n\n [\n [\"v\", \"Height\", \"Top\", \"Y\", \"flex-direction:column;width:100%;min-height:100%\"],\n [\"h\", \"Width\", \"Left\", \"X\", \"min-width:100%;width:max-content;height:100%\"],\n ].map(([prefix, size, pos, axis, css]) => {\n const initScroll = mkScroll(size, pos, axis);\n customElements.define(\n prefix + \"-scroll\",\n class extends HTMLElement {\n connectedCallback() {\n const content = mk(\"b\", \"\", mk(\"slot\")),\n wrapper = mk(\"b\", \"scroll\", content);\n content.style.cssText = \"display:flex;\" + css;\n this.attachShadow({ mode: \"open\" }).appendChild(wrapper);\n this._unbind = initScroll(wrapper);\n }\n disconnectedCallback() {\n this._unbind?.();\n }\n },\n );\n });\n})();\n"
6
- ],
7
- "mappings": "AAAA,aAAS,gBACT,YAAS,WAAG,kBAEX,IAAM,CACL,IAAQ,QAAO,MAAK,OAAQ,KAM1B,EAAK,CAAC,EAAK,KAAS,IAAS,CAC3B,IAAM,EAAI,EAAM,CAAG,EACnB,GAAI,EAAM,EAAE,aAPP,OAO0B,CAAI,EAEnC,OADA,EAAE,OAAO,GAAG,CAAI,EACT,GAET,EAAW,CAAC,EAAM,EAAK,IAAS,CAC9B,IAAM,EAAa,EAAK,YAAY,EAClC,EAAY,EAAI,YAAY,EAC5B,EAAc,SAAW,EACzB,EAAc,SAAW,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e,OACb,EAAS,UACT,cAAc,WAAY,CACxB,iBAAiB,EAAG,CAClB,IAAM,EAAU,EAAG,IAAK,GAAI,EAAG,MAAM,CAAC,EACpC,EAAU,EAAG,IAAK,SAAU,CAAO,EACrC,EAAQ,MAAM,QAAU,gBAAkB,EAC1C,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAAE,YAAY,CAAO,EACvD,KAAK,QAAU,EAAW,CAAO,EAEnC,oBAAoB,EAAG,CACrB,KAAK,UAAU,EAEnB,CACF,EACD,IACA",
8
- "debugId": "5DD6B8D33029FF4A64756E2164756E21",
9
- "names": []
10
- }
1
+ {"version":3,"file":"Scroll.js","names":[],"sources":["../com/Scroll/Scroll.js"],"sourcesContent":["import { On } from \"x/On.js\";\nimport { D, newEl } from \"x/dom.js\";\n\n(() => {\n const { round, max, min } = Math,\n PART = \"part\",\n BAR = \"bar\",\n SI = \"si\",\n DRAG = \"drag\",\n PX = \"px\",\n mk = (tag, part, ...kids) => {\n const e = newEl(tag);\n if (part) e.setAttribute(PART, part);\n e.append(...kids);\n return e;\n },\n mkScroll = (size, pos, axis) => {\n const style_size = size.toLowerCase(),\n style_pos = pos.toLowerCase(),\n client_size = \"client\" + size,\n scroll_size = \"scroll\" + size,\n scroll_pos = \"scroll\" + pos,\n client_pos = \"client\" + axis;\n return (ct) => {\n let timer_bar,\n ptr_unbind,\n timer_resize,\n pre_st = -1;\n const m = ct.firstElementChild,\n si = mk(\"i\", SI),\n bar = mk(\"b\", BAR, si),\n getGeo = (sih = si[client_size]) => {\n const ch = ct[client_size],\n sh = m[scroll_size];\n return [sh - ch, max(1, ch - sih - 6), sih, ch, sh];\n },\n updateTop = (h) => {\n if (!bar.parentNode) return;\n const [ds, db] = getGeo(h),\n st = max(0, min(ct[scroll_pos], ds));\n if (pre_st != -1 && pre_st != st) {\n bar.style.opacity = 1;\n clearTimeout(timer_bar);\n timer_bar = setTimeout(() => (bar.style.opacity = 0), 1e3);\n }\n pre_st = st;\n si.style[style_pos] = 3 + round((db * st) / ds) + PX;\n },\n onDown = (e) => {\n if (ptr_unbind) return;\n const bd = D.body;\n bd.setPointerCapture(e.pointerId);\n bd.classList.add(DRAG);\n bar.part.add(DRAG);\n let pre = e[client_pos];\n const detach = () => {\n bd.classList.remove(DRAG);\n bar.part.remove(DRAG);\n un_ptr();\n ptr_unbind = null;\n },\n un_ptr = On(bd, {\n pointermove: (e) => {\n const [ds, db] = getGeo();\n ct[scroll_pos] += round((ds * (e[client_pos] - pre)) / db);\n pre = e[client_pos];\n },\n pointerup: detach,\n lostpointercapture: detach,\n });\n ptr_unbind = detach;\n },\n onClick = (e) => {\n const rect = bar.getBoundingClientRect(),\n top = rect[style_pos],\n [ds, db, sih] = getGeo();\n ct[scroll_pos] = round(ds * max(min((e[client_pos] - top - 3 - sih / 2) / db, 1), 0));\n onDown(e);\n },\n unbind = [\n On(bar, { pointerdown: onClick }),\n On(si, {\n pointerdown: (e) => {\n e.stopPropagation();\n onDown(e);\n },\n }),\n On(ct, { scroll: updateTop.bind(null, undefined) }),\n ],\n ob = new ResizeObserver(() => {\n clearTimeout(timer_resize);\n timer_resize = setTimeout(() => {\n const [, , , ch, sh] = getGeo(),\n is_turn = ch < sh;\n if (is_turn) {\n if (bar.parentNode != ct) ct.appendChild(bar);\n const h = max(16, round((ch * ch) / sh));\n si.style[style_size] = h + PX;\n updateTop(h);\n } else if (bar.parentNode) {\n bar.remove();\n }\n }, 200);\n }),\n destroy = () => {\n clearTimeout(timer_bar);\n clearTimeout(timer_resize);\n unbind.forEach((f) => f());\n if (ptr_unbind) ptr_unbind();\n ob.disconnect();\n if (bar.parentNode) bar.remove();\n };\n bar.style.opacity = 0;\n [ct, m].forEach((i) => ob.observe(i));\n return destroy;\n };\n };\n\n [\n [\"v\", \"Height\", \"Top\", \"Y\", \"flex-direction:column;width:100%;min-height:100%\"],\n [\"h\", \"Width\", \"Left\", \"X\", \"min-width:100%;width:max-content;height:100%\"],\n ].map(([prefix, size, pos, axis, css]) => {\n const initScroll = mkScroll(size, pos, axis);\n customElements.define(\n prefix + \"-scroll\",\n class extends HTMLElement {\n connectedCallback() {\n const content = mk(\"b\", \"\", mk(\"slot\")),\n wrapper = mk(\"b\", \"scroll\", content);\n content.style.cssText = \"display:flex;\" + css;\n this.attachShadow({ mode: \"open\" }).appendChild(wrapper);\n this._unbind = initScroll(wrapper);\n }\n disconnectedCallback() {\n this._unbind?.();\n }\n },\n );\n });\n})();\n"],"mappings":";;;OAGO;CACL,MAAM,EAAE,OAAO,KAAK,QAAQ,MAC1B,OAAO,QACP,MAAM,OACN,KAAK,MACL,OAAO,QACP,KAAK,MACL,MAAM,KAAK,MAAM,GAAG,SAAS;EAC3B,MAAM,IAAI,MAAM,GAAG;EACnB,IAAI,MAAM,EAAE,aAAa,MAAM,IAAI;EACnC,EAAE,OAAO,GAAG,IAAI;EAChB,OAAO;CACT,GACA,YAAY,MAAM,KAAK,SAAS;EAC9B,MAAM,aAAa,KAAK,YAAY,GAClC,YAAY,IAAI,YAAY,GAC5B,cAAc,WAAW,MACzB,cAAc,WAAW,MACzB,aAAa,WAAW,KACxB,aAAa,WAAW;EAC1B,QAAQ,OAAO;GACb,IAAI,WACF,YACA,cACA,SAAS;GACX,MAAM,IAAI,GAAG,mBACX,KAAK,GAAG,KAAK,EAAE,GACf,MAAM,GAAG,KAAK,KAAK,EAAE,GACrB,UAAU,MAAM,GAAG,iBAAiB;IAClC,MAAM,KAAK,GAAG,cACZ,KAAK,EAAE;IACT,OAAO;KAAC,KAAK;KAAI,IAAI,GAAG,KAAK,MAAM,CAAC;KAAG;KAAK;KAAI;IAAE;GACpD,GACA,aAAa,MAAM;IACjB,IAAI,CAAC,IAAI,YAAY;IACrB,MAAM,CAAC,IAAI,MAAM,OAAO,CAAC,GACvB,KAAK,IAAI,GAAG,IAAI,GAAG,aAAa,EAAE,CAAC;IACrC,IAAI,UAAU,MAAM,UAAU,IAAI;KAChC,IAAI,MAAM,UAAU;KACpB,aAAa,SAAS;KACtB,Y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,IAAI,IAAI,IAAI,MAAO,KAAK,KAAM,EAAE,CAAC;MACvC,GAAG,MAAM,cAAc,IAAI;MAC3B,UAAU,CAAC;KACb,OAAO,IAAI,IAAI,YACb,IAAI,OAAO;IAEf,GAAG,GAAG;GACR,CAAC,GACD,gBAAgB;IACd,aAAa,SAAS;IACtB,aAAa,YAAY;IACzB,OAAO,SAAS,MAAM,EAAE,CAAC;IACzB,IAAI,YAAY,WAAW;IAC3B,GAAG,WAAW;IACd,IAAI,IAAI,YAAY,IAAI,OAAO;GACjC;GACF,IAAI,MAAM,UAAU;GACpB,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,GAAG,QAAQ,CAAC,CAAC;GACpC,OAAO;EACT;CACF;CAEF,CACE;EAAC;EAAK;EAAU;EAAO;EAAK;CAAkD,GAC9E;EAAC;EAAK;EAAS;EAAQ;EAAK;CAA8C,CAC5E,EAAE,KAAK,CAAC,QAAQ,MAAM,KAAK,MAAM,SAAS;EACxC,MAAM,aAAa,SAAS,MAAM,KAAK,IAAI;EAC3C,eAAe,OACb,SAAS,WACT,cAAc,YAAY;GACxB,oBAAoB;IAClB,MAAM,UAAU,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC,GACpC,UAAU,GAAG,KAAK,UAAU,OAAO;IACrC,QAAQ,MAAM,UAAU,kBAAkB;IAC1C,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC,EAAE,YAAY,OAAO;IACvD,KAAK,UAAU,WAAW,OAAO;GACnC;GACA,uBAAuB;IACrB,KAAK,UAAU;GACjB;EACF,CACF;CACF,CAAC;AACH,GAAG"}
package/_.css ADDED
@@ -0,0 +1,369 @@
1
+ .LG {
2
+ position: relative;
3
+ z-index: 1;
4
+ }
5
+ .LG::before {
6
+ backdrop-filter: blur(30px) saturate(150%) url("/svg/W/filter/glass.svg#l");
7
+ background: linear-gradient(180deg, rgba(245,245,245,0.302), rgba(245,245,245,0.502));
8
+ border-radius: inherit;
9
+ content: '';
10
+ filter: url("/svg/W/filter/highlight.svg#hl");
11
+ inset: 0;
12
+ position: absolute;
13
+ transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
14
+ z-index: -1;
15
+ }
16
+ .LG::after {
17
+ background-clip: border-box;
18
+ background-image: linear-gradient(180deg, rgba(0,0,0,0.149), rgba(0,0,0,0.059));
19
+ background-origin: border-box;
20
+ border: 1px solid transparent;
21
+ border-radius: inherit;
22
+ border-width: 0.5px;
23
+ content: '';
24
+ inset: 0;
25
+ mask-clip: content-box, border-box;
26
+ mask-composite: exclude;
27
+ mask-image: linear-gradient(#fff 0 0), linear-gradient(#fff 0 0);
28
+ pointer-events: none;
29
+ position: absolute;
30
+ z-index: -1;
31
+ }
32
+
33
+ body {
34
+ align-items: center;
35
+ display: flex;
36
+ height: 100dvh;
37
+ justify-content: center;
38
+ width: 100%;
39
+ }
40
+
41
+ /*
42
+ Please read: https://github.com/unocss/unocss/blob/main/packages-presets/reset/tailwind-compat.md
43
+ */
44
+ /*
45
+ 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
46
+ 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
47
+ 2. [UnoCSS]: allow to override the default border color with css var `--un-default-border-color`
48
+ */
49
+ *,
50
+ ::before,
51
+ ::after {
52
+ border-color: var(--un-default-border-color, #e5e7eb) /* 2 */;
53
+ border-style: solid /* 2 */;
54
+ border-width: 0 /* 2 */;
55
+ box-sizing: border-box /* 1 */;
56
+ }
57
+ /*
58
+ 1. Use a consistent sensible line-height in all browsers.
59
+ 2. Prevent adjustments of font size after orientation changes in iOS.
60
+ 3. Use a more readable tab size.
61
+ 4. Use the user's configured `sans` font-family by default.
62
+ 5. Use the user's configured `sans` font-feature-settings by default.
63
+ 6. Use the user's configured `sans` font-variation-settings by default.
64
+ 7. Disable tap highlights on iOS.
65
+ */
66
+ html,
67
+ :host {
68
+ font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' /* 4 */;
69
+ font-feature-settings: normal /* 5 */;
70
+ font-variation-settings: normal /* 6 */;
71
+ line-height: 1.5 /* 1 */;
72
+ tab-size: 4 /* 3 */;
73
+ -moz-tab-size: 4 /* 3 */;
74
+ -webkit-tap-highlight-color: transparent /* 7 */;
75
+ -webkit-text-size-adjust: 100% /* 2 */;
76
+ }
77
+ /*
78
+ 1. Remove the margin in all browsers.
79
+ 2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
80
+ */
81
+ body {
82
+ line-height: inherit /* 2 */;
83
+ margin: 0 /* 1 */;
84
+ }
85
+ /*
86
+ 1. Add the correct height in Firefox.
87
+ 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
88
+ 3. Ensure horizontal rules are visible by default.
89
+ */
90
+ hr {
91
+ border-top-width: 1px /* 3 */;
92
+ color: inherit /* 2 */;
93
+ height: 0 /* 1 */;
94
+ }
95
+ /*
96
+ Add the correct text decoration in Chrome, Edge, and Safari.
97
+ */
98
+ abbr:where([title]) {
99
+ text-decoration: underline dotted;
100
+ }
101
+ /*
102
+ Remove the default font size and weight for headings.
103
+ */
104
+ h1,
105
+ h2,
106
+ h3,
107
+ h4,
108
+ h5,
109
+ h6 {
110
+ font-size: inherit;
111
+ font-weight: inherit;
112
+ }
113
+ /*
114
+ Reset links to optimize for opt-in styling instead of opt-out.
115
+ */
116
+ a {
117
+ color: inherit;
118
+ text-decoration: inherit;
119
+ }
120
+ /*
121
+ Add the correct font weight in Edge and Safari.
122
+ */
123
+ b,
124
+ strong {
125
+ font-weight: bolder;
126
+ }
127
+ /*
128
+ 1. Use the user's configured `mono` font-family by default.
129
+ 2. Use the user's configured `mono` font-feature-settings by default.
130
+ 3. Use the user's configured `mono` font-variation-settings by default.
131
+ 4. Correct the odd `em` font sizing in all browsers.
132
+ */
133
+ code,
134
+ kbd,
135
+ samp,
136
+ pre {
137
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace /* 1 */;
138
+ font-feature-settings: normal /* 2 */;
139
+ font-size: 1em /* 4 */;
140
+ font-variation-settings: normal /* 3 */;
141
+ }
142
+ /*
143
+ Add the correct font size in all browsers.
144
+ */
145
+ small {
146
+ font-size: 80%;
147
+ }
148
+ /*
149
+ Prevent `sub` and `sup` elements from affecting the line height in all browsers.
150
+ */
151
+ sub,
152
+ sup {
153
+ font-size: 75%;
154
+ line-height: 0;
155
+ position: relative;
156
+ vertical-align: baseline;
157
+ }
158
+ sub {
159
+ bottom: -0.25em;
160
+ }
161
+ sup {
162
+ top: -0.5em;
163
+ }
164
+ /*
165
+ 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
166
+ 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
167
+ 3. Remove gaps between table borders by default.
168
+ */
169
+ table {
170
+ border-collapse: collapse /* 3 */;
171
+ border-color: inherit /* 2 */;
172
+ text-indent: 0 /* 1 */;
173
+ }
174
+ /*
175
+ 1. Change the font styles in all browsers.
176
+ 2. Remove the margin in Firefox and Safari.
177
+ 3. Remove default padding in all browsers.
178
+ */
179
+ button,
180
+ input,
181
+ optgroup,
182
+ select,
183
+ textarea {
184
+ color: inherit /* 1 */;
185
+ font-family: inherit /* 1 */;
186
+ font-feature-settings: inherit /* 1 */;
187
+ font-size: 100% /* 1 */;
188
+ font-variation-settings: inherit /* 1 */;
189
+ font-weight: inherit /* 1 */;
190
+ line-height: inherit /* 1 */;
191
+ margin: 0 /* 2 */;
192
+ padding: 0 /* 3 */;
193
+ }
194
+ /*
195
+ Remove the inheritance of text transform in Edge and Firefox.
196
+ */
197
+ button,
198
+ select {
199
+ text-transform: none;
200
+ }
201
+ /*
202
+ 1. Correct the inability to style clickable types in iOS and Safari.
203
+ 2. Remove default button styles.
204
+ */
205
+ button,
206
+ [type='button'],
207
+ [type='reset'],
208
+ [type='submit'] {
209
+ /* Will affect the button style of most component libraries, so disable it */
210
+ /* https://github.com/unocss/unocss/issues/2127 */
211
+ /* background-color: transparent; !* 2 *! */
212
+ background-image: none /* 2 */;
213
+ -webkit-appearance: button /* 1 */;
214
+ }
215
+ /*
216
+ Use the modern Firefox focus style for all focusable elements.
217
+ */
218
+ :-moz-focusring {
219
+ outline: auto;
220
+ }
221
+ /*
222
+ Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
223
+ */
224
+ :-moz-ui-invalid {
225
+ box-shadow: none;
226
+ }
227
+ /*
228
+ Add the correct vertical alignment in Chrome and Firefox.
229
+ */
230
+ progress {
231
+ vertical-align: baseline;
232
+ }
233
+ /*
234
+ Correct the cursor style of increment and decrement buttons in Safari.
235
+ */
236
+ ::-webkit-inner-spin-button,
237
+ ::-webkit-outer-spin-button {
238
+ height: auto;
239
+ }
240
+ /*
241
+ 1. Correct the odd appearance in Chrome and Safari.
242
+ 2. Correct the outline style in Safari.
243
+ */
244
+ [type='search'] {
245
+ outline-offset: -2px /* 2 */;
246
+ -webkit-appearance: textfield /* 1 */;
247
+ }
248
+ /*
249
+ Remove the inner padding in Chrome and Safari on macOS.
250
+ */
251
+ ::-webkit-search-decoration {
252
+ -webkit-appearance: none;
253
+ }
254
+ /*
255
+ 1. Correct the inability to style clickable types in iOS and Safari.
256
+ 2. Change font properties to `inherit` in Safari.
257
+ */
258
+ ::-webkit-file-upload-button {
259
+ font: inherit /* 2 */;
260
+ -webkit-appearance: button /* 1 */;
261
+ }
262
+ /*
263
+ Add the correct display in Chrome and Safari.
264
+ */
265
+ summary {
266
+ display: list-item;
267
+ }
268
+ /*
269
+ Removes the default spacing for appropriate elements.
270
+ */
271
+ blockquote,
272
+ dl,
273
+ dd,
274
+ h1,
275
+ h2,
276
+ h3,
277
+ h4,
278
+ h5,
279
+ h6,
280
+ hr,
281
+ figure,
282
+ p,
283
+ pre {
284
+ margin: 0;
285
+ }
286
+ fieldset {
287
+ margin: 0;
288
+ padding: 0;
289
+ }
290
+ legend {
291
+ padding: 0;
292
+ }
293
+ ol,
294
+ ul,
295
+ menu {
296
+ list-style: none;
297
+ margin: 0;
298
+ padding: 0;
299
+ }
300
+ dialog {
301
+ padding: 0;
302
+ }
303
+ /*
304
+ Prevent resizing textareas horizontally by default.
305
+ */
306
+ textarea {
307
+ resize: vertical;
308
+ }
309
+ /*
310
+ 1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
311
+ 2. Set the default placeholder color to the user's configured gray 400 color.
312
+ */
313
+ input::placeholder,
314
+ textarea::placeholder {
315
+ color: #9ca3af /* 2 */;
316
+ opacity: 1 /* 1 */;
317
+ }
318
+ /*
319
+ Set the default cursor for buttons.
320
+ */
321
+ button,
322
+ [role='button'] {
323
+ cursor: pointer;
324
+ }
325
+ /*
326
+ Make sure disabled buttons don't get the pointer cursor.
327
+ */
328
+ :disabled {
329
+ cursor: default;
330
+ }
331
+ /*
332
+ 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
333
+ 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
334
+ This can trigger a poorly considered lint error in some tools but is included by design.
335
+ */
336
+ img,
337
+ svg,
338
+ video,
339
+ canvas,
340
+ audio,
341
+ iframe,
342
+ embed,
343
+ object {
344
+ display: block /* 1 */;
345
+ vertical-align: middle /* 2 */;
346
+ }
347
+ /*
348
+ Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
349
+ */
350
+ img,
351
+ video {
352
+ height: auto;
353
+ max-width: 100%;
354
+ }
355
+ /*
356
+ Make elements with the HTML hidden attribute stay hidden by default.
357
+ */
358
+ [hidden]:where(:not([hidden='until-found'])) {
359
+ display: none;
360
+ }
361
+
362
+ :root {
363
+ --gap: 24px;
364
+ }
365
+ @media (max-width: 999px) {
366
+ :root {
367
+ --gap: 16px;
368
+ }
369
+ }
Binary file
Binary file
package/favicon.ico ADDED
Binary file
package/favicon.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" fill="none"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="#ffb340"/><stop offset="1" stop-color="#ff7a18"/></linearGradient></defs><path fill="url(#a)" d="M170.15 401.578 64.362 482.114V106.28a54.3 54.3 0 0 1 7.086-26.845c4.643-8.162 11.32-14.94 19.36-19.652a52.3 52.3 0 0 1 26.448-7.194h290.918a52.3 52.3 0 0 1 26.447 7.194c8.041 4.712 14.719 11.49 19.361 19.652a54.3 54.3 0 0 1 7.087 26.845v241.607a54.3 54.3 0 0 1-7.087 26.846c-4.642 8.162-11.32 14.939-19.361 19.652a52.3 52.3 0 0 1-26.447 7.193z"/><path fill="#fff" d="M156.927 267.352a39.23 39.23 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.74 40.74 0 0 0 5.317-20.139 40.74 40.74 0 0 0-5.317-20.14 40 40 0 0 0-14.528-14.74 39.23 39.23 0 0 0-19.843-5.388 39.27 39.27 0 0 0-23.309 7.697c-6.774 4.999-11.816 12.045-14.403 20.131a40.84 40.84 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.403 20.131a39.28 39.28 0 0 0 23.309 7.697m105.788 0a39.2 39.2 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.73 40.73 0 0 0 5.318-20.139 40.74 40.74 0 0 0-5.318-20.14 40 40 0 0 0-14.528-14.74 39.2 39.2 0 0 0-19.843-5.388 39.27 39.27 0 0 0-23.308 7.697c-6.775 4.999-11.817 12.045-14.404 20.131a40.85 40.85 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.404 20.131a39.28 39.28 0 0 0 23.308 7.697m105.789 0a39.23 39.23 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.74 40.74 0 0 0 5.318-20.139 40.75 40.75 0 0 0-5.318-20.14 40 40 0 0 0-14.528-14.74 39.23 39.23 0 0 0-19.843-5.388 39.28 39.28 0 0 0-23.309 7.697c-6.774 4.999-11.816 12.045-14.403 20.131a40.84 40.84 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.403 20.131a39.3 39.3 0 0 0 23.309 7.697"/></svg>
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"webc.site","version":"0.1.19","description":"","keywords":[],"homepage":"https://webc-zh.github.io","license":"MulanPSL-2.0","author":"i18n.site@gmail.com","repository":{"type":"git","url":"git+https://github.com/webc-zh/webc-zh.github.io.git"},"files":["./*"],"type":"module","exports":{"./*":"./*"},"scripts":{},"devDependencies":{}}
1
+ {"name":"webc.site","version":"0.1.22","description":"","keywords":[],"homepage":"https://webc-zh.github.io","license":"MulanPSL-2.0","author":"i18n.site@gmail.com","repository":{"type":"git","url":"git+https://github.com/webc-zh/webc-zh.github.io.git"},"bin":{"webc-i":"./cli.js"},"files":["./*"],"type":"module","exports":{"./*":"./*"},"scripts":{},"dependencies":{"@3-/read":"^0.1.4","stylus":"^0.64.0","tar":"^7.5.15","yargs":"^18.0.0"},"devDependencies":{}}
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "MyWebSite",
3
+ "short_name": "MySite",
4
+ "icons": [
5
+ {
6
+ "src": "/web-app-manifest-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png",
9
+ "purpose": "maskable"
10
+ },
11
+ {
12
+ "src": "/web-app-manifest-512x512.png",
13
+ "sizes": "512x512",
14
+ "type": "image/png",
15
+ "purpose": "maskable"
16
+ }
17
+ ],
18
+ "theme_color": "#000000",
19
+ "background_color": "#000000",
20
+ "display": "standalone"
21
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" fill="none"><path fill="#ffffffb3" fill-rule="evenodd" d="M3.573 2.036c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.69a1.9 1.9 0 0 1 .916-.056c.313.064.642.287.765.5.362.622.368 1.898.385 1.83.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.25.05.586.344.677.487.22.344.342 1.316.38 1.658.015.141.073-.393.292-.736.406-.639 1.844-.763 1.898.64.026.653.02.623.02 1.063 0 .516-.012.828-.04 1.202-.03.4-.116 1.304-.24 1.742-.087.301-.372.978-.654 1.384 0 0-1.074 1.25-1.19 1.812-.118.563-.079.567-.103.965-.023.4.121.923.121.923s-.8.104-1.234.034c-.39-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.01-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.92c-.283-.36-1.002-.93-1.243-1.986C.875 6.46.896 6 1.125 5.625c.232-.38.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.16.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.36-.4-.943-.38-1.526.008-.22.103-.77.832-1.042" clip-rule="evenodd"/><path stroke="#0000008c" stroke-linejoin="round" stroke-width=".75" d="M3.573 2.036c.48-.178 1.427-.069 1.677.473.213.462.396 1.241.406 1.075.024-.369-.024-1.167.137-1.584.117-.304.347-.59.686-.69a1.9 1.9 0 0 1 .916-.056c.313.064.642.287.765.5.362.622.368 1.898.385 1.83.064-.272.07-1.229.283-1.584.141-.235.497-.445.687-.479.294-.052.656-.068.964-.008.25.05.586.344.677.487.22.344.342 1.316.38 1.658.015.141.073-.393.292-.736.406-.639 1.844-.763 1.898.64.026.653.02.623.02 1.063 0 .516-.012.828-.04 1.202-.03.4-.116 1.304-.24 1.742-.087.301-.372.978-.654 1.384 0 0-1.074 1.25-1.19 1.812-.118.563-.079.567-.103.965-.023.4.121.923.121.923s-.8.104-1.234.034c-.39-.062-.875-.84-1-1.078-.172-.328-.539-.265-.682-.023-.224.383-.709 1.07-1.05 1.113-.669.084-2.055.03-3.14.02 0 0 .185-1.01-.227-1.358-.305-.26-.83-.784-1.144-1.06l-.832-.92c-.283-.36-1.002-.93-1.243-1.986C.875 6.46.896 6 1.125 5.625c.232-.38.67-.589.854-.625.208-.042.692-.039.875.062.223.123.313.16.488.391.23.307.312.456.213.121-.076-.262-.322-.595-.434-.97-.109-.36-.4-.943-.38-1.526.008-.22.103-.77.832-1.042Z" clip-rule="evenodd"/><path stroke="#0000008c" stroke-linecap="round" stroke-width=".75" d="M10.566 9.734V6.275M8.55 9.746l-.015-3.473m-1.98.032.02 3.426"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path fill="#fff" stroke="#000" stroke-linejoin="round" stroke-width="2" d="m22 12-6-6v4H8V6l-6 6 6 6v-4h8v4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path fill="#fff" stroke="#000" stroke-linejoin="round" stroke-width="2" d="M12 2 6 8h4v8H6l6 6 6-6h-4V8h4z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg"/>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg"/>
package/svg/bg.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1920" height="1080" preserveAspectRatio="xMidYMid slice"><defs><filter id="b" width="160%" height="160%" x="-30%" y="-30%"><feGaussianBlur stdDeviation="80"/></filter><filter id="c" width="140%" height="140%" x="-20%" y="-20%"><feGaussianBlur stdDeviation="24"/></filter><filter id="e" width="140%" height="140%" x="-20%" y="-20%"><feGaussianBlur stdDeviation="12"/></filter><filter id="g" width="140%" height="140%" x="-20%" y="-20%"><feDropShadow dx="0" dy="24" flood-color="#000" flood-opacity=".04" stdDeviation="30"/></filter><filter id="i"><feTurbulence baseFrequency=".65" numOctaves="3" stitchTiles="stitch" type="fractalNoise"/><feColorMatrix type="saturate" values="0"/></filter><linearGradient id="a" x1="0%" x2="100%" y1="0%" y2="100%"><stop offset="0%" stop-color="#e8e8ed"/><stop offset="100%" stop-color="#f2f2f7"/></linearGradient><linearGradient id="d" x1="0%" x2="100%" y1="100%" y2="0%"><stop offset="0%" stop-color="#eaebef" stop-opacity=".9"/><stop offset="100%" stop-color="#fff" stop-opacity="0"/></linearGradient><linearGradient id="f" x1="0%" x2="100%" y1="0%" y2="100%"><stop offset="0%" stop-color="#fff"/><stop offset="100%" stop-color="#e5e5ea" stop-opacity=".7"/></linearGradient><linearGradient id="h" x1="0%" x2="100%" y1="0%" y2="100%"><stop offset="0%" stop-color="#eaebef" stop-opacity=".9"/><stop offset="100%" stop-color="#c7c7cc" stop-opacity=".8"/></linearGradient></defs><rect width="100%" height="100%" fill="url(#a)"/><g filter="url(#b)"><ellipse cx="15%" cy="5%" fill="#e5e5ea" opacity=".6" rx="50%" ry="60%"/><ellipse cx="85%" cy="15%" fill="#d1d1d6" opacity=".5" rx="45%" ry="55%"/><ellipse cx="30%" cy="95%" fill="#eaebef" opacity=".7" rx="60%" ry="50%"/><ellipse cx="85%" cy="90%" fill="#d1d1d6" opacity=".6" rx="50%" ry="55%"/><ellipse cx="50%" cy="50%" fill="#fff" opacity=".9" rx="40%" ry="45%"/></g><path fill="#fff" d="M-100 500c500-50 700-400 1300-300 400 50 600-250 900-150v1150H-100Z" filter="url(#c)" opacity=".4"/><path fill="url(#d)" d="M-100 750c500-50 700-500 1300-400 400 50 600-200 900-100v950H-100Z" filter="url(#e)"/><path fill="url(#f)" d="M-100 950c350 0 500-500 1100-500 400 0 600 200 1100 150v600H-100Z" filter="url(#g)"/><path fill="url(#h)" d="M1100 1200c200-350 500-450 1000-300v300Z" filter="url(#g)"/><path fill="#fff" d="M-100 1200v-100c200 0 350 20 550 100Z" filter="url(#g)" opacity=".8"/><rect width="100%" height="100%" filter="url(#i)" opacity=".04" style="mix-blend-mode:multiply;pointer-events:none"/></svg>
package/svg/copy.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none" viewBox="0 0 48 48"><path stroke="#000" stroke-width="3" d="M13 12.432v-4.62A2.813 2.813 0 0 1 15.813 5h24.374A2.813 2.813 0 0 1 43 7.813v24.375A2.813 2.813 0 0 1 40.188 35h-4.672"/><path stroke="#000" stroke-width="3" d="M32.188 13H7.811A2.813 2.813 0 0 0 5 15.813v24.374A2.813 2.813 0 0 0 7.813 43h24.375A2.813 2.813 0 0 0 35 40.188V15.811A2.813 2.813 0 0 0 32.188 13Z"/></svg>
package/svg/ok.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path d="m5 13 4 4L19 7"/></svg>
package/svg/site.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" fill="none"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="#ffb340"/><stop offset="1" stop-color="#ff7a18"/></linearGradient></defs><path fill="url(#a)" d="M170.15 401.578 64.362 482.114V106.28a54.3 54.3 0 0 1 7.086-26.845c4.643-8.162 11.32-14.94 19.36-19.652a52.3 52.3 0 0 1 26.448-7.194h290.918a52.3 52.3 0 0 1 26.447 7.194c8.041 4.712 14.719 11.49 19.361 19.652a54.3 54.3 0 0 1 7.087 26.845v241.607a54.3 54.3 0 0 1-7.087 26.846c-4.642 8.162-11.32 14.939-19.361 19.652a52.3 52.3 0 0 1-26.447 7.193z"/><path fill="#fff" d="M156.927 267.352a39.23 39.23 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.74 40.74 0 0 0 5.317-20.139 40.74 40.74 0 0 0-5.317-20.14 40 40 0 0 0-14.528-14.74 39.23 39.23 0 0 0-19.843-5.388 39.27 39.27 0 0 0-23.309 7.697c-6.774 4.999-11.816 12.045-14.403 20.131a40.84 40.84 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.403 20.131a39.28 39.28 0 0 0 23.309 7.697m105.788 0a39.2 39.2 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.73 40.73 0 0 0 5.318-20.139 40.74 40.74 0 0 0-5.318-20.14 40 40 0 0 0-14.528-14.74 39.2 39.2 0 0 0-19.843-5.388 39.27 39.27 0 0 0-23.308 7.697c-6.775 4.999-11.817 12.045-14.404 20.131a40.85 40.85 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.404 20.131a39.28 39.28 0 0 0 23.308 7.697m105.789 0a39.23 39.23 0 0 0 19.843-5.389 40 40 0 0 0 14.528-14.74 40.74 40.74 0 0 0 5.318-20.139 40.75 40.75 0 0 0-5.318-20.14 40 40 0 0 0-14.528-14.74 39.23 39.23 0 0 0-19.843-5.388 39.28 39.28 0 0 0-23.309 7.697c-6.774 4.999-11.816 12.045-14.403 20.131a40.84 40.84 0 0 0 0 24.88c2.587 8.085 7.629 15.132 14.403 20.131a39.3 39.3 0 0 0 23.309 7.697"/></svg>
Binary file
Binary file
package/x.js CHANGED
@@ -1 +1 @@
1
- const e=(e,t)=>{let n,r;for(n in t)r=t[n],e.addEventListener(n,r);return()=>{for(n in t)r=t[n],e.removeEventListener(n,r)}},t=()=>location.pathname.slice(1),[n,r,i,a,o,s,c,l]=(()=>{let n=t(),r=[];location.hash&&(n+=location.hash);let i=e=>(r.push(e),e(t()),()=>{r=r.filter(t=>t!==e)}),a=e=>{n=e},o=()=>n,s=e=>{e||=t();for(let t of r)t(e,n);a(e)},c=e=>e[0]===`/`?e.slice(1):e,l=(e,t)=>{let n=e.indexOf(t);return n>=0?[e.slice(0,n),e.slice(n+1)]:[e,``]},u=e=>{if(e=c(e),e!==n){let[t,r]=l(e,`#`),[i]=l(n,`#`);if(a(e),t!==i)return history.pushState(null,``,`/`+e),1;if(location.hash.slice(1)!==r){location.hash=r;return}}window.dispatchEvent(new HashChangeEvent(`hashchange`))};return e(window,{popstate:()=>{let e=t();e!==l(n,`#`)[0]&&s(e)}}),[i,a,o,s,c,l,u,e=>{u(e)&&s(e)}]})(),u=(e,t)=>{var n,r;if(e.host===location.host)return{hash:n}=e,r=e.pathname.slice(1)+e.search,n&&(r+=n),t.preventDefault(),r},d=document,f=d.body,p=d.createElement.bind(d);export{f as B,d as D,e as On,l as goto,p as newEl,t as nowUrl,i as preUrl,a as refresh,o as removeSlash,n as route,u as selfA,r as setPre,c as setUrl,s as split};
1
+ const e=(e,t)=>{let n,r;for(n in t)r=t[n],e.addEventListener(n,r);return()=>{for(n in t)r=t[n],e.removeEventListener(n,r)}},t=document,n=t.body,r=t.createElement.bind(t);export{n as B,t as D,e as On,r as newEl};
package/x.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"x.js","names":[],"sources":["../../importmap/x/On.js","../../importmap/x/route.js","../../importmap/x/selfA.js","../../importmap/x/dom.js"],"sourcesContent":["export const On = (elem, dict) => {\n let event, func;\n for (event in dict) {\n func = dict[event];\n elem.addEventListener(event, func);\n }\n return () => {\n for (event in dict) {\n func = dict[event];\n elem.removeEventListener(event, func);\n }\n };\n};\n","import { On } from \"x/On.js\";\n\nexport const nowUrl = () => location.pathname.slice(1),\n [route, setPre, preUrl, refresh, removeSlash, split, setUrl, goto] = (() => {\n let PRE = nowUrl(),\n HOOK = [];\n if (location.hash) PRE += location.hash;\n\n const HASH = \"#\",\n route = (hook) => {\n HOOK.push(hook);\n hook(nowUrl());\n return () => {\n HOOK = HOOK.filter((f) => f !== hook);\n };\n },\n setPre = (url) => {\n PRE = url;\n },\n preUrl = () => PRE,\n refresh = (url) => {\n url = url || nowUrl();\n for (const f of HOOK) f(url, PRE);\n setPre(url);\n },\n removeSlash = (url) => (url[0] === \"/\" ? url.slice(1) : url),\n split = (str, s) => {\n const p = str.indexOf(s);\n return p >= 0 ? [str.slice(0, p), str.slice(p + 1)] : [str, \"\"];\n },\n setUrl = (url) => {\n url = removeSlash(url);\n if (url !== PRE) {\n const [path, hash] = split(url, HASH),\n [p] = split(PRE, HASH);\n setPre(url);\n if (path !== p) {\n history.pushState(null, \"\", \"/\" + url);\n return 1;\n }\n if (location.hash.slice(1) !== hash) {\n location.hash = hash;\n return;\n }\n }\n window.dispatchEvent(new HashChangeEvent(\"hashchange\"));\n },\n goto = (url) => {\n if (setUrl(url)) refresh(url);\n };\n\n On(window, {\n popstate: () => {\n const url = nowUrl();\n if (url !== split(PRE, HASH)[0]) refresh(url);\n },\n });\n\n return [route, setPre, preUrl, refresh, removeSlash, split, setUrl, goto];\n })();\n","// 判断A标签的href是否为当前网站的, 如果是, 返回url, 以实现不刷新跳转\nexport const selfA = (p, e) => {\n var hash, url;\n if (p.host === location.host) {\n ({ hash } = p);\n url = p.pathname.slice(1) + p.search;\n if (hash) {\n url += hash;\n }\n e.preventDefault();\n return url;\n }\n};\n","export const D = document,\n B = D.body,\n newEl = D.createElement.bind(D);\n"],"mappings":"AAAA,MAAa,GAAM,EAAM,IAAS,CAChC,IAAI,EAAO,EACX,IAAK,KAAS,EACZ,EAAO,EAAK,GACZ,EAAK,iBAAiB,EAAO,CAAI,EAEnC,UAAa,CACX,IAAK,KAAS,EACZ,EAAO,EAAK,GACZ,EAAK,oBAAoB,EAAO,CAAI,CAExC,CACF,ECVa,MAAe,SAAS,SAAS,MAAM,CAAC,EACnD,CAAC,EAAO,EAAQ,EAAQ,EAAS,EAAa,EAAO,EAAQ,QAAe,CAC1E,IAAI,EAAM,EAAO,EACf,EAAO,CAAC,EACN,SAAS,OAAM,GAAO,SAAS,MAEnC,IACE,EAAS,IACP,EAAK,KAAK,CAAI,EACd,EAAK,EAAO,CAAC,MACA,CACX,EAAO,EAAK,OAAQ,GAAM,IAAM,CAAI,CACtC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,EAAI,EAAE,KACN,EAAQ,EAAE,cAAc,KAAK,CAAC"}
1
+ {"version":3,"file":"x.js","names":[],"sources":["../../importmap/x/On.js","../../importmap/x/dom.js"],"sourcesContent":["export const On = (elem, dict) => {\n let event, func;\n for (event in dict) {\n func = dict[event];\n elem.addEventListener(event, func);\n }\n return () => {\n for (event in dict) {\n func = dict[event];\n elem.removeEventListener(event, func);\n }\n };\n};\n","export const D = document,\n B = D.body,\n newEl = D.createElement.bind(D);\n"],"mappings":"AAAA,MAAa,GAAM,EAAM,IAAS,CAChC,IAAI,EAAO,EACX,IAAK,KAAS,EACZ,EAAO,EAAK,GACZ,EAAK,iBAAiB,EAAO,CAAI,EAEnC,UAAa,CACX,IAAK,KAAS,EACZ,EAAO,EAAK,GACZ,EAAK,oBAAoB,EAAO,CAAI,CAExC,CACF,ECZa,EAAI,SACf,EAAI,EAAE,KACN,EAAQ,EAAE,cAAc,KAAK,CAAC"}
@@ -1,9 +0,0 @@
1
- 给x目录下每个 js 在同级目录,写同名的 .md 介绍用途
2
-
3
- 第一行是标题,以#号开头,标题不要包含 js 的名字,主要写起用途
4
-
5
- 内容依次介绍每个导出的函数、参数.
6
-
7
- 函数参数如果是回调函数,请写明回调函数的参数,返回值
8
-
9
- 文风要简洁,不写形容词
package/importmap/x/On.js DELETED
@@ -1,13 +0,0 @@
1
- export const On = (elem, dict) => {
2
- let event, func;
3
- for (event in dict) {
4
- func = dict[event];
5
- elem.addEventListener(event, func);
6
- }
7
- return () => {
8
- for (event in dict) {
9
- func = dict[event];
10
- elem.removeEventListener(event, func);
11
- }
12
- };
13
- };
package/importmap/x/On.md DELETED
@@ -1,8 +0,0 @@
1
- # 绑定与解绑事件监听
2
-
3
- - `On(elem, dict)`
4
- - `elem`: DOM 元素。
5
- - `dict`: 事件与回调对象。键为事件名,值为回调函数。回调函数格式:
6
- - 参数:`e`(事件对象)。
7
- - 返回值:无。
8
- - 返回值:解绑函数。格式为 `() => void`。
package/importmap/x/a.js DELETED
@@ -1,23 +0,0 @@
1
- import { goto, selfA, B } from "../../x.js";
2
- B.addEventListener("click", (e) => {
3
- var href, name, p;
4
- p = e.target;
5
- while (p) {
6
- ({ nodeName: name } = p);
7
- if (name === "A") {
8
- ({ href } = p);
9
- if (href) {
10
- href = selfA(p, e);
11
- if (href !== void 0) {
12
- goto(href);
13
- } else if (!p.target) {
14
- p.target = "_blank";
15
- }
16
- }
17
- break;
18
- } else if (name === "BODY") {
19
- break;
20
- }
21
- p = p.parentNode;
22
- }
23
- });
package/importmap/x/a.md DELETED
@@ -1,3 +0,0 @@
1
- # 拦截链接点击实现无刷新跳转
2
-
3
- 无导出函数。导入时自动在 `document.body` 监听点击事件。点击同站链接时阻止默认行为并调用 `goto` 跳转,点击外链且无 `target` 属性时将其设为 `_blank`。
@@ -1,17 +0,0 @@
1
- import { route } from "./route.js";
2
-
3
- // 避免 onMount 之前,route 被触发,导致重复加载数据
4
- export const delayRoute = (loadUrl) => {
5
- let t;
6
- const unbind = route((url, preUrl) => {
7
- t = setTimeout(() => {
8
- loadUrl(url, preUrl);
9
- });
10
- });
11
- return () => {
12
- unbind();
13
- clearTimeout(t);
14
- };
15
- };
16
-
17
- export default delayRoute;
@@ -1,11 +0,0 @@
1
- # 延迟路由触发避免重复加载数据
2
-
3
- 用于 Svelte,避免组件被卸载前触发路由导致重复加载数据。
4
-
5
- - `delayRoute(loadUrl)`
6
- - `loadUrl`: 路由变化时的回调函数。格式:
7
- - 参数:
8
- - `url`: 字符串,新 URL 路径。
9
- - `preUrl`: 字符串(可选),旧 URL 路径。
10
- - 返回值:无。
11
- - 返回值:取消路由订阅并清除定时器的函数,格式为 `() => void`。
@@ -1,3 +0,0 @@
1
- export const D = document,
2
- B = D.body,
3
- newEl = D.createElement.bind(D);
@@ -1,7 +0,0 @@
1
- # DOM 属性与方法简写
2
-
3
- - `D`: `document` 实例。
4
- - `B`: `document.body` 元素。
5
- - `newEl(tagName)`
6
- - `tagName`: 字符串,HTML 标签名。
7
- - 返回值:新创建的 DOM 元素。
@@ -1,22 +0,0 @@
1
- {
2
- "name": "@3-/x",
3
- "version": "0.2.0",
4
- "description": "",
5
- "keywords": [],
6
- "homepage": "https://webc-zh.github.io",
7
- "license": "MulanPSL-2.0",
8
- "author": "i18n.site@gmail.com",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/webc-zh/webc-zh.github.io.git"
12
- },
13
- "files": [
14
- "./*"
15
- ],
16
- "type": "module",
17
- "exports": {
18
- "./*": "./*"
19
- },
20
- "scripts": {},
21
- "devDependencies": {}
22
- }
@@ -1,2 +0,0 @@
1
- import { D } from "./dom.js";
2
- D.getElementById("W").remove();
@@ -1,3 +0,0 @@
1
- # 移除加载等待元素
2
-
3
- 无导出函数。导入时自动从 DOM 中移除 ID 为 `W` 的元素。
@@ -1,59 +0,0 @@
1
- import { On } from "../../x.js";
2
- export const nowUrl = () => location.pathname.slice(1),
3
- [route, setPre, preUrl, refresh, removeSlash, split, setUrl, goto] = (() => {
4
- let PRE = nowUrl(),
5
- HOOK = [];
6
- if (location.hash) PRE += location.hash;
7
-
8
- const HASH = "#",
9
- route = (hook) => {
10
- HOOK.push(hook);
11
- hook(nowUrl());
12
- return () => {
13
- HOOK = HOOK.filter((f) => f !== hook);
14
- };
15
- },
16
- setPre = (url) => {
17
- PRE = url;
18
- },
19
- preUrl = () => PRE,
20
- refresh = (url) => {
21
- url = url || nowUrl();
22
- for (const f of HOOK) f(url, PRE);
23
- setPre(url);
24
- },
25
- removeSlash = (url) => (url[0] === "/" ? url.slice(1) : url),
26
- split = (str, s) => {
27
- const p = str.indexOf(s);
28
- return p >= 0 ? [str.slice(0, p), str.slice(p + 1)] : [str, ""];
29
- },
30
- setUrl = (url) => {
31
- url = removeSlash(url);
32
- if (url !== PRE) {
33
- const [path, hash] = split(url, HASH),
34
- [p] = split(PRE, HASH);
35
- setPre(url);
36
- if (path !== p) {
37
- history.pushState(null, "", "/" + url);
38
- return 1;
39
- }
40
- if (location.hash.slice(1) !== hash) {
41
- location.hash = hash;
42
- return;
43
- }
44
- }
45
- window.dispatchEvent(new HashChangeEvent("hashchange"));
46
- },
47
- goto = (url) => {
48
- if (setUrl(url)) refresh(url);
49
- };
50
-
51
- On(window, {
52
- popstate: () => {
53
- const url = nowUrl();
54
- if (url !== split(PRE, HASH)[0]) refresh(url);
55
- },
56
- });
57
-
58
- return [route, setPre, preUrl, refresh, removeSlash, split, setUrl, goto];
59
- })();
@@ -1,37 +0,0 @@
1
- # 路由管理与跳转
2
-
3
- - `nowUrl()`
4
- - 返回值:当前 URL 路径(不含首部斜杠)。
5
-
6
- - `route(hook)`
7
- - `hook`: 路由变化时执行的回调函数。格式:
8
- - 参数:
9
- - `url`: 字符串,新 URL 路径。
10
- - `preUrl`: 字符串(可选),旧 URL 路径。
11
- - 返回值:无。
12
- - 返回值:取消订阅的函数,格式为 `() => void`。
13
-
14
- - `setPre(url)`
15
- - `url`: 字符串,新的前一次 URL 路径。
16
-
17
- - `preUrl()`
18
- - 返回值:前一次的 URL 路径。
19
-
20
- - `refresh(url)`
21
- - `url`: 字符串(可选),要触发回调的 URL 路径,默认是当前 URL。
22
-
23
- - `removeSlash(url)`
24
- - `url`: 字符串。
25
- - 返回值:移除首部斜杠后的字符串。
26
-
27
- - `split(str, s)`
28
- - `str`: 待拆分字符串。
29
- - `s`: 分隔符。
30
- - 返回值:包含两个元素的数组 `[前部, 后部]`。
31
-
32
- - `setUrl(url)`
33
- - `url`: 目标 URL 路径。
34
- - 返回值:若路径改变返回 `1`,若仅 hash 改变不返回值。
35
-
36
- - `goto(url)`
37
- - `url`: 目标 URL 路径。
@@ -1,13 +0,0 @@
1
- // 判断A标签的href是否为当前网站的, 如果是, 返回url, 以实现不刷新跳转
2
- export const selfA = (p, e) => {
3
- var hash, url;
4
- if (p.host === location.host) {
5
- ({ hash } = p);
6
- url = p.pathname.slice(1) + p.search;
7
- if (hash) {
8
- url += hash;
9
- }
10
- e.preventDefault();
11
- return url;
12
- }
13
- };
@@ -1,6 +0,0 @@
1
- # 同站链接点击校验与处理
2
-
3
- - `selfA(p, e)`
4
- - `p`: `<a>` 元素。
5
- - `e`: 点击事件对象。
6
- - 返回值:若是同站链接,阻止默认行为并返回包含 search/hash 的相对路径,否则返回 `undefined`。