@lightningjs/blits 2.13.0 → 2.15.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/CHANGELOG.md +22 -0
- package/eslint.config.cjs +1 -0
- package/index.d.ts +1510 -1383
- package/package.json +11 -3
- package/src/application.js +94 -19
- package/src/component/base/index.js +2 -0
- package/src/component/base/router.js +6 -2
- package/src/component/base/settings.js +68 -0
- package/src/component.js +3 -2
- package/src/components/FPScounter.js +30 -20
- package/src/engines/L3/index.js +39 -1
- package/src/engines/L3/launch.js +1 -15
- package/src/focus/focus.js +4 -0
- package/src/launch.js +25 -1
- package/src/lib/profiler.d.ts +62 -0
- package/src/lib/profiler.js +386 -0
- package/src/router/router.js +14 -1
- package/src/settings.js +5 -0
package/index.d.ts
CHANGED
|
@@ -22,1520 +22,1647 @@ 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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
293
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
*
|
|
332
|
-
* specified for the route that we're routing to).
|
|
398
|
+
* Path of the current route
|
|
333
399
|
*
|
|
334
|
-
*
|
|
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
|
-
|
|
405
|
+
readonly path: string
|
|
337
406
|
/**
|
|
338
|
-
* Whether
|
|
339
|
-
*
|
|
340
|
-
* from a details page
|
|
407
|
+
* Whether or not the router is currently in the process of navigating
|
|
408
|
+
* between pages
|
|
341
409
|
*
|
|
342
|
-
*
|
|
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
|
-
|
|
415
|
+
readonly navigating: boolean
|
|
345
416
|
}
|
|
346
|
-
|
|
417
|
+
}
|
|
347
418
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
365
|
-
|
|
366
|
-
|
|
429
|
+
export interface ComponentBase extends CustomComponentProperties {
|
|
430
|
+
/**
|
|
431
|
+
* Indicates whether the component currently has focus
|
|
432
|
+
*
|
|
433
|
+
* @returns Boolean
|
|
434
|
+
*/
|
|
435
|
+
readonly $hasFocus: boolean,
|
|
367
436
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
437
|
+
/**
|
|
438
|
+
* Parent component instance. Undefined for the root Application component (destroyed case not modeled).
|
|
439
|
+
*/
|
|
440
|
+
readonly $parent: ComponentBase | undefined,
|
|
372
441
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
442
|
+
/**
|
|
443
|
+
* Human-readable identifier for this component instance (e.g. "MyComponent_0")
|
|
444
|
+
*/
|
|
445
|
+
readonly $componentId: string,
|
|
377
446
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
447
|
+
/**
|
|
448
|
+
* Indicates whether the component currently is hovered
|
|
449
|
+
*
|
|
450
|
+
* @returns Boolean
|
|
451
|
+
*/
|
|
452
|
+
$isHovered: boolean,
|
|
382
453
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
454
|
+
/**
|
|
455
|
+
* Listen to events emitted by other components
|
|
456
|
+
*/
|
|
457
|
+
$listen: {
|
|
458
|
+
(event: string, callback: (args: any) => void, priority?: number): void;
|
|
459
|
+
}
|
|
387
460
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
}
|
|
461
|
+
/**
|
|
462
|
+
* Remove an event listener previously registered with $listen
|
|
463
|
+
*/
|
|
464
|
+
$unlisten: {
|
|
465
|
+
(event: string): void;
|
|
412
466
|
}
|
|
413
467
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Remove all listeners for this component from all events
|
|
481
|
+
*/
|
|
482
|
+
$clearListeners: {
|
|
483
|
+
(): void;
|
|
421
484
|
}
|
|
422
485
|
|
|
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>
|
|
423
490
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
* @returns Boolean
|
|
429
|
-
*/
|
|
430
|
-
readonly $hasFocus: boolean,
|
|
491
|
+
/**
|
|
492
|
+
* Clear a timeout
|
|
493
|
+
*/
|
|
494
|
+
$clearTimeout: (id: ReturnType<typeof setTimeout>) => void
|
|
431
495
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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>
|
|
436
504
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Clear a specific debounce by name
|
|
507
|
+
* @param name - The name of the debounce to clear
|
|
508
|
+
*/
|
|
509
|
+
$clearDebounce: (name: string) => void
|
|
441
510
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
*/
|
|
447
|
-
$isHovered: boolean,
|
|
511
|
+
/**
|
|
512
|
+
* Clear all debounces registered on the component (automatically called on component destroy)
|
|
513
|
+
*/
|
|
514
|
+
$clearDebounces: () => void
|
|
448
515
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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>
|
|
455
522
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
(event: string): void;
|
|
461
|
-
}
|
|
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>
|
|
462
527
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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;
|
|
528
|
+
/**
|
|
529
|
+
* Clear a interval
|
|
530
|
+
*/
|
|
531
|
+
$clearInterval: (id: ReturnType<typeof setInterval>) => void
|
|
473
532
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
(): void;
|
|
479
|
-
}
|
|
533
|
+
/**
|
|
534
|
+
* Log to the console with prettier output and configurable debug levels in Settings
|
|
535
|
+
*/
|
|
536
|
+
$log: Log
|
|
480
537
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
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
|
|
485
564
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
565
|
+
/**
|
|
566
|
+
* Announcer methods for screen reader support
|
|
567
|
+
*/
|
|
568
|
+
$announcer: Announcer
|
|
490
569
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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
|
|
499
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: {
|
|
500
601
|
/**
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
$clearDebounce: (name: string) => void
|
|
505
|
-
|
|
602
|
+
* Component width
|
|
603
|
+
*/
|
|
604
|
+
w: number,
|
|
506
605
|
/**
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
606
|
+
* Component height
|
|
607
|
+
*/
|
|
608
|
+
h: number
|
|
609
|
+
}) => void
|
|
610
|
+
}
|
|
510
611
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Context type for the root Application: no parent.
|
|
614
|
+
*/
|
|
615
|
+
export interface ApplicationBase extends Omit<ComponentBase, '$parent'> {
|
|
616
|
+
readonly $parent: undefined
|
|
617
|
+
}
|
|
517
618
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
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
|
+
}
|
|
522
625
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Prop object
|
|
628
|
+
*/
|
|
629
|
+
export type PropObject = {
|
|
630
|
+
/**
|
|
631
|
+
* Name of the prop
|
|
632
|
+
*/
|
|
633
|
+
key: string,
|
|
634
|
+
/**
|
|
635
|
+
* Whether the prop is required to be passed
|
|
636
|
+
*/
|
|
637
|
+
required?: boolean,
|
|
638
|
+
/**
|
|
639
|
+
* Default value for the prop when omited
|
|
640
|
+
*/
|
|
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
|
+
};
|
|
527
655
|
|
|
528
|
-
|
|
529
|
-
* Log to the console with prettier output and configurable debug levels in Settings
|
|
530
|
-
*/
|
|
531
|
-
$log: Log
|
|
656
|
+
export type Props = Record<string, any>
|
|
532
657
|
|
|
533
|
-
|
|
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
|
|
541
|
-
*/
|
|
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
|
|
658
|
+
type InferProp<T> = T extends (...args: any[]) => any ? ReturnType<T> : T
|
|
559
659
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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
|
+
}
|
|
564
665
|
|
|
565
|
-
|
|
566
|
-
|
|
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
|
-
}
|
|
666
|
+
type Computed<T extends Record<string, () => any>> = {
|
|
667
|
+
[K in keyof T]: Readonly<ReturnType<T[K]>>
|
|
668
|
+
}
|
|
595
669
|
|
|
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
|
|
695
|
+
}
|
|
596
696
|
/**
|
|
597
|
-
*
|
|
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
|
+
* ```
|
|
598
710
|
*/
|
|
599
|
-
|
|
600
|
-
readonly $parent: undefined
|
|
601
|
-
}
|
|
602
|
-
|
|
711
|
+
template?: String,
|
|
603
712
|
/**
|
|
604
|
-
*
|
|
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
|
+
* ```
|
|
605
728
|
*/
|
|
606
|
-
|
|
607
|
-
readonly $parent: ComponentBase
|
|
608
|
-
}
|
|
609
|
-
|
|
729
|
+
props?: P;
|
|
610
730
|
/**
|
|
611
|
-
*
|
|
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
|
+
* ```
|
|
612
747
|
*/
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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
|
+
}
|
|
639
774
|
|
|
640
|
-
|
|
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
|
+
}
|
|
641
781
|
|
|
642
|
-
|
|
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>,
|
|
643
787
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
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[]
|
|
649
802
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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
|
+
}
|
|
653
822
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
>
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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
|
|
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
|
|
679
840
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
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>
|
|
757
|
-
}
|
|
758
|
-
|
|
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
|
-
}
|
|
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
|
+
)
|
|
765
859
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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
|
+
}
|
|
771
882
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
* ]
|
|
783
|
-
* ```
|
|
784
|
-
*/
|
|
785
|
-
routes?: Route[]
|
|
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
|
+
}
|
|
786
893
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
* }
|
|
802
|
-
* ```
|
|
803
|
-
*/
|
|
804
|
-
backNavigation?: boolean
|
|
805
|
-
}
|
|
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
|
+
}
|
|
806
908
|
|
|
807
|
-
|
|
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
|
-
}
|
|
909
|
+
export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
|
|
866
910
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
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
|
+
}
|
|
877
923
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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
|
-
}
|
|
924
|
+
export type RequireAtLeastOne<T> = {
|
|
925
|
+
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
|
|
926
|
+
}[keyof T]
|
|
892
927
|
|
|
893
|
-
|
|
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
|
+
}
|
|
894
932
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
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
|
|
906
966
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
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
|
|
915
976
|
}
|
|
916
977
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
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
|
-
}
|
|
961
|
-
|
|
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
|
-
}
|
|
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
|
|
972
987
|
}
|
|
988
|
+
}
|
|
973
989
|
|
|
974
|
-
|
|
990
|
+
type ComponentFactory = () => void
|
|
975
991
|
|
|
976
|
-
|
|
992
|
+
// Launch Related
|
|
977
993
|
|
|
978
|
-
|
|
979
|
-
|
|
994
|
+
type DebugLevel = 0 | 1 | 2
|
|
995
|
+
type LogTypes = 'info' | 'warn' | 'error' | 'debug'
|
|
980
996
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
997
|
+
interface WebFont {
|
|
998
|
+
/**
|
|
999
|
+
* Name of the font family
|
|
1000
|
+
*/
|
|
1001
|
+
family: string,
|
|
1002
|
+
/**
|
|
1003
|
+
* Type of font (web)
|
|
1004
|
+
*/
|
|
1005
|
+
type: 'web',
|
|
1006
|
+
/**
|
|
1007
|
+
* Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
|
|
1008
|
+
*/
|
|
1009
|
+
file: string
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
interface SdfFontWithFile {
|
|
1013
|
+
/**
|
|
1014
|
+
* Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
|
|
992
1015
|
*/
|
|
993
|
-
|
|
994
|
-
|
|
1016
|
+
file: string
|
|
1017
|
+
}
|
|
995
1018
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1019
|
+
interface SdfFontWithPngJson {
|
|
1020
|
+
/**
|
|
1021
|
+
* Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
|
|
1022
|
+
*/
|
|
1023
|
+
json: string,
|
|
1024
|
+
/**
|
|
1025
|
+
* Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
|
|
1026
|
+
*/
|
|
1027
|
+
png: string
|
|
1028
|
+
}
|
|
1002
1029
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1030
|
+
type SdfFont = {
|
|
1031
|
+
/**
|
|
1032
|
+
* Name of the font family
|
|
1033
|
+
*/
|
|
1034
|
+
family: string,
|
|
1035
|
+
/**
|
|
1036
|
+
* Type of font (web)
|
|
1037
|
+
*/
|
|
1038
|
+
type: 'msdf' | 'sdf',
|
|
1039
|
+
} & (SdfFontWithFile | SdfFontWithPngJson)
|
|
1013
1040
|
|
|
1014
|
-
|
|
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)
|
|
1041
|
+
type Font = WebFont | SdfFont
|
|
1024
1042
|
|
|
1025
|
-
|
|
1043
|
+
type ShaderEffect = {
|
|
1044
|
+
name: string,
|
|
1045
|
+
type: RendererShaderEffect
|
|
1046
|
+
}
|
|
1026
1047
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1048
|
+
type Shader = {
|
|
1049
|
+
name: string,
|
|
1050
|
+
type: WebGlShaderType | CanvasShaderType
|
|
1051
|
+
}
|
|
1031
1052
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
type: WebGlShaderType | CanvasShaderType
|
|
1035
|
-
}
|
|
1053
|
+
type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
|
|
1054
|
+
type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
|
|
1036
1055
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1056
|
+
type ReactivityModes = 'Proxy' | 'defineProperty'
|
|
1057
|
+
type RenderModes = 'webgl' | 'canvas'
|
|
1039
1058
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1059
|
+
interface Platform {
|
|
1060
|
+
/**
|
|
1061
|
+
* Target used for keyboard and pointer input listeners.
|
|
1062
|
+
*/
|
|
1063
|
+
input?: EventTarget | any,
|
|
1064
|
+
/**
|
|
1065
|
+
* Target used for viewport-level listeners such as resize, scroll, and hashchange.
|
|
1066
|
+
*/
|
|
1067
|
+
viewport?: EventTarget | any,
|
|
1068
|
+
/**
|
|
1069
|
+
* Dispatch an event through the platform's event system.
|
|
1070
|
+
*/
|
|
1071
|
+
dispatchEvent?: (event: any) => boolean | void,
|
|
1072
|
+
/**
|
|
1073
|
+
* Persistent key/value storage API.
|
|
1074
|
+
*/
|
|
1075
|
+
localStorage?: Storage | any,
|
|
1076
|
+
/**
|
|
1077
|
+
* Read the platform cookie string.
|
|
1078
|
+
*/
|
|
1079
|
+
getCookie?: () => string,
|
|
1080
|
+
/**
|
|
1081
|
+
* Write a cookie string.
|
|
1082
|
+
*/
|
|
1083
|
+
setCookie?: (value: string) => void,
|
|
1084
|
+
/**
|
|
1085
|
+
* Navigate back in the platform history, when available.
|
|
1086
|
+
*/
|
|
1087
|
+
historyBack?: () => void,
|
|
1088
|
+
/**
|
|
1089
|
+
* Current viewport/screen height.
|
|
1090
|
+
*/
|
|
1091
|
+
screenHeight?: number,
|
|
1092
|
+
/**
|
|
1093
|
+
* Available hardware concurrency.
|
|
1094
|
+
*/
|
|
1095
|
+
hardwareConcurrency?: number,
|
|
1096
|
+
/**
|
|
1097
|
+
* User agent string for platform-specific defaults.
|
|
1098
|
+
*/
|
|
1099
|
+
userAgent?: string,
|
|
1100
|
+
/**
|
|
1101
|
+
* KeyboardEvent constructor used for event creation and type checks.
|
|
1102
|
+
*/
|
|
1103
|
+
KeyboardEvent?: typeof KeyboardEvent | any,
|
|
1104
|
+
/**
|
|
1105
|
+
* Check whether an object should be treated as a keyboard event.
|
|
1106
|
+
*/
|
|
1107
|
+
isKeyboardEvent?: (event: any) => boolean,
|
|
1108
|
+
/**
|
|
1109
|
+
* Create a keyboard event for the current platform.
|
|
1110
|
+
*/
|
|
1111
|
+
createKeyboardEvent?: (type: string, init?: KeyboardEventInit | any) => any,
|
|
1112
|
+
/**
|
|
1113
|
+
* Platform-specific announcer driver used instead of the default Web Speech driver.
|
|
1114
|
+
*/
|
|
1115
|
+
announcer?: AnnouncerDriver,
|
|
1116
|
+
/**
|
|
1117
|
+
* Monotonic timestamp provider used for input throttling.
|
|
1118
|
+
*/
|
|
1119
|
+
now?: () => number,
|
|
1120
|
+
[key: string]: any,
|
|
1121
|
+
}
|
|
1042
1122
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
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
|
-
}
|
|
1123
|
+
export interface SettingsApi {
|
|
1124
|
+
/**
|
|
1125
|
+
* Returns the value of a setting (any launch setting can be read)
|
|
1126
|
+
*/
|
|
1127
|
+
get<K extends keyof Settings>(key: K, defaultValue?: Settings[K]): Settings[K]
|
|
1128
|
+
/**
|
|
1129
|
+
* Changes a setting at runtime (only a subset of settings can be changed at runtime,
|
|
1130
|
+
* see docs/essentials/runtime_settings.md)
|
|
1131
|
+
*/
|
|
1132
|
+
set<K extends keyof Settings>(key: K, value: Settings[K]): void
|
|
1133
|
+
}
|
|
1106
1134
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1135
|
+
/**
|
|
1136
|
+
* Settings
|
|
1137
|
+
*
|
|
1138
|
+
* Launcher function that sets up the Lightning renderer and instantiates
|
|
1139
|
+
* the Blits App
|
|
1140
|
+
*/
|
|
1141
|
+
export interface Settings {
|
|
1142
|
+
/**
|
|
1143
|
+
* Start the performance profiler when the App launches
|
|
1144
|
+
*
|
|
1145
|
+
* The profiler is also available on `globalThis.__BLITS_PROFILER__`, so it
|
|
1146
|
+
* can be started and stopped from the devtools console
|
|
1147
|
+
*
|
|
1148
|
+
* @default false
|
|
1149
|
+
*/
|
|
1150
|
+
profiler?: boolean,
|
|
1151
|
+
/**
|
|
1152
|
+
* Width of the Application
|
|
1153
|
+
*/
|
|
1154
|
+
w?: number,
|
|
1155
|
+
/**
|
|
1156
|
+
* Height of the Application
|
|
1157
|
+
*/
|
|
1158
|
+
h?: number,
|
|
1159
|
+
/**
|
|
1160
|
+
* Whether to enable multithreaded
|
|
1161
|
+
*/
|
|
1162
|
+
multithreaded?: boolean,
|
|
1163
|
+
/**
|
|
1164
|
+
* Debug level for console log messages
|
|
1165
|
+
*/
|
|
1166
|
+
debugLevel?: DebugLevel | LogTypes[],
|
|
1167
|
+
/**
|
|
1168
|
+
* Fonts to be used in the Application
|
|
1169
|
+
*/
|
|
1170
|
+
fonts?: Font[],
|
|
1171
|
+
/**
|
|
1172
|
+
* Shaders to be used in the application
|
|
1173
|
+
*/
|
|
1174
|
+
shaders?: Shader[],
|
|
1175
|
+
/**
|
|
1176
|
+
* Default font family to use in the Application when no font attribute is specified
|
|
1177
|
+
* on a Text-component
|
|
1178
|
+
*
|
|
1179
|
+
* The default font must be registered in the `fonts` array in the settings.
|
|
1180
|
+
*
|
|
1181
|
+
* Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
|
|
1182
|
+
*/
|
|
1183
|
+
defaultFont?: string,
|
|
1184
|
+
/**
|
|
1185
|
+
* Custom keymapping
|
|
1186
|
+
*/
|
|
1187
|
+
keymap?: object,
|
|
1188
|
+
/**
|
|
1189
|
+
* Mode of reactivity (`Proxy` or `defineProperty`)
|
|
1190
|
+
*/
|
|
1191
|
+
reactivityMode?: ReactivityModes,
|
|
1192
|
+
/**
|
|
1193
|
+
* Screen resolution of the device, defining the pixelRatio used to convert dimensions
|
|
1194
|
+
* and positions in the App code to the actual device logical coordinates
|
|
1195
|
+
*
|
|
1196
|
+
* If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
|
|
1197
|
+
* the exact dimensions and positions used the app code are used.
|
|
1198
|
+
*
|
|
1199
|
+
* Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
|
|
1200
|
+
* over the screen resolution setting.
|
|
1201
|
+
*
|
|
1202
|
+
* Currently 3 screen resolutions are supported, which can be defined with different alias values:
|
|
1203
|
+
*
|
|
1204
|
+
* For 720x1280 (1px = 0.66666667px)
|
|
1205
|
+
* - hd
|
|
1206
|
+
* - 720p
|
|
1207
|
+
* - 720
|
|
1208
|
+
*
|
|
1209
|
+
* For 1080x1920 (1px = 1px)
|
|
1210
|
+
* - fhd
|
|
1211
|
+
* - fullhd
|
|
1212
|
+
* - 1080p
|
|
1213
|
+
* - 1080
|
|
1214
|
+
*
|
|
1215
|
+
* For 2160x3840 (1px = 2px)
|
|
1216
|
+
* - 4k
|
|
1217
|
+
* - 2160p
|
|
1218
|
+
* - 2160
|
|
1219
|
+
*/
|
|
1220
|
+
screenResolution?: ScreenResolutions,
|
|
1221
|
+
/**
|
|
1222
|
+
* Controls the quality of the rendered App.
|
|
1223
|
+
*
|
|
1224
|
+
* Setting a lower quality leads to less detail on screen, but can positively affect overall
|
|
1225
|
+
* performance and smoothness of the App (i.e. a higher FPS).
|
|
1226
|
+
*
|
|
1227
|
+
* The render quality can be one of the following presets:
|
|
1228
|
+
*
|
|
1229
|
+
* - `low` => 66% quality
|
|
1230
|
+
* - `medium` => 85% quality
|
|
1231
|
+
* - `high` => 100% quality
|
|
1232
|
+
* - `retina` => 200% quality
|
|
1233
|
+
*
|
|
1234
|
+
* It's also possible to provide a custom value as a (decimal) number:
|
|
1235
|
+
*
|
|
1236
|
+
* - `0.2` => 20% quality
|
|
1237
|
+
* - `1.5` => 150% quality
|
|
1238
|
+
*
|
|
1239
|
+
* Defaults to 1 (high quality) when not specified
|
|
1240
|
+
*/
|
|
1241
|
+
renderQuality?: RenderQualities,
|
|
1242
|
+
/**
|
|
1243
|
+
* Custom pixel ratio of the device used to convert dimensions
|
|
1244
|
+
* and positions in the App code to the actual device logical coordinates
|
|
1245
|
+
*
|
|
1246
|
+
* Takes presedence over the `screenResolution` setting
|
|
1247
|
+
*
|
|
1248
|
+
* Defaults to 1 if not specified
|
|
1249
|
+
*/
|
|
1250
|
+
pixelRatio?: number
|
|
1251
|
+
/**
|
|
1252
|
+
* Interval in milliseconds to receive FPS updates
|
|
1109
1253
|
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1254
|
+
* @remarks
|
|
1255
|
+
* If set to `0`, FPS updates will be disabled.
|
|
1256
|
+
*
|
|
1257
|
+
* @defaultValue `1000` (disabled)
|
|
1112
1258
|
*/
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
* Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
|
|
1163
|
-
* over the screen resolution setting.
|
|
1164
|
-
*
|
|
1165
|
-
* Currently 3 screen resolutions are supported, which can be defined with different alias values:
|
|
1166
|
-
*
|
|
1167
|
-
* For 720x1280 (1px = 0.66666667px)
|
|
1168
|
-
* - hd
|
|
1169
|
-
* - 720p
|
|
1170
|
-
* - 720
|
|
1171
|
-
*
|
|
1172
|
-
* For 1080x1920 (1px = 1px)
|
|
1173
|
-
* - fhd
|
|
1174
|
-
* - fullhd
|
|
1175
|
-
* - 1080p
|
|
1176
|
-
* - 1080
|
|
1177
|
-
*
|
|
1178
|
-
* For 2160x3840 (1px = 2px)
|
|
1179
|
-
* - 4k
|
|
1180
|
-
* - 2160p
|
|
1181
|
-
* - 2160
|
|
1182
|
-
*/
|
|
1183
|
-
screenResolution?: ScreenResolutions,
|
|
1184
|
-
/**
|
|
1185
|
-
* Controls the quality of the rendered App.
|
|
1186
|
-
*
|
|
1187
|
-
* Setting a lower quality leads to less detail on screen, but can positively affect overall
|
|
1188
|
-
* performance and smoothness of the App (i.e. a higher FPS).
|
|
1189
|
-
*
|
|
1190
|
-
* The render quality can be one of the following presets:
|
|
1191
|
-
*
|
|
1192
|
-
* - `low` => 66% quality
|
|
1193
|
-
* - `medium` => 85% quality
|
|
1194
|
-
* - `high` => 100% quality
|
|
1195
|
-
* - `retina` => 200% quality
|
|
1196
|
-
*
|
|
1197
|
-
* It's also possible to provide a custom value as a (decimal) number:
|
|
1198
|
-
*
|
|
1199
|
-
* - `0.2` => 20% quality
|
|
1200
|
-
* - `1.5` => 150% quality
|
|
1201
|
-
*
|
|
1202
|
-
* Defaults to 1 (high quality) when not specified
|
|
1203
|
-
*/
|
|
1204
|
-
renderQuality?: RenderQualities,
|
|
1205
|
-
/**
|
|
1206
|
-
* Custom pixel ratio of the device used to convert dimensions
|
|
1207
|
-
* and positions in the App code to the actual device logical coordinates
|
|
1208
|
-
*
|
|
1209
|
-
* Takes presedence over the `screenResolution` setting
|
|
1210
|
-
*
|
|
1211
|
-
* Defaults to 1 if not specified
|
|
1212
|
-
*/
|
|
1213
|
-
pixelRatio?: number
|
|
1214
|
-
/**
|
|
1215
|
-
* Interval in milliseconds to receive FPS updates
|
|
1216
|
-
*
|
|
1217
|
-
* @remarks
|
|
1218
|
-
* If set to `0`, FPS updates will be disabled.
|
|
1219
|
-
*
|
|
1220
|
-
* @defaultValue `1000` (disabled)
|
|
1221
|
-
*/
|
|
1222
|
-
fpsInterval?: number
|
|
1223
|
-
/**
|
|
1224
|
-
* Maximum number of web workers to spin up simultaneously for offloading functionality such
|
|
1225
|
-
* as image loading to separate threads (when supported by the browser)
|
|
1226
|
-
*
|
|
1227
|
-
* If not specified defaults to the number of logical processers available on the device, as reported by
|
|
1228
|
-
* `navigator.hardwareConcurrency`, with a maximum of 2. If `navigator.hardwareConcurrency` is
|
|
1229
|
-
* not supported the default value will be 2
|
|
1230
|
-
*/
|
|
1231
|
-
webWorkersLimit?: number
|
|
1232
|
-
/**
|
|
1233
|
-
* Background color of the canvas (also known as the clearColor)
|
|
1234
|
-
*
|
|
1235
|
-
* Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
|
|
1236
|
-
* or a color number in rgba order (`0xff0033ff`)
|
|
1237
|
-
*
|
|
1238
|
-
* Defauls to transparent (`0x00000000`)
|
|
1239
|
-
*
|
|
1240
|
-
*/
|
|
1241
|
-
canvasColor?: string,
|
|
1242
|
-
/**
|
|
1243
|
-
* Enable inspector
|
|
1244
|
-
*
|
|
1245
|
-
* Enables the inspector tool for debugging and inspecting the application, the node tree
|
|
1246
|
-
* will be replicated in the DOM and can be inspected using the browser's developer tools
|
|
1247
|
-
*
|
|
1248
|
-
* Defaults to `false`
|
|
1249
|
-
*/
|
|
1250
|
-
inspector?: boolean,
|
|
1251
|
-
/**
|
|
1252
|
-
* Add an extra margin to the viewport for earlier pre-loading of elements and components
|
|
1253
|
-
*
|
|
1254
|
-
* By default the Lightning renderer, only renders elements that are inside the defined viewport.
|
|
1255
|
-
* Everything outside of these bounds is removed from the render tree.
|
|
1256
|
-
*
|
|
1257
|
-
* With the viewportMargin you have the option to _virtually_ increase the viewport area,
|
|
1258
|
-
* to expedite the pre-loading of elements and / or delay the unloading of elements depending
|
|
1259
|
-
* on their position in the (virtual) viewport
|
|
1260
|
-
*
|
|
1261
|
-
* The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
|
|
1262
|
-
* or as a single number which is then applied to all 4 directions equally.
|
|
1263
|
-
*
|
|
1264
|
-
* Defaults to `0`
|
|
1265
|
-
*/
|
|
1266
|
-
viewportMargin?: number | [number, number, number, number],
|
|
1267
|
-
/**
|
|
1268
|
-
* Configures the gpu memory settings used by the renderer
|
|
1269
|
-
*/
|
|
1270
|
-
gpuMemory?: {
|
|
1271
|
-
/**
|
|
1272
|
-
* Maximum GPU memory threshold (in `mb`) after which
|
|
1273
|
-
* the renderer will immediately start cleaning up textures to free
|
|
1274
|
-
* up graphical memory
|
|
1275
|
-
*
|
|
1276
|
-
* When setting to `0`, texture memory management is disabled
|
|
1277
|
-
*
|
|
1278
|
-
* @default `200`
|
|
1279
|
-
*/
|
|
1280
|
-
max?: number,
|
|
1281
|
-
/**
|
|
1282
|
-
* Target threshold of GPU memory usage, defined as a fraction of
|
|
1283
|
-
* the max threshold. The renderer will attempt to keep memory
|
|
1284
|
-
* usage below this target by cleaning up non-renderable textures
|
|
1285
|
-
*
|
|
1286
|
-
* @default `0.8`
|
|
1287
|
-
*/
|
|
1288
|
-
target?: number,
|
|
1289
|
-
/**
|
|
1290
|
-
* Interval at which regular texture cleanups occur (in `ms`)
|
|
1291
|
-
*
|
|
1292
|
-
* @default `5000`
|
|
1293
|
-
*/
|
|
1294
|
-
cleanupInterval?: number,
|
|
1295
|
-
/**
|
|
1296
|
-
* Baseline GPU memory usage of the App (in `mb`), without rendering any
|
|
1297
|
-
* textures. This value will be used as a basis when calculating
|
|
1298
|
-
* the total memory usage towards the max and target memory
|
|
1299
|
-
* usage
|
|
1300
|
-
*
|
|
1301
|
-
* @default `25`
|
|
1302
|
-
*/
|
|
1303
|
-
baseline?: number,
|
|
1304
|
-
/**
|
|
1305
|
-
* Whether or not the max threshold should be considered
|
|
1306
|
-
* as a strict number that can not be exceeded in any way
|
|
1307
|
-
*
|
|
1308
|
-
* When set to `true`, new textures won't be created when the
|
|
1309
|
-
* max threshold has been reached, until agressive texture cleanup
|
|
1310
|
-
* has brought the memory back down
|
|
1311
|
-
*
|
|
1312
|
-
* @default false
|
|
1313
|
-
*/
|
|
1314
|
-
strict?: boolean,
|
|
1315
|
-
},
|
|
1316
|
-
/**
|
|
1317
|
-
* Defines which mode the renderer should operate in: `webgl` or `canvas`
|
|
1318
|
-
*
|
|
1319
|
-
* SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
|
|
1320
|
-
* be used. Also note that Canvas2d rendering doesnt support the use of shaders.
|
|
1321
|
-
*
|
|
1322
|
-
* Defaults to `webgl`
|
|
1323
|
-
*/
|
|
1324
|
-
renderMode?: RenderModes,
|
|
1325
|
-
|
|
1326
|
-
/**
|
|
1327
|
-
* The time, in milliseconds, after which Blits considers a key press a _hold_ key press
|
|
1328
|
-
*
|
|
1329
|
-
* During a hold key press the focus delegation behaviour is different: when scrolling
|
|
1330
|
-
* through a long list, focus is not handed over to each individual list item, creating a
|
|
1331
|
-
* smoother experience
|
|
1332
|
-
*
|
|
1333
|
-
* Defaults to `50` (ms)
|
|
1334
|
-
*/
|
|
1335
|
-
holdTimeout?: number,
|
|
1336
|
-
/**
|
|
1337
|
-
* Input throttle time in milliseconds to prevent rapid successive inputs
|
|
1338
|
-
*
|
|
1339
|
-
* Within the throttle window, only one input will be processed immediately.
|
|
1340
|
-
* Subsequent inputs _of the same key_ are ignored until the scheduled input is processed.
|
|
1341
|
-
*
|
|
1342
|
-
* Pressing a different key will be processed immediately.
|
|
1343
|
-
*
|
|
1344
|
-
* Set to `0` to disable input throttling.
|
|
1345
|
-
*
|
|
1346
|
-
* Defaults to `0` (disabled)
|
|
1347
|
-
*/
|
|
1348
|
-
inputThrottle?: number,
|
|
1259
|
+
fpsInterval?: number
|
|
1260
|
+
/**
|
|
1261
|
+
* Maximum number of web workers to spin up simultaneously for offloading functionality such
|
|
1262
|
+
* as image loading to separate threads (when supported by the browser)
|
|
1263
|
+
*
|
|
1264
|
+
* If not specified defaults to the number of logical processers available on the device, as reported by
|
|
1265
|
+
* `navigator.hardwareConcurrency`, with a maximum of 2. If `navigator.hardwareConcurrency` is
|
|
1266
|
+
* not supported the default value will be 2
|
|
1267
|
+
*/
|
|
1268
|
+
webWorkersLimit?: number
|
|
1269
|
+
/**
|
|
1270
|
+
* Background color of the canvas (also known as the clearColor)
|
|
1271
|
+
*
|
|
1272
|
+
* Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
|
|
1273
|
+
* or a color number in rgba order (`0xff0033ff`)
|
|
1274
|
+
*
|
|
1275
|
+
* Defauls to transparent (`0x00000000`)
|
|
1276
|
+
*
|
|
1277
|
+
*/
|
|
1278
|
+
canvasColor?: string,
|
|
1279
|
+
/**
|
|
1280
|
+
* Enable inspector
|
|
1281
|
+
*
|
|
1282
|
+
* Enables the inspector tool for debugging and inspecting the application, the node tree
|
|
1283
|
+
* will be replicated in the DOM and can be inspected using the browser's developer tools
|
|
1284
|
+
*
|
|
1285
|
+
* Defaults to `false`
|
|
1286
|
+
*/
|
|
1287
|
+
inspector?: boolean,
|
|
1288
|
+
/**
|
|
1289
|
+
* Add an extra margin to the viewport for earlier pre-loading of elements and components
|
|
1290
|
+
*
|
|
1291
|
+
* By default the Lightning renderer, only renders elements that are inside the defined viewport.
|
|
1292
|
+
* Everything outside of these bounds is removed from the render tree.
|
|
1293
|
+
*
|
|
1294
|
+
* With the viewportMargin you have the option to _virtually_ increase the viewport area,
|
|
1295
|
+
* to expedite the pre-loading of elements and / or delay the unloading of elements depending
|
|
1296
|
+
* on their position in the (virtual) viewport
|
|
1297
|
+
*
|
|
1298
|
+
* The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
|
|
1299
|
+
* or as a single number which is then applied to all 4 directions equally.
|
|
1300
|
+
*
|
|
1301
|
+
* Defaults to `0`
|
|
1302
|
+
*/
|
|
1303
|
+
viewportMargin?: number | [number, number, number, number],
|
|
1304
|
+
/**
|
|
1305
|
+
* Configures the gpu memory settings used by the renderer
|
|
1306
|
+
*/
|
|
1307
|
+
gpuMemory?: {
|
|
1349
1308
|
/**
|
|
1350
|
-
*
|
|
1309
|
+
* Maximum GPU memory threshold (in `mb`) after which
|
|
1310
|
+
* the renderer will immediately start cleaning up textures to free
|
|
1311
|
+
* up graphical memory
|
|
1351
1312
|
*
|
|
1352
|
-
* When
|
|
1353
|
-
* new Canvas element and inject it into the DOM
|
|
1354
|
-
*/
|
|
1355
|
-
canvas?: HTMLCanvasElement,
|
|
1356
|
-
/**
|
|
1357
|
-
* The maximum amount of time the renderer is allowed to process textures in a
|
|
1358
|
-
* single frame. If the processing time exceeds this limit, the renderer will
|
|
1359
|
-
* skip processing the remaining textures and continue rendering the frame.
|
|
1313
|
+
* When setting to `0`, texture memory management is disabled
|
|
1360
1314
|
*
|
|
1361
|
-
*
|
|
1315
|
+
* @default `200`
|
|
1362
1316
|
*/
|
|
1363
|
-
|
|
1317
|
+
max?: number,
|
|
1364
1318
|
/**
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1319
|
+
* Target threshold of GPU memory usage, defined as a fraction of
|
|
1320
|
+
* the max threshold. The renderer will attempt to keep memory
|
|
1321
|
+
* usage below this target by cleaning up non-renderable textures
|
|
1367
1322
|
*
|
|
1368
|
-
* @
|
|
1323
|
+
* @default `0.8`
|
|
1369
1324
|
*/
|
|
1370
|
-
|
|
1325
|
+
target?: number,
|
|
1371
1326
|
/**
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
* When set to `false` announcements via `this.$annoucer.speak()` will
|
|
1375
|
-
* be ignored. When set to `true` announcement will be spoken out via the
|
|
1376
|
-
* text to speech API
|
|
1377
|
-
*
|
|
1378
|
-
* Announcer can be enabled / disabled run time as well via:
|
|
1379
|
-
* - this.$announcer.enable()
|
|
1380
|
-
* - this.$announcer.disable()
|
|
1381
|
-
* - this.$announcer.toggle(true/false)
|
|
1327
|
+
* Interval at which regular texture cleanups occur (in `ms`)
|
|
1382
1328
|
*
|
|
1383
|
-
* @default
|
|
1329
|
+
* @default `5000`
|
|
1384
1330
|
*/
|
|
1385
|
-
|
|
1331
|
+
cleanupInterval?: number,
|
|
1386
1332
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1333
|
+
* Baseline GPU memory usage of the App (in `mb`), without rendering any
|
|
1334
|
+
* textures. This value will be used as a basis when calculating
|
|
1335
|
+
* the total memory usage towards the max and target memory
|
|
1336
|
+
* usage
|
|
1391
1337
|
*
|
|
1392
|
-
* @
|
|
1393
|
-
* ```js
|
|
1394
|
-
* announcerOptions: {
|
|
1395
|
-
* rate: 1.0,
|
|
1396
|
-
* pitch: 1.0,
|
|
1397
|
-
* lang: 'en-US',
|
|
1398
|
-
* volume: 1.0
|
|
1399
|
-
* }
|
|
1400
|
-
* ```
|
|
1338
|
+
* @default `25`
|
|
1401
1339
|
*/
|
|
1402
|
-
|
|
1340
|
+
baseline?: number,
|
|
1403
1341
|
/**
|
|
1404
|
-
*
|
|
1342
|
+
* Whether or not the max threshold should be considered
|
|
1343
|
+
* as a strict number that can not be exceeded in any way
|
|
1405
1344
|
*
|
|
1406
|
-
* When set to `true`,
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1345
|
+
* When set to `true`, new textures won't be created when the
|
|
1346
|
+
* max threshold has been reached, until agressive texture cleanup
|
|
1347
|
+
* has brought the memory back down
|
|
1409
1348
|
*
|
|
1410
1349
|
* @default false
|
|
1411
1350
|
*/
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1351
|
+
strict?: boolean,
|
|
1352
|
+
},
|
|
1353
|
+
/**
|
|
1354
|
+
* Defines which mode the renderer should operate in: `webgl` or `canvas`
|
|
1355
|
+
*
|
|
1356
|
+
* SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
|
|
1357
|
+
* be used. Also note that Canvas2d rendering doesnt support the use of shaders.
|
|
1358
|
+
*
|
|
1359
|
+
* Defaults to `webgl`
|
|
1360
|
+
*/
|
|
1361
|
+
renderMode?: RenderModes,
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* The time, in milliseconds, after which Blits considers a key press a _hold_ key press
|
|
1365
|
+
*
|
|
1366
|
+
* During a hold key press the focus delegation behaviour is different: when scrolling
|
|
1367
|
+
* through a long list, focus is not handed over to each individual list item, creating a
|
|
1368
|
+
* smoother experience
|
|
1369
|
+
*
|
|
1370
|
+
* Defaults to `50` (ms)
|
|
1371
|
+
*/
|
|
1372
|
+
holdTimeout?: number,
|
|
1373
|
+
/**
|
|
1374
|
+
* Input throttle time in milliseconds to prevent rapid successive inputs
|
|
1375
|
+
*
|
|
1376
|
+
* Within the throttle window, only one input will be processed immediately.
|
|
1377
|
+
* Subsequent inputs _of the same key_ are ignored until the scheduled input is processed.
|
|
1378
|
+
*
|
|
1379
|
+
* Pressing a different key will be processed immediately.
|
|
1380
|
+
*
|
|
1381
|
+
* Set to `0` to disable input throttling.
|
|
1382
|
+
*
|
|
1383
|
+
* Defaults to `0` (disabled)
|
|
1384
|
+
*/
|
|
1385
|
+
inputThrottle?: number,
|
|
1386
|
+
/**
|
|
1387
|
+
* Custom canvas object used to render the App to.
|
|
1388
|
+
*
|
|
1389
|
+
* When not provided, the Lightning renderer will create a
|
|
1390
|
+
* new Canvas element and inject it into the DOM
|
|
1391
|
+
*/
|
|
1392
|
+
canvas?: HTMLCanvasElement,
|
|
1393
|
+
/**
|
|
1394
|
+
* The maximum amount of time the renderer is allowed to process textures in a
|
|
1395
|
+
* single frame. If the processing time exceeds this limit, the renderer will
|
|
1396
|
+
* skip processing the remaining textures and continue rendering the frame.
|
|
1397
|
+
*
|
|
1398
|
+
* Defaults to `10`
|
|
1399
|
+
*/
|
|
1400
|
+
textureProcessingTimeLimit?: number,
|
|
1401
|
+
/**
|
|
1402
|
+
* Advanced renderer settings to override Blits launch settings, or configure
|
|
1403
|
+
* settings that are not officially exposed in Blits yet
|
|
1404
|
+
*
|
|
1405
|
+
* @important if you dont know what you're doing here, you probably shouldn't be doing it!
|
|
1406
|
+
*/
|
|
1407
|
+
advanced?: Partial<RendererMainSettings>,
|
|
1408
|
+
/**
|
|
1409
|
+
* Whether or not the announcer should be activated on initialization
|
|
1410
|
+
*
|
|
1411
|
+
* When set to `false` announcements via `this.$annoucer.speak()` will
|
|
1412
|
+
* be ignored. When set to `true` announcement will be spoken out via the
|
|
1413
|
+
* text to speech API
|
|
1414
|
+
*
|
|
1415
|
+
* Announcer can be enabled / disabled run time as well via:
|
|
1416
|
+
* - this.$announcer.enable()
|
|
1417
|
+
* - this.$announcer.disable()
|
|
1418
|
+
* - this.$announcer.toggle(true/false)
|
|
1419
|
+
*
|
|
1420
|
+
* @default false
|
|
1421
|
+
*/
|
|
1422
|
+
announcer?: boolean,
|
|
1423
|
+
/**
|
|
1424
|
+
* Global default utterance options for the announcer.
|
|
1425
|
+
*
|
|
1426
|
+
* These options will be applied to all announcements unless overridden
|
|
1427
|
+
* by per-call options passed to `speak()`, `polite()`, or `assertive()`.
|
|
1428
|
+
*
|
|
1429
|
+
* @example
|
|
1430
|
+
* ```js
|
|
1431
|
+
* announcerOptions: {
|
|
1432
|
+
* rate: 1.0,
|
|
1433
|
+
* pitch: 1.0,
|
|
1434
|
+
* lang: 'en-US',
|
|
1435
|
+
* volume: 1.0
|
|
1436
|
+
* }
|
|
1437
|
+
* ```
|
|
1438
|
+
*/
|
|
1439
|
+
announcerOptions?: AnnouncerUtteranceOptions,
|
|
1440
|
+
/**
|
|
1441
|
+
* Enable mouse support (hover and click-to-focus).
|
|
1442
|
+
*
|
|
1443
|
+
* When set to `true`, pointer movement over the canvas updates hover state on components
|
|
1444
|
+
* and click dispatches focus and Enter key input to the component under the cursor.
|
|
1445
|
+
* When set to `false`, no mouse or pointer listeners are registered.
|
|
1446
|
+
*
|
|
1447
|
+
* @default false
|
|
1448
|
+
*/
|
|
1449
|
+
enableMouse?: boolean,
|
|
1450
|
+
/**
|
|
1451
|
+
* Minimum time in milliseconds between two pointer moves that are processed for hover.
|
|
1452
|
+
*
|
|
1453
|
+
* Moves arriving sooner are dropped, not delayed.
|
|
1454
|
+
*
|
|
1455
|
+
* @default 100
|
|
1456
|
+
*/
|
|
1457
|
+
mouseMoveThrottle?: number,
|
|
1438
1458
|
/**
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1459
|
+
* Maximum FPS at which the App will be rendered
|
|
1460
|
+
*
|
|
1461
|
+
* Lowering the maximum FPS value can improve the overall experience on lower end devices.
|
|
1462
|
+
* Targetting a lower FPS may gives the CPU more time to construct each frame leading to a smoother rendering.
|
|
1463
|
+
*
|
|
1464
|
+
* Defaults to `0` which means no maximum
|
|
1465
|
+
*/
|
|
1466
|
+
maxFPS?: number,
|
|
1467
|
+
/**
|
|
1468
|
+
* Custom platform layer to be used by the App.
|
|
1469
|
+
*
|
|
1470
|
+
* Allows replacing platform capabilities such as input targets, storage,
|
|
1471
|
+
* keyboard event constructors, and speech APIs.
|
|
1472
|
+
* A callback receives Blits' browser defaults and should return the platform overrides.
|
|
1473
|
+
*/
|
|
1474
|
+
platform?: (defaults: Platform) => Partial<Platform>,
|
|
1475
|
+
/**
|
|
1476
|
+
* Custom platform layer to be used by the renderer.
|
|
1477
|
+
*
|
|
1478
|
+
* For renderer-specific platform implementations. Passing a renderer platform
|
|
1479
|
+
* through `platform` is deprecated.
|
|
1480
|
+
*/
|
|
1481
|
+
rendererPlatform?: RendererMainSettings['platform']
|
|
1445
1482
|
|
|
1446
|
-
|
|
1483
|
+
}
|
|
1447
1484
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1485
|
+
interface State {
|
|
1486
|
+
[key: string]: any
|
|
1487
|
+
}
|
|
1451
1488
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1489
|
+
interface Methods {
|
|
1490
|
+
[key: string]: any
|
|
1491
|
+
}
|
|
1455
1492
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1493
|
+
interface Watch {
|
|
1494
|
+
[key: string]: any
|
|
1495
|
+
}
|
|
1459
1496
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1497
|
+
interface Computed {
|
|
1498
|
+
[key: string]: () => any
|
|
1499
|
+
}
|
|
1463
1500
|
|
|
1464
1501
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1502
|
+
interface Plugin {
|
|
1503
|
+
/**
|
|
1504
|
+
* Name of the plugin. The plugin will be accessible on each Component's
|
|
1505
|
+
* `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
|
|
1506
|
+
*/
|
|
1507
|
+
name: string,
|
|
1508
|
+
/**
|
|
1509
|
+
* Singleton function that will be used to instantiate the plugin.
|
|
1510
|
+
* Should do all necessary setup and ideally return an object with
|
|
1511
|
+
* properties or methods that can be used in the App
|
|
1512
|
+
*/
|
|
1513
|
+
plugin: (options?: any) => any
|
|
1514
|
+
}
|
|
1478
1515
|
|
|
1479
1516
|
|
|
1517
|
+
export interface ProfilerEntry {
|
|
1480
1518
|
/**
|
|
1481
|
-
*
|
|
1519
|
+
* Number of times the measurement was recorded
|
|
1482
1520
|
*/
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
|
|
1505
|
-
/**
|
|
1506
|
-
* Blits Launch
|
|
1507
|
-
*/
|
|
1508
|
-
Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
|
|
1509
|
-
/**
|
|
1510
|
-
* Blits Plugin
|
|
1511
|
-
*
|
|
1512
|
-
* @param plugin
|
|
1513
|
-
* Plugin object or singleton function that will be used to instantiate the
|
|
1514
|
-
* plugin. Should do all necessary setup and ideally return an object with
|
|
1515
|
-
* properties or methods that can be used in the App
|
|
1516
|
-
*
|
|
1517
|
-
* @param nameOrOptions
|
|
1518
|
-
* Name of the plugin or options object, to be passed into the plugin instantiation.
|
|
1519
|
-
*
|
|
1520
|
-
* When passing a string, the value will be used as **name** of the plugin. The plugin
|
|
1521
|
-
* will be accessible on each Component's `this` scope under this name, prefixed with a `$`
|
|
1522
|
-
* (i.e. myplugin => `this.$myplugin`)
|
|
1523
|
-
*
|
|
1524
|
-
* Passing a name is **required** when `plugin` argument is a singleton function
|
|
1525
|
-
*
|
|
1526
|
-
* When passing an object, the value will be considered to be an `options` object.
|
|
1527
|
-
* The options object will be passed into the plugin instantiation method. Can
|
|
1528
|
-
* be used to set default values
|
|
1529
|
-
*
|
|
1530
|
-
* @param options
|
|
1531
|
-
* Object with options to be passed into the plugin instantiation method.
|
|
1532
|
-
* Can be used to set default values
|
|
1533
|
-
*/
|
|
1534
|
-
Plugin(plugin: Plugin | ((options?: any) => any), nameOrOptions?: string | object , options?: object) : void
|
|
1535
|
-
}
|
|
1521
|
+
calls: number,
|
|
1522
|
+
/**
|
|
1523
|
+
* Total time spent, in milliseconds
|
|
1524
|
+
*/
|
|
1525
|
+
totalMs: number,
|
|
1526
|
+
/**
|
|
1527
|
+
* Slowest single measurement, in milliseconds
|
|
1528
|
+
*/
|
|
1529
|
+
maxMs: number,
|
|
1530
|
+
/**
|
|
1531
|
+
* Average time per call, in milliseconds
|
|
1532
|
+
*/
|
|
1533
|
+
averageMs: number
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
export interface ProfilerFrameSummary {
|
|
1537
|
+
medianMs: number,
|
|
1538
|
+
p95Ms: number,
|
|
1539
|
+
p99Ms: number,
|
|
1540
|
+
maxMs: number
|
|
1541
|
+
}
|
|
1536
1542
|
|
|
1537
|
-
|
|
1543
|
+
export interface ProfilerFrameLabel {
|
|
1544
|
+
calls: number,
|
|
1545
|
+
totalMs: number
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
export interface ProfilerFrameSnapshot {
|
|
1549
|
+
frameCount: number,
|
|
1550
|
+
retainedFrameLimit: number,
|
|
1551
|
+
frameInterval: ProfilerFrameSummary,
|
|
1552
|
+
instrumentedTime: ProfilerFrameSummary,
|
|
1553
|
+
slowFramePercent: number,
|
|
1554
|
+
slowestFrames: Array<{
|
|
1555
|
+
intervalMs: number,
|
|
1556
|
+
instrumentedMs: number,
|
|
1557
|
+
labels: Record<string, ProfilerFrameLabel>
|
|
1558
|
+
}>,
|
|
1559
|
+
labels: Record<string, ProfilerFrameLabel & {
|
|
1560
|
+
callsPerFrame: number,
|
|
1561
|
+
averageMsPerFrame: number
|
|
1562
|
+
}>
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
export interface ProfilerSnapshot {
|
|
1566
|
+
measurements: Record<string, ProfilerEntry>,
|
|
1567
|
+
frames: ProfilerFrameSnapshot
|
|
1568
|
+
}
|
|
1538
1569
|
|
|
1539
|
-
|
|
1570
|
+
export interface Profiler {
|
|
1571
|
+
/**
|
|
1572
|
+
* Marks the start of a measurement
|
|
1573
|
+
*/
|
|
1574
|
+
mark(name: string): void,
|
|
1575
|
+
/**
|
|
1576
|
+
* Ends the most recent measurement started with the same name
|
|
1577
|
+
*/
|
|
1578
|
+
markEnd(name: string): void,
|
|
1579
|
+
/**
|
|
1580
|
+
* Clears previously collected measurements and starts recording
|
|
1581
|
+
*/
|
|
1582
|
+
start(options?: { frames?: boolean, maxFrames?: number, targetFps?: number }): void,
|
|
1583
|
+
/**
|
|
1584
|
+
* Stops recording and returns the collected measurements
|
|
1585
|
+
*/
|
|
1586
|
+
stop(): ProfilerSnapshot,
|
|
1587
|
+
/**
|
|
1588
|
+
* Clears all collected measurements, without changing the enabled state
|
|
1589
|
+
*/
|
|
1590
|
+
reset(): void,
|
|
1591
|
+
/**
|
|
1592
|
+
* Returns the measurements collected so far
|
|
1593
|
+
*/
|
|
1594
|
+
snapshot(): ProfilerSnapshot,
|
|
1595
|
+
/**
|
|
1596
|
+
* Returns frame-oriented results collected by default or with start({ frames: true })
|
|
1597
|
+
*/
|
|
1598
|
+
frameSnapshot(): ProfilerFrameSnapshot,
|
|
1599
|
+
/**
|
|
1600
|
+
* Logs marker and frame results as console tables and returns the combined snapshot
|
|
1601
|
+
*/
|
|
1602
|
+
report(): ProfilerSnapshot,
|
|
1603
|
+
/**
|
|
1604
|
+
* Whether the profiler is currently recording
|
|
1605
|
+
*/
|
|
1606
|
+
readonly enabled: boolean
|
|
1607
|
+
}
|
|
1540
1608
|
|
|
1609
|
+
/**
|
|
1610
|
+
* Blits App Framework
|
|
1611
|
+
*/
|
|
1612
|
+
export interface Blits {
|
|
1613
|
+
/**
|
|
1614
|
+
* Blits Application
|
|
1615
|
+
* @param {ApplicationConfig} config - Application Configuration object
|
|
1616
|
+
*/
|
|
1617
|
+
Application<
|
|
1618
|
+
P extends Props,
|
|
1619
|
+
S extends State,
|
|
1620
|
+
M extends Methods,
|
|
1621
|
+
C extends Computed = Record<never, never>,
|
|
1622
|
+
W extends Watch>(config: ApplicationConfig<P, S, M, C, W>) : ComponentFactory
|
|
1623
|
+
/**
|
|
1624
|
+
* Blits Component
|
|
1625
|
+
* @param {string} name - The name of the Component
|
|
1626
|
+
* @param {ComponentConfig} config - Component Configuration object
|
|
1627
|
+
*/
|
|
1628
|
+
Component<
|
|
1629
|
+
P extends Props,
|
|
1630
|
+
S extends State,
|
|
1631
|
+
M extends Methods,
|
|
1632
|
+
C extends Computed = Record<never, never>,
|
|
1633
|
+
W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
|
|
1634
|
+
/**
|
|
1635
|
+
* Blits Launch
|
|
1636
|
+
*/
|
|
1637
|
+
Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
|
|
1638
|
+
/**
|
|
1639
|
+
* Blits Plugin
|
|
1640
|
+
*
|
|
1641
|
+
* @param plugin
|
|
1642
|
+
* Plugin object or singleton function that will be used to instantiate the
|
|
1643
|
+
* plugin. Should do all necessary setup and ideally return an object with
|
|
1644
|
+
* properties or methods that can be used in the App
|
|
1645
|
+
*
|
|
1646
|
+
* @param nameOrOptions
|
|
1647
|
+
* Name of the plugin or options object, to be passed into the plugin instantiation.
|
|
1648
|
+
*
|
|
1649
|
+
* When passing a string, the value will be used as **name** of the plugin. The plugin
|
|
1650
|
+
* will be accessible on each Component's `this` scope under this name, prefixed with a `$`
|
|
1651
|
+
* (i.e. myplugin => `this.$myplugin`)
|
|
1652
|
+
*
|
|
1653
|
+
* Passing a name is **required** when `plugin` argument is a singleton function
|
|
1654
|
+
*
|
|
1655
|
+
* When passing an object, the value will be considered to be an `options` object.
|
|
1656
|
+
* The options object will be passed into the plugin instantiation method. Can
|
|
1657
|
+
* be used to set default values
|
|
1658
|
+
*
|
|
1659
|
+
* @param options
|
|
1660
|
+
* Object with options to be passed into the plugin instantiation method.
|
|
1661
|
+
* Can be used to set default values
|
|
1662
|
+
*/
|
|
1663
|
+
Plugin(plugin: Plugin | ((options?: any) => any), nameOrOptions?: string | object , options?: object) : void
|
|
1541
1664
|
}
|
|
1665
|
+
|
|
1666
|
+
const Blits: Blits;
|
|
1667
|
+
|
|
1668
|
+
export default Blits;
|