@ax-design/reveal-highlight 0.4.2 → 0.5.3

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.
Files changed (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +75 -75
  3. package/build/BaseConfig.d.ts +5 -1
  4. package/build/BaseConfig.d.ts.map +1 -1
  5. package/build/CanvasConfig.d.ts +7 -1
  6. package/build/CanvasConfig.d.ts.map +1 -1
  7. package/build/ComputedStyleStorage.d.ts.map +1 -1
  8. package/build/CustomElements.d.ts +20 -4
  9. package/build/CustomElements.d.ts.map +1 -1
  10. package/build/RevealBoundryStore.d.ts +4 -0
  11. package/build/RevealBoundryStore.d.ts.map +1 -1
  12. package/build/RevealStateManager.d.ts +5 -1
  13. package/build/RevealStateManager.d.ts.map +1 -1
  14. package/build/main.js +113 -82
  15. package/build/utils/types.d.ts +2 -10
  16. package/build/utils/types.d.ts.map +1 -1
  17. package/es/BaseConfig.d.ts +46 -42
  18. package/es/BaseConfig.d.ts.map +1 -1
  19. package/es/BaseConfig.js +241 -219
  20. package/es/BaseConfig.js.map +1 -1
  21. package/es/CanvasConfig.d.ts +21 -15
  22. package/es/CanvasConfig.d.ts.map +1 -1
  23. package/es/CanvasConfig.js +332 -320
  24. package/es/CanvasConfig.js.map +1 -1
  25. package/es/ComputedStyleStorage.d.ts +8 -8
  26. package/es/ComputedStyleStorage.d.ts.map +1 -1
  27. package/es/ComputedStyleStorage.js +68 -58
  28. package/es/ComputedStyleStorage.js.map +1 -1
  29. package/es/CustomElements.d.ts +75 -59
  30. package/es/CustomElements.d.ts.map +1 -1
  31. package/es/CustomElements.js +296 -233
  32. package/es/CustomElements.js.map +1 -1
  33. package/es/Profiler.d.ts +12 -12
  34. package/es/Profiler.js +31 -31
  35. package/es/RevealBoundryStore.d.ts +80 -76
  36. package/es/RevealBoundryStore.d.ts.map +1 -1
  37. package/es/RevealBoundryStore.js +269 -248
  38. package/es/RevealBoundryStore.js.map +1 -1
  39. package/es/RevealStateManager.d.ts +19 -15
  40. package/es/RevealStateManager.d.ts.map +1 -1
  41. package/es/RevealStateManager.js +99 -73
  42. package/es/RevealStateManager.js.map +1 -1
  43. package/es/SvgConfig.d.ts +16 -16
  44. package/es/SvgConfig.js +345 -345
  45. package/es/config.d.ts +4 -4
  46. package/es/config.js +21 -21
  47. package/es/index.d.ts +5 -5
  48. package/es/index.js +205 -205
  49. package/es/tsconfig.tsbuildinfo +1 -1
  50. package/es/utils/extractRGBValue.d.ts +1 -1
  51. package/es/utils/extractRGBValue.js +47 -47
  52. package/es/utils/isValidateBorderDecorationType.d.ts +2 -2
  53. package/es/utils/isValidateBorderDecorationType.js +9 -9
  54. package/es/utils/types.d.ts +94 -102
  55. package/es/utils/types.d.ts.map +1 -1
  56. package/es/utils/types.js +1 -1
  57. package/es/variables.d.ts +1 -1
  58. package/es/variables.js +1 -1
  59. package/package.json +35 -34
  60. package/src/BaseConfig.ts +332 -310
  61. package/src/CanvasConfig.ts +420 -415
  62. package/src/ComputedStyleStorage.ts +102 -89
  63. package/src/CustomElements.ts +344 -272
  64. package/src/Profiler.ts +44 -44
  65. package/src/RevealBoundryStore.ts +315 -291
  66. package/src/RevealStateManager.ts +109 -86
  67. package/src/SvgConfig.ts +422 -422
  68. package/src/config.ts +26 -26
  69. package/src/cssTypedOM.d.ts +52 -52
  70. package/src/index.ts +219 -219
  71. package/src/utils/extractRGBValue.ts +58 -58
  72. package/src/utils/isValidateBorderDecorationType.ts +8 -8
  73. package/src/utils/types.ts +97 -105
  74. package/src/variables.ts +1 -1
package/build/main.js CHANGED
@@ -1,93 +1,116 @@
1
- (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"==typeof globalThis?e||self:globalThis,t(e.AxRevealHighlight={}))})(this,function(e){'use strict';var t=Number.isNaN,r=Math.max,a=Math.floor;function i(e){return p.compat?new m(e):new h(e)}function o(e,t){var a;const i=e.closest(t);if(i)return i;const r=null===(a=n(e))||void 0===a?void 0:a.host;return r?o(r,t):null}function n(e){return e?e.parentNode&&e.parentNode.nodeType===document.DOCUMENT_FRAGMENT_NODE?e.parentNode:n(e.parentNode):null}function l(){customElements.define(P.ElementName,P),customElements.define(C.ElementName,C),customElements.define(w.ElementName,w),customElements.define(D.ElementName,D)}function d({compat:e=!1,borderDetectionMode:t="strictEdge"}){if(A)return void console.warn("You have already registered Ax RevealHighlight, please do not call this function repeatedly.");if(p.borderDetectionMode=t,p.compat=e,A=!0,window.CSS&&window.CSS.registerProperty)window.CSS.registerProperty({name:"--reveal-color",syntax:"<color>",initialValue:"rgb(0, 0, 0)",inherits:!0}),window.CSS.registerProperty({name:"--reveal-opacity",syntax:"<number>",initialValue:"0.26",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-color",syntax:`<color>|${B}`,initialValue:B,inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-width",syntax:"<length>",initialValue:"1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-fill-radius",syntax:"<number>",initialValue:"1.5",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-type",syntax:"<custom-ident>",initialValue:"miter",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-radius",syntax:"<length>",initialValue:"0",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-top-left-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-top-right-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-bottom-left-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-bottom-right-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-left-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-right-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-top-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-bottom-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-color",syntax:`<color>|${B}`,initialValue:B,inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-fill-radius",syntax:"<number>",initialValue:"1.5",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-fill-radius-mode",syntax:"<custom-ident>",initialValue:"relative",inherits:!0}),window.CSS.registerProperty({name:"--reveal-diffuse",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-color",syntax:`<color>|${B}`,initialValue:B,inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-radius-mode",syntax:"<custom-ident>",initialValue:"cover",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-speed",syntax:"<number>",initialValue:"2000",inherits:!0}),window.CSS.registerProperty({name:"--reveal-release-animation-accelerate-rate",syntax:"<number>",initialValue:"6",inherits:!0}),l();else if(e){const e=document.documentElement;e.style.setProperty("--reveal-color","rgb(0, 0, 0)"),e.style.setProperty("--reveal-opacity","0.26"),e.style.setProperty("--reveal-border-color",B),e.style.setProperty("--reveal-border-width","1px"),e.style.setProperty("--reveal-border-fill-radius","1.5"),e.style.setProperty("--reveal-border-decoration-type","miter"),e.style.setProperty("--reveal-border-decoration-radius","0"),e.style.setProperty("--reveal-border-decoration-top-left-radius","-1"),e.style.setProperty("--reveal-border-decoration-top-right-radius","-1"),e.style.setProperty("--reveal-border-decoration-bottom-left-radius","-1"),e.style.setProperty("--reveal-border-decoration-bottom-right-radius","-1"),e.style.setProperty("--reveal-border-left-type","line"),e.style.setProperty("--reveal-border-right-type","line"),e.style.setProperty("--reveal-border-top-type","line"),e.style.setProperty("--reveal-border-bottom-type","line"),e.style.setProperty("--reveal-hover-light","true"),e.style.setProperty("--reveal-hover-light-color",B),e.style.setProperty("--reveal-hover-light-fill-radius","1.5"),e.style.setProperty("--reveal-hover-light-fill-radius-mode","relative"),e.style.setProperty("--reveal-diffuse","true"),e.style.setProperty("--reveal-press-animation","true"),e.style.setProperty("--reveal-press-animation-radius-mode","cover"),e.style.setProperty("--reveal-press-animation-color",B),e.style.setProperty("--reveal-press-animation-speed","2000"),e.style.setProperty("--reveal-release-animation-accelerate-rate","6"),l()}else console.warn("Your browser do NOT support `CSS.registerProperty` method, registration failed!"),console.warn("If you are the developer, try using `register(true)` to support old browsers.")}let s="strictEdge",c=!1;class u extends Error{constructor(){super("Border detection mode has already been initialized."),this.name="InitializedError"}}const p={compat:!1,get borderDetectionMode(){return s},set borderDetectionMode(e){if(c)throw new u;s=e,c=!0}};class m{constructor(e){if(!m.colorParser){const e=document.createElement("div");e.style.display="none !important",document.body.appendChild(e),m.colorParser=e,m.colorParserStyle=window.getComputedStyle(e)}this.el=e,this.style=window.getComputedStyle(e)}size(){return this.style.length}get(e){return this.style.getPropertyValue(e).trim()}getColor(e){return m.colorParser.style.color=this.get(e),m.colorParserStyle.color||"rgb(0, 0, 0)"}getNumber(e){// Length values in computed style will always in the unit of px
1
+ (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"==typeof globalThis?e||self:globalThis,t(e.AxRevealHighlight={}))})(this,function(e){'use strict';var t=Number.isNaN,r=Math.max,i=Math.floor;function a(e){return h.compat||!y?new p(e):new m(e)}function o(e,t){var i;const a=e.closest(t);if(a)return a;const r=null===(i=n(e))||void 0===i?void 0:i.host;return r?o(r,t):null}function n(e){return e?e.parentNode&&e.parentNode.nodeType===document.DOCUMENT_FRAGMENT_NODE?e.parentNode:n(e.parentNode):null}function l(){customElements.define(x.ElementName,x),customElements.define(w.ElementName,w),customElements.define(C.ElementName,C),customElements.define(B.ElementName,B)}function d({compat:e=!1,borderDetectionMode:t="strictEdge"}){if(A)return void console.warn("You have already registered Ax RevealHighlight, please do not call this function repeatedly.");if(h.borderDetectionMode=t,h.compat=e,A=!0,window.CSS&&window.CSS.registerProperty)window.CSS.registerProperty({name:"--reveal-color",syntax:"<color>",initialValue:"rgb(0, 0, 0)",inherits:!0}),window.CSS.registerProperty({name:"--reveal-opacity",syntax:"<number>",initialValue:"0.26",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-color",syntax:`<color>|${D}`,initialValue:D,inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-width",syntax:"<length>",initialValue:"1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-fill-radius",syntax:"<number>",initialValue:"1.5",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-type",syntax:"<custom-ident>",initialValue:"miter",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-radius",syntax:"<length>",initialValue:"0",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-top-left-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-top-right-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-bottom-left-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-decoration-bottom-right-radius",syntax:"<length>",initialValue:"-1px",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-left-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-right-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-top-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-border-bottom-type",syntax:"<custom-ident>",initialValue:"line",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-color",syntax:`<color>|${D}`,initialValue:D,inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-fill-radius",syntax:"<number>",initialValue:"1.5",inherits:!0}),window.CSS.registerProperty({name:"--reveal-hover-light-fill-radius-mode",syntax:"<custom-ident>",initialValue:"relative",inherits:!0}),window.CSS.registerProperty({name:"--reveal-diffuse",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation",syntax:"<custom-ident>",initialValue:"true",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-color",syntax:`<color>|${D}`,initialValue:D,inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-radius-mode",syntax:"<custom-ident>",initialValue:"cover",inherits:!0}),window.CSS.registerProperty({name:"--reveal-press-animation-speed",syntax:"<number>",initialValue:"2000",inherits:!0}),window.CSS.registerProperty({name:"--reveal-release-animation-accelerate-rate",syntax:"<number>",initialValue:"6",inherits:!0}),l();else if(e){const e=document.documentElement;e.style.setProperty("--reveal-color","rgb(0, 0, 0)"),e.style.setProperty("--reveal-opacity","0.26"),e.style.setProperty("--reveal-border-color",D),e.style.setProperty("--reveal-border-width","1px"),e.style.setProperty("--reveal-border-fill-radius","1.5"),e.style.setProperty("--reveal-border-decoration-type","miter"),e.style.setProperty("--reveal-border-decoration-radius","0"),e.style.setProperty("--reveal-border-decoration-top-left-radius","-1"),e.style.setProperty("--reveal-border-decoration-top-right-radius","-1"),e.style.setProperty("--reveal-border-decoration-bottom-left-radius","-1"),e.style.setProperty("--reveal-border-decoration-bottom-right-radius","-1"),e.style.setProperty("--reveal-border-left-type","line"),e.style.setProperty("--reveal-border-right-type","line"),e.style.setProperty("--reveal-border-top-type","line"),e.style.setProperty("--reveal-border-bottom-type","line"),e.style.setProperty("--reveal-hover-light","true"),e.style.setProperty("--reveal-hover-light-color",D),e.style.setProperty("--reveal-hover-light-fill-radius","1.5"),e.style.setProperty("--reveal-hover-light-fill-radius-mode","relative"),e.style.setProperty("--reveal-diffuse","true"),e.style.setProperty("--reveal-press-animation","true"),e.style.setProperty("--reveal-press-animation-radius-mode","cover"),e.style.setProperty("--reveal-press-animation-color",D),e.style.setProperty("--reveal-press-animation-speed","2000"),e.style.setProperty("--reveal-release-animation-accelerate-rate","6"),l()}else console.warn("Your browser do NOT support `CSS.registerProperty` method, registration failed!"),console.warn("If you are the developer, try using `register(true)` to support old browsers.")}let c="strictEdge",s=!1;class u extends Error{constructor(){super("Border detection mode has already been initialized."),this.name="InitializedError"}}const h={compat:!1,get borderDetectionMode(){return c},set borderDetectionMode(e){if(s)throw new u;c=e,s=!0}};class p{constructor(e){if(!p.colorParser){const e=document.createElement("div");e.style.setProperty("display","none","important"),document.body.appendChild(e),p.colorParser=e,p.colorParserStyle=window.getComputedStyle(e)}this.el=e,this.style=window.getComputedStyle(e)}size(){return this.style.length}get(e){return this.style.getPropertyValue(e).trim()}getColor(e){const t=this.get(e);let r=p.colorCache.get(t);return void 0===r&&(p.colorParser.style.color=t,r=p.colorParserStyle.color||"rgb(0, 0, 0)",p.colorCache.set(t,r)),r}getNumber(e){// Length values in computed style will always in the unit of px
2
2
  // Maybe NaN
3
- return parseFloat(this.get(e))}}class h{constructor(e){this.el=e,this.style=e.computedStyleMap()}size(){return this.style.size}get(e){return this.style.get(e).toString()}getColor(e){return this.get(e)}getNumber(e){const t=this.style.get(e).value;return"number"==typeof t?t:parseFloat(t);// Maybe NaN
4
- }}const y=e=>{if(""===e)return"";if("#"===e[0]){// Thanks bro:
3
+ return parseFloat(this.get(e))}}// Parsing a color forces a style recalc, so cache the result by the raw value
4
+ p.colorCache=new Map;class m{constructor(e){this.el=e,this.style=e.computedStyleMap()}size(){return this.style.size}get(e){return this.style.get(e).toString()}getColor(e){return this.get(e)}getNumber(e){const t=this.style.get(e).value;return"number"==typeof t?t:parseFloat(t);// Maybe NaN
5
+ }}// Firefox supports `CSS.registerProperty` but not `computedStyleMap`
6
+ const y="undefined"!=typeof Element&&"computedStyleMap"in Element.prototype,g=e=>{if(""===e)return"";if("#"===e[0]){// Thanks bro:
5
7
  // https://stackoverflow.com/a/11508164/3931936
6
- const i=parseInt(e.substring(1),16);var t=255&i>>16,r=255&i>>8,a=255&i;return t+","+r+","+a}else{let t="",r=!1,a=0;for(let o=0;o<e.length;o++){const i=e[o],n=i.charCodeAt(0)-48;if(" "!==i){if(r&&!(0<=n&&10>n)&&","!==i&&")"!==i)throw new SyntaxError(`${e} is not a validate color value!`);if(!r&&"("===i){r=!0;continue}if(2>a&&")"===i)throw new SyntaxError(`${e} should have at least three color channel`);if(","===i&&a++,")"===i)return t;r&&(t+=i)}}return t}},v=e=>"round"===e||"bevel"===e||"miter"===e;class g{constructor(e,t,o){/**
8
+ const a=parseInt(e.substring(1),16);var t=255&a>>16,r=255&a>>8,i=255&a;return t+","+r+","+i}else{let t="",r=!1,i=0;for(let a=0;a<e.length;a++){const o=e[a],n=o.charCodeAt(0)-48;if(" "!==o){if(r&&!(0<=n&&10>n)&&","!==o&&")"!==o)throw new SyntaxError(`${e} is not a validate color value!`);if(!r&&"("===o){r=!0;continue}if(2>i&&")"===o)throw new SyntaxError(`${e} should have at least three color channel`);if(","===o&&i++,")"===o)return t;r&&(t+=o)}}return t}},v=e=>"round"===e||"bevel"===e||"miter"===e;class f{constructor(e,t,o){/**
9
+ * Bumped whenever `cacheCanvasPaintingStyle` sees any value change, so
10
+ * painters can tell whether the last painted frame is still valid.
11
+ */ /**
7
12
  * If is cleaned up by `RevealBoundaryStore` during animation
8
13
  * duration checkup.
9
- */this.pxRatio=window.devicePixelRatio||1,this.paintedWidth=0,this.paintedHeight=0,this.currentFrameId=-1,this.cachedBoundingRectFrameId=-2,this.cachedBoundingRect={top:-1,left:-1,width:-1,height:-1},this.cachedStyleFrameId=-2,this.cachedStyle={trueFillRadius:[0,0],color:"",opacity:1,borderColor:"",borderFillRadius:0,borderDecorationType:"miter",borderDecorationRadius:0,topLeftBorderDecorationRadius:0,topRightBorderDecorationRadius:0,bottomLeftBorderDecorationRadius:0,bottomRightBorderDecorationRadius:0,withLeftBorderFactor:1,withRightBorderFactor:1,withTopBorderFactor:1,withBottomBorderFactor:1,borderWidth:1,hoverLight:!0,hoverLightColor:"",hoverLightFillMode:"",hoverLightFillRadius:0,diffuse:!0,pressAnimation:!0,pressAnimationFillMode:"",pressAnimationColor:"",pressAnimationSpeed:0,releaseAnimationAccelerateRate:0},this.dirty=!1,this.shapeDirty=!0,this.fillDirty=!0,this.animationDirty=!0,this.cleanedUpForAnimation=!1,this.mouseUpClientX=null,this.mouseUpClientY=null,this.mouseDownAnimateStartFrame=null,this.mouseDownAnimateCurrentFrame=null,this.mouseDownAnimateReleasedFrame=null,this.mouseDownAnimateLogicFrame=null,this.mousePressed=!1,this.mouseReleased=!1,this.cacheBoundingRect=()=>{if(this.currentFrameId!==this.cachedBoundingRectFrameId){const e=this.container.getBoundingClientRect();this.cachedBoundingRect.top=a(e.top),this.cachedBoundingRect.left=a(e.left),this.cachedBoundingRect.width=a(e.width),this.cachedBoundingRect.height=a(e.height),this.cachedBoundingRectFrameId=this.currentFrameId}},this.getTrueFillRadius=(e=[0,0],t=this.computedStyle.get("--reveal-hover-light-fill-radius-mode")||"relative")=>{const a=this.cachedBoundingRect;switch(t){case"relative":e[0]=Math.min(a.width,a.height),e[1]=r(a.width,a.height);break;case"absolute":e[0]=-1,e[1]=-1;break;default:throw new SyntaxError("The value of `--reveal-hover-light-fill-radius-mode` must be `relative`, `absolute`, but got `"+t+"`!");}return e},this.getPropFromMultipleSource=(e,t)=>{const r=this.container.dataset[e];return r?r:this.computedStyle.get(t)},this.getNumberPropFromMultipleSource=(e,t)=>{var r=Number.parseFloat;const a=this.container.dataset[e];return a?r(a):this.computedStyle.getNumber(t)},this.cacheCanvasPaintingStyle=()=>{if(this.currentFrameId===this.cachedStyleFrameId)return;if(0===this.computedStyle.size())return;const e=y(this.computedStyle.getColor("--reveal-color"))||"0, 0, 0",t=y(this.computedStyle.getColor("--reveal-border-color"))||e,a=y(this.computedStyle.getColor("--reveal-hover-light-color"))||e,i=y(this.computedStyle.getColor("--reveal-press-animation-color"))||e,o=e,n=this.computedStyle.getNumber("--reveal-opacity"),l=t,d=this.computedStyle.getNumber("--reveal-border-fill-radius"),s=this.computedStyle.get("--reveal-border-decoration-type")||"miter",u=this.computedStyle.getNumber("--reveal-border-width"),p="line"===this.getPropFromMultipleSource("leftBorder","--reveal-border-left-type")?1:0,m="line"===this.getPropFromMultipleSource("rightBorder","--reveal-border-right-type")?1:0,h="line"===this.getPropFromMultipleSource("topBorder","--reveal-border-top-type")?1:0,g="line"===this.getPropFromMultipleSource("bottomBorder","--reveal-border-bottom-type")?1:0,R="true"===this.computedStyle.get("--reveal-hover-light"),f=a,S=this.computedStyle.getNumber("--reveal-hover-light-fill-radius"),b=this.computedStyle.get("--reveal-hover-light-fill-radius-mode")||"relative",x="true"===this.computedStyle.get("--reveal-diffuse"),F="true"===this.computedStyle.get("--reveal-press-animation"),P=this.computedStyle.get("--reveal-press-animation-radius-mode"),C=i,w=this.computedStyle.getNumber("--reveal-press-animation-speed"),D=this.computedStyle.getNumber("--reveal-release-animation-accelerate-rate"),B=this.computedStyle.getNumber("--reveal-border-decoration-radius"),r=this.getNumberPropFromMultipleSource("topLeftBorderRadius","--reveal-border-decoration-top-left-radius"),A=this.getNumberPropFromMultipleSource("topRightBorderRadius","--reveal-border-decoration-top-right-radius"),T=this.getNumberPropFromMultipleSource("bottomLeftBorderRadius","--reveal-border-decoration-bottom-left-radius"),L=this.getNumberPropFromMultipleSource("bottomRightBorderRadius","--reveal-border-decoration-bottom-right-radius"),I=0<=r?r:B,E=0<=A?A:B,M=0<=T?T:B,V=0<=L?L:B,N=this.cachedStyle;if(this.fillDirty=this.fillDirty||N.color!==o,this.fillDirty=this.fillDirty||N.opacity!==n,this.fillDirty=this.fillDirty||N.borderColor!==l,this.fillDirty=this.fillDirty||N.borderFillRadius!==d,this.fillDirty=this.fillDirty||N.hoverLightColor!==f,this.fillDirty=this.fillDirty||N.hoverLightFillRadius!==S,this.fillDirty=this.fillDirty||N.hoverLightFillMode!==b,this.shapeDirty=this.shapeDirty||N.borderDecorationType!==s,this.shapeDirty=this.shapeDirty||N.borderWidth!==u,this.shapeDirty=this.shapeDirty||N.withLeftBorderFactor!==p,this.shapeDirty=this.shapeDirty||N.withRightBorderFactor!==m,this.shapeDirty=this.shapeDirty||N.withTopBorderFactor!==h,this.shapeDirty=this.shapeDirty||N.withBottomBorderFactor!==g,this.shapeDirty=this.shapeDirty||N.topLeftBorderDecorationRadius!==I,this.shapeDirty=this.shapeDirty||N.topRightBorderDecorationRadius!==E,this.shapeDirty=this.shapeDirty||N.bottomLeftBorderDecorationRadius!==M,this.shapeDirty=this.shapeDirty||N.bottomRightBorderDecorationRadius!==V,this.animationDirty=this.animationDirty||N.pressAnimation!==F,this.animationDirty=this.animationDirty||N.pressAnimationFillMode!==P,this.animationDirty=this.animationDirty||N.pressAnimationColor!==C,this.animationDirty=this.animationDirty||N.pressAnimationSpeed!==w,this.animationDirty=this.animationDirty||N.releaseAnimationAccelerateRate!==D,N.color=o,N.opacity=n,N.borderColor=l,N.borderFillRadius=d,N.borderDecorationType=s,N.borderWidth=u,N.withLeftBorderFactor=p,N.withRightBorderFactor=m,N.withTopBorderFactor=h,N.withBottomBorderFactor=g,N.hoverLight=R,N.hoverLightColor=f,N.hoverLightFillRadius=S,N.hoverLightFillMode=b,N.diffuse=x,N.pressAnimation=F,N.pressAnimationFillMode=P,N.pressAnimationColor=C,N.pressAnimationSpeed=w,N.releaseAnimationAccelerateRate=D,N.topLeftBorderDecorationRadius=I,N.topRightBorderDecorationRadius=E,N.bottomLeftBorderDecorationRadius=M,N.bottomRightBorderDecorationRadius=V,this.getTrueFillRadius(N.trueFillRadius,N.hoverLightFillMode),!v(N.borderDecorationType))throw new SyntaxError("The value of `--reveal-border-decoration-type` must be `round`, `bevel` or `miter`!");this.cachedStyleFrameId=this.currentFrameId},this.mouseInCanvas=()=>{const e=this.cachedBoundingRect,t=this._store.clientX-e.left,r=this._store.clientY-e.top;return 0<t&&0<r&&t<e.width&&r<e.height},this.syncSizeToRevealRadius=(e,t)=>{const{trueFillRadius:r}=this.cachedStyle,a=r[1]||1,i=2*a*this.pxRatio*t;(e.width!==i||e.height!==i)&&(e.width=i,e.height=i)},this._store=e,this.container=o,this.element=t,this.computedStyle=i(o)}}const R=()=>document.createElement("canvas");class f extends g{constructor(e,i,o){super(e,i,o),this.updateCachedReveal=()=>{if(!this.fillDirty)return;const e=this.cachedStyle,t=e.trueFillRadius[1]*this.pxRatio,r=this.cachedImg.cachedReveal,{borderReveal:a,fillReveal:o}=this.cachedImg.cachedCanvas,{borderReveal:n,fillReveal:l}=this.cachedImg.cachedCtx;this._store.updateMaxRadius(e.trueFillRadius[1]*e.borderFillRadius);for(let d=0;2>d;d++){// 0 means border, 1 means hover light.
14
+ */this.pxRatio=window.devicePixelRatio||1,this.paintedWidth=0,this.paintedHeight=0,this.currentFrameId=-1,this.cachedBoundingRectFrameId=-2,this.cachedBoundingRect={top:-1,left:-1,width:-1,height:-1},this.cachedStyleFrameId=-2,this.cachedStyle={trueFillRadius:[0,0],color:"",opacity:1,borderColor:"",borderFillRadius:0,borderDecorationType:"miter",borderDecorationRadius:0,topLeftBorderDecorationRadius:0,topRightBorderDecorationRadius:0,bottomLeftBorderDecorationRadius:0,bottomRightBorderDecorationRadius:0,withLeftBorderFactor:1,withRightBorderFactor:1,withTopBorderFactor:1,withBottomBorderFactor:1,borderWidth:1,hoverLight:!0,hoverLightColor:"",hoverLightFillMode:"",hoverLightFillRadius:0,diffuse:!0,pressAnimation:!0,pressAnimationFillMode:"",pressAnimationColor:"",pressAnimationSpeed:0,releaseAnimationAccelerateRate:0},this.dirty=!1,this.styleVersion=0,this.shapeDirty=!0,this.fillDirty=!0,this.animationDirty=!0,this.cleanedUpForAnimation=!1,this.mouseUpClientX=null,this.mouseUpClientY=null,this.mouseDownAnimateStartFrame=null,this.mouseDownAnimateCurrentFrame=null,this.mouseDownAnimateReleasedFrame=null,this.mouseDownAnimateLogicFrame=null,this.mousePressed=!1,this.mouseReleased=!1,this.cacheBoundingRect=()=>{if(this.currentFrameId!==this.cachedBoundingRectFrameId){const e=this.container.getBoundingClientRect();this.cachedBoundingRect.top=i(e.top),this.cachedBoundingRect.left=i(e.left),this.cachedBoundingRect.width=i(e.width),this.cachedBoundingRect.height=i(e.height),this.cachedBoundingRectFrameId=this.currentFrameId}},this.getTrueFillRadius=(e=[0,0],t=this.computedStyle.get("--reveal-hover-light-fill-radius-mode")||"relative")=>{const i=this.cachedBoundingRect;switch(t){case"relative":e[0]=Math.min(i.width,i.height),e[1]=r(i.width,i.height);break;case"absolute":e[0]=-1,e[1]=-1;break;default:throw new SyntaxError("The value of `--reveal-hover-light-fill-radius-mode` must be `relative`, `absolute`, but got `"+t+"`!");}return e},this.getPropFromMultipleSource=(e,t)=>{const r=this.container.dataset[e];return r?r:this.computedStyle.get(t)},this.getNumberPropFromMultipleSource=(e,t)=>{var r=Number.parseFloat;const i=this.container.dataset[e];return i?r(i):this.computedStyle.getNumber(t)},this.cacheCanvasPaintingStyle=()=>{if(this.currentFrameId===this.cachedStyleFrameId)return;if(0===this.computedStyle.size())return;const e=g(this.computedStyle.getColor("--reveal-color"))||"0, 0, 0",t=g(this.computedStyle.getColor("--reveal-border-color"))||e,i=g(this.computedStyle.getColor("--reveal-hover-light-color"))||e,a=g(this.computedStyle.getColor("--reveal-press-animation-color"))||e,o=e,n=this.computedStyle.getNumber("--reveal-opacity"),l=t,d=this.computedStyle.getNumber("--reveal-border-fill-radius"),s=this.computedStyle.get("--reveal-border-decoration-type")||"miter",u=this.computedStyle.getNumber("--reveal-border-width"),h="line"===this.getPropFromMultipleSource("leftBorder","--reveal-border-left-type")?1:0,p="line"===this.getPropFromMultipleSource("rightBorder","--reveal-border-right-type")?1:0,m="line"===this.getPropFromMultipleSource("topBorder","--reveal-border-top-type")?1:0,y="line"===this.getPropFromMultipleSource("bottomBorder","--reveal-border-bottom-type")?1:0,f="true"===this.computedStyle.get("--reveal-hover-light"),R=i,S=this.computedStyle.getNumber("--reveal-hover-light-fill-radius"),b=this.computedStyle.get("--reveal-hover-light-fill-radius-mode")||"relative",F="true"===this.computedStyle.get("--reveal-diffuse"),P="true"===this.computedStyle.get("--reveal-press-animation"),x=this.computedStyle.get("--reveal-press-animation-radius-mode"),w=a,C=this.computedStyle.getNumber("--reveal-press-animation-speed"),B=this.computedStyle.getNumber("--reveal-release-animation-accelerate-rate"),D=this.computedStyle.getNumber("--reveal-border-decoration-radius"),r=this.getNumberPropFromMultipleSource("topLeftBorderRadius","--reveal-border-decoration-top-left-radius"),A=this.getNumberPropFromMultipleSource("topRightBorderRadius","--reveal-border-decoration-top-right-radius"),L=this.getNumberPropFromMultipleSource("bottomLeftBorderRadius","--reveal-border-decoration-bottom-left-radius"),T=this.getNumberPropFromMultipleSource("bottomRightBorderRadius","--reveal-border-decoration-bottom-right-radius"),I=0<=r?r:D,E=0<=A?A:D,M=0<=L?L:D,V=0<=T?T:D,N=this.cachedStyle,c=N.color!==o||N.opacity!==n||N.borderColor!==l||N.borderFillRadius!==d||N.borderDecorationType!==s||N.borderWidth!==u||N.withLeftBorderFactor!==h||N.withRightBorderFactor!==p||N.withTopBorderFactor!==m||N.withBottomBorderFactor!==y||N.hoverLight!==f||N.hoverLightColor!==R||N.hoverLightFillRadius!==S||N.hoverLightFillMode!==b||N.diffuse!==F||N.pressAnimation!==P||N.pressAnimationFillMode!==x||N.pressAnimationColor!==w||N.pressAnimationSpeed!==C||N.releaseAnimationAccelerateRate!==B||N.topLeftBorderDecorationRadius!==I||N.topRightBorderDecorationRadius!==E||N.bottomLeftBorderDecorationRadius!==M||N.bottomRightBorderDecorationRadius!==V;// Border related configurations
15
+ // Hover light related configurations
16
+ // Press animation related configurations
17
+ // Border decoration related configurations
18
+ if(c&&this.styleVersion++,this.fillDirty=this.fillDirty||N.color!==o,this.fillDirty=this.fillDirty||N.opacity!==n,this.fillDirty=this.fillDirty||N.borderColor!==l,this.fillDirty=this.fillDirty||N.borderFillRadius!==d,this.fillDirty=this.fillDirty||N.hoverLightColor!==R,this.fillDirty=this.fillDirty||N.hoverLightFillRadius!==S,this.fillDirty=this.fillDirty||N.hoverLightFillMode!==b,this.shapeDirty=this.shapeDirty||N.borderDecorationType!==s,this.shapeDirty=this.shapeDirty||N.borderWidth!==u,this.shapeDirty=this.shapeDirty||N.withLeftBorderFactor!==h,this.shapeDirty=this.shapeDirty||N.withRightBorderFactor!==p,this.shapeDirty=this.shapeDirty||N.withTopBorderFactor!==m,this.shapeDirty=this.shapeDirty||N.withBottomBorderFactor!==y,this.shapeDirty=this.shapeDirty||N.topLeftBorderDecorationRadius!==I,this.shapeDirty=this.shapeDirty||N.topRightBorderDecorationRadius!==E,this.shapeDirty=this.shapeDirty||N.bottomLeftBorderDecorationRadius!==M,this.shapeDirty=this.shapeDirty||N.bottomRightBorderDecorationRadius!==V,this.animationDirty=this.animationDirty||N.pressAnimation!==P,this.animationDirty=this.animationDirty||N.pressAnimationFillMode!==x,this.animationDirty=this.animationDirty||N.pressAnimationColor!==w,this.animationDirty=this.animationDirty||N.pressAnimationSpeed!==C,this.animationDirty=this.animationDirty||N.releaseAnimationAccelerateRate!==B,N.color=o,N.opacity=n,N.borderColor=l,N.borderFillRadius=d,N.borderDecorationType=s,N.borderWidth=u,N.withLeftBorderFactor=h,N.withRightBorderFactor=p,N.withTopBorderFactor=m,N.withBottomBorderFactor=y,N.hoverLight=f,N.hoverLightColor=R,N.hoverLightFillRadius=S,N.hoverLightFillMode=b,N.diffuse=F,N.pressAnimation=P,N.pressAnimationFillMode=x,N.pressAnimationColor=w,N.pressAnimationSpeed=C,N.releaseAnimationAccelerateRate=B,N.topLeftBorderDecorationRadius=I,N.topRightBorderDecorationRadius=E,N.bottomLeftBorderDecorationRadius=M,N.bottomRightBorderDecorationRadius=V,this.getTrueFillRadius(N.trueFillRadius,N.hoverLightFillMode),!v(N.borderDecorationType))throw new SyntaxError("The value of `--reveal-border-decoration-type` must be `round`, `bevel` or `miter`!");this.cachedStyleFrameId=this.currentFrameId},this.mouseInCanvas=()=>{const e=this.cachedBoundingRect,t=this._store.clientX-e.left,r=this._store.clientY-e.top;return 0<t&&0<r&&t<e.width&&r<e.height},this._store=e,this.container=o,this.element=t,this.computedStyle=a(o)}}class R extends f{constructor(e,a,o){// Inputs of the last painted frame, a frame with identical inputs is
19
+ // skipped and the canvas keeps its content.
20
+ super(e,a,o),this.updateCachedReveal=()=>{if(!this.fillDirty)return;if(!this.ctx)return;const e=this.cachedStyle,t=e.trueFillRadius[1]*this.pxRatio,r=this.cachedImg.cachedReveal;this._store.updateMaxRadius(e.trueFillRadius[1]*e.borderFillRadius);for(let a=0;2>a;a++){// 0 means border, 1 means hover light.
10
21
  //-----------------------------------------
11
22
  // Last rendered style.
12
- const i=0==d?r.borderReveal:r.fillReveal,s=0==d?e.borderColor:e.hoverLightColor,c=0==d?e.borderFillRadius:e.hoverLightFillRadius,u=s===i.color&&e.opacity===i.opacity&&c===i.radiusFactor;if(u)continue;const p=0==d?a:o,m=0==d?n:l;if(this.syncSizeToRevealRadius(p,c),!m)continue;m.clearRect(0,0,p.width,p.height);const h=0==d?e.opacity:.5*e.opacity,y=t*c,v=m.createRadialGradient(y,y,0,y,y,y);v.addColorStop(0,`rgba(${s}, ${h})`),v.addColorStop(1,`rgba(${s}, 0.0)`);const g=2*t*c;m.fillStyle=v,m.clearRect(0,0,g,g),m.fillRect(0,0,g,g),i.radius=y,i.radiusFactor=c,i.color=s,i.opacity=e.opacity,this.ctx&&(i.pattern=this.ctx.createPattern(p,"no-repeat"))}this.fillDirty=!1},this.updateCachedBitmap=()=>{this.ctx&&this.updateCachedReveal()},this.updateAnimateGrd=(e,t)=>{const{pressAnimationColor:r,opacity:a}=this.cachedStyle,i=a*(.2-e),o=a*(.1-.07*e),n=.1+.8*e,l=0>i?0:i,d=0>o?0:o;let s=0;s=1<n?1:n,s=0>n?0:n,t.addColorStop(0,`rgba(${r},${l})`),t.addColorStop(.55*s,`rgba(${r},${d})`),t.addColorStop(s,`rgba(${r}, 0)`)},this.drawShape=e=>{if(!this.ctx)return;const t=this.cachedBoundingRect,r=t.width*this.pxRatio,a=t.height*this.pxRatio,i=this.cachedStyle,o=i.borderWidth*this.pxRatio,n=i.topLeftBorderDecorationRadius*this.pxRatio,l=i.topRightBorderDecorationRadius*this.pxRatio,d=i.bottomLeftBorderDecorationRadius*this.pxRatio,s=i.bottomRightBorderDecorationRadius*this.pxRatio,c=i.withLeftBorderFactor,u=i.withRightBorderFactor,p=i.withTopBorderFactor,m=i.withBottomBorderFactor,h=o<n?n-o:0,y=o<l?l-o:0,v=o<d?d-o:0,g=o<s?s-o:0;switch(this.ctx.beginPath(),i.borderDecorationType){// Oh... Fuck... It's painful...
13
- case"round":this.ctx.moveTo(n,0),this.ctx.arcTo(r,0,r,a,l),this.ctx.lineTo(r,a-s),this.ctx.arcTo(r,a,s,a,s),this.ctx.lineTo(d,a),this.ctx.arcTo(0,a,0,s,d),this.ctx.lineTo(0,n),this.ctx.arcTo(0,0,n,0,n),e&&(this.ctx.moveTo(h,o*p),this.ctx.arcTo(o*c,o*p,o*c,h+o*p,h),this.ctx.lineTo(o*c,a-o*m-v),this.ctx.arcTo(o*c,a-o*m,o*c+v,a-o*m,v),this.ctx.lineTo(r-o*u-g,a-o*m),this.ctx.arcTo(r-o*u,a-o*m,r-o*u,a-o*m-g,g),this.ctx.lineTo(r-o*u,o*p+y),this.ctx.arcTo(r-o*u,o*p,r-o*u-y,o*p,y),this.ctx.lineTo(h,o*p));break;case"bevel":this.ctx.moveTo(n,0),this.ctx.lineTo(r-l,0),this.ctx.lineTo(r,l),this.ctx.lineTo(r,a-s),this.ctx.lineTo(r-s,a),this.ctx.lineTo(d,a),this.ctx.lineTo(0,a-d),this.ctx.lineTo(0,n),this.ctx.lineTo(n,0),this.ctx.lineTo(r-l,0),e&&(this.ctx.moveTo(h+o*c,o*p),this.ctx.lineTo(o*c,h+o*p),this.ctx.lineTo(o*c,a-v-o*m),this.ctx.lineTo(o*c+v,a-o*m),this.ctx.lineTo(r-g-o*u,a-o*m),this.ctx.lineTo(r-o*u,a-g-o*m),this.ctx.lineTo(r-o*u,y+o*p),this.ctx.lineTo(r-y-o*u,o*p),this.ctx.lineTo(h+o*u,o*p));break;case"miter":this.ctx.moveTo(0,0),this.ctx.lineTo(r,0),this.ctx.lineTo(r,a),this.ctx.lineTo(0,a),this.ctx.lineTo(0,0),e&&(this.ctx.moveTo(o*c,o*p),this.ctx.lineTo(o*c,a-o*m),this.ctx.lineTo(r-o*u,a-o*m),this.ctx.lineTo(r-o*u,o*p),this.ctx.lineTo(o*c,o*p));}this.ctx.closePath()},this.syncSizeToElement=e=>{const t=this.cachedBoundingRect;(e.width!==t.width||e.height!==t.height)&&(e.width=t.width*this.pxRatio,e.height=t.height*this.pxRatio,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)},this.clear=()=>{if(!this.ctx)return!1;if(!this.dirty)return!1;const{width:e,height:t}=this.cachedBoundingRect;return this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,e*window.devicePixelRatio,t*window.devicePixelRatio),this.dirty=!1,!0},this.paint=e=>{const i=this._store,o=i.animationQueue.includes(this),n=i.clientX===i.paintedClientX&&i.clientY===i.paintedClientY;if(n&&!e&&!o)return!1;if(!this.ctx)return!1;if(this.dirty=!0,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.paintedWidth,this.paintedHeight),!i.mouseInBoundary&&!o)return!1;if(!this.cachedImg.cachedReveal)return!1;this.syncSizeToElement(this.element),this.cacheBoundingRect();const l=this.cachedBoundingRect,d=i.clientX-l.left,s=i.clientY-l.top;if(t(d)||t(s))return!1;const u=this.cachedStyle;this.getTrueFillRadius(u.trueFillRadius),this.paintedWidth=l.width*this.pxRatio,this.paintedHeight=l.height*this.pxRatio;const c=u.trueFillRadius[1],p=d-c<l.width,m=s-c<l.height,h=0<d+c&&p&&0<s+c&&m;if(!h&&!o)return!1;if(this.cacheCanvasPaintingStyle(),this.updateCachedBitmap(),i.mouseInBoundary){const e=0<d&&0<s&&d<l.width&&s<l.height,t=this.cachedImg.cachedReveal.fillReveal.pattern;if(u.hoverLight&&e&&t){// draw fill.
14
- const e=this.cachedImg.cachedReveal.fillReveal.radius,r=a(d*this.pxRatio-e),i=a(s*this.pxRatio-e);this.ctx.setTransform(1,0,0,1,0,0),this.drawShape(!1),this.ctx.translate(r,i),this.ctx.fillStyle=t,this.ctx.fill()}const r=u.diffuse&&h||e,i=this.cachedImg.cachedReveal.borderReveal.pattern;if(0!==u.borderWidth&&i&&r){// Draw border.
15
- const e=this.cachedImg.cachedReveal.borderReveal.radius,t=a(d*this.pxRatio-e),r=a(s*this.pxRatio-e);this.ctx.setTransform(1,0,0,1,0,0),this.drawShape(!0),this.ctx.translate(t,r),this.ctx.fillStyle=i,this.ctx.fill()}}if(u.pressAnimation&&this.mousePressed&&this.mouseDownAnimateLogicFrame){this.ctx.setTransform(1,0,0,1,0,0);const e="constrained"===u.pressAnimationFillMode?u.trueFillRadius[1]:r(l.width,l.height),t=this.mouseReleased&&this.mouseUpClientX&&this.mouseUpClientY?this.ctx.createRadialGradient((this.mouseUpClientX-l.left)*this.pxRatio,(this.mouseUpClientY-l.top)*this.pxRatio,0,(this.mouseUpClientX-l.left)*this.pxRatio,(this.mouseUpClientY-l.top)*this.pxRatio,e*this.pxRatio):this.ctx.createRadialGradient(d*this.pxRatio,s*this.pxRatio,0,d*this.pxRatio,s*this.pxRatio,e*this.pxRatio);// prettier-ignore
16
- this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,t),this.drawShape(!1),this.ctx.fillStyle=t,this.ctx.fill()}return!0},this.ctx=i.getContext("2d");const n={borderReveal:R(),fillReveal:R()},l={borderReveal:n.borderReveal.getContext("2d"),fillReveal:n.fillReveal.getContext("2d")};this.cachedImg={cachedReveal:{borderReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null},fillReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null}},cachedCanvas:n,cachedCtx:l}}}class S extends g{constructor(e,a,i){super(e,a,i),this.updateCachedBitmap=()=>{},this.updateCachedReveal=()=>{const e=this.cachedStyle,t=this.cachedImg.cachedGradientStop;t.borderReveal[0].style.stopColor=e.borderColor,t.borderReveal[1].style.stopColor=e.borderColor,t.borderReveal[0].style.stopOpacity=e.opacity.toString(),t.borderReveal[1].style.stopOpacity="0",t.fillReveal[0].style.stopColor=e.hoverLightColor,t.fillReveal[1].style.stopColor=e.hoverLightColor,t.fillReveal[0].style.stopOpacity=(.5*e.opacity).toString(),t.fillReveal[1].style.stopOpacity="0",t.rippleReveal[0].style.stopColor=e.pressAnimationColor,t.rippleReveal[1].style.stopColor=e.pressAnimationColor,t.rippleReveal[2].style.stopColor=e.pressAnimationColor;const r=this.cachedImg.cachedGradient,a=-1===e.trueFillRadius[0];r.borderReveal.r.baseVal.value=a?e.borderFillRadius:e.borderFillRadius*e.trueFillRadius[1],r.fillReveal.r.baseVal.value=a?e.hoverLightFillRadius:e.hoverLightFillRadius*e.trueFillRadius[0],this.fillDirty=!1},this.updateAnimateGrd=(e,t,r,a)=>{const{opacity:i}=this.cachedStyle,o=i*(.2-e),n=i*(.1-.07*e),l=.1+.8*e,d=0>o?0:o,s=0>n?0:n;let c=0;c=1<l?1:l,c=0>l?0:l;const u=this.cachedImg.cachedGradientStop;u.rippleReveal[0].style.stopOpacity=d.toString(),u.rippleReveal[1].style.stopOpacity=s.toString(),u.rippleReveal[2].style.stopOpacity="0",u.rippleReveal[0].offset.baseVal=0,u.rippleReveal[1].offset.baseVal=.55*c,u.rippleReveal[2].offset.baseVal=c;const p=this.cachedImg.cachedGradient;p.rippleReveal.r.baseVal.value=a,p.rippleReveal.cx.baseVal.value=t,p.rippleReveal.cy.baseVal.value=r},this.updateGradientPosition=(e,t)=>{const r=this.cachedImg.cachedGradient;r.borderReveal.cx.baseVal.value=e,r.borderReveal.cy.baseVal.value=t,r.fillReveal.cx.baseVal.value=e,r.fillReveal.cy.baseVal.value=t},this.drawShape=(e,t)=>{const r=this.cachedBoundingRect,a=r.width,i=r.height,o=this.cachedStyle,n=o.borderWidth,l=o.topLeftBorderDecorationRadius,s=o.topRightBorderDecorationRadius,c=o.bottomLeftBorderDecorationRadius,u=o.bottomRightBorderDecorationRadius,p=o.withLeftBorderFactor,m=o.withRightBorderFactor,h=o.withTopBorderFactor,y=o.withBottomBorderFactor,v=o.withLeftBorderFactor?0:1,g=o.withRightBorderFactor?0:1,R=o.withTopBorderFactor?0:1,f=o.withBottomBorderFactor?0:1,S=!o.withTopBorderFactor&&!o.withLeftBorderFactor,b=!o.withTopBorderFactor&&!o.withRightBorderFactor,x=!o.withBottomBorderFactor&&!o.withLeftBorderFactor,F=!o.withBottomBorderFactor&&!o.withRightBorderFactor,P=n<l?l-n:0,C=n<s?s-n:0,w=n<c?c-n:0,D=n<u?u-n:0;let B="";// Step 1: Starting point
17
- switch(B+=e?`M ${l}, 0 `:`M ${n}, ${P+n} `,o.borderDecorationType){// Oh... Fuck again...
18
- case"round":e&&(B+=`
19
- h ${a-l-s}
20
- a ${s}, ${s} 0 0 1 ${s}, ${s}
21
- v ${i-s-u}
23
+ const i=0==a?r.borderReveal:r.fillReveal,o=0==a?e.borderColor:e.hoverLightColor,n=0==a?e.borderFillRadius:e.hoverLightFillRadius,l=t*n,d=o===i.color&&e.opacity===i.opacity&&n===i.radiusFactor&&l===i.radius;if(d)continue;// The gradient is centered at (trueRadius, trueRadius), painting
24
+ // translates it to the pointer. A gradient is used instead of a
25
+ // pre-rendered bitmap, which takes `(4 * radius) ^ 2` pixels per
26
+ // element and is enough to exhaust the memory of mobile browsers.
27
+ const c=0==a?e.opacity:.5*e.opacity,s=this.ctx.createRadialGradient(l,l,0,l,l,l);s.addColorStop(0,`rgba(${o}, ${c})`),s.addColorStop(1,`rgba(${o}, 0.0)`),i.radius=l,i.radiusFactor=n,i.color=o,i.opacity=e.opacity,i.pattern=s}this.fillDirty=!1},this.updateCachedBitmap=()=>{this.ctx&&this.updateCachedReveal()},this.updateAnimateGrd=(e,t)=>{const{pressAnimationColor:r,opacity:i}=this.cachedStyle,a=i*(.2-e),o=i*(.1-.07*e),n=.1+.8*e,l=0>a?0:a,d=0>o?0:o;let c=0;c=1<n?1:n,c=0>n?0:n,t.addColorStop(0,`rgba(${r},${l})`),t.addColorStop(.55*c,`rgba(${r},${d})`),t.addColorStop(c,`rgba(${r}, 0)`)},this.drawShape=e=>{if(!this.ctx)return;const t=this.cachedBoundingRect,r=t.width*this.pxRatio,i=t.height*this.pxRatio,a=this.cachedStyle,o=a.borderWidth*this.pxRatio,n=a.topLeftBorderDecorationRadius*this.pxRatio,l=a.topRightBorderDecorationRadius*this.pxRatio,d=a.bottomLeftBorderDecorationRadius*this.pxRatio,c=a.bottomRightBorderDecorationRadius*this.pxRatio,s=a.withLeftBorderFactor,u=a.withRightBorderFactor,h=a.withTopBorderFactor,p=a.withBottomBorderFactor,m=o<n?n-o:0,y=o<l?l-o:0,g=o<d?d-o:0,v=o<c?c-o:0;switch(this.ctx.beginPath(),a.borderDecorationType){// Oh... Fuck... It's painful...
28
+ case"round":this.ctx.moveTo(n,0),this.ctx.arcTo(r,0,r,i,l),this.ctx.lineTo(r,i-c),this.ctx.arcTo(r,i,c,i,c),this.ctx.lineTo(d,i),this.ctx.arcTo(0,i,0,c,d),this.ctx.lineTo(0,n),this.ctx.arcTo(0,0,n,0,n),e&&(this.ctx.moveTo(m,o*h),this.ctx.arcTo(o*s,o*h,o*s,m+o*h,m),this.ctx.lineTo(o*s,i-o*p-g),this.ctx.arcTo(o*s,i-o*p,o*s+g,i-o*p,g),this.ctx.lineTo(r-o*u-v,i-o*p),this.ctx.arcTo(r-o*u,i-o*p,r-o*u,i-o*p-v,v),this.ctx.lineTo(r-o*u,o*h+y),this.ctx.arcTo(r-o*u,o*h,r-o*u-y,o*h,y),this.ctx.lineTo(m,o*h));break;case"bevel":this.ctx.moveTo(n,0),this.ctx.lineTo(r-l,0),this.ctx.lineTo(r,l),this.ctx.lineTo(r,i-c),this.ctx.lineTo(r-c,i),this.ctx.lineTo(d,i),this.ctx.lineTo(0,i-d),this.ctx.lineTo(0,n),this.ctx.lineTo(n,0),this.ctx.lineTo(r-l,0),e&&(this.ctx.moveTo(m+o*s,o*h),this.ctx.lineTo(o*s,m+o*h),this.ctx.lineTo(o*s,i-g-o*p),this.ctx.lineTo(o*s+g,i-o*p),this.ctx.lineTo(r-v-o*u,i-o*p),this.ctx.lineTo(r-o*u,i-v-o*p),this.ctx.lineTo(r-o*u,y+o*h),this.ctx.lineTo(r-y-o*u,o*h),this.ctx.lineTo(m+o*u,o*h));break;case"miter":this.ctx.moveTo(0,0),this.ctx.lineTo(r,0),this.ctx.lineTo(r,i),this.ctx.lineTo(0,i),this.ctx.lineTo(0,0),e&&(this.ctx.moveTo(o*s,o*h),this.ctx.lineTo(o*s,i-o*p),this.ctx.lineTo(r-o*u,i-o*p),this.ctx.lineTo(r-o*u,o*h),this.ctx.lineTo(o*s,o*h));}this.ctx.closePath()},this.syncSizeToElement=e=>{const t=this.cachedBoundingRect,r=i(t.width*this.pxRatio),a=i(t.height*this.pxRatio);// Compare against the backing store size; assigning `width` or
29
+ // `height` resets the bitmap even when the value is unchanged.
30
+ (e.width!==r||e.height!==a)&&(e.width=r,e.height=a,e.style.width=`${t.width}px`,e.style.height=`${t.height}px`)},this.paintedRelativeX=NaN,this.paintedRelativeY=NaN,this.paintedRectWidth=-1,this.paintedRectHeight=-1,this.paintedStyleVersion=-1,this.paintedAnimation=!1,this.clear=()=>{if(!this.ctx)return!1;if(!this.dirty)return!1;const{width:e,height:t}=this.cachedBoundingRect;return this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,e*window.devicePixelRatio,t*window.devicePixelRatio),this.dirty=!1,!0},this.paint=()=>{const e=this._store;if(!this.ctx)return!1;const a=e.animationQueue.includes(this);if(!e.mouseInBoundary&&!a)return this.clear(),!1;if(!this.cachedImg.cachedReveal)return!1;// Read layout before any write to the canvas, so the read never
31
+ // forces a synchronous layout.
32
+ this.cacheBoundingRect();const o=this.cachedBoundingRect,n=e.clientX-o.left,l=e.clientY-o.top;if(t(n)||t(l))return!1;const d=this.cachedStyle;this.getTrueFillRadius(d.trueFillRadius);const c=d.trueFillRadius[1],s=n-c<o.width,u=l-c<o.height,h=0<n+c&&s&&0<l+c&&u;if(!h&&!a)return this.clear(),!1;this.cacheCanvasPaintingStyle();const p=this.dirty&&!a&&!this.paintedAnimation&&n===this.paintedRelativeX&&l===this.paintedRelativeY&&o.width===this.paintedRectWidth&&o.height===this.paintedRectHeight&&this.styleVersion===this.paintedStyleVersion;if(p)return!1;if(this.syncSizeToElement(this.element),this.updateCachedBitmap(),this.dirty=!0,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.paintedWidth,this.paintedHeight),this.paintedWidth=o.width*this.pxRatio,this.paintedHeight=o.height*this.pxRatio,this.paintedRelativeX=n,this.paintedRelativeY=l,this.paintedRectWidth=o.width,this.paintedRectHeight=o.height,this.paintedStyleVersion=this.styleVersion,this.paintedAnimation=a,e.mouseInBoundary){const e=0<n&&0<l&&n<o.width&&l<o.height,t=this.cachedImg.cachedReveal.fillReveal.pattern;if(d.hoverLight&&e&&t){// draw fill.
33
+ const e=this.cachedImg.cachedReveal.fillReveal.radius,r=i(n*this.pxRatio-e),a=i(l*this.pxRatio-e);this.ctx.setTransform(1,0,0,1,0,0),this.drawShape(!1),this.ctx.translate(r,a),this.ctx.fillStyle=t,this.ctx.fill()}const r=d.diffuse&&h||e,a=this.cachedImg.cachedReveal.borderReveal.pattern;if(0!==d.borderWidth&&a&&r){// Draw border.
34
+ const e=this.cachedImg.cachedReveal.borderReveal.radius,t=i(n*this.pxRatio-e),r=i(l*this.pxRatio-e);this.ctx.setTransform(1,0,0,1,0,0),this.drawShape(!0),this.ctx.translate(t,r),this.ctx.fillStyle=a,this.ctx.fill()}}if(d.pressAnimation&&this.mousePressed&&this.mouseDownAnimateLogicFrame){this.ctx.setTransform(1,0,0,1,0,0);const e="constrained"===d.pressAnimationFillMode?d.trueFillRadius[1]:r(o.width,o.height),t=this.mouseReleased&&this.mouseUpClientX&&this.mouseUpClientY?this.ctx.createRadialGradient((this.mouseUpClientX-o.left)*this.pxRatio,(this.mouseUpClientY-o.top)*this.pxRatio,0,(this.mouseUpClientX-o.left)*this.pxRatio,(this.mouseUpClientY-o.top)*this.pxRatio,e*this.pxRatio):this.ctx.createRadialGradient(n*this.pxRatio,l*this.pxRatio,0,n*this.pxRatio,l*this.pxRatio,e*this.pxRatio);// prettier-ignore
35
+ this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,t),this.drawShape(!1),this.ctx.fillStyle=t,this.ctx.fill()}return!0},this.ctx=a.getContext("2d"),this.cachedImg={cachedReveal:{borderReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null},fillReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null}}}}}class S extends f{constructor(e,i,a){super(e,i,a),this.updateCachedBitmap=()=>{},this.updateCachedReveal=()=>{const e=this.cachedStyle,t=this.cachedImg.cachedGradientStop;t.borderReveal[0].style.stopColor=e.borderColor,t.borderReveal[1].style.stopColor=e.borderColor,t.borderReveal[0].style.stopOpacity=e.opacity.toString(),t.borderReveal[1].style.stopOpacity="0",t.fillReveal[0].style.stopColor=e.hoverLightColor,t.fillReveal[1].style.stopColor=e.hoverLightColor,t.fillReveal[0].style.stopOpacity=(.5*e.opacity).toString(),t.fillReveal[1].style.stopOpacity="0",t.rippleReveal[0].style.stopColor=e.pressAnimationColor,t.rippleReveal[1].style.stopColor=e.pressAnimationColor,t.rippleReveal[2].style.stopColor=e.pressAnimationColor;const r=this.cachedImg.cachedGradient,i=-1===e.trueFillRadius[0];r.borderReveal.r.baseVal.value=i?e.borderFillRadius:e.borderFillRadius*e.trueFillRadius[1],r.fillReveal.r.baseVal.value=i?e.hoverLightFillRadius:e.hoverLightFillRadius*e.trueFillRadius[0],this.fillDirty=!1},this.updateAnimateGrd=(e,t,r,i)=>{const{opacity:a}=this.cachedStyle,o=a*(.2-e),n=a*(.1-.07*e),l=.1+.8*e,d=0>o?0:o,c=0>n?0:n;let s=0;s=1<l?1:l,s=0>l?0:l;const u=this.cachedImg.cachedGradientStop;u.rippleReveal[0].style.stopOpacity=d.toString(),u.rippleReveal[1].style.stopOpacity=c.toString(),u.rippleReveal[2].style.stopOpacity="0",u.rippleReveal[0].offset.baseVal=0,u.rippleReveal[1].offset.baseVal=.55*s,u.rippleReveal[2].offset.baseVal=s;const h=this.cachedImg.cachedGradient;h.rippleReveal.r.baseVal.value=i,h.rippleReveal.cx.baseVal.value=t,h.rippleReveal.cy.baseVal.value=r},this.updateGradientPosition=(e,t)=>{const r=this.cachedImg.cachedGradient;r.borderReveal.cx.baseVal.value=e,r.borderReveal.cy.baseVal.value=t,r.fillReveal.cx.baseVal.value=e,r.fillReveal.cy.baseVal.value=t},this.drawShape=(e,t)=>{const r=this.cachedBoundingRect,i=r.width,a=r.height,o=this.cachedStyle,n=o.borderWidth,l=o.topLeftBorderDecorationRadius,c=o.topRightBorderDecorationRadius,s=o.bottomLeftBorderDecorationRadius,u=o.bottomRightBorderDecorationRadius,h=o.withLeftBorderFactor,p=o.withRightBorderFactor,m=o.withTopBorderFactor,y=o.withBottomBorderFactor,g=o.withLeftBorderFactor?0:1,v=o.withRightBorderFactor?0:1,f=o.withTopBorderFactor?0:1,R=o.withBottomBorderFactor?0:1,S=!o.withTopBorderFactor&&!o.withLeftBorderFactor,b=!o.withTopBorderFactor&&!o.withRightBorderFactor,F=!o.withBottomBorderFactor&&!o.withLeftBorderFactor,P=!o.withBottomBorderFactor&&!o.withRightBorderFactor,x=n<l?l-n:0,w=n<c?c-n:0,C=n<s?s-n:0,B=n<u?u-n:0;let D="";// Step 1: Starting point
36
+ switch(D+=e?`M ${l}, 0 `:`M ${n}, ${x+n} `,o.borderDecorationType){// Oh... Fuck again...
37
+ case"round":e&&(D+=`
38
+ h ${i-l-c}
39
+ a ${c}, ${c} 0 0 1 ${c}, ${c}
40
+ v ${a-c-u}
22
41
  a ${u}, ${u} 0 0 1 ${-u}, ${u}
23
- h ${-a+c+u}
24
- a ${c}, ${c} 0 0 1 ${-c}, ${-c}
25
- v ${-i+s+u}
42
+ h ${-i+s+u}
43
+ a ${s}, ${s} 0 0 1 ${-s}, ${-s}
44
+ v ${-a+c+u}
26
45
  a ${l}, ${l} 0 0 1 ${l}, ${-l}
27
46
  Z
28
- `),B+=`
29
- M ${n*p}, ${P+n}
30
- v ${i-P-w-2*n+f*n}
31
- a ${w}, ${w} 0 0 0 ${w}, ${w}
32
- h ${a-w-D-2*n+v*n+g*n}
33
- a ${D}, ${D} 0 0 0 ${D}, ${-D}
34
- v ${-i+C+D+2*n-R*n-f*n}
35
- a ${C}, ${C} 0 0 0 ${-C}, ${-C}
36
- h ${-a+w+D+2*n-v*n-g*n}
37
- a ${P}, ${P} 0 0 0 ${-P}, ${P}
38
- L ${n*p}, ${P+n}
39
- `;break;case"bevel":e&&(B+=`
40
- h ${a-l-s}
41
- l ${s} ${s}
42
- v ${i-s-u}
47
+ `),D+=`
48
+ M ${n*h}, ${x+n}
49
+ v ${a-x-C-2*n+R*n}
50
+ a ${C}, ${C} 0 0 0 ${C}, ${C}
51
+ h ${i-C-B-2*n+g*n+v*n}
52
+ a ${B}, ${B} 0 0 0 ${B}, ${-B}
53
+ v ${-a+w+B+2*n-f*n-R*n}
54
+ a ${w}, ${w} 0 0 0 ${-w}, ${-w}
55
+ h ${-i+C+B+2*n-g*n-v*n}
56
+ a ${x}, ${x} 0 0 0 ${-x}, ${x}
57
+ L ${n*h}, ${x+n}
58
+ `;break;case"bevel":e&&(D+=`
59
+ h ${i-l-c}
60
+ l ${c} ${c}
61
+ v ${a-c-u}
43
62
  l ${-u} ${u}
44
- h ${-a+s+u}
45
- l ${-c} ${-c}
46
- v ${-i+s+u}
63
+ h ${-i+c+u}
64
+ l ${-s} ${-s}
65
+ v ${-a+c+u}
47
66
  l ${l} ${-l}
48
67
  Z
49
- `),B+=`
50
- M ${n}, ${P+n}
51
- ${v?`h ${-n}`:""}
52
- v ${i-P-w-2*n}
53
- ${v?`h ${n}`:""}
54
- ${x?`l ${-n} 0`:""}
55
- l ${w} ${w}
56
- ${x?`l ${n} 0`:""}
57
- ${f?`v ${n}`:""}
58
- h ${a-w-D-2*n}
59
- ${f?`v ${-n}`:""}
60
- ${F?`l ${n} 0`:""}
61
- l ${D} ${-D}
62
- ${F?`l ${-n} 0`:""}
63
- ${g?`h ${n}`:""}
64
- v ${-i+P+w+2*n}
68
+ `),D+=`
69
+ M ${n}, ${x+n}
65
70
  ${g?`h ${-n}`:""}
71
+ v ${a-x-C-2*n}
72
+ ${g?`h ${n}`:""}
73
+ ${F?`l ${-n} 0`:""}
74
+ l ${C} ${C}
75
+ ${F?`l ${n} 0`:""}
76
+ ${R?`v ${n}`:""}
77
+ h ${i-C-B-2*n}
78
+ ${R?`v ${-n}`:""}
79
+ ${P?`l ${n} 0`:""}
80
+ l ${B} ${-B}
81
+ ${P?`l ${-n} 0`:""}
82
+ ${v?`h ${n}`:""}
83
+ v ${-a+x+C+2*n}
84
+ ${v?`h ${-n}`:""}
66
85
  ${b?`l 0 ${-n}`:""}
67
- l ${-C} ${-C}
86
+ l ${-w} ${-w}
68
87
  ${b?`l 0 ${n}`:""}
69
- ${R?`v ${-n}`:""}
70
- h ${-a+w+D+2*n}
71
- ${R?`v ${n}`:""}
88
+ ${f?`v ${-n}`:""}
89
+ h ${-i+C+B+2*n}
90
+ ${f?`v ${n}`:""}
72
91
  ${S?`l 0 ${-n}`:""}
73
- l ${-P} ${P}
92
+ l ${-x} ${x}
74
93
  ${S?`l 0 ${n}`:""}
75
- `;break;case"miter":e&&(B+=`
94
+ `;break;case"miter":e&&(D+=`
76
95
  M 0, 0
77
- h ${a}
78
- v ${i}
79
- h ${0-a}
80
- v ${0-i}
96
+ h ${i}
97
+ v ${a}
98
+ h ${0-i}
99
+ v ${0-a}
81
100
  Z
82
- `),B+=`
83
- M ${n*p}, ${n*h}
84
- v ${i-h*n-y*n}
85
- h ${a-p*n-m*n}
86
- v ${-i+h*n+y*n}
87
- h ${-a+p*n+m*n}
101
+ `),D+=`
102
+ M ${n*h}, ${n*m}
103
+ v ${a-m*n-y*n}
104
+ h ${i-h*n-p*n}
105
+ v ${-a+m*n+y*n}
106
+ h ${-i+h*n+p*n}
88
107
  `;}// Step 3: Close the path
89
- B+="miter"===o.borderDecorationType?e?`L ${n}, ${n}`:`z`:e?`L ${P+n}, ${P+n}`:`z`,t.setAttribute("d",B)},this.syncSizeToElement=e=>{const t=this.cachedBoundingRect,r=e.width.baseVal,a=e.height.baseVal;(r.value!==t.width||a.value!==t.height)&&(r.value=t.width,a.value=t.height)},this.clear=e=>{e||this.internalClear()},this.internalClear=()=>{if(!this.dirty)return!1;const e=this.cachedImg.cachedPath;return e.borderReveal.style.fill="transparent",e.fillReveal.style.fill="transparent",e.rippleReveal.style.fill="transparent",this.dirty=!1,!0},this.paint=e=>{const a=this._store,i=a.animationQueue.includes(this),o=a.clientX===a.paintedClientX&&a.clientY===a.paintedClientY;if(o&&!e&&!i)return!1;if(!a.mouseInBoundary&&!i)return this.internalClear(),!1;this.syncSizeToElement(this.element),this.cacheBoundingRect();const n=this.cachedBoundingRect,l=a.clientX-n.left,d=a.clientY-n.top;if(t(l)||t(d))return!1;const s=this.cachedStyle;this.getTrueFillRadius(s.trueFillRadius),this.paintedWidth=n.width,this.paintedHeight=n.height;const c=this.cachedImg.cachedGradient,u=r(c.borderReveal.r.baseVal.value,c.fillReveal.r.baseVal.value);this._store.updateMaxRadius(u),this.cacheCanvasPaintingStyle(),this.fillDirty&&this.updateCachedReveal();const p=l-u<n.width,m=d-u<n.height,h=0<l+u&&p&&0<d+u&&m;if(!h&&!i)return this.internalClear(),!1;if(this.dirty=!0,this.updateGradientPosition(l,d),this.shapeDirty&&(this.drawShape(!0,this.cachedImg.cachedPath.borderReveal),this.drawShape(!1,this.cachedImg.cachedPath.fillReveal),this.drawShape(!1,this.cachedImg.cachedPath.rippleReveal),this.shapeDirty=!1),a.mouseInBoundary){const e=0<l&&0<d&&l<n.width&&d<n.height;s.hoverLight&&e?this.cachedImg.cachedPath.fillReveal.style.fill="url(#fillGrad)":"transparent"!==this.cachedImg.cachedPath.fillReveal.style.fill&&(this.cachedImg.cachedPath.fillReveal.style.fill="transparent");const t=s.diffuse&&h||e;0!==s.borderWidth&&t?this.cachedImg.cachedPath.borderReveal.style.fill="url(#borderGrad)":"transparent"!==this.cachedImg.cachedPath.borderReveal.style.fill&&(this.cachedImg.cachedPath.borderReveal.style.fill="transparent")}if(s.pressAnimation&&this.mousePressed&&this.mouseDownAnimateLogicFrame){const e="constrained"===s.pressAnimationFillMode?s.trueFillRadius[1]:r(n.width,n.height);this.mouseReleased&&this.mouseUpClientX&&this.mouseUpClientY?this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,this.mouseUpClientX-n.left,this.mouseUpClientY-n.top,e):this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,l,d,e),this.cachedImg.cachedPath.rippleReveal.style.fill="url(#rippleGrad)"}else"transparent"!==this.cachedImg.cachedPath.rippleReveal.style.fill&&(this.cachedImg.cachedPath.rippleReveal.style.fill="transparent");return!0},this._store=e;const o={borderReveal:a.querySelector("#borderPath"),fillReveal:a.querySelector("#fillPath"),rippleReveal:a.querySelector("#ripplePath")},n={borderReveal:a.querySelector("#borderGrad"),fillReveal:a.querySelector("#fillGrad"),rippleReveal:a.querySelector("#rippleGrad")},l={borderReveal:[a.querySelector("#borderCenter"),a.querySelector("#borderOut")],fillReveal:[a.querySelector("#fillCenter"),a.querySelector("#fillOut")],rippleReveal:[a.querySelector("#rippleCenter"),a.querySelector("#rippleMiddle"),a.querySelector("#rippleOut")]};this.cachedImg={cachedReveal:{borderReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null},fillReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null}},cachedPath:o,cachedGradient:n,cachedGradientStop:l}}}class b{constructor(e,t){// The current cursor position relative to window.
108
+ D+="miter"===o.borderDecorationType?e?`L ${n}, ${n}`:`z`:e?`L ${x+n}, ${x+n}`:`z`,t.setAttribute("d",D)},this.syncSizeToElement=e=>{const t=this.cachedBoundingRect,r=e.width.baseVal,i=e.height.baseVal;(r.value!==t.width||i.value!==t.height)&&(r.value=t.width,i.value=t.height)},this.clear=e=>{e||this.internalClear()},this.internalClear=()=>{if(!this.dirty)return!1;const e=this.cachedImg.cachedPath;return e.borderReveal.style.fill="transparent",e.fillReveal.style.fill="transparent",e.rippleReveal.style.fill="transparent",this.dirty=!1,!0},this.paint=e=>{const i=this._store,a=i.animationQueue.includes(this),o=i.clientX===i.paintedClientX&&i.clientY===i.paintedClientY;if(o&&!e&&!a)return!1;if(!i.mouseInBoundary&&!a)return this.internalClear(),!1;this.syncSizeToElement(this.element),this.cacheBoundingRect();const n=this.cachedBoundingRect,l=i.clientX-n.left,d=i.clientY-n.top;if(t(l)||t(d))return!1;const s=this.cachedStyle;this.getTrueFillRadius(s.trueFillRadius),this.paintedWidth=n.width,this.paintedHeight=n.height;const c=this.cachedImg.cachedGradient,u=r(c.borderReveal.r.baseVal.value,c.fillReveal.r.baseVal.value);this._store.updateMaxRadius(u),this.cacheCanvasPaintingStyle(),this.fillDirty&&this.updateCachedReveal();const h=l-u<n.width,p=d-u<n.height,m=0<l+u&&h&&0<d+u&&p;if(!m&&!a)return this.internalClear(),!1;if(this.dirty=!0,this.updateGradientPosition(l,d),this.shapeDirty&&(this.drawShape(!0,this.cachedImg.cachedPath.borderReveal),this.drawShape(!1,this.cachedImg.cachedPath.fillReveal),this.drawShape(!1,this.cachedImg.cachedPath.rippleReveal),this.shapeDirty=!1),i.mouseInBoundary){const e=0<l&&0<d&&l<n.width&&d<n.height;s.hoverLight&&e?this.cachedImg.cachedPath.fillReveal.style.fill="url(#fillGrad)":"transparent"!==this.cachedImg.cachedPath.fillReveal.style.fill&&(this.cachedImg.cachedPath.fillReveal.style.fill="transparent");const t=s.diffuse&&m||e;0!==s.borderWidth&&t?this.cachedImg.cachedPath.borderReveal.style.fill="url(#borderGrad)":"transparent"!==this.cachedImg.cachedPath.borderReveal.style.fill&&(this.cachedImg.cachedPath.borderReveal.style.fill="transparent")}if(s.pressAnimation&&this.mousePressed&&this.mouseDownAnimateLogicFrame){const e="constrained"===s.pressAnimationFillMode?s.trueFillRadius[1]:r(n.width,n.height);this.mouseReleased&&this.mouseUpClientX&&this.mouseUpClientY?this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,this.mouseUpClientX-n.left,this.mouseUpClientY-n.top,e):this.updateAnimateGrd(this.mouseDownAnimateLogicFrame,l,d,e),this.cachedImg.cachedPath.rippleReveal.style.fill="url(#rippleGrad)"}else"transparent"!==this.cachedImg.cachedPath.rippleReveal.style.fill&&(this.cachedImg.cachedPath.rippleReveal.style.fill="transparent");return!0},this._store=e;const o={borderReveal:i.querySelector("#borderPath"),fillReveal:i.querySelector("#fillPath"),rippleReveal:i.querySelector("#ripplePath")},n={borderReveal:i.querySelector("#borderGrad"),fillReveal:i.querySelector("#fillGrad"),rippleReveal:i.querySelector("#rippleGrad")},l={borderReveal:[i.querySelector("#borderCenter"),i.querySelector("#borderOut")],fillReveal:[i.querySelector("#fillCenter"),i.querySelector("#fillOut")],rippleReveal:[i.querySelector("#rippleCenter"),i.querySelector("#rippleMiddle"),i.querySelector("#rippleOut")]};this.cachedImg={cachedReveal:{borderReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null},fillReveal:{radiusFactor:-1,radius:-1,color:"INVALID",opacity:0,pattern:null}},cachedPath:o,cachedGradient:n,cachedGradientStop:l}}}class b{constructor(e,t){// The current cursor position relative to window.
90
109
  // The cursor position of painted reveal effect.
110
+ // While the browser scrolls under a finger, the finger stays on the same
111
+ // spot of the content, but touch events are throttled (~200ms in Chromium).
112
+ // The pointer is kept relative to the container and re-derived on every
113
+ // frame, otherwise it stays still on the screen while the content moves.
91
114
  /**
92
115
  * Repaint all canvas while user's pointer has entered the boundary.
93
116
  */ /**
@@ -114,27 +137,33 @@ B+="miter"===o.borderDecorationType?e?`L ${n}, ${n}`:`z`:e?`L ${P+n}, ${P+n}`:`z
114
137
  * @param config The config to be cleaned up.
115
138
  * @param skipPaint Skip painting.
116
139
  * @param forceClean Force clear the painting.
117
- */this.clientX=-1e3,this.clientY=-1e3,this.paintedClientX=-1e3,this.paintedClientY=-1e3,this.mouseInBoundary=!1,this.canvasList=[],this.animationQueue=[],this.animationFrame=null,this.mouseUpClientX=null,this.mouseUpClientY=null,this.mouseDownAnimateStartFrame=null,this.mouseDownAnimateCurrentFrame=null,this.mouseDownAnimateReleasedFrame=null,this.mouseDownAnimateLogicFrame=null,this.mousePressed=!1,this.mouseReleased=!1,this.maxRadius=-1,this.requestedAnimationFrame=!1,this.addReveal=(e,t)=>{let r;const a=Object.prototype.toString.call(e);if("[object HTMLCanvasElement]"===a)r=new f(this,e,t);else if("[object SVGSVGElement]"===a)r=new S(this,e,t);else throw new TypeError(`Unknown element type, got: ${a}, Canvas or SVG element expected.`);r.cacheBoundingRect(),r.cacheCanvasPaintingStyle(),r.updateCachedBitmap(),this.canvasList.push(r)},this.removeReveal=e=>{this.canvasList=this.canvasList.filter(t=>t&&t.element!==e)},this.updateMaxRadius=e=>{this.maxRadius=r(e,this.maxRadius)},this.requestPaintAll=e=>{this.requestedAnimationFrame||(this.requestedAnimationFrame=!0,this.animationFrame=window.requestAnimationFrame(t=>{this.requestedAnimationFrame=!1,this.paintAll(e?-1:t,!0)}))},this.updatePointerPosition=(e,t)=>{this.clientX=e,this.clientY=t;const r=this.container.getBoundingClientRect();let a=!0;e<r.left-this.maxRadius&&(a=!1),e>r.right+this.maxRadius&&(a=!1),t<r.top-this.maxRadius&&(a=!1),t>r.bottom+this.maxRadius&&(a=!1),this.mouseInBoundary=a},this.onPointerMoveOnScreen=(e,t)=>{if(this.updatePointerPosition(e,t),!!this.mouseInBoundary)return this.requestPaintAll(),!0},this.onPointerEnterBoundary=()=>{this.mouseInBoundary=!0,this.animationFrame||this.requestPaintAll()},this.onPointerLeaveBoundary=()=>{this.mouseInBoundary=!1,this.requestPaintAll(!0)},this.paintAll=(e,t)=>{if(t||this.mouseInBoundary||0!==this.animationQueue.length){// Animation duration checkup
140
+ */this.clientX=-1e3,this.clientY=-1e3,this.paintedClientX=-1e3,this.paintedClientY=-1e3,this.mouseInBoundary=!1,this.canvasList=[],this.animationQueue=[],this.animationFrame=null,this.mouseUpClientX=null,this.mouseUpClientY=null,this.mouseDownAnimateStartFrame=null,this.mouseDownAnimateCurrentFrame=null,this.mouseDownAnimateReleasedFrame=null,this.mouseDownAnimateLogicFrame=null,this.mousePressed=!1,this.mouseReleased=!1,this.maxRadius=-1,this.requestedAnimationFrame=!1,this.addReveal=(e,t)=>{let r;const i=Object.prototype.toString.call(e);if("[object HTMLCanvasElement]"===i)r=new R(this,e,t);else if("[object SVGSVGElement]"===i)r=new S(this,e,t);else throw new TypeError(`Unknown element type, got: ${i}, Canvas or SVG element expected.`);r.cacheBoundingRect(),r.cacheCanvasPaintingStyle(),r.updateCachedBitmap(),this.canvasList.push(r)},this.removeReveal=e=>{this.canvasList=this.canvasList.filter(t=>t&&t.element!==e)},this.updateMaxRadius=e=>{this.maxRadius=r(e,this.maxRadius)},this.requestPaintAll=e=>{this.requestedAnimationFrame||(this.requestedAnimationFrame=!0,this.animationFrame=window.requestAnimationFrame(t=>{this.requestedAnimationFrame=!1,this.paintAll(e?-1:t,!0)}))},this.updatePointerPosition=(e,t)=>{this.clientX=e,this.clientY=t;const r=this.container.getBoundingClientRect();let i=!0;e<r.left-this.maxRadius&&(i=!1),e>r.right+this.maxRadius&&(i=!1),t<r.top-this.maxRadius&&(i=!1),t>r.bottom+this.maxRadius&&(i=!1),this.mouseInBoundary=i},this.anchorOffsetX=null,this.anchorOffsetY=null,this.anchorPointer=()=>{const e=this.container.getBoundingClientRect();this.anchorOffsetX=this.clientX-e.left,this.anchorOffsetY=this.clientY-e.top},this.followAnchor=()=>{if(null!==this.anchorOffsetX&&null!==this.anchorOffsetY){const e=this.container.getBoundingClientRect();this.clientX=e.left+this.anchorOffsetX,this.clientY=e.top+this.anchorOffsetY}},this.onPointerMoveOnScreen=(e,t)=>{if(this.updatePointerPosition(e,t),!!this.mouseInBoundary)return this.requestPaintAll(),!0},this.onPointerEnterBoundary=()=>{this.mouseInBoundary=!0,this.animationFrame||this.requestPaintAll()},this.onPointerLeaveBoundary=()=>{this.anchorOffsetX=null,this.anchorOffsetY=null,this.mouseInBoundary=!1,this.requestPaintAll(!0)},this.paintAll=(e,t)=>{if(t||this.mouseInBoundary||0!==this.animationQueue.length){this.followAnchor();// Animation duration checkup
141
+ // Paint the canvas one by one
118
142
  for(let t=0;t<this.animationQueue.length;t++){const r=this.animationQueue[t];if(!e||r.currentFrameId===e)continue;r.currentFrameId=e,null===r.mouseDownAnimateStartFrame&&(r.mouseDownAnimateStartFrame=e);// Calculate how long the animation has been playing
119
- const a=e-r.mouseDownAnimateStartFrame;r.mouseDownAnimateCurrentFrame=a;const i=r.cachedStyle.pressAnimationSpeed,o=r.cachedStyle.releaseAnimationAccelerateRate;// We assume that Ripple is a one-way linear process from
143
+ const i=e-r.mouseDownAnimateStartFrame;r.mouseDownAnimateCurrentFrame=i;const a=r.cachedStyle.pressAnimationSpeed,o=r.cachedStyle.releaseAnimationAccelerateRate;// We assume that Ripple is a one-way linear process from
120
144
  // no diffusion to fully diffused,
121
145
  // and Logic Frame represents the progress of the animation
122
146
  // in this process.
123
- let n=a;r.mouseReleased&&r.mouseDownAnimateReleasedFrame&&(n+=(a-r.mouseDownAnimateReleasedFrame)*o),r.mouseDownAnimateLogicFrame=n/i,1<r.mouseDownAnimateLogicFrame&&(r.cleanedUpForAnimation=!0)}// Paint the canvas one by one
124
- for(let r=0;r<this.canvasList.length;r++){const a=this.canvasList[r];if(a.currentFrameId=e,a.cleanedUpForAnimation)this.cleanUpAnimationUnit(a,!1),a.cleanedUpForAnimation=!1;else{const e=-1===this.animationQueue.indexOf(a);this.mouseInBoundary||e?a.paint(t):a.clear(!1)}}this.paintedClientX=this.clientX,this.paintedClientY=this.clientY,this.mouseInBoundary||0!==this.animationQueue.length?this.requestPaintAll():this.animationFrame=null}},this.clearAll=e=>{this.cleanupAnimation(e,!0)},this.initializeAnimation=()=>{const e=this.canvasList.find(e=>e.mouseInCanvas());e&&(!this.animationQueue.includes(e)&&this.animationQueue.push(e),e.mouseDownAnimateStartFrame=null,e.mousePressed=!0,e.mouseReleased=!1)},this.switchAnimation=()=>{for(let e=0;e<this.animationQueue.length;e++){const t=this.animationQueue[e];t.mouseReleased||(t.mouseReleased=!0,t.mouseDownAnimateReleasedFrame=t.mouseDownAnimateCurrentFrame,t.mouseUpClientX=this.clientX,t.mouseUpClientY=this.clientY)}},this.cleanupAnimation=(e,t)=>{for(let r=0;r<this.animationQueue.length;r++){const a=this.animationQueue[r];this.cleanUpAnimationUnit(a,e,t)}},this.cleanUpAnimationUnit=(e,t,r)=>{e.mouseUpClientX=null,e.mouseUpClientY=null,e.mouseDownAnimateStartFrame=null,e.mouseDownAnimateCurrentFrame=null,e.mouseDownAnimateReleasedFrame=null,e.mouseDownAnimateLogicFrame=null,e.mousePressed=!1,e.mouseReleased=!1;const a=this.animationQueue.indexOf(e);-1<a&&this.animationQueue.splice(a,1),t||(r?e.clear(!1):this.mouseInBoundary?e.paint(!0):e.clear(!0))},this.getRevealAnimationConfig=()=>this.canvasList.find(e=>e.mouseInCanvas())||null,this.id=e,this.container=t}}class x{constructor(){if(this._currentHashId=0,this._storage=[],this.requestedTraverseBoundaries=!1,this.cachedMouseX=-1,this.cachedMouseY=-1,this.pointerLeaveScheduled=!1,this.handlePointerLeave=()=>{this.pointerLeaveScheduled||(this.pointerLeaveScheduled=!0,window.requestAnimationFrame(()=>{for(let e=0;e<this._storage.length;e++)this._storage[e].onPointerLeaveBoundary();this.pointerLeaveScheduled=!1}))},this.handlePointerMove=e=>{this.cachedMouseX=e.clientX,this.cachedMouseY=e.clientY,this.requestedTraverseBoundaries||(window.requestAnimationFrame(this.traverseBoundaries),this.requestedTraverseBoundaries=!0)},this.traverseBoundaries=()=>{this.requestedTraverseBoundaries=!1;for(let e=0;e<this._storage.length;e++)this._storage[e].onPointerMoveOnScreen(this.cachedMouseX,this.cachedMouseY)},this.newBoundary=e=>{const t=this._currentHashId++,r=new b(t,e);return this._storage.push(r),r},this.removeBoundary=e=>{this._storage=this._storage.filter(t=>t!==e)},"experimentalAutoFit"===p.borderDetectionMode){if("undefined"==typeof Window)return;window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerup",e=>{"mouse"!==e.pointerType&&this.handlePointerLeave()}),window.addEventListener("pointerleave",e=>{"mouse"===e.pointerType&&this.handlePointerLeave()}),window.addEventListener("pointercancel",()=>{console.log("pointer cancel"),this.handlePointerLeave()})}}}const F="undefined"==typeof globalThis.Window?class{constructor(){this.root={innerHTML:"",querySelector:()=>null},this.attachShadow=()=>null}}:HTMLElement;class P extends F{constructor(){super(...arguments),this.stateManager=new x}}P.ElementName="ax-reveal-provider";class C extends F{constructor(){/**
147
+ let n=i;r.mouseReleased&&r.mouseDownAnimateReleasedFrame&&(n+=(i-r.mouseDownAnimateReleasedFrame)*o),r.mouseDownAnimateLogicFrame=n/a,1<r.mouseDownAnimateLogicFrame&&(r.cleanedUpForAnimation=!0)}for(let r=0;r<this.canvasList.length;r++){const i=this.canvasList[r];if(i.currentFrameId=e,i.cleanedUpForAnimation)this.cleanUpAnimationUnit(i,!1),i.cleanedUpForAnimation=!1;else{const e=-1===this.animationQueue.indexOf(i);this.mouseInBoundary||e?i.paint(t):i.clear(!1)}}this.paintedClientX=this.clientX,this.paintedClientY=this.clientY,this.mouseInBoundary||0!==this.animationQueue.length?this.requestPaintAll():this.animationFrame=null}},this.clearAll=e=>{this.cleanupAnimation(e,!0)},this.initializeAnimation=()=>{const e=this.canvasList.find(e=>e.mouseInCanvas());e&&(!this.animationQueue.includes(e)&&this.animationQueue.push(e),e.mouseDownAnimateStartFrame=null,e.mousePressed=!0,e.mouseReleased=!1)},this.switchAnimation=()=>{for(let e=0;e<this.animationQueue.length;e++){const t=this.animationQueue[e];t.mouseReleased||(t.mouseReleased=!0,t.mouseDownAnimateReleasedFrame=t.mouseDownAnimateCurrentFrame,t.mouseUpClientX=this.clientX,t.mouseUpClientY=this.clientY)}},this.cleanupAnimation=(e,t)=>{for(let r=0;r<this.animationQueue.length;r++){const i=this.animationQueue[r];this.cleanUpAnimationUnit(i,e,t)}},this.cleanUpAnimationUnit=(e,t,r)=>{e.mouseUpClientX=null,e.mouseUpClientY=null,e.mouseDownAnimateStartFrame=null,e.mouseDownAnimateCurrentFrame=null,e.mouseDownAnimateReleasedFrame=null,e.mouseDownAnimateLogicFrame=null,e.mousePressed=!1,e.mouseReleased=!1;const i=this.animationQueue.indexOf(e);-1<i&&this.animationQueue.splice(i,1),t||(r?e.clear(!1):this.mouseInBoundary?e.paint(!0):e.clear(!0))},this.getRevealAnimationConfig=()=>this.canvasList.find(e=>e.mouseInCanvas())||null,this.id=e,this.container=t}}class F{constructor(){if(this._currentHashId=0,this._storage=[],this.requestedTraverseBoundaries=!1,this.cachedMouseX=-1,this.cachedMouseY=-1,this.touchScrolling=!1,this.pointerLeaveScheduled=!1,this.handlePointerLeave=()=>{this.pointerLeaveScheduled||(this.pointerLeaveScheduled=!0,window.requestAnimationFrame(()=>{for(let e=0;e<this._storage.length;e++)this._storage[e].onPointerLeaveBoundary();this.pointerLeaveScheduled=!1}))},this.handlePointerMove=e=>{this.cachedMouseX=e.clientX,this.cachedMouseY=e.clientY,this.requestedTraverseBoundaries||(window.requestAnimationFrame(this.traverseBoundaries),this.requestedTraverseBoundaries=!0)},this.traverseBoundaries=()=>{this.requestedTraverseBoundaries=!1;for(let e=0;e<this._storage.length;e++)this._storage[e].onPointerMoveOnScreen(this.cachedMouseX,this.cachedMouseY),this.touchScrolling&&this._storage[e].anchorPointer()},this.newBoundary=e=>{const t=this._currentHashId++,r=new b(t,e);return this._storage.push(r),r},this.removeBoundary=e=>{this._storage=this._storage.filter(t=>t!==e)},"experimentalAutoFit"===h.borderDetectionMode){if("undefined"==typeof Window)return;window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerdown",this.handlePointerMove),window.addEventListener("pointerup",e=>{"mouse"!==e.pointerType&&this.handlePointerLeave()}),window.addEventListener("pointerleave",e=>{"mouse"===e.pointerType&&this.handlePointerLeave()}),window.addEventListener("pointercancel",e=>{// The browser took over the touch for scrolling, keep following
148
+ // the finger with touch events until it leaves the screen.
149
+ if("touch"===e.pointerType){this.touchScrolling=!0;for(let e=0;e<this._storage.length;e++)this._storage[e].anchorPointer()}else this.handlePointerLeave()}),window.addEventListener("touchmove",e=>{this.touchScrolling&&e.touches.length&&this.handlePointerMove(e.touches[0])},{passive:!0});const e=e=>{!this.touchScrolling||e.touches.length||(this.touchScrolling=!1,this.handlePointerLeave())};window.addEventListener("touchend",e,{passive:!0}),window.addEventListener("touchcancel",e,{passive:!0})}}}const P="undefined"==typeof globalThis.Window?class{constructor(){this.root={innerHTML:"",querySelector:()=>null},this.attachShadow=()=>null}}:HTMLElement;class x extends P{constructor(){super(...arguments),this.stateManager=new F}}x.ElementName="ax-reveal-provider";class w extends P{constructor(){/**
125
150
  * Update the position of your pointer.
126
- * @param ev Pointer event from the listener.
127
- */super(),this.root=this.attachShadow({mode:"open"}),this.updatePointerPosition=e=>{this.waitForStorage(t=>{t.clientX=e.clientX,t.clientY=e.clientY})},this.handlePointerEnter=()=>this.waitForStorage(e=>e.onPointerEnterBoundary()),this.handlePointerLeave=()=>this.waitForStorage(e=>e.onPointerLeaveBoundary()),this.handlePointerMove=this.updatePointerPosition,this.handlePointerUp=e=>{"mouse"===e.pointerType?this.waitForStorage(e=>e.switchAnimation()):this.waitForStorage(e=>e.clearAll(!1))},this.handlePointerDown=e=>this.waitForStorage(t=>{this.updatePointerPosition(e),t.initializeAnimation()}),this.root.innerHTML=`
151
+ * @param ev Pointer event or touch point from the listener.
152
+ */ // Once the browser starts scrolling, pointer events stop (`pointercancel`)
153
+ // but touch events keep coming, so we follow the finger with them instead.
154
+ // Fired when the browser takes over the touch for scrolling or zooming,
155
+ // `pointerup` will never come, so the pressed ripple must be cleaned here.
156
+ super(),this.root=this.attachShadow({mode:"open"}),this.updatePointerPosition=e=>{this.waitForStorage(t=>{t.clientX=e.clientX,t.clientY=e.clientY})},this.touchScrolling=!1,this.handlePointerEnter=()=>this.waitForStorage(e=>e.onPointerEnterBoundary()),this.handlePointerLeave=()=>{this.touchScrolling||this.waitForStorage(e=>e.onPointerLeaveBoundary())},this.handlePointerMove=this.updatePointerPosition,this.handlePointerUp=e=>{"mouse"===e.pointerType?this.waitForStorage(e=>e.switchAnimation()):this.waitForStorage(e=>e.clearAll(!1))},this.handlePointerCancel=e=>{this.waitForStorage(t=>{"touch"===e.pointerType&&(this.touchScrolling=!0,t.anchorPointer()),t.clearAll(!1)})},this.handleTouchMove=e=>{this.touchScrolling&&e.targetTouches.length&&(this.updatePointerPosition(e.targetTouches[0]),this.waitForStorage(e=>e.anchorPointer()))},this.handleTouchEnd=e=>{!this.touchScrolling||e.targetTouches.length||(this.touchScrolling=!1,this.handlePointerLeave())},this.handlePointerDown=e=>this.waitForStorage(t=>{this.updatePointerPosition(e),t.initializeAnimation()}),this.root.innerHTML=`
128
157
  <div>
129
158
  <slot></slot>
130
- </div>`}get storage(){return this._storage}set storage(e){const t=this._storage;t&&(this.dispatchEvent(new CustomEvent(C.removeStorageEvent,{detail:t})),C.stateManager.removeBoundary(t)),e&&(this._storage=e,this.dispatchEvent(new CustomEvent(C.attachStorageEvent,{detail:e}))),t&&e&&this.dispatchEvent(new CustomEvent(C.replaceStorageEvent,{detail:{old:t,new:e}}))}waitForStorage(e){this.storage===void 0?this.addEventListener(C.attachStorageEvent,()=>e(this.storage),{once:!0}):e(this.storage)}appendStorage(e=!1){if(!e&&this.storage)return;const t=o(this,P.ElementName),r=t?t.stateManager:C.stateManager;this.storage=r.newBoundary(this)}connectedCallback(){this.appendStorage(!0),"strictEdge"===p.borderDetectionMode&&(this.addEventListener("pointerenter",this.handlePointerEnter),this.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointermove",this.handlePointerMove)),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointerup",this.handlePointerUp)}disconnectedCallback(){this.storage=void 0}}C.ElementName="ax-reveal-bound",C.removeStorageEvent="removeStorage",C.attachStorageEvent="attachStorage",C.replaceStorageEvent="replaceStorage",C.stateManager=new x;class w extends F{constructor(){super(),this.root=this.attachShadow({mode:"open"}),this.handlePointerDown=e=>{this.setPointerCapture(e.pointerId)},this.root.innerHTML=`
159
+ </div>`}static get stateManager(){return w._stateManager||(w._stateManager=new F),w._stateManager}get storage(){return this._storage}set storage(e){var t;const r=this._storage;r&&(this.dispatchEvent(new CustomEvent(w.removeStorageEvent,{detail:r})),null===(t=this.ownerStateManager)||void 0===t?void 0:t.removeBoundary(r)),this._storage=e,e&&this.dispatchEvent(new CustomEvent(w.attachStorageEvent,{detail:e})),r&&e&&this.dispatchEvent(new CustomEvent(w.replaceStorageEvent,{detail:{old:r,new:e}}))}waitForStorage(e){this.storage===void 0?this.addEventListener(w.attachStorageEvent,()=>e(this.storage),{once:!0}):e(this.storage)}appendStorage(e=!1){if(!e&&this.storage)return;const t=o(this,x.ElementName),r=t?t.stateManager:w.stateManager;this.storage=r.newBoundary(this),this.ownerStateManager=r}connectedCallback(){this.appendStorage(!0),"strictEdge"===h.borderDetectionMode&&(this.addEventListener("pointerenter",this.handlePointerEnter),this.addEventListener("pointerleave",this.handlePointerLeave),this.addEventListener("pointermove",this.handlePointerMove)),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointerup",this.handlePointerUp),this.addEventListener("pointercancel",this.handlePointerCancel),"strictEdge"===h.borderDetectionMode&&(this.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),this.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),this.addEventListener("touchcancel",this.handleTouchEnd,{passive:!0}))}disconnectedCallback(){this.storage=void 0,this.ownerStateManager=void 0}}w.ElementName="ax-reveal-bound",w.removeStorageEvent="removeStorage",w.attachStorageEvent="attachStorage",w.replaceStorageEvent="replaceStorage";class C extends P{constructor(){super(),this.root=this.attachShadow({mode:"open"}),this.connection=0,this.handlePointerDown=e=>{this.setPointerCapture(e.pointerId)},this.root.innerHTML=`
131
160
  <div class="ax-reveal">
132
161
  <canvas></canvas>
133
162
  <div class="content"><slot></slot></div>
134
163
  </div>
135
164
  <style>
136
165
  .ax-reveal { display: content; }
137
- .ax-reveal * { user-drag: none; -webkit-user-drag: none; touch-action: none; user-select: none; }
166
+ .ax-reveal * { user-drag: none; -webkit-user-drag: none; touch-action: var(--reveal-touch-action, manipulation); user-select: none; }
138
167
  .content { position: relative; }
139
168
  canvas { top: 0; left: 0; pointer-events: none; width: 100%; height: 100%; position: absolute; }
140
169
  :host { display: inline-block; position: relative; }
@@ -144,9 +173,10 @@ for(let r=0;r<this.canvasList.length;r++){const a=this.canvasList[r];if(a.curren
144
173
  :host([inline-flex]) { display: inline-flex; }
145
174
  :host([grid]) { display: grid; }
146
175
  :host([inline-grid]) { display: inline-grid; }
147
- ::slotted(*) { user-drag: none; -webkit-user-drag: none; touch-action: none; user-select: none; }
176
+ ::slotted(*) { user-drag: none; -webkit-user-drag: none; touch-action: var(--reveal-touch-action, manipulation); user-select: none; }
148
177
  ::slotted(button) { outline:none; }
149
- </style>`,this.canvas=this.root.querySelector("canvas")}adoptedCallback(){this.disconnectedCallback(),this.connectedCallback()}disconnectedCallback(){this.boundary&&this.boundary.waitForStorage(e=>e.removeReveal(this.canvas))}connectedCallback(){if(this.boundary=o(this,C.ElementName),!this.boundary)throw new SyntaxError("You must use "+C.ElementName+" as the boundary of reveal highlight!");this.boundary.waitForStorage(e=>setTimeout(()=>e.addReveal(this.canvas,this),0)),this.addEventListener("pointerdown",this.handlePointerDown)}}w.ElementName="ax-reveal";class D extends F{constructor(){super(),this.root=this.attachShadow({mode:"open"}),this.handlePointerDown=e=>{this.setPointerCapture(e.pointerId)},this.root.innerHTML=`
178
+ </style>`,this.canvas=this.root.querySelector("canvas")}adoptedCallback(){this.disconnectedCallback(),this.connectedCallback()}disconnectedCallback(){this.connection++,this.storage&&this.storage.removeReveal(this.canvas),this.storage=void 0}connectedCallback(){if(this.boundary=o(this,w.ElementName),!this.boundary)throw new SyntaxError("You must use "+w.ElementName+" as the boundary of reveal highlight!");const e=++this.connection;this.boundary.waitForStorage(t=>setTimeout(()=>{// Disconnected or reconnected before the timer fired.
179
+ e!==this.connection||(this.storage=t,t.addReveal(this.canvas,this))},0)),this.addEventListener("pointerdown",this.handlePointerDown)}}C.ElementName="ax-reveal";class B extends P{constructor(){super(),this.root=this.attachShadow({mode:"open"}),this.connection=0,this.handlePointerDown=e=>{this.setPointerCapture(e.pointerId)},this.root.innerHTML=`
150
180
  <div class="ax-reveal">
151
181
  <svg>
152
182
  <defs>
@@ -172,7 +202,7 @@ for(let r=0;r<this.canvasList.length;r++){const a=this.canvasList[r];if(a.curren
172
202
  </div>
173
203
  <style>
174
204
  .ax-reveal { display: contents; }
175
- .ax-reveal * { user-drag: none; -webkit-user-drag: none; touch-action: none; user-select: none; }
205
+ .ax-reveal * { user-drag: none; -webkit-user-drag: none; touch-action: var(--reveal-touch-action, manipulation); user-select: none; }
176
206
  .content { position: relative; }
177
207
  svg { top: 0; left: 0; pointer-events: none; width: 100%; height: 100%; position: absolute; }
178
208
  :host { display: inline-block; position: relative; }
@@ -182,6 +212,7 @@ for(let r=0;r<this.canvasList.length;r++){const a=this.canvasList[r];if(a.curren
182
212
  :host([inline-flex]) { display: inline-flex; }
183
213
  :host([grid]) { display: grid; }
184
214
  :host([inline-grid]) { display: inline-grid; }
185
- ::slotted(*) { user-drag: none; -webkit-user-drag: none; touch-action: none; user-select: none; }
215
+ ::slotted(*) { user-drag: none; -webkit-user-drag: none; touch-action: var(--reveal-touch-action, manipulation); user-select: none; }
186
216
  ::slotted(button) { outline:none; }
187
- </style>`,this.svg=this.root.querySelector("svg")}adoptedCallback(){this.disconnectedCallback(),this.connectedCallback()}disconnectedCallback(){this.boundary&&this.boundary.waitForStorage(e=>e.removeReveal(this.svg))}connectedCallback(){if(this.boundary=o(this,C.ElementName),!this.boundary)throw new SyntaxError("You must use "+C.ElementName+" as the boundary of reveal highlight!");this.boundary.waitForStorage(e=>setTimeout(()=>e.addReveal(this.svg,this),0)),this.addEventListener("pointerdown",this.handlePointerDown)}}D.ElementName="ax-reveal-ng";const B="magic";let A=!1;e.register=d,Object.defineProperty(e,"__esModule",{value:!0})});
217
+ </style>`,this.svg=this.root.querySelector("svg")}adoptedCallback(){this.disconnectedCallback(),this.connectedCallback()}disconnectedCallback(){this.connection++,this.storage&&this.storage.removeReveal(this.svg),this.storage=void 0}connectedCallback(){if(this.boundary=o(this,w.ElementName),!this.boundary)throw new SyntaxError("You must use "+w.ElementName+" as the boundary of reveal highlight!");const e=++this.connection;this.boundary.waitForStorage(t=>setTimeout(()=>{// Disconnected or reconnected before the timer fired.
218
+ e!==this.connection||(this.storage=t,t.addReveal(this.svg,this))},0)),this.addEventListener("pointerdown",this.handlePointerDown)}}B.ElementName="ax-reveal-ng";const D="magic";let A=!1;e.register=d,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -54,10 +54,10 @@ interface CachedReveal {
54
54
  radiusFactor: number;
55
55
  color: string;
56
56
  opacity: number;
57
- pattern: CanvasPattern | null;
57
+ pattern: CanvasGradient | null;
58
58
  }
59
59
  /**
60
- * Cached border and body pattern, for faster painting on the canvas.
60
+ * Cached border and body gradient, for faster painting on the canvas.
61
61
  * @interface CachedRevealBitmap
62
62
  */
63
63
  export interface CachedRevealBitmap {
@@ -65,14 +65,6 @@ export interface CachedRevealBitmap {
65
65
  borderReveal: CachedReveal;
66
66
  fillReveal: CachedReveal;
67
67
  };
68
- cachedCanvas: {
69
- borderReveal: HTMLCanvasElement;
70
- fillReveal: HTMLCanvasElement;
71
- };
72
- cachedCtx: {
73
- borderReveal: CanvasRenderingContext2D | null;
74
- fillReveal: CanvasRenderingContext2D | null;
75
- };
76
68
  }
77
69
  /**
78
70
  * Cached border and body pattern, just to store something in similar way.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,gBAAgB,CAAC;IACvC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,6BAA6B,EAAE,MAAM,CAAC;IACtC,8BAA8B,EAAE,MAAM,CAAC;IACvC,gCAAgC,EAAE,MAAM,CAAC;IACzC,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IAC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QAChB,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QAClE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;QAChE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;KACrF,CAAC;CACL"}
@@ -1,43 +1,47 @@
1
- import { ComputedStyleStorage } from './ComputedStyleStorage.js';
2
- import { RevealBoundaryStore } from './RevealBoundryStore.js';
3
- import type { CachedBoundingRect, CachedStyle } from './utils/types.js';
4
- export declare class BaseConfig<T extends Element> {
5
- protected _store: RevealBoundaryStore;
6
- pxRatio: number;
7
- readonly container: HTMLElement;
8
- readonly element: T;
9
- protected readonly computedStyle: ComputedStyleStorage;
10
- paintedWidth: number;
11
- paintedHeight: number;
12
- currentFrameId: number;
13
- cachedBoundingRectFrameId: number;
14
- cachedBoundingRect: CachedBoundingRect;
15
- cachedStyleFrameId: number;
16
- cachedStyle: CachedStyle;
17
- dirty: boolean;
18
- shapeDirty: boolean;
19
- fillDirty: boolean;
20
- animationDirty: boolean;
21
- /**
22
- * If is cleaned up by `RevealBoundaryStore` during animation
23
- * duration checkup.
24
- */
25
- cleanedUpForAnimation: boolean;
26
- mouseUpClientX: number | null;
27
- mouseUpClientY: number | null;
28
- mouseDownAnimateStartFrame: number | null;
29
- mouseDownAnimateCurrentFrame: number | null;
30
- mouseDownAnimateReleasedFrame: number | null;
31
- mouseDownAnimateLogicFrame: number | null;
32
- mousePressed: boolean;
33
- mouseReleased: boolean;
34
- constructor(store: RevealBoundaryStore, $canvas: T, $container: HTMLElement);
35
- cacheBoundingRect: () => void;
36
- getTrueFillRadius: (trueFillRadius?: [number, number], fillMode?: string) => [number, number];
37
- getPropFromMultipleSource: (domPropsName: string, cssPropsName: string) => string;
38
- getNumberPropFromMultipleSource: (domPropsName: string, cssPropsName: string) => number;
39
- cacheCanvasPaintingStyle: () => void;
40
- mouseInCanvas: () => boolean;
41
- syncSizeToRevealRadius: (x: HTMLCanvasElement, factor: number) => void;
42
- }
1
+ import { ComputedStyleStorage } from './ComputedStyleStorage.js';
2
+ import { RevealBoundaryStore } from './RevealBoundryStore.js';
3
+ import type { CachedBoundingRect, CachedStyle } from './utils/types.js';
4
+ export declare class BaseConfig<T extends Element> {
5
+ protected _store: RevealBoundaryStore;
6
+ pxRatio: number;
7
+ readonly container: HTMLElement;
8
+ readonly element: T;
9
+ protected readonly computedStyle: ComputedStyleStorage;
10
+ paintedWidth: number;
11
+ paintedHeight: number;
12
+ currentFrameId: number;
13
+ cachedBoundingRectFrameId: number;
14
+ cachedBoundingRect: CachedBoundingRect;
15
+ cachedStyleFrameId: number;
16
+ cachedStyle: CachedStyle;
17
+ dirty: boolean;
18
+ /**
19
+ * Bumped whenever `cacheCanvasPaintingStyle` sees any value change, so
20
+ * painters can tell whether the last painted frame is still valid.
21
+ */
22
+ styleVersion: number;
23
+ shapeDirty: boolean;
24
+ fillDirty: boolean;
25
+ animationDirty: boolean;
26
+ /**
27
+ * If is cleaned up by `RevealBoundaryStore` during animation
28
+ * duration checkup.
29
+ */
30
+ cleanedUpForAnimation: boolean;
31
+ mouseUpClientX: number | null;
32
+ mouseUpClientY: number | null;
33
+ mouseDownAnimateStartFrame: number | null;
34
+ mouseDownAnimateCurrentFrame: number | null;
35
+ mouseDownAnimateReleasedFrame: number | null;
36
+ mouseDownAnimateLogicFrame: number | null;
37
+ mousePressed: boolean;
38
+ mouseReleased: boolean;
39
+ constructor(store: RevealBoundaryStore, $canvas: T, $container: HTMLElement);
40
+ cacheBoundingRect: () => void;
41
+ getTrueFillRadius: (trueFillRadius?: [number, number], fillMode?: string) => [number, number];
42
+ getPropFromMultipleSource: (domPropsName: string, cssPropsName: string) => string;
43
+ getNumberPropFromMultipleSource: (domPropsName: string, cssPropsName: string) => number;
44
+ cacheCanvasPaintingSt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