masoneffect 2.0.2 → 2.0.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 (212) hide show
  1. package/README.md +4 -4
  2. package/dist/core/index.d.ts +2 -0
  3. package/dist/core/index.d.ts.map +1 -1
  4. package/dist/core/typing/index.d.ts +52 -0
  5. package/dist/core/typing/index.d.ts.map +1 -0
  6. package/dist/count/core/index.d.ts +2 -0
  7. package/dist/count/core/index.d.ts.map +1 -1
  8. package/dist/count/core/typing/index.d.ts +52 -0
  9. package/dist/count/core/typing/index.d.ts.map +1 -0
  10. package/dist/count/index.d.ts +2 -0
  11. package/dist/count/index.d.ts.map +1 -1
  12. package/dist/count/react/index.d.ts +2 -0
  13. package/dist/count/react/index.d.ts.map +1 -1
  14. package/dist/count/react/typing/Typing.d.ts +18 -0
  15. package/dist/count/react/typing/Typing.d.ts.map +1 -0
  16. package/dist/count/react/typing/index.d.ts +4 -0
  17. package/dist/count/react/typing/index.d.ts.map +1 -0
  18. package/dist/count/svelte/index.d.ts +1 -0
  19. package/dist/count/svelte/index.d.ts.map +1 -1
  20. package/dist/count/svelte/typing/index.d.ts +3 -0
  21. package/dist/count/svelte/typing/index.d.ts.map +1 -0
  22. package/dist/count/vue/index.d.ts +1 -0
  23. package/dist/count/vue/index.d.ts.map +1 -1
  24. package/dist/count/vue/typing/index.d.ts +4 -0
  25. package/dist/count/vue/typing/index.d.ts.map +1 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.mjs +1 -1
  30. package/dist/react/core/index.d.ts +2 -0
  31. package/dist/react/core/typing/index.d.ts +51 -0
  32. package/dist/react/count/core/index.d.ts +2 -0
  33. package/dist/react/count/core/index.d.ts.map +1 -1
  34. package/dist/react/count/core/typing/index.d.ts +52 -0
  35. package/dist/react/count/core/typing/index.d.ts.map +1 -0
  36. package/dist/react/count/index.d.ts +2 -0
  37. package/dist/react/count/index.d.ts.map +1 -1
  38. package/dist/react/count/react/index.d.ts +2 -0
  39. package/dist/react/count/react/index.d.ts.map +1 -1
  40. package/dist/react/count/react/typing/Typing.d.ts +18 -0
  41. package/dist/react/count/react/typing/Typing.d.ts.map +1 -0
  42. package/dist/react/count/react/typing/index.d.ts +4 -0
  43. package/dist/react/count/react/typing/index.d.ts.map +1 -0
  44. package/dist/react/count/svelte/index.d.ts +1 -0
  45. package/dist/react/count/svelte/index.d.ts.map +1 -1
  46. package/dist/react/count/svelte/typing/index.d.ts +3 -0
  47. package/dist/react/count/svelte/typing/index.d.ts.map +1 -0
  48. package/dist/react/count/vue/index.d.ts +1 -0
  49. package/dist/react/count/vue/index.d.ts.map +1 -1
  50. package/dist/react/count/vue/typing/index.d.ts +4 -0
  51. package/dist/react/count/vue/typing/index.d.ts.map +1 -0
  52. package/dist/react/index.cjs +2 -0
  53. package/dist/react/index.d.ts.map +1 -1
  54. package/dist/react/index.mjs +1 -0
  55. package/dist/react/react/index.d.ts +2 -0
  56. package/dist/react/react/typing/Typing.d.ts +17 -0
  57. package/dist/react/react/typing/index.d.ts +3 -0
  58. package/dist/react/svelte/index.d.ts +1 -0
  59. package/dist/react/svelte/typing/index.d.ts +2 -0
  60. package/dist/react/textToParticle/core/index.d.ts +2 -0
  61. package/dist/react/textToParticle/core/index.d.ts.map +1 -1
  62. package/dist/react/textToParticle/core/typing/index.d.ts +52 -0
  63. package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -0
  64. package/dist/react/textToParticle/index.d.ts +2 -0
  65. package/dist/react/textToParticle/index.d.ts.map +1 -1
  66. package/dist/react/textToParticle/react/index.d.ts +2 -0
  67. package/dist/react/textToParticle/react/index.d.ts.map +1 -1
  68. package/dist/react/textToParticle/react/typing/Typing.d.ts +18 -0
  69. package/dist/react/textToParticle/react/typing/Typing.d.ts.map +1 -0
  70. package/dist/react/textToParticle/react/typing/index.d.ts +4 -0
  71. package/dist/react/textToParticle/react/typing/index.d.ts.map +1 -0
  72. package/dist/react/textToParticle/svelte/index.d.ts +1 -0
  73. package/dist/react/textToParticle/svelte/index.d.ts.map +1 -1
  74. package/dist/react/textToParticle/svelte/typing/index.d.ts +3 -0
  75. package/dist/react/textToParticle/svelte/typing/index.d.ts.map +1 -0
  76. package/dist/react/textToParticle/vue/index.d.ts +1 -0
  77. package/dist/react/textToParticle/vue/index.d.ts.map +1 -1
  78. package/dist/react/textToParticle/vue/typing/index.d.ts +4 -0
  79. package/dist/react/textToParticle/vue/typing/index.d.ts.map +1 -0
  80. package/dist/react/typing/Typing.d.ts +18 -0
  81. package/dist/react/typing/Typing.d.ts.map +1 -0
  82. package/dist/react/typing/core/count/index.d.ts +52 -0
  83. package/dist/react/typing/core/count/index.d.ts.map +1 -0
  84. package/dist/react/typing/core/index.d.ts +20 -0
  85. package/dist/react/typing/core/index.d.ts.map +1 -0
  86. package/dist/react/typing/core/textToParticle/index.d.ts +103 -0
  87. package/dist/react/typing/core/textToParticle/index.d.ts.map +1 -0
  88. package/dist/react/typing/core/typing/index.d.ts +52 -0
  89. package/dist/react/typing/core/typing/index.d.ts.map +1 -0
  90. package/dist/react/typing/index.cjs +1 -0
  91. package/dist/react/typing/index.d.ts +18 -0
  92. package/dist/react/typing/index.d.ts.map +1 -0
  93. package/dist/react/typing/index.mjs +1 -0
  94. package/dist/react/typing/index.umd.d.ts +7 -0
  95. package/dist/react/typing/index.umd.d.ts.map +1 -0
  96. package/dist/react/typing/react/MasonEffect.d.ts +32 -0
  97. package/dist/react/typing/react/MasonEffect.d.ts.map +1 -0
  98. package/dist/react/typing/react/count/Count.d.ts +19 -0
  99. package/dist/react/typing/react/count/Count.d.ts.map +1 -0
  100. package/dist/react/typing/react/count/index.d.ts +5 -0
  101. package/dist/react/typing/react/count/index.d.ts.map +1 -0
  102. package/dist/react/typing/react/index.d.ts +14 -0
  103. package/dist/react/typing/react/index.d.ts.map +1 -0
  104. package/dist/react/typing/react/textToParticle/TextToParticle.d.ts +15 -0
  105. package/dist/react/typing/react/textToParticle/TextToParticle.d.ts.map +1 -0
  106. package/dist/react/typing/react/textToParticle/index.d.ts +4 -0
  107. package/dist/react/typing/react/textToParticle/index.d.ts.map +1 -0
  108. package/dist/react/typing/react/typing/Typing.d.ts +18 -0
  109. package/dist/react/typing/react/typing/Typing.d.ts.map +1 -0
  110. package/dist/react/typing/react/typing/index.d.ts +4 -0
  111. package/dist/react/typing/react/typing/index.d.ts.map +1 -0
  112. package/dist/react/typing/svelte/count/index.d.ts +2 -0
  113. package/dist/react/typing/svelte/count/index.d.ts.map +1 -0
  114. package/dist/react/typing/svelte/index.d.ts +9 -0
  115. package/dist/react/typing/svelte/index.d.ts.map +1 -0
  116. package/dist/react/typing/svelte/textToParticle/index.d.ts +2 -0
  117. package/dist/react/typing/svelte/textToParticle/index.d.ts.map +1 -0
  118. package/dist/react/typing/svelte/typing/index.d.ts +3 -0
  119. package/dist/react/typing/svelte/typing/index.d.ts.map +1 -0
  120. package/dist/react/typing/vue/count/index.d.ts +2 -0
  121. package/dist/react/typing/vue/count/index.d.ts.map +1 -0
  122. package/dist/react/typing/vue/index.d.ts +9 -0
  123. package/dist/react/typing/vue/index.d.ts.map +1 -0
  124. package/dist/react/typing/vue/textToParticle/index.d.ts +2 -0
  125. package/dist/react/typing/vue/textToParticle/index.d.ts.map +1 -0
  126. package/dist/react/typing/vue/typing/index.d.ts +4 -0
  127. package/dist/react/typing/vue/typing/index.d.ts.map +1 -0
  128. package/dist/react/vue/index.d.ts +1 -0
  129. package/dist/react/vue/typing/index.d.ts +3 -0
  130. package/dist/svelte/count/index.d.ts +52 -0
  131. package/dist/svelte/index.cjs +1 -1
  132. package/dist/svelte/index.d.ts +52 -0
  133. package/dist/svelte/index.mjs +415 -48
  134. package/dist/svelte/textToParticle/index.d.ts +52 -0
  135. package/dist/svelte/typing/index.cjs +1 -0
  136. package/dist/svelte/typing/index.d.ts +215 -0
  137. package/dist/svelte/typing/index.mjs +634 -0
  138. package/dist/textToParticle/core/index.d.ts +2 -0
  139. package/dist/textToParticle/core/index.d.ts.map +1 -1
  140. package/dist/textToParticle/core/typing/index.d.ts +52 -0
  141. package/dist/textToParticle/core/typing/index.d.ts.map +1 -0
  142. package/dist/textToParticle/index.d.ts +2 -0
  143. package/dist/textToParticle/index.d.ts.map +1 -1
  144. package/dist/textToParticle/react/index.d.ts +2 -0
  145. package/dist/textToParticle/react/index.d.ts.map +1 -1
  146. package/dist/textToParticle/react/typing/Typing.d.ts +18 -0
  147. package/dist/textToParticle/react/typing/Typing.d.ts.map +1 -0
  148. package/dist/textToParticle/react/typing/index.d.ts +4 -0
  149. package/dist/textToParticle/react/typing/index.d.ts.map +1 -0
  150. package/dist/textToParticle/svelte/index.d.ts +1 -0
  151. package/dist/textToParticle/svelte/index.d.ts.map +1 -1
  152. package/dist/textToParticle/svelte/typing/index.d.ts +3 -0
  153. package/dist/textToParticle/svelte/typing/index.d.ts.map +1 -0
  154. package/dist/textToParticle/vue/index.d.ts +1 -0
  155. package/dist/textToParticle/vue/index.d.ts.map +1 -1
  156. package/dist/textToParticle/vue/typing/index.d.ts +4 -0
  157. package/dist/textToParticle/vue/typing/index.d.ts.map +1 -0
  158. package/dist/typing/core/count/index.d.ts +52 -0
  159. package/dist/typing/core/count/index.d.ts.map +1 -0
  160. package/dist/typing/core/index.d.ts +20 -0
  161. package/dist/typing/core/index.d.ts.map +1 -0
  162. package/dist/typing/core/textToParticle/index.d.ts +103 -0
  163. package/dist/typing/core/textToParticle/index.d.ts.map +1 -0
  164. package/dist/typing/core/typing/index.d.ts +52 -0
  165. package/dist/typing/core/typing/index.d.ts.map +1 -0
  166. package/dist/typing/index.cjs +1 -0
  167. package/dist/typing/index.d.ts +18 -0
  168. package/dist/typing/index.d.ts.map +1 -0
  169. package/dist/typing/index.mjs +1 -0
  170. package/dist/typing/index.umd.d.ts +7 -0
  171. package/dist/typing/index.umd.d.ts.map +1 -0
  172. package/dist/typing/react/MasonEffect.d.ts +32 -0
  173. package/dist/typing/react/MasonEffect.d.ts.map +1 -0
  174. package/dist/typing/react/count/Count.d.ts +19 -0
  175. package/dist/typing/react/count/Count.d.ts.map +1 -0
  176. package/dist/typing/react/count/index.d.ts +5 -0
  177. package/dist/typing/react/count/index.d.ts.map +1 -0
  178. package/dist/typing/react/index.d.ts +14 -0
  179. package/dist/typing/react/index.d.ts.map +1 -0
  180. package/dist/typing/react/textToParticle/TextToParticle.d.ts +15 -0
  181. package/dist/typing/react/textToParticle/TextToParticle.d.ts.map +1 -0
  182. package/dist/typing/react/textToParticle/index.d.ts +4 -0
  183. package/dist/typing/react/textToParticle/index.d.ts.map +1 -0
  184. package/dist/typing/react/typing/Typing.d.ts +18 -0
  185. package/dist/typing/react/typing/Typing.d.ts.map +1 -0
  186. package/dist/typing/react/typing/index.d.ts +4 -0
  187. package/dist/typing/react/typing/index.d.ts.map +1 -0
  188. package/dist/typing/svelte/count/index.d.ts +2 -0
  189. package/dist/typing/svelte/count/index.d.ts.map +1 -0
  190. package/dist/typing/svelte/index.d.ts +9 -0
  191. package/dist/typing/svelte/index.d.ts.map +1 -0
  192. package/dist/typing/svelte/textToParticle/index.d.ts +2 -0
  193. package/dist/typing/svelte/textToParticle/index.d.ts.map +1 -0
  194. package/dist/typing/svelte/typing/index.d.ts +3 -0
  195. package/dist/typing/svelte/typing/index.d.ts.map +1 -0
  196. package/dist/typing/vue/count/index.d.ts +2 -0
  197. package/dist/typing/vue/count/index.d.ts.map +1 -0
  198. package/dist/typing/vue/index.d.ts +9 -0
  199. package/dist/typing/vue/index.d.ts.map +1 -0
  200. package/dist/typing/vue/textToParticle/index.d.ts +2 -0
  201. package/dist/typing/vue/textToParticle/index.d.ts.map +1 -0
  202. package/dist/typing/vue/typing/index.d.ts +4 -0
  203. package/dist/typing/vue/typing/index.d.ts.map +1 -0
  204. package/dist/vue/count/index.d.ts +52 -0
  205. package/dist/vue/index.cjs +1 -1
  206. package/dist/vue/index.d.ts +52 -0
  207. package/dist/vue/index.mjs +312 -7
  208. package/dist/vue/textToParticle/index.d.ts +52 -0
  209. package/dist/vue/typing/index.cjs +1 -0
  210. package/dist/vue/typing/index.d.ts +215 -0
  211. package/dist/vue/typing/index.mjs +308 -0
  212. package/package.json +25 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/svelte/textToParticle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default } from './Typing.svelte';
2
+ export type { TypingOptions } from '../../core/typing/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/svelte/typing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './Count.vue';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vue/count/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * MasonEffect Vue - 모든 Vue 컴포넌트를 export하는 메인 파일
3
+ */
4
+ export { default as TextToParticle } from './textToParticle/index.js';
5
+ export { default as Count } from './count/index.js';
6
+ export { default as Typing } from './typing/index.js';
7
+ export { default as MasonEffect } from './textToParticle/index.js';
8
+ export { default } from './textToParticle/index.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vue/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './TextToParticle.vue';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vue/textToParticle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default } from './Typing.vue';
2
+ export type { TypingRef } from './Typing.vue';
3
+ export type { TypingOptions } from '../../core/typing/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/vue/typing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
@@ -160,4 +160,56 @@ declare class TextToParticle {
160
160
  export { TextToParticleOptions as MasonEffectOptions }
161
161
  export { TextToParticleOptions }
162
162
 
163
+ export declare class Typing {
164
+ container: HTMLElement;
165
+ config: Required<Omit<TypingOptions, 'onUpdate' | 'onComplete'>> & {
166
+ onUpdate: TypingOptions['onUpdate'];
167
+ onComplete: TypingOptions['onComplete'];
168
+ };
169
+ textUnits: string[];
170
+ currentIndex: number;
171
+ displayedText: string;
172
+ timeoutId: ReturnType<typeof setTimeout> | null;
173
+ intersectionObserver: IntersectionObserver | null;
174
+ isRunning: boolean;
175
+ hasTriggered: boolean;
176
+ originalText: string;
177
+ constructor(container: HTMLElement | string, options: TypingOptions);
178
+ init(): void;
179
+ setupIntersectionObserver(): void;
180
+ private originalChars;
181
+ private charUnitMap;
182
+ private initializeTextStructure;
183
+ private getCharIndexFromUnitIndex;
184
+ private buildTextFromUnits;
185
+ start(): void;
186
+ typeNext(): void;
187
+ stop(): void;
188
+ reset(): void;
189
+ updateDisplay(text: string): void;
190
+ setText(newText: string): void;
191
+ destroy(): void;
192
+ }
193
+
194
+ /**
195
+ * Typing - 타이핑 애니메이션 효과
196
+ * 바닐라 JS 코어 클래스
197
+ *
198
+ * 사용법:
199
+ * import { Typing } from 'masoneffect/typing';
200
+ */
201
+ export declare interface TypingOptions {
202
+ text: string;
203
+ speed?: number;
204
+ delay?: number;
205
+ enabled?: boolean;
206
+ threshold?: number;
207
+ rootMargin?: string;
208
+ triggerOnce?: boolean;
209
+ showCursor?: boolean;
210
+ cursorChar?: string;
211
+ onUpdate?: (text: string) => void;
212
+ onComplete?: () => void;
213
+ }
214
+
163
215
  export { }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");function e(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}class i{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const n=this.canvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Canvas context not available");this.ctx=n,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const s=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Offscreen canvas context not available");this.offCtx=s,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.isVisible=!1,this.intersectionObserver=null,this.debounceDelay=i.debounceDelay??150;const o=this.handleResize.bind(this);this.handleResize=e(o,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=e(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=e(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupIntersectionObserver(),this.config.onReady&&this.config.onReady(this)}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void this.start();this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.start()):(this.isVisible=!1,this.stop()))},{threshold:.1}),this.intersectionObserver.observe(this.container))}resize(){const t=this.config.width||this.container.clientWidth||window.innerWidth,e=this.config.height||this.container.clientHeight||.7*window.innerHeight;if(t<=0||e<=0)return;this.W=Math.floor(t*this.DPR),this.H=Math.floor(e*this.DPR);const i=4096;if(this.W>i||this.H>i){const t=Math.min(i/this.W,i/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,a=.1*t,r=.05*t;let h=0;for(const d of s){if(0===d.length)continue;const t=this.offCtx.measureText(d).width+r*(d.length>0?d.length-1:0);h=Math.max(h,t)}const l=s.length>0?o*s.length+a*(s.length-1):o;return{width:h,height:l,fits:h<=i&&l<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,a=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(a=n,s=n+1):o=n-1}return a}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const a=t.split("\n"),r=o,h=.1*o,l=.05*o,d=a.length>0?r*a.length+h*(a.length-1):r;let c=this.H/2-d/2+r/2;for(const g of a){if(0===g.length){c+=r+h;continue}const t=g.split(""),e=this.offCtx.measureText(g).width+l*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,c),i+=this.offCtx.measureText(n).width+l;c+=r+h}const u=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let g=0;g<this.H;g+=u)for(let t=0;t<this.W;t+=u){const e=4*(g*this.W+t);f[e]+f[e+1]+f[e+2]>600&&p.push({x:t,y:g})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let g=0;g<this.particles.length;g++){const t=this.particles[g],e=p[g];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const e of this.particles){let t=(e.tx-e.x)*this.config.ease,i=(e.ty-e.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const n=e.x-this.mouse.x,s=e.y-this.mouse.y,o=n*n+s*s,a=this.config.repelRadius*this.DPR;if(o<a*a){const e=Math.sqrt(o)+1e-4,r=(this.mouse.down?-1:1)*this.config.repelStrength*(1-e/a);t+=n/e*r*6,i+=s/e*r*6}}e.j+=2,t+=.05*Math.cos(e.j),i+=.05*Math.sin(1.3*e.j),e.vx=(e.vx+t)*Math.random(),e.vy=(e.vy+i)*Math.random(),e.x+=e.vx,e.y+=e.vy}this.ctx.fillStyle=this.config.particleColor;const t=this.config.pointSize*this.DPR;for(const e of this.particles)this.ctx.beginPath(),this.ctx.arc(e.x,e.y,t,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const n={linear:t=>t};class s{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:e.targetValue,duration:e.duration??2e3,startValue:e.startValue??0,enabled:e.enabled??!0,easing:e.easing??n.linear,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.intersectionObserver=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupIntersectionObserver()}setupIntersectionObserver(){"undefined"!=typeof window&&void 0!==window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(t=>{var e;for(const i of t)if(i.target===this.container)if(i.isIntersecting)!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start()),this.config.triggerOnce&&(null==(e=this.intersectionObserver)||e.unobserve(this.container));else if(!this.config.triggerOnce){const t=i.boundingClientRect,e=window.innerHeight,n=window.innerWidth;(t.bottom<=0||t.top>=e||t.right<=0||t.left>=n)&&this.isRunning&&this.reset()}},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&this.start()}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=e=>{null===this.startTime&&(this.startTime=e);const i=e-this.startTime,n=Math.min(i/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),e&&this.config.enabled&&this.start()):e&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}const o=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(e,{expose:n,emit:s}){const o=e,a=s,r=t.ref(null);let h=null;return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{h&&h.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),a("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)}};h=new i(r.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),n({morph:t=>{h&&h.morph(t)},scatter:()=>{h&&h.scatter()},updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),a=t.defineComponent({__name:"Count",props:{className:{default:""},style:{default:()=>({})},targetValue:{default:0},duration:{default:2e3},startValue:{default:0},enabled:{type:Boolean,default:!0},easing:{type:Function,default:()=>t=>t},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},onUpdate:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["update","complete"],setup(e,{expose:i,emit:n}){const o=e,a=n,r=t.ref(null);let h=null;return t.watch(()=>[o.targetValue,o.duration,o.startValue,o.enabled,o.easing,o.threshold,o.rootMargin,o.triggerOnce],()=>{h&&h.updateConfig({targetValue:o.targetValue,duration:o.duration,startValue:o.startValue,enabled:o.enabled,easing:o.easing,threshold:o.threshold,rootMargin:o.rootMargin,triggerOnce:o.triggerOnce,onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)},onComplete:()=>{o.onComplete&&o.onComplete(),a("complete")}})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={targetValue:o.targetValue,duration:o.duration,startValue:o.startValue,enabled:o.enabled,easing:o.easing,threshold:o.threshold,rootMargin:o.rootMargin,triggerOnce:o.triggerOnce,onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)},onComplete:()=>{o.onComplete&&o.onComplete(),a("complete")}};h=new s(r.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),i({start:()=>{h&&h.start()},stop:()=>{h&&h.stop()},reset:()=>{h&&h.reset()},getValue:()=>h?h.getValue():0,updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}});exports.Count=a,exports.MasonEffect=o,exports.TextToParticle=o,exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");function e(t,e){let i=null;return function(...n){null!==i&&clearTimeout(i),i=setTimeout(()=>{i=null,t.apply(this,n)},e)}}class i{constructor(t,i={}){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={text:i.text||"mason effect",densityStep:i.densityStep??2,maxParticles:i.maxParticles??3200,pointSize:i.pointSize??.5,ease:i.ease??.05,repelRadius:i.repelRadius??150,repelStrength:i.repelStrength??1,particleColor:i.particleColor||"#fff",fontFamily:i.fontFamily||"Inter, system-ui, Arial",fontSize:i.fontSize||null,width:i.width||null,height:i.height||null,devicePixelRatio:i.devicePixelRatio??null,onReady:i.onReady||null,onUpdate:i.onUpdate||null},this.canvas=document.createElement("canvas");const n=this.canvas.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("Canvas context not available");this.ctx=n,this.container.appendChild(this.canvas),this.canvas.style.display="block",this.offCanvas=document.createElement("canvas");const s=this.offCanvas.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("Offscreen canvas context not available");this.offCtx=s,this.W=0,this.H=0,this.DPR=this.config.devicePixelRatio||Math.min(window.devicePixelRatio||1,1.8),this.particles=[],this.mouse={x:0,y:0,down:!1},this.animationId=null,this.isRunning=!1,this.isVisible=!1,this.intersectionObserver=null,this.debounceDelay=i.debounceDelay??150;const o=this.handleResize.bind(this);this.handleResize=e(o,this.debounceDelay),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this._debouncedMorph=e(this._morphInternal.bind(this),this.debounceDelay),this._debouncedUpdateConfig=e(this._updateConfigInternal.bind(this),this.debounceDelay),this.init()}init(){this.resize(),this.setupEventListeners(),this.setupIntersectionObserver(),this.config.onReady&&this.config.onReady(this)}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void this.start();this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.start()):(this.isVisible=!1,this.stop()))},{threshold:.1}),this.intersectionObserver.observe(this.container))}resize(){const t=this.config.width||this.container.clientWidth||window.innerWidth,e=this.config.height||this.container.clientHeight||.7*window.innerHeight;if(t<=0||e<=0)return;this.W=Math.floor(t*this.DPR),this.H=Math.floor(e*this.DPR);const i=4096;if(this.W>i||this.H>i){const t=Math.min(i/this.W,i/this.H);this.W=Math.floor(this.W*t),this.H=Math.floor(this.H*t),this.DPR=this.DPR*t}this.canvas.width=this.W,this.canvas.height=this.H,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.W>0&&this.H>0&&(this.buildTargets(),this.particles.length||this.initParticles())}measureTextFit(t,e,i,n){this.offCtx.font=`400 ${t}px ${this.config.fontFamily}`;const s=e.split("\n"),o=t,a=.1*t,r=.05*t;let h=0;for(const u of s){if(0===u.length)continue;const t=this.offCtx.measureText(u).width+r*(u.length>0?u.length-1:0);h=Math.max(h,t)}const l=s.length>0?o*s.length+a*(s.length-1):o;return{width:h,height:l,fits:h<=i&&l<=n}}findOptimalFontSize(t,e,i,n){if(this.measureTextFit(n,t,e,i).fits)return n;if(n<=12)return 12;let s=12,o=n,a=12;for(;s<=o;){const n=Math.floor((s+o)/2);this.measureTextFit(n,t,e,i).fits?(a=n,s=n+1):o=n-1}return a}buildTargets(){if(this.W<=0||this.H<=0)return;const t=this.config.text;this.offCanvas.width=this.W,this.offCanvas.height=this.H,this.offCtx.clearRect(0,0,this.offCanvas.width,this.offCanvas.height);const e=Math.min(this.W,this.H),i=this.config.fontSize||Math.max(80,Math.floor(.18*e)),n=this.W-80,s=this.H-80,o=this.findOptimalFontSize(t,n,s,i);this.offCtx.fillStyle="#ffffff",this.offCtx.textAlign="center",this.offCtx.textBaseline="middle",this.offCtx.font=`400 ${o}px ${this.config.fontFamily}`;const a=t.split("\n"),r=o,h=.1*o,l=.05*o,u=a.length>0?r*a.length+h*(a.length-1):r;let d=this.H/2-u/2+r/2;for(const g of a){if(0===g.length){d+=r+h;continue}const t=g.split(""),e=this.offCtx.measureText(g).width+l*(t.length>0?t.length-1:0);let i=this.W/2-e/2;for(const n of t)this.offCtx.fillText(n,i+this.offCtx.measureText(n).width/2,d),i+=this.offCtx.measureText(n).width+l;d+=r+h}const c=Math.max(2,this.config.densityStep),f=this.offCtx.getImageData(0,0,this.W,this.H).data,p=[];for(let g=0;g<this.H;g+=c)for(let t=0;t<this.W;t+=c){const e=4*(g*this.W+t);f[e]+f[e+1]+f[e+2]>600&&p.push({x:t,y:g})}for(;p.length>this.config.maxParticles;)p.splice(Math.floor(Math.random()*p.length),1);if(this.particles.length<p.length){const t=p.length-this.particles.length;for(let e=0;e<t;e++)this.particles.push(this.makeParticle())}else this.particles.length>p.length&&(this.particles.length=p.length);for(let g=0;g<this.particles.length;g++){const t=this.particles[g],e=p[g];t.tx=e.x,t.ty=e.y}}makeParticle(){const t=Math.random()*this.W,e=Math.random()*this.H;return{x:t,y:e,vx:0,vy:0,tx:t,ty:e,initialX:t,initialY:e,j:Math.random()*Math.PI*2}}initParticles(){for(const t of this.particles){const e=Math.random()*this.W,i=Math.random()*this.H;t.x=e,t.y=i,t.vx=t.vy=0,t.initialX=e,t.initialY=i}}scatter(){for(const t of this.particles)void 0!==t.initialX&&void 0!==t.initialY?(t.tx=t.initialX,t.ty=t.initialY):(t.initialX=t.x,t.initialY=t.y,t.tx=t.initialX,t.ty=t.initialY)}morph(t){this._debouncedMorph(t)}_morphInternal(t){if(0!==this.W&&0!==this.H||this.resize(),"string"==typeof t)this.config.text=t,this.buildTargets();else if(t&&"object"==typeof t){const e=void 0!==t.text;this.config={...this.config,...t},e&&this.buildTargets()}else this.buildTargets()}update(){this.ctx.clearRect(0,0,this.W,this.H);for(const e of this.particles){let t=(e.tx-e.x)*this.config.ease,i=(e.ty-e.y)*this.config.ease;if(this.mouse.x||this.mouse.y){const n=e.x-this.mouse.x,s=e.y-this.mouse.y,o=n*n+s*s,a=this.config.repelRadius*this.DPR;if(o<a*a){const e=Math.sqrt(o)+1e-4,r=(this.mouse.down?-1:1)*this.config.repelStrength*(1-e/a);t+=n/e*r*6,i+=s/e*r*6}}e.j+=2,t+=.05*Math.cos(e.j),i+=.05*Math.sin(1.3*e.j),e.vx=(e.vx+t)*Math.random(),e.vy=(e.vy+i)*Math.random(),e.x+=e.vx,e.y+=e.vy}this.ctx.fillStyle=this.config.particleColor;const t=this.config.pointSize*this.DPR;for(const e of this.particles)this.ctx.beginPath(),this.ctx.arc(e.x,e.y,t,0,2*Math.PI),this.ctx.fill();this.config.onUpdate&&this.config.onUpdate(this)}animate(){this.isRunning&&(this.update(),this.animationId=requestAnimationFrame(()=>this.animate()))}start(){this.isRunning||(this.isRunning=!0,this.animate())}stop(){this.isRunning=!1,this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setupEventListeners(){window.addEventListener("resize",this.handleResize),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("mousedown",this.handleMouseDown),window.addEventListener("mouseup",this.handleMouseUp)}removeEventListeners(){window.removeEventListener("resize",this.handleResize),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mouseup",this.handleMouseUp)}handleResize(){this.resize()}handleMouseMove(t){const e=this.canvas.getBoundingClientRect();this.mouse.x=(t.clientX-e.left)*this.DPR,this.mouse.y=(t.clientY-e.top)*this.DPR}handleMouseLeave(){this.mouse.x=this.mouse.y=0}handleMouseDown(){this.mouse.down=!0}handleMouseUp(){this.mouse.down=!1}updateConfig(t){this._debouncedUpdateConfig(t)}_updateConfigInternal(t){this.config={...this.config,...t},t.text&&this.buildTargets()}destroy(){this.stop(),this.removeEventListeners(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.canvas&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}}const n={linear:t=>t};class s{constructor(t,e){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.config={targetValue:e.targetValue,duration:e.duration??2e3,startValue:e.startValue??0,enabled:e.enabled??!0,easing:e.easing??n.linear,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.currentValue=this.config.startValue,this.startTime=null,this.animationFrameId=null,this.intersectionObserver=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupIntersectionObserver()}setupIntersectionObserver(){"undefined"!=typeof window&&void 0!==window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(t=>{var e;for(const i of t)if(i.target===this.container)if(i.isIntersecting)!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start()),this.config.triggerOnce&&(null==(e=this.intersectionObserver)||e.unobserve(this.container));else if(!this.config.triggerOnce){const t=i.boundingClientRect,e=window.innerHeight,n=window.innerWidth;(t.bottom<=0||t.top>=e||t.right<=0||t.left>=n)&&this.isRunning&&this.reset()}},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&this.start()}start(){if(this.isRunning)return;if(!this.config.enabled)return;this.isRunning=!0,this.startTime=null,this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue);const t=e=>{null===this.startTime&&(this.startTime=e);const i=e-this.startTime,n=Math.min(i/this.config.duration,1),s=this.config.easing(n);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*s),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),n<1?this.animationFrameId=requestAnimationFrame(t):(this.currentValue=this.config.targetValue,this.updateDisplay(this.currentValue),this.isRunning=!1,this.config.onComplete&&this.config.onComplete())};this.animationFrameId=requestAnimationFrame(t)}stop(){this.isRunning=!1,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}reset(){this.stop(),this.currentValue=this.config.startValue,this.updateDisplay(this.currentValue),this.hasTriggered=!1,this.startTime=null}updateDisplay(t){this.container.textContent=this.formatNumber(t)}formatNumber(t){return Math.floor(t).toLocaleString()}updateConfig(t){const e=this.isRunning;this.stop(),this.config={...this.config,...t,onUpdate:void 0!==t.onUpdate?t.onUpdate:this.config.onUpdate,onComplete:void 0!==t.onComplete?t.onComplete:this.config.onComplete},void 0!==t.targetValue?(this.reset(),e&&this.config.enabled&&this.start()):e&&this.config.enabled&&this.start()}getValue(){return this.currentValue}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}function o(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const i=e-44032,n=Math.floor(i/588),s=Math.floor(i%588/28),o=i%28,a=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],r=[];return r.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),r.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),o>0&&r.push(a[o]),r}function a(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i],s=n.charCodeAt(0);if(s>=44032&&s<=55203){const t=o(n);e.push(...t)}else e.push(n)}return e}class r{constructor(t,e){if(this.originalChars=[],this.charUnitMap=[],this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.textUnits=a(this.config.text),this.originalChars=[],this.charUnitMap=[],this.initializeTextStructure(),this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.intersectionObserver=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.setupIntersectionObserver()}setupIntersectionObserver(){"undefined"!=typeof window&&void 0!==window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(t=>{var e;for(const i of t)i.target===this.container&&i.isIntersecting&&!this.hasTriggered&&(this.config.enabled&&setTimeout(()=>this.start(),this.config.delay),this.hasTriggered=!0,this.config.triggerOnce&&(null==(e=this.intersectionObserver)||e.disconnect()))},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}initializeTextStructure(){this.originalChars=[],this.charUnitMap=[];for(let t=0;t<this.originalText.length;t++){const e=this.originalText[t],i=e.charCodeAt(0);if(this.originalChars.push(e),i>=44032&&i<=55203){const t=o(e);this.charUnitMap.push(t.length)}else this.charUnitMap.push(1)}}getCharIndexFromUnitIndex(t){if(0===t)return 0;let e=0,i=0;for(let n=0;n<this.charUnitMap.length;n++){const s=this.charUnitMap[n];if(i+=s,!(t>=i)){const o=t-(i-s);if(o>0){const t=this.originalChars[n]&&this.originalChars[n].charCodeAt(0)>=44032&&this.originalChars[n].charCodeAt(0)<=55203;(t&&o>=2||!t&&o>=1)&&(e=n+1)}break}e=n+1}return e}buildTextFromUnits(t){if(0===t.length)return"";const e=this.getCharIndexFromUnitIndex(t.length);return this.originalText.substring(0,e)}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());const t=this.textUnits.slice(0,this.currentIndex+1);this.displayedText=this.buildTextFromUnits(t);let e=this.displayedText;this.config.showCursor&&(e+=this.config.cursorChar),this.updateDisplay(e),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){this.container.textContent=t}setText(t){this.originalText=t,this.config.text=t,this.textUnits=a(t),this.initializeTextStructure(),this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}const h=t.defineComponent({__name:"TextToParticle",props:{className:{default:""},style:{default:()=>({})},text:{default:"mason effect"},densityStep:{default:2},maxParticles:{default:3200},pointSize:{default:.5},ease:{default:.05},repelRadius:{default:150},repelStrength:{default:1},particleColor:{default:"#fff"},fontFamily:{default:"Inter, system-ui, Arial"},fontSize:{default:null},width:{default:null},height:{default:null},devicePixelRatio:{default:null},debounceDelay:{},onReady:{type:Function,default:null},onUpdate:{type:Function,default:null}},emits:["ready","update"],setup(e,{expose:n,emit:s}){const o=e,a=s,r=t.ref(null);let h=null;return t.watch(()=>[o.text,o.densityStep,o.maxParticles,o.pointSize,o.ease,o.repelRadius,o.repelStrength,o.particleColor,o.fontFamily,o.fontSize,o.width,o.height,o.devicePixelRatio],()=>{h&&h.updateConfig({text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={text:o.text,densityStep:o.densityStep,maxParticles:o.maxParticles,pointSize:o.pointSize,ease:o.ease,repelRadius:o.repelRadius,repelStrength:o.repelStrength,particleColor:o.particleColor,fontFamily:o.fontFamily,fontSize:o.fontSize,width:o.width,height:o.height,devicePixelRatio:o.devicePixelRatio,onReady:t=>{o.onReady&&o.onReady(t),a("ready",t)},onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)}};h=new i(r.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),n({morph:t=>{h&&h.morph(t)},scatter:()=>{h&&h.scatter()},updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),l=t.defineComponent({__name:"Count",props:{className:{default:""},style:{default:()=>({})},targetValue:{default:0},duration:{default:2e3},startValue:{default:0},enabled:{type:Boolean,default:!0},easing:{type:Function,default:()=>t=>t},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},onUpdate:{type:Function,default:null},onComplete:{type:Function,default:null}},emits:["update","complete"],setup(e,{expose:i,emit:n}){const o=e,a=n,r=t.ref(null);let h=null;return t.watch(()=>[o.targetValue,o.duration,o.startValue,o.enabled,o.easing,o.threshold,o.rootMargin,o.triggerOnce],()=>{h&&h.updateConfig({targetValue:o.targetValue,duration:o.duration,startValue:o.startValue,enabled:o.enabled,easing:o.easing,threshold:o.threshold,rootMargin:o.rootMargin,triggerOnce:o.triggerOnce,onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)},onComplete:()=>{o.onComplete&&o.onComplete(),a("complete")}})}),t.onMounted(()=>{(()=>{if(!r.value)return;const t={targetValue:o.targetValue,duration:o.duration,startValue:o.startValue,enabled:o.enabled,easing:o.easing,threshold:o.threshold,rootMargin:o.rootMargin,triggerOnce:o.triggerOnce,onUpdate:t=>{o.onUpdate&&o.onUpdate(t),a("update",t)},onComplete:()=>{o.onComplete&&o.onComplete(),a("complete")}};h=new s(r.value,t)})()}),t.onBeforeUnmount(()=>{h&&(h.destroy(),h=null)}),i({start:()=>{h&&h.start()},stop:()=>{h&&h.stop()},reset:()=>{h&&h.reset()},getValue:()=>h?h.getValue():0,updateConfig:t=>{h&&h.updateConfig(t)},destroy:()=>{h&&(h.destroy(),h=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:r,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}}),u=t.defineComponent({__name:"Typing",props:{className:{},style:{},onUpdate:{},onComplete:{},text:{},speed:{default:50},delay:{default:0},enabled:{type:Boolean,default:!0},threshold:{default:.2},rootMargin:{default:"0px 0px -100px 0px"},triggerOnce:{type:Boolean,default:!1},showCursor:{type:Boolean,default:!0},cursorChar:{default:"|"}},setup(e,{expose:i}){const n=e,s=t.ref(null),o=t.ref(null);return t.onMounted(()=>{if(!s.value)return;const t={text:n.text,speed:n.speed,delay:n.delay,enabled:n.enabled,threshold:n.threshold,rootMargin:n.rootMargin,triggerOnce:n.triggerOnce,showCursor:n.showCursor,cursorChar:n.cursorChar,onUpdate:n.onUpdate,onComplete:n.onComplete};o.value=new r(s.value,t)}),t.onUnmounted(()=>{o.value&&(o.value.destroy(),o.value=null)}),t.watch(()=>n.text,t=>{o.value&&t!==o.value.originalText&&o.value.setText(t)}),i({start:()=>{var t;return null==(t=o.value)?void 0:t.start()},stop:()=>{var t;return null==(t=o.value)?void 0:t.stop()},reset:()=>{var t;return null==(t=o.value)?void 0:t.reset()},setText:t=>{var e;return null==(e=o.value)?void 0:e.setText(t)},destroy:()=>{o.value&&(o.value.destroy(),o.value=null)}}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:s,class:t.normalizeClass(e.className),style:t.normalizeStyle(e.style)},null,6))}});exports.Count=l,exports.MasonEffect=h,exports.TextToParticle=h,exports.Typing=u,exports.default=h;
@@ -160,4 +160,56 @@ declare class TextToParticle {
160
160
  export { TextToParticleOptions as MasonEffectOptions }
161
161
  export { TextToParticleOptions }
162
162
 
163
+ export declare class Typing {
164
+ container: HTMLElement;
165
+ config: Required<Omit<TypingOptions, 'onUpdate' | 'onComplete'>> & {
166
+ onUpdate: TypingOptions['onUpdate'];
167
+ onComplete: TypingOptions['onComplete'];
168
+ };
169
+ textUnits: string[];
170
+ currentIndex: number;
171
+ displayedText: string;
172
+ timeoutId: ReturnType<typeof setTimeout> | null;
173
+ intersectionObserver: IntersectionObserver | null;
174
+ isRunning: boolean;
175
+ hasTriggered: boolean;
176
+ originalText: string;
177
+ constructor(container: HTMLElement | string, options: TypingOptions);
178
+ init(): void;
179
+ setupIntersectionObserver(): void;
180
+ private originalChars;
181
+ private charUnitMap;
182
+ private initializeTextStructure;
183
+ private getCharIndexFromUnitIndex;
184
+ private buildTextFromUnits;
185
+ start(): void;
186
+ typeNext(): void;
187
+ stop(): void;
188
+ reset(): void;
189
+ updateDisplay(text: string): void;
190
+ setText(newText: string): void;
191
+ destroy(): void;
192
+ }
193
+
194
+ /**
195
+ * Typing - 타이핑 애니메이션 효과
196
+ * 바닐라 JS 코어 클래스
197
+ *
198
+ * 사용법:
199
+ * import { Typing } from 'masoneffect/typing';
200
+ */
201
+ export declare interface TypingOptions {
202
+ text: string;
203
+ speed?: number;
204
+ delay?: number;
205
+ enabled?: boolean;
206
+ threshold?: number;
207
+ rootMargin?: string;
208
+ triggerOnce?: boolean;
209
+ showCursor?: boolean;
210
+ cursorChar?: string;
211
+ onUpdate?: (text: string) => void;
212
+ onComplete?: () => void;
213
+ }
214
+
163
215
  export { }
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, normalizeClass } from "vue";
1
+ import { defineComponent, ref, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeStyle, normalizeClass, onUnmounted } from "vue";
2
2
  function debounce(func, wait) {
3
3
  let timeout = null;
4
4
  return function executedFunction(...args) {
@@ -583,7 +583,228 @@ class Count {
583
583
  }
584
584
  }
585
585
  }
586
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
586
+ function decomposeHangul(char) {
587
+ const code = char.charCodeAt(0);
588
+ if (code < 44032 || code > 55203) {
589
+ return [char];
590
+ }
591
+ const base = code - 44032;
592
+ const initial = Math.floor(base / (21 * 28));
593
+ const medial = Math.floor(base % (21 * 28) / 28);
594
+ const final = base % 28;
595
+ const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
596
+ const medialChars = ["ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
597
+ const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
598
+ const result = [];
599
+ result.push(initialChars[initial]);
600
+ result.push(medialChars[medial]);
601
+ if (final > 0) {
602
+ result.push(finalChars[final]);
603
+ }
604
+ return result;
605
+ }
606
+ function decomposeText(text) {
607
+ const units = [];
608
+ for (let i = 0; i < text.length; i++) {
609
+ const char = text[i];
610
+ const code = char.charCodeAt(0);
611
+ if (code >= 44032 && code <= 55203) {
612
+ const decomposed = decomposeHangul(char);
613
+ units.push(...decomposed);
614
+ } else {
615
+ units.push(char);
616
+ }
617
+ }
618
+ return units;
619
+ }
620
+ class Typing {
621
+ // 원본 텍스트
622
+ constructor(container, options) {
623
+ this.originalChars = [];
624
+ this.charUnitMap = [];
625
+ this.container = typeof container === "string" ? document.querySelector(container) : container;
626
+ if (!this.container) {
627
+ throw new Error("Container element not found");
628
+ }
629
+ this.originalText = options.text;
630
+ this.config = {
631
+ text: options.text,
632
+ speed: options.speed ?? 50,
633
+ delay: options.delay ?? 0,
634
+ enabled: options.enabled ?? true,
635
+ threshold: options.threshold ?? 0.2,
636
+ rootMargin: options.rootMargin ?? "0px 0px -100px 0px",
637
+ triggerOnce: options.triggerOnce ?? false,
638
+ showCursor: options.showCursor ?? true,
639
+ cursorChar: options.cursorChar ?? "|",
640
+ onUpdate: options.onUpdate || null,
641
+ onComplete: options.onComplete || null
642
+ };
643
+ this.textUnits = decomposeText(this.config.text);
644
+ this.originalChars = [];
645
+ this.charUnitMap = [];
646
+ this.initializeTextStructure();
647
+ this.currentIndex = 0;
648
+ this.displayedText = "";
649
+ this.timeoutId = null;
650
+ this.intersectionObserver = null;
651
+ this.isRunning = false;
652
+ this.hasTriggered = false;
653
+ this.init();
654
+ }
655
+ init() {
656
+ this.updateDisplay("");
657
+ this.setupIntersectionObserver();
658
+ }
659
+ setupIntersectionObserver() {
660
+ if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
661
+ if (this.config.enabled) {
662
+ setTimeout(() => this.start(), this.config.delay);
663
+ }
664
+ return;
665
+ }
666
+ this.intersectionObserver = new IntersectionObserver(
667
+ (entries) => {
668
+ var _a;
669
+ for (const entry of entries) {
670
+ if (entry.target !== this.container) continue;
671
+ if (entry.isIntersecting && !this.hasTriggered) {
672
+ if (this.config.enabled) {
673
+ setTimeout(() => this.start(), this.config.delay);
674
+ }
675
+ this.hasTriggered = true;
676
+ if (this.config.triggerOnce) {
677
+ (_a = this.intersectionObserver) == null ? void 0 : _a.disconnect();
678
+ }
679
+ }
680
+ }
681
+ },
682
+ {
683
+ threshold: this.config.threshold,
684
+ rootMargin: this.config.rootMargin
685
+ }
686
+ );
687
+ this.intersectionObserver.observe(this.container);
688
+ }
689
+ // 각 글자에 해당하는 단위 개수
690
+ initializeTextStructure() {
691
+ this.originalChars = [];
692
+ this.charUnitMap = [];
693
+ for (let i = 0; i < this.originalText.length; i++) {
694
+ const char = this.originalText[i];
695
+ const code = char.charCodeAt(0);
696
+ this.originalChars.push(char);
697
+ if (code >= 44032 && code <= 55203) {
698
+ const decomposed = decomposeHangul(char);
699
+ this.charUnitMap.push(decomposed.length);
700
+ } else {
701
+ this.charUnitMap.push(1);
702
+ }
703
+ }
704
+ }
705
+ // 단위 인덱스를 원본 텍스트의 글자 인덱스로 변환
706
+ // unitIndex: 현재까지 입력된 단위 개수 (0부터 시작)
707
+ // 반환: 표시할 글자 개수 (0부터 시작, exclusive)
708
+ getCharIndexFromUnitIndex(unitIndex) {
709
+ if (unitIndex === 0) return 0;
710
+ let charIndex = 0;
711
+ let currentUnits = 0;
712
+ for (let i = 0; i < this.charUnitMap.length; i++) {
713
+ const unitsForChar = this.charUnitMap[i];
714
+ currentUnits += unitsForChar;
715
+ if (unitIndex >= currentUnits) {
716
+ charIndex = i + 1;
717
+ } else {
718
+ const unitsEntered = unitIndex - (currentUnits - unitsForChar);
719
+ if (unitsEntered > 0) {
720
+ const isHangul = this.originalChars[i] && this.originalChars[i].charCodeAt(0) >= 44032 && this.originalChars[i].charCodeAt(0) <= 55203;
721
+ if (isHangul && unitsEntered >= 2) {
722
+ charIndex = i + 1;
723
+ } else if (!isHangul && unitsEntered >= 1) {
724
+ charIndex = i + 1;
725
+ }
726
+ }
727
+ break;
728
+ }
729
+ }
730
+ return charIndex;
731
+ }
732
+ // 단위들을 다시 합쳐서 실제 표시할 텍스트 생성
733
+ buildTextFromUnits(units) {
734
+ if (units.length === 0) return "";
735
+ const charIndex = this.getCharIndexFromUnitIndex(units.length);
736
+ return this.originalText.substring(0, charIndex);
737
+ }
738
+ start() {
739
+ if (this.isRunning) return;
740
+ this.isRunning = true;
741
+ this.currentIndex = 0;
742
+ this.displayedText = "";
743
+ this.typeNext();
744
+ }
745
+ typeNext() {
746
+ if (this.currentIndex >= this.textUnits.length) {
747
+ this.isRunning = false;
748
+ if (this.config.showCursor) {
749
+ this.updateDisplay(this.originalText);
750
+ }
751
+ if (this.config.onComplete) {
752
+ this.config.onComplete();
753
+ }
754
+ return;
755
+ }
756
+ const unitsToShow = this.textUnits.slice(0, this.currentIndex + 1);
757
+ this.displayedText = this.buildTextFromUnits(unitsToShow);
758
+ let displayText = this.displayedText;
759
+ if (this.config.showCursor) {
760
+ displayText += this.config.cursorChar;
761
+ }
762
+ this.updateDisplay(displayText);
763
+ if (this.config.onUpdate) {
764
+ this.config.onUpdate(this.displayedText);
765
+ }
766
+ this.currentIndex++;
767
+ this.timeoutId = setTimeout(() => {
768
+ this.typeNext();
769
+ }, this.config.speed);
770
+ }
771
+ stop() {
772
+ this.isRunning = false;
773
+ if (this.timeoutId) {
774
+ clearTimeout(this.timeoutId);
775
+ this.timeoutId = null;
776
+ }
777
+ }
778
+ reset() {
779
+ this.stop();
780
+ this.currentIndex = 0;
781
+ this.displayedText = "";
782
+ this.hasTriggered = false;
783
+ this.updateDisplay("");
784
+ }
785
+ updateDisplay(text) {
786
+ this.container.textContent = text;
787
+ }
788
+ // 텍스트 변경
789
+ setText(newText) {
790
+ this.originalText = newText;
791
+ this.config.text = newText;
792
+ this.textUnits = decomposeText(newText);
793
+ this.initializeTextStructure();
794
+ this.reset();
795
+ if (this.config.enabled) {
796
+ setTimeout(() => this.start(), this.config.delay);
797
+ }
798
+ }
799
+ destroy() {
800
+ this.stop();
801
+ if (this.intersectionObserver) {
802
+ this.intersectionObserver.disconnect();
803
+ this.intersectionObserver = null;
804
+ }
805
+ }
806
+ }
807
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
587
808
  __name: "TextToParticle",
588
809
  props: {
589
810
  className: { default: "" },
@@ -710,7 +931,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
710
931
  };
711
932
  }
712
933
  });
713
- const _sfc_main = /* @__PURE__ */ defineComponent({
934
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
714
935
  __name: "Count",
715
936
  props: {
716
937
  className: { default: "" },
@@ -831,9 +1052,93 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
831
1052
  };
832
1053
  }
833
1054
  });
1055
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1056
+ __name: "Typing",
1057
+ props: {
1058
+ className: {},
1059
+ style: {},
1060
+ onUpdate: {},
1061
+ onComplete: {},
1062
+ text: {},
1063
+ speed: { default: 50 },
1064
+ delay: { default: 0 },
1065
+ enabled: { type: Boolean, default: true },
1066
+ threshold: { default: 0.2 },
1067
+ rootMargin: { default: "0px 0px -100px 0px" },
1068
+ triggerOnce: { type: Boolean, default: false },
1069
+ showCursor: { type: Boolean, default: true },
1070
+ cursorChar: { default: "|" }
1071
+ },
1072
+ setup(__props, { expose: __expose }) {
1073
+ const props = __props;
1074
+ const containerRef = ref(null);
1075
+ const instanceRef = ref(null);
1076
+ onMounted(() => {
1077
+ if (!containerRef.value) return;
1078
+ const options = {
1079
+ text: props.text,
1080
+ speed: props.speed,
1081
+ delay: props.delay,
1082
+ enabled: props.enabled,
1083
+ threshold: props.threshold,
1084
+ rootMargin: props.rootMargin,
1085
+ triggerOnce: props.triggerOnce,
1086
+ showCursor: props.showCursor,
1087
+ cursorChar: props.cursorChar,
1088
+ onUpdate: props.onUpdate,
1089
+ onComplete: props.onComplete
1090
+ };
1091
+ instanceRef.value = new Typing(containerRef.value, options);
1092
+ });
1093
+ onUnmounted(() => {
1094
+ if (instanceRef.value) {
1095
+ instanceRef.value.destroy();
1096
+ instanceRef.value = null;
1097
+ }
1098
+ });
1099
+ watch(() => props.text, (newText) => {
1100
+ if (instanceRef.value && newText !== instanceRef.value["originalText"]) {
1101
+ instanceRef.value.setText(newText);
1102
+ }
1103
+ });
1104
+ __expose({
1105
+ start: () => {
1106
+ var _a;
1107
+ return (_a = instanceRef.value) == null ? void 0 : _a.start();
1108
+ },
1109
+ stop: () => {
1110
+ var _a;
1111
+ return (_a = instanceRef.value) == null ? void 0 : _a.stop();
1112
+ },
1113
+ reset: () => {
1114
+ var _a;
1115
+ return (_a = instanceRef.value) == null ? void 0 : _a.reset();
1116
+ },
1117
+ setText: (text) => {
1118
+ var _a;
1119
+ return (_a = instanceRef.value) == null ? void 0 : _a.setText(text);
1120
+ },
1121
+ destroy: () => {
1122
+ if (instanceRef.value) {
1123
+ instanceRef.value.destroy();
1124
+ instanceRef.value = null;
1125
+ }
1126
+ }
1127
+ });
1128
+ return (_ctx, _cache) => {
1129
+ return openBlock(), createElementBlock("div", {
1130
+ ref_key: "containerRef",
1131
+ ref: containerRef,
1132
+ class: normalizeClass(__props.className),
1133
+ style: normalizeStyle(__props.style)
1134
+ }, null, 6);
1135
+ };
1136
+ }
1137
+ });
834
1138
  export {
835
- _sfc_main as Count,
836
- _sfc_main$1 as MasonEffect,
837
- _sfc_main$1 as TextToParticle,
838
- _sfc_main$1 as default
1139
+ _sfc_main$1 as Count,
1140
+ _sfc_main$2 as MasonEffect,
1141
+ _sfc_main$2 as TextToParticle,
1142
+ _sfc_main as Typing,
1143
+ _sfc_main$2 as default
839
1144
  };
@@ -160,4 +160,56 @@ declare class TextToParticle {
160
160
  export { TextToParticleOptions as MasonEffectOptions }
161
161
  export { TextToParticleOptions }
162
162
 
163
+ export declare class Typing {
164
+ container: HTMLElement;
165
+ config: Required<Omit<TypingOptions, 'onUpdate' | 'onComplete'>> & {
166
+ onUpdate: TypingOptions['onUpdate'];
167
+ onComplete: TypingOptions['onComplete'];
168
+ };
169
+ textUnits: string[];
170
+ currentIndex: number;
171
+ displayedText: string;
172
+ timeoutId: ReturnType<typeof setTimeout> | null;
173
+ intersectionObserver: IntersectionObserver | null;
174
+ isRunning: boolean;
175
+ hasTriggered: boolean;
176
+ originalText: string;
177
+ constructor(container: HTMLElement | string, options: TypingOptions);
178
+ init(): void;
179
+ setupIntersectionObserver(): void;
180
+ private originalChars;
181
+ private charUnitMap;
182
+ private initializeTextStructure;
183
+ private getCharIndexFromUnitIndex;
184
+ private buildTextFromUnits;
185
+ start(): void;
186
+ typeNext(): void;
187
+ stop(): void;
188
+ reset(): void;
189
+ updateDisplay(text: string): void;
190
+ setText(newText: string): void;
191
+ destroy(): void;
192
+ }
193
+
194
+ /**
195
+ * Typing - 타이핑 애니메이션 효과
196
+ * 바닐라 JS 코어 클래스
197
+ *
198
+ * 사용법:
199
+ * import { Typing } from 'masoneffect/typing';
200
+ */
201
+ export declare interface TypingOptions {
202
+ text: string;
203
+ speed?: number;
204
+ delay?: number;
205
+ enabled?: boolean;
206
+ threshold?: number;
207
+ rootMargin?: string;
208
+ triggerOnce?: boolean;
209
+ showCursor?: boolean;
210
+ cursorChar?: string;
211
+ onUpdate?: (text: string) => void;
212
+ onComplete?: () => void;
213
+ }
214
+
163
215
  export { }