@lightningjs/blits 1.16.1 → 1.17.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/.eslintrc.cjs CHANGED
@@ -50,10 +50,14 @@ module.exports = {
50
50
  },
51
51
  ],
52
52
  },
53
+ parser: '@babel/eslint-parser',
53
54
  parserOptions: {
54
55
  parser: 'babel-eslint',
55
56
  ecmaVersion: 2018,
56
57
  sourceType: 'module',
58
+ babelOptions: {
59
+ plugins: ['@babel/plugin-syntax-import-assertions'],
60
+ },
57
61
  },
58
62
  globals: {
59
63
  globalThis: false,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.17.0
4
+
5
+ _24 jan 2025_
6
+
7
+ - Deprecated `wordwrap`-attribute on Text component in favour of `maxwidth`
8
+ - Added documentation about text overflow
9
+ - Upgraded renderer to v2.9.1 and added `canvas` and `textureProcessingLimit` launch options
10
+
11
+ ## v1.16.2
12
+
13
+ _21 jan 2025_
14
+
15
+ - Upgraded to latest version of MSDF font generator, with fix for missing presets
16
+
17
+
3
18
  ## v1.16.1
4
19
 
5
20
  _17 jan 2025_
@@ -24,13 +24,13 @@ The Text-tag accepts the following attributes:
24
24
  - `size` - the font size, defaults to `32`
25
25
  - `color` - the color to display for the text, defaults to `white` and can be any of the supported Blits color formats (HTML, hexadecimal or rgb(a))
26
26
  - `letterspacing` - letterspacing in pixels, defaults to `0`
27
- - `align` - the alignment of the text, can be `left`, `right`, or `center`, defaults to `left`. Centering text and aligning text to the right requires the `wordwrap` attribute to be set as well.
28
- - `wordwrap` - the max length of a line of text in pixels, words surpassing this length will be broken and wrapped onto the next line. This attribute is required when aligning center or right
27
+ - `align` - the alignment of the text, can be `left`, `right`, or `center`, defaults to `left`. Centering text and aligning text to the right requires the `maxwidth` attribute to be set as well.
28
+ - `maxwidth` - the max length of a line of text in pixels, words surpassing this length will be broken and wrapped onto the next line. This attribute is required when aligning center or right. Previously this attribute was `wordwrap`, which has now been deprecated in favour of `maxwidth`.
29
29
  - `maxlines` - maximum number of lines that will be displayed
30
30
  - `maxheight` - maximum height of a text block, lines that don't fit within this height will not be displayed
31
31
  - `lineheight` - the spacing between lines in pixels
32
32
  - `contain` - the strategy for containing text within the bounds, can be `none` (default), `width`, or `both`. In most cases, the value of this attribute will automatically be set by Blits, based on the other specified attributes
33
- - `textoverflow` - the suffix to be added when text is cropped due to bounds limits, defaults to `...`
33
+ - `textoverflow` - the suffix to be added when text is cropped due to bounds limits, defaults to `...` (see more details [here](#text-overflow))
34
34
 
35
35
  ## Text dimensions
36
36
 
@@ -67,6 +67,14 @@ export default Blits.Component('MyComponent', {
67
67
  }
68
68
  ```
69
69
 
70
+ ## Text overflow
71
+
72
+ The text renderer offers the ability to display a _text overflow suffix_ when the text exceeds the bounds of the Text component.
73
+
74
+ This functionality is automatically enabled, but requires that both a _horizontal_ boundary (using `maxwidth`) and a _vertical_ boundary (using `maxlines` or `maxheight`) are specified on the Text component.
75
+
76
+ The `textoverflow`-attribute itself is not required, unless you want to use another suffix than the standard `...`. If you want _no suffix_ (and just a hard cutoff), the`textoverflow`-attribute should be set to `false` or an _empty string_.
77
+
70
78
  ## SDF and Canvas2d
71
79
 
72
80
  Compared to Lightning 2, texts have improved a lot in Lightning 3, thanks to the SDF (Signed Distance Field) Text renderer.
package/index.d.ts CHANGED
@@ -774,7 +774,21 @@ declare module '@lightningjs/blits' {
774
774
  *
775
775
  * Defaults to `50` (ms)
776
776
  */
777
- holdTimeout?: number
777
+ holdTimeout?: number,
778
+ /**
779
+ * Custom canvas object used to render the App to.
780
+ *
781
+ * When not provided, the Lightning renderer will create a
782
+ * new Canvas element and inject it into the DOM
783
+ */
784
+ canvas?: HTMLCanvasElement,
785
+ /**
786
+ * The maximum number of textures to process in a single frame. This is used to
787
+ * prevent the renderer from processing too many textures in a single frame.
788
+ *
789
+ * Defaults to `0` (meaning no limit)
790
+ */
791
+ textureProcessingLimit?: number
778
792
  }
779
793
 
780
794
  interface State {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.16.1",
3
+ "version": "1.17.0",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -35,6 +35,8 @@
35
35
  "author": "Michiel van der Geest <hello@michielvandergeest.com>",
36
36
  "license": "Apache-2.0",
37
37
  "devDependencies": {
38
+ "@babel/eslint-parser": "^7.26.5",
39
+ "@babel/plugin-syntax-import-assertions": "^7.26.0",
38
40
  "babel-eslint": "^10.1.0",
39
41
  "c8": "^8.0.1",
40
42
  "eslint": "^8.8.0",
@@ -49,8 +51,8 @@
49
51
  "tape": "^5.5.0"
50
52
  },
51
53
  "dependencies": {
52
- "@lightningjs/msdf-generator": "^1.1.0",
53
- "@lightningjs/renderer": "^2.8.0"
54
+ "@lightningjs/msdf-generator": "^1.1.1",
55
+ "@lightningjs/renderer": "^2.9.1"
54
56
  },
55
57
  "repository": {
56
58
  "type": "git",
@@ -19,51 +19,52 @@ import Component from '../component.js'
19
19
 
20
20
  export default () =>
21
21
  Component('Circle', {
22
- /* eslint-disable no-unused-vars */
23
- code: {
24
- render: function anonymous(parent, component, context, components, effect, getRaw) {
25
- const elms = []
26
- let componentType
27
- const rootComponent = component
28
- let propData
29
- let slotComponent
30
- let inSlot = false
31
- let slotChildCounter = 0
32
- const elementConfig0 = {}
22
+ /* eslint-disable no-unused-vars */
23
+ code: { render: function anonymous(parent,component,context,components,effect,getRaw
24
+ ) {
25
+ const elms = []
26
+ let componentType
27
+ const rootComponent = component
28
+ let propData
29
+ let slotComponent
30
+ let inSlot = false
31
+ let slotChildCounter = 0
32
+ const elementConfig0 = {}
33
33
 
34
- elms[0] = this.element(
35
- { parent: parent || 'root' },
36
- inSlot === true ? slotComponent : component
37
- )
34
+ elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
35
+
36
+ elementConfig0['color'] = component.color
37
+ elementConfig0['w'] = component.size
38
+ elementConfig0['h'] = component.size
39
+ elementConfig0['effects'] = [component.shader('radius', {radius: component.radius})]
40
+ elms[0].populate(elementConfig0)
38
41
 
39
- elementConfig0['color'] = component.color
40
- elementConfig0['w'] = component.size
41
- elementConfig0['h'] = component.size
42
- elementConfig0['effects'] = [component.shader('radius', { radius: component.radius })]
43
- elms[0].populate(elementConfig0)
42
+ if(inSlot === true) {
43
+ slotChildCounter -= 1
44
+ }
45
+
46
+ return elms
47
+ }, effects: [function anonymous(component,elms,context,components,rootComponent,effect
48
+ ) {
44
49
 
45
- if (inSlot === true) {
46
- slotChildCounter -= 1
47
- }
50
+ elms[0].set('color', component.color)
51
+
52
+ },function anonymous(component,elms,context,components,rootComponent,effect
53
+ ) {
48
54
 
49
- return elms
50
- },
51
- effects: [
52
- function anonymous(component, elms, context, components, rootComponent, effect) {
53
- elms[0].set('color', component.color)
54
- },
55
- function anonymous(component, elms, context, components, rootComponent, effect) {
56
- elms[0].set('w', component.size)
57
- },
58
- function anonymous(component, elms, context, components, rootComponent, effect) {
59
- elms[0].set('h', component.size)
60
- },
61
- function anonymous(component, elms, context, components, rootComponent, effect) {
62
- elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
63
- },
64
- ],
65
- context: {},
66
- },
55
+ elms[0].set('w', component.size)
56
+
57
+ },function anonymous(component,elms,context,components,rootComponent,effect
58
+ ) {
59
+
60
+ elms[0].set('h', component.size)
61
+
62
+ },function anonymous(component,elms,context,components,rootComponent,effect
63
+ ) {
64
+
65
+ elms[0].set('effects', [component.shader('radius', {radius: component.radius})])
66
+
67
+ }], context: {}},
67
68
  props: [{ key: 'size', default: 40 }, 'color'],
68
69
  computed: {
69
70
  radius() {