masoneffect 2.0.4 → 2.0.5

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 (101) hide show
  1. package/README.md +2 -2
  2. package/dist/core/count/index.d.ts +3 -2
  3. package/dist/core/count/index.d.ts.map +1 -1
  4. package/dist/core/textToParticle/index.d.ts +3 -3
  5. package/dist/core/textToParticle/index.d.ts.map +1 -1
  6. package/dist/core/typing/index.d.ts +3 -2
  7. package/dist/core/typing/index.d.ts.map +1 -1
  8. package/dist/core/utils/visibilityManager.d.ts +35 -0
  9. package/dist/core/utils/visibilityManager.d.ts.map +1 -0
  10. package/dist/count/core/count/index.d.ts +3 -2
  11. package/dist/count/core/count/index.d.ts.map +1 -1
  12. package/dist/count/core/textToParticle/index.d.ts +3 -3
  13. package/dist/count/core/textToParticle/index.d.ts.map +1 -1
  14. package/dist/count/core/typing/index.d.ts +3 -2
  15. package/dist/count/core/typing/index.d.ts.map +1 -1
  16. package/dist/count/core/utils/visibilityManager.d.ts +35 -0
  17. package/dist/count/core/utils/visibilityManager.d.ts.map +1 -0
  18. package/dist/count/index.cjs +1 -1
  19. package/dist/count/index.mjs +1 -1
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.mjs +1 -1
  22. package/dist/index.umd.min.js +1 -1
  23. package/dist/react/core/count/index.d.ts +3 -2
  24. package/dist/react/core/textToParticle/index.d.ts +3 -3
  25. package/dist/react/core/typing/index.d.ts +3 -2
  26. package/dist/react/core/utils/visibilityManager.d.ts +34 -0
  27. package/dist/react/count/core/count/index.d.ts +3 -2
  28. package/dist/react/count/core/count/index.d.ts.map +1 -1
  29. package/dist/react/count/core/textToParticle/index.d.ts +3 -3
  30. package/dist/react/count/core/textToParticle/index.d.ts.map +1 -1
  31. package/dist/react/count/core/typing/index.d.ts +3 -2
  32. package/dist/react/count/core/typing/index.d.ts.map +1 -1
  33. package/dist/react/count/core/utils/visibilityManager.d.ts +35 -0
  34. package/dist/react/count/core/utils/visibilityManager.d.ts.map +1 -0
  35. package/dist/react/count/index.cjs +1 -1
  36. package/dist/react/count/index.mjs +1 -1
  37. package/dist/react/textToParticle/core/count/index.d.ts +3 -2
  38. package/dist/react/textToParticle/core/count/index.d.ts.map +1 -1
  39. package/dist/react/textToParticle/core/textToParticle/index.d.ts +3 -3
  40. package/dist/react/textToParticle/core/textToParticle/index.d.ts.map +1 -1
  41. package/dist/react/textToParticle/core/typing/index.d.ts +3 -2
  42. package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -1
  43. package/dist/react/textToParticle/core/utils/visibilityManager.d.ts +35 -0
  44. package/dist/react/textToParticle/core/utils/visibilityManager.d.ts.map +1 -0
  45. package/dist/react/textToParticle/index.cjs +1 -1
  46. package/dist/react/textToParticle/index.mjs +1 -1
  47. package/dist/react/typing/core/count/index.d.ts +3 -2
  48. package/dist/react/typing/core/count/index.d.ts.map +1 -1
  49. package/dist/react/typing/core/textToParticle/index.d.ts +3 -3
  50. package/dist/react/typing/core/textToParticle/index.d.ts.map +1 -1
  51. package/dist/react/typing/core/typing/index.d.ts +3 -2
  52. package/dist/react/typing/core/typing/index.d.ts.map +1 -1
  53. package/dist/react/typing/core/utils/visibilityManager.d.ts +35 -0
  54. package/dist/react/typing/core/utils/visibilityManager.d.ts.map +1 -0
  55. package/dist/react/typing/index.cjs +1 -1
  56. package/dist/react/typing/index.mjs +1 -1
  57. package/dist/svelte/count/index.cjs +1 -1
  58. package/dist/svelte/count/index.d.ts +41 -28
  59. package/dist/svelte/count/index.mjs +120 -42
  60. package/dist/svelte/index.cjs +1 -1
  61. package/dist/svelte/index.d.ts +41 -28
  62. package/dist/svelte/index.mjs +154 -107
  63. package/dist/svelte/textToParticle/index.cjs +1 -1
  64. package/dist/svelte/textToParticle/index.d.ts +41 -28
  65. package/dist/svelte/textToParticle/index.mjs +119 -33
  66. package/dist/svelte/typing/index.cjs +1 -1
  67. package/dist/svelte/typing/index.d.ts +41 -28
  68. package/dist/svelte/typing/index.mjs +117 -32
  69. package/dist/textToParticle/core/count/index.d.ts +3 -2
  70. package/dist/textToParticle/core/count/index.d.ts.map +1 -1
  71. package/dist/textToParticle/core/textToParticle/index.d.ts +3 -3
  72. package/dist/textToParticle/core/textToParticle/index.d.ts.map +1 -1
  73. package/dist/textToParticle/core/typing/index.d.ts +3 -2
  74. package/dist/textToParticle/core/typing/index.d.ts.map +1 -1
  75. package/dist/textToParticle/core/utils/visibilityManager.d.ts +35 -0
  76. package/dist/textToParticle/core/utils/visibilityManager.d.ts.map +1 -0
  77. package/dist/textToParticle/index.cjs +1 -1
  78. package/dist/textToParticle/index.mjs +1 -1
  79. package/dist/typing/core/count/index.d.ts +3 -2
  80. package/dist/typing/core/count/index.d.ts.map +1 -1
  81. package/dist/typing/core/textToParticle/index.d.ts +3 -3
  82. package/dist/typing/core/textToParticle/index.d.ts.map +1 -1
  83. package/dist/typing/core/typing/index.d.ts +3 -2
  84. package/dist/typing/core/typing/index.d.ts.map +1 -1
  85. package/dist/typing/core/utils/visibilityManager.d.ts +35 -0
  86. package/dist/typing/core/utils/visibilityManager.d.ts.map +1 -0
  87. package/dist/typing/index.cjs +1 -1
  88. package/dist/typing/index.mjs +1 -1
  89. package/dist/vue/count/index.cjs +1 -1
  90. package/dist/vue/count/index.d.ts +41 -28
  91. package/dist/vue/count/index.mjs +119 -41
  92. package/dist/vue/index.cjs +1 -1
  93. package/dist/vue/index.d.ts +41 -28
  94. package/dist/vue/index.mjs +152 -105
  95. package/dist/vue/textToParticle/index.cjs +1 -1
  96. package/dist/vue/textToParticle/index.d.ts +41 -28
  97. package/dist/vue/textToParticle/index.mjs +119 -33
  98. package/dist/vue/typing/index.cjs +1 -1
  99. package/dist/vue/typing/index.d.ts +41 -28
  100. package/dist/vue/typing/index.mjs +116 -31
  101. package/package.json +1 -1
@@ -5,6 +5,7 @@
5
5
  * 사용법:
6
6
  * import { Count } from 'masoneffect/count';
7
7
  */
8
+ import { VisibilityManager } from '../utils/visibilityManager.js';
8
9
  export interface CountOptions {
9
10
  targetValue: number;
10
11
  duration?: number;
@@ -33,12 +34,12 @@ export declare class Count {
33
34
  currentValue: number;
34
35
  startTime: number | null;
35
36
  animationFrameId: number | null;
36
- intersectionObserver: IntersectionObserver | null;
37
+ visibilityManager: VisibilityManager | null;
37
38
  isRunning: boolean;
38
39
  hasTriggered: boolean;
39
40
  constructor(container: HTMLElement | string, options: CountOptions);
40
41
  init(): void;
41
- setupIntersectionObserver(): void;
42
+ setupVisibilityManager(): void;
42
43
  start(): void;
43
44
  stop(): void;
44
45
  reset(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/count/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAGD,eAAO,MAAM,eAAe;gBACd,MAAM;oBACF,MAAM;qBACL,MAAM;uBACJ,MAAM;sBACP,MAAM;CACzB,CAAC;AAEF,qBAAa,KAAK;IAChB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QAChE,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;QACnC,UAAU,EAAE,YAAY,CAAC,YA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AK,IAAI,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAGD,eAAO,MAAM,eAAe;gBACd,MAAM;oBACF,MAAM;qBACL,MAAM;uBACJ,MAAM;sBACP,MAAM;CACzB,CAAC;AAEF,qBAAa,KAAK;IAChB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QAChE,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;QACnC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACxC,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;gBAEV,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,YAAY;IAoClE,IAAI,IAAI,IAAI;IAQZ,sBAAsB,IAAI,IAAI;IAoB9B,KAAK,IAAI,IAAI;IA6Cb,IAAI,IAAI,IAAI;IAQZ,KAAK,IAAI,IAAI;IAQb,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMnC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IA0BpD,QAAQ,IAAI,MAAM;IAKlB,OAAO,IAAI,IAAI;CAOhB;AAGD,eAAe,KAAK,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * 사용법:
6
6
  * import { TextToParticle } from 'masoneffect/textToParticle';
7
7
  */
8
+ import { VisibilityManager } from '../utils/visibilityManager.js';
8
9
  export interface TextToParticleOptions {
9
10
  text?: string;
10
11
  densityStep?: number;
@@ -55,14 +56,13 @@ export declare class TextToParticle {
55
56
  };
56
57
  animationId: number | null;
57
58
  isRunning: boolean;
58
- isVisible: boolean;
59
- intersectionObserver: IntersectionObserver | null;
59
+ visibilityManager: VisibilityManager | null;
60
60
  debounceDelay: number;
61
61
  _debouncedMorph: (textOrOptions?: string | Partial<TextToParticleOptions> | null) => void;
62
62
  _debouncedUpdateConfig: (newConfig: Partial<TextToParticleOptions>) => void;
63
63
  constructor(container: HTMLElement | string, options?: TextToParticleOptions);
64
64
  init(): void;
65
- setupIntersectionObserver(): void;
65
+ setupVisibilityManager(): void;
66
66
  resize(): void;
67
67
  /**
68
68
  * 텍스트가 영역 안에 들어가는지 확인하는 헬퍼 함수 (줄바꿈 지원)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/textToParticle/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IA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B,aAAa,IAAI,IAAI;IAcrB,OAAO,IAAI,IAAI;IAiBf,KAAK,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,GAAG,IAAI;IAM3E,cAAc,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,GAAG,IAAI;IAuBpF,MAAM,IAAI,IAAI;IAqDd,OAAO,IAAI,IAAI;IAMf,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAQZ,mBAAmB,IAAI,IAAI;IAQ3B,oBAAoB,IAAI,IAAI;IAQ5B,YAAY,IAAI,IAAI;IAIpB,eAAe,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAMpC,gBAAgB,IAAI,IAAI;IAIxB,eAAe,IAAI,IAAI;IAIvB,aAAa,IAAI,IAAI;IAKrB,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI;IAK7D,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI;IAQtE,OAAO,IAAI,IAAI;CAWhB;AAGD,eAAe,cAAc,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * 사용법:
6
6
  * import { Typing } from 'masoneffect/typing';
7
7
  */
8
+ import { VisibilityManager } from '../utils/visibilityManager.js';
8
9
  export interface TypingOptions {
9
10
  text: string;
10
11
  speed?: number;
@@ -33,13 +34,13 @@ export declare class Typing {
33
34
  currentIndex: number;
34
35
  displayedText: string;
35
36
  timeoutId: ReturnType<typeof setTimeout> | null;
36
- intersectionObserver: IntersectionObserver | null;
37
+ visibilityManager: VisibilityManager | null;
37
38
  isRunning: boolean;
38
39
  hasTriggered: boolean;
39
40
  originalText: string;
40
41
  constructor(container: HTMLElement | string, options: TypingOptions);
41
42
  init(): void;
42
- setupIntersectionObserver(): void;
43
+ setupVisibilityManager(): void;
43
44
  private buildTextFromUnits;
44
45
  start(): void;
45
46
  typeNext(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/typing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAyFD,qBAAa,MAAM;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC,GAAG;QACjE,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,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AAC,CAAC;QACpC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC;IACF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;IAChD,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;gBAET,SAAS,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa;IA6CnE,IAAI,IAAI,IAAI;IAQZ,sBAAsB,IAAI,IAAI;IAmB9B,OAAO,CAAC,kBAAkB;IAgD1B,KAAK,IAAI,IAAI;IASb,QAAQ,IAAI,IAAI;IAuChB,IAAI,IAAI,IAAI;IAQZ,KAAK,IAAI,IAAI;IAQb,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKjC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAa9B,OAAO,IAAI,IAAI;CAOhB;AAGD,eAAe,MAAM,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * VisibilityManager - IntersectionObserver와 Page Visibility API를 통합 관리
3
+ * 모든 효과에서 공통으로 사용하는 가시성 관리 유틸리티
4
+ */
5
+ export interface VisibilityManagerOptions {
6
+ threshold?: number;
7
+ rootMargin?: string;
8
+ onVisible?: () => void;
9
+ onHidden?: () => void;
10
+ }
11
+ export declare class VisibilityManager {
12
+ private container;
13
+ private options;
14
+ private intersectionObserver;
15
+ private visibilityChangeHandler;
16
+ private isVisible;
17
+ private isPageVisible;
18
+ constructor(container: HTMLElement, options?: VisibilityManagerOptions);
19
+ private setupIntersectionObserver;
20
+ private setupPageVisibility;
21
+ /**
22
+ * 현재 요소가 화면에 보이는지 확인
23
+ */
24
+ getIsVisible(): boolean;
25
+ /**
26
+ * 옵션 업데이트
27
+ */
28
+ updateOptions(newOptions: Partial<VisibilityManagerOptions>): void;
29
+ /**
30
+ * 리소스 정리
31
+ */
32
+ destroy(): void;
33
+ }
34
+ export default VisibilityManager;
35
+ //# sourceMappingURL=visibilityManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visibilityManager.d.ts","sourceRoot":"","sources":["../../../../../src/core/utils/visibilityManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,oBAAoB,CAA8B;IAC1D,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,aAAa,CAAU;gBAEnB,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,wBAA6B;IAiB1E,OAAO,CAAC,yBAAyB;IAsCjC,OAAO,CAAC,mBAAmB;IA+B3B;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,IAAI;IAWlE;;OAEG;IACH,OAAO,IAAI,IAAI;CAUhB;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,"t",{value:!0});var t=require("react");function s(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,e=Math.floor(i/588),h=Math.floor(i%588/28),r=i%28,n=[];return n.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),n.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][h]),r>0&&n.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][r]),n}function i(t,s,i){const e=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),h=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),r=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===e||-1===h)return t+(s||"")+(i||"");const n=44032+21*e*28+28*h+r;return String.fromCharCode(n)}function e(t){const i=[],e=[];for(let h=0;h<t.length;h++){const r=t[h],n=r.charCodeAt(0),o=i.length;if(n>=44032&&n<=55203){const t=s(r);i.push(...t),e.push({start:o,end:i.length,isHangul:!0})}else i.push(r),e.push({start:o,end:i.length,isHangul:!1})}return{units:i,charUnitRanges:e}}class h{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=e(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,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=>{for(const s of t)s.target===this.container&&s.isIntersecting&&!this.hasTriggered&&(this.config.enabled&&setTimeout(()=>this.start(),this.config.delay),this.hasTriggered=!0,this.config.triggerOnce&&this.intersectionObserver?.disconnect())},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}buildTextFromUnits(t){if(0===t)return"";let s="";for(let e=0;e<this.charUnitRanges.length;e++){const h=this.charUnitRanges[e];if(h.start>=t)break;const r=Math.min(t-h.start,h.end-h.start);if(r<=0)break;if(h.isHangul){const t=this.textUnits.slice(h.start,h.start+r);1===t.length?s+=t[0]:2===t.length?s+=i(t[0],t[1]):t.length>=3&&(s+=i(t[0],t[1],t[2]))}else r>0&&(s+=this.textUnits[h.start])}return s}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());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),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;const s=e(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}const r=t.forwardRef((s,i)=>{const e=t.useRef(null),r=t.useRef(null);return t.useEffect(()=>{if(!e.current)return;if(r.current)return;const{className:t,style:i,text:n,speed:o,delay:l,enabled:u,threshold:a,rootMargin:c,triggerOnce:d,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y}=s,m={text:n,speed:o,delay:l,enabled:u,threshold:a,rootMargin:c,triggerOnce:d,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y};return r.current=new h(e.current,m),()=>{r.current&&(r.current.destroy(),r.current=null)}},[]),t.useEffect(()=>{if(!r.current)return;const{text:t,speed:i,delay:e,enabled:h,threshold:n,rootMargin:o,triggerOnce:l,showCursor:u,cursorChar:a,onUpdate:c,onComplete:d}=s;void 0!==t&&t!==r.current.originalText&&r.current.setText(t)},[s.text,s.speed,s.delay,s.enabled,s.threshold,s.rootMargin,s.triggerOnce,s.showCursor,s.cursorChar,s.onUpdate,s.onComplete]),t.useImperativeHandle(i,()=>({start:()=>{r.current?r.current.start():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},stop:()=>{r.current?r.current.stop():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},reset:()=>{r.current?r.current.reset():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},setText:t=>{r.current?r.current.setText(t):console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},destroy:()=>{r.current&&(r.current.destroy(),r.current=null)}})),t.createElement("div",{ref:e,className:s.className,style:s.style})});r.displayName="Typing",exports.default=r;
1
+ Object.defineProperty(exports,"t",{value:!0});var t=require("react");class s{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function i(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,e=Math.floor(i/588),h=Math.floor(i%588/28),n=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][h]),n>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),o}function e(t,s,i){const e=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),h=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),n=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===e||-1===h)return t+(s||"")+(i||"");const o=44032+21*e*28+28*h+n;return String.fromCharCode(o)}function h(t){const s=[],e=[];for(let h=0;h<t.length;h++){const n=t[h],o=n.charCodeAt(0),r=s.length;if(o>=44032&&o<=55203){const t=i(n);s.push(...t),e.push({start:r,end:s.length,isHangul:!0})}else s.push(n),e.push({start:r,end:s.length,isHangul:!1})}return{units:s,charUnitRanges:e}}class n{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=h(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new s(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let s="";for(let i=0;i<this.charUnitRanges.length;i++){const h=this.charUnitRanges[i];if(h.start>=t)break;const n=Math.min(t-h.start,h.end-h.start);if(n<=0)break;if(h.isHangul){const t=this.textUnits.slice(h.start,h.start+n);1===t.length?s+=t[0]:2===t.length?s+=e(t[0],t[1]):t.length>=3&&(s+=e(t[0],t[1],t[2]))}else n>0&&(s+=this.textUnits[h.start])}return s}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());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),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;const s=h(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const o=t.forwardRef((s,i)=>{const e=t.useRef(null),h=t.useRef(null);return t.useEffect(()=>{if(!e.current)return;if(h.current)return;const{className:t,style:i,text:o,speed:r,delay:l,enabled:u,threshold:d,rootMargin:c,triggerOnce:a,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y}=s,m={text:o,speed:r,delay:l,enabled:u,threshold:d,rootMargin:c,triggerOnce:a,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y};return h.current=new n(e.current,m),()=>{h.current&&(h.current.destroy(),h.current=null)}},[]),t.useEffect(()=>{if(!h.current)return;const{text:t,speed:i,delay:e,enabled:n,threshold:o,rootMargin:r,triggerOnce:l,showCursor:u,cursorChar:d,onUpdate:c,onComplete:a}=s;void 0!==t&&t!==h.current.originalText&&h.current.setText(t)},[s.text,s.speed,s.delay,s.enabled,s.threshold,s.rootMargin,s.triggerOnce,s.showCursor,s.cursorChar,s.onUpdate,s.onComplete]),t.useImperativeHandle(i,()=>({start:()=>{h.current?h.current.start():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},stop:()=>{h.current?h.current.stop():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},reset:()=>{h.current?h.current.reset():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},setText:t=>{h.current?h.current.setText(t):console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},destroy:()=>{h.current&&(h.current.destroy(),h.current=null)}})),t.createElement("div",{ref:e,className:s.className,style:s.style})});o.displayName="Typing",exports.default=o;
@@ -1 +1 @@
1
- import t,{useRef as s,useEffect as i}from"react";function e(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,e=Math.floor(i/588),h=Math.floor(i%588/28),n=i%28,r=[];return r.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),r.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][h]),n>0&&r.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),r}function h(t,s,i){const e=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),h=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),n=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===e||-1===h)return t+(s||"")+(i||"");const r=44032+21*e*28+28*h+n;return String.fromCharCode(r)}function n(t){const s=[],i=[];for(let h=0;h<t.length;h++){const n=t[h],r=n.charCodeAt(0),o=s.length;if(r>=44032&&r<=55203){const t=e(n);s.push(...t),i.push({start:o,end:s.length,isHangul:!0})}else s.push(n),i.push({start:o,end:s.length,isHangul:!1})}return{units:s,charUnitRanges:i}}class r{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=n(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,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=>{for(const s of t)s.target===this.container&&s.isIntersecting&&!this.hasTriggered&&(this.config.enabled&&setTimeout(()=>this.start(),this.config.delay),this.hasTriggered=!0,this.config.triggerOnce&&this.intersectionObserver?.disconnect())},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}buildTextFromUnits(t){if(0===t)return"";let s="";for(let i=0;i<this.charUnitRanges.length;i++){const e=this.charUnitRanges[i];if(e.start>=t)break;const n=Math.min(t-e.start,e.end-e.start);if(n<=0)break;if(e.isHangul){const t=this.textUnits.slice(e.start,e.start+n);1===t.length?s+=t[0]:2===t.length?s+=h(t[0],t[1]):t.length>=3&&(s+=h(t[0],t[1],t[2]))}else n>0&&(s+=this.textUnits[e.start])}return s}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());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),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;const s=n(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}const o=t.forwardRef((e,h)=>{const n=s(null),o=s(null);return i(()=>{if(!n.current)return;if(o.current)return;const{className:t,style:s,text:i,speed:h,delay:l,enabled:u,threshold:a,rootMargin:c,triggerOnce:d,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y}=e,m={text:i,speed:h,delay:l,enabled:u,threshold:a,rootMargin:c,triggerOnce:d,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y};return o.current=new r(n.current,m),()=>{o.current&&(o.current.destroy(),o.current=null)}},[]),i(()=>{if(!o.current)return;const{text:t,speed:s,delay:i,enabled:h,threshold:n,rootMargin:r,triggerOnce:l,showCursor:u,cursorChar:a,onUpdate:c,onComplete:d}=e;void 0!==t&&t!==o.current.originalText&&o.current.setText(t)},[e.text,e.speed,e.delay,e.enabled,e.threshold,e.rootMargin,e.triggerOnce,e.showCursor,e.cursorChar,e.onUpdate,e.onComplete]),t.useImperativeHandle(h,()=>({start:()=>{o.current?o.current.start():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},stop:()=>{o.current?o.current.stop():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},reset:()=>{o.current?o.current.reset():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},setText:t=>{o.current?o.current.setText(t):console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},destroy:()=>{o.current&&(o.current.destroy(),o.current=null)}})),t.createElement("div",{ref:n,className:e.className,style:e.style})});o.displayName="Typing";export{o as default};
1
+ import t,{useRef as s,useEffect as i}from"react";class e{constructor(t,s={}){this.container=t,this.options={threshold:s.threshold??.1,rootMargin:s.rootMargin??"0px",onVisible:s.onVisible,onHidden:s.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const s of t)s.target===this.container&&(s.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}function h(t){const s=t.charCodeAt(0);if(s<44032||s>55203)return[t];const i=s-44032,e=Math.floor(i/588),h=Math.floor(i%588/28),n=i%28,o=[];return o.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][e]),o.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][h]),n>0&&o.push(["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][n]),o}function n(t,s,i){const e=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(t),h=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"].indexOf(s),n=i?["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"].indexOf(i):0;if(-1===e||-1===h)return t+(s||"")+(i||"");const o=44032+21*e*28+28*h+n;return String.fromCharCode(o)}function o(t){const s=[],i=[];for(let e=0;e<t.length;e++){const n=t[e],o=n.charCodeAt(0),r=s.length;if(o>=44032&&o<=55203){const t=h(n);s.push(...t),i.push({start:r,end:s.length,isHangul:!0})}else s.push(n),i.push({start:r,end:s.length,isHangul:!1})}return{units:s,charUnitRanges:i}}class r{constructor(t,s){if(this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=s.text,this.config={text:s.text,speed:s.speed??50,delay:s.delay??0,enabled:s.enabled??!0,threshold:s.threshold??.2,rootMargin:s.rootMargin??"0px 0px -100px 0px",triggerOnce:s.triggerOnce??!1,showCursor:s.showCursor??!0,cursorChar:s.cursorChar??"|",onUpdate:s.onUpdate||null,onComplete:s.onComplete||null};const i=o(this.config.text);this.textUnits=i.units,this.charUnitRanges=i.charUnitRanges,this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new e(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,setTimeout(()=>this.start(),this.config.delay))},onHidden:()=>{}})}buildTextFromUnits(t){if(0===t)return"";let s="";for(let i=0;i<this.charUnitRanges.length;i++){const e=this.charUnitRanges[i];if(e.start>=t)break;const h=Math.min(t-e.start,e.end-e.start);if(h<=0)break;if(e.isHangul){const t=this.textUnits.slice(e.start,e.start+h);1===t.length?s+=t[0]:2===t.length?s+=n(t[0],t[1]):t.length>=3&&(s+=n(t[0],t[1],t[2]))}else h>0&&(s+=this.textUnits[e.start])}return s}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());this.displayedText=this.buildTextFromUnits(this.currentIndex+1);let t=this.displayedText;this.config.showCursor&&(t+=this.config.cursorChar),this.updateDisplay(t),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;const s=o(t);this.textUnits=s.units,this.charUnitRanges=s.charUnitRanges,this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}const l=t.forwardRef((e,h)=>{const n=s(null),o=s(null);return i(()=>{if(!n.current)return;if(o.current)return;const{className:t,style:s,text:i,speed:h,delay:l,enabled:u,threshold:d,rootMargin:c,triggerOnce:a,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y}=e,m={text:i,speed:h,delay:l,enabled:u,threshold:d,rootMargin:c,triggerOnce:a,showCursor:p,cursorChar:f,onUpdate:g,onComplete:y};return o.current=new r(n.current,m),()=>{o.current&&(o.current.destroy(),o.current=null)}},[]),i(()=>{if(!o.current)return;const{text:t,speed:s,delay:i,enabled:h,threshold:n,rootMargin:r,triggerOnce:l,showCursor:u,cursorChar:d,onUpdate:c,onComplete:a}=e;void 0!==t&&t!==o.current.originalText&&o.current.setText(t)},[e.text,e.speed,e.delay,e.enabled,e.threshold,e.rootMargin,e.triggerOnce,e.showCursor,e.cursorChar,e.onUpdate,e.onComplete]),t.useImperativeHandle(h,()=>({start:()=>{o.current?o.current.start():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},stop:()=>{o.current?o.current.stop():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},reset:()=>{o.current?o.current.reset():console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},setText:t=>{o.current?o.current.setText(t):console.warn("Typing: 인스턴스가 아직 초기화되지 않았습니다.")},destroy:()=>{o.current&&(o.current.destroy(),o.current=null)}})),t.createElement("div",{ref:n,className:e.className,style:e.style})});l.displayName="Typing";export{l as default};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty,e=(e,n,i)=>((e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i)(e,"symbol"!=typeof n?n+"":n,i);const n=require("svelte");function i(){}function r(t){return t()}function s(){return Object.create(null)}function o(t){t.forEach(r)}function a(t){return"function"==typeof t}function u(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function l(t){t.parentNode&&t.parentNode.removeChild(t)}function c(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}let h;function g(t){h=t}const d=[],f=[];let p=[];const m=[],$=Promise.resolve();let b=!1;function y(t){p.push(t)}const V=new Set;let v=0;function x(){if(0!==v)return;const t=h;do{try{for(;v<d.length;){const t=d[v];v++,g(t),O(t.$$)}}catch(e){throw d.length=0,v=0,e}for(g(null),d.length=0,v=0;f.length;)f.pop()();for(let t=0;t<p.length;t+=1){const e=p[t];V.has(e)||(V.add(e),e())}p.length=0}while(d.length);for(;m.length;)m.pop()();b=!1,V.clear(),g(t)}function O(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(y)}}const w=new Set;function _(t,e){const n=t.$$;null!==n.fragment&&(!function(t){const e=[],n=[];p.forEach(i=>-1===t.indexOf(i)?e.push(i):n.push(i)),n.forEach(t=>t()),p=e}(n.after_update),o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function C(t,e){-1===t.$$.dirty[0]&&(d.push(t),b||(b=!0,$.then(x)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function M(t,e,n,u,c,d,f=null,p=[-1]){const m=h;g(t);const $=t.$$={fragment:null,ctx:[],props:d,update:i,not_equal:c,bound:s(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(m?m.$$.context:[])),callbacks:s(),dirty:p,skip_bound:!1,root:e.target||m.$$.root};f&&f($.root);let b=!1;if($.ctx=n?n(t,e.props||{},(e,n,...i)=>{const r=i.length?i[0]:n;return $.ctx&&c($.ctx[e],$.ctx[e]=r)&&(!$.skip_bound&&$.bound[e]&&$.bound[e](r),b&&C(t,e)),n}):[],$.update(),b=!0,o($.before_update),$.fragment=!!u&&u($.ctx),e.target){if(e.hydrate){const t=(O=e.target,Array.from(O.childNodes));$.fragment&&$.fragment.l(t),t.forEach(l)}else $.fragment&&$.fragment.c();e.intro&&((V=t.$$.fragment)&&V.i&&(w.delete(V),V.i(v))),function(t,e,n){const{fragment:i,after_update:s}=t.$$;i&&i.m(e,n),y(()=>{const e=t.$$.on_mount.map(r).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...e):o(e),t.$$.on_mount=[]}),s.forEach(y)}(t,e.target,e.anchor),x()}var V,v,O;g(m)}class I{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){_(this,1),this.$destroy=i}$on(t,e){if(!a(e))return i;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");const T={linear:t=>t};class U{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??T.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 n of t)if(n.target===this.container)if(n.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=n.boundingClientRect,e=window.innerHeight,i=window.innerWidth;(t.bottom<=0||t.top>=e||t.right<=0||t.left>=i)&&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 n=e-this.startTime,i=Math.min(n/this.config.duration,1),r=this.config.easing(i);this.currentValue=Math.floor(this.config.startValue+(this.config.targetValue-this.config.startValue)*r),this.updateDisplay(this.currentValue),this.config.onUpdate&&this.config.onUpdate(this.currentValue),i<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 E(t){let e;return{c(){var n;n="div",e=document.createElement(n),c(e,"class",t[0]),c(e,"style",t[1])},m(n,i){!function(t,e,n){t.insertBefore(e,n||null)}(n,e,i),t[18](e)},p(t,[n]){1&n&&c(e,"class",t[0]),2&n&&c(e,"style",t[1])},i:i,o:i,d(n){n&&l(e),t[18](null)}}}function F(t,e,i){let{targetValue:r=0}=e,{duration:s=2e3}=e,{startValue:o=0}=e,{enabled:a=!0}=e,{easing:u=t=>t}=e,{threshold:l=.2}=e,{rootMargin:c="0px 0px -100px 0px"}=e,{triggerOnce:h=!1}=e,{className:g=""}=e,{style:d={}}=e;const p=n.createEventDispatcher();let m,$=null;return n.onMount(()=>{if(!m)return;i(17,$=new U(m,{targetValue:r,duration:s,startValue:o,enabled:a,easing:u,threshold:l,rootMargin:c,triggerOnce:h,onUpdate:t=>{p("update",t)},onComplete:()=>{p("complete")}}))}),n.onDestroy(()=>{$&&($.destroy(),i(17,$=null))}),t.$$set=t=>{"targetValue"in t&&i(3,r=t.targetValue),"duration"in t&&i(4,s=t.duration),"startValue"in t&&i(5,o=t.startValue),"enabled"in t&&i(6,a=t.enabled),"easing"in t&&i(7,u=t.easing),"threshold"in t&&i(8,l=t.threshold),"rootMargin"in t&&i(9,c=t.rootMargin),"triggerOnce"in t&&i(10,h=t.triggerOnce),"className"in t&&i(0,g=t.className),"style"in t&&i(1,d=t.style)},t.$$.update=()=>{133112&t.$$.dirty&&$&&$.updateConfig({targetValue:r,duration:s,startValue:o,enabled:a,easing:u,threshold:l,rootMargin:c,triggerOnce:h,onUpdate:t=>{p("update",t)},onComplete:()=>{p("complete")}})},[g,d,m,r,s,o,a,u,l,c,h,function(){$&&$.start()},function(){$&&$.stop()},function(){$&&$.reset()},function(){return $?$.getValue():0},function(t){$&&$.updateConfig(t)},function(){$&&($.destroy(),i(17,$=null))},$,function(t){f[t?"unshift":"push"](()=>{m=t,i(2,m)})}]}module.exports=class extends I{constructor(t){super(),M(this,t,F,E,u,{targetValue:3,duration:4,startValue:5,enabled:6,easing:7,threshold:8,rootMargin:9,triggerOnce:10,className:0,style:1,start:11,stop:12,reset:13,getValue:14,updateConfig:15,destroy:16})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get getValue(){return this.$$.ctx[14]}get updateConfig(){return this.$$.ctx[15]}get destroy(){return this.$$.ctx[16]}};
1
+ "use strict";var t=Object.defineProperty,e=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);const i=require("svelte");function n(){}function s(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(s)}function a(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function u(t){t.parentNode&&t.parentNode.removeChild(t)}function h(t,e,i){null==i?t.removeAttribute(e):t.getAttribute(e)!==i&&t.setAttribute(e,i)}let c;function d(t){c=t}const g=[],p=[];let f=[];const b=[],m=Promise.resolve();let y=!1;function V(t){f.push(t)}const $=new Set;let v=0;function x(){if(0!==v)return;const t=c;do{try{for(;v<g.length;){const t=g[v];v++,d(t),O(t.$$)}}catch(e){throw g.length=0,v=0,e}for(d(null),g.length=0,v=0;p.length;)p.pop()();for(let t=0;t<f.length;t+=1){const e=f[t];$.has(e)||($.add(e),e())}f.length=0}while(g.length);for(;b.length;)b.pop()();y=!1,$.clear(),d(t)}function O(t){if(null!==t.fragment){t.update(),r(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(V)}}const M=new Set;function _(t,e){const i=t.$$;null!==i.fragment&&(!function(t){const e=[],i=[];f.forEach(n=>-1===t.indexOf(n)?e.push(n):i.push(n)),i.forEach(t=>t()),f=e}(i.after_update),r(i.on_destroy),i.fragment&&i.fragment.d(e),i.on_destroy=i.fragment=null,i.ctx=[])}function C(t,e){-1===t.$$.dirty[0]&&(g.push(t),y||(y=!0,m.then(x)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function w(t,e,i,l,h,g,p=null,f=[-1]){const b=c;d(t);const m=t.$$={fragment:null,ctx:[],props:g,update:n,not_equal:h,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(b?b.$$.context:[])),callbacks:o(),dirty:f,skip_bound:!1,root:e.target||b.$$.root};p&&p(m.root);let y=!1;if(m.ctx=i?i(t,e.props||{},(e,i,...n)=>{const s=n.length?n[0]:i;return m.ctx&&h(m.ctx[e],m.ctx[e]=s)&&(!m.skip_bound&&m.bound[e]&&m.bound[e](s),y&&C(t,e)),i}):[],m.update(),y=!0,r(m.before_update),m.fragment=!!l&&l(m.ctx),e.target){if(e.hydrate){const t=(O=e.target,Array.from(O.childNodes));m.fragment&&m.fragment.l(t),t.forEach(u)}else m.fragment&&m.fragment.c();e.intro&&(($=t.$$.fragment)&&$.i&&(M.delete($),$.i(v))),function(t,e,i){const{fragment:n,after_update:o}=t.$$;n&&n.m(e,i),V(()=>{const e=t.$$.on_mount.map(s).filter(a);t.$$.on_destroy?t.$$.on_destroy.push(...e):r(e),t.$$.on_mount=[]}),o.forEach(V)}(t,e.target,e.anchor),x()}var $,v,O;d(b)}class H{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){_(this,1),this.$destroy=n}$on(t,e){if(!a(e))return n;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class I{constructor(t,e={}){this.container=t,this.options={threshold:e.threshold??.1,rootMargin:e.rootMargin??"0px",onVisible:e.onVisible,onHidden:e.onHidden},this.intersectionObserver=null,this.visibilityChangeHandler=null,this.isVisible=!1,this.isPageVisible="undefined"==typeof document||!document.hidden,this.setupIntersectionObserver(),this.setupPageVisibility()}setupIntersectionObserver(){if("undefined"==typeof window||void 0===window.IntersectionObserver)return this.isVisible=!0,void(this.isPageVisible&&this.options.onVisible&&this.options.onVisible());this.intersectionObserver=new IntersectionObserver(t=>{for(const e of t)e.target===this.container&&(e.isIntersecting?(this.isVisible=!0,this.isPageVisible&&this.options.onVisible&&this.options.onVisible()):(this.isVisible=!1,this.options.onHidden&&this.options.onHidden()))},{threshold:this.options.threshold,rootMargin:this.options.rootMargin}),this.intersectionObserver.observe(this.container)}setupPageVisibility(){"undefined"!=typeof document&&(this.visibilityChangeHandler=()=>{const t=this.isPageVisible;this.isPageVisible=!document.hidden,document.hidden?this.options.onHidden&&this.options.onHidden():t!==this.isPageVisible&&this.isVisible&&this.options.onVisible&&this.options.onVisible()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),document.hidden&&this.isVisible&&this.options.onHidden&&this.options.onHidden())}getIsVisible(){return this.isVisible&&this.isPageVisible}updateOptions(t){this.options={...this.options,...t},this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.setupIntersectionObserver()}destroy(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityChangeHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null)}}const E={linear:t=>t};class P{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??E.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.visibilityManager=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(this.config.startValue),this.setupVisibilityManager()}setupVisibilityManager(){this.visibilityManager=new I(this.container,{threshold:this.config.threshold,rootMargin:this.config.rootMargin,onVisible:()=>{!this.hasTriggered&&this.config.enabled&&(this.hasTriggered=!0,this.start())},onHidden:()=>{!this.config.triggerOnce&&this.isRunning&&this.reset()}})}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.visibilityManager&&(this.visibilityManager.destroy(),this.visibilityManager=null)}}function T(t){let e;return{c(){var i;i="div",e=document.createElement(i),h(e,"class",t[0]),h(e,"style",t[1])},m(i,n){!function(t,e,i){t.insertBefore(e,i||null)}(i,e,n),t[18](e)},p(t,[i]){1&i&&h(e,"class",t[0]),2&i&&h(e,"style",t[1])},i:n,o:n,d(i){i&&u(e),t[18](null)}}}function U(t,e,n){let{targetValue:s=0}=e,{duration:o=2e3}=e,{startValue:r=0}=e,{enabled:a=!0}=e,{easing:l=t=>t}=e,{threshold:u=.2}=e,{rootMargin:h="0px 0px -100px 0px"}=e,{triggerOnce:c=!1}=e,{className:d=""}=e,{style:g={}}=e;const f=i.createEventDispatcher();let b,m=null;return i.onMount(()=>{if(!b)return;n(17,m=new P(b,{targetValue:s,duration:o,startValue:r,enabled:a,easing:l,threshold:u,rootMargin:h,triggerOnce:c,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}}))}),i.onDestroy(()=>{m&&(m.destroy(),n(17,m=null))}),t.$$set=t=>{"targetValue"in t&&n(3,s=t.targetValue),"duration"in t&&n(4,o=t.duration),"startValue"in t&&n(5,r=t.startValue),"enabled"in t&&n(6,a=t.enabled),"easing"in t&&n(7,l=t.easing),"threshold"in t&&n(8,u=t.threshold),"rootMargin"in t&&n(9,h=t.rootMargin),"triggerOnce"in t&&n(10,c=t.triggerOnce),"className"in t&&n(0,d=t.className),"style"in t&&n(1,g=t.style)},t.$$.update=()=>{133112&t.$$.dirty&&m&&m.updateConfig({targetValue:s,duration:o,startValue:r,enabled:a,easing:l,threshold:u,rootMargin:h,triggerOnce:c,onUpdate:t=>{f("update",t)},onComplete:()=>{f("complete")}})},[d,g,b,s,o,r,a,l,u,h,c,function(){m&&m.start()},function(){m&&m.stop()},function(){m&&m.reset()},function(){return m?m.getValue():0},function(t){m&&m.updateConfig(t)},function(){m&&(m.destroy(),n(17,m=null))},m,function(t){p[t?"unshift":"push"](()=>{b=t,n(2,b)})}]}module.exports=class extends H{constructor(t){super(),w(this,t,U,T,l,{targetValue:3,duration:4,startValue:5,enabled:6,easing:7,threshold:8,rootMargin:9,triggerOnce:10,className:0,style:1,start:11,stop:12,reset:13,getValue:14,updateConfig:15,destroy:16})}get start(){return this.$$.ctx[11]}get stop(){return this.$$.ctx[12]}get reset(){return this.$$.ctx[13]}get getValue(){return this.$$.ctx[14]}get updateConfig(){return this.$$.ctx[15]}get destroy(){return this.$$.ctx[16]}};
@@ -7,12 +7,12 @@ export declare class Count {
7
7
  currentValue: number;
8
8
  startTime: number | null;
9
9
  animationFrameId: number | null;
10
- intersectionObserver: IntersectionObserver | null;
10
+ visibilityManager: VisibilityManager | null;
11
11
  isRunning: boolean;
12
12
  hasTriggered: boolean;
13
13
  constructor(container: HTMLElement | string, options: CountOptions);
14
14
  init(): void;
15
- setupIntersectionObserver(): void;
15
+ setupVisibilityManager(): void;
16
16
  start(): void;
17
17
  stop(): void;
18
18
  reset(): void;
@@ -23,13 +23,6 @@ export declare class Count {
23
23
  destroy(): void;
24
24
  }
25
25
 
26
- /**
27
- * Count - 숫자 카운팅 애니메이션 효과
28
- * 바닐라 JS 코어 클래스
29
- *
30
- * 사용법:
31
- * import { Count } from 'masoneffect/count';
32
- */
33
26
  export declare interface CountOptions {
34
27
  targetValue: number;
35
28
  duration?: number;
@@ -84,14 +77,13 @@ declare class TextToParticle {
84
77
  };
85
78
  animationId: number | null;
86
79
  isRunning: boolean;
87
- isVisible: boolean;
88
- intersectionObserver: IntersectionObserver | null;
80
+ visibilityManager: VisibilityManager | null;
89
81
  debounceDelay: number;
90
82
  _debouncedMorph: (textOrOptions?: string | Partial<TextToParticleOptions> | null) => void;
91
83
  _debouncedUpdateConfig: (newConfig: Partial<TextToParticleOptions>) => void;
92
84
  constructor(container: HTMLElement | string, options?: TextToParticleOptions);
93
85
  init(): void;
94
- setupIntersectionObserver(): void;
86
+ setupVisibilityManager(): void;
95
87
  resize(): void;
96
88
  /**
97
89
  * 텍스트가 영역 안에 들어가는지 확인하는 헬퍼 함수 (줄바꿈 지원)
@@ -132,13 +124,6 @@ declare class TextToParticle {
132
124
  export { TextToParticle }
133
125
  export default TextToParticle;
134
126
 
135
- /**
136
- * TextToParticle - 텍스트를 파티클로 변환하는 효과
137
- * 바닐라 JS 코어 클래스
138
- *
139
- * 사용법:
140
- * import { TextToParticle } from 'masoneffect/textToParticle';
141
- */
142
127
  declare interface TextToParticleOptions {
143
128
  text?: string;
144
129
  densityStep?: number;
@@ -175,13 +160,13 @@ declare class TextToParticle {
175
160
  currentIndex: number;
176
161
  displayedText: string;
177
162
  timeoutId: ReturnType<typeof setTimeout> | null;
178
- intersectionObserver: IntersectionObserver | null;
163
+ visibilityManager: VisibilityManager | null;
179
164
  isRunning: boolean;
180
165
  hasTriggered: boolean;
181
166
  originalText: string;
182
167
  constructor(container: HTMLElement | string, options: TypingOptions);
183
168
  init(): void;
184
- setupIntersectionObserver(): void;
169
+ setupVisibilityManager(): void;
185
170
  private buildTextFromUnits;
186
171
  start(): void;
187
172
  typeNext(): void;
@@ -192,13 +177,6 @@ declare class TextToParticle {
192
177
  destroy(): void;
193
178
  }
194
179
 
195
- /**
196
- * Typing - 타이핑 애니메이션 효과
197
- * 바닐라 JS 코어 클래스
198
- *
199
- * 사용법:
200
- * import { Typing } from 'masoneffect/typing';
201
- */
202
180
  export declare interface TypingOptions {
203
181
  text: string;
204
182
  speed?: number;
@@ -213,4 +191,39 @@ declare class TextToParticle {
213
191
  onComplete?: () => void;
214
192
  }
215
193
 
194
+ declare class VisibilityManager {
195
+ private container;
196
+ private options;
197
+ private intersectionObserver;
198
+ private visibilityChangeHandler;
199
+ private isVisible;
200
+ private isPageVisible;
201
+ constructor(container: HTMLElement, options?: VisibilityManagerOptions);
202
+ private setupIntersectionObserver;
203
+ private setupPageVisibility;
204
+ /**
205
+ * 현재 요소가 화면에 보이는지 확인
206
+ */
207
+ getIsVisible(): boolean;
208
+ /**
209
+ * 옵션 업데이트
210
+ */
211
+ updateOptions(newOptions: Partial<VisibilityManagerOptions>): void;
212
+ /**
213
+ * 리소스 정리
214
+ */
215
+ destroy(): void;
216
+ }
217
+
218
+ /**
219
+ * VisibilityManager - IntersectionObserver와 Page Visibility API를 통합 관리
220
+ * 모든 효과에서 공통으로 사용하는 가시성 관리 유틸리티
221
+ */
222
+ declare interface VisibilityManagerOptions {
223
+ threshold?: number;
224
+ rootMargin?: string;
225
+ onVisible?: () => void;
226
+ onHidden?: () => void;
227
+ }
228
+
216
229
  export { }
@@ -263,6 +263,107 @@ class SvelteComponent {
263
263
  const PUBLIC_VERSION = "4";
264
264
  if (typeof window !== "undefined")
265
265
  (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
266
+ class VisibilityManager {
267
+ constructor(container, options = {}) {
268
+ this.container = container;
269
+ this.options = {
270
+ threshold: options.threshold ?? 0.1,
271
+ rootMargin: options.rootMargin ?? "0px",
272
+ onVisible: options.onVisible,
273
+ onHidden: options.onHidden
274
+ };
275
+ this.intersectionObserver = null;
276
+ this.visibilityChangeHandler = null;
277
+ this.isVisible = false;
278
+ this.isPageVisible = typeof document !== "undefined" ? !document.hidden : true;
279
+ this.setupIntersectionObserver();
280
+ this.setupPageVisibility();
281
+ }
282
+ setupIntersectionObserver() {
283
+ if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
284
+ this.isVisible = true;
285
+ if (this.isPageVisible && this.options.onVisible) {
286
+ this.options.onVisible();
287
+ }
288
+ return;
289
+ }
290
+ this.intersectionObserver = new IntersectionObserver(
291
+ (entries) => {
292
+ for (const entry of entries) {
293
+ if (entry.target !== this.container) continue;
294
+ if (entry.isIntersecting) {
295
+ this.isVisible = true;
296
+ if (this.isPageVisible && this.options.onVisible) {
297
+ this.options.onVisible();
298
+ }
299
+ } else {
300
+ this.isVisible = false;
301
+ if (this.options.onHidden) {
302
+ this.options.onHidden();
303
+ }
304
+ }
305
+ }
306
+ },
307
+ {
308
+ threshold: this.options.threshold,
309
+ rootMargin: this.options.rootMargin
310
+ }
311
+ );
312
+ this.intersectionObserver.observe(this.container);
313
+ }
314
+ setupPageVisibility() {
315
+ if (typeof document === "undefined") return;
316
+ this.visibilityChangeHandler = () => {
317
+ const wasVisible = this.isPageVisible;
318
+ this.isPageVisible = !document.hidden;
319
+ if (document.hidden) {
320
+ if (this.options.onHidden) {
321
+ this.options.onHidden();
322
+ }
323
+ } else if (wasVisible !== this.isPageVisible) {
324
+ if (this.isVisible && this.options.onVisible) {
325
+ this.options.onVisible();
326
+ }
327
+ }
328
+ };
329
+ document.addEventListener("visibilitychange", this.visibilityChangeHandler);
330
+ if (document.hidden && this.isVisible) {
331
+ if (this.options.onHidden) {
332
+ this.options.onHidden();
333
+ }
334
+ }
335
+ }
336
+ /**
337
+ * 현재 요소가 화면에 보이는지 확인
338
+ */
339
+ getIsVisible() {
340
+ return this.isVisible && this.isPageVisible;
341
+ }
342
+ /**
343
+ * 옵션 업데이트
344
+ */
345
+ updateOptions(newOptions) {
346
+ this.options = { ...this.options, ...newOptions };
347
+ if (this.intersectionObserver) {
348
+ this.intersectionObserver.disconnect();
349
+ this.intersectionObserver = null;
350
+ }
351
+ this.setupIntersectionObserver();
352
+ }
353
+ /**
354
+ * 리소스 정리
355
+ */
356
+ destroy() {
357
+ if (this.intersectionObserver) {
358
+ this.intersectionObserver.disconnect();
359
+ this.intersectionObserver = null;
360
+ }
361
+ if (this.visibilityChangeHandler && typeof document !== "undefined") {
362
+ document.removeEventListener("visibilitychange", this.visibilityChangeHandler);
363
+ this.visibilityChangeHandler = null;
364
+ }
365
+ }
366
+ }
266
367
  const easingFunctions = {
267
368
  linear: (t) => t
268
369
  };
@@ -287,54 +388,31 @@ class Count {
287
388
  this.currentValue = this.config.startValue;
288
389
  this.startTime = null;
289
390
  this.animationFrameId = null;
290
- this.intersectionObserver = null;
391
+ this.visibilityManager = null;
291
392
  this.isRunning = false;
292
393
  this.hasTriggered = false;
293
394
  this.init();
294
395
  }
295
396
  init() {
296
397
  this.updateDisplay(this.config.startValue);
297
- this.setupIntersectionObserver();
298
- }
299
- setupIntersectionObserver() {
300
- if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
301
- if (this.config.enabled) {
302
- this.start();
303
- }
304
- return;
305
- }
306
- this.intersectionObserver = new IntersectionObserver(
307
- (entries) => {
308
- var _a;
309
- for (const entry of entries) {
310
- if (entry.target !== this.container) continue;
311
- if (entry.isIntersecting) {
312
- if (!this.hasTriggered && this.config.enabled) {
313
- this.hasTriggered = true;
314
- this.start();
315
- }
316
- if (this.config.triggerOnce) {
317
- (_a = this.intersectionObserver) == null ? void 0 : _a.unobserve(this.container);
318
- }
319
- } else {
320
- if (!this.config.triggerOnce) {
321
- const rect = entry.boundingClientRect;
322
- const viewportHeight = window.innerHeight;
323
- const viewportWidth = window.innerWidth;
324
- const isCompletelyOutOfViewport = rect.bottom <= 0 || rect.top >= viewportHeight || rect.right <= 0 || rect.left >= viewportWidth;
325
- if (isCompletelyOutOfViewport && this.isRunning) {
326
- this.reset();
327
- }
328
- }
329
- }
398
+ this.setupVisibilityManager();
399
+ }
400
+ setupVisibilityManager() {
401
+ this.visibilityManager = new VisibilityManager(this.container, {
402
+ threshold: this.config.threshold,
403
+ rootMargin: this.config.rootMargin,
404
+ onVisible: () => {
405
+ if (!this.hasTriggered && this.config.enabled) {
406
+ this.hasTriggered = true;
407
+ this.start();
330
408
  }
331
409
  },
332
- {
333
- threshold: this.config.threshold,
334
- rootMargin: this.config.rootMargin
410
+ onHidden: () => {
411
+ if (!this.config.triggerOnce && this.isRunning) {
412
+ this.reset();
413
+ }
335
414
  }
336
- );
337
- this.intersectionObserver.observe(this.container);
415
+ });
338
416
  }
339
417
  start() {
340
418
  if (this.isRunning) return;
@@ -418,9 +496,9 @@ class Count {
418
496
  // 파괴 및 정리
419
497
  destroy() {
420
498
  this.stop();
421
- if (this.intersectionObserver) {
422
- this.intersectionObserver.disconnect();
423
- this.intersectionObserver = null;
499
+ if (this.visibilityManager) {
500
+ this.visibilityManager.destroy();
501
+ this.visibilityManager = null;
424
502
  }
425
503
  }
426
504
  }