@lightningjs/blits 1.18.1 → 1.19.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.
@@ -22,30 +22,36 @@ let hashchangeHandler = null
22
22
 
23
23
  export default () =>
24
24
  Component('RouterView', {
25
- /* eslint-disable no-unused-vars */
26
- code: { render: function anonymous(parent,component,context,components,effect,getRaw
27
- ) {
28
- const elms = []
29
- let componentType
30
- const rootComponent = component
31
- let propData
32
- let slotComponent
33
- let inSlot = false
34
- let slotChildCounter = 0
35
- const elementConfig0 = {}
25
+ /* eslint-disable no-unused-vars */
26
+ code: {
27
+ render: function anonymous(parent, component, context, components, effect, getRaw) {
28
+ const elms = []
29
+ let componentType
30
+ const rootComponent = component
31
+ let propData
32
+ let slotComponent
33
+ let inSlot = false
34
+ let slotChildCounter = 0
35
+ const elementConfig0 = {}
36
36
 
37
- elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
38
-
39
- elementConfig0['w'] = parent.node.width * (100 / 100)
40
- elementConfig0['height'] = parent.node.height * (100 / 100)
41
- elms[0].populate(elementConfig0)
37
+ elms[0] = this.element(
38
+ { parent: parent || 'root' },
39
+ inSlot === true ? slotComponent : component
40
+ )
42
41
 
43
- if(inSlot === true) {
44
- slotChildCounter -= 1
45
- }
46
-
47
- return elms
48
- }, effects: [], context: {}},
42
+ elementConfig0['w'] = parent.node.width * (100 / 100)
43
+ elementConfig0['height'] = parent.node.height * (100 / 100)
44
+ elms[0].populate(elementConfig0)
45
+
46
+ if (inSlot === true) {
47
+ slotChildCounter -= 1
48
+ }
49
+
50
+ return elms
51
+ },
52
+ effects: [],
53
+ context: {},
54
+ },
49
55
  state() {
50
56
  return {
51
57
  activeView: null,
@@ -56,7 +62,6 @@ return elms
56
62
  hashchangeHandler = () => Router.navigate.apply(this)
57
63
  Router.navigate.apply(this)
58
64
  window.addEventListener('hashchange', hashchangeHandler)
59
-
60
65
  },
61
66
  destroy() {
62
67
  window.removeEventListener('hashchange', hashchangeHandler, false)
@@ -21,42 +21,45 @@ import symbols from '../lib/symbols.js'
21
21
 
22
22
  export default () =>
23
23
  Component('Sprite', {
24
- /* eslint-disable no-unused-vars */
25
- code: { render: function anonymous(parent,component,context,components,effect,getRaw
26
- ) {
27
- const elms = []
28
- let componentType
29
- const rootComponent = component
30
- let propData
31
- let slotComponent
32
- let inSlot = false
33
- let slotChildCounter = 0
34
- const elementConfig0 = {}
24
+ /* eslint-disable no-unused-vars */
25
+ code: {
26
+ render: function anonymous(parent, component, context, components, effect, getRaw) {
27
+ const elms = []
28
+ let componentType
29
+ const rootComponent = component
30
+ let propData
31
+ let slotComponent
32
+ let inSlot = false
33
+ let slotChildCounter = 0
34
+ const elementConfig0 = {}
35
35
 
36
- elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
37
-
38
- elementConfig0['w'] = parent.node.width * (100 / 100)
39
- elementConfig0['h'] = parent.node.height * (100 / 100)
40
- elementConfig0['texture'] = component.texture
41
- elementConfig0['color'] = component.color
42
- elms[0].populate(elementConfig0)
36
+ elms[0] = this.element(
37
+ { parent: parent || 'root' },
38
+ inSlot === true ? slotComponent : component
39
+ )
43
40
 
44
- if(inSlot === true) {
45
- slotChildCounter -= 1
46
- }
47
-
48
- return elms
49
- }, effects: [function anonymous(component,elms,context,components,rootComponent,effect
50
- ) {
41
+ elementConfig0['w'] = parent.node.width * (100 / 100)
42
+ elementConfig0['h'] = parent.node.height * (100 / 100)
43
+ elementConfig0['texture'] = component.texture
44
+ elementConfig0['color'] = component.color
45
+ elms[0].populate(elementConfig0)
51
46
 
52
- elms[0].set('texture', component.texture)
53
-
54
- },function anonymous(component,elms,context,components,rootComponent,effect
55
- ) {
47
+ if (inSlot === true) {
48
+ slotChildCounter -= 1
49
+ }
56
50
 
57
- elms[0].set('color', component.color)
58
-
59
- }], context: {}},
51
+ return elms
52
+ },
53
+ effects: [
54
+ function anonymous(component, elms, context, components, rootComponent, effect) {
55
+ elms[0].set('texture', component.texture)
56
+ },
57
+ function anonymous(component, elms, context, components, rootComponent, effect) {
58
+ elms[0].set('color', component.color)
59
+ },
60
+ ],
61
+ context: {},
62
+ },
60
63
  props: ['image', 'map', 'frame', 'color'],
61
64
  state() {
62
65
  return {
package/src/constants.js CHANGED
@@ -12,3 +12,10 @@ export const SCREEN_RESOLUTIONS = {
12
12
  '2160p': 2,
13
13
  2160: 2,
14
14
  }
15
+
16
+ export const RENDER_QUALITIES = {
17
+ low: 0.66666667,
18
+ medium: 0.85,
19
+ high: 1,
20
+ retina: 2,
21
+ }
@@ -299,7 +299,7 @@ const propsTransformer = {
299
299
  },
300
300
  set show(v) {
301
301
  if (v) {
302
- this.props['alpha'] = 1
302
+ this.props['alpha'] = this.raw['alpha'] !== undefined ? this.raw['alpha'] : 1
303
303
  this.props['width'] = this.raw['w'] || this.raw['width'] || 0
304
304
  this.props['height'] = this.raw['h'] || this.raw['height'] || 0
305
305
  } else {
@@ -309,7 +309,9 @@ const propsTransformer = {
309
309
  }
310
310
  },
311
311
  set alpha(v) {
312
- this.props['alpha'] = v
312
+ if(this.raw['show'] === undefined || this.raw['show'] === true) {
313
+ this.props['alpha'] = v
314
+ }
313
315
  },
314
316
  set shader(v) {
315
317
  if (v !== null) {
@@ -419,6 +421,11 @@ const propsTransformer = {
419
421
  this.props['mountY'] = 1
420
422
  }
421
423
  },
424
+ set 'inspector-data'(v) {
425
+ if (typeof v === 'object' || (isObjectString(v) === true && (v = parseToObject(v)))) {
426
+ this.props['data'] = v
427
+ }
428
+ },
422
429
  }
423
430
 
424
431
  const Element = {
@@ -21,7 +21,7 @@ import { CanvasCoreRenderer, CanvasTextRenderer } from '@lightningjs/renderer/ca
21
21
  import { Inspector } from '@lightningjs/renderer/inspector'
22
22
 
23
23
  import { Log } from '../../lib/log.js'
24
- import { SCREEN_RESOLUTIONS } from '../../constants.js'
24
+ import { SCREEN_RESOLUTIONS, RENDER_QUALITIES } from '../../constants.js'
25
25
  import colors from '../../lib/colors/colors.js'
26
26
  import fontLoader from './fontLoader.js'
27
27
  import shaderLoader from './shaderLoader.js'
@@ -43,11 +43,15 @@ const textRenderEngines = (settings) => {
43
43
  }
44
44
 
45
45
  export default (App, target, settings = {}) => {
46
+ console.log(RENDER_QUALITIES[settings.renderQuality] || settings.renderQuality || 1)
47
+
46
48
  renderer = new RendererMain(
47
49
  {
48
50
  appWidth: settings.w || 1920,
49
51
  appHeight: settings.h || 1080,
50
52
  fpsUpdateInterval: settings.fpsInterval || 1000,
53
+ devicePhysicalPixelRatio:
54
+ RENDER_QUALITIES[settings.renderQuality] || settings.renderQuality || 1,
51
55
  deviceLogicalPixelRatio:
52
56
  settings.pixelRatio ||
53
57
  SCREEN_RESOLUTIONS[settings.screenResolution] ||
@@ -66,7 +70,7 @@ export default (App, target, settings = {}) => {
66
70
  renderEngine: renderEngine(settings),
67
71
  fontEngines: textRenderEngines(settings),
68
72
  canvas: settings.canvas,
69
- textureProcessingTimeLimit: settings.textureProcessingTimeLimit
73
+ textureProcessingTimeLimit: settings.textureProcessingTimeLimit,
70
74
  },
71
75
  target
72
76
  )
package/src/focus.js CHANGED
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  import symbols from './lib/symbols.js'
19
- import { navigating } from './router/router.js'
19
+ import { state } from './router/router.js'
20
20
  import Settings from './settings.js'
21
21
  import { DEFAULT_HOLD_TIMEOUT_MS } from './constants.js'
22
22
 
@@ -58,7 +58,7 @@ export default {
58
58
  }
59
59
  },
60
60
  input(key, event) {
61
- if (navigating === true) return
61
+ if (state.navigating === true) return
62
62
  focusChain = walkChain([focusedComponent], key)
63
63
  const componentWithInputEvent = focusChain.shift()
64
64
 
@@ -107,10 +107,14 @@ const reactiveProxy = (original, _parent = null, _key, global) => {
107
107
  : oldRawValue === rawValue
108
108
 
109
109
  if (isEqual === false) {
110
- if(typeof value === 'object') {
110
+ if (typeof value === 'object') {
111
111
  if (Array.isArray(value) === true) {
112
112
  value = getRaw(value).slice(0)
113
- } else if(target[key] !== null && target[key] !== undefined && Object.getPrototypeOf(value) === Object.prototype) {
113
+ } else if (
114
+ target[key] !== null &&
115
+ target[key] !== undefined &&
116
+ Object.getPrototypeOf(value) === Object.prototype
117
+ ) {
114
118
  value = Object.assign(receiver[key], value)
115
119
  }
116
120
  }
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import { default as fadeInFadeOutTransition } from './transitions/fadeInOut.js'
19
+ import { reactive } from '../lib/reactivity/reactive.js'
19
20
 
20
21
  import symbols from '../lib/symbols.js'
21
22
  import { Log } from '../lib/log.js'
@@ -24,7 +25,7 @@ import Focus from '../focus.js'
24
25
  import Announcer from '../announcer/announcer.js'
25
26
 
26
27
  export let currentRoute
27
- export let navigating = false
28
+ export const state = reactive({ path: null, navigating: false })
28
29
 
29
30
  const cacheMap = new WeakMap()
30
31
  const history = []
@@ -114,7 +115,7 @@ export const matchHash = (path, routes = []) => {
114
115
  }
115
116
 
116
117
  export const navigate = async function () {
117
- navigating = true
118
+ state.navigating = true
118
119
  if (this.parent[symbols.routes]) {
119
120
  const previousRoute = currentRoute
120
121
  const { hash, queryParams } = getHash()
@@ -237,6 +238,8 @@ export const navigate = async function () {
237
238
  }
238
239
  }
239
240
 
241
+ state.path = route.path
242
+
240
243
  // apply in transition
241
244
  if (route.transition.in) {
242
245
  if (Array.isArray(route.transition.in)) {
@@ -268,7 +271,7 @@ export const navigate = async function () {
268
271
 
269
272
  // reset navigating indicators
270
273
  navigatingBack = false
271
- navigating = false
274
+ state.navigating = false
272
275
  }
273
276
 
274
277
  const removeView = async (route, view, transition) => {
@@ -320,7 +323,7 @@ export const to = (location, data = {}, options = {}) => {
320
323
  window.location.hash = `#${location}`
321
324
  }
322
325
 
323
- export const back = function(){
326
+ export const back = function () {
324
327
  const route = history.pop()
325
328
  if (route && currentRoute !== route) {
326
329
  // set indicator that we are navigating back (to prevent adding page to history stack)
@@ -335,11 +338,11 @@ export const back = function(){
335
338
  return true
336
339
  }
337
340
 
338
- const backtrack = currentRoute && currentRoute.options.backtrack || false
341
+ const backtrack = (currentRoute && currentRoute.options.backtrack) || false
339
342
 
340
343
  // If we deeplink to a page without backtrack
341
344
  // we we let the RouterView handle back
342
- if(!backtrack){
345
+ if (backtrack === false) {
343
346
  return false
344
347
  }
345
348
 
@@ -348,19 +351,19 @@ export const back = function(){
348
351
  let level = path.split('/').length
349
352
 
350
353
  // On root return
351
- if(level <= 1){
354
+ if (level <= 1) {
352
355
  return false
353
356
  }
354
357
 
355
- while(level--){
356
- if(!hashEnd.test(path)){
358
+ while (level--) {
359
+ if (!hashEnd.test(path)) {
357
360
  return false
358
361
  }
359
362
  // Construct new path to backtrack to
360
363
  path = path.replace(hashEnd, '')
361
364
  const route = matchHash(path, this.parent[symbols.routes])
362
365
 
363
- if(route && backtrack){
366
+ if (route && backtrack) {
364
367
  to(route.path)
365
368
  return true
366
369
  }