@lightningjs/blits 0.9.4 → 0.9.6

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,6 +1,20 @@
1
1
  # Changelog
2
2
 
3
- # v0.9.4
3
+ ## v0.9.6
4
+
5
+ _4 apr 2024_
6
+
7
+ - Added before hook to router
8
+ - Upgraded Lightning renderer to v0.8.2
9
+
10
+ ## v0.9.5
11
+
12
+ _29 mar 2024_
13
+
14
+ - Fixed cancelling of scheduled / running transitions when starting a new transition on the same prop (broke in v0.7.1).
15
+ - Added viewport relates lifecycle hooks
16
+
17
+ ## v0.9.4
4
18
 
5
19
  _28 mar 2024_
6
20
 
@@ -9,7 +23,7 @@ _28 mar 2024_
9
23
  - Introduced new `gpuMemoryLimit` launch setting
10
24
 
11
25
 
12
- # v0.9.3
26
+ ## v0.9.3
13
27
 
14
28
  _25 mar 2024_
15
29
 
@@ -21,7 +35,7 @@ _21 mar 2024_
21
35
 
22
36
  - Fixed issue with updates not triggering during array operation
23
37
 
24
- # v0.9.1
38
+ ## v0.9.1
25
39
 
26
40
  _21 mar 2024_
27
41
 
@@ -31,7 +45,7 @@ _21 mar 2024_
31
45
  - Introduced `viewportMargin` setting
32
46
  - Added `undefined`-check for props sent to renderer
33
47
 
34
- # v0.9.0
48
+ ## v0.9.0
35
49
 
36
50
  _18 mar 2024_
37
51
 
@@ -41,7 +55,7 @@ _18 mar 2024_
41
55
  - Refactored font loading, removed the need for temporary `src/fontLoader.js` file
42
56
  - Replaced using component name with unique identifier for registering and emitting hooks
43
57
 
44
- # v0.8.1
58
+ ## v0.8.1
45
59
 
46
60
  _9 mar 2024_
47
61
 
@@ -50,20 +64,20 @@ _9 mar 2024_
50
64
  - Removed explicit destroy of child nodes, as the renderer now takes care of this
51
65
  - Re-added support for clipping
52
66
 
53
- # v0.8.0
67
+ ## v0.8.0
54
68
 
55
69
  _1 mar 2024_
56
70
 
57
71
  - Added `this.$clearIntervals()` and `this.$clearTimeouts()` methods that clear all intervals and timers set on a certain component
58
72
  - **Breaking change:** Renamed the key `function` to `easing` in the transitions object used to specify a custom easing functio (deprecation notice added)
59
73
 
60
- # v0.7.4
74
+ ## v0.7.4
61
75
 
62
76
  _28 feb 2024_
63
77
 
64
78
  - Fixed dependency for on the fly MSDF font generation
65
79
 
66
- # v0.7.3
80
+ ## v0.7.3
67
81
 
68
82
  _28 feb 2024_
69
83
 
@@ -74,14 +88,14 @@ _28 feb 2024_
74
88
  - Added support for pre-compilation for files with more than 1 Blits component
75
89
  - Fixed transitions on scale attribute when passed an object with `x` and `y` values
76
90
 
77
- # v0.7.2
91
+ ## v0.7.2
78
92
 
79
93
  _23 feb 2024_
80
94
 
81
95
  - Added small fix to support for (re)assigning an array used in a for-loop
82
96
  - Added option to enable the Lightning inspector in launch setting (`inspector: true/false`)
83
97
 
84
- # v0.7.1
98
+ ## v0.7.1
85
99
 
86
100
  _22 feb 2024_
87
101
 
@@ -94,7 +108,7 @@ _22 feb 2024_
94
108
  - Added preliminary support for frameTick hook
95
109
  - Upgraded to latest version of the renderer (0.7.4)
96
110
 
97
- # v0.7.0
111
+ ## v0.7.0
98
112
 
99
113
  _20 feb 2024_
100
114
 
@@ -103,7 +117,7 @@ _20 feb 2024_
103
117
  - Added functionality to pass extra data / props when navigating to a new route ( _breaking change_ in signature of `router.to()` method - previously: `router.to(path, options)`, now: `router.to(path, data, options)`)
104
118
  - Added configuration option to set the canvas color (aka clear color)
105
119
 
106
- # v0.6.13
120
+ ## v0.6.13
107
121
 
108
122
  _16 feb 2024_
109
123
 
@@ -113,7 +127,7 @@ _16 feb 2024_
113
127
  - Fixed logic to not unfoces a parent when it passes focus to a child
114
128
  - Removed temporary fix for renderer issue [#123](https://github.com/lightning-js/renderer/issues/123)
115
129
 
116
- # v0.6.12
130
+ ## v0.6.12
117
131
 
118
132
  _9 feb 2024_
119
133
 
@@ -121,7 +135,7 @@ _9 feb 2024_
121
135
  - Fixed issue with `.gitignore` in app create flow
122
136
  - Added support for dynamic route parts in the router (i.e `/tv/:series/episodes/:episode`)
123
137
 
124
- # v0.6.11
138
+ ## v0.6.11
125
139
 
126
140
  _7 feb 2024_
127
141
 
@@ -129,7 +143,7 @@ _7 feb 2024_
129
143
  - Removed setting focus to AppComponent on back key press in RouterView
130
144
  - Fixed broken app create flow caused by missing dev dependencies in npx command (temporary fix)
131
145
 
132
- # v0.6.10
146
+ ## v0.6.10
133
147
 
134
148
  _2 feb 2024_
135
149
 
@@ -138,20 +152,20 @@ _2 feb 2024_
138
152
  - Updated flow to create a new App project with an interactive prompt of questions (`npx @lightningjs/blits@latest`)
139
153
  - Upgraded to latest version of the Lightning 3 renderer (0.7.1)
140
154
 
141
- # v0.6.9
155
+ ## v0.6.9
142
156
 
143
157
  _31 jan 2024_
144
158
 
145
159
  - Fixed single quote escaping for all browsers (removing sometimes unsupported negative lookahead)
146
160
  - Fixed issue with focus when navigating back to a page that is kept in history
147
161
 
148
- # v0.6.8
162
+ ## v0.6.8
149
163
 
150
164
  _29 jan 2024_
151
165
 
152
166
  - Reverted fix (initially) empty for-loops
153
167
 
154
- # v0.6.7
168
+ ## v0.6.7
155
169
 
156
170
  _26 jan 2024_
157
171
 
@@ -161,7 +175,7 @@ _26 jan 2024_
161
175
  - Added setting for specifying maximum number of web workers to spawn (`webWorkersLimit`)
162
176
  - Added fix for issue with setting up reactivity for (initially) empty for-loops
163
177
 
164
- # v0.6.6
178
+ ## v0.6.6
165
179
 
166
180
  _24 jan 2024_
167
181
 
@@ -169,54 +183,54 @@ _24 jan 2024_
169
183
  - Fixed issue with setting mount, pivot and scale values to zero (0) in object literal with x and y key
170
184
  - Added automatic mapping of ref string to each item in a for-loop
171
185
 
172
- # v0.6.5
186
+ ## v0.6.5
173
187
 
174
188
  _16 jan 2024_
175
189
 
176
190
  - Added `path` to boilerplate vite.config.js for deployments in a sub folder
177
191
  - Improved error handling in the template parser, with more contextual error messages
178
192
 
179
- # v0.6.4
193
+ ## v0.6.4
180
194
 
181
195
  _15 jan 2024_
182
196
 
183
197
  - Added fix for sprites not working on certain devices
184
198
 
185
- # v0.6.3
199
+ ## v0.6.3
186
200
 
187
201
  _12 jan 2024_
188
202
 
189
203
  - Removed prepending protocol and host from sprite image
190
204
 
191
205
 
192
- # v0.6.2
206
+ ## v0.6.2
193
207
 
194
208
  _12 jan 2024_
195
209
 
196
210
  - Fixed issue with Sprites not working correctly due to missing background color
197
211
 
198
- # v0.6.1
212
+ ## v0.6.1
199
213
 
200
214
  _8 jan 2024_
201
215
 
202
216
  - Fixed issue with using single quotes as Text content
203
217
  - Added first Text-to-Speech / Announcer functionality
204
218
 
205
- # v0.6.0
219
+ ## v0.6.0
206
220
 
207
221
  _4 jan 2024_
208
222
 
209
223
  - Added pre-compilation functionality to improve performance. Requires an update to the `vite.config.js` to enable. Read more details in this [blog post](https://lightningjs.io/blogs/blitsPreCompilation.html)
210
224
  - Added `defaultFont` to the Launch settings
211
225
 
212
- # v0.5.10
226
+ ## v0.5.10
213
227
 
214
228
  _3 jan 2024_
215
229
 
216
230
  - Updated and improved documentation
217
231
  - Added `screenResolution` and `pixelRatio` options to settings
218
232
 
219
- # v0.5.9
233
+ ## v0.5.9
220
234
 
221
235
  _21 dec 2023_
222
236
 
@@ -227,13 +241,13 @@ _21 dec 2023_
227
241
  - Added functionality to override route options during navigation
228
242
  - Upgraded to latest version of the renderer (0.6.1) which contains a fix for animations not finishing correctly
229
243
 
230
- # v0.5.8
244
+ ## v0.5.8
231
245
 
232
246
  _15 dec 2023_
233
247
 
234
248
  - Internal refactor of the `Element`
235
249
 
236
- # v0.5.7
250
+ ## v0.5.7
237
251
 
238
252
  _13 dec 2023_
239
253
 
@@ -241,39 +255,39 @@ _13 dec 2023_
241
255
  - Linked effects directly to the available shaders exposed by the L3 renderer (starting 0.6.0)
242
256
  - Added setting `reactivityMode` to control whether `Proxy` (default) or `defineProperty` is used to trigger reactive side effects
243
257
 
244
- # v0.5.6
258
+ ## v0.5.6
245
259
 
246
260
  _11 dec 2023_
247
261
 
248
262
  - Upgraded to version 0.6.0 of the Lightning 3 renderer
249
263
 
250
- # v0.5.5
264
+ ## v0.5.5
251
265
 
252
266
  _5 dec 2023_
253
267
 
254
268
  - Fixed regression in Slots functionality caused by forloop cleanup fix in 0.5.4
255
269
 
256
- # v0.5.4
270
+ ## v0.5.4
257
271
 
258
272
  _5 dec 2023_
259
273
 
260
274
  - Fixed issue with Components and Elements not always being cleaned up in forloop
261
275
  - Added support for nested children inside a forloop on an Element
262
276
 
263
- # v0.5.3
277
+ ## v0.5.3
264
278
 
265
279
  _4 dec 2023_
266
280
 
267
281
  - Added transition `start` and tranition `end` callbacks
268
282
 
269
- # v0.5.2
283
+ ## v0.5.2
270
284
 
271
285
  _30 nov 2023_
272
286
 
273
287
  - Fixed issue in code generator leading to creation unnecessary child nodes
274
288
  - Added focus handler to router view (that passes focus to the current active page)
275
289
 
276
- # v0.5.1
290
+ ## v0.5.1
277
291
 
278
292
  _29 nov 2023_
279
293
 
@@ -281,20 +295,20 @@ _29 nov 2023_
281
295
  - Added fastforward of transitions on the same property
282
296
  - Added functionality to skip focus change on key hold
283
297
 
284
- # v0.5.0
298
+ ## v0.5.0
285
299
 
286
300
  _23 nov 2023_
287
301
 
288
302
  - Introduced `wordwrap` and `maxlines` attributes on the Text-component, replacing the previous `w` and `h` attributes (breaking change!)
289
303
 
290
- # v0.4.2
304
+ ## v0.4.2
291
305
 
292
306
  _22 nov 2023_
293
307
 
294
308
  - Improved parser and added more template validation (i.e. one single root element in a template)
295
309
  - Fixed typo in documentation
296
310
 
297
- # v0.4.1
311
+ ## v0.4.1
298
312
 
299
313
  _13 nov 2023_
300
314
 
@@ -2,9 +2,3 @@
2
2
 
3
3
  ## Utilities
4
4
 
5
- - focus()
6
- - $router()
7
- - select()
8
- - parent
9
- - Log
10
- - setTimeout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -45,7 +45,7 @@
45
45
  "tape": "^5.5.0"
46
46
  },
47
47
  "dependencies": {
48
- "@lightningjs/renderer": "^0.8.0",
48
+ "@lightningjs/renderer": "^0.8.2",
49
49
  "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0",
50
50
  "execa": "^8.0.1",
51
51
  "kolorist": "^1.8.0",
@@ -1,3 +1,4 @@
1
+
1
2
  /*
2
3
  * Copyright 2023 Comcast Cable Communications Management, LLC
3
4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -91,6 +92,10 @@ declare namespace Application {
91
92
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
92
93
  }[keyof T]
93
94
 
95
+ interface RouteHooks {
96
+ before?: (to: Route, from: Route) => string | Route;
97
+ }
98
+
94
99
  type Route = {
95
100
  /**
96
101
  * URI path for the route
@@ -115,6 +120,26 @@ declare namespace Application {
115
120
  * politeness level
116
121
  */
117
122
  announce?: String | RouteAnnounce
123
+ /**
124
+ * Register hooks for the route
125
+ */
126
+ hooks?: RouteHooks
127
+ /**
128
+ * Route path parameters
129
+ */
130
+ readonly params?: {
131
+ [key: string]: string | number
132
+ }
133
+ /**
134
+ * Allows for attaching custom data to a route, either hardcoded in the
135
+ * route definition or asigned to the route object in a before hook
136
+ *
137
+ * Will be merged with the route params and navigation data and passed as
138
+ * props into the route component
139
+ */
140
+ data?: {
141
+ [key: string]: any
142
+ }
118
143
  }
119
144
 
120
145
  export interface ApplicationInstance extends ComponentInstance {}
@@ -113,11 +113,13 @@ declare namespace Component {
113
113
  ready?: (this: ComponentInstance) => void
114
114
  /**
115
115
  * Triggers when the Component receives focus.
116
+ *
116
117
  * This event can fire multiple times during the component's lifecycle
117
118
  */
118
119
  focus?: (this: ComponentInstance) => void
119
120
  /**
120
121
  * Triggers when the Component loses focus.
122
+ *
121
123
  * This event can fire multiple times during the component's lifecycle
122
124
  */
123
125
  unfocus?: (this: ComponentInstance) => void
@@ -130,7 +132,31 @@ declare namespace Component {
130
132
  *
131
133
  * Note: This hook will fire continuously, multiple times per second!
132
134
  */
133
- frameTick?: (this: ComponentInstance) => void
135
+ frameTick?: (this: ComponentInstance) => void,
136
+ /**
137
+ * Fires when the component enters the viewport _margin_ and is attached to the render tree
138
+ *
139
+ * This event can fire multiple times during the component's lifecycle
140
+ */
141
+ attach?: (this: ComponentInstance) => void,
142
+ /**
143
+ * Fires when the component leaves the viewport _margin_ and is detached from the render tree
144
+ *
145
+ * This event can fire multiple times during the component's lifecycle
146
+ */
147
+ detach?: (this: ComponentInstance) => void,
148
+ /**
149
+ * Fires when the component enters the visible viewport
150
+ *
151
+ * This event can fire multiple times during the component's lifecycle
152
+ */
153
+ enter?: (this: ComponentInstance) => void,
154
+ /**
155
+ * Fires when the component leaves the visible viewport
156
+ *
157
+ * This event can fire multiple times during the component's lifecycle
158
+ */
159
+ exit?: (this: ComponentInstance) => void,
134
160
  }
135
161
 
136
162
  export interface ComponentInstance {
package/src/component.js CHANGED
@@ -102,7 +102,7 @@ const Component = (name = required('name'), config = required('config')) => {
102
102
  }
103
103
 
104
104
  this.parent = parentComponent
105
- this[symbols.wrapper] = parentEl
105
+ this[symbols.holder] = parentEl
106
106
 
107
107
  Object.defineProperties(this, {
108
108
  componentId: {
@@ -163,6 +163,37 @@ const Component = (name = required('name'), config = required('config')) => {
163
163
  configurable: false,
164
164
  })
165
165
 
166
+ Object.defineProperty(this, symbols.wrapper, {
167
+ value: this[symbols.children][0],
168
+ writable: false,
169
+ enumerable: false,
170
+ configurable: false,
171
+ })
172
+
173
+ if (config.hooks && config.hooks.attach) {
174
+ this[symbols.wrapper].node.on('inBounds', () => {
175
+ this.lifecycle.state = 'attach'
176
+ })
177
+ }
178
+
179
+ if (config.hooks && config.hooks.detach) {
180
+ this[symbols.wrapper].node.on('outOfBounds', (node, { previous }) => {
181
+ if (previous > 0) this.lifecycle.state = 'detach'
182
+ })
183
+ }
184
+
185
+ if (config.hooks && config.hooks.enter) {
186
+ this[symbols.wrapper].node.on('inViewport', () => {
187
+ this.lifecycle.state = 'enter'
188
+ })
189
+ }
190
+
191
+ if (config.hooks && config.hooks.enter) {
192
+ this[symbols.wrapper].node.on('outOfViewport', () => {
193
+ this.lifecycle.state = 'exit'
194
+ })
195
+ }
196
+
166
197
  Object.defineProperty(this, symbols.slots, {
167
198
  value: this[symbols.children].filter((child) => child[symbols.isSlot]),
168
199
  writable: false,
@@ -19,38 +19,35 @@ 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) {
25
- const elms = []
22
+ /* eslint-disable no-unused-vars */
23
+ code: { render: function anonymous(parent,component,context
24
+ ) {
25
+ const elms = []
26
26
 
27
- if (!elms[0]) {
28
- elms[0] = this.element({ parent: parent || 'root' }, component)
29
- }
30
- const elementConfig0 = {}
27
+ if(!elms[0]) {
28
+ elms[0] = this.element({parent: parent || 'root'}, component)
29
+ }
30
+ const elementConfig0 = {}
31
+
31
32
 
32
- if (!elms[0].nodeId) {
33
- elms[0].populate(elementConfig0)
34
- }
35
-
36
- return elms
37
- },
38
- effects: [
39
- function anonymous(component, elms, context) {
40
- elms[0].set('color', component.color)
41
- },
42
- function anonymous(component, elms, context) {
43
- elms[0].set('w', component.size)
44
- },
45
- function anonymous(component, elms, context) {
46
- elms[0].set('h', component.size)
47
- },
48
- function anonymous(component, elms, context) {
49
- elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
50
- },
51
- ],
52
- context: {},
53
- },
33
+ if(!elms[0].nodeId) {
34
+ elms[0].populate(elementConfig0)
35
+ }
36
+
37
+ return elms
38
+ }, effects: [function anonymous(component,elms,context
39
+ ) {
40
+ elms[0].set('color', component.color)
41
+ },function anonymous(component,elms,context
42
+ ) {
43
+ elms[0].set('w', component.size)
44
+ },function anonymous(component,elms,context
45
+ ) {
46
+ elms[0].set('h', component.size)
47
+ },function anonymous(component,elms,context
48
+ ) {
49
+ elms[0].set('effects', [component.shader('radius', {radius: component.radius})])
50
+ }], context: {}},
54
51
  props: [{ key: 'size', default: 40 }, 'color'],
55
52
  computed: {
56
53
  radius() {
@@ -19,9 +19,35 @@ import Component from '../component.js'
19
19
 
20
20
  export default () =>
21
21
  Component('Circle', {
22
- template: `
23
- <Element :color="$color" :w="$size" :h="$size" :effects="[$shader('radius', {radius: $radius})]"></Element>
24
- `,
22
+ /* eslint-disable no-unused-vars */
23
+ code: { render: function anonymous(parent,component,context
24
+ ) {
25
+ const elms = []
26
+
27
+ if(!elms[0]) {
28
+ elms[0] = this.element({parent: parent || 'root'}, component)
29
+ }
30
+ const elementConfig0 = {}
31
+
32
+
33
+ if(!elms[0].nodeId) {
34
+ elms[0].populate(elementConfig0)
35
+ }
36
+
37
+ return elms
38
+ }, effects: [function anonymous(component,elms,context
39
+ ) {
40
+ elms[0].set('color', component.color)
41
+ },function anonymous(component,elms,context
42
+ ) {
43
+ elms[0].set('w', component.size)
44
+ },function anonymous(component,elms,context
45
+ ) {
46
+ elms[0].set('h', component.size)
47
+ },function anonymous(component,elms,context
48
+ ) {
49
+ elms[0].set('effects', [component.shader('radius', {radius: component.radius})])
50
+ }], context: {}},
25
51
  props: [{ key: 'size', default: 40 }, 'color'],
26
52
  computed: {
27
53
  radius() {