gospelo-iconcraft-react 0.3.7 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +124 -0
  2. package/dist/index.js +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -353,6 +353,121 @@ function IconGallery() {
353
353
  }
354
354
  ```
355
355
 
356
+ ### Advanced Context Hooks
357
+
358
+ ```tsx
359
+ import {
360
+ useIconCraftSelection,
361
+ useIconCraftCreate,
362
+ useIconCraftEvent,
363
+ } from 'gospelo-iconcraft-react';
364
+
365
+ // Selection management
366
+ function SelectionToolbar() {
367
+ const { selected, count, hasSelection, selectAll, getSelectedInstances } =
368
+ useIconCraftSelection();
369
+
370
+ return <span>{count} selected</span>;
371
+ }
372
+
373
+ // Create icons with options
374
+ function IconCreator() {
375
+ const create = useIconCraftCreate({
376
+ config: { mode: 'jelly', shapeColor: '#6366f1' },
377
+ autoSelect: true,
378
+ });
379
+
380
+ const handleAdd = (svg: string) => {
381
+ const id = create(svg);
382
+ };
383
+ }
384
+
385
+ // Event subscription
386
+ function EventLogger() {
387
+ useIconCraftEvent('*', 'update', (event) => {
388
+ console.log('Icon updated:', event);
389
+ });
390
+ }
391
+ ```
392
+
393
+ ## Backup / Restore
394
+
395
+ Save and restore icon configurations as JSON:
396
+
397
+ ```tsx
398
+ import {
399
+ createBackup,
400
+ downloadBackup,
401
+ loadBackupFromFile,
402
+ validateBackup,
403
+ } from 'gospelo-iconcraft-react';
404
+
405
+ // Create backup from icon data
406
+ const backup = createBackup(icons, { license: 'MIT' });
407
+
408
+ // Download as JSON file
409
+ downloadBackup(backup, 'my-icons.json');
410
+
411
+ // Load from file input
412
+ const fileInput = document.querySelector('input[type="file"]');
413
+ fileInput.addEventListener('change', async (e) => {
414
+ const file = e.target.files[0];
415
+ const loaded = await loadBackupFromFile(file);
416
+ if (loaded) {
417
+ console.log('Loaded icons:', loaded.icons);
418
+ }
419
+ });
420
+
421
+ // Validate backup data
422
+ const result = validateBackup(data);
423
+ if (!result.valid) {
424
+ console.error('Validation errors:', result.errors);
425
+ }
426
+ ```
427
+
428
+ ## WasmManager
429
+
430
+ Singleton manager for WASM initialization and caching:
431
+
432
+ ```tsx
433
+ import { WasmManager } from 'gospelo-iconcraft-react';
434
+
435
+ // Manually initialize (usually handled automatically)
436
+ await WasmManager.init();
437
+
438
+ // Check readiness
439
+ console.log(WasmManager.isReady);
440
+
441
+ // Cache control
442
+ WasmManager.setMaxCacheSize(200);
443
+ console.log('Cached:', WasmManager.cacheSize);
444
+ WasmManager.clearCache();
445
+ ```
446
+
447
+ ## Registry
448
+
449
+ Global instance tracking and search:
450
+
451
+ ```tsx
452
+ import { globalRegistry, generateIconId, getTimestampFromId } from 'gospelo-iconcraft-react';
453
+
454
+ // Query instances
455
+ const allIcons = globalRegistry.getAll();
456
+ const jellyIcons = globalRegistry.findByMode('jelly');
457
+ const blueIcons = globalRegistry.findByColor('#6366f1');
458
+
459
+ // Time-based queries (ULID-based IDs)
460
+ const recentIcons = globalRegistry.findByTimeRange(startDate, endDate);
461
+ const sorted = globalRegistry.getAllSorted('newest');
462
+
463
+ // Stats
464
+ const stats = globalRegistry.getStats();
465
+
466
+ // ID utilities
467
+ const id = generateIconId(); // "ic_01HGW..."
468
+ const created = getTimestampFromId(id); // Date
469
+ ```
470
+
356
471
  ## TypeScript
357
472
 
358
473
  Full TypeScript support with exported types:
@@ -366,6 +481,7 @@ import type {
366
481
  IconCraftResult,
367
482
  IconCraftShapeProps,
368
483
  IconCraftViewProps,
484
+ IconCraftConfigOptions,
369
485
  DialPreset,
370
486
  DialPresetName,
371
487
  ReticlePreset,
@@ -374,6 +490,14 @@ import type {
374
490
  DialNotchProps,
375
491
  DialLabelProps,
376
492
  ReticleProps,
493
+ IconBackupData,
494
+ IconCraftBackup,
495
+ BackupValidationResult,
496
+ CustomAnimationDefinition,
497
+ TransformOriginValue,
498
+ IconCraftMetadata,
499
+ IconCraftEvent,
500
+ IconCraftEventType,
377
501
  } from 'gospelo-iconcraft-react';
378
502
  ```
379
503
 
package/dist/index.js CHANGED
@@ -1972,7 +1972,7 @@ function IconCraftView({
1972
1972
  }
1973
1973
  );
1974
1974
  }
1975
- const dialDegValue = isRotating ? dialDeg : rotation;
1975
+ const dialDegValue = isRotating ? dialDeg : cssRotation != null ? cssRotation : rotation;
1976
1976
  const dialPadding = 14;
1977
1977
  const actualWidth = measuredSize || containerStyle.width || 0;
1978
1978
  const dialSvgSize = actualWidth ? actualWidth + dialPadding * 2 : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gospelo-iconcraft-react",
3
- "version": "0.3.7",
3
+ "version": "0.5.0",
4
4
  "description": "IconCraft React components - 3D decorative icon shapes from SVG",
5
5
  "license": "MIT",
6
6
  "author": "gorosun <goro-hayakawa@no-studio.net>",
@@ -32,7 +32,7 @@
32
32
  "react-dom": ">=18.0.0"
33
33
  },
34
34
  "dependencies": {
35
- "gospelo-iconcraft-wasm": "^0.3.5",
35
+ "gospelo-iconcraft-wasm": "^0.4.0",
36
36
  "ulid": "^3.0.2"
37
37
  },
38
38
  "devDependencies": {