@lightningjs/blits 1.20.0 → 1.20.1

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,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.20.1
4
+
5
+ _14 feb 2025_
6
+
7
+ - Added error message when root element in template contains a `:for`-attribute
8
+ - Added workaround fix for shader caching issue
9
+ - Upgraded to renderer v2.12.1
10
+
3
11
  ## v1.20.0
4
12
 
5
13
  _12 feb 2025_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.20.0",
3
+ "version": "1.20.1",
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.12.0"
55
+ "@lightningjs/renderer": "^2.12.1"
56
56
  },
57
57
  "repository": {
58
58
  "type": "git",
@@ -22,6 +22,9 @@ import { Log } from '../../lib/log.js'
22
22
  import symbols from '../../lib/symbols.js'
23
23
  import Settings from '../../settings.js'
24
24
 
25
+ // temporary counter to work around shader caching issues
26
+ let counter = 0
27
+
25
28
  const createPaddingObject = (padding, direction) => {
26
29
  if (padding === undefined) {
27
30
  return { start: 0, end: 0, oppositeStart: 0, oppositeEnd: 0 }
@@ -330,14 +333,21 @@ const propsTransformer = {
330
333
  if (this.element.node === undefined) {
331
334
  this.props['shader'] = renderer.createShader('DynamicShader', {
332
335
  effects: v.map((effect) => {
333
- return renderer.createEffect(effect.type, effect.props, effect.type)
336
+ // temporary add counter to work around shader caching issues
337
+ return renderer.createEffect(
338
+ effect.type,
339
+ effect.props,
340
+ effect.type + this.element.counter
341
+ )
334
342
  }),
335
343
  })
336
344
  } else {
337
345
  for (let i = 0; i < v.length; i++) {
338
- const target = this.element.node.shader.props[v[i].type]
346
+ // temporary add counter to work around shader caching issues
347
+ const target = this.element.node.shader.props[v[i].type + this.element.counter]
339
348
  const props = Object.keys(v[i].props)
340
349
 
350
+ if (target == undefined) continue
341
351
  for (let j = 0; j < props.length; j++) {
342
352
  target[props[j]] = v[i].props[props[j]]
343
353
  }
@@ -642,5 +652,6 @@ export default (config, component) => {
642
652
  scheduledTransitions: {},
643
653
  config,
644
654
  component,
655
+ counter: counter++,
645
656
  })
646
657
  }
@@ -239,6 +239,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
239
239
  #2: There must be exactly one top-level element (an element at level 0). This element may either be a self-closing
240
240
  element or an opening tag followed by a closing tag. If more than one top-level element is encountered, an error
241
241
  should be thrown.
242
+ But the top-level element can not have :for attribute.
242
243
  */
243
244
  const format = (parsedData) => {
244
245
  let stack = []
@@ -254,6 +255,10 @@ export default (template = '', componentName, parentComponent, filePath = null)
254
255
  if (rootElementDefined) {
255
256
  throw TemplateStructureError('MultipleTopLevelTags', element)
256
257
  }
258
+ // Check for :for attribute on root level element
259
+ if (element[':for'] !== undefined) {
260
+ throw TemplateStructureError('ForAttributeOnRootElement', element)
261
+ }
257
262
  rootElementDefined = true
258
263
  }
259
264
 
@@ -1388,3 +1388,24 @@ test('Parse template with color and effects attributes and parsing should conver
1388
1388
  )
1389
1389
  assert.end()
1390
1390
  })
1391
+
1392
+ test('Parse template with :for attribute on root element and parsing should fail', (assert) => {
1393
+ const template = `
1394
+ <Element :for="item in $items">
1395
+ <Text content="$item.name" />
1396
+ </Element>
1397
+ `
1398
+
1399
+ try {
1400
+ parser(template)
1401
+ assert.fail('Parser should throw TemplateStructureError:ForAttributeOnRootElement')
1402
+ } catch (error) {
1403
+ assert.equal(error.name, 'TemplateStructureError', 'Parser should throw TemplateStructureError')
1404
+ assert.ok(
1405
+ error.message.startsWith('ForAttributeOnRootElement'),
1406
+ 'Parser should throw TemplateStructureError:ForAttributeOnRootElement'
1407
+ )
1408
+ }
1409
+
1410
+ assert.end()
1411
+ })