gospelo-iconcraft-react 0.1.0

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.
@@ -0,0 +1,942 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import * as _gospelo_dev_iconcraft_wasm from '@gospelo-dev/iconcraft-wasm';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type ShapeMode = 'jelly' | 'droplet' | 'wax';
6
+ type IconStyle = 'original' | 'white' | 'dark' | 'emboss';
7
+ /** Built-in animation types */
8
+ type BuiltInAnimationType = 'none' | 'shake' | 'bounce' | 'pulse' | 'swing' | 'wobble' | 'jello' | 'heartbeat' | 'float' | 'spin' | 'rubberBand' | 'squish' | 'tada' | 'flip' | 'drop' | 'pop' | 'wiggle' | 'breathe';
9
+ /**
10
+ * Custom animation registry for module augmentation.
11
+ *
12
+ * Users can extend this interface to add type-safe custom animations:
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // types/iconcraft.d.ts
17
+ * declare module '@gospelo-dev/iconcraft-react' {
18
+ * interface CustomAnimationRegistry {
19
+ * tada: true;
20
+ * flip: true;
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ interface CustomAnimationRegistry {
26
+ }
27
+ /** All animation types (built-in + custom) */
28
+ type AnimationType = BuiltInAnimationType | keyof CustomAnimationRegistry;
29
+ /**
30
+ * Animation target - which part of the component to animate
31
+ * - 'shape': Animate only the background shape (SVG container)
32
+ * - 'icon': Animate only the icon inside the shape
33
+ * - 'both': Animate the entire component (default, legacy behavior)
34
+ */
35
+ type AnimationTarget = 'shape' | 'icon' | 'both';
36
+ interface AnimationOptions {
37
+ type: AnimationType;
38
+ /** Animation target: 'shape', 'icon', or 'both' (default) */
39
+ target?: AnimationTarget;
40
+ duration?: number;
41
+ delay?: number;
42
+ iterationCount?: number | 'infinite';
43
+ timingFunction?: 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear';
44
+ playState?: 'running' | 'paused';
45
+ }
46
+ interface ColorPalette {
47
+ very_light: string;
48
+ light: string;
49
+ mid: string;
50
+ dark: string;
51
+ very_dark: string;
52
+ }
53
+ interface IconLayout {
54
+ top_percent: number;
55
+ left_percent: number;
56
+ width_percent: number;
57
+ height_percent: number;
58
+ }
59
+ interface SvgPaths {
60
+ clip: string | null;
61
+ inner: string | null;
62
+ shadow: string | null;
63
+ highlight: string | null;
64
+ }
65
+ interface EmbossPath {
66
+ d: string;
67
+ fill: string | null;
68
+ stroke: string | null;
69
+ stroke_width: number | null;
70
+ transform: string | null;
71
+ fill_rule: string | null;
72
+ }
73
+ interface EmbossIconData {
74
+ view_box: string | null;
75
+ paths: EmbossPath[];
76
+ width: number | null;
77
+ height: number | null;
78
+ }
79
+ interface IconCraftResult {
80
+ success: boolean;
81
+ clip_path: string | null;
82
+ inner_clip_path: string | null;
83
+ highlight_clip_paths: string[] | null;
84
+ points_count: number;
85
+ mode: string;
86
+ error: string | null;
87
+ icon_layout: IconLayout | null;
88
+ svg_paths: SvgPaths | null;
89
+ emboss_svg: string | null;
90
+ icon_paths: EmbossIconData | null;
91
+ }
92
+ interface IconCraftShapeProps {
93
+ /** SVG content string or URL */
94
+ svg: string;
95
+ /** Shape mode: jelly, droplet, or wax */
96
+ mode?: ShapeMode;
97
+ /** Base color for the shape (hex) */
98
+ color?: string;
99
+ /** Custom color palette (overrides color) */
100
+ palette?: Partial<ColorPalette>;
101
+ /** Icon rendering style */
102
+ iconStyle?: IconStyle;
103
+ /** Show drop shadow on shape */
104
+ shadow?: boolean;
105
+ /** Show highlight effect */
106
+ highlight?: boolean;
107
+ /** Contour offset (default: 20) */
108
+ offset?: number;
109
+ /** Rasterization resolution (default: 256) */
110
+ resolution?: number;
111
+ /** Polygon simplification epsilon (default: 2.0) */
112
+ simplify?: number;
113
+ /** Width of the component */
114
+ width?: number | string;
115
+ /** Height of the component */
116
+ height?: number | string;
117
+ /** Size shorthand (sets both width and height) */
118
+ size?: number | string;
119
+ /** Animation preset or custom options */
120
+ animation?: AnimationType | AnimationOptions;
121
+ /** Trigger animation on hover */
122
+ animateOnHover?: boolean;
123
+ /** Additional CSS class */
124
+ className?: string;
125
+ /** Inline styles */
126
+ style?: CSSProperties;
127
+ /** Called when generation is complete */
128
+ onLoad?: (result: IconCraftResult) => void;
129
+ /** Called on error */
130
+ onError?: (error: string) => void;
131
+ /** Click handler */
132
+ onClick?: () => void;
133
+ }
134
+ interface IconCraftProps {
135
+ svgContent: string;
136
+ mode?: ShapeMode;
137
+ baseColor?: string;
138
+ offset?: number;
139
+ resolution?: number;
140
+ simplifyEpsilon?: number;
141
+ showShadow?: boolean;
142
+ showHighlight?: boolean;
143
+ className?: string;
144
+ style?: CSSProperties;
145
+ }
146
+
147
+ /**
148
+ * IconCraft 設定インターフェース
149
+ */
150
+ interface IconCraftConfigOptions {
151
+ mode?: ShapeMode;
152
+ color?: string;
153
+ iconStyle?: IconStyle;
154
+ shadow?: boolean;
155
+ highlight?: boolean;
156
+ offset?: number;
157
+ resolution?: number;
158
+ simplify?: number;
159
+ size?: number | string;
160
+ width?: number | string;
161
+ height?: number | string;
162
+ animation?: AnimationType | AnimationOptions;
163
+ animateOnHover?: boolean;
164
+ }
165
+ /**
166
+ * デフォルト設定
167
+ */
168
+ declare const DEFAULT_CONFIG: Required<Omit<IconCraftConfigOptions, 'width' | 'height' | 'animation'>> & Pick<IconCraftConfigOptions, 'width' | 'height' | 'animation'>;
169
+ /**
170
+ * IconCraft 設定クラス(プロトタイプ)
171
+ *
172
+ * このクラスをベースに clone() でユニークなインスタンスを生成する
173
+ */
174
+ declare class IconCraftConfig {
175
+ readonly mode: ShapeMode;
176
+ readonly color: string;
177
+ readonly iconStyle: IconStyle;
178
+ readonly shadow: boolean;
179
+ readonly highlight: boolean;
180
+ readonly offset: number;
181
+ readonly resolution: number;
182
+ readonly simplify: number;
183
+ readonly size: number | string;
184
+ readonly width?: number | string;
185
+ readonly height?: number | string;
186
+ readonly animation?: AnimationType | AnimationOptions;
187
+ readonly animateOnHover: boolean;
188
+ constructor(options?: IconCraftConfigOptions);
189
+ /**
190
+ * 設定を部分的に上書きした新しいConfigを生成
191
+ */
192
+ clone(overrides?: IconCraftConfigOptions): IconCraftConfig;
193
+ /**
194
+ * WASM呼び出し用のパラメータを取得
195
+ */
196
+ getWasmParams(): {
197
+ mode: ShapeMode;
198
+ offset: number;
199
+ resolution: number;
200
+ simplify: number;
201
+ includeIcon: boolean;
202
+ color: string;
203
+ };
204
+ /**
205
+ * スタイル用のサイズを取得
206
+ */
207
+ getSize(): {
208
+ width: string;
209
+ height: string;
210
+ };
211
+ }
212
+
213
+ /**
214
+ * IconCraft インスタンス
215
+ *
216
+ * Factoryから生成されるユニークなオブジェクト
217
+ * 各インスタンスは独自のID、状態(SVG、生成結果)を持つ
218
+ *
219
+ * ID形式: ic_{ULID}
220
+ * 例: ic_01HY7X3K8GQZN5RVXJ2TMCBDEF
221
+ */
222
+ declare class IconCraftInstance {
223
+ private readonly _id;
224
+ private readonly _svg;
225
+ private readonly _config;
226
+ private _svgState;
227
+ private _generateState;
228
+ private _generatePromise;
229
+ constructor(svg: string, config: IconCraftConfig, id?: string);
230
+ get id(): string;
231
+ get svg(): string;
232
+ get config(): IconCraftConfig;
233
+ get isUrl(): boolean;
234
+ get svgContent(): string | null;
235
+ get result(): IconCraftResult | null;
236
+ get embossSvg(): string | null;
237
+ get isLoading(): boolean;
238
+ get isReady(): boolean;
239
+ get error(): string | null;
240
+ /**
241
+ * SVGコンテンツを取得
242
+ */
243
+ fetchSvg(): Promise<string>;
244
+ /**
245
+ * アイコンを生成
246
+ */
247
+ generate(): Promise<IconCraftResult>;
248
+ private _doGenerate;
249
+ /**
250
+ * 新しい設定でクローン
251
+ */
252
+ clone(overrides?: IconCraftConfigOptions): IconCraftInstance;
253
+ /**
254
+ * 別のSVGで新しいインスタンスを作成
255
+ */
256
+ withSvg(svg: string): IconCraftInstance;
257
+ /**
258
+ * 状態をリセット
259
+ */
260
+ reset(): void;
261
+ }
262
+
263
+ /**
264
+ * IconCraft Factory
265
+ *
266
+ * 設定をプロトタイプとして保持し、そこからインスタンスを生成する
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * // Factoryを作成(共通設定)
271
+ * const factory = new IconCraftFactory({
272
+ * mode: 'wax',
273
+ * color: '#6366f1',
274
+ * size: 64,
275
+ * });
276
+ *
277
+ * // インスタンスを生成
278
+ * const icon1 = factory.create('<svg>...</svg>');
279
+ * const icon2 = factory.create('<svg>...</svg>', { color: '#ef4444' }); // 色だけ変更
280
+ *
281
+ * // 生成
282
+ * const result = await icon1.generate();
283
+ * console.log(result.emboss_svg);
284
+ * ```
285
+ */
286
+ declare class IconCraftFactory {
287
+ private readonly prototype;
288
+ constructor(options?: IconCraftConfigOptions);
289
+ /**
290
+ * 新しいインスタンスを生成
291
+ *
292
+ * @param svg - SVGコンテンツまたはURL
293
+ * @param overrides - このインスタンス固有の設定(オプション)
294
+ */
295
+ create(svg: string, overrides?: IconCraftConfigOptions): IconCraftInstance;
296
+ /**
297
+ * プロトタイプ設定を取得
298
+ */
299
+ getConfig(): IconCraftConfig;
300
+ /**
301
+ * 新しい設定でFactoryを複製
302
+ */
303
+ clone(overrides: IconCraftConfigOptions): IconCraftFactory;
304
+ /**
305
+ * 複数のSVGから一括でインスタンスを生成
306
+ */
307
+ createMany(svgs: string[], overrides?: IconCraftConfigOptions): IconCraftInstance[];
308
+ /**
309
+ * 複数のSVGを一括生成
310
+ */
311
+ generateMany(svgs: string[], overrides?: IconCraftConfigOptions): Promise<IconCraftInstance[]>;
312
+ }
313
+ /**
314
+ * デフォルトのFactory(グローバル設定)
315
+ */
316
+ declare const defaultFactory: IconCraftFactory;
317
+
318
+ /**
319
+ * WASM生成パラメータ
320
+ */
321
+ interface WasmGenerateParams {
322
+ svgContent: string;
323
+ mode: ShapeMode;
324
+ offset: number;
325
+ resolution: number;
326
+ simplify: number;
327
+ includeIcon: boolean;
328
+ color: string;
329
+ }
330
+ /**
331
+ * WASMマネージャー(Singleton)
332
+ *
333
+ * - WASMモジュールの初期化を一元管理
334
+ * - 生成結果のキャッシュ
335
+ * - 並列呼び出しのキュー管理
336
+ */
337
+ declare class WasmManagerClass {
338
+ private module;
339
+ private initPromise;
340
+ private cache;
341
+ private maxCacheSize;
342
+ /**
343
+ * WASMモジュールを初期化
344
+ */
345
+ init(): Promise<typeof _gospelo_dev_iconcraft_wasm>;
346
+ /**
347
+ * 初期化済みかどうか
348
+ */
349
+ get isReady(): boolean;
350
+ /**
351
+ * アイコンを生成(キャッシュ付き)
352
+ */
353
+ generate(params: WasmGenerateParams): Promise<IconCraftResult>;
354
+ /**
355
+ * キャッシュに追加(LRU)
356
+ */
357
+ private addToCache;
358
+ /**
359
+ * キャッシュをクリア
360
+ */
361
+ clearCache(): void;
362
+ /**
363
+ * キャッシュサイズを設定
364
+ */
365
+ setMaxCacheSize(size: number): void;
366
+ /**
367
+ * 現在のキャッシュ数
368
+ */
369
+ get cacheSize(): number;
370
+ }
371
+ /**
372
+ * WASMマネージャーのシングルトンインスタンス
373
+ */
374
+ declare const WasmManager: WasmManagerClass;
375
+
376
+ /**
377
+ * ID生成ユーティリティ
378
+ */
379
+ declare function generateIconId(): string;
380
+ /**
381
+ * IDからタイムスタンプを抽出
382
+ */
383
+ declare function getTimestampFromId(id: string): Date | null;
384
+ /**
385
+ * IconCraft レジストリ
386
+ *
387
+ * インスタンスの管理とプロパティ別検索を提供
388
+ */
389
+ declare class IconCraftRegistry {
390
+ private byId;
391
+ private byMode;
392
+ private byColor;
393
+ /**
394
+ * インスタンスを登録
395
+ */
396
+ register(instance: IconCraftInstance): void;
397
+ /**
398
+ * インスタンスを削除
399
+ */
400
+ unregister(id: string): boolean;
401
+ /**
402
+ * IDで取得
403
+ */
404
+ get(id: string): IconCraftInstance | undefined;
405
+ /**
406
+ * 全インスタンスを取得
407
+ */
408
+ getAll(): IconCraftInstance[];
409
+ /**
410
+ * モードで検索
411
+ */
412
+ findByMode(mode: ShapeMode): IconCraftInstance[];
413
+ /**
414
+ * 色で検索
415
+ */
416
+ findByColor(color: string): IconCraftInstance[];
417
+ /**
418
+ * 時間範囲で検索(ULIDのタイムスタンプを利用)
419
+ */
420
+ findByTimeRange(start: Date, end: Date): IconCraftInstance[];
421
+ /**
422
+ * 作成順でソート(ULIDは辞書順でソート可能)
423
+ */
424
+ getAllSorted(order?: 'asc' | 'desc'): IconCraftInstance[];
425
+ /**
426
+ * 登録数
427
+ */
428
+ get size(): number;
429
+ /**
430
+ * すべてクリア
431
+ */
432
+ clear(): void;
433
+ /**
434
+ * インデックスの統計情報
435
+ */
436
+ getStats(): {
437
+ total: number;
438
+ byMode: Record<string, number>;
439
+ byColor: Record<string, number>;
440
+ };
441
+ }
442
+ /**
443
+ * グローバルレジストリ(シングルトン)
444
+ */
445
+ declare const globalRegistry: IconCraftRegistry;
446
+
447
+ interface IconCraftViewProps {
448
+ /** IconCraftInstance */
449
+ instance: IconCraftInstance;
450
+ /** Animation override */
451
+ animation?: AnimationType | AnimationOptions;
452
+ /**
453
+ * Animation target override.
454
+ * - 'shape': Animate only the background shape
455
+ * - 'icon': Animate only the icon inside
456
+ * - 'both': Animate entire component (default)
457
+ */
458
+ animationTarget?: AnimationTarget;
459
+ /** Animate on hover */
460
+ animateOnHover?: boolean;
461
+ /** Z-index for layering */
462
+ zIndex?: number;
463
+ /** Additional CSS class */
464
+ className?: string;
465
+ /** Inline styles */
466
+ style?: CSSProperties;
467
+ /** Click handler */
468
+ onClick?: () => void;
469
+ /** Load callback */
470
+ onLoad?: () => void;
471
+ /** Error callback */
472
+ onError?: (error: string) => void;
473
+ }
474
+ /**
475
+ * IconCraftView - インスタンスからSVGを表示するコンポーネント
476
+ *
477
+ * @example
478
+ * ```tsx
479
+ * const factory = new IconCraftFactory({ mode: 'wax', color: '#6366f1' });
480
+ * const icon = factory.create('<svg>...</svg>');
481
+ *
482
+ * <IconCraftView instance={icon} zIndex={10} />
483
+ * ```
484
+ */
485
+ declare function IconCraftView({ instance, animation, animationTarget, animateOnHover, zIndex, className, style, onClick, onLoad, onError, }: IconCraftViewProps): react_jsx_runtime.JSX.Element | null;
486
+
487
+ /**
488
+ * IconCraftShape - Full-featured emboss icon component
489
+ *
490
+ * @example
491
+ * ```tsx
492
+ * <IconCraftShape
493
+ * svg="<svg>...</svg>"
494
+ * mode="wax"
495
+ * color="#6366f1"
496
+ * size={120}
497
+ * animation="float"
498
+ * />
499
+ * ```
500
+ */
501
+ declare function IconCraftShape({ svg, mode, color, iconStyle, shadow: _shadow, highlight: _highlight, offset, resolution, simplify, width, height, size, animation, animateOnHover, className, style, onLoad, onError, onClick, }: IconCraftShapeProps): react_jsx_runtime.JSX.Element | null;
502
+
503
+ /**
504
+ * Legacy IconCraft component
505
+ * @deprecated Use IconCraftView with IconCraftFactory instead
506
+ */
507
+ declare function IconCraft({ svgContent, mode, baseColor, offset, resolution, simplifyEpsilon, showShadow: _showShadow, showHighlight: _showHighlight, className, style, }: IconCraftProps): react_jsx_runtime.JSX.Element | null;
508
+
509
+ /**
510
+ * インスタンスのメタデータ(位置、サイズ、選択状態など)
511
+ */
512
+ interface IconCraftMetadata {
513
+ x: number;
514
+ y: number;
515
+ zIndex: number;
516
+ width?: number;
517
+ height?: number;
518
+ rotation?: number;
519
+ scale?: number;
520
+ opacity?: number;
521
+ animation?: AnimationType;
522
+ custom?: Record<string, unknown>;
523
+ }
524
+ declare const DEFAULT_METADATA: IconCraftMetadata;
525
+ /**
526
+ * イベントタイプ
527
+ */
528
+ type IconCraftEventType = 'created' | 'removed' | 'ready' | 'error' | 'select' | 'deselect' | 'move' | 'resize' | 'zIndex' | 'transform' | 'config' | 'metadata' | 'custom';
529
+ /**
530
+ * イベントペイロード
531
+ */
532
+ type IconCraftEvent = {
533
+ type: 'created';
534
+ id: string;
535
+ instance: IconCraftInstance;
536
+ } | {
537
+ type: 'removed';
538
+ id: string;
539
+ } | {
540
+ type: 'ready';
541
+ id: string;
542
+ result: IconCraftResult;
543
+ } | {
544
+ type: 'error';
545
+ id: string;
546
+ error: string;
547
+ } | {
548
+ type: 'select';
549
+ id: string;
550
+ } | {
551
+ type: 'deselect';
552
+ id: string;
553
+ } | {
554
+ type: 'move';
555
+ id: string;
556
+ x: number;
557
+ y: number;
558
+ } | {
559
+ type: 'resize';
560
+ id: string;
561
+ width: number;
562
+ height: number;
563
+ } | {
564
+ type: 'zIndex';
565
+ id: string;
566
+ zIndex: number;
567
+ } | {
568
+ type: 'transform';
569
+ id: string;
570
+ changes: Partial<IconCraftMetadata>;
571
+ } | {
572
+ type: 'config';
573
+ id: string;
574
+ changes: Partial<IconCraftConfigOptions>;
575
+ } | {
576
+ type: 'metadata';
577
+ id: string;
578
+ changes: Partial<IconCraftMetadata>;
579
+ } | {
580
+ type: 'custom';
581
+ id: string;
582
+ name: string;
583
+ payload: unknown;
584
+ };
585
+ /**
586
+ * イベントハンドラー
587
+ */
588
+ type IconCraftEventHandler<T extends IconCraftEvent = IconCraftEvent> = (event: T) => void;
589
+ /**
590
+ * イベントフィルター('*' で全イベント)
591
+ */
592
+ type IconCraftEventFilter = string | '*';
593
+ /**
594
+ * ストアの状態
595
+ */
596
+ interface IconCraftStoreState {
597
+ instances: Map<string, IconCraftInstance>;
598
+ metadata: Map<string, IconCraftMetadata>;
599
+ selection: Set<string>;
600
+ }
601
+ /**
602
+ * ストアのアクション
603
+ */
604
+ interface IconCraftStoreActions {
605
+ create: (svg: string, config?: Partial<IconCraftConfigOptions>, metadata?: Partial<IconCraftMetadata>) => string;
606
+ remove: (id: string) => boolean;
607
+ getById: (id: string) => IconCraftInstance | undefined;
608
+ getAll: () => IconCraftInstance[];
609
+ getMetadata: (id: string) => IconCraftMetadata | undefined;
610
+ updateMetadata: (id: string, changes: Partial<IconCraftMetadata>) => void;
611
+ select: (id: string) => void;
612
+ deselect: (id: string) => void;
613
+ toggleSelect: (id: string) => void;
614
+ clearSelection: () => void;
615
+ getSelected: () => string[];
616
+ isSelected: (id: string) => boolean;
617
+ clear: () => void;
618
+ }
619
+ /**
620
+ * イベントディスパッチャー
621
+ */
622
+ interface IconCraftDispatcher {
623
+ dispatch: (event: IconCraftEvent) => void;
624
+ subscribe: (filter: IconCraftEventFilter, eventType: IconCraftEventType | IconCraftEventType[] | '*', handler: IconCraftEventHandler) => () => void;
625
+ }
626
+ /**
627
+ * Contextの値
628
+ */
629
+ interface IconCraftContextValue {
630
+ state: IconCraftStoreState;
631
+ actions: IconCraftStoreActions;
632
+ dispatcher: IconCraftDispatcher;
633
+ defaultConfig: Partial<IconCraftConfigOptions>;
634
+ }
635
+
636
+ interface IconCraftProviderProps {
637
+ children: ReactNode;
638
+ defaultConfig?: Partial<IconCraftConfigOptions>;
639
+ }
640
+ declare function IconCraftProvider({ children, defaultConfig, }: IconCraftProviderProps): react_jsx_runtime.JSX.Element;
641
+ declare function useIconCraftContext(): IconCraftContextValue;
642
+
643
+ /**
644
+ * ストア操作用フック
645
+ *
646
+ * @example
647
+ * ```tsx
648
+ * const { create, remove, getAll } = useIconCraftStore();
649
+ *
650
+ * const handleAdd = () => {
651
+ * const id = create('<svg>...</svg>', { mode: 'wax' });
652
+ * console.log('Created:', id);
653
+ * };
654
+ * ```
655
+ */
656
+ declare function useIconCraftStore(): {
657
+ create: (svg: string, config?: Partial<IconCraftConfigOptions>, metadata?: Partial<IconCraftMetadata>) => string;
658
+ remove: (id: string) => boolean;
659
+ getById: (id: string) => IconCraftInstance | undefined;
660
+ getAll: () => IconCraftInstance[];
661
+ getMetadata: (id: string) => IconCraftMetadata | undefined;
662
+ updateMetadata: (id: string, changes: Partial<IconCraftMetadata>) => void;
663
+ clear: () => void;
664
+ count: number;
665
+ ids: string[];
666
+ };
667
+ interface UseIconCraftReturn$1 {
668
+ instance: IconCraftInstance | undefined;
669
+ metadata: IconCraftMetadata | undefined;
670
+ isSelected: boolean;
671
+ exists: boolean;
672
+ remove: () => boolean;
673
+ updateMetadata: (changes: Partial<IconCraftMetadata>) => void;
674
+ select: () => void;
675
+ deselect: () => void;
676
+ toggleSelect: () => void;
677
+ move: (x: number, y: number) => void;
678
+ setZIndex: (zIndex: number) => void;
679
+ }
680
+ /**
681
+ * 特定インスタンス操作用フック
682
+ *
683
+ * @example
684
+ * ```tsx
685
+ * const { instance, metadata, move, select } = useIconCraft('ic_xxx');
686
+ *
687
+ * <div
688
+ * style={{ transform: `translate(${metadata?.x}px, ${metadata?.y}px)` }}
689
+ * onClick={select}
690
+ * onDrag={(e) => move(e.clientX, e.clientY)}
691
+ * >
692
+ * <IconCraftView instance={instance} />
693
+ * </div>
694
+ * ```
695
+ */
696
+ declare function useIconCraft$1(id: string): UseIconCraftReturn$1;
697
+ interface UseIconCraftSelectionReturn {
698
+ selected: string[];
699
+ count: number;
700
+ hasSelection: boolean;
701
+ select: (id: string) => void;
702
+ deselect: (id: string) => void;
703
+ toggle: (id: string) => void;
704
+ clear: () => void;
705
+ isSelected: (id: string) => boolean;
706
+ selectAll: () => void;
707
+ getSelectedInstances: () => IconCraftInstance[];
708
+ }
709
+ /**
710
+ * 選択管理用フック
711
+ *
712
+ * @example
713
+ * ```tsx
714
+ * const { selected, hasSelection, clear, selectAll } = useIconCraftSelection();
715
+ *
716
+ * <button onClick={selectAll}>Select All</button>
717
+ * <button onClick={clear} disabled={!hasSelection}>Clear</button>
718
+ * <span>{selected.length} selected</span>
719
+ * ```
720
+ */
721
+ declare function useIconCraftSelection(): UseIconCraftSelectionReturn;
722
+ /**
723
+ * イベント購読用フック
724
+ *
725
+ * @param filter - 対象ID('*' で全て)
726
+ * @param eventType - イベントタイプ('*' で全て)
727
+ * @param handler - イベントハンドラー
728
+ *
729
+ * @example
730
+ * ```tsx
731
+ * // 特定IDのmoveイベント
732
+ * useIconCraftEvent('ic_xxx', 'move', (event) => {
733
+ * console.log('Moved:', event.x, event.y);
734
+ * });
735
+ *
736
+ * // 全インスタンスのselect/deselectイベント
737
+ * useIconCraftEvent('*', ['select', 'deselect'], (event) => {
738
+ * console.log('Selection changed:', event.id);
739
+ * });
740
+ *
741
+ * // 全イベント
742
+ * useIconCraftEvent('*', '*', (event) => {
743
+ * console.log('Event:', event.type, event.id);
744
+ * });
745
+ * ```
746
+ */
747
+ declare function useIconCraftEvent(filter: IconCraftEventFilter, eventType: IconCraftEventType | IconCraftEventType[] | '*', handler: IconCraftEventHandler): void;
748
+ interface UseIconCraftCreateOptions {
749
+ config?: Partial<IconCraftConfigOptions>;
750
+ metadata?: Partial<IconCraftMetadata>;
751
+ autoSelect?: boolean;
752
+ }
753
+ /**
754
+ * インスタンス作成用フック
755
+ *
756
+ * @example
757
+ * ```tsx
758
+ * const createIcon = useIconCraftCreate({
759
+ * config: { mode: 'wax', color: '#6366f1' },
760
+ * autoSelect: true,
761
+ * });
762
+ *
763
+ * <button onClick={() => createIcon('<svg>...</svg>')}>
764
+ * Add Icon
765
+ * </button>
766
+ * ```
767
+ */
768
+ declare function useIconCraftCreate(options?: UseIconCraftCreateOptions): (svg: string, overrides?: Partial<IconCraftConfigOptions>) => string;
769
+
770
+ /**
771
+ * イベントディスパッチャーの作成
772
+ */
773
+ declare function createDispatcher(): IconCraftDispatcher;
774
+
775
+ interface UseIconCraftOptions {
776
+ /** SVG content string or URL */
777
+ svg: string;
778
+ /** Shape mode */
779
+ mode?: ShapeMode;
780
+ /** Base color (hex) */
781
+ color?: string;
782
+ /** Icon style */
783
+ iconStyle?: IconStyle;
784
+ /** Contour offset */
785
+ offset?: number;
786
+ /** Rasterization resolution */
787
+ resolution?: number;
788
+ /** Polygon simplification epsilon */
789
+ simplify?: number;
790
+ /** Auto-generate on mount/change */
791
+ autoGenerate?: boolean;
792
+ }
793
+ interface UseIconCraftReturn {
794
+ /** Generated result */
795
+ result: IconCraftResult | null;
796
+ /** Loading state */
797
+ isLoading: boolean;
798
+ /** Error message */
799
+ error: string | null;
800
+ /** Resolved SVG content */
801
+ svgContent: string | null;
802
+ /** Manually trigger generation */
803
+ generate: () => Promise<void>;
804
+ /** Reset state */
805
+ reset: () => void;
806
+ }
807
+ /**
808
+ * Hook for generating IconCraft shapes
809
+ *
810
+ * @example
811
+ * ```tsx
812
+ * const { result, isLoading, error } = useIconCraft({
813
+ * svg: '<svg>...</svg>',
814
+ * mode: 'wax',
815
+ * color: '#6366f1',
816
+ * });
817
+ * ```
818
+ */
819
+ declare function useIconCraft(options: UseIconCraftOptions): UseIconCraftReturn;
820
+ interface UseLegacyIconCraftOptions {
821
+ svgContent: string;
822
+ mode?: ShapeMode;
823
+ baseColor?: string;
824
+ offset?: number;
825
+ resolution?: number;
826
+ simplifyEpsilon?: number;
827
+ }
828
+ interface UseLegacyIconCraftReturn {
829
+ result: IconCraftResult | null;
830
+ isLoading: boolean;
831
+ error: string | null;
832
+ generate: () => Promise<void>;
833
+ }
834
+ /**
835
+ * Legacy hook (backwards compatibility)
836
+ * @deprecated Use useIconCraft with new API instead
837
+ */
838
+ declare function useLegacyIconCraft(options: UseLegacyIconCraftOptions): UseLegacyIconCraftReturn;
839
+
840
+ /**
841
+ * Transform origin preset for icon animations
842
+ * - 'center': Element center using transform-box: fill-box (default)
843
+ * - 'icon': Same as 'center' but semantically for icon-only animations
844
+ * - 'top': Top center (50% 0%)
845
+ * - 'bottom': Bottom center (50% 100%)
846
+ * - 'left': Left center (0% 50%)
847
+ * - 'right': Right center (100% 50%)
848
+ * - 'top-left': Top left corner (0% 0%)
849
+ * - 'top-right': Top right corner (100% 0%)
850
+ * - 'bottom-left': Bottom left corner (0% 100%)
851
+ * - 'bottom-right': Bottom right corner (100% 100%)
852
+ */
853
+ type TransformOriginPreset = 'center' | 'icon' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
854
+ /**
855
+ * Custom transform origin coordinates (type-safe)
856
+ * @example
857
+ * { x: '50%', y: 0 } // top center
858
+ * { x: 0, y: '100%' } // bottom left
859
+ * { x: '25%', y: '75%' } // custom position
860
+ */
861
+ interface TransformOriginCustom {
862
+ /** X coordinate - number (px) or string (%, px, etc.) */
863
+ x: string | number;
864
+ /** Y coordinate - number (px) or string (%, px, etc.) */
865
+ y: string | number;
866
+ }
867
+ /**
868
+ * Transform origin value - preset or custom coordinates
869
+ * @example
870
+ * 'center' // preset
871
+ * 'top-left' // preset
872
+ * { x: '50%', y: 0 } // custom (type-safe)
873
+ * { x: 0, y: '100%' } // custom (type-safe)
874
+ */
875
+ type TransformOriginValue = TransformOriginPreset | TransformOriginCustom;
876
+ interface CustomAnimationDefinition {
877
+ /** CSS @keyframes rule string */
878
+ keyframes: string;
879
+ /** Default animation options */
880
+ defaults?: Omit<AnimationOptions, 'type'>;
881
+ /**
882
+ * Transform origin for the animation.
883
+ * Can be a preset ('center', 'icon', 'top', etc.) or a custom CSS value ('50% 0%', etc.)
884
+ * @default 'center'
885
+ */
886
+ transformOrigin?: TransformOriginValue;
887
+ }
888
+ /**
889
+ * Register a custom animation.
890
+ *
891
+ * @example
892
+ * ```typescript
893
+ * registerAnimation('tada', {
894
+ * keyframes: `
895
+ * @keyframes iconcraft-tada {
896
+ * 0% { transform: scale(1) rotate(0deg); }
897
+ * 10%, 20% { transform: scale(0.9) rotate(-3deg); }
898
+ * 30%, 50%, 70%, 90% { transform: scale(1.1) rotate(3deg); }
899
+ * 40%, 60%, 80% { transform: scale(1.1) rotate(-3deg); }
900
+ * 100% { transform: scale(1) rotate(0deg); }
901
+ * }
902
+ * `,
903
+ * defaults: { duration: 1, iterationCount: 1 }
904
+ * });
905
+ * ```
906
+ */
907
+ declare function registerAnimation(name: string, definition: CustomAnimationDefinition): void;
908
+ /**
909
+ * Get custom animation definition
910
+ */
911
+ declare function getCustomAnimation(name: string): CustomAnimationDefinition | undefined;
912
+ /**
913
+ * Get transform origin value for an animation type
914
+ */
915
+ declare function getTransformOrigin(type: AnimationType): TransformOriginValue;
916
+ /**
917
+ * Get animation defaults (built-in or custom)
918
+ */
919
+ declare function getAnimationDefaults(type: AnimationType): Omit<AnimationOptions, 'type'>;
920
+ /** @deprecated Use getAnimationDefaults instead */
921
+ declare const animationDefaults: Record<BuiltInAnimationType, Omit<AnimationOptions, "type">>;
922
+ /**
923
+ * Get animation name from type
924
+ */
925
+ declare function getAnimationName(type: AnimationType): string;
926
+ /**
927
+ * Parse animation prop into full options
928
+ */
929
+ declare function parseAnimationOptions(animation: AnimationType | AnimationOptions | undefined): AnimationOptions | null;
930
+ /**
931
+ * Generate CSS animation string
932
+ */
933
+ declare function getAnimationStyle(options: AnimationOptions | null): string;
934
+ /**
935
+ * Get keyframes CSS for an animation type (built-in or custom)
936
+ */
937
+ declare function getKeyframes(type: AnimationType): string;
938
+ /** @deprecated Use getKeyframes instead */
939
+ declare const keyframes: Record<BuiltInAnimationType, string>;
940
+ declare function injectKeyframes(type: AnimationType): void;
941
+
942
+ export { type AnimationOptions, type AnimationTarget, type AnimationType, type BuiltInAnimationType, type ColorPalette, type CustomAnimationDefinition, type CustomAnimationRegistry, DEFAULT_CONFIG, DEFAULT_METADATA, type EmbossIconData, type EmbossPath, IconCraft, IconCraftConfig, type IconCraftConfigOptions, type IconCraftContextValue, type IconCraftDispatcher, type IconCraftEvent, type IconCraftEventFilter, type IconCraftEventHandler, type IconCraftEventType, IconCraftFactory, IconCraftInstance, type IconCraftMetadata, type IconCraftProps, IconCraftProvider, type IconCraftProviderProps, IconCraftRegistry, type IconCraftResult, IconCraftShape, type IconCraftShapeProps, type IconCraftStoreActions, type IconCraftStoreState, IconCraftView, type IconCraftViewProps, type IconLayout, type IconStyle, type ShapeMode, type SvgPaths, type TransformOriginCustom, type TransformOriginPreset, type TransformOriginValue, type UseIconCraftCreateOptions, type UseIconCraftReturn$1 as UseIconCraftInstanceReturn, type UseIconCraftOptions, type UseIconCraftReturn, type UseIconCraftSelectionReturn, type WasmGenerateParams, WasmManager, animationDefaults, createDispatcher, defaultFactory, generateIconId, getAnimationDefaults, getAnimationName, getAnimationStyle, getCustomAnimation, getKeyframes, getTimestampFromId, getTransformOrigin, globalRegistry, injectKeyframes, keyframes, parseAnimationOptions, registerAnimation, useIconCraft, useIconCraftContext, useIconCraftCreate, useIconCraftEvent, useIconCraft$1 as useIconCraftInstance, useIconCraftSelection, useIconCraftStore, useLegacyIconCraft };