@lightningjs/blits 0.6.5 → 0.6.6
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 +8 -0
- package/boilerplate/package.json +1 -1
- package/package.json +1 -1
- package/src/application.js +1 -3
- package/src/element.js +15 -6
- package/src/lib/codegenerator/generator.js +13 -3
- package/src/lib/codegenerator/generator.test_.js +23 -23
- package/src/lib/symbols.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# v0.6.6
|
|
4
|
+
|
|
5
|
+
_24 jan 2024_
|
|
6
|
+
|
|
7
|
+
- Added temporary fix for renderer issue [#123](https://github.com/lightning-js/renderer/issues/123)
|
|
8
|
+
- Fixed issue with setting mount, pivot and scale values to zero (0) in object literal with x and y key
|
|
9
|
+
- Added automatic mapping of ref string to each item in a for-loop
|
|
10
|
+
|
|
3
11
|
# v0.6.5
|
|
4
12
|
|
|
5
13
|
_16 jan 2024_
|
package/boilerplate/package.json
CHANGED
package/package.json
CHANGED
package/src/application.js
CHANGED
package/src/element.js
CHANGED
|
@@ -51,6 +51,8 @@ const unpackTransition = (obj) => {
|
|
|
51
51
|
return obj
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
let firstNode = false
|
|
55
|
+
|
|
54
56
|
const Props = {
|
|
55
57
|
set parent(v) {
|
|
56
58
|
this._props.parent = v === 'root' ? renderer.root : v.node
|
|
@@ -126,11 +128,11 @@ const Props = {
|
|
|
126
128
|
},
|
|
127
129
|
set mount(v) {
|
|
128
130
|
if (typeof v === 'object' || (isObjectString(v) && (v = parseToObject(v)))) {
|
|
129
|
-
if (v
|
|
131
|
+
if ('x' in v) {
|
|
130
132
|
this._props.mountX = v.x
|
|
131
133
|
this._set.add('mountX')
|
|
132
134
|
}
|
|
133
|
-
if (v
|
|
135
|
+
if ('y' in v) {
|
|
134
136
|
this._props.mountY = v.y
|
|
135
137
|
this._set.add('mountY')
|
|
136
138
|
}
|
|
@@ -142,11 +144,11 @@ const Props = {
|
|
|
142
144
|
},
|
|
143
145
|
set pivot(v) {
|
|
144
146
|
if (typeof v === 'object' || (isObjectString(v) && (v = parseToObject(v)))) {
|
|
145
|
-
if (v
|
|
147
|
+
if ('x' in v) {
|
|
146
148
|
this._set.add('pivotX')
|
|
147
149
|
this._props.pivotX = v.x
|
|
148
150
|
}
|
|
149
|
-
if (v
|
|
151
|
+
if ('y' in v) {
|
|
150
152
|
this._set.add('pivotY')
|
|
151
153
|
this._props.pivotY = v.y
|
|
152
154
|
}
|
|
@@ -158,8 +160,8 @@ const Props = {
|
|
|
158
160
|
},
|
|
159
161
|
set scale(v) {
|
|
160
162
|
if (typeof v === 'object' || (isObjectString(v) && (v = parseToObject(v)))) {
|
|
161
|
-
if (v
|
|
162
|
-
if (v
|
|
163
|
+
if ('x' in v) this._props.scaleX = v.x
|
|
164
|
+
if ('y' in v) this._props.scaleY = v.y
|
|
163
165
|
} else {
|
|
164
166
|
this._props.scale = v
|
|
165
167
|
}
|
|
@@ -239,6 +241,13 @@ const Element = {
|
|
|
239
241
|
this.props._set.has('src') || this.props._set.has('texture') ? 0xffffffff : 0
|
|
240
242
|
}
|
|
241
243
|
|
|
244
|
+
// temporary workaround for renderer issue https://github.com/lightning-js/renderer/issues/123
|
|
245
|
+
if (!firstNode) {
|
|
246
|
+
this.props._props.src =
|
|
247
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII='
|
|
248
|
+
firstNode = true
|
|
249
|
+
}
|
|
250
|
+
|
|
242
251
|
this.node = props.__textnode
|
|
243
252
|
? renderer.createTextNode(this.props._props)
|
|
244
253
|
: renderer.createNode(this.props._props)
|
|
@@ -56,7 +56,7 @@ const generateElementCode = function (
|
|
|
56
56
|
|
|
57
57
|
renderCode.push(`
|
|
58
58
|
if(!${elm}) {
|
|
59
|
-
${elm} = this.element({
|
|
59
|
+
${elm} = this.element({parent: parent || 'root'}, component)
|
|
60
60
|
}
|
|
61
61
|
const elementConfig${counter} = {}
|
|
62
62
|
`)
|
|
@@ -221,9 +221,19 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
221
221
|
const scope = Object.assign(component, {
|
|
222
222
|
key: Math.random(),
|
|
223
223
|
${index}: __index,
|
|
224
|
-
${item}: collection[__index]
|
|
225
|
-
|
|
224
|
+
${item}: collection[__index],
|
|
225
|
+
`)
|
|
226
|
+
|
|
227
|
+
if ('ref' in templateObject && templateObject.ref.indexOf('$') === -1) {
|
|
228
|
+
// automatically map the ref for each item in the loop based on the given ref key
|
|
229
|
+
ctx.renderCode.push(`
|
|
230
|
+
__ref: '${templateObject.ref}' + __index
|
|
226
231
|
`)
|
|
232
|
+
templateObject.ref = '$__ref'
|
|
233
|
+
}
|
|
234
|
+
ctx.renderCode.push(`
|
|
235
|
+
})
|
|
236
|
+
`)
|
|
227
237
|
|
|
228
238
|
if ('key' in templateObject) {
|
|
229
239
|
ctx.renderCode.push(`
|
|
@@ -107,7 +107,7 @@ test('Generate render and effect code for a template with a single simple elemen
|
|
|
107
107
|
function anonymous(parent,component,context) {
|
|
108
108
|
const elms = []
|
|
109
109
|
|
|
110
|
-
elms[1] = this.element(
|
|
110
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
111
111
|
const elementConfig1 = {}
|
|
112
112
|
|
|
113
113
|
elementConfig1['type'] = "Component"
|
|
@@ -149,7 +149,7 @@ test('Generate code for a template with a simple element and a simple nested ele
|
|
|
149
149
|
function anonymous(parent,component,context) {
|
|
150
150
|
const elms = []
|
|
151
151
|
|
|
152
|
-
elms[1] = this.element(
|
|
152
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
153
153
|
const elementConfig1 = {}
|
|
154
154
|
|
|
155
155
|
elementConfig1['type'] = "Component"
|
|
@@ -158,7 +158,7 @@ test('Generate code for a template with a simple element and a simple nested ele
|
|
|
158
158
|
|
|
159
159
|
parent = elms[1]
|
|
160
160
|
|
|
161
|
-
elms[2] = this.element(
|
|
161
|
+
elms[2] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
162
162
|
const elementConfig2 = {}
|
|
163
163
|
|
|
164
164
|
elementConfig2['type'] = "Element"
|
|
@@ -198,7 +198,7 @@ test('Generate code for a template with a single element with attributes', (asse
|
|
|
198
198
|
function anonymous(parent,component,context) {
|
|
199
199
|
const elms = []
|
|
200
200
|
|
|
201
|
-
elms[1] = this.element(
|
|
201
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
202
202
|
const elementConfig1 = {}
|
|
203
203
|
|
|
204
204
|
elementConfig1['type'] = "Component"
|
|
@@ -246,7 +246,7 @@ test('Generate code for a template with attributes and a nested element with att
|
|
|
246
246
|
function anonymous(parent,component,context) {
|
|
247
247
|
const elms = []
|
|
248
248
|
|
|
249
|
-
elms[1] = this.element(
|
|
249
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
250
250
|
const elementConfig1 = {}
|
|
251
251
|
|
|
252
252
|
elementConfig1['type'] = "Component"
|
|
@@ -257,7 +257,7 @@ test('Generate code for a template with attributes and a nested element with att
|
|
|
257
257
|
|
|
258
258
|
parent = elms[1]
|
|
259
259
|
|
|
260
|
-
elms[2] = this.element(
|
|
260
|
+
elms[2] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
261
261
|
const elementConfig2 = {}
|
|
262
262
|
|
|
263
263
|
elementConfig2['type'] = "Element"
|
|
@@ -313,7 +313,7 @@ test('Generate code for a template with attributes and 2 nested elements with at
|
|
|
313
313
|
function anonymous(parent,component,context) {
|
|
314
314
|
const elms = []
|
|
315
315
|
|
|
316
|
-
elms[1] = this.element(
|
|
316
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
317
317
|
const elementConfig1 = {}
|
|
318
318
|
|
|
319
319
|
elementConfig1['type'] = "Component"
|
|
@@ -324,7 +324,7 @@ test('Generate code for a template with attributes and 2 nested elements with at
|
|
|
324
324
|
|
|
325
325
|
parent = elms[1]
|
|
326
326
|
|
|
327
|
-
elms[2] = this.element(
|
|
327
|
+
elms[2] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
328
328
|
const elementConfig2 = {}
|
|
329
329
|
|
|
330
330
|
elementConfig2['type'] = "Element"
|
|
@@ -336,7 +336,7 @@ test('Generate code for a template with attributes and 2 nested elements with at
|
|
|
336
336
|
|
|
337
337
|
parent = elms[1]
|
|
338
338
|
|
|
339
|
-
elms[3] = this.element(
|
|
339
|
+
elms[3] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
340
340
|
const elementConfig3 = {}
|
|
341
341
|
|
|
342
342
|
elementConfig3['type'] = "Element"
|
|
@@ -403,7 +403,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
403
403
|
function anonymous(parent,component,context) {
|
|
404
404
|
const elms = []
|
|
405
405
|
|
|
406
|
-
elms[1] = this.element(
|
|
406
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
407
407
|
const elementConfig1 = {}
|
|
408
408
|
|
|
409
409
|
elementConfig1['type'] = "Component"
|
|
@@ -414,7 +414,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
414
414
|
|
|
415
415
|
parent = elms[1]
|
|
416
416
|
|
|
417
|
-
elms[2] = this.element(
|
|
417
|
+
elms[2] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
418
418
|
const elementConfig2 = {}
|
|
419
419
|
|
|
420
420
|
elementConfig2['type'] = "Element"
|
|
@@ -426,7 +426,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
426
426
|
|
|
427
427
|
parent = elms[1]
|
|
428
428
|
|
|
429
|
-
elms[3] = this.element(
|
|
429
|
+
elms[3] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
430
430
|
const elementConfig3 = {}
|
|
431
431
|
|
|
432
432
|
elementConfig3['type'] = "Element"
|
|
@@ -438,7 +438,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
438
438
|
|
|
439
439
|
parent = elms[3]
|
|
440
440
|
|
|
441
|
-
elms[4] = this.element(
|
|
441
|
+
elms[4] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
442
442
|
const elementConfig4 = {}
|
|
443
443
|
|
|
444
444
|
elementConfig4['type'] = "Element"
|
|
@@ -448,7 +448,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
448
448
|
|
|
449
449
|
parent = elms[3]
|
|
450
450
|
|
|
451
|
-
elms[5] = this.element(
|
|
451
|
+
elms[5] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
452
452
|
const elementConfig5 = {}
|
|
453
453
|
|
|
454
454
|
elementConfig5['type'] = "Element"
|
|
@@ -492,7 +492,7 @@ test('Generate code for a template with simple dynamic attributes', (assert) =>
|
|
|
492
492
|
function anonymous(parent,component,context) {
|
|
493
493
|
const elms = []
|
|
494
494
|
|
|
495
|
-
elms[1] = this.element(
|
|
495
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
496
496
|
const elementConfig1 = {}
|
|
497
497
|
|
|
498
498
|
elementConfig1['type'] = "Component"
|
|
@@ -559,7 +559,7 @@ test('Generate code for a template with an attribute with a dash', (assert) => {
|
|
|
559
559
|
function anonymous(parent,component,context) {
|
|
560
560
|
const elms = []
|
|
561
561
|
|
|
562
|
-
elms[1] = this.element(
|
|
562
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
563
563
|
const elementConfig1 = {}
|
|
564
564
|
|
|
565
565
|
elementConfig1['type'] = "Component"
|
|
@@ -604,7 +604,7 @@ test('Generate code for a template with dynamic attributes with code to be evalu
|
|
|
604
604
|
function anonymous(parent,component,context) {
|
|
605
605
|
const elms = []
|
|
606
606
|
|
|
607
|
-
elms[1] = this.element(
|
|
607
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
608
608
|
const elementConfig1 = {}
|
|
609
609
|
|
|
610
610
|
elementConfig1['type'] = "Component"
|
|
@@ -690,7 +690,7 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
690
690
|
function anonymous(parent,component,context) {
|
|
691
691
|
const elms = []
|
|
692
692
|
|
|
693
|
-
elms[1] = this.element(
|
|
693
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
694
694
|
const elementConfig1 = {}
|
|
695
695
|
|
|
696
696
|
elementConfig1['type'] = "Component"
|
|
@@ -746,7 +746,7 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
746
746
|
function anonymous(parent,component,context) {
|
|
747
747
|
const elms = []
|
|
748
748
|
|
|
749
|
-
elms[1] = this.element(
|
|
749
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
750
750
|
const elementConfig1 = {}
|
|
751
751
|
|
|
752
752
|
elementConfig1['type'] = "Component"
|
|
@@ -757,7 +757,7 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
757
757
|
|
|
758
758
|
parent = elms[1]
|
|
759
759
|
|
|
760
|
-
elms[3] = this.element(
|
|
760
|
+
elms[3] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
761
761
|
const elementConfig3 = {}
|
|
762
762
|
|
|
763
763
|
elementConfig3['type'] = "Poster2"
|
|
@@ -813,7 +813,7 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
813
813
|
function anonymous(parent,component,context) {
|
|
814
814
|
const elms = []
|
|
815
815
|
|
|
816
|
-
elms[1] = this.element(
|
|
816
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
817
817
|
const elementConfig1 = {}
|
|
818
818
|
|
|
819
819
|
elementConfig1['type'] = "Component"
|
|
@@ -876,7 +876,7 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
876
876
|
function anonymous(parent,component,context) {
|
|
877
877
|
const elms = []
|
|
878
878
|
|
|
879
|
-
elms[1] = this.element(
|
|
879
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
880
880
|
const elementConfig1 = {}
|
|
881
881
|
|
|
882
882
|
elementConfig1['type'] = "Component"
|
|
@@ -946,7 +946,7 @@ test('Generate code for a template with a transition attributes', (assert) => {
|
|
|
946
946
|
function anonymous(parent,component,context) {
|
|
947
947
|
const elms = []
|
|
948
948
|
|
|
949
|
-
elms[1] = this.element(
|
|
949
|
+
elms[1] = this.element(parentId: parent && parent.nodeId || 'root'})
|
|
950
950
|
const elementConfig1 = {}
|
|
951
951
|
|
|
952
952
|
elementConfig1['type'] = "Component"
|
package/src/lib/symbols.js
CHANGED
|
@@ -32,8 +32,6 @@ export default {
|
|
|
32
32
|
children: Symbol.for('children'),
|
|
33
33
|
// Symbol 'components' utilized within generated code
|
|
34
34
|
components: Symbol.for('components'),
|
|
35
|
-
// Symbol 'id' utilized within generated code
|
|
36
|
-
id: Symbol.for('id'),
|
|
37
35
|
// Symbol 'isSlot' utilized within generated code
|
|
38
36
|
isSlot: Symbol.for('isSlot'),
|
|
39
37
|
// Symbol 'props' utilized within generated code
|