@lightningjs/blits 1.15.0 → 1.16.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 +8 -0
- package/package.json +1 -1
- package/src/components/Circle.js +12 -1
- package/src/components/FPScounter.js +325 -42
- package/src/components/RouterView.js +12 -1
- package/src/components/Sprite.js +15 -4
- package/src/components/Sprite.orig.js +3 -3
- package/src/lib/codegenerator/generator.js +28 -9
- package/src/lib/reactivity/reactive.js +8 -8
- package/vite/blitsFileConverter.js +37 -8
- package/vite/preCompiler.js +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.16.0
|
|
4
|
+
|
|
5
|
+
_16 jan 2025_
|
|
6
|
+
|
|
7
|
+
- Fixed issue with component scope in Slots
|
|
8
|
+
- Fixed issue with sprites (regression since v1.14.0)
|
|
9
|
+
- Changed reactive state to only make plain objects reactive, and return custom Classes, Blits components, Renderer texture etc in raw form
|
|
10
|
+
|
|
3
11
|
## v1.15.0
|
|
4
12
|
|
|
5
13
|
_14 jan 2025_
|
package/package.json
CHANGED
package/src/components/Circle.js
CHANGED
|
@@ -26,15 +26,26 @@ export default () =>
|
|
|
26
26
|
let componentType
|
|
27
27
|
const rootComponent = component
|
|
28
28
|
let propData
|
|
29
|
+
let slotComponent
|
|
30
|
+
let inSlot = false
|
|
31
|
+
let slotChildCounter = 0
|
|
29
32
|
const elementConfig0 = {}
|
|
30
33
|
|
|
31
|
-
elms[0] = this.element(
|
|
34
|
+
elms[0] = this.element(
|
|
35
|
+
{ parent: parent || 'root' },
|
|
36
|
+
inSlot === true ? slotComponent : component
|
|
37
|
+
)
|
|
32
38
|
|
|
33
39
|
elementConfig0['color'] = component.color
|
|
34
40
|
elementConfig0['w'] = component.size
|
|
35
41
|
elementConfig0['h'] = component.size
|
|
36
42
|
elementConfig0['effects'] = [component.shader('radius', { radius: component.radius })]
|
|
37
43
|
elms[0].populate(elementConfig0)
|
|
44
|
+
|
|
45
|
+
if (inSlot === true) {
|
|
46
|
+
slotChildCounter -= 1
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
return elms
|
|
39
50
|
},
|
|
40
51
|
effects: [
|
|
@@ -28,32 +28,61 @@ export default () =>
|
|
|
28
28
|
let componentType
|
|
29
29
|
const rootComponent = component
|
|
30
30
|
let propData
|
|
31
|
+
let slotComponent
|
|
32
|
+
let inSlot = false
|
|
33
|
+
let slotChildCounter = 0
|
|
31
34
|
const elementConfig0 = {}
|
|
32
35
|
|
|
33
|
-
elms[0] = this.element(
|
|
36
|
+
elms[0] = this.element(
|
|
37
|
+
{ parent: parent || 'root' },
|
|
38
|
+
inSlot === true ? slotComponent : component
|
|
39
|
+
)
|
|
34
40
|
|
|
35
41
|
elms[0].populate(elementConfig0)
|
|
42
|
+
|
|
43
|
+
if (inSlot === true) {
|
|
44
|
+
slotChildCounter -= 1
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
parent = elms[0]
|
|
37
48
|
const elementConfig1 = {}
|
|
38
49
|
|
|
39
|
-
elms[1] = this.element(
|
|
50
|
+
elms[1] = this.element(
|
|
51
|
+
{ parent: parent || 'root' },
|
|
52
|
+
inSlot === true ? slotComponent : component
|
|
53
|
+
)
|
|
40
54
|
|
|
41
55
|
elementConfig1['y'] = 15
|
|
42
56
|
elementConfig1['x'] = 20
|
|
43
57
|
elms[1].populate(elementConfig1)
|
|
58
|
+
|
|
59
|
+
if (inSlot === true) {
|
|
60
|
+
slotChildCounter -= 1
|
|
61
|
+
}
|
|
62
|
+
|
|
44
63
|
parent = elms[1]
|
|
45
64
|
const elementConfig2 = {}
|
|
46
65
|
|
|
47
|
-
elms[2] = this.element(
|
|
66
|
+
elms[2] = this.element(
|
|
67
|
+
{ parent: parent || 'root' },
|
|
68
|
+
inSlot === true ? slotComponent : component
|
|
69
|
+
)
|
|
48
70
|
|
|
49
71
|
elms[2].populate(elementConfig2)
|
|
50
72
|
|
|
73
|
+
if (inSlot === true) {
|
|
74
|
+
slotChildCounter -= 1
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
const cmp3 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
52
78
|
|
|
53
79
|
parent = elms[2]
|
|
54
80
|
const elementConfig3 = {}
|
|
55
81
|
|
|
56
|
-
elms[3] = this.element(
|
|
82
|
+
elms[3] = this.element(
|
|
83
|
+
{ parent: parent || 'root' },
|
|
84
|
+
inSlot === true ? slotComponent : component
|
|
85
|
+
)
|
|
57
86
|
|
|
58
87
|
elementConfig3['image'] = component.image
|
|
59
88
|
elementConfig3['w'] = 43
|
|
@@ -70,6 +99,11 @@ export default () =>
|
|
|
70
99
|
}
|
|
71
100
|
|
|
72
101
|
elms[3].populate(elementConfig3)
|
|
102
|
+
|
|
103
|
+
if (inSlot === true) {
|
|
104
|
+
slotChildCounter -= 1
|
|
105
|
+
}
|
|
106
|
+
|
|
73
107
|
parent = elms[3]
|
|
74
108
|
const props4 = {}
|
|
75
109
|
props4['image'] = component.image
|
|
@@ -98,26 +132,41 @@ export default () =>
|
|
|
98
132
|
|
|
99
133
|
if (elms[4][Symbol.for('slots')][0]) {
|
|
100
134
|
parent = elms[4][Symbol.for('slots')][0]
|
|
101
|
-
|
|
135
|
+
slotComponent = elms[4]
|
|
136
|
+
inSlot = true
|
|
102
137
|
} else {
|
|
103
138
|
parent = elms[4][Symbol.for('children')][0]
|
|
104
139
|
}
|
|
105
140
|
|
|
141
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
142
|
+
inSlot = false
|
|
143
|
+
}
|
|
144
|
+
|
|
106
145
|
parent = elms[2]
|
|
107
146
|
const elementConfig5 = {}
|
|
108
147
|
|
|
109
|
-
elms[5] = this.element(
|
|
148
|
+
elms[5] = this.element(
|
|
149
|
+
{ parent: parent || 'root' },
|
|
150
|
+
inSlot === true ? slotComponent : component
|
|
151
|
+
)
|
|
110
152
|
|
|
111
153
|
elementConfig5['x'] = 58
|
|
112
154
|
elementConfig5['y'] = 2
|
|
113
155
|
elms[5].populate(elementConfig5)
|
|
114
156
|
|
|
157
|
+
if (inSlot === true) {
|
|
158
|
+
slotChildCounter -= 1
|
|
159
|
+
}
|
|
160
|
+
|
|
115
161
|
const cmp6 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
116
162
|
|
|
117
163
|
parent = elms[5]
|
|
118
164
|
const elementConfig6 = {}
|
|
119
165
|
|
|
120
|
-
elms[6] = this.element(
|
|
166
|
+
elms[6] = this.element(
|
|
167
|
+
{ parent: parent || 'root' },
|
|
168
|
+
inSlot === true ? slotComponent : component
|
|
169
|
+
)
|
|
121
170
|
|
|
122
171
|
elementConfig6['image'] = component.image
|
|
123
172
|
elementConfig6['x'] = 0
|
|
@@ -135,6 +184,11 @@ export default () =>
|
|
|
135
184
|
}
|
|
136
185
|
|
|
137
186
|
elms[6].populate(elementConfig6)
|
|
187
|
+
|
|
188
|
+
if (inSlot === true) {
|
|
189
|
+
slotChildCounter -= 1
|
|
190
|
+
}
|
|
191
|
+
|
|
138
192
|
parent = elms[6]
|
|
139
193
|
const props7 = {}
|
|
140
194
|
props7['image'] = component.image
|
|
@@ -169,17 +223,25 @@ export default () =>
|
|
|
169
223
|
|
|
170
224
|
if (elms[7][Symbol.for('slots')][0]) {
|
|
171
225
|
parent = elms[7][Symbol.for('slots')][0]
|
|
172
|
-
|
|
226
|
+
slotComponent = elms[7]
|
|
227
|
+
inSlot = true
|
|
173
228
|
} else {
|
|
174
229
|
parent = elms[7][Symbol.for('children')][0]
|
|
175
230
|
}
|
|
176
231
|
|
|
232
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
233
|
+
inSlot = false
|
|
234
|
+
}
|
|
235
|
+
|
|
177
236
|
const cmp8 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
178
237
|
|
|
179
238
|
parent = elms[5]
|
|
180
239
|
const elementConfig8 = {}
|
|
181
240
|
|
|
182
|
-
elms[8] = this.element(
|
|
241
|
+
elms[8] = this.element(
|
|
242
|
+
{ parent: parent || 'root' },
|
|
243
|
+
inSlot === true ? slotComponent : component
|
|
244
|
+
)
|
|
183
245
|
|
|
184
246
|
elementConfig8['image'] = component.image
|
|
185
247
|
elementConfig8['x'] = 18
|
|
@@ -197,6 +259,11 @@ export default () =>
|
|
|
197
259
|
}
|
|
198
260
|
|
|
199
261
|
elms[8].populate(elementConfig8)
|
|
262
|
+
|
|
263
|
+
if (inSlot === true) {
|
|
264
|
+
slotChildCounter -= 1
|
|
265
|
+
}
|
|
266
|
+
|
|
200
267
|
parent = elms[8]
|
|
201
268
|
const props9 = {}
|
|
202
269
|
props9['image'] = component.image
|
|
@@ -231,17 +298,25 @@ export default () =>
|
|
|
231
298
|
|
|
232
299
|
if (elms[9][Symbol.for('slots')][0]) {
|
|
233
300
|
parent = elms[9][Symbol.for('slots')][0]
|
|
234
|
-
|
|
301
|
+
slotComponent = elms[9]
|
|
302
|
+
inSlot = true
|
|
235
303
|
} else {
|
|
236
304
|
parent = elms[9][Symbol.for('children')][0]
|
|
237
305
|
}
|
|
238
306
|
|
|
307
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
308
|
+
inSlot = false
|
|
309
|
+
}
|
|
310
|
+
|
|
239
311
|
const cmp10 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
240
312
|
|
|
241
313
|
parent = elms[5]
|
|
242
314
|
const elementConfig10 = {}
|
|
243
315
|
|
|
244
|
-
elms[10] = this.element(
|
|
316
|
+
elms[10] = this.element(
|
|
317
|
+
{ parent: parent || 'root' },
|
|
318
|
+
inSlot === true ? slotComponent : component
|
|
319
|
+
)
|
|
245
320
|
|
|
246
321
|
elementConfig10['image'] = component.image
|
|
247
322
|
elementConfig10['x'] = 36
|
|
@@ -259,6 +334,11 @@ export default () =>
|
|
|
259
334
|
}
|
|
260
335
|
|
|
261
336
|
elms[10].populate(elementConfig10)
|
|
337
|
+
|
|
338
|
+
if (inSlot === true) {
|
|
339
|
+
slotChildCounter -= 1
|
|
340
|
+
}
|
|
341
|
+
|
|
262
342
|
parent = elms[10]
|
|
263
343
|
const props11 = {}
|
|
264
344
|
props11['image'] = component.image
|
|
@@ -293,25 +373,40 @@ export default () =>
|
|
|
293
373
|
|
|
294
374
|
if (elms[11][Symbol.for('slots')][0]) {
|
|
295
375
|
parent = elms[11][Symbol.for('slots')][0]
|
|
296
|
-
|
|
376
|
+
slotComponent = elms[11]
|
|
377
|
+
inSlot = true
|
|
297
378
|
} else {
|
|
298
379
|
parent = elms[11][Symbol.for('children')][0]
|
|
299
380
|
}
|
|
300
381
|
|
|
382
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
383
|
+
inSlot = false
|
|
384
|
+
}
|
|
385
|
+
|
|
301
386
|
parent = elms[1]
|
|
302
387
|
const elementConfig12 = {}
|
|
303
388
|
|
|
304
|
-
elms[12] = this.element(
|
|
389
|
+
elms[12] = this.element(
|
|
390
|
+
{ parent: parent || 'root' },
|
|
391
|
+
inSlot === true ? slotComponent : component
|
|
392
|
+
)
|
|
305
393
|
|
|
306
394
|
elementConfig12['x'] = 150
|
|
307
395
|
elms[12].populate(elementConfig12)
|
|
308
396
|
|
|
397
|
+
if (inSlot === true) {
|
|
398
|
+
slotChildCounter -= 1
|
|
399
|
+
}
|
|
400
|
+
|
|
309
401
|
const cmp13 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
310
402
|
|
|
311
403
|
parent = elms[12]
|
|
312
404
|
const elementConfig13 = {}
|
|
313
405
|
|
|
314
|
-
elms[13] = this.element(
|
|
406
|
+
elms[13] = this.element(
|
|
407
|
+
{ parent: parent || 'root' },
|
|
408
|
+
inSlot === true ? slotComponent : component
|
|
409
|
+
)
|
|
315
410
|
|
|
316
411
|
elementConfig13['image'] = component.image
|
|
317
412
|
elementConfig13['y'] = 2
|
|
@@ -329,6 +424,11 @@ export default () =>
|
|
|
329
424
|
}
|
|
330
425
|
|
|
331
426
|
elms[13].populate(elementConfig13)
|
|
427
|
+
|
|
428
|
+
if (inSlot === true) {
|
|
429
|
+
slotChildCounter -= 1
|
|
430
|
+
}
|
|
431
|
+
|
|
332
432
|
parent = elms[13]
|
|
333
433
|
const props14 = {}
|
|
334
434
|
props14['image'] = component.image
|
|
@@ -358,26 +458,41 @@ export default () =>
|
|
|
358
458
|
|
|
359
459
|
if (elms[14][Symbol.for('slots')][0]) {
|
|
360
460
|
parent = elms[14][Symbol.for('slots')][0]
|
|
361
|
-
|
|
461
|
+
slotComponent = elms[14]
|
|
462
|
+
inSlot = true
|
|
362
463
|
} else {
|
|
363
464
|
parent = elms[14][Symbol.for('children')][0]
|
|
364
465
|
}
|
|
365
466
|
|
|
467
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
468
|
+
inSlot = false
|
|
469
|
+
}
|
|
470
|
+
|
|
366
471
|
parent = elms[12]
|
|
367
472
|
const elementConfig15 = {}
|
|
368
473
|
|
|
369
|
-
elms[15] = this.element(
|
|
474
|
+
elms[15] = this.element(
|
|
475
|
+
{ parent: parent || 'root' },
|
|
476
|
+
inSlot === true ? slotComponent : component
|
|
477
|
+
)
|
|
370
478
|
|
|
371
479
|
elementConfig15['x'] = 63
|
|
372
480
|
elementConfig15['y'] = 2
|
|
373
481
|
elms[15].populate(elementConfig15)
|
|
374
482
|
|
|
483
|
+
if (inSlot === true) {
|
|
484
|
+
slotChildCounter -= 1
|
|
485
|
+
}
|
|
486
|
+
|
|
375
487
|
const cmp16 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
376
488
|
|
|
377
489
|
parent = elms[15]
|
|
378
490
|
const elementConfig16 = {}
|
|
379
491
|
|
|
380
|
-
elms[16] = this.element(
|
|
492
|
+
elms[16] = this.element(
|
|
493
|
+
{ parent: parent || 'root' },
|
|
494
|
+
inSlot === true ? slotComponent : component
|
|
495
|
+
)
|
|
381
496
|
|
|
382
497
|
elementConfig16['image'] = component.image
|
|
383
498
|
elementConfig16['x'] = 0
|
|
@@ -395,6 +510,11 @@ export default () =>
|
|
|
395
510
|
}
|
|
396
511
|
|
|
397
512
|
elms[16].populate(elementConfig16)
|
|
513
|
+
|
|
514
|
+
if (inSlot === true) {
|
|
515
|
+
slotChildCounter -= 1
|
|
516
|
+
}
|
|
517
|
+
|
|
398
518
|
parent = elms[16]
|
|
399
519
|
const props17 = {}
|
|
400
520
|
props17['image'] = component.image
|
|
@@ -429,17 +549,25 @@ export default () =>
|
|
|
429
549
|
|
|
430
550
|
if (elms[17][Symbol.for('slots')][0]) {
|
|
431
551
|
parent = elms[17][Symbol.for('slots')][0]
|
|
432
|
-
|
|
552
|
+
slotComponent = elms[17]
|
|
553
|
+
inSlot = true
|
|
433
554
|
} else {
|
|
434
555
|
parent = elms[17][Symbol.for('children')][0]
|
|
435
556
|
}
|
|
436
557
|
|
|
558
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
559
|
+
inSlot = false
|
|
560
|
+
}
|
|
561
|
+
|
|
437
562
|
const cmp18 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
438
563
|
|
|
439
564
|
parent = elms[15]
|
|
440
565
|
const elementConfig18 = {}
|
|
441
566
|
|
|
442
|
-
elms[18] = this.element(
|
|
567
|
+
elms[18] = this.element(
|
|
568
|
+
{ parent: parent || 'root' },
|
|
569
|
+
inSlot === true ? slotComponent : component
|
|
570
|
+
)
|
|
443
571
|
|
|
444
572
|
elementConfig18['image'] = component.image
|
|
445
573
|
elementConfig18['x'] = 18
|
|
@@ -457,6 +585,11 @@ export default () =>
|
|
|
457
585
|
}
|
|
458
586
|
|
|
459
587
|
elms[18].populate(elementConfig18)
|
|
588
|
+
|
|
589
|
+
if (inSlot === true) {
|
|
590
|
+
slotChildCounter -= 1
|
|
591
|
+
}
|
|
592
|
+
|
|
460
593
|
parent = elms[18]
|
|
461
594
|
const props19 = {}
|
|
462
595
|
props19['image'] = component.image
|
|
@@ -491,17 +624,25 @@ export default () =>
|
|
|
491
624
|
|
|
492
625
|
if (elms[19][Symbol.for('slots')][0]) {
|
|
493
626
|
parent = elms[19][Symbol.for('slots')][0]
|
|
494
|
-
|
|
627
|
+
slotComponent = elms[19]
|
|
628
|
+
inSlot = true
|
|
495
629
|
} else {
|
|
496
630
|
parent = elms[19][Symbol.for('children')][0]
|
|
497
631
|
}
|
|
498
632
|
|
|
633
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
634
|
+
inSlot = false
|
|
635
|
+
}
|
|
636
|
+
|
|
499
637
|
const cmp20 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
500
638
|
|
|
501
639
|
parent = elms[15]
|
|
502
640
|
const elementConfig20 = {}
|
|
503
641
|
|
|
504
|
-
elms[20] = this.element(
|
|
642
|
+
elms[20] = this.element(
|
|
643
|
+
{ parent: parent || 'root' },
|
|
644
|
+
inSlot === true ? slotComponent : component
|
|
645
|
+
)
|
|
505
646
|
|
|
506
647
|
elementConfig20['image'] = component.image
|
|
507
648
|
elementConfig20['x'] = 36
|
|
@@ -519,6 +660,11 @@ export default () =>
|
|
|
519
660
|
}
|
|
520
661
|
|
|
521
662
|
elms[20].populate(elementConfig20)
|
|
663
|
+
|
|
664
|
+
if (inSlot === true) {
|
|
665
|
+
slotChildCounter -= 1
|
|
666
|
+
}
|
|
667
|
+
|
|
522
668
|
parent = elms[20]
|
|
523
669
|
const props21 = {}
|
|
524
670
|
props21['image'] = component.image
|
|
@@ -553,26 +699,41 @@ export default () =>
|
|
|
553
699
|
|
|
554
700
|
if (elms[21][Symbol.for('slots')][0]) {
|
|
555
701
|
parent = elms[21][Symbol.for('slots')][0]
|
|
556
|
-
|
|
702
|
+
slotComponent = elms[21]
|
|
703
|
+
inSlot = true
|
|
557
704
|
} else {
|
|
558
705
|
parent = elms[21][Symbol.for('children')][0]
|
|
559
706
|
}
|
|
560
707
|
|
|
708
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
709
|
+
inSlot = false
|
|
710
|
+
}
|
|
711
|
+
|
|
561
712
|
parent = elms[1]
|
|
562
713
|
const elementConfig22 = {}
|
|
563
714
|
|
|
564
|
-
elms[22] = this.element(
|
|
715
|
+
elms[22] = this.element(
|
|
716
|
+
{ parent: parent || 'root' },
|
|
717
|
+
inSlot === true ? slotComponent : component
|
|
718
|
+
)
|
|
565
719
|
|
|
566
720
|
elementConfig22['x'] = 0
|
|
567
721
|
elementConfig22['y'] = 40
|
|
568
722
|
elms[22].populate(elementConfig22)
|
|
569
723
|
|
|
724
|
+
if (inSlot === true) {
|
|
725
|
+
slotChildCounter -= 1
|
|
726
|
+
}
|
|
727
|
+
|
|
570
728
|
const cmp23 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
571
729
|
|
|
572
730
|
parent = elms[22]
|
|
573
731
|
const elementConfig23 = {}
|
|
574
732
|
|
|
575
|
-
elms[23] = this.element(
|
|
733
|
+
elms[23] = this.element(
|
|
734
|
+
{ parent: parent || 'root' },
|
|
735
|
+
inSlot === true ? slotComponent : component
|
|
736
|
+
)
|
|
576
737
|
|
|
577
738
|
elementConfig23['image'] = component.image
|
|
578
739
|
elementConfig23['x'] = -2
|
|
@@ -590,6 +751,11 @@ export default () =>
|
|
|
590
751
|
}
|
|
591
752
|
|
|
592
753
|
elms[23].populate(elementConfig23)
|
|
754
|
+
|
|
755
|
+
if (inSlot === true) {
|
|
756
|
+
slotChildCounter -= 1
|
|
757
|
+
}
|
|
758
|
+
|
|
593
759
|
parent = elms[23]
|
|
594
760
|
const props24 = {}
|
|
595
761
|
props24['image'] = component.image
|
|
@@ -619,26 +785,41 @@ export default () =>
|
|
|
619
785
|
|
|
620
786
|
if (elms[24][Symbol.for('slots')][0]) {
|
|
621
787
|
parent = elms[24][Symbol.for('slots')][0]
|
|
622
|
-
|
|
788
|
+
slotComponent = elms[24]
|
|
789
|
+
inSlot = true
|
|
623
790
|
} else {
|
|
624
791
|
parent = elms[24][Symbol.for('children')][0]
|
|
625
792
|
}
|
|
626
793
|
|
|
794
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
795
|
+
inSlot = false
|
|
796
|
+
}
|
|
797
|
+
|
|
627
798
|
parent = elms[22]
|
|
628
799
|
const elementConfig25 = {}
|
|
629
800
|
|
|
630
|
-
elms[25] = this.element(
|
|
801
|
+
elms[25] = this.element(
|
|
802
|
+
{ parent: parent || 'root' },
|
|
803
|
+
inSlot === true ? slotComponent : component
|
|
804
|
+
)
|
|
631
805
|
|
|
632
806
|
elementConfig25['x'] = 58
|
|
633
807
|
elementConfig25['y'] = 2
|
|
634
808
|
elms[25].populate(elementConfig25)
|
|
635
809
|
|
|
810
|
+
if (inSlot === true) {
|
|
811
|
+
slotChildCounter -= 1
|
|
812
|
+
}
|
|
813
|
+
|
|
636
814
|
const cmp26 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
637
815
|
|
|
638
816
|
parent = elms[25]
|
|
639
817
|
const elementConfig26 = {}
|
|
640
818
|
|
|
641
|
-
elms[26] = this.element(
|
|
819
|
+
elms[26] = this.element(
|
|
820
|
+
{ parent: parent || 'root' },
|
|
821
|
+
inSlot === true ? slotComponent : component
|
|
822
|
+
)
|
|
642
823
|
|
|
643
824
|
elementConfig26['image'] = component.image
|
|
644
825
|
elementConfig26['x'] = 0
|
|
@@ -656,6 +837,11 @@ export default () =>
|
|
|
656
837
|
}
|
|
657
838
|
|
|
658
839
|
elms[26].populate(elementConfig26)
|
|
840
|
+
|
|
841
|
+
if (inSlot === true) {
|
|
842
|
+
slotChildCounter -= 1
|
|
843
|
+
}
|
|
844
|
+
|
|
659
845
|
parent = elms[26]
|
|
660
846
|
const props27 = {}
|
|
661
847
|
props27['image'] = component.image
|
|
@@ -690,17 +876,25 @@ export default () =>
|
|
|
690
876
|
|
|
691
877
|
if (elms[27][Symbol.for('slots')][0]) {
|
|
692
878
|
parent = elms[27][Symbol.for('slots')][0]
|
|
693
|
-
|
|
879
|
+
slotComponent = elms[27]
|
|
880
|
+
inSlot = true
|
|
694
881
|
} else {
|
|
695
882
|
parent = elms[27][Symbol.for('children')][0]
|
|
696
883
|
}
|
|
697
884
|
|
|
885
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
886
|
+
inSlot = false
|
|
887
|
+
}
|
|
888
|
+
|
|
698
889
|
const cmp28 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
699
890
|
|
|
700
891
|
parent = elms[25]
|
|
701
892
|
const elementConfig28 = {}
|
|
702
893
|
|
|
703
|
-
elms[28] = this.element(
|
|
894
|
+
elms[28] = this.element(
|
|
895
|
+
{ parent: parent || 'root' },
|
|
896
|
+
inSlot === true ? slotComponent : component
|
|
897
|
+
)
|
|
704
898
|
|
|
705
899
|
elementConfig28['image'] = component.image
|
|
706
900
|
elementConfig28['x'] = 18
|
|
@@ -718,6 +912,11 @@ export default () =>
|
|
|
718
912
|
}
|
|
719
913
|
|
|
720
914
|
elms[28].populate(elementConfig28)
|
|
915
|
+
|
|
916
|
+
if (inSlot === true) {
|
|
917
|
+
slotChildCounter -= 1
|
|
918
|
+
}
|
|
919
|
+
|
|
721
920
|
parent = elms[28]
|
|
722
921
|
const props29 = {}
|
|
723
922
|
props29['image'] = component.image
|
|
@@ -752,17 +951,25 @@ export default () =>
|
|
|
752
951
|
|
|
753
952
|
if (elms[29][Symbol.for('slots')][0]) {
|
|
754
953
|
parent = elms[29][Symbol.for('slots')][0]
|
|
755
|
-
|
|
954
|
+
slotComponent = elms[29]
|
|
955
|
+
inSlot = true
|
|
756
956
|
} else {
|
|
757
957
|
parent = elms[29][Symbol.for('children')][0]
|
|
758
958
|
}
|
|
759
959
|
|
|
960
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
961
|
+
inSlot = false
|
|
962
|
+
}
|
|
963
|
+
|
|
760
964
|
const cmp30 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
761
965
|
|
|
762
966
|
parent = elms[25]
|
|
763
967
|
const elementConfig30 = {}
|
|
764
968
|
|
|
765
|
-
elms[30] = this.element(
|
|
969
|
+
elms[30] = this.element(
|
|
970
|
+
{ parent: parent || 'root' },
|
|
971
|
+
inSlot === true ? slotComponent : component
|
|
972
|
+
)
|
|
766
973
|
|
|
767
974
|
elementConfig30['image'] = component.image
|
|
768
975
|
elementConfig30['x'] = 36
|
|
@@ -780,6 +987,11 @@ export default () =>
|
|
|
780
987
|
}
|
|
781
988
|
|
|
782
989
|
elms[30].populate(elementConfig30)
|
|
990
|
+
|
|
991
|
+
if (inSlot === true) {
|
|
992
|
+
slotChildCounter -= 1
|
|
993
|
+
}
|
|
994
|
+
|
|
783
995
|
parent = elms[30]
|
|
784
996
|
const props31 = {}
|
|
785
997
|
props31['image'] = component.image
|
|
@@ -814,26 +1026,41 @@ export default () =>
|
|
|
814
1026
|
|
|
815
1027
|
if (elms[31][Symbol.for('slots')][0]) {
|
|
816
1028
|
parent = elms[31][Symbol.for('slots')][0]
|
|
817
|
-
|
|
1029
|
+
slotComponent = elms[31]
|
|
1030
|
+
inSlot = true
|
|
818
1031
|
} else {
|
|
819
1032
|
parent = elms[31][Symbol.for('children')][0]
|
|
820
1033
|
}
|
|
821
1034
|
|
|
1035
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1036
|
+
inSlot = false
|
|
1037
|
+
}
|
|
1038
|
+
|
|
822
1039
|
parent = elms[1]
|
|
823
1040
|
const elementConfig32 = {}
|
|
824
1041
|
|
|
825
|
-
elms[32] = this.element(
|
|
1042
|
+
elms[32] = this.element(
|
|
1043
|
+
{ parent: parent || 'root' },
|
|
1044
|
+
inSlot === true ? slotComponent : component
|
|
1045
|
+
)
|
|
826
1046
|
|
|
827
1047
|
elementConfig32['x'] = 150
|
|
828
1048
|
elementConfig32['y'] = 40
|
|
829
1049
|
elms[32].populate(elementConfig32)
|
|
830
1050
|
|
|
1051
|
+
if (inSlot === true) {
|
|
1052
|
+
slotChildCounter -= 1
|
|
1053
|
+
}
|
|
1054
|
+
|
|
831
1055
|
const cmp33 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
832
1056
|
|
|
833
1057
|
parent = elms[32]
|
|
834
1058
|
const elementConfig33 = {}
|
|
835
1059
|
|
|
836
|
-
elms[33] = this.element(
|
|
1060
|
+
elms[33] = this.element(
|
|
1061
|
+
{ parent: parent || 'root' },
|
|
1062
|
+
inSlot === true ? slotComponent : component
|
|
1063
|
+
)
|
|
837
1064
|
|
|
838
1065
|
elementConfig33['image'] = component.image
|
|
839
1066
|
elementConfig33['w'] = 53
|
|
@@ -850,6 +1077,11 @@ export default () =>
|
|
|
850
1077
|
}
|
|
851
1078
|
|
|
852
1079
|
elms[33].populate(elementConfig33)
|
|
1080
|
+
|
|
1081
|
+
if (inSlot === true) {
|
|
1082
|
+
slotChildCounter -= 1
|
|
1083
|
+
}
|
|
1084
|
+
|
|
853
1085
|
parent = elms[33]
|
|
854
1086
|
const props34 = {}
|
|
855
1087
|
props34['image'] = component.image
|
|
@@ -878,26 +1110,41 @@ export default () =>
|
|
|
878
1110
|
|
|
879
1111
|
if (elms[34][Symbol.for('slots')][0]) {
|
|
880
1112
|
parent = elms[34][Symbol.for('slots')][0]
|
|
881
|
-
|
|
1113
|
+
slotComponent = elms[34]
|
|
1114
|
+
inSlot = true
|
|
882
1115
|
} else {
|
|
883
1116
|
parent = elms[34][Symbol.for('children')][0]
|
|
884
1117
|
}
|
|
885
1118
|
|
|
1119
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1120
|
+
inSlot = false
|
|
1121
|
+
}
|
|
1122
|
+
|
|
886
1123
|
parent = elms[32]
|
|
887
1124
|
const elementConfig35 = {}
|
|
888
1125
|
|
|
889
|
-
elms[35] = this.element(
|
|
1126
|
+
elms[35] = this.element(
|
|
1127
|
+
{ parent: parent || 'root' },
|
|
1128
|
+
inSlot === true ? slotComponent : component
|
|
1129
|
+
)
|
|
890
1130
|
|
|
891
1131
|
elementConfig35['x'] = 63
|
|
892
1132
|
elementConfig35['y'] = 2
|
|
893
1133
|
elms[35].populate(elementConfig35)
|
|
894
1134
|
|
|
1135
|
+
if (inSlot === true) {
|
|
1136
|
+
slotChildCounter -= 1
|
|
1137
|
+
}
|
|
1138
|
+
|
|
895
1139
|
const cmp36 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
896
1140
|
|
|
897
1141
|
parent = elms[35]
|
|
898
1142
|
const elementConfig36 = {}
|
|
899
1143
|
|
|
900
|
-
elms[36] = this.element(
|
|
1144
|
+
elms[36] = this.element(
|
|
1145
|
+
{ parent: parent || 'root' },
|
|
1146
|
+
inSlot === true ? slotComponent : component
|
|
1147
|
+
)
|
|
901
1148
|
|
|
902
1149
|
elementConfig36['image'] = component.image
|
|
903
1150
|
elementConfig36['x'] = 0
|
|
@@ -915,6 +1162,11 @@ export default () =>
|
|
|
915
1162
|
}
|
|
916
1163
|
|
|
917
1164
|
elms[36].populate(elementConfig36)
|
|
1165
|
+
|
|
1166
|
+
if (inSlot === true) {
|
|
1167
|
+
slotChildCounter -= 1
|
|
1168
|
+
}
|
|
1169
|
+
|
|
918
1170
|
parent = elms[36]
|
|
919
1171
|
const props37 = {}
|
|
920
1172
|
props37['image'] = component.image
|
|
@@ -949,17 +1201,25 @@ export default () =>
|
|
|
949
1201
|
|
|
950
1202
|
if (elms[37][Symbol.for('slots')][0]) {
|
|
951
1203
|
parent = elms[37][Symbol.for('slots')][0]
|
|
952
|
-
|
|
1204
|
+
slotComponent = elms[37]
|
|
1205
|
+
inSlot = true
|
|
953
1206
|
} else {
|
|
954
1207
|
parent = elms[37][Symbol.for('children')][0]
|
|
955
1208
|
}
|
|
956
1209
|
|
|
1210
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1211
|
+
inSlot = false
|
|
1212
|
+
}
|
|
1213
|
+
|
|
957
1214
|
const cmp38 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
958
1215
|
|
|
959
1216
|
parent = elms[35]
|
|
960
1217
|
const elementConfig38 = {}
|
|
961
1218
|
|
|
962
|
-
elms[38] = this.element(
|
|
1219
|
+
elms[38] = this.element(
|
|
1220
|
+
{ parent: parent || 'root' },
|
|
1221
|
+
inSlot === true ? slotComponent : component
|
|
1222
|
+
)
|
|
963
1223
|
|
|
964
1224
|
elementConfig38['image'] = component.image
|
|
965
1225
|
elementConfig38['x'] = 18
|
|
@@ -977,6 +1237,11 @@ export default () =>
|
|
|
977
1237
|
}
|
|
978
1238
|
|
|
979
1239
|
elms[38].populate(elementConfig38)
|
|
1240
|
+
|
|
1241
|
+
if (inSlot === true) {
|
|
1242
|
+
slotChildCounter -= 1
|
|
1243
|
+
}
|
|
1244
|
+
|
|
980
1245
|
parent = elms[38]
|
|
981
1246
|
const props39 = {}
|
|
982
1247
|
props39['image'] = component.image
|
|
@@ -1011,17 +1276,25 @@ export default () =>
|
|
|
1011
1276
|
|
|
1012
1277
|
if (elms[39][Symbol.for('slots')][0]) {
|
|
1013
1278
|
parent = elms[39][Symbol.for('slots')][0]
|
|
1014
|
-
|
|
1279
|
+
slotComponent = elms[39]
|
|
1280
|
+
inSlot = true
|
|
1015
1281
|
} else {
|
|
1016
1282
|
parent = elms[39][Symbol.for('children')][0]
|
|
1017
1283
|
}
|
|
1018
1284
|
|
|
1285
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1286
|
+
inSlot = false
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1019
1289
|
const cmp40 = (context.components && context.components['Sprite']) || components['Sprite']
|
|
1020
1290
|
|
|
1021
1291
|
parent = elms[35]
|
|
1022
1292
|
const elementConfig40 = {}
|
|
1023
1293
|
|
|
1024
|
-
elms[40] = this.element(
|
|
1294
|
+
elms[40] = this.element(
|
|
1295
|
+
{ parent: parent || 'root' },
|
|
1296
|
+
inSlot === true ? slotComponent : component
|
|
1297
|
+
)
|
|
1025
1298
|
|
|
1026
1299
|
elementConfig40['image'] = component.image
|
|
1027
1300
|
elementConfig40['x'] = 36
|
|
@@ -1039,6 +1312,11 @@ export default () =>
|
|
|
1039
1312
|
}
|
|
1040
1313
|
|
|
1041
1314
|
elms[40].populate(elementConfig40)
|
|
1315
|
+
|
|
1316
|
+
if (inSlot === true) {
|
|
1317
|
+
slotChildCounter -= 1
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1042
1320
|
parent = elms[40]
|
|
1043
1321
|
const props41 = {}
|
|
1044
1322
|
props41['image'] = component.image
|
|
@@ -1073,11 +1351,16 @@ export default () =>
|
|
|
1073
1351
|
|
|
1074
1352
|
if (elms[41][Symbol.for('slots')][0]) {
|
|
1075
1353
|
parent = elms[41][Symbol.for('slots')][0]
|
|
1076
|
-
|
|
1354
|
+
slotComponent = elms[41]
|
|
1355
|
+
inSlot = true
|
|
1077
1356
|
} else {
|
|
1078
1357
|
parent = elms[41][Symbol.for('children')][0]
|
|
1079
1358
|
}
|
|
1080
1359
|
|
|
1360
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1361
|
+
inSlot = false
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1081
1364
|
return elms
|
|
1082
1365
|
},
|
|
1083
1366
|
effects: [
|
|
@@ -29,13 +29,24 @@ export default () =>
|
|
|
29
29
|
let componentType
|
|
30
30
|
const rootComponent = component
|
|
31
31
|
let propData
|
|
32
|
+
let slotComponent
|
|
33
|
+
let inSlot = false
|
|
34
|
+
let slotChildCounter = 0
|
|
32
35
|
const elementConfig0 = {}
|
|
33
36
|
|
|
34
|
-
elms[0] = this.element(
|
|
37
|
+
elms[0] = this.element(
|
|
38
|
+
{ parent: parent || 'root' },
|
|
39
|
+
inSlot === true ? slotComponent : component
|
|
40
|
+
)
|
|
35
41
|
|
|
36
42
|
elementConfig0['w'] = parent.node.width * (100 / 100)
|
|
37
43
|
elementConfig0['height'] = parent.node.height * (100 / 100)
|
|
38
44
|
elms[0].populate(elementConfig0)
|
|
45
|
+
|
|
46
|
+
if (inSlot === true) {
|
|
47
|
+
slotChildCounter -= 1
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
return elms
|
|
40
51
|
},
|
|
41
52
|
effects: [],
|
package/src/components/Sprite.js
CHANGED
|
@@ -28,15 +28,26 @@ export default () =>
|
|
|
28
28
|
let componentType
|
|
29
29
|
const rootComponent = component
|
|
30
30
|
let propData
|
|
31
|
+
let slotComponent
|
|
32
|
+
let inSlot = false
|
|
33
|
+
let slotChildCounter = 0
|
|
31
34
|
const elementConfig0 = {}
|
|
32
35
|
|
|
33
|
-
elms[0] = this.element(
|
|
36
|
+
elms[0] = this.element(
|
|
37
|
+
{ parent: parent || 'root' },
|
|
38
|
+
inSlot === true ? slotComponent : component
|
|
39
|
+
)
|
|
34
40
|
|
|
35
41
|
elementConfig0['w'] = parent.node.width * (100 / 100)
|
|
36
42
|
elementConfig0['h'] = parent.node.height * (100 / 100)
|
|
37
43
|
elementConfig0['texture'] = component.texture
|
|
38
44
|
elementConfig0['color'] = component.color
|
|
39
45
|
elms[0].populate(elementConfig0)
|
|
46
|
+
|
|
47
|
+
if (inSlot === true) {
|
|
48
|
+
slotChildCounter -= 1
|
|
49
|
+
}
|
|
50
|
+
|
|
40
51
|
return elms
|
|
41
52
|
},
|
|
42
53
|
effects: [
|
|
@@ -52,7 +63,7 @@ export default () =>
|
|
|
52
63
|
props: ['image', 'map', 'frame', 'color'],
|
|
53
64
|
state() {
|
|
54
65
|
return {
|
|
55
|
-
spriteTexture:
|
|
66
|
+
spriteTexture: null,
|
|
56
67
|
}
|
|
57
68
|
},
|
|
58
69
|
computed: {
|
|
@@ -62,7 +73,7 @@ export default () =>
|
|
|
62
73
|
? Object.assign({}, this.map.defaults || {}, this.map.frames[this.frame])
|
|
63
74
|
: this.map[this.frame]
|
|
64
75
|
|
|
65
|
-
if (this.spriteTexture && options) {
|
|
76
|
+
if (this.spriteTexture !== null && options) {
|
|
66
77
|
return this[symbols.renderer]().createTexture('SubTexture', {
|
|
67
78
|
texture: this.spriteTexture,
|
|
68
79
|
x: options.x,
|
|
@@ -74,7 +85,7 @@ export default () =>
|
|
|
74
85
|
},
|
|
75
86
|
},
|
|
76
87
|
hooks: {
|
|
77
|
-
|
|
88
|
+
init() {
|
|
78
89
|
this.spriteTexture = this[symbols.renderer]().createTexture('ImageTexture', {
|
|
79
90
|
src: this.image,
|
|
80
91
|
})
|
|
@@ -27,7 +27,7 @@ export default () =>
|
|
|
27
27
|
props: ['image', 'map', 'frame', 'color'],
|
|
28
28
|
state() {
|
|
29
29
|
return {
|
|
30
|
-
spriteTexture:
|
|
30
|
+
spriteTexture: null,
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
computed: {
|
|
@@ -37,7 +37,7 @@ export default () =>
|
|
|
37
37
|
? Object.assign({}, this.map.defaults || {}, this.map.frames[this.frame])
|
|
38
38
|
: this.map[this.frame]
|
|
39
39
|
|
|
40
|
-
if (this.spriteTexture && options) {
|
|
40
|
+
if (this.spriteTexture !== null && options) {
|
|
41
41
|
return this[symbols.renderer]().createTexture('SubTexture', {
|
|
42
42
|
texture: this.spriteTexture,
|
|
43
43
|
x: options.x,
|
|
@@ -49,7 +49,7 @@ export default () =>
|
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
hooks: {
|
|
52
|
-
|
|
52
|
+
init() {
|
|
53
53
|
this.spriteTexture = this[symbols.renderer]().createTexture('ImageTexture', {
|
|
54
54
|
src: this.image,
|
|
55
55
|
})
|
|
@@ -24,6 +24,9 @@ export default function (templateObject = { children: [] }) {
|
|
|
24
24
|
'let componentType',
|
|
25
25
|
'const rootComponent = component',
|
|
26
26
|
'let propData',
|
|
27
|
+
'let slotComponent',
|
|
28
|
+
'let inSlot = false',
|
|
29
|
+
'let slotChildCounter = 0',
|
|
27
30
|
],
|
|
28
31
|
effectsCode: [],
|
|
29
32
|
context: { props: [], components: this.components },
|
|
@@ -79,7 +82,7 @@ const generateElementCode = function (
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
renderCode.push(`
|
|
82
|
-
${elm} = this.element({parent: parent || 'root'}, component)
|
|
85
|
+
${elm} = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
83
86
|
`)
|
|
84
87
|
|
|
85
88
|
if (options.forloop) {
|
|
@@ -96,7 +99,7 @@ const generateElementCode = function (
|
|
|
96
99
|
Object.keys(templateObject).forEach((key) => {
|
|
97
100
|
if (key === 'slot') {
|
|
98
101
|
renderCode.push(`
|
|
99
|
-
elementConfig${counter}['parent'] = component[Symbol.for('slots')].filter(slot => slot.ref === '${templateObject.slot}').shift() || parent
|
|
102
|
+
elementConfig${counter}['parent'] = component[Symbol.for('slots')] !== undefined && Array.isArray(component[Symbol.for('slots')]) === true && component[Symbol.for('slots')].filter(slot => slot.ref === '${templateObject.slot}').shift() || parent
|
|
100
103
|
`)
|
|
101
104
|
}
|
|
102
105
|
|
|
@@ -149,6 +152,12 @@ const generateElementCode = function (
|
|
|
149
152
|
|
|
150
153
|
renderCode.push(`${elm}.populate(elementConfig${counter})`)
|
|
151
154
|
|
|
155
|
+
renderCode.push(`
|
|
156
|
+
if(inSlot === true) {
|
|
157
|
+
slotChildCounter -= 1
|
|
158
|
+
}
|
|
159
|
+
`)
|
|
160
|
+
|
|
152
161
|
if (options.forloop) {
|
|
153
162
|
renderCode.push('}')
|
|
154
163
|
}
|
|
@@ -247,7 +256,8 @@ const generateComponentCode = function (
|
|
|
247
256
|
|
|
248
257
|
if (${elm}[Symbol.for('slots')][0]) {
|
|
249
258
|
parent = ${elm}[Symbol.for('slots')][0]
|
|
250
|
-
|
|
259
|
+
slotComponent = ${elm}
|
|
260
|
+
inSlot = true
|
|
251
261
|
} else {
|
|
252
262
|
parent = ${elm}[Symbol.for('children')][0]
|
|
253
263
|
}
|
|
@@ -258,15 +268,24 @@ const generateComponentCode = function (
|
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
if (children) {
|
|
271
|
+
if (!options.forloop) {
|
|
272
|
+
renderCode.push(`
|
|
273
|
+
if(inSlot === true) {
|
|
274
|
+
slotChildCounter = ${children.length} + 1
|
|
275
|
+
}
|
|
276
|
+
`)
|
|
277
|
+
}
|
|
261
278
|
counter++
|
|
262
279
|
generateElementCode.call(this, { children }, false, { ...options })
|
|
263
280
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
281
|
+
|
|
282
|
+
if (!options.forloop) {
|
|
283
|
+
renderCode.push(`
|
|
284
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
285
|
+
inSlot = false
|
|
286
|
+
}
|
|
287
|
+
`)
|
|
288
|
+
}
|
|
270
289
|
}
|
|
271
290
|
|
|
272
291
|
const generateForLoopCode = function (templateObject, parent) {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { ImageTexture, Texture } from '@lightningjs/renderer'
|
|
19
18
|
import { track, trigger, pauseTracking, resumeTracking } from './effect.js'
|
|
20
19
|
import symbols from '../symbols.js'
|
|
21
20
|
import deepEqualArray from '../../helpers/deepEqualArray.js'
|
|
@@ -30,14 +29,15 @@ export const getRaw = (value) => {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
const reactiveProxy = (original, _parent = null, _key, global) => {
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
// only create a proxy for plain objects. Other classes, Blits components, renderer textures etc
|
|
33
|
+
// are returned unmodified and will not become reactive
|
|
34
|
+
if (
|
|
35
|
+
typeof original === 'object' &&
|
|
36
|
+
Array.isArray(original) === false &&
|
|
37
|
+
Object.getPrototypeOf(original) !== Object.prototype
|
|
38
|
+
) {
|
|
39
|
+
return original
|
|
39
40
|
}
|
|
40
|
-
|
|
41
41
|
// if original object is already a proxy, don't create a new one but return the existing one instead
|
|
42
42
|
const existingProxy = proxyMap.get(original)
|
|
43
43
|
if (existingProxy !== undefined) {
|
|
@@ -16,23 +16,52 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import blitsfileconverter from '../src/lib/blitsfileconverter/blitsfileconverter.js'
|
|
19
|
+
import path from 'node:path'
|
|
20
|
+
import fs from 'node:fs'
|
|
21
|
+
import { createRequire } from 'module'
|
|
19
22
|
|
|
20
23
|
export default function blitsFileType() {
|
|
21
24
|
return {
|
|
22
25
|
name: 'vite-plugin-blits-file-type',
|
|
23
26
|
enforce: 'pre',
|
|
24
|
-
|
|
27
|
+
|
|
28
|
+
resolveId(source, importer) {
|
|
29
|
+
if (source.endsWith('.blits')) {
|
|
30
|
+
return importer ? path.resolve(path.dirname(importer), source) : path.resolve(source)
|
|
31
|
+
}
|
|
32
|
+
return null
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
load(id) {
|
|
25
36
|
if (id.endsWith('.blits')) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
const source = fs.readFileSync(id, 'utf-8')
|
|
38
|
+
let code = blitsfileconverter(source)
|
|
39
|
+
|
|
40
|
+
// Check for TypeScript and transpile to JS if needed
|
|
41
|
+
if (/<script\s+lang=["']ts["']/.test(source)) {
|
|
42
|
+
// Resolve the local typescript dependency
|
|
43
|
+
const userRequire = createRequire(process.cwd() + '/')
|
|
44
|
+
let ts
|
|
45
|
+
try {
|
|
46
|
+
ts = userRequire('typescript')
|
|
47
|
+
} catch (err) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`\n\nThe file "${id}" contains \`lang="ts"\`, indicating it uses TypeScript. \nTo enable TypeScript support, please install the 'typescript' package as a dev dependency by running:\n\n` +
|
|
50
|
+
' npm install --save-dev typescript\n\n'
|
|
51
|
+
)
|
|
31
52
|
}
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
const transpiled = ts.transpileModule(code, {
|
|
54
|
+
compilerOptions: { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.ESNext },
|
|
55
|
+
})
|
|
56
|
+
code = transpiled.outputText
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
code,
|
|
61
|
+
map: null,
|
|
34
62
|
}
|
|
35
63
|
}
|
|
64
|
+
return null
|
|
36
65
|
},
|
|
37
66
|
}
|
|
38
67
|
}
|
package/vite/preCompiler.js
CHANGED
|
@@ -30,12 +30,13 @@ export default function () {
|
|
|
30
30
|
|
|
31
31
|
const fileExtension = path.extname(filePath)
|
|
32
32
|
|
|
33
|
-
// we should only precompile .js and .ts files
|
|
34
|
-
if (fileExtension === '.js' || fileExtension === '.ts') {
|
|
33
|
+
// we should only precompile .blits, .js and .ts files
|
|
34
|
+
if (fileExtension === '.js' || fileExtension === '.ts' || fileExtension === '.blits') {
|
|
35
35
|
return compiler(source, filePath)
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
// vite expects null if there is no modification
|
|
39
|
+
return null
|
|
39
40
|
},
|
|
40
41
|
}
|
|
41
42
|
}
|