asciify-engine 4.27.1 → 4.28.0
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/CHANGELOG.md +4 -0
- package/dist/kit/chunk-2MLFWO4U.js +1 -0
- package/dist/kit.cjs +1 -1
- package/dist/kit.d.cts +29 -1
- package/dist/kit.d.ts +29 -1
- package/dist/kit.js +1 -1
- package/package.json +1 -1
- package/skills/asciify-engine/SKILL.md +2 -2
- package/skills/asciify-engine/references/applying-asciify.md +1 -0
- package/skills/asciify-engine/references/kit.md +13 -2
- package/skills/asciify-engine/references/scenario-prompts.md +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ Notable changes to `asciify-engine`, newest first. Releases are published to [np
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
## 4.28: cursorTrail, an ASCII cursor for the whole page
|
|
9
|
+
|
|
10
|
+
- New: `cursorTrail()` in `asciify-engine/kit` puts a page-wide cursor trail on any site in one call: `cursorTrail({ style: 'trail' | 'wake' | 'water' | 'sparkle', ink, charset, cellSize })`. One fixed, click-through layer on the shared GPU context, mounted on the first pointer move and drawing only while something fades. Off on touch, under reduced motion and in hidden tabs; quiet over inputs, dialogs and `[data-ascii-cursor-skip]`. Returns a handle with `update`, `clear`, `pause`, `play` and `destroy`.
|
|
11
|
+
|
|
8
12
|
## 4.27.1
|
|
9
13
|
|
|
10
14
|
- Fixed: kit components drawing an `<img>` that uses `srcset` (compare, image accordion) took only the top-left part of the file, because `naturalWidth` is density-corrected while a source rectangle is read in file pixels. `drawCover` now places the whole image, so the before/after slider lines up across the divider.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mergeOptions as e,prefersReduced as t,hash as o,mountSurface as n}from"./chunk-GF72XM4C.js";import{isGlyphFieldSupported as l,watchPointer as i,watchVisibility as r,watchMotionPreference as a}from"../field.js";var s={style:"trail",charset:" .:-=+*#%@",cellSize:9,zIndex:1e3},c='input, textarea, select, [contenteditable], dialog, [role="dialog"], [role="alertdialog"], [data-ascii-cursor-skip]',u={trail:64,wake:48,water:20,sparkle:140},d=e=>{const t=Math.round(255*Math.max(0,Math.min(1,e)));return`rgb(${t},${t},${t})`};function h(e,t,o,n,l,i,r){for(let a=1;a<t.length;a++){const s=t[a-1],c=t[a],u=t[a-2]??s,h=1-(n-c.t)/l;h<=0||(e.strokeStyle=d(r(h)),e.lineWidth=Math.max(1,i(h)*o),e.beginPath(),e.moveTo((u.x+s.x)/2*o,(u.y+s.y)/2*o),e.quadraticCurveTo(s.x*o,s.y*o,(s.x+c.x)/2*o,(s.y+c.y)/2*o),e.lineTo(c.x*o,c.y*o),e.stroke())}}function f(e,t,o,n,l,i,r){if(e.lineCap="round",e.lineJoin="round",e.globalCompositeOperation="lighten","trail"===o)h(e,t,r,n,l,e=>i*(.5+.95*e),e=>e**1.25);else if("wake"===o)h(e,t,r,n,l,e=>i*(2+3.2*e),e=>.34*e**1.6),h(e,t,r,n,l,e=>i*(.8+1.4*e),e=>.62*e**1.4);else if("water"===o)for(const o of t){const t=n-o.t,a=1-t/l;a<=0||(e.strokeStyle=d(.9*a**1.5),e.lineWidth=Math.max(1,i*(.45+.5*a)*r),e.beginPath(),e.arc(o.x*r,o.y*r,(.8*i+.085*t)*r,0,2*Math.PI),e.stroke())}else for(const o of t){const t=n-o.t,a=1-t/l;if(a<=0)continue;const s=.55+.45*Math.sin(.028*t+6.28*o.seed),c=i*(.55+.6*o.seed)*(.6+.4*a)*r;e.fillStyle=d(a**1.2*s),e.fillRect((o.x+o.vx*t)*r-c/2,(o.y+o.vy*t)*r-c/2,c,c)}e.globalCompositeOperation="source-over"}function p(d={}){const h={current:{...s,...d}},p=()=>h.current;let y=[],k=null,m=null,g=!1,x=!1,v=!1,M=0;const w="undefined"!=typeof document&&"undefined"!=typeof window&&l(),b=()=>!!(p().reducedMotion??t()),z=()=>({mark:"glyph",charset:p().charset,cellSize:p().cellSize,cellAspect:.62,glyphScale:.92,shade:.6,contrast:1,...p().look}),S=e=>{e.style.cssText=`position:fixed;left:0;top:0;width:100vw;height:100vh;pointer-events:none;z-index:${p().zIndex};contain:strict`},C=({pen:e,now:t,scale:o})=>{const n=p().life??("water"===p().style?950:800);return y=y.filter(e=>t-e.t<n),!!y.length&&(f(e,y,p().style,t,n,p().cellSize,o),!0)},$=w?[i({target:window,move:e=>{if(x||v||"touch"===e.pointerType||"function"==typeof matchMedia&&matchMedia("(hover: none)").matches&&matchMedia("(pointer: coarse)").matches||b()||(e=>{const t=e;return!!t?.closest&&!!t.closest(p().skip?`${c}, ${p().skip}`:c)})(e.target))return;const t=performance.now(),l=e.clientX,i=e.clientY,r=p().style,a=y[y.length-1],s=a?Math.hypot(l-a.x,i-a.y):1/0;if(!("water"===r?s<2.6*p().cellSize&&t-M<90:s<2)){if(M=t,"sparkle"===r)for(let e=0;e<2;e++){const n=o(t+17*e,l+i),r=o(i+e,t)*Math.PI*2,a=1.4*p().cellSize*o(l,t+e);y.push({x:l+Math.cos(r)*a,y:i+Math.sin(r)*a,t:t,seed:n,vx:.012*Math.cos(r),vy:.012*Math.sin(r)+.01})}else y.push({x:l,y:i,t:t,seed:0,vx:0,vy:0});for(;y.length>u[r];)y.shift();k||g||x||!w||(m=document.createElement("div"),m.setAttribute("aria-hidden","true"),m.dataset.asciiCursor="",S(m),document.body.appendChild(m),k=n({host:m,kit:{get current(){return{lazy:!1,globalLook:p().globalLook??!1}}},look:z,ink:()=>p().ink??"--ascii-ink",resolution:.5,paint:C,reducedMotion:()=>p().reducedMotion,onFail:()=>{g=!0,k=null,m?.remove(),m=null}}),k||(g=!0,m.remove(),m=null)),k?.kick()}},leave(){}}),r(()=>{document.hidden&&(y=[])}),a(()=>{b()&&(y=[]),k?.kick()})]:[];return{get supported(){return w&&!g&&!x},get field(){return x?null:k?.field??null},get active(){return y.length>0},clear(){y=[],k?.kick()},update(t){if(x)return;const o=p().style;h.current={...s,...e(h.current,t)},p().style!==o&&(y=[]),m&&S(m),k?.refresh()},play(){x||(v=!1,k?.play())},pause(){x||(v=!0,y=[],k?.pause())},destroy(){if(!x){x=!0;for(const e of $)e();y=[],k?.destroy(),k=null,m?.remove(),m=null}}}}export{p as cursorTrail,f as cursorTrailFrame};//# sourceMappingURL=chunk-2MLFWO4U.js.map
|