@hkdigital/lib-core 0.4.22 → 0.4.24

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 (30) hide show
  1. package/dist/auth/jwt/util.js +35 -41
  2. package/dist/network/loaders/audio/AudioScene.svelte.js +2 -2
  3. package/dist/network/loaders/image/ImageScene.svelte.js +18 -28
  4. package/dist/network/states/NetworkLoader.svelte.d.ts +1 -1
  5. package/dist/network/states/NetworkLoader.svelte.js +2 -2
  6. package/dist/services/README.md +23 -0
  7. package/dist/state/classes.d.ts +0 -2
  8. package/dist/state/classes.js +0 -2
  9. package/dist/state/{classes → machines}/finite-state-machine/FiniteStateMachine.svelte.d.ts +10 -0
  10. package/dist/state/{classes → machines}/finite-state-machine/FiniteStateMachine.svelte.js +19 -1
  11. package/dist/state/machines/finite-state-machine/README.md +545 -0
  12. package/dist/state/{classes → machines}/finite-state-machine/index.d.ts +1 -1
  13. package/dist/state/{classes → machines}/finite-state-machine/index.js +1 -1
  14. package/dist/state/machines/finite-state-machine/typedef.d.ts +29 -0
  15. package/dist/state/machines/finite-state-machine/typedef.js +28 -0
  16. package/dist/state/{classes → machines}/loading-state-machine/LoadingStateMachine.svelte.d.ts +0 -2
  17. package/dist/state/{classes → machines}/loading-state-machine/LoadingStateMachine.svelte.js +7 -27
  18. package/dist/state/machines/loading-state-machine/README.md +544 -0
  19. package/dist/state/machines/typedef.d.ts +1 -0
  20. package/dist/state/machines/typedef.js +1 -0
  21. package/dist/state/machines.d.ts +2 -0
  22. package/dist/state/machines.js +2 -0
  23. package/dist/state/typedef.d.ts +1 -0
  24. package/dist/state/typedef.js +1 -0
  25. package/dist/ui/components/game-box/README.md +245 -0
  26. package/package.json +1 -1
  27. /package/dist/state/{classes → machines}/loading-state-machine/constants.d.ts +0 -0
  28. /package/dist/state/{classes → machines}/loading-state-machine/constants.js +0 -0
  29. /package/dist/state/{classes → machines}/loading-state-machine/index.d.ts +0 -0
  30. /package/dist/state/{classes → machines}/loading-state-machine/index.js +0 -0
@@ -0,0 +1,245 @@
1
+ # GameBox Component
2
+
3
+ A responsive container component designed for creating games and fullscreen
4
+ applications with adaptive scaling, orientation handling, and mobile PWA
5
+ support.
6
+
7
+ ## Features
8
+
9
+ - **Responsive Layout**: Automatically adapts to landscape and portrait
10
+ orientations
11
+ - **Aspect Ratio Control**: Configurable aspect ratios for different
12
+ orientations
13
+ - **Mobile PWA Support**: Handles iOS Safari PWA quirks and fullscreen modes
14
+ - **Dynamic Scaling**: Optional design system scaling based on container size
15
+ - **Fullscreen Management**: Built-in fullscreen request handling
16
+ - **Device Detection**: Automatic mobile and OS detection
17
+
18
+ ## Basic Usage
19
+
20
+ ```svelte
21
+ <script>
22
+ import { GameBox } from '$lib/ui/components/game-box/index.js';
23
+ </script>
24
+
25
+ <GameBox
26
+ aspectOnLandscape={16/9}
27
+ aspectOnPortrait={9/16}
28
+ snippetLandscape={landscapeContent}
29
+ snippetPortrait={portraitContent}
30
+ />
31
+
32
+ {#snippet landscapeContent({ gameWidth, gameHeight, isMobile })}
33
+ <div>Game content for landscape - {gameWidth}x{gameHeight}</div>
34
+ {/snippet}
35
+
36
+ {#snippet portraitContent({ gameWidth, gameHeight, isMobile })}
37
+ <div>Game content for portrait - {gameWidth}x{gameHeight}</div>
38
+ {/snippet}
39
+ ```
40
+
41
+ ## Props
42
+
43
+ ### Styling Props
44
+ - `base?: string` - Base CSS classes
45
+ - `bg?: string` - Background CSS classes
46
+ - `classes?: string` - Additional CSS classes
47
+ - `style?: string` - Inline styles
48
+
49
+ ### Layout Props
50
+ - `aspectOnLandscape?: number` - Aspect ratio for landscape mode (e.g., 16/9)
51
+ - `aspectOnPortrait?: number` - Aspect ratio for portrait mode (e.g., 9/16)
52
+ - `marginLeft?: number` - Left margin in pixels (default: 0)
53
+ - `marginRight?: number` - Right margin in pixels (default: 0)
54
+ - `marginTop?: number` - Top margin in pixels (default: 0)
55
+ - `marginBottom?: number` - Bottom margin in pixels (default: 0)
56
+ - `center?: boolean` - Center the game box in viewport
57
+
58
+ ### Scaling Props
59
+ - `enableScaling?: boolean` - Enable design system scaling (default: false)
60
+ - `designLandscape?: {width: number, height: number}` - Design dimensions
61
+ for landscape (default: {width: 1920, height: 1080})
62
+ - `designPortrait?: {width: number, height: number}` - Design dimensions
63
+ for portrait (default: {width: 1920, height: 1080})
64
+ - `clamping?: object` - Scaling limits for different elements
65
+
66
+ ### Snippet Props
67
+ - `snippetLandscape?: Snippet` - Content for landscape orientation
68
+ - `snippetPortrait?: Snippet` - Content for portrait orientation
69
+ - `snippetRequireFullscreen?: Snippet` - Content when fullscreen is required
70
+ - `snippetInstallOnHomeScreen?: Snippet` - Content for home screen install
71
+ prompt
72
+
73
+ ## Snippet Parameters
74
+
75
+ All snippets receive these parameters:
76
+
77
+ ```js
78
+ {
79
+ isMobile: boolean, // Is running on mobile device
80
+ os: 'Android'|'iOS', // Operating system
81
+ isFullscreen: boolean, // Is in fullscreen mode
82
+ isDevMode: boolean, // Is in development mode
83
+ requestDevmode: function, // Function to enable dev mode
84
+ requestFullscreen: function, // Function to request fullscreen
85
+ gameWidth: number, // Calculated game width
86
+ gameHeight: number // Calculated game height
87
+ }
88
+ ```
89
+
90
+ ## Examples
91
+
92
+ ### Simple Game Container
93
+
94
+ ```svelte
95
+ <GameBox
96
+ aspectOnLandscape={16/9}
97
+ aspectOnPortrait={9/16}
98
+ center={true}
99
+ snippetLandscape={gameContent}
100
+ snippetPortrait={gameContent}
101
+ />
102
+
103
+ {#snippet gameContent({ gameWidth, gameHeight })}
104
+ <div class="game-area bg-surface-900 rounded-lg p-20up">
105
+ <h1 class="type-heading-h1 text-center mb-20up">My Game</h1>
106
+ <div class="game-content" style="width: 100%; height: 100%;">
107
+ Game content goes here
108
+ </div>
109
+ </div>
110
+ {/snippet}
111
+ ```
112
+
113
+ ### With Fullscreen Requirement
114
+
115
+ ```svelte
116
+ <GameBox
117
+ aspectOnLandscape={21/9}
118
+ center={true}
119
+ snippetLandscape={gameContent}
120
+ snippetRequireFullscreen={fullscreenPrompt}
121
+ />
122
+
123
+ {#snippet gameContent({ gameWidth, gameHeight, isFullscreen })}
124
+ <div class="cinematic-game">
125
+ Ultra-wide cinematic game experience
126
+ </div>
127
+ {/snippet}
128
+
129
+ {#snippet fullscreenPrompt({ requestFullscreen })}
130
+ <div class="fullscreen-prompt text-center">
131
+ <h2 class="type-heading-h2 mb-16bt">Fullscreen Required</h2>
132
+ <p class="type-base-md mb-20bt">
133
+ This game requires fullscreen mode for the best experience.
134
+ </p>
135
+ <button class="btn-primary" onclick={requestFullscreen}>
136
+ Enter Fullscreen
137
+ </button>
138
+ </div>
139
+ {/snippet}
140
+ ```
141
+
142
+ ### With Scaling Enabled
143
+
144
+ ```svelte
145
+ <GameBox
146
+ aspectOnLandscape={16/9}
147
+ enableScaling={true}
148
+ designLandscape={{ width: 1920, height: 1080 }}
149
+ clamping={{
150
+ ui: { min: 0.5, max: 1.5 },
151
+ textBase: { min: 0.8, max: 1.2 },
152
+ textHeading: { min: 0.75, max: 2 },
153
+ textUi: { min: 0.6, max: 1.1 }
154
+ }}
155
+ snippetLandscape={scaledContent}
156
+ />
157
+
158
+ {#snippet scaledContent()}
159
+ <div class="game-ui">
160
+ <!-- UI elements will automatically scale based on container size -->
161
+ <div class="hud">
162
+ <span class="type-ui-sm">Score: 1000</span>
163
+ </div>
164
+ </div>
165
+ {/snippet}
166
+ ```
167
+
168
+ ### Mobile-Specific Handling
169
+
170
+ ```svelte
171
+ <GameBox
172
+ aspectOnLandscape={16/9}
173
+ aspectOnPortrait={9/16}
174
+ snippetLandscape={landscapeGame}
175
+ snippetPortrait={portraitGame}
176
+ snippetInstallOnHomeScreen={installPrompt}
177
+ />
178
+
179
+ {#snippet landscapeGame({ isMobile, os })}
180
+ <div class="landscape-game">
181
+ {#if isMobile}
182
+ <div class="mobile-controls">
183
+ <!-- Touch controls for mobile -->
184
+ </div>
185
+ {:else}
186
+ <div class="desktop-controls">
187
+ <!-- Keyboard/mouse controls for desktop -->
188
+ </div>
189
+ {/if}
190
+ </div>
191
+ {/snippet}
192
+
193
+ {#snippet portraitGame({ isMobile })}
194
+ <div class="portrait-game">
195
+ <!-- Optimized for portrait mobile gameplay -->
196
+ </div>
197
+ {/snippet}
198
+
199
+ {#snippet installPrompt({ os })}
200
+ <div class="install-prompt text-center">
201
+ <h2 class="type-heading-h2 mb-16bt">Install App</h2>
202
+ <p class="type-base-md mb-20bt">
203
+ {#if os === 'iOS'}
204
+ Tap the share button and select "Add to Home Screen"
205
+ {:else}
206
+ Install this app for the best gaming experience
207
+ {/if}
208
+ </p>
209
+ </div>
210
+ {/snippet}
211
+ ```
212
+
213
+ ## CSS Custom Properties
214
+
215
+ The component exposes these CSS custom properties:
216
+
217
+ - `--game-width`: Current game width in pixels
218
+ - `--game-height`: Current game height in pixels
219
+
220
+ These can be used in your CSS for responsive styling:
221
+
222
+ ```css
223
+ .game-element {
224
+ width: calc(var(--game-width) * 0.5);
225
+ height: calc(var(--game-height) * 0.2);
226
+ }
227
+ ```
228
+
229
+ ## Mobile PWA Considerations
230
+
231
+ The component includes special handling for mobile PWAs:
232
+
233
+ - **iOS Safari PWA**: Handles viewport quirks and orientation changes
234
+ - **Fullscreen Detection**: Properly detects PWA fullscreen mode
235
+ - **Screen Orientation**: Listens for orientation changes and updates layout
236
+ - **No Scroll**: Automatically prevents scrolling when active
237
+
238
+ ## Development Mode
239
+
240
+ The component automatically enables development mode when:
241
+ - Running on `localhost`
242
+ - Called via `requestDevmode()` function
243
+
244
+ In development mode, fullscreen and installation requirements are bypassed
245
+ for easier testing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.4.22",
3
+ "version": "0.4.24",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"