@lightningjs/blits 0.6.9 → 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.
Files changed (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/bin/helpers.js +220 -0
  3. package/bin/index.js +141 -0
  4. package/boilerplate/common/eslint/husky/pre-commit +2 -0
  5. package/boilerplate/common/eslint/package.json +20 -0
  6. package/boilerplate/common/ide/.vscode/settings.json +10 -0
  7. package/boilerplate/js/default/.gitattributes +3 -0
  8. package/boilerplate/{package.json → js/default/package.json} +3 -3
  9. package/docs/getting_started.md +7 -7
  10. package/package.json +13 -6
  11. package/public/assets/fps_sprite.base64.js +1 -0
  12. package/public/assets/fps_sprite.png +0 -0
  13. package/scripts/postpublish.js +59 -0
  14. package/scripts/prepublishOnly.js +84 -0
  15. package/src/component.js +0 -6
  16. package/src/components/Circle.js +32 -3
  17. package/src/components/Circle.orig.js +31 -0
  18. package/src/components/FPScounter.js +1127 -0
  19. package/src/components/FPScounter.orig.js +122 -0
  20. package/src/components/Image.js +23 -2
  21. package/src/components/Image.orig.js +33 -0
  22. package/src/components/RouterView.js +24 -5
  23. package/src/components/RouterView.orig.js +51 -0
  24. package/src/components/Sprite.js +26 -3
  25. package/src/components/Sprite.orig.js +58 -0
  26. package/src/components/Text.js +56 -20
  27. package/src/components/Text.orig.js +79 -0
  28. package/src/launch.d.ts +10 -1
  29. package/src/launch.js +1 -0
  30. package/src/lib/codegenerator/generator.js +23 -13
  31. package/src/lib/precompiler/precompiler.js +64 -0
  32. package/src/lib/setup/base.js +2 -0
  33. package/src/lib/symbols.js +2 -0
  34. package/src/lib/templateparser/parser.js +8 -6
  35. package/vite/index.js +17 -0
  36. package/vite/preCompiler.js +19 -39
  37. package/bin/index.cjs +0 -25
  38. package/boilerplate/.vscode/settings.json +0 -10
  39. /package/boilerplate/{.editorconfig → common/eslint/.editorconfig} +0 -0
  40. /package/boilerplate/{.eslintignore → common/eslint/.eslintignore} +0 -0
  41. /package/boilerplate/{.eslintrc.cjs → common/eslint/.eslintrc.cjs} +0 -0
  42. /package/boilerplate/{.vscode → common/ide/.vscode}/extensions.json +0 -0
  43. /package/boilerplate/{.vscode → common/ide/.vscode}/launch.json +0 -0
  44. /package/boilerplate/{public → common/public}/assets/logo.png +0 -0
  45. /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.json +0 -0
  46. /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.png +0 -0
  47. /package/boilerplate/{public → common/public}/fonts/OpenSans-Medium.ttf +0 -0
  48. /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.json +0 -0
  49. /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.png +0 -0
  50. /package/boilerplate/{index.html → js/default/index.html} +0 -0
  51. /package/boilerplate/{src → js/default/src}/App.js +0 -0
  52. /package/boilerplate/{src → js/default/src}/components/Loader.js +0 -0
  53. /package/boilerplate/{src → js/default/src}/fontloader.js +0 -0
  54. /package/boilerplate/{src → js/default/src}/index.js +0 -0
  55. /package/boilerplate/{src → js/default/src}/pages/Home.js +0 -0
  56. /package/boilerplate/{src → js/default/src}/renderer.js +0 -0
  57. /package/boilerplate/{vite.config.js → js/default/vite.config.js} +0 -0
@@ -0,0 +1,122 @@
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 Component from '../component.js'
19
+ import { renderer } from '../launch.js'
20
+ import fps_sprite from '../../public/assets/fps_sprite.base64.js'
21
+
22
+ console.log(fps_sprite)
23
+
24
+ export default () =>
25
+ Component('FPScounter', {
26
+ template: `
27
+ <Element>
28
+ <Element y="15" x="20">
29
+ <Element>
30
+ <Sprite image="$image" w="43" h="25" map="$sprite" frame="fps" />
31
+ <Element x="58" y="2">
32
+ <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$fps[0]" />
33
+ <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$fps[1]" />
34
+ <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$fps[2]" />
35
+ </Element>
36
+ </Element>
37
+
38
+ <Element x="150">
39
+ <Sprite image="$image" y="2" w="48" h="25" map="$sprite" frame="avg" />
40
+ <Element x="63" y="2">
41
+ <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$avgFps[0]" />
42
+ <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$avgFps[1]" />
43
+ <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$avgFps[2]" />
44
+ </Element>
45
+ </Element>
46
+
47
+ <Element x="0" y="40" >
48
+ <Sprite image="$image" x="-2" w="47" h="25" map="$sprite" frame="min" />
49
+ <Element x="58" y="2">
50
+ <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$minFps[0]" />
51
+ <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$minFps[1]" />
52
+ <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$minFps[2]" />
53
+ </Element>
54
+ </Element>
55
+
56
+ <Element x="150" y="40">
57
+ <Sprite image="$image" w="53" h="25" map="$sprite" frame="max" />
58
+ <Element x="63" y="2">
59
+ <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$maxFps[0]" />
60
+ <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$maxFps[1]" />
61
+ <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$maxFps[2]" />
62
+ </Element>
63
+ </Element>
64
+ </Element>
65
+ </Element>
66
+ `,
67
+ state() {
68
+ return {
69
+ image: fps_sprite,
70
+ sprite: {
71
+ defaults: {
72
+ y: 1,
73
+ w: 20,
74
+ h: 20,
75
+ },
76
+ frames: {
77
+ '-': { x: -1000 },
78
+ 0: { x: 1 },
79
+ 1: { x: 23 },
80
+ 2: { x: 45 },
81
+ 3: { x: 67 },
82
+ 4: { x: 89 },
83
+ 5: { x: 111 },
84
+ 6: { x: 133 },
85
+ 7: { x: 155 },
86
+ 8: { x: 177 },
87
+ 9: { x: 199 },
88
+ avg: { x: 221, w: 48, h: 25 },
89
+ fps: { x: 271, w: 43, h: 25 },
90
+ max: { x: 316, w: 53, h: 25 },
91
+ min: { x: 371, w: 47, h: 25 },
92
+ },
93
+ },
94
+ fps: '---',
95
+ avgFps: '---',
96
+ minFps: '---',
97
+ maxFps: '---',
98
+ }
99
+ },
100
+ hooks: {
101
+ ready() {
102
+ let minFps = 10000
103
+ let maxFps = 0
104
+ let avgFps = 0
105
+ let totalFps = 0
106
+ let fpsUpdateCounter = 0
107
+
108
+ renderer.on('fpsUpdate', (rM, { fps }) => {
109
+ minFps = Math.min(fps, minFps)
110
+ maxFps = Math.max(fps, maxFps)
111
+ totalFps += fps
112
+ fpsUpdateCounter++
113
+ avgFps = Math.round(totalFps / fpsUpdateCounter)
114
+
115
+ this.fps = fps.toString().padStart(3, '0')
116
+ this.avgFps = avgFps.toString().padStart(3, '0')
117
+ this.minFps = minFps.toString().padStart(3, '0')
118
+ this.maxFps = maxFps.toString().padStart(3, '0')
119
+ })
120
+ },
121
+ },
122
+ })
@@ -19,8 +19,29 @@ import Component from '../component.js'
19
19
 
20
20
  export default () =>
21
21
  Component('Image', {
22
- template: `
23
- <Element :imageSource="$imageSource" />`,
22
+ /* eslint-disable no-unused-vars */
23
+ code: {
24
+ render: function anonymous(parent, component, context) {
25
+ const elms = []
26
+
27
+ if (!elms[0]) {
28
+ elms[0] = this.element({ parent: parent || 'root' }, component)
29
+ }
30
+ const elementConfig0 = {}
31
+
32
+ if (!elms[0].nodeId) {
33
+ elms[0].populate(elementConfig0)
34
+ }
35
+
36
+ return elms
37
+ },
38
+ effects: [
39
+ function anonymous(component, elms, context) {
40
+ elms[0].set('imageSource', component.imageSource)
41
+ },
42
+ ],
43
+ context: {},
44
+ },
24
45
  props: ['src'],
25
46
  computed: {
26
47
  imageSource() {
@@ -0,0 +1,33 @@
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 Component from '../component.js'
19
+
20
+ export default () =>
21
+ Component('Image', {
22
+ template: `
23
+ <Element :imageSource="$imageSource" />`,
24
+ props: ['src'],
25
+ computed: {
26
+ imageSource() {
27
+ if (/^(?:https?:)?\/\//i.test(this.src)) {
28
+ return this.src
29
+ }
30
+ return `${window.location.protocol}//${window.location.host}/${this.src}`
31
+ },
32
+ },
33
+ })
@@ -22,9 +22,28 @@ let handler
22
22
 
23
23
  export default () =>
24
24
  Component('RouterView', {
25
- template: `
26
- <Element w="100%" height="100%"></Element>
27
- `,
25
+ /* eslint-disable no-unused-vars */
26
+ code: {
27
+ render: function anonymous(parent, component, context) {
28
+ const elms = []
29
+
30
+ if (!elms[0]) {
31
+ elms[0] = this.element({ parent: parent || 'root' }, component)
32
+ }
33
+ const elementConfig0 = {}
34
+
35
+ elementConfig0['w'] = parent.node.width * (100 / 100)
36
+ elementConfig0['height'] = parent.node.height * (100 / 100)
37
+
38
+ if (!elms[0].nodeId) {
39
+ elms[0].populate(elementConfig0)
40
+ }
41
+
42
+ return elms
43
+ },
44
+ effects: [],
45
+ context: {},
46
+ },
28
47
  state() {
29
48
  return {
30
49
  activeView: null,
@@ -44,8 +63,8 @@ export default () =>
44
63
  },
45
64
  },
46
65
  input: {
47
- back(e) {
48
- if (!Router.back()) this.parent.focus(e)
66
+ back() {
67
+ Router.back()
49
68
  },
50
69
  },
51
70
  })
@@ -0,0 +1,51 @@
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 Component from '../component.js'
19
+ import Router from '../router/router.js'
20
+
21
+ let handler
22
+
23
+ export default () =>
24
+ Component('RouterView', {
25
+ template: `
26
+ <Element w="100%" height="100%"></Element>
27
+ `,
28
+ state() {
29
+ return {
30
+ activeView: null,
31
+ }
32
+ },
33
+ hooks: {
34
+ ready() {
35
+ handler = () => Router.navigate.apply(this)
36
+ Router.navigate.apply(this)
37
+ window.addEventListener('hashchange', handler)
38
+ },
39
+ destroy() {
40
+ window.removeEventListener('hashchange', handler, false)
41
+ },
42
+ focus() {
43
+ this.activeView && this.activeView.focus()
44
+ },
45
+ },
46
+ input: {
47
+ back() {
48
+ Router.back()
49
+ },
50
+ },
51
+ })
@@ -21,9 +21,32 @@ import symbols from '../lib/symbols.js'
21
21
 
22
22
  export default () =>
23
23
  Component('Sprite', {
24
- template: `
25
- <Element w="$w" h="$h" :texture="$texture" />
26
- `,
24
+ /* eslint-disable no-unused-vars */
25
+ code: {
26
+ render: function anonymous(parent, component, context) {
27
+ const elms = []
28
+
29
+ if (!elms[0]) {
30
+ elms[0] = this.element({ parent: parent || 'root' }, component)
31
+ }
32
+ const elementConfig0 = {}
33
+
34
+ elementConfig0['w'] = component.w
35
+ elementConfig0['h'] = component.h
36
+
37
+ if (!elms[0].nodeId) {
38
+ elms[0].populate(elementConfig0)
39
+ }
40
+
41
+ return elms
42
+ },
43
+ effects: [
44
+ function anonymous(component, elms, context) {
45
+ elms[0].set('texture', component.texture)
46
+ },
47
+ ],
48
+ context: {},
49
+ },
27
50
  props: ['image', 'map', 'frame', 'w', 'h'],
28
51
  state() {
29
52
  return {
@@ -0,0 +1,58 @@
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 Component from '../component.js'
19
+
20
+ import symbols from '../lib/symbols.js'
21
+
22
+ export default () =>
23
+ Component('Sprite', {
24
+ template: `
25
+ <Element w="$w" h="$h" :texture="$texture" />
26
+ `,
27
+ props: ['image', 'map', 'frame', 'w', 'h'],
28
+ state() {
29
+ return {
30
+ spriteTexture: false,
31
+ }
32
+ },
33
+ computed: {
34
+ texture() {
35
+ const options =
36
+ 'frames' in this.map
37
+ ? Object.assign({}, this.map.defaults || {}, this.map.frames[this.frame])
38
+ : this.map[this.frame]
39
+
40
+ if (this.spriteTexture && options) {
41
+ return this[symbols.renderer].createTexture('SubTexture', {
42
+ texture: this.spriteTexture,
43
+ x: options.x,
44
+ y: options.y,
45
+ width: options.w,
46
+ height: options.h,
47
+ })
48
+ }
49
+ },
50
+ },
51
+ hooks: {
52
+ ready() {
53
+ this.spriteTexture = this[symbols.renderer].createTexture('ImageTexture', {
54
+ src: this.image,
55
+ })
56
+ },
57
+ },
58
+ })
@@ -20,26 +20,62 @@ import Settings from '../settings.js'
20
20
 
21
21
  export default () =>
22
22
  Component('Text', {
23
- template: `
24
- <Element
25
- __textnode="true"
26
- :text="$content"
27
- fontFamily="$font"
28
- :fontSize="$size"
29
- :color="$color"
30
- :style="$style"
31
- :weight="$weight"
32
- letterSpacing="$letterspacing"
33
- lineHeight="$_lineheight"
34
- stretch="$stretch"
35
- contain="$_contain"
36
- :wordWrap="$wordwrap"
37
- :maxLines="$maxlines"
38
- :textAlign="$align"
39
- :overflowSuffix="$textoverflow"
40
- @loaded="$@loaded"
41
- @error="$@error"
42
- />`,
23
+ /* eslint-disable no-unused-vars */
24
+ code: {
25
+ render: function anonymous(parent, component, context) {
26
+ const elms = []
27
+
28
+ if (!elms[0]) {
29
+ elms[0] = this.element({ parent: parent || 'root' }, component)
30
+ }
31
+ const elementConfig0 = {}
32
+
33
+ elementConfig0['__textnode'] = true
34
+ elementConfig0['fontFamily'] = component.font
35
+ elementConfig0['letterSpacing'] = component.letterspacing
36
+ elementConfig0['lineHeight'] = component._lineheight
37
+ elementConfig0['stretch'] = component.stretch
38
+ elementConfig0['contain'] = component._contain
39
+ elementConfig0['@loaded'] = component['@loaded'] && component['@loaded'].bind(component)
40
+ elementConfig0['@error'] = component['@error'] && component['@error'].bind(component)
41
+
42
+ if (!elms[0].nodeId) {
43
+ elms[0].populate(elementConfig0)
44
+ }
45
+
46
+ return elms
47
+ },
48
+ effects: [
49
+ function anonymous(component, elms, context) {
50
+ elms[0].set('text', component.content)
51
+ },
52
+ function anonymous(component, elms, context) {
53
+ elms[0].set('fontSize', component.size)
54
+ },
55
+ function anonymous(component, elms, context) {
56
+ elms[0].set('color', component.color)
57
+ },
58
+ function anonymous(component, elms, context) {
59
+ elms[0].set('style', component.style)
60
+ },
61
+ function anonymous(component, elms, context) {
62
+ elms[0].set('weight', component.weight)
63
+ },
64
+ function anonymous(component, elms, context) {
65
+ elms[0].set('wordWrap', component.wordwrap)
66
+ },
67
+ function anonymous(component, elms, context) {
68
+ elms[0].set('maxLines', component.maxlines)
69
+ },
70
+ function anonymous(component, elms, context) {
71
+ elms[0].set('textAlign', component.align)
72
+ },
73
+ function anonymous(component, elms, context) {
74
+ elms[0].set('overflowSuffix', component.textoverflow)
75
+ },
76
+ ],
77
+ context: {},
78
+ },
43
79
  props: [
44
80
  'content',
45
81
  {
@@ -0,0 +1,79 @@
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 Component from '../component.js'
19
+ import Settings from '../settings.js'
20
+
21
+ export default () =>
22
+ Component('Text', {
23
+ template: `
24
+ <Element
25
+ __textnode="true"
26
+ :text="$content"
27
+ fontFamily="$font"
28
+ :fontSize="$size"
29
+ :color="$color"
30
+ :style="$style"
31
+ :weight="$weight"
32
+ letterSpacing="$letterspacing"
33
+ lineHeight="$_lineheight"
34
+ stretch="$stretch"
35
+ contain="$_contain"
36
+ :wordWrap="$wordwrap"
37
+ :maxLines="$maxlines"
38
+ :textAlign="$align"
39
+ :overflowSuffix="$textoverflow"
40
+ @loaded="$@loaded"
41
+ @error="$@error"
42
+ />`,
43
+ props: [
44
+ 'content',
45
+ {
46
+ key: 'font',
47
+ default: Settings.get('defaultFont', 'lato'),
48
+ },
49
+ {
50
+ key: 'size',
51
+ cast: Number,
52
+ default: 32,
53
+ },
54
+ 'style',
55
+ 'color',
56
+ 'weight',
57
+ 'letterspacing',
58
+ 'stretch',
59
+ 'align',
60
+ 'wordwrap',
61
+ 'maxlines',
62
+ 'lineheight',
63
+ 'contain',
64
+ '@loaded',
65
+ '@error',
66
+ 'textoverflow',
67
+ ],
68
+ computed: {
69
+ _contain() {
70
+ return (
71
+ this.contain ||
72
+ (this.wordwrap && this.maxlines ? 'both' : this.wordwrap ? 'width' : 'none')
73
+ )
74
+ },
75
+ _lineheight() {
76
+ return this.lineheight !== undefined ? this.lineheight : this.size
77
+ },
78
+ },
79
+ })
package/src/launch.d.ts CHANGED
@@ -144,7 +144,16 @@ export interface Settings {
144
144
  *
145
145
  * Defaults to 1 if not specified
146
146
  */
147
- pixelRatio?: number,
147
+ pixelRatio?: number
148
+ /**
149
+ * Interval in milliseconds to receive FPS updates
150
+ *
151
+ * @remarks
152
+ * If set to `0`, FPS updates will be disabled.
153
+ *
154
+ * @defaultValue `1000` (disabled)
155
+ */
156
+ fpsInterval?: number
148
157
  /**
149
158
  * Maximum number of web workers to spin up simultaneously for offloading functionality such
150
159
  * as image loading to separate threads (when supported by the browser)
package/src/launch.js CHANGED
@@ -41,6 +41,7 @@ export default (App, target, settings) => {
41
41
  appWidth: settings.w || 1920,
42
42
  appHeight: settings.h || 1080,
43
43
  coreExtensionModule: settings.fontLoader,
44
+ fpsUpdateInterval: settings.fpsInterval || 1000,
44
45
  deviceLogicalPixelRatio:
45
46
  settings.pixelRatio ||
46
47
  screenResolutions[settings.screenResolution] ||
@@ -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)