@freegamestore/games 0.16.0 → 0.19.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 (114) hide show
  1. package/README.md +106 -8
  2. package/TOKENS.md +132 -0
  3. package/dist/Confetti.d.ts +18 -0
  4. package/dist/Confetti.d.ts.map +1 -0
  5. package/dist/Confetti.js +43 -0
  6. package/dist/Confetti.js.map +1 -0
  7. package/dist/GameAuth.d.ts.map +1 -1
  8. package/dist/GameAuth.js +5 -87
  9. package/dist/GameAuth.js.map +1 -1
  10. package/dist/GameButton.d.ts +2 -1
  11. package/dist/GameButton.d.ts.map +1 -1
  12. package/dist/GameButton.js +16 -67
  13. package/dist/GameButton.js.map +1 -1
  14. package/dist/GameConfirm.d.ts +1 -1
  15. package/dist/GameConfirm.d.ts.map +1 -1
  16. package/dist/GameConfirm.js +1 -7
  17. package/dist/GameConfirm.js.map +1 -1
  18. package/dist/GameModal.d.ts +3 -2
  19. package/dist/GameModal.d.ts.map +1 -1
  20. package/dist/GameModal.js +3 -40
  21. package/dist/GameModal.js.map +1 -1
  22. package/dist/GameOverScreen.d.ts +3 -2
  23. package/dist/GameOverScreen.d.ts.map +1 -1
  24. package/dist/GameOverScreen.js +3 -37
  25. package/dist/GameOverScreen.js.map +1 -1
  26. package/dist/GameResultScreen.d.ts +41 -0
  27. package/dist/GameResultScreen.d.ts.map +1 -0
  28. package/dist/GameResultScreen.js +25 -0
  29. package/dist/GameResultScreen.js.map +1 -0
  30. package/dist/GameShell.d.ts +3 -0
  31. package/dist/GameShell.d.ts.map +1 -1
  32. package/dist/GameShell.js +4 -43
  33. package/dist/GameShell.js.map +1 -1
  34. package/dist/GameTextSizeToggle.d.ts +1 -1
  35. package/dist/GameTextSizeToggle.d.ts.map +1 -1
  36. package/dist/GameTextSizeToggle.js +1 -16
  37. package/dist/GameTextSizeToggle.js.map +1 -1
  38. package/dist/GameThemeToggle.d.ts +1 -1
  39. package/dist/GameThemeToggle.d.ts.map +1 -1
  40. package/dist/GameThemeToggle.js +44 -21
  41. package/dist/GameThemeToggle.js.map +1 -1
  42. package/dist/GameTopbar.d.ts +12 -7
  43. package/dist/GameTopbar.d.ts.map +1 -1
  44. package/dist/GameTopbar.js +54 -188
  45. package/dist/GameTopbar.js.map +1 -1
  46. package/dist/GameTopbar.module.css +201 -0
  47. package/dist/Leaderboard.d.ts.map +1 -1
  48. package/dist/Leaderboard.js +2 -5
  49. package/dist/Leaderboard.js.map +1 -1
  50. package/dist/StartScreen.d.ts +41 -0
  51. package/dist/StartScreen.d.ts.map +1 -0
  52. package/dist/StartScreen.js +30 -0
  53. package/dist/StartScreen.js.map +1 -0
  54. package/dist/feel/ScorePopup.d.ts +20 -0
  55. package/dist/feel/ScorePopup.d.ts.map +1 -0
  56. package/dist/feel/ScorePopup.js +51 -0
  57. package/dist/feel/ScorePopup.js.map +1 -0
  58. package/dist/feel/easing.d.ts +14 -0
  59. package/dist/feel/easing.d.ts.map +1 -0
  60. package/dist/feel/easing.js +12 -0
  61. package/dist/feel/easing.js.map +1 -0
  62. package/dist/feel/haptics.d.ts +19 -0
  63. package/dist/feel/haptics.d.ts.map +1 -0
  64. package/dist/feel/haptics.js +24 -0
  65. package/dist/feel/haptics.js.map +1 -0
  66. package/dist/feel/index.d.ts +17 -0
  67. package/dist/feel/index.d.ts.map +1 -0
  68. package/dist/feel/index.js +17 -0
  69. package/dist/feel/index.js.map +1 -0
  70. package/dist/feel/particles.d.ts +46 -0
  71. package/dist/feel/particles.d.ts.map +1 -0
  72. package/dist/feel/particles.js +61 -0
  73. package/dist/feel/particles.js.map +1 -0
  74. package/dist/feel/reducedMotion.d.ts +6 -0
  75. package/dist/feel/reducedMotion.d.ts.map +1 -0
  76. package/dist/feel/reducedMotion.js +10 -0
  77. package/dist/feel/reducedMotion.js.map +1 -0
  78. package/dist/feel/shake.d.ts +6 -0
  79. package/dist/feel/shake.d.ts.map +1 -0
  80. package/dist/feel/shake.js +17 -0
  81. package/dist/feel/shake.js.map +1 -0
  82. package/dist/feel/tween.d.ts +9 -0
  83. package/dist/feel/tween.d.ts.map +1 -0
  84. package/dist/feel/tween.js +15 -0
  85. package/dist/feel/tween.js.map +1 -0
  86. package/dist/feel/useHaptics.d.ts +12 -0
  87. package/dist/feel/useHaptics.d.ts.map +1 -0
  88. package/dist/feel/useHaptics.js +16 -0
  89. package/dist/feel/useHaptics.js.map +1 -0
  90. package/dist/feel/useParticles.d.ts +18 -0
  91. package/dist/feel/useParticles.d.ts.map +1 -0
  92. package/dist/feel/useParticles.js +79 -0
  93. package/dist/feel/useParticles.js.map +1 -0
  94. package/dist/feel/useShake.d.ts +14 -0
  95. package/dist/feel/useShake.d.ts.map +1 -0
  96. package/dist/feel/useShake.js +17 -0
  97. package/dist/feel/useShake.js.map +1 -0
  98. package/dist/index.d.ts +5 -2
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +14 -2
  101. package/dist/index.js.map +1 -1
  102. package/dist/theme.css +93 -0
  103. package/dist/tokens.d.ts +112 -0
  104. package/dist/tokens.d.ts.map +1 -0
  105. package/dist/tokens.js +106 -0
  106. package/dist/tokens.js.map +1 -0
  107. package/dist/useGameSounds.d.ts.map +1 -1
  108. package/dist/useGameSounds.js +37 -15
  109. package/dist/useGameSounds.js.map +1 -1
  110. package/dist/useLeaderboard.d.ts +8 -1
  111. package/dist/useLeaderboard.d.ts.map +1 -1
  112. package/dist/useLeaderboard.js +21 -11
  113. package/dist/useLeaderboard.js.map +1 -1
  114. package/package.json +23 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParticles.js","sourceRoot":"","sources":["../../src/feel/useParticles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAEL,WAAW,EACX,aAAa,EAEb,aAAa,EACb,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAA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C,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;QAC3F,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACnC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,GAAG,CAAC,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC1C,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;QAChC,GAAG,CAAC,QAAQ,CACV,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,CAAC,EAC9B,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,CAAC,EAC9B,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,CACd,CAAC;IACJ,CAAC;IACD,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type RefObject } from 'react';
2
+ export interface ShakeOptions {
3
+ /** Peak offset in px. Keep it small: a few pixels reads as impact, more reads as a glitch. */
4
+ amplitude?: number;
5
+ /** Length of the shake in ms. */
6
+ duration?: number;
7
+ }
8
+ /**
9
+ * A function that shakes the element behind `ref`. It uses the Web Animations API,
10
+ * so nothing re-renders and the animation runs on the compositor. It does nothing
11
+ * under reduced motion, or where `element.animate` is missing.
12
+ */
13
+ export declare function useShake<T extends HTMLElement>(ref: RefObject<T | null>, { amplitude, duration }?: ShakeOptions): () => void;
14
+ //# sourceMappingURL=useShake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShake.d.ts","sourceRoot":"","sources":["../../src/feel/useShake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAIpD,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAC5C,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,EACxB,EAAE,SAAa,EAAE,QAAc,EAAE,GAAE,YAAiB,GACnD,MAAM,IAAI,CAMZ"}
@@ -0,0 +1,17 @@
1
+ import { useCallback } from 'react';
2
+ import { prefersReducedMotion } from './reducedMotion.js';
3
+ import { shakeKeyframes } from './shake.js';
4
+ /**
5
+ * A function that shakes the element behind `ref`. It uses the Web Animations API,
6
+ * so nothing re-renders and the animation runs on the compositor. It does nothing
7
+ * under reduced motion, or where `element.animate` is missing.
8
+ */
9
+ export function useShake(ref, { amplitude = 4, duration = 320 } = {}) {
10
+ return useCallback(() => {
11
+ const element = ref.current;
12
+ if (!element || prefersReducedMotion() || typeof element.animate !== 'function')
13
+ return;
14
+ element.animate(shakeKeyframes(amplitude), { duration, easing: 'ease-out' });
15
+ }, [ref, amplitude, duration]);
16
+ }
17
+ //# sourceMappingURL=useShake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShake.js","sourceRoot":"","sources":["../../src/feel/useShake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAS5C;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,GAAwB,EACxB,EAAE,SAAS,GAAG,CAAC,EAAE,QAAQ,GAAG,GAAG,KAAmB,EAAE;IAEpD,OAAO,WAAW,CAAC,GAAG,EAAE;QACtB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,IAAI,oBAAoB,EAAE,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU;YAAE,OAAO;QACxF,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,18 +12,21 @@
12
12
  * What you get:
13
13
  * <GameShell topbar={<GameTopbar score={42} />}>{your game}</GameShell>
14
14
  */
15
+ export { CONFETTI_COLOURS, Confetti, type ConfettiProps, } from './Confetti.js';
16
+ export * from './feel/index.js';
15
17
  export { GameAuth } from './GameAuth.js';
16
18
  export { GameButton, type GameButtonProps, type GameButtonSize, type GameButtonVariant, } from './GameButton.js';
17
19
  export { GameConfirm, type GameConfirmProps } from './GameConfirm.js';
18
20
  export { GameModal, type GameModalProps } from './GameModal.js';
19
21
  export { GameOverScreen, type GameOverScreenProps } from './GameOverScreen.js';
22
+ export { GameResultScreen, type GameResultScreenProps, type GameResultStat, } from './GameResultScreen.js';
20
23
  export { GameShell, type GameShellProps } from './GameShell.js';
21
24
  export { GameTextSizeToggle } from './GameTextSizeToggle.js';
22
25
  export { GameThemeToggle } from './GameThemeToggle.js';
23
26
  export { GameTopbar, type GameTopbarProps, type GameTopbarStat, } from './GameTopbar.js';
24
- export { Leaderboard, type LeaderboardProps } from './Leaderboard.js';
25
27
  export { useSound } from './SoundContext.js';
28
+ export { StartScreen, type StartScreenProps, type StartScreenStep, } from './StartScreen.js';
29
+ export { type ColourTokens, DARK_COLOUR_OVERRIDES, DARK_COLOURS, GAME_TOKENS_CSS, LIGHT_COLOURS, MOTION_TOKENS, type MotionTokens, REDUCED_MOTION_DURATIONS, SHAPE_TOKENS, type ShapeTokens, TYPOGRAPHY_TOKENS, type TypographyTokens, } from './tokens.js';
26
30
  export { type User, useAuth } from './useAuth.js';
27
31
  export { useGameSounds } from './useGameSounds.js';
28
- export { type LeaderboardEntry, useLeaderboard, } from './useLeaderboard.js';
29
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,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BAAiB,CAAC;AAKzB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,YAAY,EACjB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,KAAK,YAAY,EACjB,wBAAwB,EACxB,YAAY,EACZ,KAAK,WAAW,EAChB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -12,18 +12,30 @@
12
12
  * What you get:
13
13
  * <GameShell topbar={<GameTopbar score={42} />}>{your game}</GameShell>
14
14
  */
15
+ export { CONFETTI_COLOURS, Confetti, } from './Confetti.js';
16
+ export * from './feel/index.js';
15
17
  export { GameAuth } from './GameAuth.js';
16
18
  export { GameButton, } from './GameButton.js';
17
19
  export { GameConfirm } from './GameConfirm.js';
18
20
  export { GameModal } from './GameModal.js';
19
21
  export { GameOverScreen } from './GameOverScreen.js';
22
+ export { GameResultScreen, } from './GameResultScreen.js';
20
23
  export { GameShell } from './GameShell.js';
21
24
  export { GameTextSizeToggle } from './GameTextSizeToggle.js';
22
25
  export { GameThemeToggle } from './GameThemeToggle.js';
23
26
  export { GameTopbar, } from './GameTopbar.js';
24
- export { Leaderboard } from './Leaderboard.js';
27
+ // Hidden: leaderboard not currently surfaced to users (issue #31) — remove the
28
+ // comment markers to re-enable. Leaderboard.tsx and useLeaderboard.ts are left
29
+ // intact on purpose, as is the workers/leaderboard API and its data.
30
+ // export { Leaderboard, type LeaderboardProps } from './Leaderboard.js';
25
31
  export { useSound } from './SoundContext.js';
32
+ export { StartScreen, } from './StartScreen.js';
33
+ export { DARK_COLOUR_OVERRIDES, DARK_COLOURS, GAME_TOKENS_CSS, LIGHT_COLOURS, MOTION_TOKENS, REDUCED_MOTION_DURATIONS, SHAPE_TOKENS, TYPOGRAPHY_TOKENS, } from './tokens.js';
26
34
  export { useAuth } from './useAuth.js';
27
35
  export { useGameSounds } from './useGameSounds.js';
28
- export { useLeaderboard, } from './useLeaderboard.js';
36
+ // Hidden: see the note on Leaderboard above (issue #31).
37
+ // export {
38
+ // type LeaderboardEntry,
39
+ // useLeaderboard,
40
+ // } from './useLeaderboard.js';
29
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,UAAU,GAIX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,cAAc,GACf,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,gBAAgB,EAChB,QAAQ,GAET,MAAM,eAAe,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,UAAU,GAIX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,gBAAgB,GAGjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,yEAAyE;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,WAAW,GAGZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EAEb,wBAAwB,EACxB,YAAY,EAEZ,iBAAiB,GAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,yDAAyD;AACzD,WAAW;AACX,2BAA2B;AAC3B,oBAAoB;AACpB,gCAAgC"}
package/dist/theme.css ADDED
@@ -0,0 +1,93 @@
1
+ /*
2
+ * @freegamestore/games theme: the Tailwind entries the SDK components use
3
+ * beyond the token mapping every template already carries (paper, panel, ink,
4
+ * muted, line, accent, success, warning, danger, font-display).
5
+ *
6
+ * Import it once from the game's index.css, after `@import "tailwindcss"` and
7
+ * the SDK `@source`:
8
+ *
9
+ * @import "tailwindcss";
10
+ * @source "../node_modules/@freegamestore/games/dist";
11
+ * @import "@freegamestore/games/theme.css";
12
+ *
13
+ * Or copy this file's contents into index.css. Durations and easings read the
14
+ * motion tokens (`--motion-*`) with the same fallbacks as tokens.ts.
15
+ */
16
+
17
+ @theme inline {
18
+ --color-accent-ink: var(--accent-ink, var(--accent));
19
+ --color-accent-soft: var(--accent-soft, transparent);
20
+ }
21
+
22
+ @theme {
23
+ --radius-fgs: var(--radius, 1.25rem);
24
+ --text-fgs-stat: var(--text-stat, 1.25rem);
25
+ --text-fgs-title: var(--text-title, clamp(2rem, 9vw, 2.6rem));
26
+ --text-fgs-display: var(--text-display, clamp(2.25rem, 11vw, 3.25rem));
27
+
28
+ --animate-fgs-fade: fgs-fade var(--motion-base, 240ms) ease-out both;
29
+ --animate-fgs-enter: fgs-enter var(--motion-slow, 420ms) cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
30
+ --animate-fgs-enter-title: fgs-enter var(--motion-slow, 420ms) cubic-bezier(0.2, 0.9, 0.3, 1.2)
31
+ 120ms both;
32
+ --animate-fgs-enter-stat: fgs-enter var(--motion-base, 240ms) ease-out
33
+ calc(260ms + var(--i, 0) * 70ms) both;
34
+ --animate-fgs-enter-actions: fgs-enter var(--motion-base, 240ms) ease-out 480ms both;
35
+ --animate-fgs-enter-badge: fgs-enter var(--motion-base, 240ms) ease-out 560ms both;
36
+ --animate-fgs-rise: fgs-rise var(--motion-slow, 420ms) cubic-bezier(0.2, 0.8, 0.2, 1)
37
+ var(--delay, 0ms) both;
38
+ --animate-fgs-rise-step: fgs-rise var(--motion-base, 240ms) ease-out calc(var(--i, 0) * 60ms) both;
39
+ --animate-fgs-float: fgs-float 7s ease-in-out infinite;
40
+ --animate-fgs-confetti: fgs-confetti-fall var(--duration, 1.6s) cubic-bezier(0.3, 0, 0.7, 1)
41
+ var(--delay, 0ms) both;
42
+
43
+ @keyframes fgs-fade {
44
+ from {
45
+ opacity: 0;
46
+ }
47
+ to {
48
+ opacity: 1;
49
+ }
50
+ }
51
+ @keyframes fgs-enter {
52
+ from {
53
+ opacity: 0;
54
+ transform: translateY(10px);
55
+ }
56
+ to {
57
+ opacity: 1;
58
+ transform: none;
59
+ }
60
+ }
61
+ @keyframes fgs-rise {
62
+ from {
63
+ opacity: 0;
64
+ transform: translateY(12px);
65
+ }
66
+ to {
67
+ opacity: 1;
68
+ transform: none;
69
+ }
70
+ }
71
+ @keyframes fgs-float {
72
+ 0%,
73
+ 100% {
74
+ transform: translateY(0) rotate(0deg);
75
+ }
76
+ 50% {
77
+ transform: translateY(-4px) rotate(-1deg);
78
+ }
79
+ }
80
+ @keyframes fgs-confetti-fall {
81
+ from {
82
+ transform: translate3d(0, 0, 0) rotate(0deg);
83
+ opacity: 1;
84
+ }
85
+ 80% {
86
+ opacity: 1;
87
+ }
88
+ to {
89
+ transform: translate3d(var(--drift, 0px), 620px, 0) rotate(var(--spin, 360deg));
90
+ opacity: 0;
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Brand, typography and motion design tokens for FreeGameStore games.
3
+ *
4
+ * These values are lifted from the Mosaic Rush pilot (`web/src/index.css`),
5
+ * which is the first game to be built on them. They are the single definition
6
+ * the SDK documents. See TOKENS.md for the full reference.
7
+ *
8
+ * The SDK components read these as CSS custom properties (`var(--paper)` and
9
+ * so on), with their own fallbacks. This module does not inject anything on
10
+ * import (the package is `sideEffects: false`). A game that wants the tokens
11
+ * adds GAME_TOKENS_CSS to its stylesheet, or copies it into index.css.
12
+ *
13
+ * Changing a value here changes every game that adopts the tokens, so treat
14
+ * it as a platform-wide decision.
15
+ */
16
+ /** Colour tokens. Each key becomes `--<kebab-case>`, for example `lineStrong` becomes `--line-strong`. */
17
+ export interface ColourTokens {
18
+ /** Page and board background. */
19
+ paper: string;
20
+ /** Primary text. */
21
+ ink: string;
22
+ /** Secondary text and captions. */
23
+ muted: string;
24
+ /** Hairline borders on empty surfaces. */
25
+ line: string;
26
+ /** Borders on buttons and toggles. */
27
+ lineStrong: string;
28
+ /** Raised cards and overlays. */
29
+ panel: string;
30
+ /** Translucent surface, for frosted overlays. */
31
+ glass: string;
32
+ /** Bottom dock surface. */
33
+ dock: string;
34
+ /** Status: success. */
35
+ success: string;
36
+ /** Status: warning. */
37
+ warning: string;
38
+ /** Status: error. */
39
+ error: string;
40
+ /** Primary actions and highlights. */
41
+ accent: string;
42
+ /** Quiet fill behind accent text, for badges and tints. */
43
+ accentSoft: string;
44
+ /** Accent used as text (titles, badges). Lighter in dark mode so it passes AA on dark surfaces. */
45
+ accentInk: string;
46
+ }
47
+ /** Light theme. The default when `data-theme` is absent. */
48
+ export declare const LIGHT_COLOURS: ColourTokens;
49
+ /**
50
+ * Only the tokens that differ in dark mode. Applied under `:root[data-theme="dark"]`.
51
+ * `accent` is not listed: it is the same in both themes.
52
+ */
53
+ export declare const DARK_COLOUR_OVERRIDES: Partial<ColourTokens>;
54
+ /** Dark theme, resolved: the light values with the dark overrides applied. */
55
+ export declare const DARK_COLOURS: ColourTokens;
56
+ /** Typography tokens. Only display headings and score values use the display face. */
57
+ export interface TypographyTokens {
58
+ /** Display face for titles and score values. */
59
+ fontDisplay: string;
60
+ /** Body face for everything else. */
61
+ fontBody: string;
62
+ /** Score and stat values. */
63
+ textStat: string;
64
+ /** Overlay titles. */
65
+ textTitle: string;
66
+ /** The start-screen title. */
67
+ textDisplay: string;
68
+ }
69
+ export declare const TYPOGRAPHY_TOKENS: TypographyTokens;
70
+ /** Shape tokens. */
71
+ export interface ShapeTokens {
72
+ /** Corner radius for cards and overlays. */
73
+ radius: string;
74
+ }
75
+ export declare const SHAPE_TOKENS: ShapeTokens;
76
+ /** Motion tokens. Durations and easings every animation reads. */
77
+ export interface MotionTokens {
78
+ /** Quick feedback, such as a press or a pop. */
79
+ fast: string;
80
+ /** Standard transitions. */
81
+ base: string;
82
+ /** Larger entrances and overlays. */
83
+ slow: string;
84
+ /** Default ease-out curve. */
85
+ easeOut: string;
86
+ /** Overshooting spring curve for pops. */
87
+ easeSpring: string;
88
+ /**
89
+ * The default duration for a control transition, such as a press or a hover.
90
+ * It follows `fast`, and reduced motion sets it to 0ms.
91
+ */
92
+ duration: string;
93
+ /** The default easing for a control transition. It follows `easeOut`. */
94
+ easing: string;
95
+ }
96
+ export declare const MOTION_TOKENS: MotionTokens;
97
+ /**
98
+ * Durations under `prefers-reduced-motion: reduce`. The animations finish at
99
+ * once and only the final state is shown. Easings are unchanged.
100
+ */
101
+ export declare const REDUCED_MOTION_DURATIONS: Pick<MotionTokens, 'fast' | 'base' | 'slow' | 'duration'>;
102
+ /**
103
+ * A stylesheet that defines every token. It has three blocks:
104
+ * - `:root`, the light values and the type, shape and motion tokens;
105
+ * - `:root[data-theme="dark"]`, the dark colour overrides;
106
+ * - `prefers-reduced-motion: reduce`, which zeroes the durations.
107
+ *
108
+ * Add it to a game's stylesheet, for example `<style>{GAME_TOKENS_CSS}</style>`
109
+ * or the top of `index.css`.
110
+ */
111
+ export declare const GAME_TOKENS_CSS: string;
112
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD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U,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,aAAa,EAAE,YAQ3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAK9F,CAAC;AASF;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,QASd,CAAC"}
package/dist/tokens.js ADDED
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Brand, typography and motion design tokens for FreeGameStore games.
3
+ *
4
+ * These values are lifted from the Mosaic Rush pilot (`web/src/index.css`),
5
+ * which is the first game to be built on them. They are the single definition
6
+ * the SDK documents. See TOKENS.md for the full reference.
7
+ *
8
+ * The SDK components read these as CSS custom properties (`var(--paper)` and
9
+ * so on), with their own fallbacks. This module does not inject anything on
10
+ * import (the package is `sideEffects: false`). A game that wants the tokens
11
+ * adds GAME_TOKENS_CSS to its stylesheet, or copies it into index.css.
12
+ *
13
+ * Changing a value here changes every game that adopts the tokens, so treat
14
+ * it as a platform-wide decision.
15
+ */
16
+ /** Light theme. The default when `data-theme` is absent. */
17
+ export const LIGHT_COLOURS = {
18
+ paper: '#ffffff',
19
+ ink: '#1a1a1a',
20
+ muted: '#6b7280',
21
+ line: '#e5e7eb',
22
+ lineStrong: '#d1d5db',
23
+ panel: '#f9fafb',
24
+ glass: 'rgba(255, 255, 255, 0.8)',
25
+ dock: '#ffffff',
26
+ success: '#16a34a',
27
+ warning: '#d97706',
28
+ error: '#dc2626',
29
+ accent: '#2563eb',
30
+ accentSoft: '#eff6ff',
31
+ accentInk: '#2563eb',
32
+ };
33
+ /**
34
+ * Only the tokens that differ in dark mode. Applied under `:root[data-theme="dark"]`.
35
+ * `accent` is not listed: it is the same in both themes.
36
+ */
37
+ export const DARK_COLOUR_OVERRIDES = {
38
+ paper: '#0f0f0f',
39
+ ink: '#f5f5f5',
40
+ muted: '#9ca3af',
41
+ line: '#2d2d2d',
42
+ lineStrong: '#404040',
43
+ panel: '#1a1a1a',
44
+ glass: 'rgba(15, 15, 15, 0.8)',
45
+ dock: '#1a1a1a',
46
+ success: '#22c55e',
47
+ warning: '#fbbf24',
48
+ error: '#ef4444',
49
+ accentSoft: '#1a2e26',
50
+ accentInk: '#60a5fa',
51
+ };
52
+ /** Dark theme, resolved: the light values with the dark overrides applied. */
53
+ export const DARK_COLOURS = { ...LIGHT_COLOURS, ...DARK_COLOUR_OVERRIDES };
54
+ export const TYPOGRAPHY_TOKENS = {
55
+ fontDisplay: '"Fraunces", Georgia, serif',
56
+ fontBody: '"Manrope", system-ui, sans-serif',
57
+ textStat: '1.25rem',
58
+ textTitle: 'clamp(2rem, 9vw, 2.6rem)',
59
+ textDisplay: 'clamp(2.25rem, 11vw, 3.25rem)',
60
+ };
61
+ export const SHAPE_TOKENS = {
62
+ radius: '1.25rem',
63
+ };
64
+ export const MOTION_TOKENS = {
65
+ fast: '120ms',
66
+ base: '240ms',
67
+ slow: '420ms',
68
+ easeOut: 'cubic-bezier(0.2, 0.9, 0.3, 1)',
69
+ easeSpring: 'cubic-bezier(0.2, 0.9, 0.3, 1.3)',
70
+ duration: 'var(--motion-fast)',
71
+ easing: 'var(--motion-ease-out)',
72
+ };
73
+ /**
74
+ * Durations under `prefers-reduced-motion: reduce`. The animations finish at
75
+ * once and only the final state is shown. Easings are unchanged.
76
+ */
77
+ export const REDUCED_MOTION_DURATIONS = {
78
+ fast: '0ms',
79
+ base: '0ms',
80
+ slow: '0ms',
81
+ duration: '0ms',
82
+ };
83
+ const toKebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
84
+ const declarations = (entries, prefix = '', indent = ' ') => Object.entries(entries)
85
+ .map(([key, value]) => `${indent}--${prefix}${toKebab(key)}: ${value};`)
86
+ .join('\n');
87
+ /**
88
+ * A stylesheet that defines every token. It has three blocks:
89
+ * - `:root`, the light values and the type, shape and motion tokens;
90
+ * - `:root[data-theme="dark"]`, the dark colour overrides;
91
+ * - `prefers-reduced-motion: reduce`, which zeroes the durations.
92
+ *
93
+ * Add it to a game's stylesheet, for example `<style>{GAME_TOKENS_CSS}</style>`
94
+ * or the top of `index.css`.
95
+ */
96
+ export const GAME_TOKENS_CSS = [
97
+ `:root {\n${[
98
+ declarations(LIGHT_COLOURS),
99
+ declarations(TYPOGRAPHY_TOKENS),
100
+ declarations(SHAPE_TOKENS),
101
+ declarations(MOTION_TOKENS, 'motion-'),
102
+ ].join('\n')}\n}`,
103
+ `:root[data-theme="dark"] {\n${declarations(DARK_COLOUR_OVERRIDES)}\n}`,
104
+ `@media (prefers-reduced-motion: reduce) {\n :root {\n${declarations(REDUCED_MOTION_DURATIONS, 'motion-', ' ')}\n }\n}`,
105
+ ].join('\n\n');
106
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkCH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,0BAA0B;IACjC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,SAAS;IACrB,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE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,GAAG,IAAI,EAAU,EAAE,CAC3E,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;KACpB,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC;KACvE,IAAI,CAAC,IAAI,CAAC,CAAC;AAEhB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;QACV,YAAY,CAAC,aAAa,CAAC;QAC3B,YAAY,CAAC,iBAAiB,CAAC;QAC/B,YAAY,CAAC,YAAY,CAAC;QAC1B,YAAY,CAAC,aAAa,EAAE,SAAS,CAAC;KACvC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;IACjB,+BAA+B,YAAY,CAAC,qBAAqB,CAAC,KAAK;IACvE,yDAAyD,YAAY,CAAC,wBAAwB,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU;CAC7H,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGameSounds.d.ts","sourceRoot":"","sources":["../src/useGameSounds.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa;;;;;;;;;EAoH5B"}
1
+ {"version":3,"file":"useGameSounds.d.ts","sourceRoot":"","sources":["../src/useGameSounds.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa;;;;;;;;;EA6I5B"}
@@ -8,16 +8,30 @@ import { useSound } from './SoundContext.js';
8
8
  export function useGameSounds() {
9
9
  const { muted } = useSound();
10
10
  const ctxRef = useRef(null);
11
+ // Set once the game unmounts: no new AudioContext may be created after that.
12
+ const disposedRef = useRef(false);
13
+ // Delayed notes of multi-tone sounds (score, game over, level up, …).
14
+ const timersRef = useRef(new Set());
11
15
  // Release the AudioContext when the game unmounts so it isn't leaked
12
- // (browsers cap concurrent contexts).
16
+ // (browsers cap concurrent contexts). Pending delayed notes are cancelled
17
+ // first: one firing after unmount used to create a NEW context that nothing
18
+ // ever closed — one leak per game swapped out mid-sound, until browsers stop
19
+ // allowing new contexts and sound dies (#99). Reset on (re)mount so
20
+ // StrictMode's simulated remount doesn't leave sounds permanently disabled.
13
21
  useEffect(() => {
22
+ disposedRef.current = false;
23
+ const timers = timersRef.current;
14
24
  return () => {
15
- void ctxRef.current?.close();
25
+ disposedRef.current = true;
26
+ for (const t of timers)
27
+ clearTimeout(t);
28
+ timers.clear();
29
+ void ctxRef.current?.close().catch(() => { });
16
30
  ctxRef.current = null;
17
31
  };
18
32
  }, []);
19
33
  const getCtx = useCallback(() => {
20
- if (muted)
34
+ if (muted || disposedRef.current)
21
35
  return null;
22
36
  if (!ctxRef.current) {
23
37
  try {
@@ -59,6 +73,14 @@ export function useGameSounds() {
59
73
  osc.start(ctx.currentTime);
60
74
  osc.stop(ctx.currentTime + duration);
61
75
  }, [getCtx]);
76
+ /** Play a note after `ms`, cancelled if the game unmounts first. */
77
+ const later = useCallback((ms, ...args) => {
78
+ const timer = setTimeout(() => {
79
+ timersRef.current.delete(timer);
80
+ tone(...args);
81
+ }, ms);
82
+ timersRef.current.add(timer);
83
+ }, [tone]);
62
84
  /** Short click/tap — piece moved, card flipped, button pressed */
63
85
  const playMove = useCallback(() => {
64
86
  tone(600, 0.06, 'square', 0.08);
@@ -66,8 +88,8 @@ export function useGameSounds() {
66
88
  /** Positive ding — scored a point, matched, correct answer */
67
89
  const playScore = useCallback(() => {
68
90
  tone(880, 0.12, 'sine', 0.15);
69
- setTimeout(() => tone(1100, 0.15, 'sine', 0.12), 60);
70
- }, [tone]);
91
+ later(60, 1100, 0.15, 'sine', 0.12);
92
+ }, [tone, later]);
71
93
  /** Negative buzz — wrong answer, hit obstacle, lost life */
72
94
  const playError = useCallback(() => {
73
95
  tone(200, 0.2, 'sawtooth', 0.1);
@@ -75,16 +97,16 @@ export function useGameSounds() {
75
97
  /** Game over — descending tones */
76
98
  const playGameOver = useCallback(() => {
77
99
  tone(440, 0.15, 'sine', 0.12);
78
- setTimeout(() => tone(350, 0.15, 'sine', 0.1), 100);
79
- setTimeout(() => tone(260, 0.3, 'sine', 0.08), 200);
80
- }, [tone]);
100
+ later(100, 350, 0.15, 'sine', 0.1);
101
+ later(200, 260, 0.3, 'sine', 0.08);
102
+ }, [tone, later]);
81
103
  /** Level up / achievement — ascending arpeggio */
82
104
  const playLevelUp = useCallback(() => {
83
105
  tone(523, 0.1, 'sine', 0.12);
84
- setTimeout(() => tone(659, 0.1, 'sine', 0.12), 80);
85
- setTimeout(() => tone(784, 0.1, 'sine', 0.12), 160);
86
- setTimeout(() => tone(1047, 0.2, 'sine', 0.15), 240);
87
- }, [tone]);
106
+ later(80, 659, 0.1, 'sine', 0.12);
107
+ later(160, 784, 0.1, 'sine', 0.12);
108
+ later(240, 1047, 0.2, 'sine', 0.15);
109
+ }, [tone, later]);
88
110
  /** Hard drop / thud — Tetris block landing, bowling throw */
89
111
  const playDrop = useCallback(() => {
90
112
  tone(150, 0.12, 'triangle', 0.2);
@@ -92,9 +114,9 @@ export function useGameSounds() {
92
114
  /** Line clear / combo — satisfying sweep */
93
115
  const playClear = useCallback(() => {
94
116
  tone(700, 0.08, 'sine', 0.1);
95
- setTimeout(() => tone(900, 0.08, 'sine', 0.1), 50);
96
- setTimeout(() => tone(1200, 0.12, 'sine', 0.12), 100);
97
- }, [tone]);
117
+ later(50, 900, 0.08, 'sine', 0.1);
118
+ later(100, 1200, 0.12, 'sine', 0.12);
119
+ }, [tone, later]);
98
120
  /** Countdown tick — timer warning */
99
121
  const playTick = useCallback(() => {
100
122
  tone(1000, 0.03, 'square', 0.06);
@@ -1 +1 @@
1
- {"version":3,"file":"useGameSounds.js","sourceRoot":"","sources":["../src/useGameSounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,QAAQ,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CAAC;IAElB,qCAAqC;IACrC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAChC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO;QACL,QAAQ;QACR,SAAS;QACT,SAAS;QACT,YAAY;QACZ,WAAW;QACX,QAAQ;QACR,SAAS;QACT,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -5,7 +5,14 @@ export interface LeaderboardEntry {
5
5
  avatar_url?: string;
6
6
  created_at: string;
7
7
  }
8
- export declare function useLeaderboard(gameId: string): {
8
+ export interface UseLeaderboardOptions {
9
+ /**
10
+ * A day key (YYYY-MM-DD, UTC) for a per-day board, such as a daily puzzle.
11
+ * Omit it for the all-time board.
12
+ */
13
+ period?: string;
14
+ }
15
+ export declare function useLeaderboard(gameId: string, options?: UseLeaderboardOptions): {
9
16
  topScores: LeaderboardEntry[];
10
17
  recentScores: LeaderboardEntry[];
11
18
  submitScore: (score: number) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"useLeaderboard.d.ts","sourceRoot":"","sources":["../src/useLeaderboard.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAoBD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAC9C,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,C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