@lightningjs/blits 2.14.0 → 2.16.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.
package/index.d.ts CHANGED
@@ -22,1621 +22,1650 @@ import {type ShaderEffect as RendererShaderEffect, type RendererMainSettings, ty
22
22
  import { CanvasShaderType } from '@lightningjs/renderer/canvas';
23
23
  import { WebGlShaderType } from '@lightningjs/renderer/webgl';
24
24
 
25
- declare module '@lightningjs/blits' {
26
- type RendererShaderEffect = import('@lightningjs/renderer').ShaderEffect
27
- type WebGlCoreShader = import('@lightningjs/renderer').WebGlCoreShader
28
- type RendererMainSettings = import('@lightningjs/renderer').RendererMainSettings
25
+ type WebGlCoreShader = import('@lightningjs/renderer').WebGlCoreShader
29
26
 
30
- export interface AnnouncerUtteranceOptions {
31
- /**
32
- * Language code (BCP 47 format, e.g., 'en-US', 'fr-FR')
33
- *
34
- * @default 'en-US'
35
- */
36
- lang?: string,
37
- /**
38
- * Voice pitch (0 to 2, where 1 is normal)
39
- *
40
- * @default 1
41
- */
42
- pitch?: number,
43
- /**
44
- * Speech rate (0.1 to 10, where 1 is normal)
45
- *
46
- * @default 1
47
- */
48
- rate?: number,
49
- /**
50
- * Voice to use (obtained from `speechSynthesis.getVoices()`)
51
- *
52
- * @default null
53
- */
54
- voice?: SpeechSynthesisVoice | null,
55
- /**
56
- * Volume level (0 to 1, where 1 is full volume)
57
- *
58
- * @default 1
59
- */
60
- volume?: number,
61
- /**
62
- * Whether to enable utterance keep-alive (prevents pausing on some platforms)
63
- *
64
- * @default undefined
65
- */
66
- enableUtteranceKeepAlive?: boolean
67
- }
27
+ export interface AnnouncerUtteranceOptions {
28
+ /**
29
+ * Language code (BCP 47 format, e.g., 'en-US', 'fr-FR')
30
+ *
31
+ * @default 'en-US'
32
+ */
33
+ lang?: string,
34
+ /**
35
+ * Voice pitch (0 to 2, where 1 is normal)
36
+ *
37
+ * @default 1
38
+ */
39
+ pitch?: number,
40
+ /**
41
+ * Speech rate (0.1 to 10, where 1 is normal)
42
+ *
43
+ * @default 1
44
+ */
45
+ rate?: number,
46
+ /**
47
+ * Voice to use (obtained from `speechSynthesis.getVoices()`)
48
+ *
49
+ * @default null
50
+ */
51
+ voice?: SpeechSynthesisVoice | null,
52
+ /**
53
+ * Volume level (0 to 1, where 1 is full volume)
54
+ *
55
+ * @default 1
56
+ */
57
+ volume?: number,
58
+ /**
59
+ * Whether to enable utterance keep-alive (prevents pausing on some platforms)
60
+ *
61
+ * @default undefined
62
+ */
63
+ enableUtteranceKeepAlive?: boolean
64
+ }
68
65
 
69
- export interface AnnouncerDriverOptions extends AnnouncerUtteranceOptions {
70
- /**
71
- * Message to be spoken by the platform announcer driver.
72
- */
73
- message: string | number,
74
- /**
75
- * Internal announcement id used by the Blits announcer queue.
76
- */
77
- id: number,
78
- }
66
+ export interface AnnouncerDriverOptions extends AnnouncerUtteranceOptions {
67
+ /**
68
+ * Message to be spoken by the platform announcer driver.
69
+ */
70
+ message: string | number,
71
+ /**
72
+ * Internal announcement id used by the Blits announcer queue.
73
+ */
74
+ id: number,
75
+ }
79
76
 
80
- export interface AnnouncerDriver {
81
- /**
82
- * Speak one queued announcement.
83
- */
84
- speak(options: AnnouncerDriverOptions): Promise<any>,
85
- /**
86
- * Stop the active platform announcement, when supported.
87
- */
88
- cancel(): void,
89
- }
77
+ export interface AnnouncerDriver {
78
+ /**
79
+ * Speak one queued announcement.
80
+ */
81
+ speak(options: AnnouncerDriverOptions): Promise<any>,
82
+ /**
83
+ * Stop the active platform announcement, when supported.
84
+ */
85
+ cancel(): void,
86
+ }
90
87
 
91
- export interface AnnouncerUtterance<T = any> extends Promise<T> {
92
- /**
93
- * Removes a specific message from the announcement queue,
94
- * to make sure it isn't spoke out.
95
- *
96
- * Does not interupt the message when it's already being announced.
97
- */
98
- cancel()
99
- /**
100
- * Interrupts a specific message as it is being spoken out by the Text to Speech
101
- * engine.
102
- */
103
- stop()
104
- }
88
+ export interface AnnouncerUtterance<T = any> extends Promise<T> {
89
+ /**
90
+ * Removes a specific message from the announcement queue,
91
+ * to make sure it isn't spoke out.
92
+ *
93
+ * Does not interupt the message when it's already being announced.
94
+ */
95
+ cancel()
96
+ /**
97
+ * Interrupts a specific message as it is being spoken out by the Text to Speech
98
+ * engine.
99
+ */
100
+ stop()
101
+ }
105
102
 
106
- export interface Announcer {
107
- /**
108
- * Instruct the Announcer to speak a message. Will add the message
109
- * to the end of announcement queue by default
110
- *
111
- * When a message is added with politeness set to `assertive` the message
112
- * will be added to the beginning of the queue
113
- *
114
- * @param message - The message to be spoken
115
- * @param politeness - Politeness level ('off', 'polite', or 'assertive')
116
- * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
117
- */
118
- speak(message: string | number, politeness?: 'off' | 'polite' | 'assertive', options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
119
- /**
120
- * Instruct the Announcer to speak a message with 'polite' politeness level.
121
- * Will add the message to the end of announcement queue.
122
- *
123
- * @param message - The message to be spoken
124
- * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
125
- */
126
- polite(message: string | number, options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
127
- /**
128
- * Instruct the Announcer to speak a message with 'assertive' politeness level.
129
- * Will add the message to the beginning of announcement queue.
130
- *
131
- * @param message - The message to be spoken
132
- * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
133
- */
134
- assertive(message: string | number, options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
135
- /**
136
- * Configure global default utterance options that will be applied to all
137
- * subsequent announcements unless overridden by per-call options.
138
- *
139
- * @param options - Default utterance options (rate, pitch, lang, voice, volume)
140
- */
141
- configure(options?: AnnouncerUtteranceOptions): void;
142
- /**
143
- * Instruct the Announcer to add a pause of a certain duration (in ms). Will add this pause
144
- * to the end of announcement queue
145
- *
146
- */
147
- pause(delay: number): AnnouncerUtterance;
148
- /**
149
- * Interupts and instantly stops any running text to speech utterance
150
- *
151
- */
152
- stop(): void;
153
- /**
154
- * Clears out the announcement queue of messages.
155
- */
156
- clear(): void;
157
- /**
158
- * Enables the announcer.
159
- */
160
- enable(): void;
161
- /**
162
- * Disables the announcer. Any messages passed in the announcer.speak() message
163
- * will not be added to the queue
164
- */
165
- disable(): void;
166
- /**
167
- * Toggles the announcer based on the passed toggle value (Boolean)
168
- */
169
- toggle(toggle: Boolean): void;
170
- }
103
+ export interface Announcer {
104
+ /**
105
+ * Instruct the Announcer to speak a message. Will add the message
106
+ * to the end of announcement queue by default
107
+ *
108
+ * When a message is added with politeness set to `assertive` the message
109
+ * will be added to the beginning of the queue
110
+ *
111
+ * @param message - The message to be spoken
112
+ * @param politeness - Politeness level ('off', 'polite', or 'assertive')
113
+ * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
114
+ */
115
+ speak(message: string | number, politeness?: 'off' | 'polite' | 'assertive', options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
116
+ /**
117
+ * Instruct the Announcer to speak a message with 'polite' politeness level.
118
+ * Will add the message to the end of announcement queue.
119
+ *
120
+ * @param message - The message to be spoken
121
+ * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
122
+ */
123
+ polite(message: string | number, options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
124
+ /**
125
+ * Instruct the Announcer to speak a message with 'assertive' politeness level.
126
+ * Will add the message to the beginning of announcement queue.
127
+ *
128
+ * @param message - The message to be spoken
129
+ * @param options - Optional utterance options (rate, pitch, lang, voice, volume)
130
+ */
131
+ assertive(message: string | number, options?: AnnouncerUtteranceOptions): AnnouncerUtterance;
132
+ /**
133
+ * Configure global default utterance options that will be applied to all
134
+ * subsequent announcements unless overridden by per-call options.
135
+ *
136
+ * @param options - Default utterance options (rate, pitch, lang, voice, volume)
137
+ */
138
+ configure(options?: AnnouncerUtteranceOptions): void;
139
+ /**
140
+ * Instruct the Announcer to add a pause of a certain duration (in ms). Will add this pause
141
+ * to the end of announcement queue
142
+ *
143
+ */
144
+ pause(delay: number): AnnouncerUtterance;
145
+ /**
146
+ * Interupts and instantly stops any running text to speech utterance
147
+ *
148
+ */
149
+ stop(): void;
150
+ /**
151
+ * Clears out the announcement queue of messages.
152
+ */
153
+ clear(): void;
154
+ /**
155
+ * Enables the announcer.
156
+ */
157
+ enable(): void;
158
+ /**
159
+ * Disables the announcer. Any messages passed in the announcer.speak() message
160
+ * will not be added to the queue
161
+ */
162
+ disable(): void;
163
+ /**
164
+ * Toggles the announcer based on the passed toggle value (Boolean)
165
+ */
166
+ toggle(toggle: Boolean): void;
167
+ }
171
168
 
172
169
 
173
- export interface Hooks {
174
- /**
175
- * Fires when the Component is being instantiated
176
- * At this moment child elements will not be available yet
177
- */
178
- init?: () => void;
179
- /**
180
- * Fires when the Component is fully initialized and ready for interaction.
181
- */
182
- ready?: () => void;
183
- /**
184
- * Triggers when the Component receives focus.
185
- *
186
- * This event can fire multiple times during the component's lifecycle
187
- */
188
- focus?: () => void;
189
- /**
190
- * Triggers when the Component loses focus.
191
- *
192
- * This event can fire multiple times during the component's lifecycle
193
- */
194
- unfocus?: () => void;
195
- /**
196
- * Fires when the Component is being destroyed and removed.
197
- */
198
- destroy?: () => void;
199
- hover?: () => void;
200
- unhover?: () => void;
201
- /**
202
- * Fires upon each frame start (allowing you to tap directly into the renderloop)
203
- *
204
- * Note: This hook will fire continuously, multiple times per second!
205
- */
206
- frameTick?: (data: {time: number, delta: number}) => void;
207
- /**
208
- * Fires when the component enters the viewport _margin_ and is attached to the render tree
209
- *
210
- * This event can fire multiple times during the component's lifecycle
211
- */
212
- attach?: () => void;
213
- /**
214
- * Fires when the component leaves the viewport _margin_ and is detached from the render tree
215
- *
216
- * This event can fire multiple times during the component's lifecycle
217
- */
218
- detach?: () => void;
219
- /**
220
- * Fires when the component enters the visible viewport
221
- *
222
- * This event can fire multiple times during the component's lifecycle
223
- */
224
- enter?: () => void;
225
- /**
226
- * Fires when the component leaves the visible viewport
227
- *
228
- * This event can fire multiple times during the component's lifecycle
229
- */
230
- exit?: () => void;
231
- /**
232
- * Fires when the renderer is done rendering and enters an idle state (idle = true)
233
- * and when the renderer starts rendering again and leaves the idle state (idle = false)
234
- *
235
- * @param idle - boolean to indicate whether the renderer is in idle state or not
236
- *
237
- * Note: This event can fire multiple times
238
- */
239
- idle?: (idle: boolean) => void;
240
- /**
241
- * Fires at a predefined interval and reports the current FPS value
242
- *
243
- * Note: This event fire multiple times
244
- */
245
- fpsUpdate?: (fps: number, frameCounter: FrameCounter) => void;
246
- }
170
+ export interface Hooks {
171
+ /**
172
+ * Fires when the Component is being instantiated
173
+ * At this moment child elements will not be available yet
174
+ */
175
+ init?: () => void;
176
+ /**
177
+ * Fires when the Component is fully initialized and ready for interaction.
178
+ */
179
+ ready?: () => void;
180
+ /**
181
+ * Triggers when the Component receives focus.
182
+ *
183
+ * This event can fire multiple times during the component's lifecycle
184
+ */
185
+ focus?: () => void;
186
+ /**
187
+ * Triggers when the Component loses focus.
188
+ *
189
+ * This event can fire multiple times during the component's lifecycle
190
+ */
191
+ unfocus?: () => void;
192
+ /**
193
+ * Fires when the Component is being destroyed and removed.
194
+ */
195
+ destroy?: () => void;
196
+ hover?: () => void;
197
+ unhover?: () => void;
198
+ /**
199
+ * Fires upon each frame start (allowing you to tap directly into the renderloop)
200
+ *
201
+ * Note: This hook will fire continuously, multiple times per second!
202
+ */
203
+ frameTick?: (data: {time: number, delta: number}) => void;
204
+ /**
205
+ * Fires when the component enters the viewport _margin_ and is attached to the render tree
206
+ *
207
+ * This event can fire multiple times during the component's lifecycle
208
+ */
209
+ attach?: () => void;
210
+ /**
211
+ * Fires when the component leaves the viewport _margin_ and is detached from the render tree
212
+ *
213
+ * This event can fire multiple times during the component's lifecycle
214
+ */
215
+ detach?: () => void;
216
+ /**
217
+ * Fires when the component enters the visible viewport
218
+ *
219
+ * This event can fire multiple times during the component's lifecycle
220
+ */
221
+ enter?: () => void;
222
+ /**
223
+ * Fires when the component leaves the visible viewport
224
+ *
225
+ * This event can fire multiple times during the component's lifecycle
226
+ */
227
+ exit?: () => void;
228
+ /**
229
+ * Fires when the renderer is done rendering and enters an idle state (idle = true)
230
+ * and when the renderer starts rendering again and leaves the idle state (idle = false)
231
+ *
232
+ * @param idle - boolean to indicate whether the renderer is in idle state or not
233
+ *
234
+ * Note: This event can fire multiple times
235
+ */
236
+ idle?: (idle: boolean) => void;
237
+ /**
238
+ * Fires at a predefined interval and reports the current FPS value
239
+ *
240
+ * Note: This event fire multiple times
241
+ */
242
+ fpsUpdate?: (fps: number, frameCounter: FrameCounter) => void;
243
+ }
247
244
 
248
- export interface Input {
249
- [key: string]: ((event: KeyboardEvent) => unknown) | undefined,
250
- /**
251
- * Catch all input function
252
- *
253
- * Will be invoked when there is no dedicated function for a certain key
254
- */
255
- // @ts-ignore
256
- any?: (event: KeyboardEvent) => void,
257
- /**
258
- * Intercept key presses on the root Application component before being handled
259
- * by the currently focused component.
260
- *
261
- * Only when a KeyboardEvent (the original one, or a modified one) is returned from the
262
- * intercept function, the Input event is passed on to the Component with focus.
263
- *
264
- * The intercept function can be asynchronous.
265
- *
266
- * Note: the intercept input handler is only available on the Root App component (i.e. Blits.Application)
267
- */
268
- intercept?: (event: KeyboardEvent) => KeyboardEvent | Promise<KeyboardEvent | any> | any
269
- }
245
+ export interface Input {
246
+ [key: string]: ((event: KeyboardEvent) => unknown) | undefined,
247
+ /**
248
+ * Catch all input function
249
+ *
250
+ * Will be invoked when there is no dedicated function for a certain key
251
+ */
252
+ // @ts-ignore
253
+ any?: (event: KeyboardEvent) => void,
254
+ /**
255
+ * Intercept key presses on the root Application component before being handled
256
+ * by the currently focused component.
257
+ *
258
+ * Only when a KeyboardEvent (the original one, or a modified one) is returned from the
259
+ * intercept function, the Input event is passed on to the Component with focus.
260
+ *
261
+ * The intercept function can be asynchronous.
262
+ *
263
+ * Note: the intercept input handler is only available on the Root App component (i.e. Blits.Application)
264
+ */
265
+ intercept?: (event: KeyboardEvent) => KeyboardEvent | Promise<KeyboardEvent | any> | any
266
+ }
270
267
 
271
- export interface Log {
272
- /**
273
- * Log an info message
274
- */
275
- info(...args): typeof console.info
276
- /**
277
- * Log an error message
278
- */
279
- error(...args): typeof console.error
280
- /**
281
- * Log a warning
282
- */
283
- warn(...args): typeof console.warn
284
- /**
285
- * Log a debug message
286
- */
287
- debug(...args): typeof console.debug
288
- }
268
+ export interface Log {
269
+ /**
270
+ * Log an info message
271
+ */
272
+ info(...args): typeof console.info
273
+ /**
274
+ * Log an error message
275
+ */
276
+ error(...args): typeof console.error
277
+ /**
278
+ * Log a warning
279
+ */
280
+ warn(...args): typeof console.warn
281
+ /**
282
+ * Log a debug message
283
+ */
284
+ debug(...args): typeof console.debug
285
+ }
289
286
 
290
287
 
291
288
 
292
- export interface RouteData {
293
- [key: string]: any
294
- }
289
+ export interface RouteData {
290
+ [key: string]: any
291
+ }
295
292
 
293
+ /**
294
+ * Router Options that can be used at the same time.
295
+ */
296
+ interface ConcurrentRouteOpts {
296
297
  /**
297
- * Router Options that can be used at the same time.
298
+ * Whether the page navigation should be added to the history stack
299
+ * used when navigating back using `this.$router.back()`
300
+ *
301
+ * @default true
298
302
  */
299
- interface ConcurrentRouteOpts {
300
- /**
301
- * Whether the page navigation should be added to the history stack
302
- * used when navigating back using `this.$router.back()`
303
- *
304
- * @default true
305
- */
306
- inHistory?: boolean,
307
- passFocus?: boolean,
308
- }
303
+ inHistory?: boolean,
304
+ passFocus?: boolean,
305
+ }
309
306
 
307
+ /**
308
+ * Route Options that can't be true at the same time
309
+ */
310
+ type MutualExclusiveRouteOpts = {
310
311
  /**
311
- * Route Options that can't be true at the same time
312
+ * Whether the router should reuse the current page component instance (when matching with the Component
313
+ * specified for the route that we're routing to).
314
+ *
315
+ * @default true
312
316
  */
313
- type MutualExclusiveRouteOpts = {
314
- /**
315
- * Whether the router should reuse the current page component instance (when matching with the Component
316
- * specified for the route that we're routing to).
317
- *
318
- * @default true
319
- */
320
- reuseComponent?: true,
321
- /**
322
- * Whether the page should be kept alive when navigating away. Can be useful
323
- * for a homepage where the state should be fully retained when navigating back
324
- * from a details page
325
- *
326
- * @default false
327
- */
328
- keepAlive?: false
329
- } | {
317
+ reuseComponent?: true,
318
+ /**
319
+ * Whether the page should be kept alive when navigating away. Can be useful
320
+ * for a homepage where the state should be fully retained when navigating back
321
+ * from a details page
322
+ *
323
+ * @default false
324
+ */
325
+ keepAlive?: false
326
+ } | {
327
+ /**
328
+ * Whether the router should reuse the current page component instance (when matching with the Component
329
+ * specified for the route that we're routing to).
330
+ *
331
+ * @default true
332
+ */
333
+ reuseComponent?: false,
334
+ /**
335
+ * Whether the page should be kept alive when navigating away. Can be useful
336
+ * for a homepage where the state should be fully retained when navigating back
337
+ * from a details page
338
+ *
339
+ * @default false
340
+ */
341
+ keepAlive?: true
342
+ }
343
+ export type RouteOptions = ConcurrentRouteOpts & MutualExclusiveRouteOpts;
344
+
345
+ export interface Router {
346
+ /**
347
+ * Navigate to a different location
348
+ *
349
+ * @param {string}
350
+ */
351
+ to(location: string, data?: RouteData, options?: RouteOptions): boolean;
352
+
353
+ /**
354
+ * Get a router scoped to a named RouterView
355
+ *
356
+ * @param {string}
357
+ */
358
+ get(name: string): Router;
359
+
360
+ /**
361
+ * Navigate back one or more locations in the history stack
362
+ *
363
+ * @param {number} [steps=1] - Number of entries to navigate back (like `history.go(-steps)`)
364
+ */
365
+ back(steps?: number): boolean;
366
+
367
+ /**
368
+ * Enable or disable RouterView history navigation on Back input
369
+ */
370
+ backNavigation: boolean;
371
+
372
+ /**
373
+ * Get the current route read-only
374
+ */
375
+ readonly currentRoute: Route;
376
+
377
+ /**
378
+ * Get the list of all routes
379
+ */
380
+ readonly routes: Route[];
381
+
382
+ /**
383
+ * Get navigating state
384
+ */
385
+ readonly navigating: boolean;
386
+
387
+ /**
388
+ * Get a read-only snapshot of the history stack, ordered oldest to most recent.
389
+ * The last entry is the route that `back()` will navigate to first.
390
+ */
391
+ readonly history: Route[];
392
+
393
+ /**
394
+ * Reactive router state
395
+ */
396
+ state: {
330
397
  /**
331
- * Whether the router should reuse the current page component instance (when matching with the Component
332
- * specified for the route that we're routing to).
398
+ * Path of the current route
333
399
  *
334
- * @default true
400
+ * Can be used in:
401
+ * - a template as `$$router.state.path`
402
+ * - inside business logic as `this.$router.state.path`
403
+ * - as a watcher as `$router.state.path(v) {}`
335
404
  */
336
- reuseComponent?: false,
405
+ readonly path: string
337
406
  /**
338
- * Whether the page should be kept alive when navigating away. Can be useful
339
- * for a homepage where the state should be fully retained when navigating back
340
- * from a details page
407
+ * Whether or not the router is currently in the process of navigating
408
+ * between pages
341
409
  *
342
- * @default false
410
+ * Can be used in:
411
+ * - a template as `$$router.state.navihating`
412
+ * - inside business logic as `this.$router.state.navigating`
413
+ * - as a watcher as `$router.state.navigating(v) {}`
343
414
  */
344
- keepAlive?: true
415
+ readonly navigating: boolean
345
416
  }
346
- export type RouteOptions = ConcurrentRouteOpts & MutualExclusiveRouteOpts;
417
+ }
347
418
 
348
- export interface Router {
349
- /**
350
- * Navigate to a different location
351
- *
352
- * @param {string}
353
- */
354
- to(location: string, data?: RouteData, options?: RouteOptions): boolean;
419
+ // Extension point for app- and plugin-specific fields on the component `this`.
420
+ // Add your own properties (e.g., `$telemetry`, `componentName`) via TypeScript
421
+ // module augmentation in your app, without changing core types.
422
+ // Note: `ComponentBase` extends this interface, so augmented fields appear in all
423
+ // hooks, methods, input, computed, and watch.
424
+ export interface CustomComponentProperties {
425
+ // Empty by design: extend in your app via TypeScript module augmentation.
426
+ }
355
427
 
356
- /**
357
- * Get a router scoped to a named RouterView
358
- *
359
- * @param {string}
360
- */
361
- get(name: string): Router;
362
428
 
363
- /**
364
- * Navigate to the previous location
365
- */
366
- back(): boolean;
367
-
368
- /**
369
- * Enable or disable RouterView history navigation on Back input
370
- */
371
- backNavigation: boolean;
429
+ export interface ComponentBase extends CustomComponentProperties {
430
+ /**
431
+ * Indicates whether the component currently has focus
432
+ *
433
+ * @returns Boolean
434
+ */
435
+ readonly $hasFocus: boolean,
372
436
 
373
- /**
374
- * Get the current route read-only
375
- */
376
- readonly currentRoute: Route;
437
+ /**
438
+ * Parent component instance. Undefined for the root Application component (destroyed case not modeled).
439
+ */
440
+ readonly $parent: ComponentBase | undefined,
377
441
 
378
- /**
379
- * Get the list of all routes
380
- */
381
- readonly routes: Route[];
442
+ /**
443
+ * Human-readable identifier for this component instance (e.g. "MyComponent_0")
444
+ */
445
+ readonly $componentId: string,
382
446
 
383
- /**
384
- * Get navigating state
385
- */
386
- readonly navigating: boolean;
447
+ /**
448
+ * Indicates whether the component currently is hovered
449
+ *
450
+ * @returns Boolean
451
+ */
452
+ $isHovered: boolean,
387
453
 
388
- /**
389
- * Reactive router state
390
- */
391
- state: {
392
- /**
393
- * Path of the current route
394
- *
395
- * Can be used in:
396
- * - a template as `$$router.state.path`
397
- * - inside business logic as `this.$router.state.path`
398
- * - as a watcher as `$router.state.path(v) {}`
399
- */
400
- readonly path: string
401
- /**
402
- * Whether or not the router is currently in the process of navigating
403
- * between pages
404
- *
405
- * Can be used in:
406
- * - a template as `$$router.state.navihating`
407
- * - inside business logic as `this.$router.state.navigating`
408
- * - as a watcher as `$router.state.navigating(v) {}`
409
- */
410
- readonly navigating: boolean
411
- }
454
+ /**
455
+ * Listen to events emitted by other components
456
+ */
457
+ $listen: {
458
+ (event: string, callback: (args: any) => void, priority?: number): void;
412
459
  }
413
460
 
414
- // Extension point for app- and plugin-specific fields on the component `this`.
415
- // Add your own properties (e.g., `$telemetry`, `componentName`) via TypeScript
416
- // module augmentation in your app, without changing core types.
417
- // Note: `ComponentBase` extends this interface, so augmented fields appear in all
418
- // hooks, methods, input, computed, and watch.
419
- export interface CustomComponentProperties {
420
- // Empty by design: extend in your app via TypeScript module augmentation.
461
+ /**
462
+ * Remove an event listener previously registered with $listen
463
+ */
464
+ $unlisten: {
465
+ (event: string): void;
421
466
  }
422
467
 
468
+ /**
469
+ * Emit events that other components can listen to
470
+ * @param name - name of the event to be emitted
471
+ * @param data - optional data to be passed along
472
+ * @param byReference - whether or not to pass the data by reference.
473
+ * The default behaviour is passing the data object by reference (`true`).
474
+ * When explicitely passing `false` the object will be recursively cloned
475
+ * and cleaned from any potential reactivity before emitting
476
+ */
477
+ $emit(name: string, data?: any, byReference?: boolean): void;
423
478
 
424
- export interface ComponentBase extends CustomComponentProperties {
425
- /**
426
- * Indicates whether the component currently has focus
427
- *
428
- * @returns Boolean
429
- */
430
- readonly $hasFocus: boolean,
431
-
432
- /**
433
- * Parent component instance. Undefined for the root Application component (destroyed case not modeled).
434
- */
435
- readonly $parent: ComponentBase | undefined,
436
-
437
- /**
438
- * Human-readable identifier for this component instance (e.g. "MyComponent_0")
439
- */
440
- readonly $componentId: string,
441
-
442
- /**
443
- * Indicates whether the component currently is hovered
444
- *
445
- * @returns Boolean
446
- */
447
- $isHovered: boolean,
448
-
449
- /**
450
- * Listen to events emitted by other components
451
- */
452
- $listen: {
453
- (event: string, callback: (args: any) => void, priority?: number): void;
454
- }
479
+ /**
480
+ * Remove all listeners for this component from all events
481
+ */
482
+ $clearListeners: {
483
+ (): void;
484
+ }
455
485
 
456
- /**
457
- * Remove an event listener previously registered with $listen
458
- */
459
- $unlisten: {
460
- (event: string): void;
461
- }
486
+ /**
487
+ * Set a timeout that is automatically cleaned upon component destroy
488
+ */
489
+ $setTimeout: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setTimeout>
462
490
 
463
- /**
464
- * Emit events that other components can listen to
465
- * @param name - name of the event to be emitted
466
- * @param data - optional data to be passed along
467
- * @param byReference - whether or not to pass the data by reference.
468
- * The default behaviour is passing the data object by reference (`true`).
469
- * When explicitely passing `false` the object will be recursively cloned
470
- * and cleaned from any potential reactivity before emitting
471
- */
472
- $emit(name: string, data?: any, byReference?: boolean): void;
491
+ /**
492
+ * Clear a timeout
493
+ */
494
+ $clearTimeout: (id: ReturnType<typeof setTimeout>) => void
473
495
 
474
- /**
475
- * Remove all listeners for this component from all events
476
- */
477
- $clearListeners: {
478
- (): void;
479
- }
496
+ /**
497
+ * Debounce a function execution, preventing memory leaks and function re-allocation
498
+ * @param name - Unique identifier for this debounce instance (unique per component instance)
499
+ * @param callback - Function to debounce
500
+ * @param ms - Delay in milliseconds
501
+ * @param args - Arguments to pass to the callback
502
+ */
503
+ $debounce: (name: string, callback: (...args: any[]) => void, ms?: number, ...args: any[]) => ReturnType<typeof setTimeout>
480
504
 
481
- /**
482
- * Set a timeout that is automatically cleaned upon component destroy
483
- */
484
- $setTimeout: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setTimeout>
505
+ /**
506
+ * Clear a specific debounce by name
507
+ * @param name - The name of the debounce to clear
508
+ */
509
+ $clearDebounce: (name: string) => void
485
510
 
486
- /**
487
- * Clear a timeout
488
- */
489
- $clearTimeout: (id: ReturnType<typeof setTimeout>) => void
511
+ /**
512
+ * Clear all debounces registered on the component (automatically called on component destroy)
513
+ */
514
+ $clearDebounces: () => void
490
515
 
491
- /**
492
- * Debounce a function execution, preventing memory leaks and function re-allocation
493
- * @param name - Unique identifier for this debounce instance (unique per component instance)
494
- * @param callback - Function to debounce
495
- * @param ms - Delay in milliseconds
496
- * @param args - Arguments to pass to the callback
497
- */
498
- $debounce: (name: string, callback: (...args: any[]) => void, ms?: number, ...args: any[]) => ReturnType<typeof setTimeout>
516
+ /**
517
+ * Defer a callback to the next tick (setTimeout 0), automatically cleaned upon component destroy
518
+ * @param callback - Function to execute on the next tick
519
+ * @param args - Arguments to pass to the callback
520
+ */
521
+ $nextTick: (callback: (...args: any[]) => void, ...args: any[]) => ReturnType<typeof setTimeout>
499
522
 
500
- /**
501
- * Clear a specific debounce by name
502
- * @param name - The name of the debounce to clear
503
- */
504
- $clearDebounce: (name: string) => void
523
+ /**
524
+ * Set an interval that is automatically cleaned upon component destroy
525
+ */
526
+ $setInterval: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setInterval>
505
527
 
506
- /**
507
- * Clear all debounces registered on the component (automatically called on component destroy)
508
- */
509
- $clearDebounces: () => void
528
+ /**
529
+ * Clear a interval
530
+ */
531
+ $clearInterval: (id: ReturnType<typeof setInterval>) => void
510
532
 
511
- /**
512
- * Defer a callback to the next tick (setTimeout 0), automatically cleaned upon component destroy
513
- * @param callback - Function to execute on the next tick
514
- * @param args - Arguments to pass to the callback
515
- */
516
- $nextTick: (callback: (...args: any[]) => void, ...args: any[]) => ReturnType<typeof setTimeout>
533
+ /**
534
+ * Log to the console with prettier output and configurable debug levels in Settings
535
+ */
536
+ $log: Log
517
537
 
518
- /**
519
- * Set an interval that is automatically cleaned upon component destroy
520
- */
521
- $setInterval: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setInterval>
538
+ /**
539
+ * Set focus to the Component, optionally pass a KeyboardEvent for instant event bubbling
540
+ */
541
+ $focus: (event?: KeyboardEvent) => void
542
+ /**
543
+ * Handle a keyboard event on this component without changing focus
544
+ * @param event - The keyboard event to handle
545
+ * @returns Returns true if this component or a parent component handled the event, false otherwise
546
+ */
547
+ $input: (event: KeyboardEvent) => boolean
548
+ /**
549
+ * Select a child Element or Component by ref
550
+ *
551
+ * Elements and Components in the template can have an optional ref argument.
552
+ * Returns an Element Instance or Component Instance.
553
+ * Useful for passing on the focus to a Child component.
554
+ *
555
+ * @example
556
+ * ```js
557
+ * const menu = this.$select('Menu')
558
+ * if(menu) {
559
+ * menu.$focus()
560
+ * }
561
+ * ```
562
+ */
563
+ $select: (ref: string) => ComponentBase
522
564
 
523
- /**
524
- * Clear a interval
525
- */
526
- $clearInterval: (id: ReturnType<typeof setInterval>) => void
565
+ /**
566
+ * Announcer methods for screen reader support
567
+ */
568
+ $announcer: Announcer
527
569
 
528
- /**
529
- * Log to the console with prettier output and configurable debug levels in Settings
530
- */
531
- $log: Log
570
+ /**
571
+ * Read settings and change a subset of them at runtime
572
+ *
573
+ * @example
574
+ * ```js
575
+ * this.$settings.get('renderMode')
576
+ * this.$settings.set('canvasColor', 'darkblue')
577
+ * ```
578
+ */
579
+ $settings: SettingsApi
532
580
 
581
+ /**
582
+ * Triggers a forced update on state variables.
583
+ */
584
+ $trigger: (key: string) => void
585
+ /**
586
+ * Router instance
587
+ */
588
+ $router: Router
589
+ /**
590
+ * Creates a reactive object. Changes to properties on the returned object
591
+ * will automatically trigger re-renders in any component that accesses them.
592
+ *
593
+ * Pre-configured with the app's reactivity mode and global scope.
594
+ * Primarily intended for use inside custom plugins.
595
+ */
596
+ $reactive: <T extends Record<string, any>>(target: T) => T
597
+ /**
598
+ * Dynamically set the size of a component holder node
599
+ */
600
+ $size: (dimensions: {
533
601
  /**
534
- * Set focus to the Component, optionally pass a KeyboardEvent for instant event bubbling
535
- */
536
- $focus: (event?: KeyboardEvent) => void
537
- /**
538
- * Handle a keyboard event on this component without changing focus
539
- * @param event - The keyboard event to handle
540
- * @returns Returns true if this component or a parent component handled the event, false otherwise
602
+ * Component width
541
603
  */
542
- $input: (event: KeyboardEvent) => boolean
543
- /**
544
- * Select a child Element or Component by ref
545
- *
546
- * Elements and Components in the template can have an optional ref argument.
547
- * Returns an Element Instance or Component Instance.
548
- * Useful for passing on the focus to a Child component.
549
- *
550
- * @example
551
- * ```js
552
- * const menu = this.$select('Menu')
553
- * if(menu) {
554
- * menu.$focus()
555
- * }
556
- * ```
557
- */
558
- $select: (ref: string) => ComponentBase
559
-
604
+ w: number,
560
605
  /**
561
- * Announcer methods for screen reader support
606
+ * Component height
562
607
  */
563
- $announcer: Announcer
608
+ h: number
609
+ }) => void
610
+ }
564
611
 
565
- /**
566
- * Triggers a forced update on state variables.
567
- */
568
- $trigger: (key: string) => void
569
- /**
570
- * Router instance
571
- */
572
- $router: Router
573
- /**
574
- * Creates a reactive object. Changes to properties on the returned object
575
- * will automatically trigger re-renders in any component that accesses them.
576
- *
577
- * Pre-configured with the app's reactivity mode and global scope.
578
- * Primarily intended for use inside custom plugins.
579
- */
580
- $reactive: <T extends Record<string, any>>(target: T) => T
581
- /**
582
- * Dynamically set the size of a component holder node
583
- */
584
- $size: (dimensions: {
585
- /**
586
- * Component width
587
- */
588
- w: number,
589
- /**
590
- * Component height
591
- */
592
- h: number
593
- }) => void
594
- }
612
+ /**
613
+ * Context type for the root Application: no parent.
614
+ */
615
+ export interface ApplicationBase extends Omit<ComponentBase, '$parent'> {
616
+ readonly $parent: undefined
617
+ }
595
618
 
619
+ /**
620
+ * Context type for Components (Blits.Component): always has a parent when mounted. Destroyed case is not modeled.
621
+ */
622
+ export interface ChildComponentBase extends Omit<ComponentBase, '$parent'> {
623
+ readonly $parent: ComponentBase
624
+ }
625
+
626
+ /**
627
+ * Prop object
628
+ */
629
+ export type PropObject = {
596
630
  /**
597
- * Context type for the root Application: no parent.
631
+ * Name of the prop
598
632
  */
599
- export interface ApplicationBase extends Omit<ComponentBase, '$parent'> {
600
- readonly $parent: undefined
601
- }
602
-
633
+ key: string,
603
634
  /**
604
- * Context type for Components (Blits.Component): always has a parent when mounted. Destroyed case is not modeled.
635
+ * Whether the prop is required to be passed
605
636
  */
606
- export interface ChildComponentBase extends Omit<ComponentBase, '$parent'> {
607
- readonly $parent: ComponentBase
608
- }
609
-
637
+ required?: boolean,
610
638
  /**
611
- * Prop object
639
+ * Default value for the prop when omited
612
640
  */
613
- export type PropObject = {
614
- /**
615
- * Name of the prop
616
- */
617
- key: string,
618
- /**
619
- * Whether the prop is required to be passed
620
- */
621
- required?: boolean,
622
- /**
623
- * Default value for the prop when omited
624
- */
625
- default?: any,
626
- /**
627
- * Cast the value of the prop
628
- *
629
- * @example
630
- * ```js
631
- * {
632
- * cast: Number, // casts to a number
633
- * cast: (v) => v.toUpperCase() // casts to uppercase
634
- * }
635
- * ```
636
- */
637
- cast?: () => any
638
- };
641
+ default?: any,
642
+ /**
643
+ * Cast the value of the prop
644
+ *
645
+ * @example
646
+ * ```js
647
+ * {
648
+ * cast: Number, // casts to a number
649
+ * cast: (v) => v.toUpperCase() // casts to uppercase
650
+ * }
651
+ * ```
652
+ */
653
+ cast?: () => any
654
+ };
639
655
 
640
- export type Props = Record<string, any>
656
+ export type Props = Record<string, any>
641
657
 
642
- type InferProp<T> = T extends (...args: any[]) => any ? ReturnType<T> : T
658
+ type InferProp<T> = T extends (...args: any[]) => any ? ReturnType<T> : T
643
659
 
644
- type InferProps<T extends Record<string, any>> = {
645
- // Since InferProps is no longer used for `Computed` props,
646
- // then we do not need to infer the return type of a function-typed prop in `Props`.
647
- [K in keyof T]: T[K]
648
- }
660
+ type InferProps<T extends Record<string, any>> = {
661
+ // Since InferProps is no longer used for `Computed` props,
662
+ // then we do not need to infer the return type of a function-typed prop in `Props`.
663
+ [K in keyof T]: T[K]
664
+ }
649
665
 
650
- type Computed<T extends Record<string, () => any>> = {
651
- [K in keyof T]: Readonly<ReturnType<T[K]>>
652
- }
666
+ type Computed<T extends Record<string, () => any>> = {
667
+ [K in keyof T]: Readonly<ReturnType<T[K]>>
668
+ }
653
669
 
654
- export type ComponentContext<
655
- P extends Record<string, any>,
656
- S,
657
- M,
658
- C extends Record<string, () => any> = Record<never, never>,
659
- > = ThisType<
660
- Readonly<InferProps<P>> & S & M & Computed<C> & ChildComponentBase
661
- >
662
-
663
- export type ApplicationContext<
664
- P extends Record<string, any>,
665
- S,
666
- M,
667
- C extends Record<string, () => any> = Record<never, never>,
668
- > = ThisType<Readonly<InferProps<P>> & S & M & Computed<C> & ApplicationBase>
669
-
670
- export interface ComponentConfig<
671
- P extends Props = {},
672
- S,
673
- M,
674
- C extends Record<string, () => any> = Record<never, never>,
675
- W,
676
- > {
677
- components?: {
678
- [key: string]: ComponentFactory
679
- }
680
- /**
681
- * XML-based template string of the Component
682
- *
683
- * @example
684
- * ```xml
685
- * <Element :x="$x" w="400" h="1080" color="#64748b">
686
- * <Element x="50" y="40">
687
- * <Button color="#e4e4e7" />
688
- * <Button color="#e4e4e7" y="100" />
689
- * <Button color="#e4e4e7" y="200" />
690
- * <Button color="#e4e4e7" y="300" />
691
- * </Element>
692
- * </Element>
693
- * ```
694
- */
695
- template?: String,
696
- /**
697
- * Allowed props to be passed into the Component by the parent
698
- *
699
- * Can be a simple array with `prop` keys as strings.
700
- * Alternatively objects can be used to specify `required` props and `default` values
701
- *
702
- * @example
703
- * ```js
704
- * props: ['index', {
705
- * key: 'alpha',
706
- * required: true
707
- * }, {
708
- * key: 'color',
709
- * default: 'red'
710
- * }]
711
- * ```
712
- */
713
- props?: P;
714
- /**
715
- * Reactive internal state of the Component instance
716
- *
717
- * Should return an object (literal) with key value pairs.
718
- * Can contain nested objects, but beware that too deep nesting can have
719
- * a negative impact on performance
720
- *
721
- * @example
722
- * ```js
723
- * state() {
724
- * return {
725
- * items: [],
726
- * color: 'red',
727
- * alpha: 0.1
728
- * }
729
- * }
730
- * ```
731
- */
732
- state?: (this: Readonly<InferProps<P>> & ChildComponentBase) => S;
733
- /**
734
- * Methods for abstracting more complex business logic into separate function
735
- */
736
- methods?: M & ComponentContext<P, S, M, C>
737
- /**
738
- * Hooking into Lifecycle events
739
- */
740
- hooks?: Hooks & ComponentContext<P, S, M, C>
741
- /**
742
- * Tapping into user input
743
- */
744
- input?: Input & ComponentContext<P, S, M, C>
745
- /**
746
- * Computed properties
747
- */
748
- computed?: C & ComponentContext<P, S, M, C>
749
- /**
750
- * Watchers for changes to state variables, props or computed properties
751
- */
752
- watch?: W & ComponentContext<P, S, M, C>
753
- /**
754
- * Router Configuration
755
- */
756
- router?: RouterConfig<P, S, M, C>
670
+ export type ComponentContext<
671
+ P extends Record<string, any>,
672
+ S,
673
+ M,
674
+ C extends Record<string, () => any> = Record<never, never>,
675
+ > = ThisType<
676
+ Readonly<InferProps<P>> & S & M & Computed<C> & ChildComponentBase
677
+ >
678
+
679
+ export type ApplicationContext<
680
+ P extends Record<string, any>,
681
+ S,
682
+ M,
683
+ C extends Record<string, () => any> = Record<never, never>,
684
+ > = ThisType<Readonly<InferProps<P>> & S & M & Computed<C> & ApplicationBase>
685
+
686
+ export interface ComponentConfig<
687
+ P extends Props = {},
688
+ S,
689
+ M,
690
+ C extends Record<string, () => any> = Record<never, never>,
691
+ W,
692
+ > {
693
+ components?: {
694
+ [key: string]: ComponentFactory
757
695
  }
696
+ /**
697
+ * XML-based template string of the Component
698
+ *
699
+ * @example
700
+ * ```xml
701
+ * <Element :x="$x" w="400" h="1080" color="#64748b">
702
+ * <Element x="50" y="40">
703
+ * <Button color="#e4e4e7" />
704
+ * <Button color="#e4e4e7" y="100" />
705
+ * <Button color="#e4e4e7" y="200" />
706
+ * <Button color="#e4e4e7" y="300" />
707
+ * </Element>
708
+ * </Element>
709
+ * ```
710
+ */
711
+ template?: String,
712
+ /**
713
+ * Allowed props to be passed into the Component by the parent
714
+ *
715
+ * Can be a simple array with `prop` keys as strings.
716
+ * Alternatively objects can be used to specify `required` props and `default` values
717
+ *
718
+ * @example
719
+ * ```js
720
+ * props: ['index', {
721
+ * key: 'alpha',
722
+ * required: true
723
+ * }, {
724
+ * key: 'color',
725
+ * default: 'red'
726
+ * }]
727
+ * ```
728
+ */
729
+ props?: P;
730
+ /**
731
+ * Reactive internal state of the Component instance
732
+ *
733
+ * Should return an object (literal) with key value pairs.
734
+ * Can contain nested objects, but beware that too deep nesting can have
735
+ * a negative impact on performance
736
+ *
737
+ * @example
738
+ * ```js
739
+ * state() {
740
+ * return {
741
+ * items: [],
742
+ * color: 'red',
743
+ * alpha: 0.1
744
+ * }
745
+ * }
746
+ * ```
747
+ */
748
+ state?: (this: Readonly<InferProps<P>> & ChildComponentBase) => S;
749
+ /**
750
+ * Methods for abstracting more complex business logic into separate function
751
+ */
752
+ methods?: M & ComponentContext<P, S, M, C>
753
+ /**
754
+ * Hooking into Lifecycle events
755
+ */
756
+ hooks?: Hooks & ComponentContext<P, S, M, C>
757
+ /**
758
+ * Tapping into user input
759
+ */
760
+ input?: Input & ComponentContext<P, S, M, C>
761
+ /**
762
+ * Computed properties
763
+ */
764
+ computed?: C & ComponentContext<P, S, M, C>
765
+ /**
766
+ * Watchers for changes to state variables, props or computed properties
767
+ */
768
+ watch?: W & ComponentContext<P, S, M, C>
769
+ /**
770
+ * Router Configuration
771
+ */
772
+ router?: RouterConfig<P, S, M, C>
773
+ }
758
774
 
759
- export interface RouterHooks {
760
- init?: () => Promise<void> | void;
761
- beforeEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
762
- afterEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
763
- error?: (err: string) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
764
- }
775
+ export interface RouterHooks {
776
+ init?: () => Promise<void> | void;
777
+ beforeEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
778
+ afterEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
779
+ error?: (err: string) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
780
+ }
765
781
 
766
- export interface RouterConfig<P extends Props, S, M, C> {
767
- /**
768
- * Register hooks for the router
769
- */
770
- hooks?: RouterHooks & ComponentContext<P, S, M, C>,
782
+ export interface RouterConfig<P extends Props, S, M, C> {
783
+ /**
784
+ * Register hooks for the router
785
+ */
786
+ hooks?: RouterHooks & ComponentContext<P, S, M, C>,
771
787
 
772
- /**
773
- * Routes definition
774
- *
775
- * @example
776
- *
777
- * ```js
778
- * routes: [
779
- * { path: '/', component: Home },
780
- * { path: '/details', component: Details },
781
- * { path: '/account', component: Account },
782
- * ]
783
- * ```
784
- */
785
- routes?: Route[]
788
+ /**
789
+ * Routes definition
790
+ *
791
+ * @example
792
+ *
793
+ * ```js
794
+ * routes: [
795
+ * { path: '/', component: Home },
796
+ * { path: '/details', component: Details },
797
+ * { path: '/account', component: Account },
798
+ * ]
799
+ * ```
800
+ */
801
+ routes?: Route[]
786
802
 
787
- /**
788
- * Enable or disable RouterView history navigation on Back input
789
- *
790
- * @default true
791
- *
792
- * @remarks
793
- * This is an app-wide setting that affects all RouterView instances in your application.
794
- * The router state is global and shared across all router instances.
795
- *
796
- * @example
797
- * ```js
798
- * router: {
799
- * backNavigation: false, // Disable automatic back navigation
800
- * routes: [...]
801
- * }
802
- * ```
803
- */
804
- backNavigation?: boolean
805
- }
803
+ /**
804
+ * Enable or disable RouterView history navigation on Back input
805
+ *
806
+ * @default true
807
+ *
808
+ * @remarks
809
+ * This is an app-wide setting that affects all RouterView instances in your application.
810
+ * The router state is global and shared across all router instances.
811
+ *
812
+ * @example
813
+ * ```js
814
+ * router: {
815
+ * backNavigation: false, // Disable automatic back navigation
816
+ * routes: [...]
817
+ * }
818
+ * ```
819
+ */
820
+ backNavigation?: boolean
821
+ }
806
822
 
807
- export type ApplicationConfig<P extends Props, S, M, C, W> = Omit<
808
- ComponentConfig<P, S, M, C, W>,
809
- 'hooks' | 'methods' | 'input' | 'computed' | 'watch' | 'state' | 'router' | 'routes'
810
- > & {
811
- hooks?: Hooks & ApplicationContext<P, S, M, C>
812
- methods?: M & ApplicationContext<P, S, M, C>
813
- input?: Input & ApplicationContext<P, S, M, C>
814
- computed?: C & ApplicationContext<P, S, M, C>
815
- watch?: W & ApplicationContext<P, S, M, C>
816
- state?: (this: Readonly<InferProps<P>> & ApplicationBase) => S
817
- } & (
818
- | {
819
- /**
820
- * Router Configuration
821
- */
822
- router?: RouterConfig<P, S, M, C>
823
- routes?: never
824
- }
825
- | {
826
- router?: never
827
- /**
828
- * Routes definition
829
- *
830
- * @example
831
- *
832
- * ```js
833
- * routes: [
834
- * { path: '/', component: Home },
835
- * { path: '/details', component: Details },
836
- * { path: '/account', component: Account },
837
- * ]
838
- * ```
839
- */
840
- routes?: Route[]
841
- }
842
- )
843
-
844
- export interface Transition {
845
- /**
846
- * Name of the prop to transition (i.e. 'x', 'y', 'alpha', 'color')
847
- */
848
- prop: string,
849
- /**
850
- * Value the prop should transition to (i.e. 0, 100, '#223388')
851
- */
852
- value: any,
853
- /**
854
- * Duration of the transition in milliseconds, defaults to 300
855
- */
856
- duration?: number,
857
- /**
858
- * Easing function to apply to the transition
859
- */
860
- easing?: string,
861
- /**
862
- * Delay before the transition starts in milliseconds
863
- */
864
- delay?: number
865
- }
823
+ export type ApplicationConfig<P extends Props, S, M, C, W> = Omit<
824
+ ComponentConfig<P, S, M, C, W>,
825
+ 'hooks' | 'methods' | 'input' | 'computed' | 'watch' | 'state' | 'router' | 'routes'
826
+ > & {
827
+ hooks?: Hooks & ApplicationContext<P, S, M, C>
828
+ methods?: M & ApplicationContext<P, S, M, C>
829
+ input?: Input & ApplicationContext<P, S, M, C>
830
+ computed?: C & ApplicationContext<P, S, M, C>
831
+ watch?: W & ApplicationContext<P, S, M, C>
832
+ state?: (this: Readonly<InferProps<P>> & ApplicationBase) => S
833
+ } & (
834
+ | {
835
+ /**
836
+ * Router Configuration
837
+ */
838
+ router?: RouterConfig<P, S, M, C>
839
+ routes?: never
840
+ }
841
+ | {
842
+ router?: never
843
+ /**
844
+ * Routes definition
845
+ *
846
+ * @example
847
+ *
848
+ * ```js
849
+ * routes: [
850
+ * { path: '/', component: Home },
851
+ * { path: '/details', component: Details },
852
+ * { path: '/account', component: Account },
853
+ * ]
854
+ * ```
855
+ */
856
+ routes?: Route[]
857
+ }
858
+ )
866
859
 
867
- export interface Before {
868
- /**
869
- * Name of the prop to set before the transition starts
870
- */
871
- prop: string,
872
- /**
873
- * Value the prop to set before the transition starts
874
- */
875
- value: any,
876
- }
860
+ export interface Transition {
861
+ /**
862
+ * Name of the prop to transition (i.e. 'x', 'y', 'alpha', 'color')
863
+ */
864
+ prop: string,
865
+ /**
866
+ * Value the prop should transition to (i.e. 0, 100, '#223388')
867
+ */
868
+ value: any,
869
+ /**
870
+ * Duration of the transition in milliseconds, defaults to 300
871
+ */
872
+ duration?: number,
873
+ /**
874
+ * Easing function to apply to the transition
875
+ */
876
+ easing?: string,
877
+ /**
878
+ * Delay before the transition starts in milliseconds
879
+ */
880
+ delay?: number
881
+ }
877
882
 
878
- export interface RouteTransition {
879
- /**
880
- * Setting or Array of Settings before new view enters into the router view
881
- */
882
- before: Before | Before[],
883
- /**
884
- * Transition or Array of Transitions for new view to enters into the router view
885
- */
886
- in: Transition | Transition[],
887
- /**
888
- * Transition or Array of Transitions for old view to leave the router view
889
- */
890
- out: Transition | Transition[],
891
- }
883
+ export interface Before {
884
+ /**
885
+ * Name of the prop to set before the transition starts
886
+ */
887
+ prop: string,
888
+ /**
889
+ * Value the prop to set before the transition starts
890
+ */
891
+ value: any,
892
+ }
892
893
 
893
- export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
894
+ export interface RouteTransition {
895
+ /**
896
+ * Setting or Array of Settings before new view enters into the router view
897
+ */
898
+ before: Before | Before[],
899
+ /**
900
+ * Transition or Array of Transitions for new view to enters into the router view
901
+ */
902
+ in: Transition | Transition[],
903
+ /**
904
+ * Transition or Array of Transitions for old view to leave the router view
905
+ */
906
+ out: Transition | Transition[],
907
+ }
894
908
 
895
- export interface RouteAnnounce {
896
- /**
897
- * Message to be announced
898
- */
899
- message: String,
900
- /**
901
- * Politeness level
902
- *
903
- * Defaults to 'off'
904
- */
905
- politeness?: 'off' | 'polite' | 'assertive'
906
- }
909
+ export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
907
910
 
908
- export type RequireAtLeastOne<T> = {
909
- [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
910
- }[keyof T]
911
+ export interface RouteAnnounce {
912
+ /**
913
+ * Message to be announced
914
+ */
915
+ message: String,
916
+ /**
917
+ * Politeness level
918
+ *
919
+ * Defaults to 'off'
920
+ */
921
+ politeness?: 'off' | 'polite' | 'assertive'
922
+ }
911
923
 
912
- export interface RouteHooks {
913
- before?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
914
- after?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
915
- }
924
+ export type RequireAtLeastOne<T> = {
925
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
926
+ }[keyof T]
916
927
 
917
- export type Route = {
918
- /**
919
- * URI path for the route
920
- */
921
- path: string,
922
- /**
923
- * Component to load when activating the route
924
- */
925
- component: ComponentFactory // todo: or promise returning a component instance
926
- /**
927
- * Transition configuration for the route
928
- */
929
- transition?: RequireAtLeastOne<RouteTransition> | RouteTransitionFunction,
930
- /**
931
- * Extra route options
932
- */
933
- options?: RouteOptions
934
- /**
935
- * Message to be announced when visiting the route (often used for accessibility purposes)
936
- *
937
- * Can be either a `String` with the message or an object that defines the message and the
938
- * politeness level
939
- */
940
- announce?: String | RouteAnnounce
941
- /**
942
- * Register hooks for the route
943
- */
944
- hooks?: RouteHooks
945
- /**
946
- * Route path parameters
947
- */
948
- readonly params?: {
949
- [key: string]: string | number
950
- }
951
- /**
952
- * Allows for attaching custom data to a route, either hardcoded in the
953
- * route definition or asigned to the route object in a before hook
954
- *
955
- * Will be merged with the route params and navigation data and passed as
956
- * props into the route component
957
- */
958
- data?: {
959
- [key: string]: any
960
- }
928
+ export interface RouteHooks {
929
+ before?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
930
+ after?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
931
+ }
961
932
 
962
- /**
963
- * Metadata attached to the route, can be used to add any arbitrary
964
- * data to a route such as `auth: true/false`, a route ID or route description
965
- * Note that this data is not reactive and not passed as props to components.
966
- * The metadata is available in the router `before` or `beforeEach` hooks
967
- *
968
- */
969
- meta?: {
970
- [key: string]: any
971
- }
933
+ export type Route = {
934
+ /**
935
+ * URI path for the route
936
+ */
937
+ path: string,
938
+ /**
939
+ * Component to load when activating the route
940
+ */
941
+ component: ComponentFactory // todo: or promise returning a component instance
942
+ /**
943
+ * Transition configuration for the route
944
+ */
945
+ transition?: RequireAtLeastOne<RouteTransition> | RouteTransitionFunction,
946
+ /**
947
+ * Extra route options
948
+ */
949
+ options?: RouteOptions
950
+ /**
951
+ * Message to be announced when visiting the route (often used for accessibility purposes)
952
+ *
953
+ * Can be either a `String` with the message or an object that defines the message and the
954
+ * politeness level
955
+ */
956
+ announce?: String | RouteAnnounce
957
+ /**
958
+ * Register hooks for the route
959
+ */
960
+ hooks?: RouteHooks
961
+ /**
962
+ * Route path parameters
963
+ */
964
+ readonly params?: {
965
+ [key: string]: string | number
966
+ }
967
+ /**
968
+ * Allows for attaching custom data to a route, either hardcoded in the
969
+ * route definition or asigned to the route object in a before hook
970
+ *
971
+ * Will be merged with the route params and navigation data and passed as
972
+ * props into the route component
973
+ */
974
+ data?: {
975
+ [key: string]: any
972
976
  }
973
977
 
974
- type ComponentFactory = () => void
978
+ /**
979
+ * Metadata attached to the route, can be used to add any arbitrary
980
+ * data to a route such as `auth: true/false`, a route ID or route description
981
+ * Note that this data is not reactive and not passed as props to components.
982
+ * The metadata is available in the router `before` or `beforeEach` hooks
983
+ *
984
+ */
985
+ meta?: {
986
+ [key: string]: any
987
+ }
988
+ }
975
989
 
976
- // Launch Related
990
+ type ComponentFactory = (() => void) & {
991
+ needsInteractive?: boolean
992
+ prepare?: () => void
993
+ }
977
994
 
978
- type DebugLevel = 0 | 1 | 2
979
- type LogTypes = 'info' | 'warn' | 'error' | 'debug'
995
+ // Launch Related
980
996
 
981
- interface WebFont {
982
- /**
983
- * Name of the font family
984
- */
985
- family: string,
986
- /**
987
- * Type of font (web)
988
- */
989
- type: 'web',
990
- /**
991
- * Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
992
- */
993
- file: string
994
- }
997
+ type DebugLevel = 0 | 1 | 2
998
+ type LogTypes = 'info' | 'warn' | 'error' | 'debug'
995
999
 
996
- interface SdfFontWithFile {
997
- /**
998
- * Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
999
- */
1000
- file: string
1001
- }
1000
+ interface WebFont {
1001
+ /**
1002
+ * Name of the font family
1003
+ */
1004
+ family: string,
1005
+ /**
1006
+ * Type of font (web)
1007
+ */
1008
+ type: 'web',
1009
+ /**
1010
+ * Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
1011
+ */
1012
+ file: string
1013
+ }
1002
1014
 
1003
- interface SdfFontWithPngJson {
1004
- /**
1005
- * Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
1006
- */
1007
- json: string,
1008
- /**
1009
- * Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
1015
+ interface SdfFontWithFile {
1016
+ /**
1017
+ * Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
1010
1018
  */
1011
- png: string
1012
- }
1019
+ file: string
1020
+ }
1013
1021
 
1014
- type SdfFont = {
1015
- /**
1016
- * Name of the font family
1017
- */
1018
- family: string,
1019
- /**
1020
- * Type of font (web)
1021
- */
1022
- type: 'msdf' | 'sdf',
1023
- } & (SdfFontWithFile | SdfFontWithPngJson)
1022
+ interface SdfFontWithPngJson {
1023
+ /**
1024
+ * Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
1025
+ */
1026
+ json: string,
1027
+ /**
1028
+ * Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
1029
+ */
1030
+ png: string
1031
+ }
1024
1032
 
1025
- type Font = WebFont | SdfFont
1033
+ type SdfFont = {
1034
+ /**
1035
+ * Name of the font family
1036
+ */
1037
+ family: string,
1038
+ /**
1039
+ * Type of font (web)
1040
+ */
1041
+ type: 'msdf' | 'sdf',
1042
+ } & (SdfFontWithFile | SdfFontWithPngJson)
1026
1043
 
1027
- type ShaderEffect = {
1028
- name: string,
1029
- type: RendererShaderEffect
1030
- }
1044
+ type Font = WebFont | SdfFont
1031
1045
 
1032
- type Shader = {
1033
- name: string,
1034
- type: WebGlShaderType | CanvasShaderType
1035
- }
1046
+ type ShaderEffect = {
1047
+ name: string,
1048
+ type: RendererShaderEffect
1049
+ }
1036
1050
 
1037
- type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
1038
- type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
1051
+ type Shader = {
1052
+ name: string,
1053
+ type: WebGlShaderType | CanvasShaderType
1054
+ }
1039
1055
 
1040
- type ReactivityModes = 'Proxy' | 'defineProperty'
1041
- type RenderModes = 'webgl' | 'canvas'
1056
+ type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
1057
+ type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
1042
1058
 
1043
- interface Platform {
1044
- /**
1045
- * Target used for keyboard and pointer input listeners.
1046
- */
1047
- input?: EventTarget | any,
1048
- /**
1049
- * Target used for viewport-level listeners such as resize, scroll, and hashchange.
1050
- */
1051
- viewport?: EventTarget | any,
1052
- /**
1053
- * Dispatch an event through the platform's event system.
1054
- */
1055
- dispatchEvent?: (event: any) => boolean | void,
1056
- /**
1057
- * Persistent key/value storage API.
1058
- */
1059
- localStorage?: Storage | any,
1060
- /**
1061
- * Read the platform cookie string.
1062
- */
1063
- getCookie?: () => string,
1064
- /**
1065
- * Write a cookie string.
1066
- */
1067
- setCookie?: (value: string) => void,
1068
- /**
1069
- * Navigate back in the platform history, when available.
1070
- */
1071
- historyBack?: () => void,
1072
- /**
1073
- * Current viewport/screen height.
1074
- */
1075
- screenHeight?: number,
1076
- /**
1077
- * Available hardware concurrency.
1078
- */
1079
- hardwareConcurrency?: number,
1080
- /**
1081
- * User agent string for platform-specific defaults.
1082
- */
1083
- userAgent?: string,
1084
- /**
1085
- * KeyboardEvent constructor used for event creation and type checks.
1086
- */
1087
- KeyboardEvent?: typeof KeyboardEvent | any,
1088
- /**
1089
- * Check whether an object should be treated as a keyboard event.
1090
- */
1091
- isKeyboardEvent?: (event: any) => boolean,
1092
- /**
1093
- * Create a keyboard event for the current platform.
1094
- */
1095
- createKeyboardEvent?: (type: string, init?: KeyboardEventInit | any) => any,
1096
- /**
1097
- * Platform-specific announcer driver used instead of the default Web Speech driver.
1098
- */
1099
- announcer?: AnnouncerDriver,
1100
- /**
1101
- * Monotonic timestamp provider used for input throttling.
1102
- */
1103
- now?: () => number,
1104
- [key: string]: any,
1105
- }
1059
+ type ReactivityModes = 'Proxy' | 'defineProperty'
1060
+ type RenderModes = 'webgl' | 'canvas'
1106
1061
 
1107
- /**
1108
- * Settings
1109
- *
1110
- * Launcher function that sets up the Lightning renderer and instantiates
1111
- * the Blits App
1062
+ interface Platform {
1063
+ /**
1064
+ * Target used for keyboard and pointer input listeners.
1112
1065
  */
1113
- export interface Settings {
1114
- /**
1115
- * Start the performance profiler when the App launches
1116
- *
1117
- * The profiler is also available on `globalThis.__BLITS_PROFILER__`, so it
1118
- * can be started and stopped from the devtools console
1119
- *
1120
- * @default false
1121
- */
1122
- profiler?: boolean,
1123
- /**
1124
- * Width of the Application
1125
- */
1126
- w?: number,
1127
- /**
1128
- * Height of the Application
1129
- */
1130
- h?: number,
1131
- /**
1132
- * Whether to enable multithreaded
1133
- */
1134
- multithreaded?: boolean,
1135
- /**
1136
- * Debug level for console log messages
1137
- */
1138
- debugLevel?: DebugLevel | LogTypes[],
1139
- /**
1140
- * Fonts to be used in the Application
1141
- */
1142
- fonts?: Font[],
1143
- /**
1144
- * Shaders to be used in the application
1145
- */
1146
- shaders?: Shader[],
1147
- /**
1148
- * Default font family to use in the Application when no font attribute is specified
1149
- * on a Text-component
1150
- *
1151
- * The default font must be registered in the `fonts` array in the settings.
1152
- *
1153
- * Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
1154
- */
1155
- defaultFont?: string,
1156
- /**
1157
- * Custom keymapping
1158
- */
1159
- keymap?: object,
1160
- /**
1161
- * Mode of reactivity (`Proxy` or `defineProperty`)
1162
- */
1163
- reactivityMode?: ReactivityModes,
1164
- /**
1165
- * Screen resolution of the device, defining the pixelRatio used to convert dimensions
1166
- * and positions in the App code to the actual device logical coordinates
1167
- *
1168
- * If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
1169
- * the exact dimensions and positions used the app code are used.
1170
- *
1171
- * Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
1172
- * over the screen resolution setting.
1173
- *
1174
- * Currently 3 screen resolutions are supported, which can be defined with different alias values:
1175
- *
1176
- * For 720x1280 (1px = 0.66666667px)
1177
- * - hd
1178
- * - 720p
1179
- * - 720
1180
- *
1181
- * For 1080x1920 (1px = 1px)
1182
- * - fhd
1183
- * - fullhd
1184
- * - 1080p
1185
- * - 1080
1186
- *
1187
- * For 2160x3840 (1px = 2px)
1188
- * - 4k
1189
- * - 2160p
1190
- * - 2160
1191
- */
1192
- screenResolution?: ScreenResolutions,
1193
- /**
1194
- * Controls the quality of the rendered App.
1195
- *
1196
- * Setting a lower quality leads to less detail on screen, but can positively affect overall
1197
- * performance and smoothness of the App (i.e. a higher FPS).
1198
- *
1199
- * The render quality can be one of the following presets:
1200
- *
1201
- * - `low` => 66% quality
1202
- * - `medium` => 85% quality
1203
- * - `high` => 100% quality
1204
- * - `retina` => 200% quality
1205
- *
1206
- * It's also possible to provide a custom value as a (decimal) number:
1207
- *
1208
- * - `0.2` => 20% quality
1209
- * - `1.5` => 150% quality
1210
- *
1211
- * Defaults to 1 (high quality) when not specified
1212
- */
1213
- renderQuality?: RenderQualities,
1214
- /**
1215
- * Custom pixel ratio of the device used to convert dimensions
1216
- * and positions in the App code to the actual device logical coordinates
1217
- *
1218
- * Takes presedence over the `screenResolution` setting
1219
- *
1220
- * Defaults to 1 if not specified
1221
- */
1222
- pixelRatio?: number
1223
- /**
1224
- * Interval in milliseconds to receive FPS updates
1225
- *
1226
- * @remarks
1227
- * If set to `0`, FPS updates will be disabled.
1228
- *
1229
- * @defaultValue `1000` (disabled)
1230
- */
1231
- fpsInterval?: number
1232
- /**
1233
- * Maximum number of web workers to spin up simultaneously for offloading functionality such
1234
- * as image loading to separate threads (when supported by the browser)
1235
- *
1236
- * If not specified defaults to the number of logical processers available on the device, as reported by
1237
- * `navigator.hardwareConcurrency`, with a maximum of 2. If `navigator.hardwareConcurrency` is
1238
- * not supported the default value will be 2
1239
- */
1240
- webWorkersLimit?: number
1241
- /**
1242
- * Background color of the canvas (also known as the clearColor)
1243
- *
1244
- * Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
1245
- * or a color number in rgba order (`0xff0033ff`)
1246
- *
1247
- * Defauls to transparent (`0x00000000`)
1248
- *
1249
- */
1250
- canvasColor?: string,
1251
- /**
1252
- * Enable inspector
1253
- *
1254
- * Enables the inspector tool for debugging and inspecting the application, the node tree
1255
- * will be replicated in the DOM and can be inspected using the browser's developer tools
1256
- *
1257
- * Defaults to `false`
1258
- */
1259
- inspector?: boolean,
1260
- /**
1261
- * Add an extra margin to the viewport for earlier pre-loading of elements and components
1262
- *
1263
- * By default the Lightning renderer, only renders elements that are inside the defined viewport.
1264
- * Everything outside of these bounds is removed from the render tree.
1265
- *
1266
- * With the viewportMargin you have the option to _virtually_ increase the viewport area,
1267
- * to expedite the pre-loading of elements and / or delay the unloading of elements depending
1268
- * on their position in the (virtual) viewport
1269
- *
1270
- * The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
1271
- * or as a single number which is then applied to all 4 directions equally.
1272
- *
1273
- * Defaults to `0`
1274
- */
1275
- viewportMargin?: number | [number, number, number, number],
1276
- /**
1277
- * Configures the gpu memory settings used by the renderer
1278
- */
1279
- gpuMemory?: {
1280
- /**
1281
- * Maximum GPU memory threshold (in `mb`) after which
1282
- * the renderer will immediately start cleaning up textures to free
1283
- * up graphical memory
1284
- *
1285
- * When setting to `0`, texture memory management is disabled
1286
- *
1287
- * @default `200`
1288
- */
1289
- max?: number,
1290
- /**
1291
- * Target threshold of GPU memory usage, defined as a fraction of
1292
- * the max threshold. The renderer will attempt to keep memory
1293
- * usage below this target by cleaning up non-renderable textures
1294
- *
1295
- * @default `0.8`
1296
- */
1297
- target?: number,
1298
- /**
1299
- * Interval at which regular texture cleanups occur (in `ms`)
1300
- *
1301
- * @default `5000`
1302
- */
1303
- cleanupInterval?: number,
1304
- /**
1305
- * Baseline GPU memory usage of the App (in `mb`), without rendering any
1306
- * textures. This value will be used as a basis when calculating
1307
- * the total memory usage towards the max and target memory
1308
- * usage
1309
- *
1310
- * @default `25`
1311
- */
1312
- baseline?: number,
1313
- /**
1314
- * Whether or not the max threshold should be considered
1315
- * as a strict number that can not be exceeded in any way
1316
- *
1317
- * When set to `true`, new textures won't be created when the
1318
- * max threshold has been reached, until agressive texture cleanup
1319
- * has brought the memory back down
1320
- *
1321
- * @default false
1322
- */
1323
- strict?: boolean,
1324
- },
1325
- /**
1326
- * Defines which mode the renderer should operate in: `webgl` or `canvas`
1327
- *
1328
- * SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
1329
- * be used. Also note that Canvas2d rendering doesnt support the use of shaders.
1330
- *
1331
- * Defaults to `webgl`
1332
- */
1333
- renderMode?: RenderModes,
1066
+ input?: EventTarget | any,
1067
+ /**
1068
+ * Target used for viewport-level listeners such as resize, scroll, and hashchange.
1069
+ */
1070
+ viewport?: EventTarget | any,
1071
+ /**
1072
+ * Dispatch an event through the platform's event system.
1073
+ */
1074
+ dispatchEvent?: (event: any) => boolean | void,
1075
+ /**
1076
+ * Persistent key/value storage API.
1077
+ */
1078
+ localStorage?: Storage | any,
1079
+ /**
1080
+ * Read the platform cookie string.
1081
+ */
1082
+ getCookie?: () => string,
1083
+ /**
1084
+ * Write a cookie string.
1085
+ */
1086
+ setCookie?: (value: string) => void,
1087
+ /**
1088
+ * Navigate back in the platform history, when available.
1089
+ */
1090
+ historyBack?: () => void,
1091
+ /**
1092
+ * Current viewport/screen height.
1093
+ */
1094
+ screenHeight?: number,
1095
+ /**
1096
+ * Available hardware concurrency.
1097
+ */
1098
+ hardwareConcurrency?: number,
1099
+ /**
1100
+ * User agent string for platform-specific defaults.
1101
+ */
1102
+ userAgent?: string,
1103
+ /**
1104
+ * KeyboardEvent constructor used for event creation and type checks.
1105
+ */
1106
+ KeyboardEvent?: typeof KeyboardEvent | any,
1107
+ /**
1108
+ * Check whether an object should be treated as a keyboard event.
1109
+ */
1110
+ isKeyboardEvent?: (event: any) => boolean,
1111
+ /**
1112
+ * Create a keyboard event for the current platform.
1113
+ */
1114
+ createKeyboardEvent?: (type: string, init?: KeyboardEventInit | any) => any,
1115
+ /**
1116
+ * Platform-specific announcer driver used instead of the default Web Speech driver.
1117
+ */
1118
+ announcer?: AnnouncerDriver,
1119
+ /**
1120
+ * Monotonic timestamp provider used for input throttling.
1121
+ */
1122
+ now?: () => number,
1123
+ [key: string]: any,
1124
+ }
1334
1125
 
1126
+ export interface SettingsApi {
1127
+ /**
1128
+ * Returns the value of a setting (any launch setting can be read)
1129
+ */
1130
+ get<K extends keyof Settings>(key: K, defaultValue?: Settings[K]): Settings[K]
1131
+ /**
1132
+ * Changes a setting at runtime (only a subset of settings can be changed at runtime,
1133
+ * see docs/essentials/runtime_settings.md)
1134
+ */
1135
+ set<K extends keyof Settings>(key: K, value: Settings[K]): void
1136
+ }
1137
+
1138
+ /**
1139
+ * Settings
1140
+ *
1141
+ * Launcher function that sets up the Lightning renderer and instantiates
1142
+ * the Blits App
1143
+ */
1144
+ export interface Settings {
1145
+ /**
1146
+ * Start the performance profiler when the App launches
1147
+ *
1148
+ * The profiler is also available on `globalThis.__BLITS_PROFILER__`, so it
1149
+ * can be started and stopped from the devtools console
1150
+ *
1151
+ * @default false
1152
+ */
1153
+ profiler?: boolean,
1154
+ /**
1155
+ * Width of the Application
1156
+ */
1157
+ w?: number,
1158
+ /**
1159
+ * Height of the Application
1160
+ */
1161
+ h?: number,
1162
+ /**
1163
+ * Whether to enable multithreaded
1164
+ */
1165
+ multithreaded?: boolean,
1166
+ /**
1167
+ * Debug level for console log messages
1168
+ */
1169
+ debugLevel?: DebugLevel | LogTypes[],
1170
+ /**
1171
+ * Fonts to be used in the Application
1172
+ */
1173
+ fonts?: Font[],
1174
+ /**
1175
+ * Shaders to be used in the application
1176
+ */
1177
+ shaders?: Shader[],
1178
+ /**
1179
+ * Default font family to use in the Application when no font attribute is specified
1180
+ * on a Text-component
1181
+ *
1182
+ * The default font must be registered in the `fonts` array in the settings.
1183
+ *
1184
+ * Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
1185
+ */
1186
+ defaultFont?: string,
1187
+ /**
1188
+ * Custom keymapping
1189
+ */
1190
+ keymap?: object,
1191
+ /**
1192
+ * Mode of reactivity (`Proxy` or `defineProperty`)
1193
+ */
1194
+ reactivityMode?: ReactivityModes,
1195
+ /**
1196
+ * Screen resolution of the device, defining the pixelRatio used to convert dimensions
1197
+ * and positions in the App code to the actual device logical coordinates
1198
+ *
1199
+ * If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
1200
+ * the exact dimensions and positions used the app code are used.
1201
+ *
1202
+ * Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
1203
+ * over the screen resolution setting.
1204
+ *
1205
+ * Currently 3 screen resolutions are supported, which can be defined with different alias values:
1206
+ *
1207
+ * For 720x1280 (1px = 0.66666667px)
1208
+ * - hd
1209
+ * - 720p
1210
+ * - 720
1211
+ *
1212
+ * For 1080x1920 (1px = 1px)
1213
+ * - fhd
1214
+ * - fullhd
1215
+ * - 1080p
1216
+ * - 1080
1217
+ *
1218
+ * For 2160x3840 (1px = 2px)
1219
+ * - 4k
1220
+ * - 2160p
1221
+ * - 2160
1222
+ */
1223
+ screenResolution?: ScreenResolutions,
1224
+ /**
1225
+ * Controls the quality of the rendered App.
1226
+ *
1227
+ * Setting a lower quality leads to less detail on screen, but can positively affect overall
1228
+ * performance and smoothness of the App (i.e. a higher FPS).
1229
+ *
1230
+ * The render quality can be one of the following presets:
1231
+ *
1232
+ * - `low` => 66% quality
1233
+ * - `medium` => 85% quality
1234
+ * - `high` => 100% quality
1235
+ * - `retina` => 200% quality
1236
+ *
1237
+ * It's also possible to provide a custom value as a (decimal) number:
1238
+ *
1239
+ * - `0.2` => 20% quality
1240
+ * - `1.5` => 150% quality
1241
+ *
1242
+ * Defaults to 1 (high quality) when not specified
1243
+ */
1244
+ renderQuality?: RenderQualities,
1245
+ /**
1246
+ * Custom pixel ratio of the device used to convert dimensions
1247
+ * and positions in the App code to the actual device logical coordinates
1248
+ *
1249
+ * Takes presedence over the `screenResolution` setting
1250
+ *
1251
+ * Defaults to 1 if not specified
1252
+ */
1253
+ pixelRatio?: number
1254
+ /**
1255
+ * Interval in milliseconds to receive FPS updates
1256
+ *
1257
+ * @remarks
1258
+ * If set to `0`, FPS updates will be disabled.
1259
+ *
1260
+ * @defaultValue `1000` (disabled)
1261
+ */
1262
+ fpsInterval?: number
1263
+ /**
1264
+ * Maximum number of web workers to spin up simultaneously for offloading functionality such
1265
+ * as image loading to separate threads (when supported by the browser)
1266
+ *
1267
+ * If not specified defaults to the number of logical processers available on the device, as reported by
1268
+ * `navigator.hardwareConcurrency`, with a maximum of 2. If `navigator.hardwareConcurrency` is
1269
+ * not supported the default value will be 2
1270
+ */
1271
+ webWorkersLimit?: number
1272
+ /**
1273
+ * Background color of the canvas (also known as the clearColor)
1274
+ *
1275
+ * Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
1276
+ * or a color number in rgba order (`0xff0033ff`)
1277
+ *
1278
+ * Defauls to transparent (`0x00000000`)
1279
+ *
1280
+ */
1281
+ canvasColor?: string,
1282
+ /**
1283
+ * Enable inspector
1284
+ *
1285
+ * Enables the inspector tool for debugging and inspecting the application, the node tree
1286
+ * will be replicated in the DOM and can be inspected using the browser's developer tools
1287
+ *
1288
+ * Defaults to `false`
1289
+ */
1290
+ inspector?: boolean,
1291
+ /**
1292
+ * Add an extra margin to the viewport for earlier pre-loading of elements and components
1293
+ *
1294
+ * By default the Lightning renderer, only renders elements that are inside the defined viewport.
1295
+ * Everything outside of these bounds is removed from the render tree.
1296
+ *
1297
+ * With the viewportMargin you have the option to _virtually_ increase the viewport area,
1298
+ * to expedite the pre-loading of elements and / or delay the unloading of elements depending
1299
+ * on their position in the (virtual) viewport
1300
+ *
1301
+ * The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
1302
+ * or as a single number which is then applied to all 4 directions equally.
1303
+ *
1304
+ * Defaults to `0`
1305
+ */
1306
+ viewportMargin?: number | [number, number, number, number],
1307
+ /**
1308
+ * Configures the gpu memory settings used by the renderer
1309
+ */
1310
+ gpuMemory?: {
1335
1311
  /**
1336
- * The time, in milliseconds, after which Blits considers a key press a _hold_ key press
1337
- *
1338
- * During a hold key press the focus delegation behaviour is different: when scrolling
1339
- * through a long list, focus is not handed over to each individual list item, creating a
1340
- * smoother experience
1341
- *
1342
- * Defaults to `50` (ms)
1343
- */
1344
- holdTimeout?: number,
1345
- /**
1346
- * Input throttle time in milliseconds to prevent rapid successive inputs
1347
- *
1348
- * Within the throttle window, only one input will be processed immediately.
1349
- * Subsequent inputs _of the same key_ are ignored until the scheduled input is processed.
1350
- *
1351
- * Pressing a different key will be processed immediately.
1352
- *
1353
- * Set to `0` to disable input throttling.
1354
- *
1355
- * Defaults to `0` (disabled)
1356
- */
1357
- inputThrottle?: number,
1358
- /**
1359
- * Custom canvas object used to render the App to.
1312
+ * Maximum GPU memory threshold (in `mb`) after which
1313
+ * the renderer will immediately start cleaning up textures to free
1314
+ * up graphical memory
1360
1315
  *
1361
- * When not provided, the Lightning renderer will create a
1362
- * new Canvas element and inject it into the DOM
1363
- */
1364
- canvas?: HTMLCanvasElement,
1365
- /**
1366
- * The maximum amount of time the renderer is allowed to process textures in a
1367
- * single frame. If the processing time exceeds this limit, the renderer will
1368
- * skip processing the remaining textures and continue rendering the frame.
1316
+ * When setting to `0`, texture memory management is disabled
1369
1317
  *
1370
- * Defaults to `10`
1318
+ * @default `200`
1371
1319
  */
1372
- textureProcessingTimeLimit?: number,
1320
+ max?: number,
1373
1321
  /**
1374
- * Advanced renderer settings to override Blits launch settings, or configure
1375
- * settings that are not officially exposed in Blits yet
1322
+ * Target threshold of GPU memory usage, defined as a fraction of
1323
+ * the max threshold. The renderer will attempt to keep memory
1324
+ * usage below this target by cleaning up non-renderable textures
1376
1325
  *
1377
- * @important if you dont know what you're doing here, you probably shouldn't be doing it!
1326
+ * @default `0.8`
1378
1327
  */
1379
- advanced?: Partial<RendererMainSettings>,
1328
+ target?: number,
1380
1329
  /**
1381
- * Whether or not the announcer should be activated on initialization
1330
+ * Interval at which regular texture cleanups occur (in `ms`)
1382
1331
  *
1383
- * When set to `false` announcements via `this.$annoucer.speak()` will
1384
- * be ignored. When set to `true` announcement will be spoken out via the
1385
- * text to speech API
1386
- *
1387
- * Announcer can be enabled / disabled run time as well via:
1388
- * - this.$announcer.enable()
1389
- * - this.$announcer.disable()
1390
- * - this.$announcer.toggle(true/false)
1391
- *
1392
- * @default false
1332
+ * @default `5000`
1393
1333
  */
1394
- announcer?: boolean,
1334
+ cleanupInterval?: number,
1395
1335
  /**
1396
- * Global default utterance options for the announcer.
1397
- *
1398
- * These options will be applied to all announcements unless overridden
1399
- * by per-call options passed to `speak()`, `polite()`, or `assertive()`.
1336
+ * Baseline GPU memory usage of the App (in `mb`), without rendering any
1337
+ * textures. This value will be used as a basis when calculating
1338
+ * the total memory usage towards the max and target memory
1339
+ * usage
1400
1340
  *
1401
- * @example
1402
- * ```js
1403
- * announcerOptions: {
1404
- * rate: 1.0,
1405
- * pitch: 1.0,
1406
- * lang: 'en-US',
1407
- * volume: 1.0
1408
- * }
1409
- * ```
1341
+ * @default `25`
1410
1342
  */
1411
- announcerOptions?: AnnouncerUtteranceOptions,
1343
+ baseline?: number,
1412
1344
  /**
1413
- * Enable mouse support (hover and click-to-focus).
1345
+ * Whether or not the max threshold should be considered
1346
+ * as a strict number that can not be exceeded in any way
1414
1347
  *
1415
- * When set to `true`, pointer movement over the canvas updates hover state on components
1416
- * and click dispatches focus and Enter key input to the component under the cursor.
1417
- * When set to `false`, no mouse or pointer listeners are registered.
1348
+ * When set to `true`, new textures won't be created when the
1349
+ * max threshold has been reached, until agressive texture cleanup
1350
+ * has brought the memory back down
1418
1351
  *
1419
1352
  * @default false
1420
1353
  */
1421
- enableMouse?: boolean,
1422
- /**
1423
- * Minimum time in milliseconds between two pointer moves that are processed for hover.
1424
- *
1425
- * Moves arriving sooner are dropped, not delayed.
1426
- *
1427
- * @default 100
1428
- */
1429
- mouseMoveThrottle?: number,
1430
- /**
1431
- * Maximum FPS at which the App will be rendered
1432
- *
1433
- * Lowering the maximum FPS value can improve the overall experience on lower end devices.
1434
- * Targetting a lower FPS may gives the CPU more time to construct each frame leading to a smoother rendering.
1435
- *
1436
- * Defaults to `0` which means no maximum
1437
- */
1438
- maxFPS?: number,
1439
- /**
1440
- * Custom platform layer to be used by the App.
1441
- *
1442
- * Allows replacing platform capabilities such as input targets, storage,
1443
- * keyboard event constructors, and speech APIs.
1444
- * A callback receives Blits' browser defaults and should return the platform overrides.
1445
- */
1446
- platform?: (defaults: Platform) => Partial<Platform>,
1447
- /**
1448
- * Custom platform layer to be used by the renderer.
1449
- *
1450
- * For renderer-specific platform implementations. Passing a renderer platform
1451
- * through `platform` is deprecated.
1452
- */
1453
- rendererPlatform?: RendererMainSettings['platform']
1354
+ strict?: boolean,
1355
+ },
1356
+ /**
1357
+ * Defines which mode the renderer should operate in: `webgl` or `canvas`
1358
+ *
1359
+ * SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
1360
+ * be used. Also note that Canvas2d rendering doesnt support the use of shaders.
1361
+ *
1362
+ * Defaults to `webgl`
1363
+ */
1364
+ renderMode?: RenderModes,
1454
1365
 
1455
- }
1366
+ /**
1367
+ * The time, in milliseconds, after which Blits considers a key press a _hold_ key press
1368
+ *
1369
+ * During a hold key press the focus delegation behaviour is different: when scrolling
1370
+ * through a long list, focus is not handed over to each individual list item, creating a
1371
+ * smoother experience
1372
+ *
1373
+ * Defaults to `50` (ms)
1374
+ */
1375
+ holdTimeout?: number,
1376
+ /**
1377
+ * Input throttle time in milliseconds to prevent rapid successive inputs
1378
+ *
1379
+ * Within the throttle window, only one input will be processed immediately.
1380
+ * Subsequent inputs _of the same key_ are ignored until the scheduled input is processed.
1381
+ *
1382
+ * Pressing a different key will be processed immediately.
1383
+ *
1384
+ * Set to `0` to disable input throttling.
1385
+ *
1386
+ * Defaults to `0` (disabled)
1387
+ */
1388
+ inputThrottle?: number,
1389
+ /**
1390
+ * Custom canvas object used to render the App to.
1391
+ *
1392
+ * When not provided, the Lightning renderer will create a
1393
+ * new Canvas element and inject it into the DOM
1394
+ */
1395
+ canvas?: HTMLCanvasElement,
1396
+ /**
1397
+ * The maximum amount of time the renderer is allowed to process textures in a
1398
+ * single frame. If the processing time exceeds this limit, the renderer will
1399
+ * skip processing the remaining textures and continue rendering the frame.
1400
+ *
1401
+ * Defaults to `10`
1402
+ */
1403
+ textureProcessingTimeLimit?: number,
1404
+ /**
1405
+ * Advanced renderer settings to override Blits launch settings, or configure
1406
+ * settings that are not officially exposed in Blits yet
1407
+ *
1408
+ * @important if you dont know what you're doing here, you probably shouldn't be doing it!
1409
+ */
1410
+ advanced?: Partial<RendererMainSettings>,
1411
+ /**
1412
+ * Whether or not the announcer should be activated on initialization
1413
+ *
1414
+ * When set to `false` announcements via `this.$annoucer.speak()` will
1415
+ * be ignored. When set to `true` announcement will be spoken out via the
1416
+ * text to speech API
1417
+ *
1418
+ * Announcer can be enabled / disabled run time as well via:
1419
+ * - this.$announcer.enable()
1420
+ * - this.$announcer.disable()
1421
+ * - this.$announcer.toggle(true/false)
1422
+ *
1423
+ * @default false
1424
+ */
1425
+ announcer?: boolean,
1426
+ /**
1427
+ * Global default utterance options for the announcer.
1428
+ *
1429
+ * These options will be applied to all announcements unless overridden
1430
+ * by per-call options passed to `speak()`, `polite()`, or `assertive()`.
1431
+ *
1432
+ * @example
1433
+ * ```js
1434
+ * announcerOptions: {
1435
+ * rate: 1.0,
1436
+ * pitch: 1.0,
1437
+ * lang: 'en-US',
1438
+ * volume: 1.0
1439
+ * }
1440
+ * ```
1441
+ */
1442
+ announcerOptions?: AnnouncerUtteranceOptions,
1443
+ /**
1444
+ * Enable mouse support (hover and click-to-focus).
1445
+ *
1446
+ * When set to `true`, pointer movement over the canvas updates hover state on components
1447
+ * and click dispatches focus and Enter key input to the component under the cursor.
1448
+ * When set to `false`, no mouse or pointer listeners are registered.
1449
+ *
1450
+ * @default false
1451
+ */
1452
+ enableMouse?: boolean,
1453
+ /**
1454
+ * Minimum time in milliseconds between two pointer moves that are processed for hover.
1455
+ *
1456
+ * Moves arriving sooner are dropped, not delayed.
1457
+ *
1458
+ * @default 100
1459
+ */
1460
+ mouseMoveThrottle?: number,
1461
+ /**
1462
+ * Maximum FPS at which the App will be rendered
1463
+ *
1464
+ * Lowering the maximum FPS value can improve the overall experience on lower end devices.
1465
+ * Targetting a lower FPS may gives the CPU more time to construct each frame leading to a smoother rendering.
1466
+ *
1467
+ * Defaults to `0` which means no maximum
1468
+ */
1469
+ maxFPS?: number,
1470
+ /**
1471
+ * Custom platform layer to be used by the App.
1472
+ *
1473
+ * Allows replacing platform capabilities such as input targets, storage,
1474
+ * keyboard event constructors, and speech APIs.
1475
+ * A callback receives Blits' browser defaults and should return the platform overrides.
1476
+ */
1477
+ platform?: (defaults: Platform) => Partial<Platform>,
1478
+ /**
1479
+ * Custom platform layer to be used by the renderer.
1480
+ *
1481
+ * For renderer-specific platform implementations. Passing a renderer platform
1482
+ * through `platform` is deprecated.
1483
+ */
1484
+ rendererPlatform?: RendererMainSettings['platform']
1456
1485
 
1457
- interface State {
1458
- [key: string]: any
1459
- }
1486
+ }
1460
1487
 
1461
- interface Methods {
1462
- [key: string]: any
1463
- }
1488
+ interface State {
1489
+ [key: string]: any
1490
+ }
1464
1491
 
1465
- interface Watch {
1466
- [key: string]: any
1467
- }
1492
+ interface Methods {
1493
+ [key: string]: any
1494
+ }
1468
1495
 
1469
- interface Computed {
1470
- [key: string]: () => any
1471
- }
1496
+ interface Watch {
1497
+ [key: string]: any
1498
+ }
1472
1499
 
1500
+ interface Computed {
1501
+ [key: string]: () => any
1502
+ }
1473
1503
 
1474
- interface Plugin {
1475
- /**
1476
- * Name of the plugin. The plugin will be accessible on each Component's
1477
- * `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
1478
- */
1479
- name: string,
1480
- /**
1481
- * Singleton function that will be used to instantiate the plugin.
1482
- * Should do all necessary setup and ideally return an object with
1483
- * properties or methods that can be used in the App
1484
- */
1485
- plugin: (options?: any) => any
1486
- }
1487
1504
 
1505
+ interface Plugin {
1506
+ /**
1507
+ * Name of the plugin. The plugin will be accessible on each Component's
1508
+ * `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
1509
+ */
1510
+ name: string,
1511
+ /**
1512
+ * Singleton function that will be used to instantiate the plugin.
1513
+ * Should do all necessary setup and ideally return an object with
1514
+ * properties or methods that can be used in the App
1515
+ */
1516
+ plugin: (options?: any) => any
1517
+ }
1488
1518
 
1489
- export interface ProfilerEntry {
1490
- /**
1491
- * Number of times the measurement was recorded
1492
- */
1493
- calls: number,
1494
- /**
1495
- * Total time spent, in milliseconds
1496
- */
1497
- totalMs: number,
1498
- /**
1499
- * Slowest single measurement, in milliseconds
1500
- */
1501
- maxMs: number,
1502
- /**
1503
- * Average time per call, in milliseconds
1504
- */
1505
- averageMs: number
1506
- }
1507
1519
 
1508
- export interface ProfilerFrameSummary {
1509
- medianMs: number,
1510
- p95Ms: number,
1511
- p99Ms: number,
1512
- maxMs: number
1513
- }
1520
+ export interface ProfilerEntry {
1521
+ /**
1522
+ * Number of times the measurement was recorded
1523
+ */
1524
+ calls: number,
1525
+ /**
1526
+ * Total time spent, in milliseconds
1527
+ */
1528
+ totalMs: number,
1529
+ /**
1530
+ * Slowest single measurement, in milliseconds
1531
+ */
1532
+ maxMs: number,
1533
+ /**
1534
+ * Average time per call, in milliseconds
1535
+ */
1536
+ averageMs: number
1537
+ }
1514
1538
 
1515
- export interface ProfilerFrameLabel {
1516
- calls: number,
1517
- totalMs: number
1518
- }
1539
+ export interface ProfilerFrameSummary {
1540
+ medianMs: number,
1541
+ p95Ms: number,
1542
+ p99Ms: number,
1543
+ maxMs: number
1544
+ }
1519
1545
 
1520
- export interface ProfilerFrameSnapshot {
1521
- frameCount: number,
1522
- retainedFrameLimit: number,
1523
- frameInterval: ProfilerFrameSummary,
1524
- instrumentedTime: ProfilerFrameSummary,
1525
- slowFramePercent: number,
1526
- slowestFrames: Array<{
1527
- intervalMs: number,
1528
- instrumentedMs: number,
1529
- labels: Record<string, ProfilerFrameLabel>
1530
- }>,
1531
- labels: Record<string, ProfilerFrameLabel & {
1532
- callsPerFrame: number,
1533
- averageMsPerFrame: number
1534
- }>
1535
- }
1546
+ export interface ProfilerFrameLabel {
1547
+ calls: number,
1548
+ totalMs: number
1549
+ }
1536
1550
 
1537
- export interface ProfilerSnapshot {
1538
- measurements: Record<string, ProfilerEntry>,
1539
- frames: ProfilerFrameSnapshot
1540
- }
1551
+ export interface ProfilerFrameSnapshot {
1552
+ frameCount: number,
1553
+ retainedFrameLimit: number,
1554
+ frameInterval: ProfilerFrameSummary,
1555
+ instrumentedTime: ProfilerFrameSummary,
1556
+ slowFramePercent: number,
1557
+ slowestFrames: Array<{
1558
+ intervalMs: number,
1559
+ instrumentedMs: number,
1560
+ labels: Record<string, ProfilerFrameLabel>
1561
+ }>,
1562
+ labels: Record<string, ProfilerFrameLabel & {
1563
+ callsPerFrame: number,
1564
+ averageMsPerFrame: number
1565
+ }>
1566
+ }
1541
1567
 
1542
- export interface Profiler {
1543
- /**
1544
- * Marks the start of a measurement
1545
- */
1546
- mark(name: string): void,
1547
- /**
1548
- * Ends the most recent measurement started with the same name
1549
- */
1550
- markEnd(name: string): void,
1551
- /**
1552
- * Clears previously collected measurements and starts recording
1553
- */
1554
- start(options?: { frames?: boolean, maxFrames?: number, targetFps?: number }): void,
1555
- /**
1556
- * Stops recording and returns the collected measurements
1557
- */
1558
- stop(): ProfilerSnapshot,
1559
- /**
1560
- * Clears all collected measurements, without changing the enabled state
1561
- */
1562
- reset(): void,
1563
- /**
1564
- * Returns the measurements collected so far
1565
- */
1566
- snapshot(): ProfilerSnapshot,
1567
- /**
1568
- * Returns frame-oriented results collected by default or with start({ frames: true })
1569
- */
1570
- frameSnapshot(): ProfilerFrameSnapshot,
1571
- /**
1572
- * Logs marker and frame results as console tables and returns the combined snapshot
1573
- */
1574
- report(): ProfilerSnapshot,
1575
- /**
1576
- * Whether the profiler is currently recording
1577
- */
1578
- readonly enabled: boolean
1579
- }
1568
+ export interface ProfilerSnapshot {
1569
+ measurements: Record<string, ProfilerEntry>,
1570
+ frames: ProfilerFrameSnapshot
1571
+ }
1580
1572
 
1573
+ export interface Profiler {
1581
1574
  /**
1582
- * Blits App Framework
1575
+ * Marks the start of a measurement
1583
1576
  */
1584
- export interface Blits {
1585
- /**
1586
- * Blits Application
1587
- * @param {ApplicationConfig} config - Application Configuration object
1588
- */
1589
- Application<
1590
- P extends Props,
1591
- S extends State,
1592
- M extends Methods,
1593
- C extends Computed = Record<never, never>,
1594
- W extends Watch>(config: ApplicationConfig<P, S, M, C, W>) : ComponentFactory
1595
- /**
1596
- * Blits Component
1597
- * @param {string} name - The name of the Component
1598
- * @param {ComponentConfig} config - Component Configuration object
1599
- */
1600
- Component<
1601
- P extends Props,
1602
- S extends State,
1603
- M extends Methods,
1604
- C extends Computed = Record<never, never>,
1605
- W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
1606
- /**
1607
- * Blits Launch
1608
- */
1609
- Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
1610
- /**
1611
- * Blits Plugin
1612
- *
1613
- * @param plugin
1614
- * Plugin object or singleton function that will be used to instantiate the
1615
- * plugin. Should do all necessary setup and ideally return an object with
1616
- * properties or methods that can be used in the App
1617
- *
1618
- * @param nameOrOptions
1619
- * Name of the plugin or options object, to be passed into the plugin instantiation.
1620
- *
1621
- * When passing a string, the value will be used as **name** of the plugin. The plugin
1622
- * will be accessible on each Component's `this` scope under this name, prefixed with a `$`
1623
- * (i.e. myplugin => `this.$myplugin`)
1624
- *
1625
- * Passing a name is **required** when `plugin` argument is a singleton function
1626
- *
1627
- * When passing an object, the value will be considered to be an `options` object.
1628
- * The options object will be passed into the plugin instantiation method. Can
1629
- * be used to set default values
1630
- *
1631
- * @param options
1632
- * Object with options to be passed into the plugin instantiation method.
1633
- * Can be used to set default values
1634
- */
1635
- Plugin(plugin: Plugin | ((options?: any) => any), nameOrOptions?: string | object , options?: object) : void
1636
- }
1577
+ mark(name: string): void,
1578
+ /**
1579
+ * Ends the most recent measurement started with the same name
1580
+ */
1581
+ markEnd(name: string): void,
1582
+ /**
1583
+ * Clears previously collected measurements and starts recording
1584
+ */
1585
+ start(options?: { frames?: boolean, maxFrames?: number, targetFps?: number }): void,
1586
+ /**
1587
+ * Stops recording and returns the collected measurements
1588
+ */
1589
+ stop(): ProfilerSnapshot,
1590
+ /**
1591
+ * Clears all collected measurements, without changing the enabled state
1592
+ */
1593
+ reset(): void,
1594
+ /**
1595
+ * Returns the measurements collected so far
1596
+ */
1597
+ snapshot(): ProfilerSnapshot,
1598
+ /**
1599
+ * Returns frame-oriented results collected by default or with start({ frames: true })
1600
+ */
1601
+ frameSnapshot(): ProfilerFrameSnapshot,
1602
+ /**
1603
+ * Logs marker and frame results as console tables and returns the combined snapshot
1604
+ */
1605
+ report(): ProfilerSnapshot,
1606
+ /**
1607
+ * Whether the profiler is currently recording
1608
+ */
1609
+ readonly enabled: boolean
1610
+ }
1637
1611
 
1638
- const Blits: Blits;
1612
+ /**
1613
+ * Blits App Framework
1614
+ */
1615
+ export interface Blits {
1616
+ /**
1617
+ * Blits Application
1618
+ * @param {ApplicationConfig} config - Application Configuration object
1619
+ */
1620
+ Application<
1621
+ P extends Props,
1622
+ S extends State,
1623
+ M extends Methods,
1624
+ C extends Computed = Record<never, never>,
1625
+ W extends Watch>(config: ApplicationConfig<P, S, M, C, W>) : ComponentFactory
1626
+ /**
1627
+ * Blits Component
1628
+ * @param {string} name - The name of the Component
1629
+ * @param {ComponentConfig} config - Component Configuration object
1630
+ */
1631
+ Component<
1632
+ P extends Props,
1633
+ S extends State,
1634
+ M extends Methods,
1635
+ C extends Computed = Record<never, never>,
1636
+ W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
1637
+ /**
1638
+ * Blits Launch
1639
+ */
1640
+ Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
1641
+ /**
1642
+ * Blits Plugin
1643
+ *
1644
+ * @param plugin
1645
+ * Plugin object or singleton function that will be used to instantiate the
1646
+ * plugin. Should do all necessary setup and ideally return an object with
1647
+ * properties or methods that can be used in the App
1648
+ *
1649
+ * @param nameOrOptions
1650
+ * Name of the plugin or options object, to be passed into the plugin instantiation.
1651
+ *
1652
+ * When passing a string, the value will be used as **name** of the plugin. The plugin
1653
+ * will be accessible on each Component's `this` scope under this name, prefixed with a `$`
1654
+ * (i.e. myplugin => `this.$myplugin`)
1655
+ *
1656
+ * Passing a name is **required** when `plugin` argument is a singleton function
1657
+ *
1658
+ * When passing an object, the value will be considered to be an `options` object.
1659
+ * The options object will be passed into the plugin instantiation method. Can
1660
+ * be used to set default values
1661
+ *
1662
+ * @param options
1663
+ * Object with options to be passed into the plugin instantiation method.
1664
+ * Can be used to set default values
1665
+ */
1666
+ Plugin(plugin: Plugin | ((options?: any) => any), nameOrOptions?: string | object , options?: object) : void
1667
+ }
1639
1668
 
1640
- export default Blits;
1669
+ const Blits: Blits;
1641
1670
 
1642
- }
1671
+ export default Blits;