textmode.overlay.js 1.0.3 → 1.1.0-beta.1

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/README.md CHANGED
@@ -28,41 +28,6 @@ Bind a target once with `t.overlay.setTarget()`, then sample it with the same ch
28
28
  Follow the [official installation guide](https://code.textmode.art/docs/installation) to install
29
29
  `textmode.overlay.js` alongside `textmode.js` with npm or browser-ready UMD bundles.
30
30
 
31
- ```bash
32
- npm install textmode.js textmode.overlay.js
33
- ```
34
-
35
- ## Usage
36
-
37
- ```ts
38
- import { textmode } from 'textmode.js';
39
- import { OverlayPlugin } from 'textmode.overlay.js';
40
-
41
- const t = textmode.create({
42
- plugins: [OverlayPlugin],
43
- });
44
-
45
- const source = t.overlay.setTarget(sourceCanvas);
46
- source.characters(' .:-=+*#%@').charColorMode('sampled');
47
-
48
- t.draw(() => {
49
- t.image(t.overlay.source!, t.grid.cols, t.grid.rows);
50
- });
51
- ```
52
-
53
- `setTarget()` is synchronous and can run immediately after `textmode.create()`. The returned `TextmodeTexture` supports the normal character, color, conversion, and transform settings.
54
-
55
- ## Migration from core overlay mode
56
-
57
- In `textmode.js` 0.18, the built-in `{ overlay: true }` target-overlay mode was extracted into this add-on. Use the table below to update an existing sketch.
58
-
59
- | Before | After |
60
- | --- | --- |
61
- | `textmode.create({ canvas: target, overlay: true })` | `textmode.create({ plugins: [OverlayPlugin] })` |
62
- | `t.overlay` as the sampled image | `t.overlay.setTarget(target)`; read the sampled `TextmodeTexture` from `t.overlay.source` |
63
- | Target following owned by core | Controller lifecycle owned by the add-on |
64
- | Available without installing anything | Install and import `textmode.overlay.js` |
65
-
66
31
  ## Next steps
67
32
 
68
33
  - **[Read the documentation](https://code.textmode.art/)** for core concepts and plugin workflows.
@@ -1 +1 @@
1
- var t="[textmode.overlay.js]",i=1e-8;function s(s){if(!s||"none"===s)return;const e=/^matrix\(([^)]+)\)$/.exec(s);if(e){const t=e[1].split(",").map(Number);if(6===t.length&&Math.abs(t[1])<=i&&Math.abs(t[2])<=i)return}const n=/^matrix3d\(([^)]+)\)$/.exec(s);if(n){const t=n[1].split(",").map(Number);if(16===t.length&&[1,2,3,4,6,7,8,9,11].every(s=>Math.abs(t[s])<=i))return}throw new Error(`${t} Rotated and skewed overlay targets are not supported.`)}function e(t){return Math.round(100*t)/100}var n=class{t;i;h;o;l;u;v=!0;m;p;_=!1;T;M;L=()=>this.request();constructor(t,i){var s;this.t=t,this.i=i,this.h=t.parentNode,this.o=t.nextSibling,this.l={position:(s=t).style.position,left:s.style.left,top:s.style.top,width:s.style.width,height:s.style.height,zIndex:s.style.zIndex,display:s.style.display,pointerEvents:s.style.pointerEvents}}bind(t,i){this.u=t,this.v=i,this.C()&&this.H(),this.request()}request(){this.u&&void 0===this.T&&(this.u.isConnected?this.T=window.requestAnimationFrame(()=>{this.T=void 0,this.O()}):this.S())}synchronizeImmediately(t={}){this.$(),this.O(t.forceResize??!1)}setVisible(t){this.v=t,t?(this.V("display",this.l.display),this.C(),this.request()):this.V("display","none")}clear(t){this.$(),this.N(),this.u=void 0,this.M=void 0,t.restoreCanvas&&this.F()}dispose(){this.clear({restoreCanvas:!0})}O(t=!1){const i=this.u;if(!i||!this.C())return;const n=function(t,i){s(getComputedStyle(t).transform);const n=t.getBoundingClientRect(),h=t instanceof HTMLCanvasElement?t.width:t.videoWidth,o=t instanceof HTMLCanvasElement?t.height:t.videoHeight,r=e(n.width>0?n.width:h),a=e(n.height>0?n.height:o);if(r<=0||a<=0)return;const d=function(t,i){const s=i.offsetParent;if(s instanceof HTMLElement&&s!==document.body&&s!==document.documentElement){const i=s.getBoundingClientRect();return{left:t.left-i.left+s.scrollLeft-s.clientLeft,top:t.top-i.top+s.scrollTop-s.clientTop}}return{left:t.left+window.scrollX,top:t.top+window.scrollY}}(n,i);return{left:e(d.left),top:e(d.top),width:r,height:a}}(i,this.t);if(!n||!t&&(o=n,(h=this.M)&&h.left===o.left&&h.top===o.top&&h.width===o.width&&h.height===o.height))return;var h,o;const r=this.M,a=t||!r||r.width!==n.width||r.height!==n.height;this.M=n,this.V("left",`${n.left}px`),this.V("top",`${n.top}px`),a&&this.i(n.width,n.height)}H(){const t=this.u;t&&!this._&&(this._=!0,"undefined"!=typeof ResizeObserver&&(this.m=new ResizeObserver(this.L),this.m.observe(t,{box:"border-box"})),window.addEventListener("resize",this.L),window.addEventListener("scroll",this.L,!0),t instanceof HTMLVideoElement&&(t.addEventListener("loadedmetadata",this.L),t.addEventListener("resize",this.L)))}C(){const t=this.u;if(!t)return!1;if(!t.isConnected||!t.parentNode)return this.S(),!1;this.p?.disconnect(),this.p=void 0,this.t.previousSibling===t&&this.t.parentNode===t.parentNode||t.parentNode.insertBefore(this.t,t.nextSibling);const i=Number.parseFloat(getComputedStyle(t).zIndex);return this.V("position","absolute"),this.V("zIndex",String((Number.isFinite(i)?i:0)+1)),this.V("pointerEvents","auto"),this.V("display",this.v?this.l.display:"none"),!0}S(){if(this.p||"undefined"==typeof MutationObserver)return;const t=document.documentElement;t&&(this.p=new MutationObserver(()=>{this.u?.isConnected&&(this.C()&&this.H(),this.request())}),this.p.observe(t,{childList:!0,subtree:!0}))}N(){this.m?.disconnect(),this.m=void 0,this.p?.disconnect(),this.p=void 0;const t=this.u;this._=!1,window.removeEventListener("resize",this.L),window.removeEventListener("scroll",this.L,!0),t instanceof HTMLVideoElement&&(t.removeEventListener("loadedmetadata",this.L),t.removeEventListener("resize",this.L))}$(){void 0!==this.T&&(window.cancelAnimationFrame(this.T),this.T=void 0)}F(){if(this.t.isConnected&&this.h){const t=this.o;this.h.insertBefore(this.t,t?.parentNode===this.h?t:null)}Object.assign(this.t.style,this.l)}V(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}},h=class{I;t;R;u;j;v=!0;q=!1;constructor(t){this.I=t,this.t=t.canvas,this.R=new n(this.t,(t,i)=>this.I.resizeCanvas(t,i))}get target(){return this.A(),this.u}get source(){return this.A(),this.j}setTarget(i){return this.A(),function(i,e){const n="undefined"!=typeof HTMLCanvasElement&&i instanceof HTMLCanvasElement,h="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement;if(!n&&!h)throw new TypeError(`${t} setTarget() requires an HTMLCanvasElement or HTMLVideoElement.`);if(i===e)throw new TypeError(`${t} The textmode output canvas cannot be used as its own overlay target.`);s(getComputedStyle(i).transform)}(i,this.t),i===this.u&&this.j?(this.requestSynchronization(),this.j):(this.P(!1),this.u=i,this.j=this.I.createTexture(i),this.R.bind(i,this.v),this.j)}clearTarget(){this.A(),this.P(!0)}show(){this.A(),this.v=!0,this.R.setVisible(!0)}hide(){this.A(),this.v&&(this.v=!1,this.R.setVisible(!1))}toggle(){this.A(),this.v?this.hide():this.show()}isVisible(){return this.A(),this.v}requestSynchronization(){this.A(),this.R.request()}synchronizeImmediately(t={}){this.A(),this.R.synchronizeImmediately(t)}dispose(){this.q||(this.P(!0),this.R.dispose(),this.q=!0)}A(){if(this.q)throw new Error(`${t} This overlay controller has been disposed.`)}P(t){this.R.clear({restoreCanvas:t}),this.j?.dispose(),this.j=void 0,this.u=void 0}},o={name:"textmode.overlay.js",install(t,i){const s=new h(t),e=i.on("preSetup",()=>s.synchronizeImmediately({forceResize:!0})),n=i.on("postDraw",()=>s.requestSynchronization());try{i.defineExtension("textmodifier","overlay",{get:()=>s})}catch(o){throw s.dispose(),e(),n(),o}return()=>{s.dispose(),e(),n()}}};"undefined"!=typeof window&&(window.OverlayPlugin=o);export{o as OverlayPlugin};
1
+ var t="[textmode.overlay.js]",i=1e-8,e=`${t} Only finite, positive, axis-aligned transforms are supported. Rotations, skew, reflections, and collapsed axes are not supported.`,s=`${t} The textmode output canvas cannot have its own transform, border, or padding while used as an overlay.`;function n(t){c(getComputedStyle(t))}function r(t){if(!t||"none"===t)return;const s=/^matrix\(([^)]+)\)$/.exec(t);if(s){const t=s[1].split(",").map(Number);if(6===t.length&&t.every(Number.isFinite)&&t[0]>i&&t[3]>i&&Math.abs(t[1])<=i&&Math.abs(t[2])<=i)return}const n=/^matrix3d\(([^)]+)\)$/.exec(t);if(n){const t=n[1].split(",").map(Number);if(16===t.length&&t.every(Number.isFinite)&&t[0]>i&&t[5]>i&&Math.abs(t[10]-1)<=i&&Math.abs(t[15]-1)<=i&&[1,2,3,4,6,7,8,9,11,14].every(e=>Math.abs(t[e])<=i))return}throw new Error(e)}function o(t){return Math.round(100*t)/100}function h(t){let i=t;for(;i;){const t=getComputedStyle(i);if(r(t.transform),u(t),d(t),t.perspective&&"none"!==t.perspective)throw new Error(e);i=a(i)}}function a(t){if(t.parentElement)return t.parentElement;const i=t.getRootNode();return"undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot?i.host:null}function u(t){if(!function(t){if(!t||"none"===t)return!0;const e=/^(-?(?:\d+\.?\d*|\.\d+))(deg|grad|rad|turn)?$/.exec(t.trim());if(!e)return!1;const s=Number(e[1]),n=e[2]??"deg",r="turn"===n?360*s:"rad"===n?180*s/Math.PI:"grad"===n?.9*s:s;return Math.abs(r%360)<=i}(t.rotate)||!function(t){if(!t||"none"===t)return!0;const e=t.trim().split(/\s+/).map(t=>t.endsWith("%")?Number.parseFloat(t)/100:Number(t));if(e.length<1||e.length>2||e.some(t=>!Number.isFinite(t)))return!1;const s=e[0],n=e[1]??s;return s>i&&n>i}(t.scale)||(s=t.translate)&&"none"!==s&&!(s.trim().split(/\s+/).length<=2))throw new Error(e);var s}function d(t){const s=t.zoom;if(!s||"normal"===s)return;const n=s.endsWith("%")?Number.parseFloat(s)/100:Number.parseFloat(s);if(!Number.isFinite(n)||n<=i)throw new Error(e)}function c(t){const e=t.transform&&"none"!==t.transform||t.rotate&&"none"!==t.rotate||t.scale&&"none"!==t.scale||t.translate&&"none"!==t.translate,n=[[t.borderTopStyle,t.borderTopWidth],[t.borderRightStyle,t.borderRightWidth],[t.borderBottomStyle,t.borderBottomWidth],[t.borderLeftStyle,t.borderLeftWidth]],r=[t.paddingTop,t.paddingRight,t.paddingBottom,t.paddingLeft],o=n.some(([t,e])=>"none"!==t&&(Number.parseFloat(e)||0)>i),h=r.some(t=>(Number.parseFloat(t)||0)>i);if(e||o||h)throw new Error(s)}var l=class{t;i;o;h;u;l;m=!0;v="none";p;_;N=!1;M;T;C=()=>this.request();constructor(t,i){var e;this.t=t,this.i=i,this.o=t.parentNode,this.h=t.nextSibling,this.u={position:(e=t).style.position,left:e.style.left,top:e.style.top,width:e.style.width,height:e.style.height,zIndex:e.style.zIndex,display:e.style.display,pointerEvents:e.style.pointerEvents}}bind(t,i,e){this.l=t,this.m=i,this.v=e,this.L(),this.S()&&(n(this.t),this.O()),this.request()}setPointerEvents(t){this.v=t,this.l&&this.H("pointerEvents",t)}request(){this.l&&void 0===this.M&&(this.l.isConnected?this.M=window.requestAnimationFrame(()=>{this.M=void 0,this.$()}):this.V())}synchronizeImmediately(t={}){this.R(),this.$(t.forceResize??!1)}setVisible(t){this.m=t,t?(this.H("display",this.u.display),this.S(),this.request()):this.H("display","none")}clear(t){this.R(),this.F(),this.l=void 0,this.T=void 0,t.restoreCanvas&&this.I()}dispose(){this.clear({restoreCanvas:!0})}$(t=!1){const i=this.l;if(!i||!this.S())return;const e=function(t){h(t);const i=t.getBoundingClientRect(),e=t instanceof HTMLCanvasElement?t.width:t.videoWidth,s=t instanceof HTMLCanvasElement?t.height:t.videoHeight,n=i.width>0?i.width:e,r=i.height>0?i.height:s;if(!(n<=0||r<=0))return{left:o(i.left),top:o(i.top),width:o(n),height:o(r)}}(i);if(!e)return;const s=function(t){const i=t.getBoundingClientRect(),e=getComputedStyle(t);c(e);const s=Number.parseFloat(e.width),n=Number.parseFloat(e.height);if(!(i.width>0&&i.height>0&&s>0&&n>0))return;const r=i.width/s,o=i.height/n;if(!Number.isFinite(r)||!Number.isFinite(o)||r<=0||o<=0)return;const h=Number.parseFloat(e.left),a=Number.parseFloat(e.top);return Number.isFinite(h)&&Number.isFinite(a)?{scaleX:r,scaleY:o,originLeft:i.left-r*h,originTop:i.top-o*a}:void 0}(this.t);if(!s)return;const n=function(t,i){return{left:o((t.left-i.originLeft)/i.scaleX),top:o((t.top-i.originTop)/i.scaleY),width:Math.round(t.width/i.scaleX),height:Math.round(t.height/i.scaleY)}}(e,s);if(!t&&(a=n,(r=this.T)&&r.left===a.left&&r.top===a.top&&r.width===a.width&&r.height===a.height))return;var r,a;const u=this.T,d=t||!u||u.width!==n.width||u.height!==n.height;this.H("left",`${n.left}px`),this.H("top",`${n.top}px`),d&&this.i(n.width,n.height),this.T=n}O(){const t=this.l;t&&!this.N&&(this.N=!0,"undefined"!=typeof ResizeObserver&&(this.p=new ResizeObserver(this.C),this.p.observe(t,{box:"border-box"})),window.addEventListener("resize",this.C),window.addEventListener("scroll",this.C,!0),t instanceof HTMLVideoElement&&(t.addEventListener("loadedmetadata",this.C),t.addEventListener("resize",this.C)))}S(){const t=this.l;if(!t)return!1;if(!t.isConnected||!t.parentNode)return this.V(),!1;this._?.disconnect(),this._=void 0,this.t.previousSibling===t&&this.t.parentNode===t.parentNode||(t.parentNode.insertBefore(this.t,t.nextSibling),this.L());const i=Number.parseFloat(getComputedStyle(t).zIndex);return this.H("position","absolute"),this.H("zIndex",String((Number.isFinite(i)?i:0)+1)),this.H("pointerEvents",this.v),this.H("display",this.m?this.u.display:"none"),!0}V(){if(this._||"undefined"==typeof MutationObserver)return;const t=document.documentElement;t&&(this._=new MutationObserver(()=>{this.l?.isConnected&&(this.S()&&this.O(),this.request())}),this._.observe(t,{childList:!0,subtree:!0}))}F(){this.p?.disconnect(),this.p=void 0,this._?.disconnect(),this._=void 0;const t=this.l;this.N=!1,window.removeEventListener("resize",this.C),window.removeEventListener("scroll",this.C,!0),t instanceof HTMLVideoElement&&(t.removeEventListener("loadedmetadata",this.C),t.removeEventListener("resize",this.C))}R(){void 0!==this.M&&(window.cancelAnimationFrame(this.M),this.M=void 0)}I(){if(this.t.isConnected&&this.o){const t=this.h;this.o.insertBefore(this.t,t?.parentNode===this.o?t:null)}Object.assign(this.t.style,this.u)}H(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}L(){this.H("position","absolute"),this.H("left","0px"),this.H("top","0px"),this.T=void 0}},f=class{P;t;j;l;q;m=!0;A=!1;constructor(t){this.P=t,this.t=t.canvas,this.j=new l(this.t,(t,i)=>this.P.resizeCanvas(t,i))}get target(){return this.k(),this.l}get source(){return this.k(),this.q}setTarget(i,e={}){this.k(),function(i,e){const s="undefined"!=typeof HTMLCanvasElement&&i instanceof HTMLCanvasElement,n="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement;if(!s&&!n)throw new TypeError(`${t} setTarget() requires an HTMLCanvasElement or HTMLVideoElement.`);if(i===e)throw new TypeError(`${t} The textmode output canvas cannot be used as its own overlay target.`);h(i)}(i,this.t),n(this.t);const s=e.pointerEvents??"none";if(i===this.l&&this.q)return this.j.setPointerEvents(s),this.requestSynchronization(),this.q;this.B(!1),this.l=i;try{return this.j.bind(i,this.m,s),this.q=this.P.createTexture(i),this.q}catch(r){throw this.j.clear({restoreCanvas:!0}),this.l=void 0,this.q=void 0,r}}clearTarget(){this.k(),this.B(!0)}show(){this.k(),this.m=!0,this.j.setVisible(!0)}hide(){this.k(),this.m&&(this.m=!1,this.j.setVisible(!1))}toggle(){this.k(),this.m?this.hide():this.show()}isVisible(){return this.k(),this.m}requestSynchronization(){this.k(),this.j.request()}synchronizeImmediately(t={}){this.k(),this.j.synchronizeImmediately(t)}dispose(){this.A||(this.B(!0),this.j.dispose(),this.A=!0)}k(){if(this.A)throw new Error(`${t} This overlay controller has been disposed.`)}B(t){this.j.clear({restoreCanvas:t}),this.q?.dispose(),this.q=void 0,this.l=void 0}},m={name:"textmode.overlay.js",install(t,i){const e=new f(t),s=i.on("preSetup",()=>e.synchronizeImmediately({forceResize:!0})),n=i.on("postDraw",()=>e.requestSynchronization());try{i.defineExtension("textmodifier","overlay",{get:()=>e})}catch(r){throw e.dispose(),s(),n(),r}return()=>{e.dispose(),s(),n()}}};"undefined"!=typeof window&&(window.OverlayPlugin=m);export{m as OverlayPlugin};
@@ -1 +1 @@
1
- !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).textmodeOverlay={})}(this,function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var i="[textmode.overlay.js]",e=1e-8;function s(t){if(!t||"none"===t)return;const s=/^matrix\(([^)]+)\)$/.exec(t);if(s){const t=s[1].split(",").map(Number);if(6===t.length&&Math.abs(t[1])<=e&&Math.abs(t[2])<=e)return}const n=/^matrix3d\(([^)]+)\)$/.exec(t);if(n){const t=n[1].split(",").map(Number);if(16===t.length&&[1,2,3,4,6,7,8,9,11].every(i=>Math.abs(t[i])<=e))return}throw new Error(`${i} Rotated and skewed overlay targets are not supported.`)}function n(t){return Math.round(100*t)/100}var h=class{t;i;h;o;l;u;v=!0;m;p;_=!1;T;M;L=()=>this.request();constructor(t,i){var e;this.t=t,this.i=i,this.h=t.parentNode,this.o=t.nextSibling,this.l={position:(e=t).style.position,left:e.style.left,top:e.style.top,width:e.style.width,height:e.style.height,zIndex:e.style.zIndex,display:e.style.display,pointerEvents:e.style.pointerEvents}}bind(t,i){this.u=t,this.v=i,this.C()&&this.H(),this.request()}request(){this.u&&void 0===this.T&&(this.u.isConnected?this.T=window.requestAnimationFrame(()=>{this.T=void 0,this.O()}):this.S())}synchronizeImmediately(t={}){this.$(),this.O(t.forceResize??!1)}setVisible(t){this.v=t,t?(this.V("display",this.l.display),this.C(),this.request()):this.V("display","none")}clear(t){this.$(),this.j(),this.u=void 0,this.M=void 0,t.restoreCanvas&&this.N()}dispose(){this.clear({restoreCanvas:!0})}O(t=!1){const i=this.u;if(!i||!this.C())return;const e=function(t,i){s(getComputedStyle(t).transform);const e=t.getBoundingClientRect(),h=t instanceof HTMLCanvasElement?t.width:t.videoWidth,o=t instanceof HTMLCanvasElement?t.height:t.videoHeight,r=n(e.width>0?e.width:h),a=n(e.height>0?e.height:o);if(r<=0||a<=0)return;const d=function(t,i){const e=i.offsetParent;if(e instanceof HTMLElement&&e!==document.body&&e!==document.documentElement){const i=e.getBoundingClientRect();return{left:t.left-i.left+e.scrollLeft-e.clientLeft,top:t.top-i.top+e.scrollTop-e.clientTop}}return{left:t.left+window.scrollX,top:t.top+window.scrollY}}(e,i);return{left:n(d.left),top:n(d.top),width:r,height:a}}(i,this.t);if(!e||!t&&(o=e,(h=this.M)&&h.left===o.left&&h.top===o.top&&h.width===o.width&&h.height===o.height))return;var h,o;const r=this.M,a=t||!r||r.width!==e.width||r.height!==e.height;this.M=e,this.V("left",`${e.left}px`),this.V("top",`${e.top}px`),a&&this.i(e.width,e.height)}H(){const t=this.u;t&&!this._&&(this._=!0,"undefined"!=typeof ResizeObserver&&(this.m=new ResizeObserver(this.L),this.m.observe(t,{box:"border-box"})),window.addEventListener("resize",this.L),window.addEventListener("scroll",this.L,!0),t instanceof HTMLVideoElement&&(t.addEventListener("loadedmetadata",this.L),t.addEventListener("resize",this.L)))}C(){const t=this.u;if(!t)return!1;if(!t.isConnected||!t.parentNode)return this.S(),!1;this.p?.disconnect(),this.p=void 0,this.t.previousSibling===t&&this.t.parentNode===t.parentNode||t.parentNode.insertBefore(this.t,t.nextSibling);const i=Number.parseFloat(getComputedStyle(t).zIndex);return this.V("position","absolute"),this.V("zIndex",String((Number.isFinite(i)?i:0)+1)),this.V("pointerEvents","auto"),this.V("display",this.v?this.l.display:"none"),!0}S(){if(this.p||"undefined"==typeof MutationObserver)return;const t=document.documentElement;t&&(this.p=new MutationObserver(()=>{this.u?.isConnected&&(this.C()&&this.H(),this.request())}),this.p.observe(t,{childList:!0,subtree:!0}))}j(){this.m?.disconnect(),this.m=void 0,this.p?.disconnect(),this.p=void 0;const t=this.u;this._=!1,window.removeEventListener("resize",this.L),window.removeEventListener("scroll",this.L,!0),t instanceof HTMLVideoElement&&(t.removeEventListener("loadedmetadata",this.L),t.removeEventListener("resize",this.L))}$(){void 0!==this.T&&(window.cancelAnimationFrame(this.T),this.T=void 0)}N(){if(this.t.isConnected&&this.h){const t=this.o;this.h.insertBefore(this.t,t?.parentNode===this.h?t:null)}Object.assign(this.t.style,this.l)}V(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}},o=class{F;t;I;u;R;v=!0;q=!1;constructor(t){this.F=t,this.t=t.canvas,this.I=new h(this.t,(t,i)=>this.F.resizeCanvas(t,i))}get target(){return this.A(),this.u}get source(){return this.A(),this.R}setTarget(t){return this.A(),function(t,e){const n="undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement,h="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(!n&&!h)throw new TypeError(`${i} setTarget() requires an HTMLCanvasElement or HTMLVideoElement.`);if(t===e)throw new TypeError(`${i} The textmode output canvas cannot be used as its own overlay target.`);s(getComputedStyle(t).transform)}(t,this.t),t===this.u&&this.R?(this.requestSynchronization(),this.R):(this.P(!1),this.u=t,this.R=this.F.createTexture(t),this.I.bind(t,this.v),this.R)}clearTarget(){this.A(),this.P(!0)}show(){this.A(),this.v=!0,this.I.setVisible(!0)}hide(){this.A(),this.v&&(this.v=!1,this.I.setVisible(!1))}toggle(){this.A(),this.v?this.hide():this.show()}isVisible(){return this.A(),this.v}requestSynchronization(){this.A(),this.I.request()}synchronizeImmediately(t={}){this.A(),this.I.synchronizeImmediately(t)}dispose(){this.q||(this.P(!0),this.I.dispose(),this.q=!0)}A(){if(this.q)throw new Error(`${i} This overlay controller has been disposed.`)}P(t){this.I.clear({restoreCanvas:t}),this.R?.dispose(),this.R=void 0,this.u=void 0}},r={name:"textmode.overlay.js",install(t,i){const e=new o(t),s=i.on("preSetup",()=>e.synchronizeImmediately({forceResize:!0})),n=i.on("postDraw",()=>e.requestSynchronization());try{i.defineExtension("textmodifier","overlay",{get:()=>e})}catch(h){throw e.dispose(),s(),n(),h}return()=>{e.dispose(),s(),n()}}};"undefined"!=typeof window&&(window.OverlayPlugin=r),t.OverlayPlugin=r});
1
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).textmodeOverlay={})}(this,function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var i="[textmode.overlay.js]",e=1e-8,s=`${i} Only finite, positive, axis-aligned transforms are supported. Rotations, skew, reflections, and collapsed axes are not supported.`,n=`${i} The textmode output canvas cannot have its own transform, border, or padding while used as an overlay.`;function o(t){f(getComputedStyle(t))}function r(t){if(!t||"none"===t)return;const i=/^matrix\(([^)]+)\)$/.exec(t);if(i){const t=i[1].split(",").map(Number);if(6===t.length&&t.every(Number.isFinite)&&t[0]>e&&t[3]>e&&Math.abs(t[1])<=e&&Math.abs(t[2])<=e)return}const n=/^matrix3d\(([^)]+)\)$/.exec(t);if(n){const t=n[1].split(",").map(Number);if(16===t.length&&t.every(Number.isFinite)&&t[0]>e&&t[5]>e&&Math.abs(t[10]-1)<=e&&Math.abs(t[15]-1)<=e&&[1,2,3,4,6,7,8,9,11,14].every(i=>Math.abs(t[i])<=e))return}throw new Error(s)}function h(t){return Math.round(100*t)/100}function a(t){let i=t;for(;i;){const t=getComputedStyle(i);if(r(t.transform),d(t),c(t),t.perspective&&"none"!==t.perspective)throw new Error(s);i=u(i)}}function u(t){if(t.parentElement)return t.parentElement;const i=t.getRootNode();return"undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot?i.host:null}function d(t){if(!function(t){if(!t||"none"===t)return!0;const i=/^(-?(?:\d+\.?\d*|\.\d+))(deg|grad|rad|turn)?$/.exec(t.trim());if(!i)return!1;const s=Number(i[1]),n=i[2]??"deg",o="turn"===n?360*s:"rad"===n?180*s/Math.PI:"grad"===n?.9*s:s;return Math.abs(o%360)<=e}(t.rotate)||!function(t){if(!t||"none"===t)return!0;const i=t.trim().split(/\s+/).map(t=>t.endsWith("%")?Number.parseFloat(t)/100:Number(t));if(i.length<1||i.length>2||i.some(t=>!Number.isFinite(t)))return!1;const s=i[0],n=i[1]??s;return s>e&&n>e}(t.scale)||(i=t.translate)&&"none"!==i&&!(i.trim().split(/\s+/).length<=2))throw new Error(s);var i}function c(t){const i=t.zoom;if(!i||"normal"===i)return;const n=i.endsWith("%")?Number.parseFloat(i)/100:Number.parseFloat(i);if(!Number.isFinite(n)||n<=e)throw new Error(s)}function f(t){const i=t.transform&&"none"!==t.transform||t.rotate&&"none"!==t.rotate||t.scale&&"none"!==t.scale||t.translate&&"none"!==t.translate,s=[[t.borderTopStyle,t.borderTopWidth],[t.borderRightStyle,t.borderRightWidth],[t.borderBottomStyle,t.borderBottomWidth],[t.borderLeftStyle,t.borderLeftWidth]],o=[t.paddingTop,t.paddingRight,t.paddingBottom,t.paddingLeft],r=s.some(([t,i])=>"none"!==t&&(Number.parseFloat(i)||0)>e),h=o.some(t=>(Number.parseFloat(t)||0)>e);if(i||r||h)throw new Error(n)}var l=class{t;i;o;h;u;l;m=!0;p="none";v;_;M=!1;N;T;C=()=>this.request();constructor(t,i){var e;this.t=t,this.i=i,this.o=t.parentNode,this.h=t.nextSibling,this.u={position:(e=t).style.position,left:e.style.left,top:e.style.top,width:e.style.width,height:e.style.height,zIndex:e.style.zIndex,display:e.style.display,pointerEvents:e.style.pointerEvents}}bind(t,i,e){this.l=t,this.m=i,this.p=e,this.L(),this.S()&&(o(this.t),this.O()),this.request()}setPointerEvents(t){this.p=t,this.l&&this.H("pointerEvents",t)}request(){this.l&&void 0===this.N&&(this.l.isConnected?this.N=window.requestAnimationFrame(()=>{this.N=void 0,this.$()}):this.V())}synchronizeImmediately(t={}){this.R(),this.$(t.forceResize??!1)}setVisible(t){this.m=t,t?(this.H("display",this.u.display),this.S(),this.request()):this.H("display","none")}clear(t){this.R(),this.j(),this.l=void 0,this.T=void 0,t.restoreCanvas&&this.F()}dispose(){this.clear({restoreCanvas:!0})}$(t=!1){const i=this.l;if(!i||!this.S())return;const e=function(t){a(t);const i=t.getBoundingClientRect(),e=t instanceof HTMLCanvasElement?t.width:t.videoWidth,s=t instanceof HTMLCanvasElement?t.height:t.videoHeight,n=i.width>0?i.width:e,o=i.height>0?i.height:s;if(!(n<=0||o<=0))return{left:h(i.left),top:h(i.top),width:h(n),height:h(o)}}(i);if(!e)return;const s=function(t){const i=t.getBoundingClientRect(),e=getComputedStyle(t);f(e);const s=Number.parseFloat(e.width),n=Number.parseFloat(e.height);if(!(i.width>0&&i.height>0&&s>0&&n>0))return;const o=i.width/s,r=i.height/n;if(!Number.isFinite(o)||!Number.isFinite(r)||o<=0||r<=0)return;const h=Number.parseFloat(e.left),a=Number.parseFloat(e.top);return Number.isFinite(h)&&Number.isFinite(a)?{scaleX:o,scaleY:r,originLeft:i.left-o*h,originTop:i.top-r*a}:void 0}(this.t);if(!s)return;const n=function(t,i){return{left:h((t.left-i.originLeft)/i.scaleX),top:h((t.top-i.originTop)/i.scaleY),width:Math.round(t.width/i.scaleX),height:Math.round(t.height/i.scaleY)}}(e,s);if(!t&&(r=n,(o=this.T)&&o.left===r.left&&o.top===r.top&&o.width===r.width&&o.height===r.height))return;var o,r;const u=this.T,d=t||!u||u.width!==n.width||u.height!==n.height;this.H("left",`${n.left}px`),this.H("top",`${n.top}px`),d&&this.i(n.width,n.height),this.T=n}O(){const t=this.l;t&&!this.M&&(this.M=!0,"undefined"!=typeof ResizeObserver&&(this.v=new ResizeObserver(this.C),this.v.observe(t,{box:"border-box"})),window.addEventListener("resize",this.C),window.addEventListener("scroll",this.C,!0),t instanceof HTMLVideoElement&&(t.addEventListener("loadedmetadata",this.C),t.addEventListener("resize",this.C)))}S(){const t=this.l;if(!t)return!1;if(!t.isConnected||!t.parentNode)return this.V(),!1;this._?.disconnect(),this._=void 0,this.t.previousSibling===t&&this.t.parentNode===t.parentNode||(t.parentNode.insertBefore(this.t,t.nextSibling),this.L());const i=Number.parseFloat(getComputedStyle(t).zIndex);return this.H("position","absolute"),this.H("zIndex",String((Number.isFinite(i)?i:0)+1)),this.H("pointerEvents",this.p),this.H("display",this.m?this.u.display:"none"),!0}V(){if(this._||"undefined"==typeof MutationObserver)return;const t=document.documentElement;t&&(this._=new MutationObserver(()=>{this.l?.isConnected&&(this.S()&&this.O(),this.request())}),this._.observe(t,{childList:!0,subtree:!0}))}j(){this.v?.disconnect(),this.v=void 0,this._?.disconnect(),this._=void 0;const t=this.l;this.M=!1,window.removeEventListener("resize",this.C),window.removeEventListener("scroll",this.C,!0),t instanceof HTMLVideoElement&&(t.removeEventListener("loadedmetadata",this.C),t.removeEventListener("resize",this.C))}R(){void 0!==this.N&&(window.cancelAnimationFrame(this.N),this.N=void 0)}F(){if(this.t.isConnected&&this.o){const t=this.h;this.o.insertBefore(this.t,t?.parentNode===this.o?t:null)}Object.assign(this.t.style,this.u)}H(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}L(){this.H("position","absolute"),this.H("left","0px"),this.H("top","0px"),this.T=void 0}},m=class{I;t;P;l;q;m=!0;A=!1;constructor(t){this.I=t,this.t=t.canvas,this.P=new l(this.t,(t,i)=>this.I.resizeCanvas(t,i))}get target(){return this.k(),this.l}get source(){return this.k(),this.q}setTarget(t,e={}){this.k(),function(t,e){const s="undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement,n="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(!s&&!n)throw new TypeError(`${i} setTarget() requires an HTMLCanvasElement or HTMLVideoElement.`);if(t===e)throw new TypeError(`${i} The textmode output canvas cannot be used as its own overlay target.`);a(t)}(t,this.t),o(this.t);const s=e.pointerEvents??"none";if(t===this.l&&this.q)return this.P.setPointerEvents(s),this.requestSynchronization(),this.q;this.B(!1),this.l=t;try{return this.P.bind(t,this.m,s),this.q=this.I.createTexture(t),this.q}catch(n){throw this.P.clear({restoreCanvas:!0}),this.l=void 0,this.q=void 0,n}}clearTarget(){this.k(),this.B(!0)}show(){this.k(),this.m=!0,this.P.setVisible(!0)}hide(){this.k(),this.m&&(this.m=!1,this.P.setVisible(!1))}toggle(){this.k(),this.m?this.hide():this.show()}isVisible(){return this.k(),this.m}requestSynchronization(){this.k(),this.P.request()}synchronizeImmediately(t={}){this.k(),this.P.synchronizeImmediately(t)}dispose(){this.A||(this.B(!0),this.P.dispose(),this.A=!0)}k(){if(this.A)throw new Error(`${i} This overlay controller has been disposed.`)}B(t){this.P.clear({restoreCanvas:t}),this.q?.dispose(),this.q=void 0,this.l=void 0}},p={name:"textmode.overlay.js",install(t,i){const e=new m(t),s=i.on("preSetup",()=>e.synchronizeImmediately({forceResize:!0})),n=i.on("postDraw",()=>e.requestSynchronization());try{i.defineExtension("textmodifier","overlay",{get:()=>e})}catch(o){throw e.dispose(),s(),n(),o}return()=>{e.dispose(),s(),n()}}};"undefined"!=typeof window&&(window.OverlayPlugin=p),t.OverlayPlugin=p});
@@ -2,8 +2,6 @@ import type { TextmodePlugin } from 'textmode.js';
2
2
  /**
3
3
  * Installs an isolated overlay controller on each textmode.js instance.
4
4
  *
5
- * @category Workflow
6
- *
7
5
  * @example
8
6
  * ```ts
9
7
  * const t = textmode.create({ plugins: [OverlayPlugin] });
@@ -11,22 +11,13 @@
11
11
  * and transform settings.
12
12
  * 4. Show, hide, or toggle the output canvas while drawing continues.
13
13
  *
14
- * @categoryDescription Workflow
15
- * The plugin that installs the overlay controller on textmode.js layers.
16
- *
17
- * @categoryDescription Overlay controller
18
- * The per-instance controller that samples a target and keeps the output aligned.
19
- *
20
- * @categoryDescription Target types
21
- * The live browser media elements the overlay can sample.
22
- *
23
14
  * @showCategories
24
15
  */
25
16
  import './augmentations';
26
17
  import type { TextmodePlugin } from 'textmode.js';
27
18
  import { OverlayPlugin } from './OverlayPlugin';
28
19
  export { OverlayPlugin };
29
- export type { TextmodeOverlayController, TextmodeOverlayTarget } from './types';
20
+ export type { TextmodeOverlayController, TextmodeOverlayPointerEvents, TextmodeOverlaySetTargetOptions, TextmodeOverlayTarget, } from './types';
30
21
  declare global {
31
22
  interface Window {
32
23
  OverlayPlugin?: TextmodePlugin;
@@ -12,12 +12,34 @@ export type OverlayGeometry = Readonly<{
12
12
  width: number;
13
13
  height: number;
14
14
  }>;
15
+ /**
16
+ * Local coordinate space of the output canvas, relative to the viewport.
17
+ *
18
+ * `scale` converts a local CSS pixel into a viewport pixel, and `origin` is the
19
+ * viewport position of the output canvas's local `(0, 0)`. The pair lets the
20
+ * synchronizer express a target's viewport rectangle in the output canvas's own
21
+ * CSS pixel space, so ancestor transforms and CSS `zoom` are only applied once.
22
+ *
23
+ * @internal
24
+ */
25
+ export type OverlayCoordinateSpace = Readonly<{
26
+ scaleX: number;
27
+ scaleY: number;
28
+ originLeft: number;
29
+ originTop: number;
30
+ }>;
15
31
  /**
16
32
  * Validate a target and preserve the package's public error contract.
17
33
  *
18
34
  * @internal
19
35
  */
20
36
  export declare function assertValidTarget(target: unknown, output: HTMLCanvasElement): asserts target is TextmodeOverlayTarget;
37
+ /**
38
+ * Validate output-canvas box assumptions before a binding mutates DOM or texture state.
39
+ *
40
+ * @internal
41
+ */
42
+ export declare function assertValidOutputCanvas(output: HTMLCanvasElement): void;
21
43
  /**
22
44
  * Reject transforms that cannot be represented by axis-aligned overlay geometry.
23
45
  *
@@ -25,11 +47,32 @@ export declare function assertValidTarget(target: unknown, output: HTMLCanvasEle
25
47
  */
26
48
  export declare function assertAxisAlignedTransform(transform: string): void;
27
49
  /**
28
- * Measure and round a target in the output canvas's coordinate space.
50
+ * Measure a target's rendered rectangle in viewport coordinates.
51
+ *
52
+ * Transform contributions from the target and its ancestors are included, which
53
+ * is exactly what the output canvas must visually match. Falls back to the
54
+ * target's intrinsic dimensions when the layout rectangle collapses to zero.
55
+ *
56
+ * @internal
57
+ */
58
+ export declare function measureTargetGeometry(target: TextmodeOverlayTarget): OverlayGeometry | undefined;
59
+ /**
60
+ * Measure the output canvas's local coordinate space.
61
+ *
62
+ * The output carries no transform of its own, so the ratio between its rendered
63
+ * box and its used CSS size is precisely the accumulated ancestor scale (from
64
+ * transforms and CSS `zoom`). Returns `undefined` while the output is not
65
+ * measurable, so synchronization can safely retry later.
66
+ *
67
+ * @internal
68
+ */
69
+ export declare function measureOutputCoordinateSpace(output: HTMLCanvasElement): OverlayCoordinateSpace | undefined;
70
+ /**
71
+ * Express a target's viewport geometry as output-canvas-local CSS pixels.
29
72
  *
30
73
  * @internal
31
74
  */
32
- export declare function measureOverlayGeometry(target: TextmodeOverlayTarget, output: HTMLCanvasElement): OverlayGeometry | undefined;
75
+ export declare function projectGeometry(target: OverlayGeometry, space: OverlayCoordinateSpace): OverlayGeometry;
33
76
  /**
34
77
  * Compare complete geometry values.
35
78
  *
@@ -1,4 +1,4 @@
1
- import type { TextmodeOverlayTarget } from '../types';
1
+ import type { TextmodeOverlayPointerEvents, TextmodeOverlayTarget } from '../types';
2
2
  /** @internal */
3
3
  export declare class OverlaySynchronizer {
4
4
  private readonly _output;
@@ -8,6 +8,7 @@ export declare class OverlaySynchronizer {
8
8
  private readonly _originalStyle;
9
9
  private _target;
10
10
  private _visible;
11
+ private _pointerEvents;
11
12
  private _resizeObserver;
12
13
  private _mountObserver;
13
14
  private _isObserving;
@@ -15,7 +16,8 @@ export declare class OverlaySynchronizer {
15
16
  private _lastGeometry;
16
17
  private readonly _scheduleFromEvent;
17
18
  constructor(output: HTMLCanvasElement, resizeCanvas: (width: number, height: number) => void);
18
- bind(target: TextmodeOverlayTarget, visible: boolean): void;
19
+ bind(target: TextmodeOverlayTarget, visible: boolean, pointerEvents: TextmodeOverlayPointerEvents): void;
20
+ setPointerEvents(pointerEvents: TextmodeOverlayPointerEvents): void;
19
21
  request(): void;
20
22
  synchronizeImmediately(options?: {
21
23
  forceResize?: boolean;
@@ -33,4 +35,5 @@ export declare class OverlaySynchronizer {
33
35
  private _cancelAnimationFrame;
34
36
  private _restoreCanvas;
35
37
  private _setStyle;
38
+ private _normalizeOutputPosition;
36
39
  }
@@ -1,5 +1,5 @@
1
1
  import type { TextmodeTexture, Textmodifier } from 'textmode.js';
2
- import type { TextmodeOverlayController, TextmodeOverlayTarget } from '../types';
2
+ import type { TextmodeOverlayController, TextmodeOverlaySetTargetOptions, TextmodeOverlayTarget } from '../types';
3
3
  /** @internal */
4
4
  export declare class TextmodeOverlayControllerImpl implements TextmodeOverlayController {
5
5
  private readonly _textmodifier;
@@ -12,7 +12,7 @@ export declare class TextmodeOverlayControllerImpl implements TextmodeOverlayCon
12
12
  constructor(textmodifier: Textmodifier);
13
13
  get target(): TextmodeOverlayTarget | undefined;
14
14
  get source(): TextmodeTexture | undefined;
15
- setTarget(target: TextmodeOverlayTarget): TextmodeTexture;
15
+ setTarget(target: TextmodeOverlayTarget, options?: TextmodeOverlaySetTargetOptions): TextmodeTexture;
16
16
  clearTarget(): void;
17
17
  show(): void;
18
18
  hide(): void;
@@ -2,27 +2,38 @@ import type { TextmodeTexture } from 'textmode.js';
2
2
  /**
3
3
  * A live browser media element that can be sampled by the overlay controller.
4
4
  *
5
- * @category Target types
6
- *
7
5
  * @see {@link https://code.textmode.art/api/textmode.overlay.js/type-aliases/TextmodeOverlayTarget | TextmodeOverlayTarget API reference}
8
6
  */
9
7
  export type TextmodeOverlayTarget = HTMLCanvasElement | HTMLVideoElement;
10
8
  /**
11
- * Controls the sampled target and DOM alignment for one textmode.js instance.
9
+ * Pointer-event policy for the output canvas.
12
10
  *
13
- * The controller never owns the output canvas. Clearing or uninstalling the plugin
14
- * restores the canvas to its original DOM location and inline styles.
11
+ * Overlays default to `'none'` so page interaction continues through them;
12
+ * opt into `'auto'` when the overlay itself must receive pointer input.
15
13
  *
16
- * @category Overlay controller
17
- *
18
- * @categoryDescription Controller state
19
- * The current sampled target, its configurable texture source, and output visibility state.
14
+ * @see {@link https://code.textmode.art/api/textmode.overlay.js/type-aliases/TextmodeOverlayPointerEvents | TextmodeOverlayPointerEvents API reference}
15
+ */
16
+ export type TextmodeOverlayPointerEvents = 'auto' | 'none';
17
+ /**
18
+ * Options accepted when binding a target.
20
19
  *
21
- * @categoryDescription Target binding
22
- * Attach a target to sample and release it to restore the output canvas.
20
+ * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlaySetTargetOptions | TextmodeOverlaySetTargetOptions API reference}
21
+ */
22
+ export interface TextmodeOverlaySetTargetOptions {
23
+ /**
24
+ * Pointer-event policy applied to the output canvas.
25
+ *
26
+ * @default 'none'
27
+ *
28
+ * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlaySetTargetOptions#pointerevents | pointerEvents API reference}
29
+ */
30
+ pointerEvents?: TextmodeOverlayPointerEvents;
31
+ }
32
+ /**
33
+ * Controls the sampled target and DOM alignment for one textmode.js instance.
23
34
  *
24
- * @categoryDescription Visibility
25
- * Show, hide, and toggle only the output canvas while sampling continues.
35
+ * The controller never owns the output canvas. Clearing or uninstalling the plugin
36
+ * restores the canvas to its original DOM location and inline styles.
26
37
  *
27
38
  * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlayController | TextmodeOverlayController API reference}
28
39
  */
@@ -30,41 +41,44 @@ export interface TextmodeOverlayController {
30
41
  /**
31
42
  * The currently sampled canvas or video.
32
43
  *
33
- * @category Controller state
34
- *
35
44
  * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlayController#target | TextmodeOverlayController.target API reference}
36
45
  */
37
46
  readonly target: TextmodeOverlayTarget | undefined;
38
47
  /**
39
48
  * The configurable texture created from {@link target}.
40
49
  *
41
- * @category Controller state
42
- *
43
50
  * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlayController#source | TextmodeOverlayController.source API reference}
44
51
  */
45
52
  readonly source: TextmodeTexture | undefined;
46
53
  /**
47
54
  * Sample a target and align the textmode output canvas above it.
48
55
  *
49
- * @category Target binding
56
+ * Positive axis-aligned scale and translation, CSS `zoom`, and scrolling are
57
+ * supported on the target and its ancestors. Rotation, skew, reflection,
58
+ * collapsed axes, 3D projection, and output-canvas transform/border/padding
59
+ * are rejected.
50
60
  *
51
61
  * @param target Canvas or video to sample.
62
+ * @param options Binding options, including the output canvas pointer-event policy.
52
63
  * @returns The configurable texture source.
64
+ * @throws {TypeError | Error} When the target kind or target/output geometry cannot be represented by an axis-aligned canvas.
53
65
  *
54
66
  * @example
55
67
  * ```ts
68
+ * // Pointer input passes through the overlay by default.
56
69
  * const source = t.overlay.setTarget(canvas);
57
70
  * source.characters(' .:-=+*#%@');
71
+ *
72
+ * // Opt in when textmode.js mouse handlers should receive the input.
73
+ * t.overlay.setTarget(canvas, { pointerEvents: 'auto' });
58
74
  * ```
59
75
  *
60
76
  * @see {@link https://code.textmode.art/api/textmode.overlay.js/interfaces/TextmodeOverlayController#settarget | TextmodeOverlayController.setTarget API reference}
61
77
  */
62
- setTarget(target: TextmodeOverlayTarget): TextmodeTexture;
78
+ setTarget(target: TextmodeOverlayTarget, options?: TextmodeOverlaySetTargetOptions): TextmodeTexture;
63
79
  /**
64
80
  * Stop sampling and restore the output canvas.
65
81
  *
66
- * @category Target binding
67
- *
68
82
  * @example
69
83
  * ```ts
70
84
  * t.overlay.clearTarget();
@@ -76,8 +90,6 @@ export interface TextmodeOverlayController {
76
90
  /**
77
91
  * Show the output canvas and request a fresh geometry synchronization.
78
92
  *
79
- * @category Visibility
80
- *
81
93
  * @example
82
94
  * ```ts
83
95
  * t.overlay.show();
@@ -89,8 +101,6 @@ export interface TextmodeOverlayController {
89
101
  /**
90
102
  * Hide only the output canvas. Sampling and sketch execution continue.
91
103
  *
92
- * @category Visibility
93
- *
94
104
  * @example
95
105
  * ```ts
96
106
  * t.overlay.hide();
@@ -102,8 +112,6 @@ export interface TextmodeOverlayController {
102
112
  /**
103
113
  * Toggle output-canvas visibility.
104
114
  *
105
- * @category Visibility
106
- *
107
115
  * @example
108
116
  * ```ts
109
117
  * t.overlay.toggle();
@@ -115,8 +123,6 @@ export interface TextmodeOverlayController {
115
123
  /**
116
124
  * Report the controller's intended output visibility.
117
125
  *
118
- * @category Visibility
119
- *
120
126
  * @returns Whether the output canvas is shown.
121
127
  *
122
128
  * @example
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "textmode.overlay.js",
3
- "version": "1.0.3",
3
+ "version": "1.1.0-beta.1",
4
4
  "description": "DOM overlay target plugin for textmode.js",
5
5
  "type": "module",
6
6
  "devEngines": {
7
7
  "runtime": {
8
8
  "name": "node",
9
- "version": "^24.0.0",
9
+ "version": ">=24.0.0",
10
10
  "onFail": "error"
11
11
  },
12
12
  "packageManager": {
@@ -65,15 +65,15 @@
65
65
  "textmode.js": "^0.18.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@textmode/build": "^0.1.0",
68
+ "@textmode/build": "^0.1.1",
69
69
  "@textmode/docs": "^0.3.0",
70
- "@textmode/lint": "^0.1.0",
70
+ "@textmode/lint": "^0.1.2",
71
71
  "@textmode/release": "^0.2.0",
72
- "@textmode/tsconfig": "^0.2.1",
73
- "@types/node": "^24.0.0",
72
+ "@textmode/tsconfig": "^0.2.2",
73
+ "@types/node": "^26.4.0",
74
74
  "textmode.js": "^0.18.0",
75
75
  "typescript": "^6.0.3",
76
- "vitest": "^4.1.10"
76
+ "vitest": "^5.0.0"
77
77
  },
78
78
  "keywords": [
79
79
  "ascii",