@lightningjs/blits 1.19.0 → 1.20.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 CHANGED
@@ -1,7 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.20.0
4
+
5
+ _12 feb 2025_
6
+
7
+ - Improved attribute definitions used for autocompletion in VScode extension
8
+ - Fixed calculation of `align-items` in Layout component
9
+ - Fixed issue with sorting reactive arrays
10
+ - Upgraded to renderer v2.12.0
11
+
12
+ ## v1.19.1
13
+
14
+ _3 feb 2025_
15
+
16
+ - Removed left-over console.log
17
+ - Upgraded to renderer v2.11.1
18
+ - Fixed issues with wrongly pre-compiling `template` key of non-blits related objects
19
+
3
20
  ## v1.19.0
4
21
 
22
+ _31 jan 2025_
23
+
5
24
  - Fixed `show`-attribute when an `alpha`-attribute is also present
6
25
  - Added `inspector-data`-attribute to help with automated testing based on the Lightning inspector
7
26
  - Added reactivity to Route changes (`this.$router.state.path` and `this.$router.state.navigating`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@lightningjs/msdf-generator": "^1.1.1",
55
- "@lightningjs/renderer": "^2.10.0"
55
+ "@lightningjs/renderer": "^2.12.0"
56
56
  },
57
57
  "repository": {
58
58
  "type": "git",
@@ -113,7 +113,7 @@ const layoutFn = function (config) {
113
113
  if (align !== 0) {
114
114
  for (let i = 0; i < childrenLength; i++) {
115
115
  const node = children[i]
116
- node[oppositePosition] = otherDimension
116
+ node[oppositePosition] = otherDimension * align
117
117
  node[oppositeMount] = align
118
118
  }
119
119
  }
@@ -309,7 +309,7 @@ const propsTransformer = {
309
309
  }
310
310
  },
311
311
  set alpha(v) {
312
- if(this.raw['show'] === undefined || this.raw['show'] === true) {
312
+ if (this.raw['show'] === undefined || this.raw['show'] === true) {
313
313
  this.props['alpha'] = v
314
314
  }
315
315
  },
@@ -43,8 +43,6 @@ const textRenderEngines = (settings) => {
43
43
  }
44
44
 
45
45
  export default (App, target, settings = {}) => {
46
- console.log(RENDER_QUALITIES[settings.renderQuality] || settings.renderQuality || 1)
47
-
48
46
  renderer = new RendererMain(
49
47
  {
50
48
  appWidth: settings.w || 1920,
@@ -35,32 +35,37 @@ export default (source, filePath) => {
35
35
 
36
36
  for (const template of templates) {
37
37
  if (template[2]) {
38
- const templateStartIndex = template.index + offset
39
- const templateEndIndex = templateStartIndex + template[0].length
40
38
  const templateContent = template[2]
41
39
 
42
- // Parse the template
43
- let resourceName = 'Blits.Application'
44
- if (source.indexOf('Blits.Component(') > -1) {
45
- resourceName = source.match(/Blits\.Component\(['"](.*)['"]\s*,/)[1]
46
- }
40
+ // Only process if it looks like a Blits template
41
+ if (templateContent.match(/^\s*(<!--[\s\S]*?-->|<[A-Za-z][^>]*>)/s)) {
42
+ const templateStartIndex = template.index + offset
43
+ const templateEndIndex = templateStartIndex + template[0].length
44
+
47
45
 
48
- const parsed = parser(templateContent, resourceName, null, filePath)
46
+ // Parse the template
47
+ let resourceName = 'Blits.Application'
48
+ if (source.indexOf('Blits.Component(') > -1) {
49
+ resourceName = source.match(/Blits\.Component\(['"](.*)['"]\s*,/)[1]
50
+ }
49
51
 
50
- // Generate the code
51
- const code = generator.call({ components: {} }, parsed)
52
+ const parsed = parser(templateContent, resourceName, null, filePath)
52
53
 
53
- // Insert the code in the component using the 'code' key, replacing the template key
54
- const replacement = `/* eslint-disable no-unused-vars */ \ncode: { render: ${code.render.toString()}, effects: [${code.effects.map(
55
- (fn) => fn.toString()
56
- )}], context: {}}`
54
+ // Generate the code
55
+ const code = generator.call({ components: {} }, parsed)
57
56
 
58
- offset += replacement.length - template[0].length
57
+ // Insert the code in the component using the 'code' key, replacing the template key
58
+ const replacement = `/* eslint-disable no-unused-vars */ \ncode: { render: ${code.render.toString()}, effects: [${code.effects.map(
59
+ (fn) => fn.toString()
60
+ )}], context: {}}`
59
61
 
60
- newSource =
61
- newSource.substring(0, templateStartIndex) +
62
- replacement +
63
- newSource.substring(templateEndIndex)
62
+ offset += replacement.length - template[0].length
63
+
64
+ newSource =
65
+ newSource.substring(0, templateStartIndex) +
66
+ replacement +
67
+ newSource.substring(templateEndIndex)
68
+ }
64
69
  }
65
70
  }
66
71
  return newSource
@@ -113,6 +113,7 @@ const reactiveProxy = (original, _parent = null, _key, global) => {
113
113
  } else if (
114
114
  target[key] !== null &&
115
115
  target[key] !== undefined &&
116
+ Array.isArray(target) === false &&
116
117
  Object.getPrototypeOf(value) === Object.prototype
117
118
  ) {
118
119
  value = Object.assign(receiver[key], value)
@@ -0,0 +1,589 @@
1
+ {
2
+ "x": {
3
+ "attrType": "regular",
4
+ "types": [
5
+ "number"
6
+ ],
7
+ "defaultValue": 0,
8
+ "reactive": true,
9
+ "description": "The x position of the Element in pixels, relative to its parent - allows negative values and decimals.",
10
+ "usedIn": [
11
+ "Element",
12
+ "Text",
13
+ "Layout",
14
+ "RouterView",
15
+ "Component"
16
+ ]
17
+ },
18
+ "y": {
19
+ "attrType": "regular",
20
+ "types": [
21
+ "number"
22
+ ],
23
+ "defaultValue": 0,
24
+ "reactive": true,
25
+ "description": "The y position of the Element in pixels, relative to its parent - allows negative values and decimals.",
26
+ "usedIn": [
27
+ "Element",
28
+ "Text",
29
+ "Layout",
30
+ "RouterView",
31
+ "Component"
32
+ ]
33
+ },
34
+ "z": {
35
+ "attrType": "regular",
36
+ "types": [
37
+ "number"
38
+ ],
39
+ "defaultValue": 0,
40
+ "reactive": true,
41
+ "description": "The z index of the element.",
42
+ "usedIn": [
43
+ "Element",
44
+ "Text",
45
+ "Layout",
46
+ "RouterView"
47
+ ]
48
+ },
49
+ "w": {
50
+ "attrType": "regular",
51
+ "types": [
52
+ "number"
53
+ ],
54
+ "defaultValue": 0,
55
+ "reactive": true,
56
+ "description": "The width of the element in pixels. Allows negative values and decimals.",
57
+ "usedIn": [
58
+ "Element",
59
+ "Text",
60
+ "RouterView"
61
+ ]
62
+ },
63
+ "h": {
64
+ "attrType": "regular",
65
+ "types": [
66
+ "number"
67
+ ],
68
+ "defaultValue": 0,
69
+ "reactive": true,
70
+ "description": "The height of the element in pixels, relative to its parent. Allows negative values and decimals.",
71
+ "usedIn": [
72
+ "Element",
73
+ "Text",
74
+ "RouterView"
75
+ ]
76
+ },
77
+ "zIndex": {
78
+ "attrType": "regular",
79
+ "types": [
80
+ "number"
81
+ ],
82
+ "defaultValue": 0,
83
+ "reactive": true,
84
+ "description": "The z-index of the element.",
85
+ "usedIn": [
86
+ "Element",
87
+ "Text",
88
+ "Layout",
89
+ "RouterView"
90
+ ]
91
+ },
92
+ "width": {
93
+ "attrType": "regular",
94
+ "types": [
95
+ "number"
96
+ ],
97
+ "defaultValue": 0,
98
+ "reactive": true,
99
+ "description": "The width of the element in pixels. Allows negative values and decimals.",
100
+ "usedIn": [
101
+ "Element",
102
+ "Text",
103
+ "RouterView"
104
+ ]
105
+ },
106
+ "height": {
107
+ "attrType": "regular",
108
+ "types": [
109
+ "number"
110
+ ],
111
+ "defaultValue": 0,
112
+ "reactive": true,
113
+ "description": "The height of the element in pixels, relative to its parent. Allows negative values and decimals.",
114
+ "usedIn": [
115
+ "Element",
116
+ "Text",
117
+ "RouterView"
118
+ ]
119
+ },
120
+ "color": {
121
+ "attrType": "regular",
122
+ "types": [
123
+ "string"
124
+ ],
125
+ "defaultValue": "transparent",
126
+ "reactive": true,
127
+ "description": "The color of the Element. Allows any hexadecimal, hexadecimal with alpha channel, hexadecimal shorthands, RGB, RGBA, and HTML color names.",
128
+ "usedIn": [
129
+ "Element",
130
+ "Text",
131
+ "Layout",
132
+ "RouterView"
133
+ ]
134
+ },
135
+ "alpha": {
136
+ "attrType": "regular",
137
+ "types": [
138
+ "number"
139
+ ],
140
+ "defaultValue": 1,
141
+ "reactive": true,
142
+ "description": "The alpha attribute controls the opacity of the element. Allows values equal to 0, 1, and between 0 and 1.",
143
+ "usedIn": [
144
+ "Element",
145
+ "Text",
146
+ "Layout",
147
+ "RouterView",
148
+ "Component"
149
+ ]
150
+ },
151
+ "rotation": {
152
+ "attrType": "regular",
153
+ "types": [
154
+ "number"
155
+ ],
156
+ "defaultValue": 0,
157
+ "reactive": true,
158
+ "description": "The rotation attribute rotates the Element. Allows both positive and negative values in degrees.",
159
+ "usedIn": [
160
+ "Element",
161
+ "Text",
162
+ "Layout",
163
+ "RouterView"
164
+ ]
165
+ },
166
+ "scale": {
167
+ "attrType": "regular",
168
+ "types": [
169
+ "number"
170
+ ],
171
+ "defaultValue": 1,
172
+ "reactive": true,
173
+ "description": "The scale attribute scales the element. Allows any value greater than 0.",
174
+ "usedIn": [
175
+ "Element",
176
+ "Text",
177
+ "Layout",
178
+ "RouterView",
179
+ "Component"
180
+ ]
181
+ },
182
+ "mount": {
183
+ "attrType": "regular",
184
+ "types": [
185
+ "number",
186
+ {
187
+ "type": "object",
188
+ "properties": {
189
+ "x": {
190
+ "type": "number"
191
+ },
192
+ "y": {
193
+ "type": "number"
194
+ }
195
+ }
196
+ }
197
+ ],
198
+ "defaultValue": 0,
199
+ "reactive": true,
200
+ "description": "The x or y position of the Element in pixels, relative to its parent. Allows values between 0 and 1 and decimals.",
201
+ "usedIn": [
202
+ "Element",
203
+ "Text",
204
+ "Layout",
205
+ "RouterView"
206
+ ]
207
+ },
208
+ "pivot": {
209
+ "attrType": "regular",
210
+ "types": [
211
+ "number",
212
+ {
213
+ "type": "object",
214
+ "properties": {
215
+ "x": {
216
+ "type": "number"
217
+ },
218
+ "y": {
219
+ "type": "number"
220
+ }
221
+ }
222
+ }
223
+ ],
224
+ "defaultValue": 0,
225
+ "reactive": true,
226
+ "description": "The x or y position of the pivot point in pixels, relative to its parent. Allows values between 0 and 1 and decimals.",
227
+ "usedIn": [
228
+ "Element",
229
+ "Text",
230
+ "Layout",
231
+ "RouterView"
232
+ ]
233
+ },
234
+ "clipping": {
235
+ "attrType": "regular",
236
+ "types": [
237
+ "enum"
238
+ ],
239
+ "values": [
240
+ "true",
241
+ "false"
242
+ ],
243
+ "defaultValue": "false",
244
+ "reactive": true,
245
+ "description": "The clipping attribute cuts off the element positioning within specified height and width. Possible values are true or false.",
246
+ "usedIn": [
247
+ "Element",
248
+ "Text",
249
+ "RouterView"
250
+ ]
251
+ },
252
+ "overflow": {
253
+ "attrType": "regular",
254
+ "types": [
255
+ "enum"
256
+ ],
257
+ "values": [
258
+ "true",
259
+ "false"
260
+ ],
261
+ "defaultValue": "true",
262
+ "reactive": true,
263
+ "description": "The overflow attribute allows the element to extend beyond the specified height and width. Possible values are true or false.",
264
+ "usedIn": [
265
+ "Text",
266
+ "Element"
267
+ ]
268
+ },
269
+ "content": {
270
+ "attrType": "regular",
271
+ "types": [
272
+ "string"
273
+ ],
274
+ "defaultValue": null,
275
+ "reactive": true,
276
+ "description": "The text to be displayed. Can be hardcoded text, a dynamic value, or a reactive value.",
277
+ "usedIn": [
278
+ "Text"
279
+ ]
280
+ },
281
+ "font": {
282
+ "attrType": "regular",
283
+ "types": [
284
+ "string"
285
+ ],
286
+ "defaultValue": "sans-serif",
287
+ "reactive": true,
288
+ "description": "The font family.",
289
+ "usedIn": [
290
+ "Text"
291
+ ]
292
+ },
293
+ "size": {
294
+ "attrType": "regular",
295
+ "types": [
296
+ "number"
297
+ ],
298
+ "defaultValue": 32,
299
+ "reactive": true,
300
+ "description": "The size of a text element. Allows any number greater than or equal to zero.",
301
+ "usedIn": [
302
+ "Text"
303
+ ]
304
+ },
305
+ "letterspacing": {
306
+ "attrType": "regular",
307
+ "types": [
308
+ "number"
309
+ ],
310
+ "defaultValue": 0,
311
+ "reactive": true,
312
+ "description": "Letter spacing in pixels. Allows any number greater than or equal to zero.",
313
+ "usedIn": [
314
+ "Text"
315
+ ]
316
+ },
317
+ "align": {
318
+ "attrType": "regular",
319
+ "types": [
320
+ "enum"
321
+ ],
322
+ "values": [
323
+ "left",
324
+ "right",
325
+ "center"
326
+ ],
327
+ "defaultValue": null,
328
+ "reactive": true,
329
+ "description": "Align position of the element.",
330
+ "usedIn": [
331
+ "Text"
332
+ ]
333
+ },
334
+ "maxwidth": {
335
+ "attrType": "regular",
336
+ "types": [
337
+ "number"
338
+ ],
339
+ "defaultValue": null,
340
+ "reactive": true,
341
+ "description": "The maximum length of a line of text in pixels.",
342
+ "usedIn": [
343
+ "Text"
344
+ ]
345
+ },
346
+ "maxlines": {
347
+ "attrType": "regular",
348
+ "types": [
349
+ "number"
350
+ ],
351
+ "defaultValue": null,
352
+ "reactive": true,
353
+ "description": "Maximum number of lines that will be displayed.",
354
+ "usedIn": [
355
+ "Text"
356
+ ]
357
+ },
358
+ "maxheight": {
359
+ "attrType": "regular",
360
+ "types": [
361
+ "number"
362
+ ],
363
+ "defaultValue": null,
364
+ "reactive": true,
365
+ "description": "Maximum height of a text block; lines exceeding this height will not be displayed.",
366
+ "usedIn": [
367
+ "Text"
368
+ ]
369
+ },
370
+ "lineheight": {
371
+ "attrType": "regular",
372
+ "types": [
373
+ "number"
374
+ ],
375
+ "defaultValue": null,
376
+ "reactive": true,
377
+ "description": "The spacing between lines in pixels.",
378
+ "usedIn": [
379
+ "Text"
380
+ ]
381
+ },
382
+ "contain": {
383
+ "attrType": "regular",
384
+ "types": [
385
+ "enum"
386
+ ],
387
+ "values": [
388
+ "none",
389
+ "width",
390
+ "both"
391
+ ],
392
+ "defaultValue": "none",
393
+ "reactive": true,
394
+ "description": "The strategy for containing text within the bounds.",
395
+ "usedIn": [
396
+ "Text"
397
+ ]
398
+ },
399
+ "textoverflow": {
400
+ "attrType": "regular",
401
+ "types": [
402
+ "string"
403
+ ],
404
+ "defaultValue": null,
405
+ "reactive": true,
406
+ "description": "The suffix to be added when text is cropped due to bounds limits. Defaults to ...",
407
+ "usedIn": [
408
+ "Text"
409
+ ]
410
+ },
411
+ "direction": {
412
+ "attrType": "regular",
413
+ "types": [
414
+ "enum"
415
+ ],
416
+ "values": [
417
+ "horizontal",
418
+ "vertical"
419
+ ],
420
+ "defaultValue": "horizontal",
421
+ "reactive": true,
422
+ "description": "Controls the direction of content.",
423
+ "usedIn": [
424
+ "Layout"
425
+ ]
426
+ },
427
+ "gap": {
428
+ "attrType": "regular",
429
+ "types": [
430
+ "number"
431
+ ],
432
+ "defaultValue": null,
433
+ "reactive": true,
434
+ "description": "Controls how much space will be added between each Element or Component.",
435
+ "usedIn": [
436
+ "Layout"
437
+ ]
438
+ },
439
+ "is": {
440
+ "attrType": "regular",
441
+ "types": [
442
+ "string"
443
+ ],
444
+ "defaultValue": null,
445
+ "reactive": true,
446
+ "description": "Dynamically instantiates a Component.",
447
+ "usedIn": [
448
+ "Component"
449
+ ]
450
+ },
451
+ "ref": {
452
+ "attrType": "regular",
453
+ "types": [
454
+ "string"
455
+ ],
456
+ "defaultValue": null,
457
+ "reactive": true,
458
+ "description": "Refers to the Element or Component in the template.",
459
+ "usedIn": [
460
+ "Element",
461
+ "Text",
462
+ "Layout",
463
+ "RouterView",
464
+ "Component"
465
+ ]
466
+ },
467
+ "for": {
468
+ "attrType": "regular",
469
+ "types": [
470
+ "string"
471
+ ],
472
+ "defaultValue": null,
473
+ "reactive": true,
474
+ "description": "Directive for repeating multiple instances of an Element or a Component.",
475
+ "usedIn": [
476
+ "Element",
477
+ "Text",
478
+ "Layout",
479
+ "RouterView",
480
+ "Component"
481
+ ]
482
+ },
483
+ "show": {
484
+ "attrType": "regular",
485
+ "types": [
486
+ "string"
487
+ ],
488
+ "defaultValue": null,
489
+ "reactive": true,
490
+ "description": "Conditionally shows and hides Components and Elements.",
491
+ "usedIn": [
492
+ "Element",
493
+ "Text",
494
+ "Layout",
495
+ "RouterView",
496
+ "Component"
497
+ ]
498
+ },
499
+ "align-items": {
500
+ "attrType": "regular",
501
+ "types": [
502
+ "enum"
503
+ ],
504
+ "values": [
505
+ "start",
506
+ "center",
507
+ "end"
508
+ ],
509
+ "defaultValue": null,
510
+ "reactive": true,
511
+ "description": "Specifies how to align children on the opposite axis.",
512
+ "usedIn": [
513
+ "Layout"
514
+ ]
515
+ },
516
+ "padding": {
517
+ "attrType": "regular",
518
+ "types": [
519
+ "number",
520
+ {
521
+ "type": "object",
522
+ "properties": {
523
+ "top": {
524
+ "type": "number"
525
+ },
526
+ "bottom": {
527
+ "type": "number"
528
+ },
529
+ "left": {
530
+ "type": "number"
531
+ },
532
+ "right": {
533
+ "type": "number"
534
+ },
535
+ "x": {
536
+ "type": "number"
537
+ },
538
+ "y": {
539
+ "type": "number"
540
+ }
541
+ }
542
+ }
543
+ ],
544
+ "defaultValue": null,
545
+ "reactive": true,
546
+ "description": "Adds spacing between the content and the edges of the Layout Component.",
547
+ "usedIn": [
548
+ "Layout"
549
+ ]
550
+ },
551
+ "@loaded": {
552
+ "attrType": "event",
553
+ "types": [
554
+ "string"
555
+ ],
556
+ "defaultValue": null,
557
+ "reactive": false,
558
+ "description": "Fires when an image or text element loads, providing its dimensions. Must be a function reference.",
559
+ "usedIn": [
560
+ "Element",
561
+ "Text"
562
+ ]
563
+ },
564
+ "@error": {
565
+ "attrType": "event",
566
+ "types": [
567
+ "string"
568
+ ],
569
+ "defaultValue": null,
570
+ "reactive": false,
571
+ "description": " Fires when an image fails to load, passing an error message. Must be a function reference.",
572
+ "usedIn": [
573
+ "Element",
574
+ "Text"
575
+ ]
576
+ },
577
+ "@updated": {
578
+ "attrType": "event",
579
+ "types": [
580
+ "string"
581
+ ],
582
+ "defaultValue": null,
583
+ "reactive": false,
584
+ "description": " Fires when each update in Layout children. Must be a function reference.",
585
+ "usedIn": [
586
+ "Layout"
587
+ ]
588
+ }
589
+ }