textmode.overlay.js 1.0.0-beta.1 → 1.0.0-beta.2
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.
|
@@ -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())}setVisible(t){this.v=t,t?(this
|
|
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.V(),this.O(t.forceResize??!1)}setVisible(t){this.v=t,t?(this.$("display",this.l.display),this.C(),this.request()):this.$("display","none")}clear(t){this.V(),this.N(),this.u=void 0,this.M=void 0,t.restoreCanvas&&this.j()}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.$("left",`${n.left}px`),this.$("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.$("position","absolute"),this.$("zIndex",String((Number.isFinite(i)?i:0)+1)),this.$("pointerEvents","auto"),this.$("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))}V(){void 0!==this.T&&(window.cancelAnimationFrame(this.T),this.T=void 0)}j(){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)}$(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}},h=class{F;t;I;u;R;v=!0;q=!1;constructor(t){this.F=t,this.t=t.canvas,this.I=new n(this.t,(t,i)=>this.F.resizeCanvas(t,i))}get target(){return this.A(),this.u}get source(){return this.A(),this.R}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.R?(this.requestSynchronization(),this.R):(this.P(!1),this.u=i,this.R=this.F.createTexture(i),this.I.bind(i,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("[textmode.overlay.js] This overlay controller has been disposed.")}P(t){this.I.clear({restoreCanvas:t}),this.R?.dispose(),this.R=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 +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 o=class{t;i;o;h;l;u;v=!0;p;
|
|
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 o=class{t;i;o;h;l;u;v=!0;m;p;_=!1;T;M;L=()=>this.request();constructor(t,i){var e;this.t=t,this.i=i,this.o=t.parentNode,this.h=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.V(),this.O(t.forceResize??!1)}setVisible(t){this.v=t,t?(this.$("display",this.l.display),this.C(),this.request()):this.$("display","none")}clear(t){this.V(),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(),o=t instanceof HTMLCanvasElement?t.width:t.videoWidth,h=t instanceof HTMLCanvasElement?t.height:t.videoHeight,r=n(e.width>0?e.width:o),a=n(e.height>0?e.height:h);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&&(h=e,(o=this.M)&&o.left===h.left&&o.top===h.top&&o.width===h.width&&o.height===h.height))return;var o,h;const r=this.M,a=t||!r||r.width!==e.width||r.height!==e.height;this.M=e,this.$("left",`${e.left}px`),this.$("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.$("position","absolute"),this.$("zIndex",String((Number.isFinite(i)?i:0)+1)),this.$("pointerEvents","auto"),this.$("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))}V(){void 0!==this.T&&(window.cancelAnimationFrame(this.T),this.T=void 0)}N(){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.l)}$(t,i){this.t.style[t]!==i&&(this.t.style[t]=i)}},h=class{F;t;I;u;R;v=!0;q=!1;constructor(t){this.F=t,this.t=t.canvas,this.I=new o(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,o="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(!n&&!o)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("[textmode.overlay.js] 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 h(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=r),t.OverlayPlugin=r});
|
|
@@ -17,6 +17,9 @@ export declare class OverlaySynchronizer {
|
|
|
17
17
|
constructor(output: HTMLCanvasElement, resizeCanvas: (width: number, height: number) => void);
|
|
18
18
|
bind(target: TextmodeOverlayTarget, visible: boolean): void;
|
|
19
19
|
request(): void;
|
|
20
|
+
synchronizeImmediately(options?: {
|
|
21
|
+
forceResize?: boolean;
|
|
22
|
+
}): void;
|
|
20
23
|
setVisible(visible: boolean): void;
|
|
21
24
|
clear(options: {
|
|
22
25
|
restoreCanvas: boolean;
|
|
@@ -24,6 +24,14 @@ export declare class TextmodeOverlayControllerImpl implements TextmodeOverlayCon
|
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
26
26
|
requestSynchronization(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Synchronize target geometry immediately at a host lifecycle boundary.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
synchronizeImmediately(options?: {
|
|
33
|
+
forceResize?: boolean;
|
|
34
|
+
}): void;
|
|
27
35
|
/** Release all plugin-owned resources. */
|
|
28
36
|
dispose(): void;
|
|
29
37
|
private _assertActive;
|