@lightningjs/blits 1.30.2 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +1029 -1019
  2. package/LICENSE +202 -202
  3. package/NOTICE +12 -12
  4. package/README.md +33 -33
  5. package/bin/index.js +8 -8
  6. package/blits.d.ts +6 -6
  7. package/index.d.ts +1099 -1099
  8. package/index.js +28 -28
  9. package/package.json +57 -56
  10. package/public/assets/fps_sprite.base64.js +1 -1
  11. package/scripts/postpublish.js +59 -59
  12. package/scripts/prepublishOnly.js +84 -84
  13. package/scripts/prepush.js +78 -78
  14. package/src/announcer/announcer.js +162 -162
  15. package/src/announcer/speechSynthesis.js +107 -107
  16. package/src/application.js +100 -100
  17. package/src/component/base/announcer.js +27 -27
  18. package/src/component/base/events.js +69 -69
  19. package/src/component/base/index.js +33 -33
  20. package/src/component/base/methods.js +244 -244
  21. package/src/component/base/router.js +41 -41
  22. package/src/component/base/timeouts_intervals.js +99 -99
  23. package/src/component/base/utils.js +72 -72
  24. package/src/component/setup/computed.js +48 -48
  25. package/src/component/setup/index.js +62 -62
  26. package/src/component/setup/input.js +30 -30
  27. package/src/component/setup/methods.js +37 -37
  28. package/src/component/setup/props.js +62 -62
  29. package/src/component/setup/routes.js +42 -42
  30. package/src/component/setup/state.js +59 -59
  31. package/src/component/setup/watch.js +35 -35
  32. package/src/component.js +437 -437
  33. package/src/components/Circle.js +73 -73
  34. package/src/components/FPScounter.js +1510 -1510
  35. package/src/components/RouterView.js +81 -81
  36. package/src/components/Sprite.js +94 -94
  37. package/src/components/index.js +28 -28
  38. package/src/constants.js +21 -21
  39. package/src/engine.js +1 -1
  40. package/src/engines/L3/element.js +744 -744
  41. package/src/engines/L3/fontLoader.js +38 -38
  42. package/src/engines/L3/index.js +7 -7
  43. package/src/engines/L3/launch.js +123 -123
  44. package/src/engines/L3/shaderLoader.js +12 -12
  45. package/src/engines/index.js +1 -1
  46. package/src/focus.js +90 -90
  47. package/src/helpers/deepEqualArray.js +50 -50
  48. package/src/helpers/fetchJson.js +34 -34
  49. package/src/helpers/sequence.js +26 -26
  50. package/src/launch.js +123 -123
  51. package/src/lib/blitsfileconverter/blitsfileconverter.js +52 -52
  52. package/src/lib/codegenerator/generator.js +788 -788
  53. package/src/lib/colors/colors.js +92 -92
  54. package/src/lib/colors/htmlColors.js +168 -168
  55. package/src/lib/componentId.js +49 -49
  56. package/src/lib/eventListeners.js +123 -123
  57. package/src/lib/hooks.js +59 -59
  58. package/src/lib/lifecycle.js +85 -85
  59. package/src/lib/log.js +117 -117
  60. package/src/lib/precompiler/precompiler.js +73 -73
  61. package/src/lib/reactivity/effect.js +93 -93
  62. package/src/lib/reactivity/reactive.js +208 -208
  63. package/src/lib/reactivityguard/computedprops.js +218 -218
  64. package/src/lib/symbols.js +108 -108
  65. package/src/lib/templateparser/parser.js +386 -386
  66. package/src/lib/utils.js +27 -27
  67. package/src/plugin.js +27 -27
  68. package/src/plugins/appstate.js +26 -26
  69. package/src/plugins/index.js +20 -20
  70. package/src/plugins/language.js +152 -152
  71. package/src/plugins/log.js +25 -25
  72. package/src/plugins/theme.js +94 -94
  73. package/src/router/router.js +516 -514
  74. package/src/router/transitions/fadeIn.js +27 -27
  75. package/src/router/transitions/fadeInOut.js +33 -33
  76. package/src/router/transitions/index.js +21 -21
  77. package/src/router/transitions/slideIn.js +28 -28
  78. package/src/router/transitions/slideInOut.js +33 -33
  79. package/src/settings.js +40 -40
  80. package/vite/blitsFileConverter.js +67 -67
  81. package/vite/index.js +28 -28
  82. package/vite/msdfGenerator.js +269 -269
  83. package/vite/preCompiler.js +47 -42
  84. package/vite/reactivityGuard.js +45 -45
  85. package/vscode/data/template-attributes.json +589 -589
  86. package/.editorconfig +0 -7
  87. package/.eslintignore +0 -1
  88. package/.eslintrc.cjs +0 -65
  89. package/.github/workflows/comment-lint-results.yml +0 -125
  90. package/.github/workflows/comment-test-results.yml +0 -109
  91. package/.github/workflows/deploy-docs.yml +0 -27
  92. package/.github/workflows/run-blits-tests.yml +0 -142
  93. package/.github/workflows/run-lint.yml +0 -128
  94. package/.husky/pre-commit +0 -1
  95. package/.husky/pre-push +0 -1
  96. package/.vscode/extensions.json +0 -7
  97. package/.vscode/settings.json +0 -9
  98. package/COPYING +0 -1
  99. package/banner.png +0 -0
  100. package/docs/.nojekyll +0 -0
  101. package/docs/README.md +0 -19
  102. package/docs/_sidebar.md +0 -37
  103. package/docs/built-in/directives.md +0 -50
  104. package/docs/built-in/for-loop.md +0 -204
  105. package/docs/built-in/layout.md +0 -168
  106. package/docs/components/component_state.md +0 -90
  107. package/docs/components/computed_properties.md +0 -45
  108. package/docs/components/lifecycle_events.md +0 -42
  109. package/docs/components/methods.md +0 -45
  110. package/docs/components/props.md +0 -56
  111. package/docs/components/user_input.md +0 -186
  112. package/docs/components/utility_methods.md +0 -320
  113. package/docs/components/watchers.md +0 -34
  114. package/docs/essentials/application_root.md +0 -19
  115. package/docs/essentials/components.md +0 -68
  116. package/docs/essentials/displaying_images.md +0 -67
  117. package/docs/essentials/displaying_text.md +0 -135
  118. package/docs/essentials/element_attributes.md +0 -195
  119. package/docs/essentials/settings.md +0 -117
  120. package/docs/essentials/template_syntax.md +0 -83
  121. package/docs/getting_started/file_structure.md +0 -58
  122. package/docs/getting_started/getting_started.md +0 -45
  123. package/docs/getting_started/intro.md +0 -20
  124. package/docs/index.html +0 -47
  125. package/docs/performance/lazy-loading.md +0 -161
  126. package/docs/plugins/global_app_state.md +0 -98
  127. package/docs/plugins/language.md +0 -172
  128. package/docs/plugins/text-to-speech-announcer.md +0 -120
  129. package/docs/plugins/theme.md +0 -176
  130. package/docs/router/basics.md +0 -175
  131. package/docs/router/hooks.md +0 -70
  132. package/docs/router/transitions.md +0 -146
  133. package/docs/sidebar.json +0 -171
  134. package/docs/transitions_animations/transitions.md +0 -150
  135. package/jsconfig.json +0 -12
  136. package/src/component/setup/props.test.js +0 -238
  137. package/src/component.test.js +0 -388
  138. package/src/components/Circle.orig.js +0 -31
  139. package/src/components/FPScounter.orig.js +0 -121
  140. package/src/components/RouterView.orig.js +0 -54
  141. package/src/components/Sprite.orig.js +0 -58
  142. package/src/components/index.orig.js +0 -28
  143. package/src/engines/L3/element.test.js +0 -579
  144. package/src/helpers/deepEqualArray.test.js +0 -127
  145. package/src/lib/codegenerator/generator.test.js +0 -3801
  146. package/src/lib/colors/colors.test.js +0 -290
  147. package/src/lib/componentId.test.js +0 -84
  148. package/src/lib/eventListeners.test.js +0 -236
  149. package/src/lib/reactivity/effect.test.js +0 -35
  150. package/src/lib/reactivity/reactive.test.js +0 -27
  151. package/src/lib/templateparser/parser.test.js +0 -1411
  152. package/src/router/router.test.js +0 -473
package/index.d.ts CHANGED
@@ -1,1099 +1,1099 @@
1
- /*
2
- * Copyright 2023 Comcast Cable Communications Management, LLC
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- *
15
- * SPDX-License-Identifier: Apache-2.0
16
- */
17
-
18
- // blits file type reference
19
- /// <reference path="./blits.d.ts" />
20
-
21
- import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader, type RendererMainSettings} from '@lightningjs/renderer'
22
-
23
- declare module '@lightningjs/blits' {
24
-
25
-
26
- export interface AnnouncerUtterance extends Promise<T> {
27
- /**
28
- * Removes a specific message from the announcement queue,
29
- * to make sure it isn't spoke out.
30
- *
31
- * Does not interupt the message when it's already being announced.
32
- */
33
- cancel()
34
- /**
35
- * Interrupts a specific message as it is being spoken out by the Text to Speech
36
- * engine.
37
- */
38
- stop()
39
- }
40
-
41
- export interface Announcer {
42
- /**
43
- * Instruct the Announcer to speak a message. Will add the message
44
- * to the end of announcement queue by default
45
- *
46
- * When a message is added with politeness set to `assertive` the message
47
- * will be added to the beginning of the queue
48
- *
49
- */
50
- speak(message: string | number, politeness?: 'off' | 'polite' | 'assertive'): AnnouncerUtterance;
51
- /**
52
- * Instruct the Announcer to add a pause of a certain duration (in ms). Will add this pause
53
- * to the end of announcement queue
54
- *
55
- */
56
- pause(delay: number): AnnouncerUtterance;
57
- /**
58
- * Interupts and instantly stops any running text to speech utterance
59
- *
60
- */
61
- stop(): void;
62
- /**
63
- * Clears out the announcement queue of messages.
64
- */
65
- clear(): void;
66
- /**
67
- * Enables the announcer.
68
- */
69
- enable(): void;
70
- /**
71
- * Disables the announcer. Any messages passed in the announcer.speak() message
72
- * will not be added to the queue
73
- */
74
- disable(): void;
75
- /**
76
- * Toggles the announcer based on the passed toggle value (Boolean)
77
- */
78
- toggle(toggle: Boolean): void;
79
- }
80
-
81
-
82
- export interface Hooks {
83
- /**
84
- * Fires when the Component is being instantiated
85
- * At this moment child elements will not be available yet
86
- */
87
- init?: () => void;
88
- /**
89
- * Fires when the Component is fully initialized and ready for interaction.
90
- */
91
- ready?: () => void;
92
- /**
93
- * Triggers when the Component receives focus.
94
- *
95
- * This event can fire multiple times during the component's lifecycle
96
- */
97
- focus?: () => void;
98
- /**
99
- * Triggers when the Component loses focus.
100
- *
101
- * This event can fire multiple times during the component's lifecycle
102
- */
103
- unfocus?: () => void;
104
- /**
105
- * Fires when the Component is being destroyed and removed.
106
- */
107
- destroy?: () => void;
108
- /**
109
- * Fires upon each frame start (allowing you to tap directly into the renderloop)
110
- *
111
- * Note: This hook will fire continuously, multiple times per second!
112
- */
113
- frameTick?: () => void;
114
- /**
115
- * Fires when the component enters the viewport _margin_ and is attached to the render tree
116
- *
117
- * This event can fire multiple times during the component's lifecycle
118
- */
119
- attach?: () => void;
120
- /**
121
- * Fires when the component leaves the viewport _margin_ and is detached from the render tree
122
- *
123
- * This event can fire multiple times during the component's lifecycle
124
- */
125
- detach?: () => void;
126
- /**
127
- * Fires when the component enters the visible viewport
128
- *
129
- * This event can fire multiple times during the component's lifecycle
130
- */
131
- enter?: () => void;
132
- /**
133
- * Fires when the component leaves the visible viewport
134
- *
135
- * This event can fire multiple times during the component's lifecycle
136
- */
137
- exit?: () => void;
138
- }
139
-
140
- export interface Input {
141
- [key: string]: (event: KeyboardEvent) => void | undefined | unknown,
142
- /**
143
- * Catch all input function
144
- *
145
- * Will be invoked when there is no dedicated function for a certain key
146
- */
147
- // @ts-ignore
148
- any?: (event: KeyboardEvent) => void,
149
- /**
150
- * Intercept key presses on the root Application component before being handled
151
- * by the currently focused component.
152
- *
153
- * Only when a KeyboardEvent (the original one, or a modified one) is returned from the
154
- * intercept function, the Input event is passed on to the Component with focus.
155
- *
156
- * The intercept function can be asynchronous.
157
- *
158
- * Note: the intercept input handler is only available on the Root App component (i.e. Blits.Application)
159
- */
160
- intercept?: (event: KeyboardEvent) => KeyboardEvent | Promise<KeyboardEvent | any> | any
161
- }
162
-
163
- export interface Log {
164
- /**
165
- * Log an info message
166
- */
167
- info(...args): typeof console.info
168
- /**
169
- * Log an error message
170
- */
171
- error(...args): typeof console.error
172
- /**
173
- * Log a warning
174
- */
175
- warn(...args): typeof console.warn
176
- /**
177
- * Log a debug message
178
- */
179
- debug(...args): typeof console.debug
180
- }
181
-
182
-
183
-
184
- export interface RouteData {
185
- [key: string]: any
186
- }
187
-
188
- // todo: specify valid route options
189
- export interface RouteOptions {
190
- [key: string]: any
191
- }
192
-
193
- export interface Router {
194
- /**
195
- * Navigate to a different location
196
- *
197
- * @param {string}
198
- */
199
- to(location: string, data?: RouteData, options?: RouteOptions): void;
200
-
201
- /**
202
- * Navigate to the previous location
203
- */
204
- back(): boolean;
205
-
206
- /**
207
- * Get the current route read-only
208
- */
209
- readonly currentRoute: Route;
210
-
211
- /**
212
- * Get the list of all routes
213
- */
214
- readonly routes: Route[];
215
-
216
- /**
217
- * Get navigating state
218
- */
219
- readonly navigating: boolean;
220
-
221
- /**
222
- * Reactive router state
223
- */
224
- state: {
225
- /**
226
- * Path of the current route
227
- *
228
- * Can be used in:
229
- * - a template as `$$router.state.path`
230
- * - inside business logic as `this.$router.state.path`
231
- * - as a watcher as `$router.state.path(v) {}`
232
- */
233
- readonly path: string
234
- /**
235
- * Whether or not the router is currently in the process of navigating
236
- * between pages
237
- *
238
- * Can be used in:
239
- * - a template as `$$router.state.navihating`
240
- * - inside business logic as `this.$router.state.navigating`
241
- * - as a watcher as `$router.state.navigating(v) {}`
242
- */
243
- readonly navigating: boolean
244
- }
245
- }
246
-
247
- export type ComponentBase = {
248
- /**
249
- * Indicates whether the component currently has focus
250
- *
251
- * @returns Boolean
252
- */
253
- hasFocus: boolean,
254
-
255
- /**
256
- * Listen to events emitted by other components
257
- */
258
- $listen: {
259
- (event: string, callback: (args: any) => void, priority?: number): void;
260
- }
261
- /**
262
- * Emit events that other components can listen to
263
- * @param name - name of the event to be emitted
264
- * @param data - optional data to be passed along
265
- */
266
- $emit(name: string, data?: any): void;
267
-
268
- /**
269
- * Set a timeout that is automatically cleaned upon component destroy
270
- */
271
- $setTimeout: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setTimeout>
272
-
273
- /**
274
- * Clear a timeout
275
- */
276
- $clearTimeout: (id: ReturnType<typeof setTimeout>) => void
277
-
278
- /**
279
- * Set an interval that is automatically cleaned upon component destroy
280
- */
281
- $setInterval: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setInterval>
282
-
283
- /**
284
- * Clear a interval
285
- */
286
- $clearInterval: (id: ReturnType<typeof setInterval>) => void
287
-
288
- /**
289
- * Log to the console with prettier output and configurable debug levels in Settings
290
- */
291
- $log: Log
292
-
293
- /**
294
- * Set focus to the Component, optionally pass a KeyboardEvent for instant event bubbling
295
- */
296
- $focus: (event?: KeyboardEvent) => void
297
- /**
298
- * @deprecated
299
- * Deprecated: use `this.$focus()` instead
300
- */
301
- focus: (event?: KeyboardEvent) => void
302
-
303
- /**
304
- * Select a child Element or Component by ref
305
- *
306
- * Elements and Components in the template can have an optional ref argument.
307
- * Returns an Element Instance or Component Instance.
308
- * Useful for passing on the focus to a Child component.
309
- *
310
- * @example
311
- * ```js
312
- * const menu = this.$select('Menu')
313
- * if(menu) {
314
- * menu.$focus()
315
- * }
316
- * ```
317
- */
318
- $select: (ref: string) => ComponentBase
319
-
320
- /**
321
- * @deprecated
322
- * Deprecated: use `this.$select()` instead
323
- */
324
- select: (ref: string) => ComponentBase
325
-
326
- /**
327
- * Announcer methods for screen reader support
328
- */
329
- $announcer: Announcer
330
-
331
- /**
332
- * Triggers a forced update on state variables.
333
- */
334
- $trigger: (key: string) => void
335
- /**
336
- * @deprecated
337
- *
338
- * Triggers a forced update on state variables.
339
- * Deprecated: use `this.$trigger()` instead
340
- */
341
- trigger: (key: string) => void
342
- /**
343
- * Router instance
344
- */
345
- $router: Router
346
- /**
347
- * Dynamically set the size of a component holder node
348
- */
349
- $size: (dimensions: {
350
- /**
351
- * Component width
352
- */
353
- w: number,
354
- /**
355
- * Component height
356
- */
357
- h: number
358
- }) => void
359
- }
360
-
361
- /**
362
- * Prop object
363
- */
364
- export type PropObject = {
365
- /**
366
- * Name of the prop
367
- */
368
- key: string,
369
- /**
370
- * Whether the prop is required to be passed
371
- */
372
- required?: boolean,
373
- /**
374
- * Default value for the prop when omited
375
- */
376
- default?: any,
377
- /**
378
- * Cast the value of the prop
379
- *
380
- * @example
381
- * ```js
382
- * {
383
- * cast: Number, // casts to a number
384
- * cast: (v) => v.toUpperCase() // casts to uppercase
385
- * }
386
- * ```
387
- */
388
- cast?: () => any
389
- };
390
-
391
- // Props Array
392
- export type Props = (string | PropObject)[];
393
-
394
- // Extract the prop names from the props array
395
- type ExtractPropNames<P extends Props> = {
396
- readonly [K in P[number] as K extends string ? K : K extends { key: infer Key } ? Key : never]: any;
397
- };
398
-
399
- // Update the PropsDefinition to handle props as strings or objects
400
- export type PropsDefinition<P extends Props> = ExtractPropNames<P>;
401
-
402
- export type ComponentContext<P extends Props, S, M, C> = ThisType<PropsDefinition<P> & S & M & C & ComponentBase>
403
-
404
- export interface ComponentConfig<P extends Props, S, M, C, W> {
405
- components?: {
406
- [key: string]: ComponentFactory,
407
- },
408
- /**
409
- * XML-based template string of the Component
410
- *
411
- * @example
412
- * ```xml
413
- * <Element :x="$x" w="400" h="1080" color="#64748b">
414
- * <Element x="50" y="40">
415
- * <Button color="#e4e4e7" />
416
- * <Button color="#e4e4e7" y="100" />
417
- * <Button color="#e4e4e7" y="200" />
418
- * <Button color="#e4e4e7" y="300" />
419
- * </Element>
420
- * </Element>
421
- * ```
422
- */
423
- template?: String,
424
- /**
425
- * Allowed props to be passed into the Component by the parent
426
- *
427
- * Can be a simple array with `prop` keys as strings.
428
- * Alternatively objects can be used to specify `required` props and `default` values
429
- *
430
- * @example
431
- * ```js
432
- * props: ['index', {
433
- * key: 'alpha',
434
- * required: true
435
- * }, {
436
- * key: 'color',
437
- * default: 'red'
438
- * }]
439
- * ```
440
- */
441
- props?: P;
442
- /**
443
- * Reactive internal state of the Component instance
444
- *
445
- * Should return an object (literal) with key value pairs.
446
- * Can contain nested objects, but beware that too deep nesting can have
447
- * a negative impact on performance
448
- *
449
- * @example
450
- * ```js
451
- * state() {
452
- * return {
453
- * items: [],
454
- * color: 'red',
455
- * alpha: 0.1
456
- * }
457
- * }
458
- * ```
459
- */
460
- state?: (this: PropsDefinition<P>) => S;
461
- /**
462
- * Methods for abstracting more complex business logic into separate function
463
- */
464
- methods?: M & ComponentContext<P, S, M, C>
465
- /**
466
- * Hooking into Lifecycle events
467
- */
468
- hooks?: Hooks & ComponentContext<P, S, M, C>
469
- /**
470
- * Tapping into user input
471
- */
472
- input?: Input & ComponentContext<P, S, M, C>
473
- /**
474
- * Computed properties
475
- */
476
- computed?: C & ComponentContext<P, S, M, C>
477
- /**
478
- * Watchers for changes to state variables, props or computed properties
479
- */
480
- watch?: W & ComponentContext<P, S, M, C>
481
- }
482
-
483
- export interface RouterHooks {
484
- beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route> | void;
485
- }
486
-
487
- export interface RouterConfig {
488
- /**
489
- * Register hooks for the router
490
- */
491
- hooks?: RouterHooks,
492
-
493
- /**
494
- * Routes definition
495
- *
496
- * @example
497
- *
498
- * ```js
499
- * routes: [
500
- * { path: '/', component: Home },
501
- * { path: '/details', component: Details },
502
- * { path: '/account', component: Account },
503
- * ]
504
- * ```
505
- */
506
- routes?: Route[]
507
- }
508
-
509
- export type ApplicationConfig<P extends Props, S, M, C, W> = ComponentConfig<P, S, M, C, W> & (
510
- {
511
- /**
512
- * Router Configuration
513
- */
514
- router?: RouterConfig,
515
- routes?: never
516
- }
517
- |
518
- {
519
- router?: never
520
- /**
521
- * Routes definition
522
- *
523
- * @example
524
- *
525
- * ```js
526
- * routes: [
527
- * { path: '/', component: Home },
528
- * { path: '/details', component: Details },
529
- * { path: '/account', component: Account },
530
- * ]
531
- * ```
532
- */
533
- routes?: Route[]
534
- }
535
- )
536
-
537
- export interface Transition {
538
- /**
539
- * Name of the prop to transition (i.e. 'x', 'y', 'alpha', 'color')
540
- */
541
- prop: string,
542
- /**
543
- * Value the prop should transition to (i.e. 0, 100, '#223388')
544
- */
545
- value: any,
546
- /**
547
- * Duration of the transition in milliseconds, defaults to 300
548
- */
549
- duration?: number,
550
- /**
551
- * Easing function to apply to the transition
552
- */
553
- easing?: string,
554
- /**
555
- * Delay before the transition starts in milliseconds
556
- */
557
- delay?: number
558
- }
559
-
560
- export interface Before {
561
- /**
562
- * Name of the prop to set before the transition starts
563
- */
564
- prop: string,
565
- /**
566
- * Value the prop to set before the transition starts
567
- */
568
- value: any,
569
- }
570
-
571
- export interface RouteTransition {
572
- /**
573
- * Setting or Array of Settings before new view enters into the router view
574
- */
575
- before: Before | Before[],
576
- /**
577
- * Transition or Array of Transitions for new view to enters into the router view
578
- */
579
- in: Transition | Transition[],
580
- /**
581
- * Transition or Array of Transitions for old view to leave the router view
582
- */
583
- out: Transition | Transition[],
584
- }
585
-
586
- export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
587
-
588
- export interface RouteAnnounce {
589
- /**
590
- * Message to be announced
591
- */
592
- message: String,
593
- /**
594
- * Politeness level
595
- *
596
- * Defaults to 'off'
597
- */
598
- politeness?: 'off' | 'polite' | 'assertive'
599
- }
600
-
601
- export type RequireAtLeastOne<T> = {
602
- [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
603
- }[keyof T]
604
-
605
- export interface RouteHooks {
606
- before?: (to: Route, from: Route) => string | Route | Promise<string | Route>;
607
- }
608
-
609
- export type Route = {
610
- /**
611
- * URI path for the route
612
- */
613
- path: string,
614
- /**
615
- * Component to load when activating the route
616
- */
617
- component: ComponentFactory // todo: or promise returning a component instance
618
- /**
619
- * Transition configuration for the route
620
- */
621
- transition?: RequireAtLeastOne<RouteTransition> | RouteTransitionFunction,
622
- /**
623
- * Extra route options
624
- */
625
- options?: object // todo: specify which options are available,
626
- /**
627
- * Message to be announced when visiting the route (often used for accessibility purposes)
628
- *
629
- * Can be either a `String` with the message or an object that defines the message and the
630
- * politeness level
631
- */
632
- announce?: String | RouteAnnounce
633
- /**
634
- * Register hooks for the route
635
- */
636
- hooks?: RouteHooks
637
- /**
638
- * Route path parameters
639
- */
640
- readonly params?: {
641
- [key: string]: string | number
642
- }
643
- /**
644
- * Allows for attaching custom data to a route, either hardcoded in the
645
- * route definition or asigned to the route object in a before hook
646
- *
647
- * Will be merged with the route params and navigation data and passed as
648
- * props into the route component
649
- */
650
- data?: {
651
- [key: string]: any
652
- }
653
- }
654
-
655
- type ComponentFactory = () => void
656
-
657
- // Launch Related
658
-
659
- type DebugLevel = 0 | 1 | 2
660
- type LogTypes = 'info' | 'warn' | 'error' | 'debug'
661
-
662
- interface WebFont {
663
- /**
664
- * Name of the font family
665
- */
666
- family: string,
667
- /**
668
- * Type of font (web)
669
- */
670
- type: 'web',
671
- /**
672
- * Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
673
- */
674
- file: string
675
- }
676
-
677
- interface SdfFontWithFile {
678
- /**
679
- * Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
680
- */
681
- file: string
682
- }
683
-
684
- interface SdfFontWithPngJson {
685
- /**
686
- * Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
687
- */
688
- json: string,
689
- /**
690
- * Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
691
- */
692
- png: string
693
- }
694
-
695
- type SdfFont = {
696
- /**
697
- * Name of the font family
698
- */
699
- family: string,
700
- /**
701
- * Type of font (web)
702
- */
703
- type: 'msdf' | 'sdf',
704
- } & (SdfFontWithFile | SdfFontWithPngJson)
705
-
706
- type Font = WebFont | SdfFont
707
-
708
- type ShaderEffect = {
709
- name: string,
710
- type: RendererShaderEffect
711
- }
712
-
713
- type Shader = {
714
- name: string,
715
- type: WebGlCoreShader
716
- }
717
-
718
- type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
719
- type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
720
-
721
- type ReactivityModes = 'Proxy' | 'defineProperty'
722
- type RenderModes = 'webgl' | 'canvas'
723
-
724
- /**
725
- * Settings
726
- *
727
- * Launcher function that sets up the Lightning renderer and instantiates
728
- * the Blits App
729
- */
730
- export interface Settings {
731
- /**
732
- * Width of the Application
733
- */
734
- w?: number,
735
- /**
736
- * Height of the Application
737
- */
738
- h?: number,
739
- /**
740
- * Whether to enable multithreaded
741
- */
742
- multithreaded?: boolean,
743
- /**
744
- * Debug level for console log messages
745
- */
746
- debugLevel?: DebugLevel | LogTypes[],
747
- /**
748
- * Fonts to be used in the Application
749
- */
750
- fonts?: Font[],
751
- /**
752
- * Effects to be used by DynamicShader
753
- */
754
- effects?: ShaderEffect[],
755
- /**
756
- * Shaders to be used in the application
757
- */
758
- shaders?: Shader[],
759
- /**
760
- * Default font family to use in the Application when no font attribute is specified
761
- * on a Text-component
762
- *
763
- * The default font must be registered in the `fonts` array in the settings.
764
- *
765
- * Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
766
- */
767
- defaultFont?: string,
768
- /**
769
- * Custom keymapping
770
- */
771
- keymap?: object,
772
- /**
773
- * Mode of reactivity (`Proxy` or `defineProperty`)
774
- */
775
- reactivityMode?: ReactivityModes,
776
- /**
777
- * Screen resolution of the device, defining the pixelRatio used to convert dimensions
778
- * and positions in the App code to the actual device logical coordinates
779
- *
780
- * If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
781
- * the exact dimensions and positions used the app code are used.
782
- *
783
- * Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
784
- * over the screen resolution setting.
785
- *
786
- * Currently 3 screen resolutions are supported, which can be defined with different alias values:
787
- *
788
- * For 720x1280 (1px = 0.66666667px)
789
- * - hd
790
- * - 720p
791
- * - 720
792
- *
793
- * For 1080x1920 (1px = 1px)
794
- * - fhd
795
- * - fullhd
796
- * - 1080p
797
- * - 1080
798
- *
799
- * For 2160x3840 (1px = 2px)
800
- * - 4k
801
- * - 2160p
802
- * - 2160
803
- */
804
- screenResolution?: ScreenResolutions,
805
- /**
806
- * Controls the quality of the rendered App.
807
- *
808
- * Setting a lower quality leads to less detail on screen, but can positively affect overall
809
- * performance and smoothness of the App (i.e. a higher FPS).
810
- *
811
- * The render quality can be one of the following presets:
812
- *
813
- * - `low` => 66% quality
814
- * - `medium` => 85% quality
815
- * - `high` => 100% quality
816
- * - `retina` => 200% quality
817
- *
818
- * It's also possible to provide a custom value as a (decimal) number:
819
- *
820
- * - `0.2` => 20% quality
821
- * - `1.5` => 150% quality
822
- *
823
- * Defaults to 1 (high quality) when not specified
824
- */
825
- renderQuality?: RenderQualities,
826
- /**
827
- * Custom pixel ratio of the device used to convert dimensions
828
- * and positions in the App code to the actual device logical coordinates
829
- *
830
- * Takes presedence over the `screenResolution` setting
831
- *
832
- * Defaults to 1 if not specified
833
- */
834
- pixelRatio?: number
835
- /**
836
- * Interval in milliseconds to receive FPS updates
837
- *
838
- * @remarks
839
- * If set to `0`, FPS updates will be disabled.
840
- *
841
- * @defaultValue `1000` (disabled)
842
- */
843
- fpsInterval?: number
844
- /**
845
- * Maximum number of web workers to spin up simultaneously for offloading functionality such
846
- * as image loading to separate threads (when supported by the browser)
847
- *
848
- * If not specified defaults to the number of logical processers available as reported by
849
- * `navigator.hardwareConcurrency` (or 2 if `navigator.hardwareConcurrency` is not supported)
850
- */
851
- webWorkersLimit?: number
852
- /**
853
- * Background color of the canvas (also known as the clearColor)
854
- *
855
- * Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
856
- * or a color number in rgba order (`0xff0033ff`)
857
- *
858
- * Defauls to transparent (`0x00000000`)
859
- *
860
- */
861
- canvasColor?: string,
862
- /**
863
- * Enable inspector
864
- *
865
- * Enables the inspector tool for debugging and inspecting the application, the node tree
866
- * will be replicated in the DOM and can be inspected using the browser's developer tools
867
- *
868
- * Defaults to `false`
869
- */
870
- inspector?: boolean,
871
- /**
872
- * Add an extra margin to the viewport for earlier pre-loading of elements and components
873
- *
874
- * By default the Lightning renderer, only renders elements that are inside the defined viewport.
875
- * Everything outside of these bounds is removed from the render tree.
876
- *
877
- * With the viewportMargin you have the option to _virtually_ increase the viewport area,
878
- * to expedite the pre-loading of elements and / or delay the unloading of elements depending
879
- * on their position in the (virtual) viewport
880
- *
881
- * The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
882
- * or as a single number which is then applied to all 4 directions equally.
883
- *
884
- * Defaults to `0`
885
- */
886
- viewportMargin?: number | [number, number, number, number],
887
- /**
888
- * Threshold in `Megabytes` after which all the textures that are currently not visible
889
- * within the configured viewport margin will be be freed and cleaned up
890
- *
891
- * When passed `0` the threshold is disabled and textures will not be actively freed
892
- * and cleaned up
893
- *
894
- * Defaults to `200` (mb)
895
- * @deprecated
896
- * Deprecated: use `gpuMemory` launch setting instead
897
- */
898
- gpuMemoryLimit?: number,
899
- /**
900
- * Configures the gpu memory settings used by the renderer
901
- */
902
- gpuMemory?: {
903
- /**
904
- * Maximum GPU memory threshold (in `mb`) after which
905
- * the renderer will immediately start cleaning up textures to free
906
- * up graphical memory
907
- *
908
- * When setting to `0`, texture memory management is disabled
909
- *
910
- * @default `200`
911
- */
912
- max?: number,
913
- /**
914
- * Target threshold of GPU memory usage, defined as a fraction of
915
- * the max threshold. The renderer will attempt to keep memory
916
- * usage below this target by cleaning up non-renderable textures
917
- *
918
- * @default `0.8`
919
- */
920
- target?: number,
921
- /**
922
- * Interval at which regular texture cleanups occur (in `ms`)
923
- *
924
- * @default `5000`
925
- */
926
- cleanupInterval?: number,
927
- /**
928
- * Baseline GPU memory usage of the App (in `mb`), without rendering any
929
- * textures. This value will be used as a basis when calculating
930
- * the total memory usage towards the max and target memory
931
- * usage
932
- *
933
- * @default `25`
934
- */
935
- baseline?: number,
936
- /**
937
- * Whether or not the max threshold should be considered
938
- * as a strict number that can not be exceeded in any way
939
- *
940
- * When set to `true`, new textures won't be created when the
941
- * max threshold has been reached, until agressive texture cleanup
942
- * has brought the memory back down
943
- *
944
- * @default false
945
- */
946
- strict?: boolean,
947
- },
948
- /**
949
- * Defines which mode the renderer should operate in: `webgl` or `canvas`
950
- *
951
- * SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
952
- * be used. Also note that Canvas2d rendering doesnt support the use of shaders.
953
- *
954
- * Defaults to `webgl`
955
- */
956
- renderMode?: RenderModes,
957
-
958
- /**
959
- * The time, in milliseconds, after which Blits considers a key press a _hold_ key press
960
- *
961
- * During a hold key press the focus delegation behaviour is different: when scrolling
962
- * through a long list, focus is not handed over to each individual list item, creating a
963
- * smoother experience
964
- *
965
- * Defaults to `50` (ms)
966
- */
967
- holdTimeout?: number,
968
- /**
969
- * Custom canvas object used to render the App to.
970
- *
971
- * When not provided, the Lightning renderer will create a
972
- * new Canvas element and inject it into the DOM
973
- */
974
- canvas?: HTMLCanvasElement,
975
- /**
976
- * The maximum amount of time the renderer is allowed to process textures in a
977
- * single frame. If the processing time exceeds this limit, the renderer will
978
- * skip processing the remaining textures and continue rendering the frame.
979
- *
980
- * Defaults to `10`
981
- */
982
- textureProcessingTimeLimit?: number,
983
- /**
984
- * Advanced renderer settings to override Blits launch settings, or configure
985
- * settings that are not officially exposed in Blits yet
986
- *
987
- * @important if you dont know what you're doing here, you probably shouldn't be doing it!
988
- */
989
- advanced?: Partial<RendererMainSettings>,
990
- /**
991
- * Whether or not the announcer should be activated on initialization
992
- *
993
- * When set to `false` announcements via `this.$annoucer.speak()` will
994
- * be ignored. When set to `true` announcement will be spoken out via the
995
- * text to speech API
996
- *
997
- * Announcer can be enabled / disabled run time as well via:
998
- * - this.$announcer.enable()
999
- * - this.$announcer.disable()
1000
- * - this.$announcer.toggle(true/false)
1001
- *
1002
- * @default false
1003
- */
1004
- announcer?: boolean
1005
- }
1006
-
1007
- interface State {
1008
- [key: string]: any
1009
- }
1010
-
1011
- interface Methods {
1012
- [key: string]: any
1013
- }
1014
-
1015
- interface Watch {
1016
- [key: string]: any
1017
- }
1018
-
1019
- interface Computed {
1020
- [key: string]: any
1021
- }
1022
-
1023
-
1024
- interface Plugin {
1025
- /**
1026
- * Name of the plugin. The plugin will be accessible on each Component's
1027
- * `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
1028
- */
1029
- name: string,
1030
- /**
1031
- * Singleton function that will be used to instantiate the plugin.
1032
- * Should do all necessary setup and ideally return an object with
1033
- * properties or methods that can be used in the App
1034
- */
1035
- plugin: () => any
1036
- }
1037
-
1038
-
1039
- /**
1040
- * Blits App Framework
1041
- */
1042
- export interface Blits {
1043
- /**
1044
- * Blits Application
1045
- * @param {ApplicationConfig} config - Application Configuration object
1046
- */
1047
- Application<
1048
- P extends Props,
1049
- S extends State,
1050
- M extends Methods,
1051
- C extends Computed,
1052
- W extends Watch>(config: ApplicationConfig<P, S, M, C, W>) : ComponentFactory
1053
- /**
1054
- * Blits Component
1055
- * @param {string} name - The name of the Component
1056
- * @param {ComponentConfig} config - Component Configuration object
1057
- */
1058
- Component<
1059
- P extends Props,
1060
- S extends State,
1061
- M extends Methods,
1062
- C extends Computed,
1063
- W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
1064
- /**
1065
- * Blits Launch
1066
- */
1067
- Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
1068
- /**
1069
- * Blits Plugin
1070
- *
1071
- * @param plugin
1072
- * Plugin object or singleton function that will be used to instantiate the
1073
- * plugin. Should do all necessary setup and ideally return an object with
1074
- * properties or methods that can be used in the App
1075
- *
1076
- * @param nameOrOptions
1077
- * Name of the plugin or options object, to be passed into the plugin instantiation.
1078
- *
1079
- * When passing a string, the value will be used as **name** of the plugin. The plugin
1080
- * will be accessible on each Component's `this` scope under this name, prefixed with a `$`
1081
- * (i.e. myplugin => `this.$myplugin`)
1082
- *
1083
- * Passing a name is **required** when `plugin` argument is a singleton function
1084
- *
1085
- * When passing an object, the value will be considered to be an `options` object.
1086
- * The options object will be passed into the plugin instantiation method. Can
1087
- * be used to set default values
1088
- *
1089
- * @param options
1090
- * Object with options to be passed into the plugin instantiation method.
1091
- * Can be used to set default values
1092
- */
1093
- Plugin(plugin: Plugin, nameOrOptions?: string | object , options?: object) : void
1094
- }
1095
-
1096
- const Blits: Blits;
1097
-
1098
- export default Blits;
1099
- }
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+
18
+ // blits file type reference
19
+ /// <reference path="./blits.d.ts" />
20
+
21
+ import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader, type RendererMainSettings} from '@lightningjs/renderer'
22
+
23
+ declare module '@lightningjs/blits' {
24
+
25
+
26
+ export interface AnnouncerUtterance extends Promise<T> {
27
+ /**
28
+ * Removes a specific message from the announcement queue,
29
+ * to make sure it isn't spoke out.
30
+ *
31
+ * Does not interupt the message when it's already being announced.
32
+ */
33
+ cancel()
34
+ /**
35
+ * Interrupts a specific message as it is being spoken out by the Text to Speech
36
+ * engine.
37
+ */
38
+ stop()
39
+ }
40
+
41
+ export interface Announcer {
42
+ /**
43
+ * Instruct the Announcer to speak a message. Will add the message
44
+ * to the end of announcement queue by default
45
+ *
46
+ * When a message is added with politeness set to `assertive` the message
47
+ * will be added to the beginning of the queue
48
+ *
49
+ */
50
+ speak(message: string | number, politeness?: 'off' | 'polite' | 'assertive'): AnnouncerUtterance;
51
+ /**
52
+ * Instruct the Announcer to add a pause of a certain duration (in ms). Will add this pause
53
+ * to the end of announcement queue
54
+ *
55
+ */
56
+ pause(delay: number): AnnouncerUtterance;
57
+ /**
58
+ * Interupts and instantly stops any running text to speech utterance
59
+ *
60
+ */
61
+ stop(): void;
62
+ /**
63
+ * Clears out the announcement queue of messages.
64
+ */
65
+ clear(): void;
66
+ /**
67
+ * Enables the announcer.
68
+ */
69
+ enable(): void;
70
+ /**
71
+ * Disables the announcer. Any messages passed in the announcer.speak() message
72
+ * will not be added to the queue
73
+ */
74
+ disable(): void;
75
+ /**
76
+ * Toggles the announcer based on the passed toggle value (Boolean)
77
+ */
78
+ toggle(toggle: Boolean): void;
79
+ }
80
+
81
+
82
+ export interface Hooks {
83
+ /**
84
+ * Fires when the Component is being instantiated
85
+ * At this moment child elements will not be available yet
86
+ */
87
+ init?: () => void;
88
+ /**
89
+ * Fires when the Component is fully initialized and ready for interaction.
90
+ */
91
+ ready?: () => void;
92
+ /**
93
+ * Triggers when the Component receives focus.
94
+ *
95
+ * This event can fire multiple times during the component's lifecycle
96
+ */
97
+ focus?: () => void;
98
+ /**
99
+ * Triggers when the Component loses focus.
100
+ *
101
+ * This event can fire multiple times during the component's lifecycle
102
+ */
103
+ unfocus?: () => void;
104
+ /**
105
+ * Fires when the Component is being destroyed and removed.
106
+ */
107
+ destroy?: () => void;
108
+ /**
109
+ * Fires upon each frame start (allowing you to tap directly into the renderloop)
110
+ *
111
+ * Note: This hook will fire continuously, multiple times per second!
112
+ */
113
+ frameTick?: () => void;
114
+ /**
115
+ * Fires when the component enters the viewport _margin_ and is attached to the render tree
116
+ *
117
+ * This event can fire multiple times during the component's lifecycle
118
+ */
119
+ attach?: () => void;
120
+ /**
121
+ * Fires when the component leaves the viewport _margin_ and is detached from the render tree
122
+ *
123
+ * This event can fire multiple times during the component's lifecycle
124
+ */
125
+ detach?: () => void;
126
+ /**
127
+ * Fires when the component enters the visible viewport
128
+ *
129
+ * This event can fire multiple times during the component's lifecycle
130
+ */
131
+ enter?: () => void;
132
+ /**
133
+ * Fires when the component leaves the visible viewport
134
+ *
135
+ * This event can fire multiple times during the component's lifecycle
136
+ */
137
+ exit?: () => void;
138
+ }
139
+
140
+ export interface Input {
141
+ [key: string]: (event: KeyboardEvent) => void | undefined | unknown,
142
+ /**
143
+ * Catch all input function
144
+ *
145
+ * Will be invoked when there is no dedicated function for a certain key
146
+ */
147
+ // @ts-ignore
148
+ any?: (event: KeyboardEvent) => void,
149
+ /**
150
+ * Intercept key presses on the root Application component before being handled
151
+ * by the currently focused component.
152
+ *
153
+ * Only when a KeyboardEvent (the original one, or a modified one) is returned from the
154
+ * intercept function, the Input event is passed on to the Component with focus.
155
+ *
156
+ * The intercept function can be asynchronous.
157
+ *
158
+ * Note: the intercept input handler is only available on the Root App component (i.e. Blits.Application)
159
+ */
160
+ intercept?: (event: KeyboardEvent) => KeyboardEvent | Promise<KeyboardEvent | any> | any
161
+ }
162
+
163
+ export interface Log {
164
+ /**
165
+ * Log an info message
166
+ */
167
+ info(...args): typeof console.info
168
+ /**
169
+ * Log an error message
170
+ */
171
+ error(...args): typeof console.error
172
+ /**
173
+ * Log a warning
174
+ */
175
+ warn(...args): typeof console.warn
176
+ /**
177
+ * Log a debug message
178
+ */
179
+ debug(...args): typeof console.debug
180
+ }
181
+
182
+
183
+
184
+ export interface RouteData {
185
+ [key: string]: any
186
+ }
187
+
188
+ // todo: specify valid route options
189
+ export interface RouteOptions {
190
+ [key: string]: any
191
+ }
192
+
193
+ export interface Router {
194
+ /**
195
+ * Navigate to a different location
196
+ *
197
+ * @param {string}
198
+ */
199
+ to(location: string, data?: RouteData, options?: RouteOptions): void;
200
+
201
+ /**
202
+ * Navigate to the previous location
203
+ */
204
+ back(): boolean;
205
+
206
+ /**
207
+ * Get the current route read-only
208
+ */
209
+ readonly currentRoute: Route;
210
+
211
+ /**
212
+ * Get the list of all routes
213
+ */
214
+ readonly routes: Route[];
215
+
216
+ /**
217
+ * Get navigating state
218
+ */
219
+ readonly navigating: boolean;
220
+
221
+ /**
222
+ * Reactive router state
223
+ */
224
+ state: {
225
+ /**
226
+ * Path of the current route
227
+ *
228
+ * Can be used in:
229
+ * - a template as `$$router.state.path`
230
+ * - inside business logic as `this.$router.state.path`
231
+ * - as a watcher as `$router.state.path(v) {}`
232
+ */
233
+ readonly path: string
234
+ /**
235
+ * Whether or not the router is currently in the process of navigating
236
+ * between pages
237
+ *
238
+ * Can be used in:
239
+ * - a template as `$$router.state.navihating`
240
+ * - inside business logic as `this.$router.state.navigating`
241
+ * - as a watcher as `$router.state.navigating(v) {}`
242
+ */
243
+ readonly navigating: boolean
244
+ }
245
+ }
246
+
247
+ export type ComponentBase = {
248
+ /**
249
+ * Indicates whether the component currently has focus
250
+ *
251
+ * @returns Boolean
252
+ */
253
+ hasFocus: boolean,
254
+
255
+ /**
256
+ * Listen to events emitted by other components
257
+ */
258
+ $listen: {
259
+ (event: string, callback: (args: any) => void, priority?: number): void;
260
+ }
261
+ /**
262
+ * Emit events that other components can listen to
263
+ * @param name - name of the event to be emitted
264
+ * @param data - optional data to be passed along
265
+ */
266
+ $emit(name: string, data?: any): void;
267
+
268
+ /**
269
+ * Set a timeout that is automatically cleaned upon component destroy
270
+ */
271
+ $setTimeout: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setTimeout>
272
+
273
+ /**
274
+ * Clear a timeout
275
+ */
276
+ $clearTimeout: (id: ReturnType<typeof setTimeout>) => void
277
+
278
+ /**
279
+ * Set an interval that is automatically cleaned upon component destroy
280
+ */
281
+ $setInterval: (callback: (args: any) => void, ms?: number | undefined) => ReturnType<typeof setInterval>
282
+
283
+ /**
284
+ * Clear a interval
285
+ */
286
+ $clearInterval: (id: ReturnType<typeof setInterval>) => void
287
+
288
+ /**
289
+ * Log to the console with prettier output and configurable debug levels in Settings
290
+ */
291
+ $log: Log
292
+
293
+ /**
294
+ * Set focus to the Component, optionally pass a KeyboardEvent for instant event bubbling
295
+ */
296
+ $focus: (event?: KeyboardEvent) => void
297
+ /**
298
+ * @deprecated
299
+ * Deprecated: use `this.$focus()` instead
300
+ */
301
+ focus: (event?: KeyboardEvent) => void
302
+
303
+ /**
304
+ * Select a child Element or Component by ref
305
+ *
306
+ * Elements and Components in the template can have an optional ref argument.
307
+ * Returns an Element Instance or Component Instance.
308
+ * Useful for passing on the focus to a Child component.
309
+ *
310
+ * @example
311
+ * ```js
312
+ * const menu = this.$select('Menu')
313
+ * if(menu) {
314
+ * menu.$focus()
315
+ * }
316
+ * ```
317
+ */
318
+ $select: (ref: string) => ComponentBase
319
+
320
+ /**
321
+ * @deprecated
322
+ * Deprecated: use `this.$select()` instead
323
+ */
324
+ select: (ref: string) => ComponentBase
325
+
326
+ /**
327
+ * Announcer methods for screen reader support
328
+ */
329
+ $announcer: Announcer
330
+
331
+ /**
332
+ * Triggers a forced update on state variables.
333
+ */
334
+ $trigger: (key: string) => void
335
+ /**
336
+ * @deprecated
337
+ *
338
+ * Triggers a forced update on state variables.
339
+ * Deprecated: use `this.$trigger()` instead
340
+ */
341
+ trigger: (key: string) => void
342
+ /**
343
+ * Router instance
344
+ */
345
+ $router: Router
346
+ /**
347
+ * Dynamically set the size of a component holder node
348
+ */
349
+ $size: (dimensions: {
350
+ /**
351
+ * Component width
352
+ */
353
+ w: number,
354
+ /**
355
+ * Component height
356
+ */
357
+ h: number
358
+ }) => void
359
+ }
360
+
361
+ /**
362
+ * Prop object
363
+ */
364
+ export type PropObject = {
365
+ /**
366
+ * Name of the prop
367
+ */
368
+ key: string,
369
+ /**
370
+ * Whether the prop is required to be passed
371
+ */
372
+ required?: boolean,
373
+ /**
374
+ * Default value for the prop when omited
375
+ */
376
+ default?: any,
377
+ /**
378
+ * Cast the value of the prop
379
+ *
380
+ * @example
381
+ * ```js
382
+ * {
383
+ * cast: Number, // casts to a number
384
+ * cast: (v) => v.toUpperCase() // casts to uppercase
385
+ * }
386
+ * ```
387
+ */
388
+ cast?: () => any
389
+ };
390
+
391
+ // Props Array
392
+ export type Props = (string | PropObject)[];
393
+
394
+ // Extract the prop names from the props array
395
+ type ExtractPropNames<P extends Props> = {
396
+ readonly [K in P[number] as K extends string ? K : K extends { key: infer Key } ? Key : never]: any;
397
+ };
398
+
399
+ // Update the PropsDefinition to handle props as strings or objects
400
+ export type PropsDefinition<P extends Props> = ExtractPropNames<P>;
401
+
402
+ export type ComponentContext<P extends Props, S, M, C> = ThisType<PropsDefinition<P> & S & M & C & ComponentBase>
403
+
404
+ export interface ComponentConfig<P extends Props, S, M, C, W> {
405
+ components?: {
406
+ [key: string]: ComponentFactory,
407
+ },
408
+ /**
409
+ * XML-based template string of the Component
410
+ *
411
+ * @example
412
+ * ```xml
413
+ * <Element :x="$x" w="400" h="1080" color="#64748b">
414
+ * <Element x="50" y="40">
415
+ * <Button color="#e4e4e7" />
416
+ * <Button color="#e4e4e7" y="100" />
417
+ * <Button color="#e4e4e7" y="200" />
418
+ * <Button color="#e4e4e7" y="300" />
419
+ * </Element>
420
+ * </Element>
421
+ * ```
422
+ */
423
+ template?: String,
424
+ /**
425
+ * Allowed props to be passed into the Component by the parent
426
+ *
427
+ * Can be a simple array with `prop` keys as strings.
428
+ * Alternatively objects can be used to specify `required` props and `default` values
429
+ *
430
+ * @example
431
+ * ```js
432
+ * props: ['index', {
433
+ * key: 'alpha',
434
+ * required: true
435
+ * }, {
436
+ * key: 'color',
437
+ * default: 'red'
438
+ * }]
439
+ * ```
440
+ */
441
+ props?: P;
442
+ /**
443
+ * Reactive internal state of the Component instance
444
+ *
445
+ * Should return an object (literal) with key value pairs.
446
+ * Can contain nested objects, but beware that too deep nesting can have
447
+ * a negative impact on performance
448
+ *
449
+ * @example
450
+ * ```js
451
+ * state() {
452
+ * return {
453
+ * items: [],
454
+ * color: 'red',
455
+ * alpha: 0.1
456
+ * }
457
+ * }
458
+ * ```
459
+ */
460
+ state?: (this: PropsDefinition<P>) => S;
461
+ /**
462
+ * Methods for abstracting more complex business logic into separate function
463
+ */
464
+ methods?: M & ComponentContext<P, S, M, C>
465
+ /**
466
+ * Hooking into Lifecycle events
467
+ */
468
+ hooks?: Hooks & ComponentContext<P, S, M, C>
469
+ /**
470
+ * Tapping into user input
471
+ */
472
+ input?: Input & ComponentContext<P, S, M, C>
473
+ /**
474
+ * Computed properties
475
+ */
476
+ computed?: C & ComponentContext<P, S, M, C>
477
+ /**
478
+ * Watchers for changes to state variables, props or computed properties
479
+ */
480
+ watch?: W & ComponentContext<P, S, M, C>
481
+ }
482
+
483
+ export interface RouterHooks {
484
+ beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route> | void;
485
+ }
486
+
487
+ export interface RouterConfig {
488
+ /**
489
+ * Register hooks for the router
490
+ */
491
+ hooks?: RouterHooks,
492
+
493
+ /**
494
+ * Routes definition
495
+ *
496
+ * @example
497
+ *
498
+ * ```js
499
+ * routes: [
500
+ * { path: '/', component: Home },
501
+ * { path: '/details', component: Details },
502
+ * { path: '/account', component: Account },
503
+ * ]
504
+ * ```
505
+ */
506
+ routes?: Route[]
507
+ }
508
+
509
+ export type ApplicationConfig<P extends Props, S, M, C, W> = ComponentConfig<P, S, M, C, W> & (
510
+ {
511
+ /**
512
+ * Router Configuration
513
+ */
514
+ router?: RouterConfig,
515
+ routes?: never
516
+ }
517
+ |
518
+ {
519
+ router?: never
520
+ /**
521
+ * Routes definition
522
+ *
523
+ * @example
524
+ *
525
+ * ```js
526
+ * routes: [
527
+ * { path: '/', component: Home },
528
+ * { path: '/details', component: Details },
529
+ * { path: '/account', component: Account },
530
+ * ]
531
+ * ```
532
+ */
533
+ routes?: Route[]
534
+ }
535
+ )
536
+
537
+ export interface Transition {
538
+ /**
539
+ * Name of the prop to transition (i.e. 'x', 'y', 'alpha', 'color')
540
+ */
541
+ prop: string,
542
+ /**
543
+ * Value the prop should transition to (i.e. 0, 100, '#223388')
544
+ */
545
+ value: any,
546
+ /**
547
+ * Duration of the transition in milliseconds, defaults to 300
548
+ */
549
+ duration?: number,
550
+ /**
551
+ * Easing function to apply to the transition
552
+ */
553
+ easing?: string,
554
+ /**
555
+ * Delay before the transition starts in milliseconds
556
+ */
557
+ delay?: number
558
+ }
559
+
560
+ export interface Before {
561
+ /**
562
+ * Name of the prop to set before the transition starts
563
+ */
564
+ prop: string,
565
+ /**
566
+ * Value the prop to set before the transition starts
567
+ */
568
+ value: any,
569
+ }
570
+
571
+ export interface RouteTransition {
572
+ /**
573
+ * Setting or Array of Settings before new view enters into the router view
574
+ */
575
+ before: Before | Before[],
576
+ /**
577
+ * Transition or Array of Transitions for new view to enters into the router view
578
+ */
579
+ in: Transition | Transition[],
580
+ /**
581
+ * Transition or Array of Transitions for old view to leave the router view
582
+ */
583
+ out: Transition | Transition[],
584
+ }
585
+
586
+ export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
587
+
588
+ export interface RouteAnnounce {
589
+ /**
590
+ * Message to be announced
591
+ */
592
+ message: String,
593
+ /**
594
+ * Politeness level
595
+ *
596
+ * Defaults to 'off'
597
+ */
598
+ politeness?: 'off' | 'polite' | 'assertive'
599
+ }
600
+
601
+ export type RequireAtLeastOne<T> = {
602
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
603
+ }[keyof T]
604
+
605
+ export interface RouteHooks {
606
+ before?: (to: Route, from: Route) => string | Route | Promise<string | Route>;
607
+ }
608
+
609
+ export type Route = {
610
+ /**
611
+ * URI path for the route
612
+ */
613
+ path: string,
614
+ /**
615
+ * Component to load when activating the route
616
+ */
617
+ component: ComponentFactory // todo: or promise returning a component instance
618
+ /**
619
+ * Transition configuration for the route
620
+ */
621
+ transition?: RequireAtLeastOne<RouteTransition> | RouteTransitionFunction,
622
+ /**
623
+ * Extra route options
624
+ */
625
+ options?: object // todo: specify which options are available,
626
+ /**
627
+ * Message to be announced when visiting the route (often used for accessibility purposes)
628
+ *
629
+ * Can be either a `String` with the message or an object that defines the message and the
630
+ * politeness level
631
+ */
632
+ announce?: String | RouteAnnounce
633
+ /**
634
+ * Register hooks for the route
635
+ */
636
+ hooks?: RouteHooks
637
+ /**
638
+ * Route path parameters
639
+ */
640
+ readonly params?: {
641
+ [key: string]: string | number
642
+ }
643
+ /**
644
+ * Allows for attaching custom data to a route, either hardcoded in the
645
+ * route definition or asigned to the route object in a before hook
646
+ *
647
+ * Will be merged with the route params and navigation data and passed as
648
+ * props into the route component
649
+ */
650
+ data?: {
651
+ [key: string]: any
652
+ }
653
+ }
654
+
655
+ type ComponentFactory = () => void
656
+
657
+ // Launch Related
658
+
659
+ type DebugLevel = 0 | 1 | 2
660
+ type LogTypes = 'info' | 'warn' | 'error' | 'debug'
661
+
662
+ interface WebFont {
663
+ /**
664
+ * Name of the font family
665
+ */
666
+ family: string,
667
+ /**
668
+ * Type of font (web)
669
+ */
670
+ type: 'web',
671
+ /**
672
+ * Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
673
+ */
674
+ file: string
675
+ }
676
+
677
+ interface SdfFontWithFile {
678
+ /**
679
+ * Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
680
+ */
681
+ file: string
682
+ }
683
+
684
+ interface SdfFontWithPngJson {
685
+ /**
686
+ * Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
687
+ */
688
+ json: string,
689
+ /**
690
+ * Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
691
+ */
692
+ png: string
693
+ }
694
+
695
+ type SdfFont = {
696
+ /**
697
+ * Name of the font family
698
+ */
699
+ family: string,
700
+ /**
701
+ * Type of font (web)
702
+ */
703
+ type: 'msdf' | 'sdf',
704
+ } & (SdfFontWithFile | SdfFontWithPngJson)
705
+
706
+ type Font = WebFont | SdfFont
707
+
708
+ type ShaderEffect = {
709
+ name: string,
710
+ type: RendererShaderEffect
711
+ }
712
+
713
+ type Shader = {
714
+ name: string,
715
+ type: WebGlCoreShader
716
+ }
717
+
718
+ type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
719
+ type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
720
+
721
+ type ReactivityModes = 'Proxy' | 'defineProperty'
722
+ type RenderModes = 'webgl' | 'canvas'
723
+
724
+ /**
725
+ * Settings
726
+ *
727
+ * Launcher function that sets up the Lightning renderer and instantiates
728
+ * the Blits App
729
+ */
730
+ export interface Settings {
731
+ /**
732
+ * Width of the Application
733
+ */
734
+ w?: number,
735
+ /**
736
+ * Height of the Application
737
+ */
738
+ h?: number,
739
+ /**
740
+ * Whether to enable multithreaded
741
+ */
742
+ multithreaded?: boolean,
743
+ /**
744
+ * Debug level for console log messages
745
+ */
746
+ debugLevel?: DebugLevel | LogTypes[],
747
+ /**
748
+ * Fonts to be used in the Application
749
+ */
750
+ fonts?: Font[],
751
+ /**
752
+ * Effects to be used by DynamicShader
753
+ */
754
+ effects?: ShaderEffect[],
755
+ /**
756
+ * Shaders to be used in the application
757
+ */
758
+ shaders?: Shader[],
759
+ /**
760
+ * Default font family to use in the Application when no font attribute is specified
761
+ * on a Text-component
762
+ *
763
+ * The default font must be registered in the `fonts` array in the settings.
764
+ *
765
+ * Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
766
+ */
767
+ defaultFont?: string,
768
+ /**
769
+ * Custom keymapping
770
+ */
771
+ keymap?: object,
772
+ /**
773
+ * Mode of reactivity (`Proxy` or `defineProperty`)
774
+ */
775
+ reactivityMode?: ReactivityModes,
776
+ /**
777
+ * Screen resolution of the device, defining the pixelRatio used to convert dimensions
778
+ * and positions in the App code to the actual device logical coordinates
779
+ *
780
+ * If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
781
+ * the exact dimensions and positions used the app code are used.
782
+ *
783
+ * Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
784
+ * over the screen resolution setting.
785
+ *
786
+ * Currently 3 screen resolutions are supported, which can be defined with different alias values:
787
+ *
788
+ * For 720x1280 (1px = 0.66666667px)
789
+ * - hd
790
+ * - 720p
791
+ * - 720
792
+ *
793
+ * For 1080x1920 (1px = 1px)
794
+ * - fhd
795
+ * - fullhd
796
+ * - 1080p
797
+ * - 1080
798
+ *
799
+ * For 2160x3840 (1px = 2px)
800
+ * - 4k
801
+ * - 2160p
802
+ * - 2160
803
+ */
804
+ screenResolution?: ScreenResolutions,
805
+ /**
806
+ * Controls the quality of the rendered App.
807
+ *
808
+ * Setting a lower quality leads to less detail on screen, but can positively affect overall
809
+ * performance and smoothness of the App (i.e. a higher FPS).
810
+ *
811
+ * The render quality can be one of the following presets:
812
+ *
813
+ * - `low` => 66% quality
814
+ * - `medium` => 85% quality
815
+ * - `high` => 100% quality
816
+ * - `retina` => 200% quality
817
+ *
818
+ * It's also possible to provide a custom value as a (decimal) number:
819
+ *
820
+ * - `0.2` => 20% quality
821
+ * - `1.5` => 150% quality
822
+ *
823
+ * Defaults to 1 (high quality) when not specified
824
+ */
825
+ renderQuality?: RenderQualities,
826
+ /**
827
+ * Custom pixel ratio of the device used to convert dimensions
828
+ * and positions in the App code to the actual device logical coordinates
829
+ *
830
+ * Takes presedence over the `screenResolution` setting
831
+ *
832
+ * Defaults to 1 if not specified
833
+ */
834
+ pixelRatio?: number
835
+ /**
836
+ * Interval in milliseconds to receive FPS updates
837
+ *
838
+ * @remarks
839
+ * If set to `0`, FPS updates will be disabled.
840
+ *
841
+ * @defaultValue `1000` (disabled)
842
+ */
843
+ fpsInterval?: number
844
+ /**
845
+ * Maximum number of web workers to spin up simultaneously for offloading functionality such
846
+ * as image loading to separate threads (when supported by the browser)
847
+ *
848
+ * If not specified defaults to the number of logical processers available as reported by
849
+ * `navigator.hardwareConcurrency` (or 2 if `navigator.hardwareConcurrency` is not supported)
850
+ */
851
+ webWorkersLimit?: number
852
+ /**
853
+ * Background color of the canvas (also known as the clearColor)
854
+ *
855
+ * Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
856
+ * or a color number in rgba order (`0xff0033ff`)
857
+ *
858
+ * Defauls to transparent (`0x00000000`)
859
+ *
860
+ */
861
+ canvasColor?: string,
862
+ /**
863
+ * Enable inspector
864
+ *
865
+ * Enables the inspector tool for debugging and inspecting the application, the node tree
866
+ * will be replicated in the DOM and can be inspected using the browser's developer tools
867
+ *
868
+ * Defaults to `false`
869
+ */
870
+ inspector?: boolean,
871
+ /**
872
+ * Add an extra margin to the viewport for earlier pre-loading of elements and components
873
+ *
874
+ * By default the Lightning renderer, only renders elements that are inside the defined viewport.
875
+ * Everything outside of these bounds is removed from the render tree.
876
+ *
877
+ * With the viewportMargin you have the option to _virtually_ increase the viewport area,
878
+ * to expedite the pre-loading of elements and / or delay the unloading of elements depending
879
+ * on their position in the (virtual) viewport
880
+ *
881
+ * The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
882
+ * or as a single number which is then applied to all 4 directions equally.
883
+ *
884
+ * Defaults to `0`
885
+ */
886
+ viewportMargin?: number | [number, number, number, number],
887
+ /**
888
+ * Threshold in `Megabytes` after which all the textures that are currently not visible
889
+ * within the configured viewport margin will be be freed and cleaned up
890
+ *
891
+ * When passed `0` the threshold is disabled and textures will not be actively freed
892
+ * and cleaned up
893
+ *
894
+ * Defaults to `200` (mb)
895
+ * @deprecated
896
+ * Deprecated: use `gpuMemory` launch setting instead
897
+ */
898
+ gpuMemoryLimit?: number,
899
+ /**
900
+ * Configures the gpu memory settings used by the renderer
901
+ */
902
+ gpuMemory?: {
903
+ /**
904
+ * Maximum GPU memory threshold (in `mb`) after which
905
+ * the renderer will immediately start cleaning up textures to free
906
+ * up graphical memory
907
+ *
908
+ * When setting to `0`, texture memory management is disabled
909
+ *
910
+ * @default `200`
911
+ */
912
+ max?: number,
913
+ /**
914
+ * Target threshold of GPU memory usage, defined as a fraction of
915
+ * the max threshold. The renderer will attempt to keep memory
916
+ * usage below this target by cleaning up non-renderable textures
917
+ *
918
+ * @default `0.8`
919
+ */
920
+ target?: number,
921
+ /**
922
+ * Interval at which regular texture cleanups occur (in `ms`)
923
+ *
924
+ * @default `5000`
925
+ */
926
+ cleanupInterval?: number,
927
+ /**
928
+ * Baseline GPU memory usage of the App (in `mb`), without rendering any
929
+ * textures. This value will be used as a basis when calculating
930
+ * the total memory usage towards the max and target memory
931
+ * usage
932
+ *
933
+ * @default `25`
934
+ */
935
+ baseline?: number,
936
+ /**
937
+ * Whether or not the max threshold should be considered
938
+ * as a strict number that can not be exceeded in any way
939
+ *
940
+ * When set to `true`, new textures won't be created when the
941
+ * max threshold has been reached, until agressive texture cleanup
942
+ * has brought the memory back down
943
+ *
944
+ * @default false
945
+ */
946
+ strict?: boolean,
947
+ },
948
+ /**
949
+ * Defines which mode the renderer should operate in: `webgl` or `canvas`
950
+ *
951
+ * SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
952
+ * be used. Also note that Canvas2d rendering doesnt support the use of shaders.
953
+ *
954
+ * Defaults to `webgl`
955
+ */
956
+ renderMode?: RenderModes,
957
+
958
+ /**
959
+ * The time, in milliseconds, after which Blits considers a key press a _hold_ key press
960
+ *
961
+ * During a hold key press the focus delegation behaviour is different: when scrolling
962
+ * through a long list, focus is not handed over to each individual list item, creating a
963
+ * smoother experience
964
+ *
965
+ * Defaults to `50` (ms)
966
+ */
967
+ holdTimeout?: number,
968
+ /**
969
+ * Custom canvas object used to render the App to.
970
+ *
971
+ * When not provided, the Lightning renderer will create a
972
+ * new Canvas element and inject it into the DOM
973
+ */
974
+ canvas?: HTMLCanvasElement,
975
+ /**
976
+ * The maximum amount of time the renderer is allowed to process textures in a
977
+ * single frame. If the processing time exceeds this limit, the renderer will
978
+ * skip processing the remaining textures and continue rendering the frame.
979
+ *
980
+ * Defaults to `10`
981
+ */
982
+ textureProcessingTimeLimit?: number,
983
+ /**
984
+ * Advanced renderer settings to override Blits launch settings, or configure
985
+ * settings that are not officially exposed in Blits yet
986
+ *
987
+ * @important if you dont know what you're doing here, you probably shouldn't be doing it!
988
+ */
989
+ advanced?: Partial<RendererMainSettings>,
990
+ /**
991
+ * Whether or not the announcer should be activated on initialization
992
+ *
993
+ * When set to `false` announcements via `this.$annoucer.speak()` will
994
+ * be ignored. When set to `true` announcement will be spoken out via the
995
+ * text to speech API
996
+ *
997
+ * Announcer can be enabled / disabled run time as well via:
998
+ * - this.$announcer.enable()
999
+ * - this.$announcer.disable()
1000
+ * - this.$announcer.toggle(true/false)
1001
+ *
1002
+ * @default false
1003
+ */
1004
+ announcer?: boolean
1005
+ }
1006
+
1007
+ interface State {
1008
+ [key: string]: any
1009
+ }
1010
+
1011
+ interface Methods {
1012
+ [key: string]: any
1013
+ }
1014
+
1015
+ interface Watch {
1016
+ [key: string]: any
1017
+ }
1018
+
1019
+ interface Computed {
1020
+ [key: string]: any
1021
+ }
1022
+
1023
+
1024
+ interface Plugin {
1025
+ /**
1026
+ * Name of the plugin. The plugin will be accessible on each Component's
1027
+ * `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
1028
+ */
1029
+ name: string,
1030
+ /**
1031
+ * Singleton function that will be used to instantiate the plugin.
1032
+ * Should do all necessary setup and ideally return an object with
1033
+ * properties or methods that can be used in the App
1034
+ */
1035
+ plugin: () => any
1036
+ }
1037
+
1038
+
1039
+ /**
1040
+ * Blits App Framework
1041
+ */
1042
+ export interface Blits {
1043
+ /**
1044
+ * Blits Application
1045
+ * @param {ApplicationConfig} config - Application Configuration object
1046
+ */
1047
+ Application<
1048
+ P extends Props,
1049
+ S extends State,
1050
+ M extends Methods,
1051
+ C extends Computed,
1052
+ W extends Watch>(config: ApplicationConfig<P, S, M, C, W>) : ComponentFactory
1053
+ /**
1054
+ * Blits Component
1055
+ * @param {string} name - The name of the Component
1056
+ * @param {ComponentConfig} config - Component Configuration object
1057
+ */
1058
+ Component<
1059
+ P extends Props,
1060
+ S extends State,
1061
+ M extends Methods,
1062
+ C extends Computed,
1063
+ W extends Watch>(name: string, config: ComponentConfig<P, S, M, C, W>) : ComponentFactory
1064
+ /**
1065
+ * Blits Launch
1066
+ */
1067
+ Launch(App: ComponentFactory, target: HTMLElement | String, settings?: Settings) : void
1068
+ /**
1069
+ * Blits Plugin
1070
+ *
1071
+ * @param plugin
1072
+ * Plugin object or singleton function that will be used to instantiate the
1073
+ * plugin. Should do all necessary setup and ideally return an object with
1074
+ * properties or methods that can be used in the App
1075
+ *
1076
+ * @param nameOrOptions
1077
+ * Name of the plugin or options object, to be passed into the plugin instantiation.
1078
+ *
1079
+ * When passing a string, the value will be used as **name** of the plugin. The plugin
1080
+ * will be accessible on each Component's `this` scope under this name, prefixed with a `$`
1081
+ * (i.e. myplugin => `this.$myplugin`)
1082
+ *
1083
+ * Passing a name is **required** when `plugin` argument is a singleton function
1084
+ *
1085
+ * When passing an object, the value will be considered to be an `options` object.
1086
+ * The options object will be passed into the plugin instantiation method. Can
1087
+ * be used to set default values
1088
+ *
1089
+ * @param options
1090
+ * Object with options to be passed into the plugin instantiation method.
1091
+ * Can be used to set default values
1092
+ */
1093
+ Plugin(plugin: Plugin, nameOrOptions?: string | object , options?: object) : void
1094
+ }
1095
+
1096
+ const Blits: Blits;
1097
+
1098
+ export default Blits;
1099
+ }