@lightningjs/blits 0.6.10 → 0.6.11

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,13 @@
1
1
  # Changelog
2
2
 
3
+ # v0.6.11
4
+
5
+ _7 feb 2024_
6
+
7
+ - Enabled the use of `type` as a component prop or state variable
8
+ - Removed setting focus to AppComponent on back key press in RouterView
9
+ - Fixed broken app create flow caused by missing dev dependencies in npx command (temporary fix)
10
+
3
11
  # v0.6.10
4
12
 
5
13
  _2 feb 2024_
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.6.10",
3
+ "version": "0.6.11",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -36,22 +36,21 @@
36
36
  "eslint": "^8.8.0",
37
37
  "eslint-config-prettier": "^8.3.0",
38
38
  "eslint-plugin-prettier": "^4.0.0",
39
- "esm": "^3.2.25",
40
- "execa": "^8.0.1",
41
39
  "husky": "^7.0.4",
42
- "kolorist": "^1.8.0",
43
40
  "lint-staged": "^12.3.3",
44
- "ora": "^7.0.1",
45
41
  "prettier": "^2.5.1",
46
- "prompts": "^2.4.2",
47
- "replace-in-file": "^6.1.0",
48
42
  "tap-diff": "^0.1.1",
49
- "tape": "^5.5.0",
50
- "validate-npm-package-name": "^5.0.0"
43
+ "tape": "^5.5.0"
51
44
  },
52
45
  "dependencies": {
53
46
  "@lightningjs/renderer": "^0.7.1",
54
- "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0"
47
+ "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0",
48
+ "execa": "^8.0.1",
49
+ "kolorist": "^1.8.0",
50
+ "ora": "^7.0.1",
51
+ "prompts": "^2.4.2",
52
+ "replace-in-file": "^6.1.0",
53
+ "validate-npm-package-name": "^5.0.0"
55
54
  },
56
55
  "repository": {
57
56
  "type": "git",
package/src/component.js CHANGED
@@ -122,12 +122,6 @@ const Component = (name = required('name'), config = required('config')) => {
122
122
  this[symbols.wrapper] = parentEl
123
123
 
124
124
  Object.defineProperties(this, {
125
- type: {
126
- value: name,
127
- writable: false,
128
- enumerable: true,
129
- configurable: false,
130
- },
131
125
  componentId: {
132
126
  value: createHumanReadableId(name),
133
127
  writable: false,
@@ -63,8 +63,8 @@ export default () =>
63
63
  },
64
64
  },
65
65
  input: {
66
- back(e) {
67
- if (!Router.back()) this.parent.focus(e)
66
+ back() {
67
+ Router.back()
68
68
  },
69
69
  },
70
70
  })
@@ -44,8 +44,8 @@ export default () =>
44
44
  },
45
45
  },
46
46
  input: {
47
- back(e) {
48
- if (!Router.back()) this.parent.focus(e)
47
+ back() {
48
+ Router.back()
49
49
  },
50
50
  },
51
51
  })
@@ -64,14 +64,11 @@ const generateElementCode = function (
64
64
  const children = templateObject['children']
65
65
  delete templateObject['children']
66
66
 
67
- Object.keys(templateObject).forEach((key) => {
68
- if (key === 'type') {
69
- if (templateObject[key] === 'Slot') {
70
- renderCode.push(`elementConfig${counter}[Symbol.for('isSlot')] = true`)
71
- }
72
- return
73
- }
67
+ if (templateObject[Symbol.for('componentType')] === 'Slot') {
68
+ renderCode.push(`elementConfig${counter}[Symbol.for('isSlot')] = true`)
69
+ }
74
70
 
71
+ Object.keys(templateObject).forEach((key) => {
75
72
  if (key === 'slot') {
76
73
  renderCode.push(`
77
74
  elementConfig${counter}['parent'] = component[Symbol.for('slots')].filter(slot => slot.ref === '${templateObject.slot}').shift() || component[Symbol.for('slots')][0] || parent
@@ -119,8 +116,10 @@ const generateComponentCode = function (
119
116
 
120
117
  renderCode.push(`
121
118
  const cmp${counter} =
122
- (context.components && context.components['${templateObject.type}']) ||
123
- component[Symbol.for('components')]['${templateObject.type}']
119
+ (context.components && context.components['${
120
+ templateObject[Symbol.for('componentType')]
121
+ }']) ||
122
+ component[Symbol.for('components')]['${templateObject[Symbol.for('componentType')]}']
124
123
  `)
125
124
 
126
125
  if ('key' in templateObject) {
@@ -149,7 +148,6 @@ const generateComponentCode = function (
149
148
 
150
149
  renderCode.push(`const props${counter} = {}`)
151
150
  Object.keys(templateObject).forEach((key) => {
152
- if (key === 'type') return
153
151
  if (isReactiveKey(key)) {
154
152
  this.effectsCode.push(`
155
153
  ${elm}[Symbol.for('props')]['${key.substring(1)}'] = ${interpolate(
@@ -171,7 +169,13 @@ const generateComponentCode = function (
171
169
 
172
170
  renderCode.push(`
173
171
  if(!${elm}) {
174
- ${elm} = (context.components && context.components['${templateObject.type}'] || component[Symbol.for('components')]['${templateObject.type}'] || (() => { console.error('component ${templateObject.type} not found')})).call(null, {props: props${counter}}, ${parent}, component)
172
+ ${elm} = (context.components && context.components['${
173
+ templateObject[Symbol.for('componentType')]
174
+ }'] || component[Symbol.for('components')]['${
175
+ templateObject[Symbol.for('componentType')]
176
+ }'] || (() => { console.error('component ${
177
+ templateObject[Symbol.for('componentType')]
178
+ } not found')})).call(null, {props: props${counter}}, ${parent}, component)
175
179
  if (${elm}[Symbol.for('slots')][0]) {
176
180
  parent = ${elm}[Symbol.for('slots')][0]
177
181
  component = ${elm}
@@ -245,7 +249,10 @@ const generateForLoopCode = function (templateObject, parent) {
245
249
  `)
246
250
  }
247
251
 
248
- if (templateObject.type === 'Element' || templateObject.type === 'Slot') {
252
+ if (
253
+ templateObject[Symbol.for('componentType')] === 'Element' ||
254
+ templateObject[Symbol.for('componentType')] === 'Slot'
255
+ ) {
249
256
  generateElementCode.call(ctx, templateObject, parent, {
250
257
  key: 'scope.key',
251
258
  component: 'scope.',
@@ -283,7 +290,10 @@ const generateCode = function (templateObject, parent = false, options = {}) {
283
290
  if (Object.keys(childTemplateObject).indexOf(':for') > -1) {
284
291
  generateForLoopCode.call(this, childTemplateObject, parent)
285
292
  } else {
286
- if (childTemplateObject.type === 'Element' || childTemplateObject.type === 'Slot') {
293
+ if (
294
+ childTemplateObject[Symbol.for('componentType')] === 'Element' ||
295
+ childTemplateObject[Symbol.for('componentType')] === 'Slot'
296
+ ) {
287
297
  generateElementCode.call(this, childTemplateObject, parent, options)
288
298
  } else {
289
299
  generateComponentCode.call(this, childTemplateObject, parent, options)
@@ -36,4 +36,6 @@ export default {
36
36
  props: Symbol.for('props'),
37
37
  // Symbol 'slots' utilized within generated code
38
38
  slots: Symbol.for('slots'),
39
+ // Symbol 'componentType' utilized within generated code
40
+ componentType: Symbol.for('componentType'),
39
41
  }
@@ -77,7 +77,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
77
77
  const match = moveCursorOnMatch(emptyTagStartRegex)
78
78
  if (match) {
79
79
  tags.push({
80
- type: null,
80
+ [Symbol.for('componentType')]: null,
81
81
  [symbols.type]: 'opening',
82
82
  [symbols.level]: currentLevel,
83
83
  [symbols.cursorTagStart]: prevCursor,
@@ -94,7 +94,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
94
94
  if (match) {
95
95
  currentLevel--
96
96
  tags.push({
97
- type: null,
97
+ [Symbol.for('componentType')]: null,
98
98
  [symbols.type]: 'closing',
99
99
  [symbols.level]: currentLevel,
100
100
  })
@@ -108,7 +108,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
108
108
  const match = moveCursorOnMatch(tagStartRegex)
109
109
  if (match) {
110
110
  currentTag = {
111
- type: match[1],
111
+ [Symbol.for('componentType')]: match[1],
112
112
  [symbols.level]: currentLevel,
113
113
  [symbols.cursorTagStart]: prevCursor,
114
114
  }
@@ -221,7 +221,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
221
221
  [symbols.level]: element[symbols.level],
222
222
  [symbols.type]: element[symbols.type],
223
223
  [symbols.cursorTagStart]: element[symbols.cursorTagStart],
224
- type: element.type,
224
+ [Symbol.for('componentType')]: element[Symbol.for('componentType')],
225
225
  parent: currentParent, // helps getting the previous parent when closing tag is encountered
226
226
  })
227
227
  } else if (element[symbols.type] === 'closing') {
@@ -230,7 +230,9 @@ export default (template = '', componentName, parentComponent, filePath = null)
230
230
  let isTagMismatch = false
231
231
  if (!isStackEmpty) {
232
232
  isLevelMismatch = stack[stack.length - 1][symbols.level] !== element[symbols.level]
233
- isTagMismatch = stack[stack.length - 1].type !== element.type
233
+ isTagMismatch =
234
+ stack[stack.length - 1][Symbol.for('componentType')] !==
235
+ element[Symbol.for('componentType')]
234
236
  }
235
237
 
236
238
  if (isStackEmpty || isLevelMismatch || isTagMismatch) {
@@ -329,7 +331,7 @@ export default (template = '', componentName, parentComponent, filePath = null)
329
331
  let currentParent = parentComponent
330
332
 
331
333
  while (currentParent) {
332
- hierarchy = `${currentParent.type}/${hierarchy}`
334
+ hierarchy = `${currentParent[Symbol.for('componentType')]}/${hierarchy}`
333
335
  currentParent = currentParent.parent
334
336
  }
335
337
  return hierarchy