@lightningjs/blits 0.6.6 → 0.6.7

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,15 @@
1
1
  # Changelog
2
2
 
3
+ # v0.6.7
4
+
5
+ _26 jan 2024_
6
+
7
+ - Added `this.$clearInterval` and `this.$clearTimeout` helper functions to Component
8
+ - Updated Lightning renderer to version _0.7.0_
9
+ - Added `lineheight` and `textoverflow` attributes to `<Text />`-component
10
+ - Added setting for specifying maximum number of web workers to spawn (`webWorkersLimit`)
11
+ - Added fix for issue with setting up reactivity for (initially) empty for-loops
12
+
3
13
  # v0.6.6
4
14
 
5
15
  _24 jan 2024_
@@ -31,6 +31,6 @@
31
31
  "vite": "^4.0.4"
32
32
  },
33
33
  "dependencies": {
34
- "@lightningjs/blits": "^0.6.6"
34
+ "@lightningjs/blits": "^0.6.7"
35
35
  }
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.cjs",
6
6
  "exports": {
@@ -42,7 +42,7 @@
42
42
  "tape": "^5.5.0"
43
43
  },
44
44
  "dependencies": {
45
- "@lightningjs/renderer": "^0.6.1",
45
+ "@lightningjs/renderer": "^0.7.0",
46
46
  "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0"
47
47
  }
48
48
  }
package/src/component.js CHANGED
@@ -146,6 +146,18 @@ const Component = (name = required('name'), config = required('config')) => {
146
146
  enumerable: false,
147
147
  configurable: false,
148
148
  },
149
+ [symbols.timeouts]: {
150
+ value: [],
151
+ writable: true,
152
+ enumerable: false,
153
+ configurable: false,
154
+ },
155
+ [symbols.intervals]: {
156
+ value: [],
157
+ writable: true,
158
+ enumerable: false,
159
+ configurable: false,
160
+ },
149
161
  })
150
162
 
151
163
  Object.defineProperty(this, symbols.originalState, {
@@ -30,11 +30,13 @@ export default () =>
30
30
  :style="$style"
31
31
  :weight="$weight"
32
32
  letterSpacing="$letterspacing"
33
+ lineHeight="$_lineheight"
33
34
  stretch="$stretch"
34
35
  contain="$_contain"
35
36
  :wordWrap="$wordwrap"
36
37
  :maxLines="$maxlines"
37
38
  :textAlign="$align"
39
+ :overflowSuffix="$textoverflow"
38
40
  @loaded="$@loaded"
39
41
  @error="$@error"
40
42
  />`,
@@ -57,9 +59,11 @@ export default () =>
57
59
  'align',
58
60
  'wordwrap',
59
61
  'maxlines',
62
+ 'lineheight',
60
63
  'contain',
61
64
  '@loaded',
62
65
  '@error',
66
+ 'textoverflow',
63
67
  ],
64
68
  computed: {
65
69
  _contain() {
@@ -68,5 +72,8 @@ export default () =>
68
72
  (this.wordwrap && this.maxlines ? 'both' : this.wordwrap ? 'width' : 'none')
69
73
  )
70
74
  },
75
+ _lineheight() {
76
+ return this.lineheight !== undefined ? this.lineheight : this.size
77
+ },
71
78
  },
72
79
  })
package/src/element.js CHANGED
@@ -201,11 +201,17 @@ const Props = {
201
201
  this._props.contain = v
202
202
  },
203
203
  set maxLines(v) {
204
- this.height = v * this.element.node.fontSize
204
+ this.height = v * this.element.node.lineHeight
205
+ },
206
+ set overflowSuffix(v) {
207
+ this._props.overflowSuffix = v === false ? ' ' : v === true ? undefined : v
205
208
  },
206
209
  set letterSpacing(v) {
207
210
  this._props.letterSpacing = v
208
211
  },
212
+ set lineHeight(v) {
213
+ this._props.lineHeight = v
214
+ },
209
215
  set textAlign(v) {
210
216
  this._props.textAlign = v
211
217
  },
package/src/launch.d.ts CHANGED
@@ -144,7 +144,15 @@ export interface Settings {
144
144
  *
145
145
  * Defaults to 1 if not specified
146
146
  */
147
- pixelRatio?: number
147
+ pixelRatio?: number,
148
+ /**
149
+ * Maximum number of web workers to spin up simultaneously for offloading functionality such
150
+ * as image loading to separate threads (when supported by the browser)
151
+ *
152
+ * If not specified defaults to the number of logical processers available as reported by
153
+ * `navigator.hardwareConcurrency` (or 2 if `navigator.hardwareConcurrency` is not supported)
154
+ */
155
+ webWorkersLimit?: number
148
156
  }
149
157
 
150
158
  /**
package/src/launch.js CHANGED
@@ -46,6 +46,10 @@ export default (App, target, settings) => {
46
46
  screenResolutions[settings.screenResolution] ||
47
47
  screenResolutions[window.innerHeight] ||
48
48
  1,
49
+ numImageWorkers:
50
+ 'webWorkersLimit' in settings
51
+ ? settings.webWorkersLimit
52
+ : window.navigator.hardwareConcurrency || 2,
49
53
  },
50
54
  target,
51
55
  driver
@@ -215,6 +215,10 @@ const generateForLoopCode = function (templateObject, parent) {
215
215
  ctx.renderCode.push(`
216
216
  const collection = ${cast(result[2], ':for')}
217
217
  const keys = []
218
+ // if array is empty push an empty object to properly set up reactivity
219
+ if(collection.length === 0) {
220
+ collection.push({})
221
+ }
218
222
  for(let __index = 0; __index < collection.length; __index++) {
219
223
  parent = ${parent}
220
224
  if(!component.key) keys.length = 0
@@ -140,17 +140,11 @@ export default (component) => {
140
140
  enumerable: false,
141
141
  configurable: false,
142
142
  },
143
- [symbols.timeouts]: {
144
- value: [],
145
- writable: false,
146
- enumerable: false,
147
- configurable: false,
148
- },
149
143
  $setTimeout: {
150
144
  value: function (fn, ms, ...params) {
151
145
  const timeoutId = setTimeout(
152
146
  () => {
153
- this[symbols._timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
147
+ this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
154
148
  fn.apply(null, params)
155
149
  },
156
150
  ms,
@@ -163,22 +157,20 @@ export default (component) => {
163
157
  enumerable: true,
164
158
  configurable: false,
165
159
  },
166
- [symbols.intervals]: {
167
- value: [],
160
+ $clearTimeout: {
161
+ value: function (timeoutId) {
162
+ if (this[symbols.timeouts].indexOf(timeoutId) > -1) {
163
+ this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
164
+ clearTimeout(timeoutId)
165
+ }
166
+ },
168
167
  writable: false,
169
- enumerable: false,
168
+ enumerable: true,
170
169
  configurable: false,
171
170
  },
172
171
  $setInterval: {
173
172
  value: function (fn, ms, ...params) {
174
- const intervalId = setInterval(
175
- () => {
176
- this[symbols._intervals] = this[symbols.intervals].filter((id) => id !== intervalId)
177
- fn.apply(null, params)
178
- },
179
- ms,
180
- params
181
- )
173
+ const intervalId = setInterval(() => fn.apply(null, params), ms, params)
182
174
  this[symbols.intervals].push(intervalId)
183
175
  return intervalId
184
176
  },
@@ -186,6 +178,17 @@ export default (component) => {
186
178
  enumerable: true,
187
179
  configurable: false,
188
180
  },
181
+ $clearInterval: {
182
+ value: function (intervalId) {
183
+ if (this[symbols.intervals].indexOf(intervalId) > -1) {
184
+ this[symbols.intervals] = this[symbols.intervals].filter((id) => id !== intervalId)
185
+ clearInterval(intervalId)
186
+ }
187
+ },
188
+ writable: false,
189
+ enumerable: true,
190
+ configurable: false,
191
+ },
189
192
  $emit: {
190
193
  value: function (event, params) {
191
194
  eventListeners.executeListeners(event, params)
@@ -7,7 +7,6 @@ export default {
7
7
  init: Symbol('init'),
8
8
  inputEvents: Symbol('inputEvents'),
9
9
  intervals: Symbol('intervals'),
10
- _intervals: Symbol('_intervals'),
11
10
  level: Symbol('level'),
12
11
  methodKeys: Symbol('methodKeys'),
13
12
  originalState: Symbol('originalState'),
@@ -20,7 +19,6 @@ export default {
20
19
  stateKeys: Symbol('stateKeys'),
21
20
  textnode: Symbol('textnode'),
22
21
  timeouts: Symbol('timeouts'),
23
- _timeouts: Symbol('_timeouts'),
24
22
  type: Symbol('type'),
25
23
  watchers: Symbol('watchers'),
26
24
  watchKeys: Symbol('watchKeys'),