aniview 1.0.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 (64) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +130 -0
  4. package/dist/Aniview.d.ts +63 -0
  5. package/dist/Aniview.d.ts.map +1 -0
  6. package/dist/Aniview.js +831 -0
  7. package/dist/Aniview.js.map +1 -0
  8. package/dist/AniviewPanel.d.ts +33 -0
  9. package/dist/AniviewPanel.d.ts.map +1 -0
  10. package/dist/AniviewPanel.js +66 -0
  11. package/dist/AniviewPanel.js.map +1 -0
  12. package/dist/GestureStressTest.d.ts +3 -0
  13. package/dist/GestureStressTest.d.ts.map +1 -0
  14. package/dist/GestureStressTest.js +125 -0
  15. package/dist/GestureStressTest.js.map +1 -0
  16. package/dist/aniviewConfig.d.ts +175 -0
  17. package/dist/aniviewConfig.d.ts.map +1 -0
  18. package/dist/aniviewConfig.js +568 -0
  19. package/dist/aniviewConfig.js.map +1 -0
  20. package/dist/aniviewProvider.d.ts +93 -0
  21. package/dist/aniviewProvider.d.ts.map +1 -0
  22. package/dist/aniviewProvider.js +229 -0
  23. package/dist/aniviewProvider.js.map +1 -0
  24. package/dist/core/AniviewLock.d.ts +16 -0
  25. package/dist/core/AniviewLock.d.ts.map +1 -0
  26. package/dist/core/AniviewLock.js +18 -0
  27. package/dist/core/AniviewLock.js.map +1 -0
  28. package/dist/core/AniviewMath.d.ts +41 -0
  29. package/dist/core/AniviewMath.d.ts.map +1 -0
  30. package/dist/core/AniviewMath.js +69 -0
  31. package/dist/core/AniviewMath.js.map +1 -0
  32. package/dist/index.d.ts +7 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +7 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/useAniview.d.ts +39 -0
  37. package/dist/useAniview.d.ts.map +1 -0
  38. package/dist/useAniview.js +32 -0
  39. package/dist/useAniview.js.map +1 -0
  40. package/dist/useAniviewContext.d.ts +156 -0
  41. package/dist/useAniviewContext.d.ts.map +1 -0
  42. package/dist/useAniviewContext.js +3 -0
  43. package/dist/useAniviewContext.js.map +1 -0
  44. package/dist/useAniviewLock.d.ts +20 -0
  45. package/dist/useAniviewLock.d.ts.map +1 -0
  46. package/dist/useAniviewLock.js +32 -0
  47. package/dist/useAniviewLock.js.map +1 -0
  48. package/package.json +60 -0
  49. package/src/Aniview.tsx +868 -0
  50. package/src/AniviewPanel.tsx +141 -0
  51. package/src/GestureStressTest.tsx +144 -0
  52. package/src/__tests__/AniviewLock.test.ts +58 -0
  53. package/src/__tests__/AniviewMath.test.ts +211 -0
  54. package/src/__tests__/AniviewSnapshot.test.tsx +85 -0
  55. package/src/__tests__/__snapshots__/AniviewSnapshot.test.tsx.snap +7 -0
  56. package/src/__tests__/aniviewConfig.test.ts +70 -0
  57. package/src/aniviewConfig.tsx +688 -0
  58. package/src/aniviewProvider.tsx +307 -0
  59. package/src/core/AniviewLock.ts +23 -0
  60. package/src/core/AniviewMath.ts +107 -0
  61. package/src/index.ts +6 -0
  62. package/src/useAniview.tsx +75 -0
  63. package/src/useAniviewContext.tsx +170 -0
  64. package/src/useAniviewLock.tsx +37 -0
@@ -0,0 +1,70 @@
1
+ import { AniviewConfig } from '../aniviewConfig';
2
+
3
+ describe('AniviewConfig Semantic Mapping', () => {
4
+ const layout = [[1, 1, 1]]; // 3 pages in a row
5
+ const pageMap = {
6
+ 'WARDROBE': 0,
7
+ 'SHELVES': 1,
8
+ 'ROOM': 2
9
+ };
10
+ const dims = {
11
+ width: 400,
12
+ height: 800,
13
+ offsetX: 0,
14
+ offsetY: 0
15
+ };
16
+
17
+ let config: AniviewConfig;
18
+
19
+ beforeEach(() => {
20
+ config = new AniviewConfig(layout, 0, pageMap, dims, {}, {});
21
+ });
22
+
23
+ test('resolvePageId: should resolve numeric indices directly', () => {
24
+ expect(config.resolvePageId(0)).toBe(0);
25
+ expect(config.resolvePageId(1)).toBe(1);
26
+ });
27
+
28
+ test('resolvePageId: should resolve semantic names from pageMap', () => {
29
+ expect(config.resolvePageId('WARDROBE')).toBe(0);
30
+ expect(config.resolvePageId('SHELVES')).toBe(1);
31
+ expect(config.resolvePageId('ROOM')).toBe(2);
32
+ });
33
+
34
+ test('resolvePageId: should fallback to parseInt for unknown strings', () => {
35
+ expect(config.resolvePageId('1')).toBe(1);
36
+ expect(config.resolvePageId('99')).toBe(99);
37
+ expect(config.resolvePageId('invalid')).toBe(0); // Default fallback
38
+ });
39
+
40
+ test('getPageOffset: should return correct coordinates for semantic names', () => {
41
+ const wardrobeOffset = config.getPageOffset('WARDROBE', dims);
42
+ const shelvesOffset = config.getPageOffset('SHELVES', dims);
43
+ const roomOffset = config.getPageOffset('ROOM', dims);
44
+
45
+ expect(wardrobeOffset).toEqual({ x: 0, y: 0 });
46
+ expect(shelvesOffset).toEqual({ x: 400, y: 0 });
47
+ expect(roomOffset).toEqual({ x: 800, y: 0 });
48
+ });
49
+
50
+ test('register: should bake frames correctly with semantic keys', () => {
51
+ const keyframes = {
52
+ move: { page: 'ROOM', style: { opacity: 0.5 } }
53
+ };
54
+
55
+ // Register component on SHELVES, moving to ROOM
56
+ const bake = config.register('SHELVES', dims, keyframes);
57
+
58
+ expect(bake.homeOffset).toEqual({ x: 400, y: 0 });
59
+ expect(bake.bakedFrames['move'].worldX).toBe(400); // 800 (ROOM) - 400 (SHELVES)
60
+ expect(bake.bakedFrames['move'].worldY).toBe(0);
61
+ });
62
+
63
+ test('getWorldBounds: should calculate correct limits for semantic layout', () => {
64
+ const bounds = config.getWorldBounds(dims);
65
+ expect(bounds.minX).toBe(0);
66
+ expect(bounds.maxX).toBe(800);
67
+ expect(bounds.minY).toBe(0);
68
+ expect(bounds.maxY).toBe(0);
69
+ });
70
+ });