@lightningjs/blits 0.3.12 → 0.3.13

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.13
4
+
5
+ _18 oct 2023_
6
+
7
+ - Added support for `borderTop`, `borderBottom`, `borderLeft`, `borderRight` and `grayScale` effects
8
+ - Fixed `@loaded` and `@error` events on `<Text/>` componenent only firing once (and not for each change)
9
+ - Fixed loading of web canvas2d fonts
10
+ - Firex error when using `this`-reference in component state
11
+
3
12
  ## v0.3.12
4
13
 
5
14
  _17 oct 2023_
@@ -31,6 +31,6 @@
31
31
  "vite": "^4.0.4"
32
32
  },
33
33
  "dependencies": {
34
- "@lightningjs/blits": "^0.3.12"
34
+ "@lightningjs/blits": "^0.3.13"
35
35
  }
36
36
  }
package/docs/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Blits - Lightning 3 App Development Framework
2
2
 
3
- With Blits (formaly know as Bolt), the App Development Framework for Lightning 3, it becomes a breeze to build great Lightning 3 applications.
3
+ With Blits (formerly know as Bolt), the App Development Framework for Lightning 3, it becomes a breeze to build great Lightning 3 applications.
4
4
 
5
- Blits is built on top of the Lightning 3 Rendererer and aims to provide a **great developer experience**, making it fun and easy to build your apps!
5
+ Blits is built on top of the Lightning 3 Renderer and aims to provide a **great developer experience**, making it fun and easy to build your apps!
6
6
 
7
7
  Built from the ground up by the LightningJS team, we're offering a **Complete App framework**, full of features to speed up development, while keeping it **lightweight** with a focus on **performance**.
8
8
 
@@ -13,8 +13,8 @@ In order to position and set the dimensions of an Element, the following attribu
13
13
  - `x` - the x position of the Element in pixels, relative to it's parent - allows negative values and decimals
14
14
  - `y` - the y position of the Element in pixels, relative to it's parent - allows negative values and decimals
15
15
  - `z` - the z index of the element (optionally `zIndex` can be used as an alias)
16
- - `w` - the width of the element in pixels (optionaly `width` can be used as an alias)
17
- - `h` - the height of the element in pixels (optionaly `height` can be used as an alias)
16
+ - `w` - the width of the element in pixels (optionally `width` can be used as an alias)
17
+ - `h` - the height of the element in pixels (optionally `height` can be used as an alias)
18
18
 
19
19
  All positioning and dimension related attributes, when not specified, default to `0`.
20
20
 
@@ -111,7 +111,7 @@ Similar to rotation, scale is also applied recursively to children down the tree
111
111
 
112
112
  ### Mounting point
113
113
 
114
- For advanced positioning the `mount` attribute can come in handy. By default when you set the `x` and `y` position of an Element, the _top-left_ corner will be set to that position. But in some cases you may want to align the position starting at a different corner, or even any arbitray point in between.
114
+ For advanced positioning the `mount` attribute can come in handy. By default when you set the `x` and `y` position of an Element, the _top-left_ corner will be set to that position. But in some cases you may want to align the position starting at a different corner, or even any arbitrary point in between.
115
115
 
116
116
  The `mount` attribute accepts an _object literal_ that allows you to precisely control the mount position on the _x-axis_ and the mount position on the _y-axis_. The default value is `{x: 0, y: 0}`, which refers to the _top-left_ corner.
117
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.cjs",
6
6
  "exports": {
@@ -41,6 +41,7 @@
41
41
  "tape": "^5.5.0"
42
42
  },
43
43
  "dependencies": {
44
+ "@lightningjs/renderer": "^0.3.6",
44
45
  "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0"
45
46
  }
46
47
  }
@@ -22,7 +22,7 @@ export default () =>
22
22
  template: `
23
23
  <Element
24
24
  __textnode="true"
25
- :text="$text"
25
+ :text="$content"
26
26
  fontFamily="$font"
27
27
  :fontSize="$size"
28
28
  :color="$color"
@@ -61,9 +61,6 @@ export default () =>
61
61
  '@error',
62
62
  ],
63
63
  computed: {
64
- text() {
65
- return this.slotcontent || this.content || ''
66
- },
67
64
  _contain() {
68
65
  return this.contain || (this.w && this.h ? 'both' : this.w ? 'width' : 'none')
69
66
  },
package/src/element.js CHANGED
@@ -189,14 +189,14 @@ const Element = {
189
189
 
190
190
  if (props['@loaded']) {
191
191
  const event = props.__textnode ? 'textLoaded' : 'txLoaded'
192
- this.node.once(event, (el, { width: w, height: h }) => {
192
+ this.node.on(event, (el, { width: w, height: h }) => {
193
193
  props['@loaded']({ w, h }, this)
194
194
  })
195
195
  }
196
196
 
197
197
  if (props['@error']) {
198
198
  const event = props.__textnode ? 'textFailed' : 'txFailed'
199
- this.node.once(event, (el, error) => {
199
+ this.node.on(event, (el, error) => {
200
200
  props['@error'](error, this)
201
201
  })
202
202
  }
package/src/fontLoader.js CHANGED
@@ -10,7 +10,7 @@ export default class FontLoader extends CoreExtension {
10
10
  new SdfTrFontFace(font.family, {}, font.type, stage, font.png, font.json)
11
11
  )
12
12
  } else if (font.type === 'web') {
13
- new WebTrFontFace(font.family, {}, font.file)
13
+ stage.fontManager.addFontFace(new WebTrFontFace(font.family, {}, font.file))
14
14
  }
15
15
  })
16
16
  }
@@ -286,7 +286,16 @@ const interpolate = (val, component = 'component.') => {
286
286
  const cast = (val = '', key = false, component = 'component.') => {
287
287
  let castedValue
288
288
 
289
- if (key !== 'color' && !isNaN(parseFloat(val))) {
289
+ // inline content
290
+ if (key === 'content') {
291
+ if (val.startsWith('$')) {
292
+ castedValue = `${component}${val.replace('$', '')}`
293
+ } else {
294
+ castedValue = `'${parseInlineContent(val, component)}'`
295
+ }
296
+ }
297
+ // numeric
298
+ else if (key !== 'color' && !isNaN(parseFloat(val))) {
290
299
  castedValue = parseFloat(val)
291
300
  if (val.endsWith('%')) {
292
301
  const map = {
@@ -329,3 +338,15 @@ const cast = (val = '', key = false, component = 'component.') => {
329
338
  }
330
339
 
331
340
  const isReactiveKey = (str) => str.startsWith(':')
341
+
342
+ const parseInlineContent = (val, component) => {
343
+ const dynamicParts = /\{\{\s*(\$\S+)\s*\}\}/g
344
+ const matches = [...val.matchAll(dynamicParts)]
345
+
346
+ if (matches.length) {
347
+ for (let [match, arg] of matches) {
348
+ val = val.replace(match, `${arg.replace('$', `'+${component}`)}+'`)
349
+ }
350
+ }
351
+ return val
352
+ }
@@ -31,6 +31,10 @@ const shaders = {
31
31
  rounded: 'radius',
32
32
  border: 'border',
33
33
  borderTop: 'borderTop',
34
+ borderBottom: 'borderBottom',
35
+ borderLeft: 'borderLeft',
36
+ borderRight: 'borderRight',
37
+ grayScale: 'grayscale',
34
38
  glitch: 'glitch',
35
39
  }
36
40
 
@@ -20,7 +20,7 @@ import { Log } from '../log.js'
20
20
  export default (component, state) => {
21
21
  component.___stateKeys = []
22
22
 
23
- state = state.apply(component)
23
+ state = state.apply(component.prototype)
24
24
  Object.keys(state).forEach((key) => {
25
25
  if (component.___propKeys && component.___propKeys.indexOf(key) > -1) {
26
26
  Log.error(`State ${key} already exists as a prop`)