@lightningjs/blits 1.23.0 → 1.23.2

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.23.2
4
+
5
+ _18 mar 2025_
6
+
7
+ - Fixed issue with keepAlive pages remaining in cache after navigating back
8
+
9
+ ## v1.23.1
10
+
11
+ _17 mar 2025_
12
+
13
+ - Fixed issue in vite plugin that ensures reacitivity setup in computed props when code block has a comment
14
+ - Fixed warnings for non-declared variables in template when they refer to plugins (i.e. `$$apState.foo`)
15
+
3
16
  ## v1.23.0
4
17
 
5
18
  _13 mar 2025_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -80,7 +80,7 @@ export default function (templateObject = { children: [] }, devMode = false) {
80
80
 
81
81
  // This is used to get only variable from expression
82
82
  const extractVariables = function (value) {
83
- const regEx = /\$\w+(\.\w+)?/g
83
+ const regEx = /\$\$?\w+(\.\w+)?/g
84
84
  const matches = value.match(regEx)
85
85
  if (matches !== null) {
86
86
  const shaderRegex = /\$shader/
@@ -45,7 +45,7 @@ export const removeGlobalEffects = (effectsToRemove) => {
45
45
  }
46
46
 
47
47
  export const track = (target, key, global = false) => {
48
- if (currentEffect) {
48
+ if (currentEffect !== null) {
49
49
  if (paused) {
50
50
  return
51
51
  }
@@ -55,12 +55,12 @@ export const track = (target, key, global = false) => {
55
55
  } else if (currentKey !== null && key !== currentKey) return
56
56
 
57
57
  let effectsMap = objectMap.get(target)
58
- if (!effectsMap) {
58
+ if (effectsMap === undefined) {
59
59
  effectsMap = new Map()
60
60
  objectMap.set(target, effectsMap)
61
61
  }
62
62
  let effects = effectsMap.get(key)
63
- if (!effects) {
63
+ if (effects === undefined) {
64
64
  effects = new Set()
65
65
  effectsMap.set(key, effects)
66
66
  }
@@ -73,11 +73,11 @@ export const track = (target, key, global = false) => {
73
73
  export const trigger = (target, key, force = false) => {
74
74
  if (paused === true) return
75
75
  const effectsMap = objectMap.get(target)
76
- if (!effectsMap) {
76
+ if (effectsMap === undefined) {
77
77
  return
78
78
  }
79
79
  const effects = effectsMap.get(key)
80
- if (effects) {
80
+ if (effects !== undefined) {
81
81
  for (let effect of effects) {
82
82
  effect(force)
83
83
  }
@@ -133,12 +133,23 @@ export default (code) => {
133
133
  const openBraceIndex = prop.fullText.indexOf('{')
134
134
 
135
135
  if (openBraceIndex !== -1) {
136
+ // Extract indentation from the original function body
137
+ const indentMatch = prop.body.match(/^(\s+)/)
138
+ const indent = indentMatch ? indentMatch[1] + ' ' : ' ' // Default to 4 spaces if no indent found
139
+
136
140
  const modifiedPropText =
137
141
  prop.fullText.substring(0, openBraceIndex + 1) +
142
+ '\n' +
143
+ indent +
138
144
  commentText +
145
+ '\n' +
146
+ indent +
139
147
  refCode +
140
- ' ' +
148
+ '\n' +
149
+ indent +
141
150
  prop.body +
151
+ '\n' +
152
+ prop.fullText.substring(0, openBraceIndex).match(/^(\s*)/)[0] +
142
153
  '}'
143
154
 
144
155
  // Replace this property in the computed object text
@@ -328,15 +328,19 @@ const removeView = async (route, view, transition) => {
328
328
  }
329
329
 
330
330
  // cache the page when it's as 'keepAlive' instead of destroying
331
- if (route.options && route.options.keepAlive === true && navigatingBack === false) {
331
+ if (navigatingBack === false && route.options && route.options.keepAlive === true) {
332
332
  cacheMap.set(route.hash, { view: view, focus: previousFocus })
333
333
  } else if (navigatingBack === true) {
334
334
  // remove the previous route from the cache when navigating back
335
335
  // cacheMap.delete will not throw an error if the route is not in the cache
336
336
  cacheMap.delete(route.hash)
337
337
  }
338
-
339
- if (route.options && route.options.keepAlive !== true) {
338
+ /* Destroy the view in the following cases:
339
+ * 1. Navigating forward, and the previous route is not configured with "keep alive" set to true.
340
+ * 2. Navigating back, and the previous route is configured with "keep alive" set to true.
341
+ * 3. Navigating back, and the previous route is not configured with "keep alive" set to true.
342
+ */
343
+ if (route.options && (route.options.keepAlive !== true || navigatingBack === true)) {
340
344
  view.destroy()
341
345
  view = null
342
346
  }