@lightningjs/blits 0.9.8 → 0.9.9
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 +12 -0
- package/docs/transitions_animations/transitions.md +3 -3
- package/package.json +2 -2
- package/src/application.d.ts +10 -10
- package/src/component/base/announcer.js +27 -0
- package/src/component/base/events.js +37 -0
- package/src/component/base/index.js +29 -0
- package/src/component/base/log.js +27 -0
- package/src/component/base/methods.js +136 -0
- package/src/component/base/router.js +40 -0
- package/src/component/base/timeouts_intervals.js +92 -0
- package/src/component/base/utils.js +29 -0
- package/src/{lib → component}/setup/computed.js +3 -3
- package/src/component/setup/index.js +61 -0
- package/src/{lib → component}/setup/input.js +4 -4
- package/src/{lib → component}/setup/methods.js +3 -3
- package/src/{lib → component}/setup/props.js +3 -3
- package/src/{lib → component}/setup/routes.js +3 -3
- package/src/{lib → component}/setup/state.js +13 -6
- package/src/{lib → component}/setup/watch.js +5 -5
- package/src/component.d.ts +157 -38
- package/src/component.js +145 -154
- package/src/components/Circle.js +5 -5
- package/src/components/FPScounter.js +57 -89
- package/src/components/Image.js +2 -2
- package/src/components/RouterView.js +1 -1
- package/src/components/Sprite.js +5 -5
- package/src/components/Sprite.orig.js +2 -2
- package/src/components/Text.js +11 -11
- package/src/components/index.js +32 -0
- package/src/components/index.orig.js +32 -0
- package/src/engines/L3/element.js +41 -35
- package/src/engines/L3/launch.js +1 -1
- package/src/lib/codegenerator/generator.js +7 -6
- package/src/lib/setup/base.js +0 -288
- /package/src/{lib → component}/setup/props.test.js +0 -0
|
@@ -240,6 +240,10 @@ const Props = {
|
|
|
240
240
|
set textAlign(v) {
|
|
241
241
|
this._props.textAlign = v
|
|
242
242
|
},
|
|
243
|
+
set rtt(v) {
|
|
244
|
+
this._props.rtt = v
|
|
245
|
+
this._set.add('rtt')
|
|
246
|
+
},
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
const Element = {
|
|
@@ -271,9 +275,12 @@ const Element = {
|
|
|
271
275
|
// correct for default white nodes (but not for text nodes)
|
|
272
276
|
if (!props.__textnode && !this.props._set.has('color')) {
|
|
273
277
|
this.props._props.color =
|
|
274
|
-
this.props._set.has('src') ||
|
|
278
|
+
this.props._set.has('src') ||
|
|
279
|
+
this.props._set.has('texture') ||
|
|
280
|
+
(this.props._set.has('rtt') && this.props._props.rtt === true)
|
|
281
|
+
? 0xffffffff
|
|
282
|
+
: 0
|
|
275
283
|
}
|
|
276
|
-
|
|
277
284
|
this.node = props.__textnode
|
|
278
285
|
? renderer.createTextNode(this.props._props)
|
|
279
286
|
: renderer.createNode(this.props._props)
|
|
@@ -312,7 +319,8 @@ const Element = {
|
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
321
|
},
|
|
315
|
-
animate(prop, value, transition) {
|
|
322
|
+
async animate(prop, value, transition) {
|
|
323
|
+
// if current value is the same as the value to animate to, instantly resolve
|
|
316
324
|
if (this.node[prop] === value) return Promise.resolve()
|
|
317
325
|
// check if a transition is already scheduled or running on the same prop
|
|
318
326
|
if (this.scheduledTransitions[prop]) {
|
|
@@ -345,39 +353,37 @@ const Element = {
|
|
|
345
353
|
delay: typeof transition === 'object' ? ('delay' in transition ? transition.delay : 0) : 0,
|
|
346
354
|
})
|
|
347
355
|
|
|
348
|
-
//
|
|
349
|
-
|
|
350
|
-
const startValue = this.node[prop]
|
|
351
|
-
this.scheduledTransitions[prop] = {
|
|
352
|
-
v: props[prop],
|
|
353
|
-
cancel: false,
|
|
354
|
-
f,
|
|
355
|
-
}
|
|
356
|
+
// capture the current value to be used in the transition start
|
|
357
|
+
const startValue = this.node[prop]
|
|
356
358
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
359
|
+
// schedule the transition for this prop, so it can be canceled /
|
|
360
|
+
// removed if another transition for the same prop starts in the mean time
|
|
361
|
+
this.scheduledTransitions[prop] = {
|
|
362
|
+
v: props[prop],
|
|
363
|
+
cancel: false,
|
|
364
|
+
f,
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// wait until the animation really starts (depending on specified delay)
|
|
368
|
+
const animation = await f.start().waitUntilStarted()
|
|
369
|
+
|
|
370
|
+
// fire transition start callback if specified
|
|
371
|
+
transition.start &&
|
|
372
|
+
typeof transition.start === 'function' &&
|
|
373
|
+
transition.start.call(this.component, this, prop, startValue)
|
|
374
|
+
|
|
375
|
+
// wait until the animation ends
|
|
376
|
+
const finished = await animation.waitUntilStopped()
|
|
377
|
+
|
|
378
|
+
// removed the prop from scheduled transitions
|
|
379
|
+
delete this.scheduledTransitions[prop]
|
|
380
|
+
|
|
381
|
+
// fire transition end callback if specified
|
|
382
|
+
transition.end &&
|
|
383
|
+
typeof transition.end === 'function' &&
|
|
384
|
+
transition.end.call(this.component, this, prop, this.node[prop])
|
|
385
|
+
|
|
386
|
+
return Promise.resolve()
|
|
381
387
|
},
|
|
382
388
|
destroy() {
|
|
383
389
|
Log.debug('Deleting Node', this.nodeId)
|
package/src/engines/L3/launch.js
CHANGED
|
@@ -24,7 +24,7 @@ import fontLoader from './fontLoader.js'
|
|
|
24
24
|
|
|
25
25
|
export let renderer
|
|
26
26
|
|
|
27
|
-
export default (App, target, settings) => {
|
|
27
|
+
export default (App, target, settings = {}) => {
|
|
28
28
|
const driver = new MainCoreDriver()
|
|
29
29
|
// settings.multithreaded === true
|
|
30
30
|
// ? new ThreadXRenderDriver({
|
|
@@ -29,8 +29,10 @@ export default function (templateObject = { children: [] }) {
|
|
|
29
29
|
ctx.renderCode.push('return elms')
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
|
-
render: new Function('parent', 'component', 'context', ctx.renderCode.join('\n')),
|
|
33
|
-
effects: ctx.effectsCode.map(
|
|
32
|
+
render: new Function('parent', 'component', 'context', 'components', ctx.renderCode.join('\n')),
|
|
33
|
+
effects: ctx.effectsCode.map(
|
|
34
|
+
(code) => new Function('component', 'elms', 'context', 'components', code)
|
|
35
|
+
),
|
|
34
36
|
context: ctx.context,
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -119,8 +121,7 @@ const generateComponentCode = function (
|
|
|
119
121
|
const cmp${counter} =
|
|
120
122
|
(context.components && context.components['${
|
|
121
123
|
templateObject[Symbol.for('componentType')]
|
|
122
|
-
}']) ||
|
|
123
|
-
component[Symbol.for('components')]['${templateObject[Symbol.for('componentType')]}']
|
|
124
|
+
}']) || components['${templateObject[Symbol.for('componentType')]}']
|
|
124
125
|
`)
|
|
125
126
|
|
|
126
127
|
if ('key' in templateObject) {
|
|
@@ -174,7 +175,7 @@ const generateComponentCode = function (
|
|
|
174
175
|
templateObject[Symbol.for('componentType')]
|
|
175
176
|
}'
|
|
176
177
|
|
|
177
|
-
${elm} = (context.components && context.components[componentType] ||
|
|
178
|
+
${elm} = (context.components && context.components[componentType] || components[componentType] || (() => { console.error('component ${
|
|
178
179
|
templateObject[Symbol.for('componentType')]
|
|
179
180
|
} not found')})).call(null, {props: props${counter}}, ${parent}, component)
|
|
180
181
|
if (${elm}[Symbol.for('slots')][0]) {
|
|
@@ -215,7 +216,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
if (parent) {
|
|
218
|
-
ctx.renderCode.push(`parent = ${parent}`)
|
|
219
|
+
ctx.renderCode.push(`let parent = ${parent}`)
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
const forStartCounter = counter
|
package/src/lib/setup/base.js
DELETED
|
@@ -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
|