@lightningjs/blits 1.39.4 → 1.40.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/component/base/methods.js +2 -1
- package/src/components/Circle.js +2 -1
- package/src/components/FPScounter.js +2 -1
- package/src/components/RouterView.js +2 -1
- package/src/components/Sprite.js +2 -1
- package/src/lib/codegenerator/generator.js +22 -11
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -112,7 +112,6 @@ export default {
|
|
|
112
112
|
this[symbols.slots].length = 0
|
|
113
113
|
|
|
114
114
|
delete this[symbols.computed]
|
|
115
|
-
delete this[symbols.effects]
|
|
116
115
|
delete this.parent
|
|
117
116
|
delete this.rootParent
|
|
118
117
|
delete this[symbols.wrapper]
|
|
@@ -131,6 +130,8 @@ export default {
|
|
|
131
130
|
this[symbols.cleanup]()
|
|
132
131
|
delete this[symbols.cleanup]
|
|
133
132
|
|
|
133
|
+
delete this[symbols.effects]
|
|
134
|
+
|
|
134
135
|
Log.debug(`Destroyed component ${this.componentId}`)
|
|
135
136
|
},
|
|
136
137
|
writable: false,
|
package/src/components/Circle.js
CHANGED
|
@@ -27,6 +27,7 @@ export default () =>
|
|
|
27
27
|
const forloops = []
|
|
28
28
|
const props = []
|
|
29
29
|
const created = []
|
|
30
|
+
const effects = {}
|
|
30
31
|
const skips = []
|
|
31
32
|
let componentType
|
|
32
33
|
let rootComponent = component
|
|
@@ -58,8 +59,8 @@ export default () =>
|
|
|
58
59
|
rootComponent = null
|
|
59
60
|
propData = null
|
|
60
61
|
slotComponent = null
|
|
61
|
-
component = null
|
|
62
62
|
parent = null
|
|
63
|
+
component = null
|
|
63
64
|
cmps.length = 0
|
|
64
65
|
elms.length = 0
|
|
65
66
|
components.length = 0
|
|
@@ -29,6 +29,7 @@ export default () =>
|
|
|
29
29
|
const forloops = []
|
|
30
30
|
const props = []
|
|
31
31
|
const created = []
|
|
32
|
+
const effects = {}
|
|
32
33
|
const skips = []
|
|
33
34
|
let componentType
|
|
34
35
|
let rootComponent = component
|
|
@@ -1373,7 +1374,6 @@ export default () =>
|
|
|
1373
1374
|
rootComponent = null
|
|
1374
1375
|
propData = null
|
|
1375
1376
|
slotComponent = null
|
|
1376
|
-
component = null
|
|
1377
1377
|
parent = null
|
|
1378
1378
|
|
|
1379
1379
|
cmps[3] = null
|
|
@@ -1455,6 +1455,7 @@ export default () =>
|
|
|
1455
1455
|
|
|
1456
1456
|
props[41] = null
|
|
1457
1457
|
components[41] = null
|
|
1458
|
+
component = null
|
|
1458
1459
|
cmps.length = 0
|
|
1459
1460
|
elms.length = 0
|
|
1460
1461
|
components.length = 0
|
|
@@ -32,6 +32,7 @@ export default () =>
|
|
|
32
32
|
const forloops = []
|
|
33
33
|
const props = []
|
|
34
34
|
const created = []
|
|
35
|
+
const effects = {}
|
|
35
36
|
const skips = []
|
|
36
37
|
let componentType
|
|
37
38
|
let rootComponent = component
|
|
@@ -61,8 +62,8 @@ export default () =>
|
|
|
61
62
|
rootComponent = null
|
|
62
63
|
propData = null
|
|
63
64
|
slotComponent = null
|
|
64
|
-
component = null
|
|
65
65
|
parent = null
|
|
66
|
+
component = null
|
|
66
67
|
cmps.length = 0
|
|
67
68
|
elms.length = 0
|
|
68
69
|
components.length = 0
|
package/src/components/Sprite.js
CHANGED
|
@@ -29,6 +29,7 @@ export default () =>
|
|
|
29
29
|
const forloops = []
|
|
30
30
|
const props = []
|
|
31
31
|
const created = []
|
|
32
|
+
const effects = {}
|
|
32
33
|
const skips = []
|
|
33
34
|
let componentType
|
|
34
35
|
let rootComponent = component
|
|
@@ -60,8 +61,8 @@ export default () =>
|
|
|
60
61
|
rootComponent = null
|
|
61
62
|
propData = null
|
|
62
63
|
slotComponent = null
|
|
63
|
-
component = null
|
|
64
64
|
parent = null
|
|
65
|
+
component = null
|
|
65
66
|
cmps.length = 0
|
|
66
67
|
elms.length = 0
|
|
67
68
|
components.length = 0
|
|
@@ -26,6 +26,7 @@ export default function (templateObject = { children: [] }, devMode = false) {
|
|
|
26
26
|
'const forloops = []',
|
|
27
27
|
'const props = []',
|
|
28
28
|
'const created = []',
|
|
29
|
+
'const effects = {}',
|
|
29
30
|
'const skips = []',
|
|
30
31
|
'let componentType',
|
|
31
32
|
'let rootComponent = component',
|
|
@@ -40,7 +41,6 @@ export default function (templateObject = { children: [] }, devMode = false) {
|
|
|
40
41
|
'rootComponent = null',
|
|
41
42
|
'propData = null',
|
|
42
43
|
'slotComponent = null',
|
|
43
|
-
'component = null',
|
|
44
44
|
'parent = null',
|
|
45
45
|
],
|
|
46
46
|
context: { props: [], components: this.components },
|
|
@@ -73,6 +73,7 @@ export default function (templateObject = { children: [] }, devMode = false) {
|
|
|
73
73
|
ctx.renderCode.push(`
|
|
74
74
|
return { elms, cleanup: () => {
|
|
75
75
|
${ctx.cleanupCode.join('\n')}
|
|
76
|
+
component = null
|
|
76
77
|
cmps.length = 0
|
|
77
78
|
elms.length = 0
|
|
78
79
|
components.length = 0
|
|
@@ -385,6 +386,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
385
386
|
delete templateObject[':range']
|
|
386
387
|
|
|
387
388
|
const key = templateObject['key']
|
|
389
|
+
const forStartCounter = counter
|
|
388
390
|
const forKey = interpolate(key, 'scope.')
|
|
389
391
|
|
|
390
392
|
const shallow = !!!(
|
|
@@ -429,10 +431,9 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
429
431
|
}
|
|
430
432
|
}
|
|
431
433
|
|
|
432
|
-
const forStartCounter = counter
|
|
433
|
-
|
|
434
434
|
ctx.renderCode.push(`
|
|
435
435
|
created[${forStartCounter}] = []
|
|
436
|
+
effects[${forStartCounter}] = []
|
|
436
437
|
|
|
437
438
|
let from${forStartCounter}
|
|
438
439
|
let to${forStartCounter}
|
|
@@ -442,7 +443,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
442
443
|
const keys = new Set()
|
|
443
444
|
let l = rawCollection.length
|
|
444
445
|
|
|
445
|
-
const range = ${interpolate(range)} || {}
|
|
446
|
+
const range = ${interpolate(range, 'component?.')} || {}
|
|
446
447
|
from${forStartCounter} = range['from'] || 0
|
|
447
448
|
to${forStartCounter} = 'to' in range ? range['to'] : rawCollection.length
|
|
448
449
|
|
|
@@ -452,7 +453,6 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
452
453
|
|
|
453
454
|
ctx.cleanupCode.push(`
|
|
454
455
|
created[${forStartCounter}].length = 0
|
|
455
|
-
forloops[${forStartCounter}] = null
|
|
456
456
|
`)
|
|
457
457
|
|
|
458
458
|
// push reference of index variable
|
|
@@ -476,10 +476,19 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
476
476
|
ctx.renderCode.push(`
|
|
477
477
|
created.length = 0
|
|
478
478
|
const length = rawCollection.length
|
|
479
|
-
|
|
479
|
+
|
|
480
|
+
component !== null && component[Symbol.for('removeGlobalEffects')](effects[${forStartCounter}])
|
|
481
|
+
|
|
482
|
+
for(let i = 0; i < effects[${forStartCounter}].length; i++) {
|
|
483
|
+
const value = effects[${forStartCounter}][i]
|
|
484
|
+
const index = component[Symbol.for('effects')].indexOf(value)
|
|
485
|
+
if (index > -1) component[Symbol.for('effects')].splice(index, 1)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
effects[${forStartCounter}].length = 0
|
|
480
489
|
for(let __index = 0; __index < length; __index++) {
|
|
481
490
|
if(__index < from${forStartCounter} || __index >= to${forStartCounter}) continue
|
|
482
|
-
|
|
491
|
+
let scope = Object.create(component)
|
|
483
492
|
parent = ${parent}
|
|
484
493
|
scope['${item}'] = rawCollection[__index]
|
|
485
494
|
`)
|
|
@@ -539,8 +548,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
539
548
|
|
|
540
549
|
if (shallow === false) {
|
|
541
550
|
ctx.renderCode.push(`
|
|
542
|
-
scope[
|
|
543
|
-
scope['${item}'] = collection[__index]
|
|
551
|
+
scope = Object.assign(collection[__index], scope)
|
|
544
552
|
`)
|
|
545
553
|
}
|
|
546
554
|
|
|
@@ -553,7 +561,7 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
553
561
|
${effect}
|
|
554
562
|
}
|
|
555
563
|
effect(eff${index}, ${key})
|
|
556
|
-
effects.push(eff${index})
|
|
564
|
+
effects[${forStartCounter}].push(eff${index})
|
|
557
565
|
component[Symbol.for('effects')].push(eff${index})
|
|
558
566
|
`)
|
|
559
567
|
} else {
|
|
@@ -612,11 +620,14 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
612
620
|
|
|
613
621
|
component[Symbol.for('effects')].push(eff${forStartCounter})
|
|
614
622
|
|
|
615
|
-
effect(eff${forStartCounter}, ['${effectKey}', ${effectKeys.join(',')}]
|
|
623
|
+
effect(eff${forStartCounter}, ['${effectKey}', ${effectKeys.join(',')}])
|
|
616
624
|
`)
|
|
617
625
|
|
|
618
626
|
ctx.cleanupCode.push(`
|
|
619
627
|
eff${forStartCounter} = null
|
|
628
|
+
// call loop with empty array
|
|
629
|
+
forloops[${forStartCounter}]([], elms, created[${forStartCounter}])
|
|
630
|
+
forloops[${forStartCounter}] = null
|
|
620
631
|
`)
|
|
621
632
|
|
|
622
633
|
outerScopeEffects.forEach((effect, outerScopeEffectsIndex) => {
|