@lightningjs/blits 1.7.1 → 1.8.1
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 +19 -0
- package/docs/essentials/displaying_text.md +53 -1
- package/docs/transitions_animations/transitions.md +21 -1
- package/index.d.ts +819 -14
- package/package.json +5 -4
- package/src/components/FPScounter.js +12 -0
- package/src/engines/L3/element.js +9 -1
- package/src/helpers/deepEqualArray.js +50 -0
- package/src/helpers/deepEqualArray.test.js +127 -0
- package/src/lib/codegenerator/generator.js +5 -6
- package/src/lib/reactivity/reactive.js +15 -8
- package/vite/msdfGenerator.js +89 -10
- package/src/application.d.ts +0 -174
- package/src/component.d.ts +0 -455
- package/src/launch.d.ts +0 -273
- package/src/plugin.d.ts +0 -71
package/src/launch.d.ts
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
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
|
-
import ApplicationInstance from './application'
|
|
19
|
-
import {type Stage, type ShaderEffect as RendererShaderEffect, type WebGlCoreShader} from '@lightningjs/renderer'
|
|
20
|
-
interface WebFont {
|
|
21
|
-
/**
|
|
22
|
-
* Name of the font family
|
|
23
|
-
*/
|
|
24
|
-
family: string,
|
|
25
|
-
/**
|
|
26
|
-
* Type of font (web)
|
|
27
|
-
*/
|
|
28
|
-
type: 'web',
|
|
29
|
-
/**
|
|
30
|
-
* Location to the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
|
|
31
|
-
*/
|
|
32
|
-
file: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface SdfFontWithFile {
|
|
36
|
-
/**
|
|
37
|
-
* Location of the font file (i.e. `/fonts/OpenSans-Medium.ttf`)
|
|
38
|
-
*/
|
|
39
|
-
file: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface SdfFontWithPngJson {
|
|
43
|
-
/**
|
|
44
|
-
* Location of the font map (i.e. `'/fonts/Lato-Regular.msdf.json'`)
|
|
45
|
-
*/
|
|
46
|
-
json: string,
|
|
47
|
-
/**
|
|
48
|
-
* Location of the font png (i.e. `'/fonts/Lato-Regular.msdf.png'`)
|
|
49
|
-
*/
|
|
50
|
-
png: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type SdfFont = {
|
|
54
|
-
/**
|
|
55
|
-
* Name of the font family
|
|
56
|
-
*/
|
|
57
|
-
family: string,
|
|
58
|
-
/**
|
|
59
|
-
* Type of font (msdf or sdf)
|
|
60
|
-
*/
|
|
61
|
-
type: 'msdf' | 'sdf',
|
|
62
|
-
} & (SdfFontWithFile | SdfFontWithPngJson)
|
|
63
|
-
|
|
64
|
-
type Shader = {
|
|
65
|
-
name: string,
|
|
66
|
-
type: WebGlCoreShader
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type ShaderEffect = {
|
|
70
|
-
name: string,
|
|
71
|
-
type: RendererShaderEffect
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
|
|
75
|
-
|
|
76
|
-
type Font = WebFont | SdfFont
|
|
77
|
-
|
|
78
|
-
export type DebugLevel = 0 | 1 | 2
|
|
79
|
-
export type LogTypes = 'info' | 'warn' | 'error' | 'debug'
|
|
80
|
-
export type ReactivityModes = 'Proxy' | 'defineProperty'
|
|
81
|
-
export type RenderModes = 'webgl' | 'canvas'
|
|
82
|
-
|
|
83
|
-
interface ExtensionLoader {
|
|
84
|
-
async (stage: Stage): void
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Settings
|
|
88
|
-
*
|
|
89
|
-
* Launcher function that sets up the Lightning renderer and instantiates
|
|
90
|
-
* the Blits App
|
|
91
|
-
*/
|
|
92
|
-
export interface Settings {
|
|
93
|
-
/**
|
|
94
|
-
* Width of the Application
|
|
95
|
-
*/
|
|
96
|
-
w?: number,
|
|
97
|
-
/**
|
|
98
|
-
* Height of the Application
|
|
99
|
-
*/
|
|
100
|
-
h?: number,
|
|
101
|
-
/**
|
|
102
|
-
* Whether to enable multithreaded
|
|
103
|
-
*/
|
|
104
|
-
multithreaded?: boolean,
|
|
105
|
-
/**
|
|
106
|
-
* Debug level for console log messages
|
|
107
|
-
*/
|
|
108
|
-
debugLevel?: DebugLevel | LogTypes[],
|
|
109
|
-
/**
|
|
110
|
-
* Fonts to be used in the Application
|
|
111
|
-
*/
|
|
112
|
-
fonts?: Font[],
|
|
113
|
-
/**
|
|
114
|
-
* Effects to be used by DynamicShader
|
|
115
|
-
*/
|
|
116
|
-
effects?: ShaderEffect[],
|
|
117
|
-
/**
|
|
118
|
-
* Shaders to be used in the application
|
|
119
|
-
*/
|
|
120
|
-
shaders?: Shader[],
|
|
121
|
-
/**
|
|
122
|
-
* Default font family to use in the Application when no font attribute is specified
|
|
123
|
-
* on a Text-component
|
|
124
|
-
*
|
|
125
|
-
* The default font must be registered in the `fonts` array in the settings.
|
|
126
|
-
*
|
|
127
|
-
* Defaults to `sans-serif` font family, which is the default of the Lightning Renderer
|
|
128
|
-
*/
|
|
129
|
-
defaultFont?: string,
|
|
130
|
-
/**
|
|
131
|
-
* Custom keymapping
|
|
132
|
-
*/
|
|
133
|
-
keymap?: object,
|
|
134
|
-
/**
|
|
135
|
-
* Mode of reactivity (`Proxy` or `defineProperty`)
|
|
136
|
-
*/
|
|
137
|
-
reactivityMode?: ReactivityModes,
|
|
138
|
-
/**
|
|
139
|
-
* Screen resolution of the device, defining the pixelRatio used to convert dimensions
|
|
140
|
-
* and positions in the App code to the actual device logical coordinates
|
|
141
|
-
*
|
|
142
|
-
* If not supplied, Blits will try to autodetect the device screen resolution. Otherwise
|
|
143
|
-
* the exact dimensions and positions used the app code are used.
|
|
144
|
-
*
|
|
145
|
-
* Note: If the option `pixelRatio` is specified in the Settings object, this value will take presedence
|
|
146
|
-
* over the screen resolution setting.
|
|
147
|
-
*
|
|
148
|
-
* Currently 3 screen resolutions are supported, which can be defined with different alias values:
|
|
149
|
-
*
|
|
150
|
-
* For 720x1080 (1px = 0.66666667px)
|
|
151
|
-
* - hd
|
|
152
|
-
* - 720p
|
|
153
|
-
* - 720
|
|
154
|
-
*
|
|
155
|
-
* For 1080x1920 (1px = 1px)
|
|
156
|
-
* - fhd
|
|
157
|
-
* - fullhd
|
|
158
|
-
* - 1080p
|
|
159
|
-
* - 1080
|
|
160
|
-
*
|
|
161
|
-
* For 2160x3840 (1px = 2px)
|
|
162
|
-
* - 4k
|
|
163
|
-
* - 2160p
|
|
164
|
-
* - 2160
|
|
165
|
-
*/
|
|
166
|
-
screenResolution?: ScreenResolutions,
|
|
167
|
-
/**
|
|
168
|
-
* Custom pixel ratio of the device used to convert dimensions
|
|
169
|
-
* and positions in the App code to the actual device logical coordinates
|
|
170
|
-
*
|
|
171
|
-
* Takes presedence over the `screenResolution` setting
|
|
172
|
-
*
|
|
173
|
-
* Defaults to 1 if not specified
|
|
174
|
-
*/
|
|
175
|
-
pixelRatio?: number
|
|
176
|
-
/**
|
|
177
|
-
* Interval in milliseconds to receive FPS updates
|
|
178
|
-
*
|
|
179
|
-
* @remarks
|
|
180
|
-
* If set to `0`, FPS updates will be disabled.
|
|
181
|
-
*
|
|
182
|
-
* @defaultValue `1000` (disabled)
|
|
183
|
-
*/
|
|
184
|
-
fpsInterval?: number
|
|
185
|
-
/**
|
|
186
|
-
* Maximum number of web workers to spin up simultaneously for offloading functionality such
|
|
187
|
-
* as image loading to separate threads (when supported by the browser)
|
|
188
|
-
*
|
|
189
|
-
* If not specified defaults to the number of logical processers available as reported by
|
|
190
|
-
* `navigator.hardwareConcurrency` (or 2 if `navigator.hardwareConcurrency` is not supported)
|
|
191
|
-
*/
|
|
192
|
-
webWorkersLimit?: number
|
|
193
|
-
/**
|
|
194
|
-
* Background color of the canvas (also known as the clearColor)
|
|
195
|
-
*
|
|
196
|
-
* Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
|
|
197
|
-
* or a color number in rgba order (`0xff0033ff`)
|
|
198
|
-
*
|
|
199
|
-
* Defauls to transparent (`0x00000000`)
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
canvasColor?: string,
|
|
203
|
-
/**
|
|
204
|
-
* Enable inspector
|
|
205
|
-
*
|
|
206
|
-
* Enables the inspector tool for debugging and inspecting the application, the node tree
|
|
207
|
-
* will be replicated in the DOM and can be inspected using the browser's developer tools
|
|
208
|
-
*
|
|
209
|
-
* Defaults to `false`
|
|
210
|
-
*/
|
|
211
|
-
inspector?: boolean,
|
|
212
|
-
/**
|
|
213
|
-
* Add an extra margin to the viewport for earlier pre-loading of elements and components
|
|
214
|
-
*
|
|
215
|
-
* By default the Lightning renderer, only renders elements that are inside the defined viewport.
|
|
216
|
-
* Everything outside of these bounds is removed from the render tree.
|
|
217
|
-
*
|
|
218
|
-
* With the viewportMargin you have the option to _virtually_ increase the viewport area,
|
|
219
|
-
* to expedite the pre-loading of elements and / or delay the unloading of elements depending
|
|
220
|
-
* on their position in the (virtual) viewport
|
|
221
|
-
*
|
|
222
|
-
* The margin can be specified in 4 directions by defining an array [top, right, bottom, left],
|
|
223
|
-
* or as a single number which is then applied to all 4 directions equally.
|
|
224
|
-
*
|
|
225
|
-
* Defaults to `0`
|
|
226
|
-
*/
|
|
227
|
-
viewportMargin?: number | [number, number, number, number],
|
|
228
|
-
/**
|
|
229
|
-
* Threshold in `Megabytes` after which all the textures that are currently not visible
|
|
230
|
-
* within the configured viewport margin will be be freed and cleaned up
|
|
231
|
-
*
|
|
232
|
-
* When passed `0` the threshold is disabled and textures will not be actively freed
|
|
233
|
-
* and cleaned up
|
|
234
|
-
*
|
|
235
|
-
* Defaults to `200` (mb)
|
|
236
|
-
*/
|
|
237
|
-
gpuMemoryLimit?: number,
|
|
238
|
-
/**
|
|
239
|
-
* Defines which mode the renderer should operate in: `webgl` or `canvas`
|
|
240
|
-
*
|
|
241
|
-
* SDF fonts are not supported in _canvas_ renderMode. Instead, _web_ fonts should
|
|
242
|
-
* be used. Also note that Canvas2d rendering doesnt support the use of shaders.
|
|
243
|
-
*
|
|
244
|
-
* Defaults to `webgl`
|
|
245
|
-
*/
|
|
246
|
-
renderMode?: RenderModes,
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* The time, in milliseconds, after which Blits considers a key press a _hold_ key press
|
|
250
|
-
*
|
|
251
|
-
* During a hold key press the focus delegation behaviour is different: when scrolling
|
|
252
|
-
* through a long list, focus is not handed over to each individual list item, creating a
|
|
253
|
-
* smoother experience
|
|
254
|
-
*
|
|
255
|
-
* Defaults to `50` (ms)
|
|
256
|
-
*/
|
|
257
|
-
holdTimeout?: number
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Blits.Launch()
|
|
262
|
-
*
|
|
263
|
-
* Launcher function that sets up the Lightning renderer and instantiates
|
|
264
|
-
* the Blits App
|
|
265
|
-
*/
|
|
266
|
-
declare function Launch(
|
|
267
|
-
App: ApplicationInstance,
|
|
268
|
-
target: HTMLElement | string,
|
|
269
|
-
settings?: Settings,
|
|
270
|
-
) : void
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
export default Launch;
|
package/src/plugin.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2024 Comcast Cable Communications Management, LLC
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
declare namespace Plugin {
|
|
20
|
-
|
|
21
|
-
interface Plugin {
|
|
22
|
-
/**
|
|
23
|
-
* Name of the plugin. The plugin will be accessible on each Component's
|
|
24
|
-
* `this` scope under this name, prefixed with a `$` (i.e. myplugin => `this.$myplugin`)
|
|
25
|
-
*/
|
|
26
|
-
name: string,
|
|
27
|
-
/**
|
|
28
|
-
* Singleton function that will be used to instantiate the plugin.
|
|
29
|
-
* Should do all necessary setup and ideally return an object with
|
|
30
|
-
* properties or methods that can be used in the App
|
|
31
|
-
*/
|
|
32
|
-
plugin: () => any
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Blits.Plugin()
|
|
40
|
-
*
|
|
41
|
-
* Method to register a plugin
|
|
42
|
-
*/
|
|
43
|
-
declare function Plugin(
|
|
44
|
-
/**
|
|
45
|
-
* Plugin object or singleton function that will be used to instantiate the
|
|
46
|
-
* plugin. Should do all necessary setup and ideally return an object with
|
|
47
|
-
* properties or methods that can be used in the App
|
|
48
|
-
*/
|
|
49
|
-
plugin: Plugin.Plugin | (() => any),
|
|
50
|
-
/**
|
|
51
|
-
* Name of the plugin or options object, to be passed into the plugin instantiation.
|
|
52
|
-
*
|
|
53
|
-
* When passing a string, the value will be used as **name** of the plugin. The plugin
|
|
54
|
-
* will be accessible on each Component's `this` scope under this name, prefixed with a `$`
|
|
55
|
-
* (i.e. myplugin => `this.$myplugin`)
|
|
56
|
-
*
|
|
57
|
-
* Passing a name is **required** when `plugin` argument is a singleton function
|
|
58
|
-
*
|
|
59
|
-
* When passing an object, the value will be considered to be an `options` object.
|
|
60
|
-
* The options object will be passed into the plugin instantiation method. Can
|
|
61
|
-
* be used to set default values
|
|
62
|
-
*/
|
|
63
|
-
nameOrOptions?: string | object,
|
|
64
|
-
/**
|
|
65
|
-
* Object with options to be passed into the plugin instantiation method.
|
|
66
|
-
* Can be used to set default values
|
|
67
|
-
*/
|
|
68
|
-
options?: object
|
|
69
|
-
) : void
|
|
70
|
-
|
|
71
|
-
export default Plugin;
|