masoneffect 2.0.2 → 2.0.4

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 +53 -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 +53 -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 +52 -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 +53 -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 +53 -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 +53 -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 +53 -0
  131. package/dist/svelte/index.cjs +1 -1
  132. package/dist/svelte/index.d.ts +53 -0
  133. package/dist/svelte/index.mjs +419 -48
  134. package/dist/svelte/textToParticle/index.d.ts +53 -0
  135. package/dist/svelte/typing/index.cjs +1 -0
  136. package/dist/svelte/typing/index.d.ts +216 -0
  137. package/dist/svelte/typing/index.mjs +638 -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 +53 -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 +53 -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 +53 -0
  205. package/dist/vue/index.cjs +1 -1
  206. package/dist/vue/index.d.ts +53 -0
  207. package/dist/vue/index.mjs +316 -7
  208. package/dist/vue/textToParticle/index.d.ts +53 -0
  209. package/dist/vue/typing/index.cjs +1 -0
  210. package/dist/vue/typing/index.d.ts +216 -0
  211. package/dist/vue/typing/index.mjs +312 -0
  212. package/package.json +25 -3
@@ -160,4 +160,57 @@ 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
+ charUnitRanges: Array<{
171
+ start: number;
172
+ end: number;
173
+ isHangul: boolean;
174
+ }>;
175
+ currentIndex: number;
176
+ displayedText: string;
177
+ timeoutId: ReturnType<typeof setTimeout> | null;
178
+ intersectionObserver: IntersectionObserver | null;
179
+ isRunning: boolean;
180
+ hasTriggered: boolean;
181
+ originalText: string;
182
+ constructor(container: HTMLElement | string, options: TypingOptions);
183
+ init(): void;
184
+ setupIntersectionObserver(): void;
185
+ private buildTextFromUnits;
186
+ start(): void;
187
+ typeNext(): void;
188
+ stop(): void;
189
+ reset(): void;
190
+ updateDisplay(text: string): void;
191
+ setText(newText: string): void;
192
+ destroy(): void;
193
+ }
194
+
195
+ /**
196
+ * Typing - 타이핑 애니메이션 효과
197
+ * 바닐라 JS 코어 클래스
198
+ *
199
+ * 사용법:
200
+ * import { Typing } from 'masoneffect/typing';
201
+ */
202
+ export declare interface TypingOptions {
203
+ text: string;
204
+ speed?: number;
205
+ delay?: number;
206
+ enabled?: boolean;
207
+ threshold?: number;
208
+ rootMargin?: string;
209
+ triggerOnce?: boolean;
210
+ showCursor?: boolean;
211
+ cursorChar?: string;
212
+ onUpdate?: (text: string) => void;
213
+ onComplete?: () => void;
214
+ }
215
+
163
216
  export { }
@@ -22,6 +22,19 @@ function safe_not_equal(a, b) {
22
22
  function is_empty(obj) {
23
23
  return Object.keys(obj).length === 0;
24
24
  }
25
+ function subscribe(store, ...callbacks) {
26
+ if (store == null) {
27
+ for (const callback of callbacks) {
28
+ callback(void 0);
29
+ }
30
+ return noop;
31
+ }
32
+ const unsub = store.subscribe(...callbacks);
33
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
34
+ }
35
+ function component_subscribe(component, store, callback) {
36
+ component.$$.on_destroy.push(subscribe(store, callback));
37
+ }
25
38
  function insert(target, node, anchor) {
26
39
  target.insertBefore(node, anchor || null);
27
40
  }
@@ -155,14 +168,14 @@ function make_dirty(component, i) {
155
168
  }
156
169
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
157
170
  }
158
- function init(component, options, instance, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
171
+ function init(component, options, instance2, create_fragment2, not_equal, props2, append_styles = null, dirty = [-1]) {
159
172
  const parent_component = current_component;
160
173
  set_current_component(component);
161
174
  const $$ = component.$$ = {
162
175
  fragment: null,
163
176
  ctx: [],
164
177
  // state
165
- props,
178
+ props: props2,
166
179
  update: noop,
167
180
  not_equal,
168
181
  bound: blank_object(),
@@ -181,7 +194,7 @@ function init(component, options, instance, create_fragment2, not_equal, props,
181
194
  };
182
195
  append_styles && append_styles($$.root);
183
196
  let ready = false;
184
- $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
197
+ $$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
185
198
  const value = rest.length ? rest[0] : ret;
186
199
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
187
200
  if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
@@ -252,10 +265,10 @@ class SvelteComponent {
252
265
  * @param {Partial<Props>} props
253
266
  * @returns {void}
254
267
  */
255
- $set(props) {
256
- if (this.$$set && !is_empty(props)) {
268
+ $set(props2) {
269
+ if (this.$$set && !is_empty(props2)) {
257
270
  this.$$.skip_bound = true;
258
- this.$$set(props);
271
+ this.$$set(props2);
259
272
  this.$$.skip_bound = false;
260
273
  }
261
274
  }
@@ -847,7 +860,232 @@ class Count {
847
860
  }
848
861
  }
849
862
  }
850
- function create_fragment$1(ctx) {
863
+ function decomposeHangul(char) {
864
+ const code = char.charCodeAt(0);
865
+ if (code < 44032 || code > 55203) {
866
+ return [char];
867
+ }
868
+ const base = code - 44032;
869
+ const initial = Math.floor(base / (21 * 28));
870
+ const medial = Math.floor(base % (21 * 28) / 28);
871
+ const final = base % 28;
872
+ const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
873
+ const medialChars = ["ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
874
+ const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
875
+ const result = [];
876
+ result.push(initialChars[initial]);
877
+ result.push(medialChars[medial]);
878
+ if (final > 0) {
879
+ result.push(finalChars[final]);
880
+ }
881
+ return result;
882
+ }
883
+ function composeHangul(initial, medial, final) {
884
+ const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
885
+ const medialChars = ["ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
886
+ const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
887
+ const initialIndex = initialChars.indexOf(initial);
888
+ const medialIndex = medialChars.indexOf(medial);
889
+ const finalIndex = final ? finalChars.indexOf(final) : 0;
890
+ if (initialIndex === -1 || medialIndex === -1) {
891
+ return initial + (medial || "") + (final || "");
892
+ }
893
+ const code = 44032 + initialIndex * 21 * 28 + medialIndex * 28 + finalIndex;
894
+ return String.fromCharCode(code);
895
+ }
896
+ function decomposeText(text) {
897
+ const units = [];
898
+ const charUnitRanges = [];
899
+ for (let i = 0; i < text.length; i++) {
900
+ const char = text[i];
901
+ const code = char.charCodeAt(0);
902
+ const startIndex = units.length;
903
+ if (code >= 44032 && code <= 55203) {
904
+ const decomposed = decomposeHangul(char);
905
+ units.push(...decomposed);
906
+ charUnitRanges.push({
907
+ start: startIndex,
908
+ end: units.length,
909
+ isHangul: true
910
+ });
911
+ } else {
912
+ units.push(char);
913
+ charUnitRanges.push({
914
+ start: startIndex,
915
+ end: units.length,
916
+ isHangul: false
917
+ });
918
+ }
919
+ }
920
+ return { units, charUnitRanges };
921
+ }
922
+ class Typing {
923
+ // 원본 텍스트
924
+ constructor(container, options) {
925
+ this.container = typeof container === "string" ? document.querySelector(container) : container;
926
+ if (!this.container) {
927
+ throw new Error("Container element not found");
928
+ }
929
+ this.originalText = options.text;
930
+ this.config = {
931
+ text: options.text,
932
+ speed: options.speed ?? 50,
933
+ delay: options.delay ?? 0,
934
+ enabled: options.enabled ?? true,
935
+ threshold: options.threshold ?? 0.2,
936
+ rootMargin: options.rootMargin ?? "0px 0px -100px 0px",
937
+ triggerOnce: options.triggerOnce ?? false,
938
+ showCursor: options.showCursor ?? true,
939
+ cursorChar: options.cursorChar ?? "|",
940
+ onUpdate: options.onUpdate || null,
941
+ onComplete: options.onComplete || null
942
+ };
943
+ const decomposed = decomposeText(this.config.text);
944
+ this.textUnits = decomposed.units;
945
+ this.charUnitRanges = decomposed.charUnitRanges;
946
+ this.currentIndex = 0;
947
+ this.displayedText = "";
948
+ this.timeoutId = null;
949
+ this.intersectionObserver = null;
950
+ this.isRunning = false;
951
+ this.hasTriggered = false;
952
+ this.init();
953
+ }
954
+ init() {
955
+ this.updateDisplay("");
956
+ this.setupIntersectionObserver();
957
+ }
958
+ setupIntersectionObserver() {
959
+ if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
960
+ if (this.config.enabled) {
961
+ setTimeout(() => this.start(), this.config.delay);
962
+ }
963
+ return;
964
+ }
965
+ this.intersectionObserver = new IntersectionObserver(
966
+ (entries) => {
967
+ var _a;
968
+ for (const entry of entries) {
969
+ if (entry.target !== this.container) continue;
970
+ if (entry.isIntersecting && !this.hasTriggered) {
971
+ if (this.config.enabled) {
972
+ setTimeout(() => this.start(), this.config.delay);
973
+ }
974
+ this.hasTriggered = true;
975
+ if (this.config.triggerOnce) {
976
+ (_a = this.intersectionObserver) == null ? void 0 : _a.disconnect();
977
+ }
978
+ }
979
+ }
980
+ },
981
+ {
982
+ threshold: this.config.threshold,
983
+ rootMargin: this.config.rootMargin
984
+ }
985
+ );
986
+ this.intersectionObserver.observe(this.container);
987
+ }
988
+ // 단위들을 다시 합쳐서 실제 표시할 텍스트 생성
989
+ // 한글의 경우 자음/모음이 하나씩 보이도록 합성
990
+ buildTextFromUnits(unitCount) {
991
+ if (unitCount === 0) return "";
992
+ let result = "";
993
+ for (let charIndex = 0; charIndex < this.charUnitRanges.length; charIndex++) {
994
+ const range = this.charUnitRanges[charIndex];
995
+ if (range.start >= unitCount) {
996
+ break;
997
+ }
998
+ const unitsEntered = Math.min(unitCount - range.start, range.end - range.start);
999
+ if (unitsEntered <= 0) {
1000
+ break;
1001
+ }
1002
+ if (range.isHangul) {
1003
+ const charUnits = this.textUnits.slice(range.start, range.start + unitsEntered);
1004
+ if (charUnits.length === 1) {
1005
+ result += charUnits[0];
1006
+ } else if (charUnits.length === 2) {
1007
+ result += composeHangul(charUnits[0], charUnits[1]);
1008
+ } else if (charUnits.length >= 3) {
1009
+ result += composeHangul(charUnits[0], charUnits[1], charUnits[2]);
1010
+ }
1011
+ } else {
1012
+ if (unitsEntered > 0) {
1013
+ result += this.textUnits[range.start];
1014
+ }
1015
+ }
1016
+ }
1017
+ return result;
1018
+ }
1019
+ start() {
1020
+ if (this.isRunning) return;
1021
+ this.isRunning = true;
1022
+ this.currentIndex = 0;
1023
+ this.displayedText = "";
1024
+ this.typeNext();
1025
+ }
1026
+ typeNext() {
1027
+ if (this.currentIndex >= this.textUnits.length) {
1028
+ this.isRunning = false;
1029
+ if (this.config.showCursor) {
1030
+ this.updateDisplay(this.originalText);
1031
+ }
1032
+ if (this.config.onComplete) {
1033
+ this.config.onComplete();
1034
+ }
1035
+ return;
1036
+ }
1037
+ this.displayedText = this.buildTextFromUnits(this.currentIndex + 1);
1038
+ let displayText = this.displayedText;
1039
+ if (this.config.showCursor) {
1040
+ displayText += this.config.cursorChar;
1041
+ }
1042
+ this.updateDisplay(displayText);
1043
+ if (this.config.onUpdate) {
1044
+ this.config.onUpdate(this.displayedText);
1045
+ }
1046
+ this.currentIndex++;
1047
+ this.timeoutId = setTimeout(() => {
1048
+ this.typeNext();
1049
+ }, this.config.speed);
1050
+ }
1051
+ stop() {
1052
+ this.isRunning = false;
1053
+ if (this.timeoutId) {
1054
+ clearTimeout(this.timeoutId);
1055
+ this.timeoutId = null;
1056
+ }
1057
+ }
1058
+ reset() {
1059
+ this.stop();
1060
+ this.currentIndex = 0;
1061
+ this.displayedText = "";
1062
+ this.hasTriggered = false;
1063
+ this.updateDisplay("");
1064
+ }
1065
+ updateDisplay(text) {
1066
+ this.container.textContent = text;
1067
+ }
1068
+ // 텍스트 변경
1069
+ setText(newText) {
1070
+ this.originalText = newText;
1071
+ this.config.text = newText;
1072
+ const decomposed = decomposeText(newText);
1073
+ this.textUnits = decomposed.units;
1074
+ this.charUnitRanges = decomposed.charUnitRanges;
1075
+ this.reset();
1076
+ if (this.config.enabled) {
1077
+ setTimeout(() => this.start(), this.config.delay);
1078
+ }
1079
+ }
1080
+ destroy() {
1081
+ this.stop();
1082
+ if (this.intersectionObserver) {
1083
+ this.intersectionObserver.disconnect();
1084
+ this.intersectionObserver = null;
1085
+ }
1086
+ }
1087
+ }
1088
+ function create_fragment$2(ctx) {
851
1089
  let div;
852
1090
  return {
853
1091
  c() {
@@ -917,7 +1155,7 @@ function instance_1$1($$self, $$props, $$invalidate) {
917
1155
  let { style = {} } = $$props;
918
1156
  const dispatch = createEventDispatcher();
919
1157
  let container;
920
- let instance = null;
1158
+ let instance2 = null;
921
1159
  onMount(() => {
922
1160
  if (!container) return;
923
1161
  const options = {
@@ -941,33 +1179,33 @@ function instance_1$1($$self, $$props, $$invalidate) {
941
1179
  dispatch("update", inst);
942
1180
  }
943
1181
  };
944
- $$invalidate(20, instance = new TextToParticle(container, options));
1182
+ $$invalidate(20, instance2 = new TextToParticle(container, options));
945
1183
  });
946
1184
  onDestroy(() => {
947
- if (instance) {
948
- instance.destroy();
949
- $$invalidate(20, instance = null);
1185
+ if (instance2) {
1186
+ instance2.destroy();
1187
+ $$invalidate(20, instance2 = null);
950
1188
  }
951
1189
  });
952
1190
  function morph(textOrOptions) {
953
- if (instance) {
954
- instance.morph(textOrOptions);
1191
+ if (instance2) {
1192
+ instance2.morph(textOrOptions);
955
1193
  }
956
1194
  }
957
1195
  function scatter() {
958
- if (instance) {
959
- instance.scatter();
1196
+ if (instance2) {
1197
+ instance2.scatter();
960
1198
  }
961
1199
  }
962
1200
  function updateConfig(config) {
963
- if (instance) {
964
- instance.updateConfig(config);
1201
+ if (instance2) {
1202
+ instance2.updateConfig(config);
965
1203
  }
966
1204
  }
967
1205
  function destroy() {
968
- if (instance) {
969
- instance.destroy();
970
- $$invalidate(20, instance = null);
1206
+ if (instance2) {
1207
+ instance2.destroy();
1208
+ $$invalidate(20, instance2 = null);
971
1209
  }
972
1210
  }
973
1211
  function div_binding($$value) {
@@ -997,8 +1235,8 @@ function instance_1$1($$self, $$props, $$invalidate) {
997
1235
  if ($$self.$$.dirty & /*instance, text, densityStep, maxParticles, pointSize, ease, repelRadius, repelStrength, particleColor, fontFamily, fontSize, width, height, devicePixelRatio*/
998
1236
  1114104) {
999
1237
  {
1000
- if (instance) {
1001
- instance.updateConfig({
1238
+ if (instance2) {
1239
+ instance2.updateConfig({
1002
1240
  text,
1003
1241
  densityStep,
1004
1242
  maxParticles,
@@ -1038,14 +1276,14 @@ function instance_1$1($$self, $$props, $$invalidate) {
1038
1276
  scatter,
1039
1277
  updateConfig,
1040
1278
  destroy,
1041
- instance,
1279
+ instance2,
1042
1280
  div_binding
1043
1281
  ];
1044
1282
  }
1045
1283
  class TextToParticle_1 extends SvelteComponent {
1046
1284
  constructor(options) {
1047
1285
  super();
1048
- init(this, options, instance_1$1, create_fragment$1, safe_not_equal, {
1286
+ init(this, options, instance_1$1, create_fragment$2, safe_not_equal, {
1049
1287
  text: 3,
1050
1288
  densityStep: 4,
1051
1289
  maxParticles: 5,
@@ -1080,7 +1318,7 @@ class TextToParticle_1 extends SvelteComponent {
1080
1318
  return this.$$.ctx[19];
1081
1319
  }
1082
1320
  }
1083
- function create_fragment(ctx) {
1321
+ function create_fragment$1(ctx) {
1084
1322
  let div;
1085
1323
  return {
1086
1324
  c() {
@@ -1145,7 +1383,7 @@ function instance_1($$self, $$props, $$invalidate) {
1145
1383
  let { style = {} } = $$props;
1146
1384
  const dispatch = createEventDispatcher();
1147
1385
  let container;
1148
- let instance = null;
1386
+ let instance2 = null;
1149
1387
  onMount(() => {
1150
1388
  if (!container) return;
1151
1389
  const options = {
@@ -1164,44 +1402,44 @@ function instance_1($$self, $$props, $$invalidate) {
1164
1402
  dispatch("complete");
1165
1403
  }
1166
1404
  };
1167
- $$invalidate(17, instance = new Count(container, options));
1405
+ $$invalidate(17, instance2 = new Count(container, options));
1168
1406
  });
1169
1407
  onDestroy(() => {
1170
- if (instance) {
1171
- instance.destroy();
1172
- $$invalidate(17, instance = null);
1408
+ if (instance2) {
1409
+ instance2.destroy();
1410
+ $$invalidate(17, instance2 = null);
1173
1411
  }
1174
1412
  });
1175
1413
  function start() {
1176
- if (instance) {
1177
- instance.start();
1414
+ if (instance2) {
1415
+ instance2.start();
1178
1416
  }
1179
1417
  }
1180
1418
  function stop() {
1181
- if (instance) {
1182
- instance.stop();
1419
+ if (instance2) {
1420
+ instance2.stop();
1183
1421
  }
1184
1422
  }
1185
1423
  function reset() {
1186
- if (instance) {
1187
- instance.reset();
1424
+ if (instance2) {
1425
+ instance2.reset();
1188
1426
  }
1189
1427
  }
1190
1428
  function getValue() {
1191
- if (instance) {
1192
- return instance.getValue();
1429
+ if (instance2) {
1430
+ return instance2.getValue();
1193
1431
  }
1194
1432
  return 0;
1195
1433
  }
1196
1434
  function updateConfig(config) {
1197
- if (instance) {
1198
- instance.updateConfig(config);
1435
+ if (instance2) {
1436
+ instance2.updateConfig(config);
1199
1437
  }
1200
1438
  }
1201
1439
  function destroy() {
1202
- if (instance) {
1203
- instance.destroy();
1204
- $$invalidate(17, instance = null);
1440
+ if (instance2) {
1441
+ instance2.destroy();
1442
+ $$invalidate(17, instance2 = null);
1205
1443
  }
1206
1444
  }
1207
1445
  function div_binding($$value) {
@@ -1226,8 +1464,8 @@ function instance_1($$self, $$props, $$invalidate) {
1226
1464
  if ($$self.$$.dirty & /*instance, targetValue, duration, startValue, enabled, easing, threshold, rootMargin, triggerOnce*/
1227
1465
  133112) {
1228
1466
  {
1229
- if (instance) {
1230
- instance.updateConfig({
1467
+ if (instance2) {
1468
+ instance2.updateConfig({
1231
1469
  targetValue,
1232
1470
  duration,
1233
1471
  startValue,
@@ -1265,14 +1503,14 @@ function instance_1($$self, $$props, $$invalidate) {
1265
1503
  getValue,
1266
1504
  updateConfig,
1267
1505
  destroy,
1268
- instance,
1506
+ instance2,
1269
1507
  div_binding
1270
1508
  ];
1271
1509
  }
1272
1510
  class Count_1 extends SvelteComponent {
1273
1511
  constructor(options) {
1274
1512
  super();
1275
- init(this, options, instance_1, create_fragment, safe_not_equal, {
1513
+ init(this, options, instance_1, create_fragment$1, safe_not_equal, {
1276
1514
  targetValue: 3,
1277
1515
  duration: 4,
1278
1516
  startValue: 5,
@@ -1310,9 +1548,142 @@ class Count_1 extends SvelteComponent {
1310
1548
  return this.$$.ctx[16];
1311
1549
  }
1312
1550
  }
1551
+ function create_fragment(ctx) {
1552
+ let div;
1553
+ return {
1554
+ c() {
1555
+ div = element("div");
1556
+ attr(
1557
+ div,
1558
+ "class",
1559
+ /*className*/
1560
+ ctx[1]
1561
+ );
1562
+ attr(
1563
+ div,
1564
+ "style",
1565
+ /*style*/
1566
+ ctx[2]
1567
+ );
1568
+ },
1569
+ m(target, anchor) {
1570
+ insert(target, div, anchor);
1571
+ ctx[8](div);
1572
+ },
1573
+ p: noop,
1574
+ i: noop,
1575
+ o: noop,
1576
+ d(detaching) {
1577
+ if (detaching) {
1578
+ detach(div);
1579
+ }
1580
+ ctx[8](null);
1581
+ }
1582
+ };
1583
+ }
1584
+ function instance($$self, $$props, $$invalidate) {
1585
+ let $effect;
1586
+ let $props;
1587
+ component_subscribe($$self, effect, ($$value) => $$invalidate(10, $effect = $$value));
1588
+ component_subscribe($$self, props, ($$value) => $$invalidate(11, $props = $$value));
1589
+ let { text, speed = 50, delay = 0, enabled = true, threshold = 0.2, rootMargin = "0px 0px -100px 0px", triggerOnce = false, showCursor = true, cursorChar = "|", className = "", style = "", onUpdate, onComplete } = $props();
1590
+ let containerRef = null;
1591
+ let instanceRef = null;
1592
+ onMount(() => {
1593
+ if (!containerRef) return;
1594
+ const options = {
1595
+ text,
1596
+ speed,
1597
+ delay,
1598
+ enabled,
1599
+ threshold,
1600
+ rootMargin,
1601
+ triggerOnce,
1602
+ showCursor,
1603
+ cursorChar,
1604
+ onUpdate,
1605
+ onComplete
1606
+ };
1607
+ instanceRef = new Typing(containerRef, options);
1608
+ });
1609
+ onDestroy(() => {
1610
+ if (instanceRef) {
1611
+ instanceRef.destroy();
1612
+ instanceRef = null;
1613
+ }
1614
+ });
1615
+ $effect(() => {
1616
+ if (instanceRef && text !== instanceRef["originalText"]) {
1617
+ instanceRef.setText(text);
1618
+ }
1619
+ });
1620
+ function start() {
1621
+ instanceRef == null ? void 0 : instanceRef.start();
1622
+ }
1623
+ function stop() {
1624
+ instanceRef == null ? void 0 : instanceRef.stop();
1625
+ }
1626
+ function reset() {
1627
+ instanceRef == null ? void 0 : instanceRef.reset();
1628
+ }
1629
+ function setText(newText) {
1630
+ instanceRef == null ? void 0 : instanceRef.setText(newText);
1631
+ }
1632
+ function destroy() {
1633
+ if (instanceRef) {
1634
+ instanceRef.destroy();
1635
+ instanceRef = null;
1636
+ }
1637
+ }
1638
+ function div_binding($$value) {
1639
+ binding_callbacks[$$value ? "unshift" : "push"](() => {
1640
+ containerRef = $$value;
1641
+ $$invalidate(0, containerRef);
1642
+ });
1643
+ }
1644
+ return [
1645
+ containerRef,
1646
+ className,
1647
+ style,
1648
+ start,
1649
+ stop,
1650
+ reset,
1651
+ setText,
1652
+ destroy,
1653
+ div_binding
1654
+ ];
1655
+ }
1656
+ class Typing_1 extends SvelteComponent {
1657
+ constructor(options) {
1658
+ super();
1659
+ init(this, options, instance, create_fragment, safe_not_equal, {
1660
+ start: 3,
1661
+ stop: 4,
1662
+ reset: 5,
1663
+ setText: 6,
1664
+ destroy: 7
1665
+ });
1666
+ }
1667
+ get start() {
1668
+ return this.$$.ctx[3];
1669
+ }
1670
+ get stop() {
1671
+ return this.$$.ctx[4];
1672
+ }
1673
+ get reset() {
1674
+ return this.$$.ctx[5];
1675
+ }
1676
+ get setText() {
1677
+ return this.$$.ctx[6];
1678
+ }
1679
+ get destroy() {
1680
+ return this.$$.ctx[7];
1681
+ }
1682
+ }
1313
1683
  export {
1314
1684
  Count_1 as Count,
1315
1685
  TextToParticle_1 as MasonEffect,
1316
1686
  TextToParticle_1 as TextToParticle,
1687
+ Typing_1 as Typing,
1317
1688
  TextToParticle_1 as default
1318
1689
  };