@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 +8 -0
- package/package.json +9 -10
- package/src/component.js +0 -6
- package/src/components/RouterView.js +2 -2
- package/src/components/RouterView.orig.js +2 -2
- package/src/lib/codegenerator/generator.js +23 -13
- package/src/lib/symbols.js +2 -0
- package/src/lib/templateparser/parser.js +8 -6
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.
|
|
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,
|
|
@@ -64,14 +64,11 @@ const generateElementCode = function (
|
|
|
64
64
|
const children = templateObject['children']
|
|
65
65
|
delete templateObject['children']
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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['${
|
|
123
|
-
|
|
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['${
|
|
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 (
|
|
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 (
|
|
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)
|
package/src/lib/symbols.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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.
|
|
334
|
+
hierarchy = `${currentParent[Symbol.for('componentType')]}/${hierarchy}`
|
|
333
335
|
currentParent = currentParent.parent
|
|
334
336
|
}
|
|
335
337
|
return hierarchy
|