@lightningjs/blits 0.9.8 → 0.10.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 (44) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/boilerplate/common/public/fonts/Lato-Regular.ttf +0 -0
  3. package/boilerplate/common/public/fonts/Raleway-ExtraBold.ttf +0 -0
  4. package/docs/transitions_animations/transitions.md +3 -3
  5. package/package.json +3 -4
  6. package/src/application.d.ts +10 -10
  7. package/src/component/base/announcer.js +27 -0
  8. package/src/component/base/events.js +37 -0
  9. package/src/component/base/index.js +29 -0
  10. package/src/component/base/log.js +27 -0
  11. package/src/component/base/methods.js +136 -0
  12. package/src/component/base/router.js +40 -0
  13. package/src/component/base/timeouts_intervals.js +92 -0
  14. package/src/component/base/utils.js +29 -0
  15. package/src/{lib → component}/setup/computed.js +3 -3
  16. package/src/component/setup/index.js +61 -0
  17. package/src/{lib → component}/setup/input.js +4 -4
  18. package/src/{lib → component}/setup/methods.js +3 -3
  19. package/src/{lib → component}/setup/props.js +3 -3
  20. package/src/{lib → component}/setup/routes.js +3 -3
  21. package/src/{lib → component}/setup/state.js +13 -6
  22. package/src/{lib → component}/setup/watch.js +5 -5
  23. package/src/component.d.ts +157 -38
  24. package/src/component.js +145 -154
  25. package/src/components/Circle.js +5 -5
  26. package/src/components/FPScounter.js +249 -185
  27. package/src/components/Image.js +2 -2
  28. package/src/components/RouterView.js +1 -1
  29. package/src/components/Sprite.js +5 -5
  30. package/src/components/Sprite.orig.js +2 -2
  31. package/src/components/Text.js +11 -11
  32. package/src/components/index.js +32 -0
  33. package/src/components/index.orig.js +32 -0
  34. package/src/engines/L3/element.js +41 -35
  35. package/src/engines/L3/fontLoader.js +16 -2
  36. package/src/engines/L3/launch.js +1 -1
  37. package/src/lib/codegenerator/generator.js +18 -8
  38. package/vite/msdfGenerator.js +52 -53
  39. package/boilerplate/common/public/fonts/Lato-Regular.msdf.json +0 -5383
  40. package/boilerplate/common/public/fonts/Lato-Regular.msdf.png +0 -0
  41. package/boilerplate/common/public/fonts/Raleway-ExtraBold.msdf.json +0 -10838
  42. package/boilerplate/common/public/fonts/Raleway-ExtraBold.msdf.png +0 -0
  43. package/src/lib/setup/base.js +0 -288
  44. /package/src/{lib → component}/setup/props.test.js +0 -0
@@ -1,288 +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 { renderer } from '../../launch.js'
19
- import Focus from '../../focus.js'
20
- import { to, currentRoute, navigating, back } from '../../router/router.js'
21
- import Image from '../../components/Image.js'
22
- import Circle from '../../components/Circle.js'
23
- import RouterView from '../../components/RouterView.js'
24
- import Sprite from '../../components/Sprite.js'
25
- import Text from '../../components/Text.js'
26
- import FPScounter from '../../components/FPScounter.js'
27
- import eventListeners from '../eventListeners.js'
28
- import { default as log, Log } from '../log.js'
29
- import symbols from '../symbols.js'
30
-
31
- import { trigger } from '../reactivity/effect.js'
32
- import Announcer from '../../announcer/announcer.js'
33
-
34
- const shaderAlias = {
35
- rounded: 'radius',
36
- }
37
-
38
- export default (component, name) => {
39
- Object.defineProperties(component.prototype, {
40
- name: {
41
- value: name,
42
- writable: false,
43
- enumerable: true,
44
- configurable: false,
45
- },
46
- [symbols.identifier]: {
47
- value: component[symbols.identifier],
48
- writable: false,
49
- enumerable: false,
50
- configurable: false,
51
- },
52
- focus: {
53
- value: function (e) {
54
- this[symbols.state].hasFocus = true
55
- Focus.set(this, e)
56
- },
57
- writable: false,
58
- enumerable: true,
59
- configurable: false,
60
- },
61
- unfocus: {
62
- value: function () {
63
- this[symbols.state].hasFocus = false
64
- this.lifecycle.state = 'unfocus'
65
- },
66
- writable: false,
67
- enumerable: true,
68
- configurable: false,
69
- },
70
- destroy: {
71
- value: function () {
72
- this.lifecycle.state = 'destroy'
73
- this.$clearTimeouts()
74
- this.$clearIntervals()
75
- eventListeners.removeListeners(this)
76
- deleteChildren(this[symbols.children])
77
- Log.debug(`Destroyed component ${this.componentId}`)
78
- },
79
- writable: false,
80
- enumerable: true,
81
- configurable: false,
82
- },
83
- select: {
84
- value: function (ref) {
85
- let selected = null
86
- this[symbols.children].forEach((child) => {
87
- if (Array.isArray(child)) {
88
- child.forEach((c) => {
89
- if (c['ref'] === ref) selected = c
90
- })
91
- } else if (Object.getPrototypeOf(child) === Object.prototype) {
92
- Object.keys(child).forEach((k) => {
93
- if (child[k]['ref'] === ref) selected = child[k]
94
- })
95
- } else {
96
- if (child['ref'] === ref) selected = child
97
- }
98
- })
99
-
100
- return selected
101
- },
102
- writable: false,
103
- enumerable: true,
104
- configurable: false,
105
- },
106
- shader: {
107
- value: function (type, args) {
108
- const target = shaderAlias[type] || type
109
- const shaders = renderer.driver.stage.shManager.getRegisteredEffects()
110
-
111
- if (target in shaders) {
112
- return {
113
- type: target,
114
- props: args,
115
- }
116
- } else {
117
- Log.error(`Shader ${type} not found`)
118
- }
119
- },
120
- writable: false,
121
- enumerable: false,
122
- configurable: false,
123
- },
124
- $router: {
125
- value: {
126
- to,
127
- back,
128
- get currentRoute() {
129
- return currentRoute
130
- },
131
- get routes() {
132
- return component.prototype[symbols.routes]
133
- },
134
- get navigating() {
135
- return navigating
136
- },
137
- },
138
- writable: false,
139
- enumerable: true,
140
- configurable: false,
141
- },
142
- [symbols.components]: {
143
- value: {
144
- Image: Image(),
145
- Circle: Circle(),
146
- RouterView: RouterView(),
147
- Sprite: Sprite(),
148
- Text: Text(),
149
- FPScounter: FPScounter(),
150
- },
151
- writable: false,
152
- enumerable: false,
153
- configurable: false,
154
- },
155
- $setTimeout: {
156
- value: function (fn, ms, ...params) {
157
- const timeoutId = setTimeout(
158
- () => {
159
- this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
160
- fn.apply(null, params)
161
- },
162
- ms,
163
- params
164
- )
165
- this[symbols.timeouts].push(timeoutId)
166
- return timeoutId
167
- },
168
- writable: false,
169
- enumerable: true,
170
- configurable: false,
171
- },
172
- $clearTimeout: {
173
- value: function (timeoutId) {
174
- if (this[symbols.timeouts].indexOf(timeoutId) > -1) {
175
- this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
176
- clearTimeout(timeoutId)
177
- }
178
- },
179
- writable: false,
180
- enumerable: true,
181
- configurable: false,
182
- },
183
- $clearTimeouts: {
184
- value: function () {
185
- for (let i = 0; i < this[symbols.timeouts].length; i++) {
186
- clearTimeout(this[symbols.timeouts][i])
187
- }
188
- this[symbols.timeouts] = []
189
- },
190
- writable: false,
191
- enumerable: true,
192
- configurable: false,
193
- },
194
- $setInterval: {
195
- value: function (fn, ms, ...params) {
196
- const intervalId = setInterval(() => fn.apply(null, params), ms, params)
197
- this[symbols.intervals].push(intervalId)
198
- return intervalId
199
- },
200
- writable: false,
201
- enumerable: true,
202
- configurable: false,
203
- },
204
- $clearInterval: {
205
- value: function (intervalId) {
206
- if (this[symbols.intervals].indexOf(intervalId) > -1) {
207
- this[symbols.intervals] = this[symbols.intervals].filter((id) => id !== intervalId)
208
- clearInterval(intervalId)
209
- }
210
- },
211
- writable: false,
212
- enumerable: true,
213
- configurable: false,
214
- },
215
- $clearIntervals: {
216
- value: function () {
217
- for (let i = 0; i < this[symbols.intervals].length; i++) {
218
- clearInterval(this[symbols.intervals][i])
219
- }
220
- this[symbols.intervals] = []
221
- },
222
- writable: false,
223
- enumerable: true,
224
- configurable: false,
225
- },
226
- $emit: {
227
- value: function (event, params) {
228
- eventListeners.executeListeners(event, params)
229
- },
230
- writable: false,
231
- enumerable: true,
232
- configurable: false,
233
- },
234
- $listen: {
235
- value: function (event, callback) {
236
- eventListeners.registerListener(this, event, callback)
237
- },
238
- writable: false,
239
- enumerable: true,
240
- configurable: false,
241
- },
242
- [symbols.renderer]: {
243
- value: renderer,
244
- writable: false,
245
- enumerable: false,
246
- configurable: false,
247
- },
248
- $log: {
249
- value: log('App'),
250
- writable: false,
251
- enumerable: false,
252
- configurable: false,
253
- },
254
- $trigger: {
255
- value: function (key) {
256
- // trigger with force set to true
257
- trigger(this[symbols.originalState], key, true)
258
- },
259
- writable: false,
260
- enumerable: false,
261
- configurable: false,
262
- },
263
- $announcer: {
264
- value: Announcer,
265
- writable: false,
266
- enumerable: false,
267
- configurable: false,
268
- },
269
- })
270
- }
271
-
272
- const deleteChildren = function (children) {
273
- for (let i = 0; i < children.length; i++) {
274
- if (!children[i]) return
275
- // call destroy when method is available on child
276
- if (children[i].destroy && typeof children[i].destroy === 'function') {
277
- children[i].destroy()
278
- }
279
- // recursively call deleteChildren when it's an object of items (happens when using a forloop construct)
280
- else if (Object.getPrototypeOf(children[i]) === Object.prototype) {
281
- deleteChildren(Object.values(children[i]))
282
- }
283
-
284
- children[i] = null
285
- }
286
-
287
- children.length = 0
288
- }
File without changes