@lightningjs/blits 0.9.1 → 0.9.3

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,17 @@
1
1
  # Changelog
2
2
 
3
+ # v0.9.3
4
+
5
+ _25 mar 2024_
6
+
7
+ - Added support for mount / pivot on Text elements and Sprites.
8
+
9
+ # v0.9.2
10
+
11
+ _21 mar 2024_
12
+
13
+ - Fixed issue with updates not triggering during array operation
14
+
3
15
  # v0.9.1
4
16
 
5
17
  _21 mar 2024_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
package/src/component.js CHANGED
@@ -18,8 +18,7 @@
18
18
  import parser from './lib/templateparser/parser.js'
19
19
  import codegenerator from './lib/codegenerator/generator.js'
20
20
 
21
- import element from './element.js'
22
- import { renderer } from './launch.js'
21
+ import { stage, renderer } from './launch.js'
23
22
 
24
23
  import { createHumanReadableId, createInternalId } from './lib/componentId.js'
25
24
  import { registerHooks, emit } from './lib/hooks.js'
@@ -42,10 +41,6 @@ import symbols from './lib/symbols.js'
42
41
 
43
42
  let counter = 0
44
43
 
45
- const stage = {
46
- element,
47
- }
48
-
49
44
  const required = (name) => {
50
45
  throw new Error(`Parameter ${name} is required`)
51
46
  }
@@ -31,8 +31,8 @@ export default () =>
31
31
  }
32
32
  const elementConfig0 = {}
33
33
 
34
- elementConfig0['w'] = component.w
35
- elementConfig0['h'] = component.h
34
+ elementConfig0['w'] = parent.node.width * (100 / 100)
35
+ elementConfig0['h'] = parent.node.height * (100 / 100)
36
36
 
37
37
  if (!elms[0].nodeId) {
38
38
  elms[0].populate(elementConfig0)
@@ -50,7 +50,7 @@ export default () =>
50
50
  ],
51
51
  context: {},
52
52
  },
53
- props: ['image', 'map', 'frame', 'w', 'h', 'color'],
53
+ props: ['image', 'map', 'frame', 'color'],
54
54
  state() {
55
55
  return {
56
56
  spriteTexture: false,
@@ -22,9 +22,9 @@ import symbols from '../lib/symbols.js'
22
22
  export default () =>
23
23
  Component('Sprite', {
24
24
  template: `
25
- <Element w="$w" h="$h" :texture="$texture" :color="$color" />
25
+ <Element w="100%" h="100%" :texture="$texture" :color="$color" />
26
26
  `,
27
- props: ['image', 'map', 'frame', 'w', 'h', 'color'],
27
+ props: ['image', 'map', 'frame', 'color'],
28
28
  state() {
29
29
  return {
30
30
  spriteTexture: false,
package/src/engine.js ADDED
@@ -0,0 +1 @@
1
+ export { L3 as default } from './engines'
@@ -16,10 +16,10 @@
16
16
  */
17
17
 
18
18
  import { renderer } from './launch.js'
19
- import colors from './lib/colors/colors.js'
19
+ import colors from '../../lib/colors/colors.js'
20
20
 
21
- import { Log } from './lib/log.js'
22
- import symbols from './lib/symbols.js'
21
+ import { Log } from '../../lib/log.js'
22
+ import symbols from '../../lib/symbols.js'
23
23
 
24
24
  const deprecationMsg = `
25
25
  ----------------------------------------------------------------------------------------------------
@@ -275,6 +275,13 @@ const Element = {
275
275
  ? renderer.createTextNode(this.props._props)
276
276
  : renderer.createNode(this.props._props)
277
277
 
278
+ if (props.__textnode) {
279
+ this.node.on('loaded', (el, { dimensions }) => {
280
+ this.node.parent.width = dimensions.width
281
+ this.node.parent.height = dimensions.height
282
+ })
283
+ }
284
+
278
285
  if (props['@loaded']) {
279
286
  this.node.on('loaded', (el, { type, dimensions }) => {
280
287
  props['@loaded']({ w: dimensions.width, h: dimensions.height, type }, this)
@@ -1,6 +1,6 @@
1
1
  import { WebTrFontFace, SdfTrFontFace } from '@lightningjs/renderer/core'
2
2
 
3
- import Settings from './settings'
3
+ import Settings from '../../settings'
4
4
  import { renderer } from './launch'
5
5
 
6
6
  export default () => {
@@ -0,0 +1,7 @@
1
+ import Element from './element'
2
+ import Launch from './launch'
3
+
4
+ export default {
5
+ Element,
6
+ Launch,
7
+ }
@@ -0,0 +1,80 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+
18
+ import { MainCoreDriver, RendererMain } from '@lightningjs/renderer'
19
+ // import RendererWorker from '@lightningjs/renderer/workers/renderer?worker'
20
+ import { Log } from '../../lib/log.js'
21
+ import { screenResolutions } from '../../lib/utils.js'
22
+ import colors from '../../lib/colors/colors.js'
23
+ import fontLoader from './fontLoader.js'
24
+
25
+ export let renderer
26
+
27
+ export default (App, target, settings) => {
28
+ const driver = new MainCoreDriver()
29
+ // settings.multithreaded === true
30
+ // ? new ThreadXRenderDriver({
31
+ // RendererWorker,
32
+ // })
33
+ // : new MainRenderDriver()
34
+
35
+ if ('fontLoader' in settings) {
36
+ Log.warn(
37
+ `
38
+
39
+ Starting version 0.9.0 of Blits, the Launch setting \`fontLoader\` is not supported / required anymore.
40
+ You can remove the option from your \`src/index.js\`-file. And you can safely remove the file \`src/fontLoader.js\` from your project.
41
+ `
42
+ )
43
+ }
44
+
45
+ renderer = new RendererMain(
46
+ {
47
+ appWidth: settings.w || 1920,
48
+ appHeight: settings.h || 1080,
49
+ fpsUpdateInterval: settings.fpsInterval || 1000,
50
+ deviceLogicalPixelRatio:
51
+ settings.pixelRatio ||
52
+ screenResolutions[settings.screenResolution] ||
53
+ screenResolutions[window.innerHeight] ||
54
+ 1,
55
+ numImageWorkers:
56
+ 'webWorkersLimit' in settings
57
+ ? settings.webWorkersLimit
58
+ : window.navigator.hardwareConcurrency || 2,
59
+ clearColor: (settings.canvasColor && colors.normalize(settings.canvasColor)) || 0x00000000,
60
+ enableInspector: settings.inspector || false,
61
+ boundsMargin: settings.viewportMargin || 0,
62
+ },
63
+ target,
64
+ driver
65
+ )
66
+
67
+ const initApp = () => {
68
+ let app = App()
69
+ app.quit = () => {
70
+ Log.info('Closing App')
71
+ app.destroy()
72
+ app = null
73
+ renderer = null
74
+ }
75
+ }
76
+
77
+ renderer.init().then(fontLoader).then(initApp)
78
+
79
+ return renderer
80
+ }
@@ -0,0 +1 @@
1
+ export { default as L3 } from './L3'
package/src/launch.js CHANGED
@@ -15,69 +15,19 @@
15
15
  * SPDX-License-Identifier: Apache-2.0
16
16
  */
17
17
 
18
- import { MainCoreDriver, RendererMain } from '@lightningjs/renderer'
19
- // import RendererWorker from '@lightningjs/renderer/workers/renderer?worker'
20
18
  import Settings from './settings.js'
21
- import { initLog, Log } from './lib/log.js'
22
- import { screenResolutions } from './lib/utils.js'
23
- import colors from './lib/colors/colors.js'
24
- import fontLoader from './fontLoader.js'
19
+ import { initLog } from './lib/log.js'
20
+ import engine from './engine.js'
25
21
 
26
22
  export let renderer
23
+ export const stage = {}
27
24
 
28
25
  export default (App, target, settings) => {
29
26
  Settings.set(settings)
30
27
 
31
28
  initLog()
32
29
 
33
- const driver = new MainCoreDriver()
34
- // settings.multithreaded === true
35
- // ? new ThreadXRenderDriver({
36
- // RendererWorker,
37
- // })
38
- // : new MainCoreDriver()
30
+ stage.element = engine.Element
39
31
 
40
- if ('fontLoader' in settings) {
41
- Log.warn(
42
- `
43
-
44
- Starting version 0.9.0 of Blits, the Launch setting \`fontLoader\` is not supported / required anymore.
45
- You can remove the option from your \`src/index.js\`-file. And you can safely remove the file \`src/fontLoader.js\` from your project.
46
- `
47
- )
48
- }
49
-
50
- renderer = new RendererMain(
51
- {
52
- appWidth: settings.w || 1920,
53
- appHeight: settings.h || 1080,
54
- fpsUpdateInterval: settings.fpsInterval || 1000,
55
- deviceLogicalPixelRatio:
56
- settings.pixelRatio ||
57
- screenResolutions[settings.screenResolution] ||
58
- screenResolutions[window.innerHeight] ||
59
- 1,
60
- numImageWorkers:
61
- 'webWorkersLimit' in settings
62
- ? settings.webWorkersLimit
63
- : window.navigator.hardwareConcurrency || 2,
64
- clearColor: (settings.canvasColor && colors.normalize(settings.canvasColor)) || 0x00000000,
65
- enableInspector: settings.inspector || false,
66
- boundsMargin: settings.viewportMargin || 0,
67
- },
68
- target,
69
- driver
70
- )
71
-
72
- const initApp = () => {
73
- let app = App()
74
- app.quit = () => {
75
- Log.info('Closing App')
76
- app.destroy()
77
- app = null
78
- renderer = null
79
- }
80
- }
81
-
82
- renderer.init().then(fontLoader).then(initApp)
32
+ renderer = engine.Launch(App, target, settings)
83
33
  }
@@ -76,6 +76,7 @@ const generateElementCode = function (
76
76
  }
77
77
 
78
78
  if (isReactiveKey(key)) {
79
+ if (options.holder && key === ':color') return
79
80
  this.effectsCode.push(
80
81
  `${elm}.set('${key.substring(1)}', ${interpolate(templateObject[key], options.component)})`
81
82
  )
@@ -90,7 +91,7 @@ const generateElementCode = function (
90
91
  renderCode.push(`
91
92
  if(typeof cmp${counter} !== 'undefined') {
92
93
  for(let key in cmp${counter}.config.props) {
93
- delete elementConfig${counter}[cmp${counter}.config.props[key]]
94
+ delete elementConfig${counter}[cmp${counter}.config.props[key]]
94
95
  }
95
96
  }
96
97
  `)
@@ -219,7 +220,7 @@ const generateForLoopCode = function (templateObject, parent) {
219
220
 
220
221
  const forCounter = counter
221
222
  ctx.renderCode.push(`
222
- const collection = ${cast(result[2], ':for')}
223
+ const collection = ${cast(result[2], ':for')} || []
223
224
  const keys = []
224
225
  for(let __index = 0; __index < collection.length; __index++) {
225
226
  parent = ${parent}
@@ -55,8 +55,8 @@ const reactiveProxy = (original, _parent = null, _key) => {
55
55
  // trigger a change on the parent object and the key
56
56
  // i.e. when pushing a new item to `obj.data`, _parent will equal `obj`
57
57
  // and _key will equal `data`
58
- trigger(_parent, _key)
59
58
  resumeTracking()
59
+ trigger(_parent, _key)
60
60
  return result
61
61
  }
62
62
  } else {
@@ -35,7 +35,7 @@ const shaderAlias = {
35
35
  rounded: 'radius',
36
36
  }
37
37
 
38
- export default (component, name, identifier) => {
38
+ export default (component, name) => {
39
39
  Object.defineProperties(component.prototype, {
40
40
  name: {
41
41
  value: name,
@@ -19,7 +19,7 @@ import { default as fadeInFadeOutTransition } from './transitions/fadeInOut.js'
19
19
 
20
20
  import symbols from '../lib/symbols.js'
21
21
  import { Log } from '../lib/log.js'
22
- import Element from '../element.js'
22
+ import { stage } from '../launch.js'
23
23
  import Focus from '../focus.js'
24
24
  import Announcer from '../announcer/announcer.js'
25
25
 
@@ -130,7 +130,7 @@ export const navigate = async function () {
130
130
 
131
131
  if (!view) {
132
132
  // create a holder element for the new view
133
- holder = Element({ parent: this[symbols.children][0] })
133
+ holder = stage.element({ parent: this[symbols.children][0] })
134
134
  holder.populate({})
135
135
  holder.set('w', '100%')
136
136
  holder.set('h', '100%')