@lightningjs/blits 0.6.9 → 0.6.10
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 +9 -0
- package/bin/helpers.js +220 -0
- package/bin/index.js +141 -0
- package/boilerplate/common/eslint/husky/pre-commit +2 -0
- package/boilerplate/common/eslint/package.json +20 -0
- package/boilerplate/common/ide/.vscode/settings.json +10 -0
- package/boilerplate/js/default/.gitattributes +3 -0
- package/boilerplate/{package.json → js/default/package.json} +3 -3
- package/docs/getting_started.md +7 -7
- package/package.json +13 -5
- package/public/assets/fps_sprite.base64.js +1 -0
- package/public/assets/fps_sprite.png +0 -0
- package/scripts/postpublish.js +59 -0
- package/scripts/prepublishOnly.js +84 -0
- package/src/components/Circle.js +32 -3
- package/src/components/Circle.orig.js +31 -0
- package/src/components/FPScounter.js +1127 -0
- package/src/components/FPScounter.orig.js +122 -0
- package/src/components/Image.js +23 -2
- package/src/components/Image.orig.js +33 -0
- package/src/components/RouterView.js +22 -3
- package/src/components/RouterView.orig.js +51 -0
- package/src/components/Sprite.js +26 -3
- package/src/components/Sprite.orig.js +58 -0
- package/src/components/Text.js +56 -20
- package/src/components/Text.orig.js +79 -0
- package/src/launch.d.ts +10 -1
- package/src/launch.js +1 -0
- package/src/lib/precompiler/precompiler.js +64 -0
- package/src/lib/setup/base.js +2 -0
- package/vite/index.js +17 -0
- package/vite/preCompiler.js +19 -39
- package/bin/index.cjs +0 -25
- package/boilerplate/.vscode/settings.json +0 -10
- /package/boilerplate/{.editorconfig → common/eslint/.editorconfig} +0 -0
- /package/boilerplate/{.eslintignore → common/eslint/.eslintignore} +0 -0
- /package/boilerplate/{.eslintrc.cjs → common/eslint/.eslintrc.cjs} +0 -0
- /package/boilerplate/{.vscode → common/ide/.vscode}/extensions.json +0 -0
- /package/boilerplate/{.vscode → common/ide/.vscode}/launch.json +0 -0
- /package/boilerplate/{public → common/public}/assets/logo.png +0 -0
- /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.json +0 -0
- /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.png +0 -0
- /package/boilerplate/{public → common/public}/fonts/OpenSans-Medium.ttf +0 -0
- /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.json +0 -0
- /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.png +0 -0
- /package/boilerplate/{index.html → js/default/index.html} +0 -0
- /package/boilerplate/{src → js/default/src}/App.js +0 -0
- /package/boilerplate/{src → js/default/src}/components/Loader.js +0 -0
- /package/boilerplate/{src → js/default/src}/fontloader.js +0 -0
- /package/boilerplate/{src → js/default/src}/index.js +0 -0
- /package/boilerplate/{src → js/default/src}/pages/Home.js +0 -0
- /package/boilerplate/{src → js/default/src}/renderer.js +0 -0
- /package/boilerplate/{vite.config.js → js/default/vite.config.js} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
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 fs from 'fs'
|
|
19
|
+
import path from 'path'
|
|
20
|
+
import compiler from '../src/lib/precompiler/precompiler.js'
|
|
21
|
+
import { exec } from 'child_process'
|
|
22
|
+
|
|
23
|
+
const currentDir = process.cwd()
|
|
24
|
+
const componentDirs = ['src/components']
|
|
25
|
+
|
|
26
|
+
function precompileComponents() {
|
|
27
|
+
for (const dir of componentDirs) {
|
|
28
|
+
const fullDir = path.resolve(currentDir, dir)
|
|
29
|
+
console.log(`Checking files in ${fullDir} for components to precompile`)
|
|
30
|
+
processDirectory(fullDir)
|
|
31
|
+
}
|
|
32
|
+
console.log('Finished processing files suitable for precompilation')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function processDirectory(directory) {
|
|
36
|
+
const files = fs.readdirSync(directory)
|
|
37
|
+
|
|
38
|
+
for (const file of files) {
|
|
39
|
+
const filePath = path.join(directory, file)
|
|
40
|
+
const stat = fs.statSync(filePath)
|
|
41
|
+
|
|
42
|
+
if (stat.isDirectory()) {
|
|
43
|
+
processDirectory(filePath)
|
|
44
|
+
} else if (/^(?!.*\.orig\.(js|ts)$).*\.(js|ts)$/.test(file)) {
|
|
45
|
+
// only process files that don't end in .orig.js or .orig.ts
|
|
46
|
+
processFile(filePath)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function processFile(filePath) {
|
|
52
|
+
console.log(`Precompiling ${filePath}`)
|
|
53
|
+
// backup the file
|
|
54
|
+
const backupFilePath = filePath.replace(/\.(j|t)s$/, '.orig.$1s')
|
|
55
|
+
fs.copyFileSync(filePath, backupFilePath)
|
|
56
|
+
|
|
57
|
+
const source = fs.readFileSync(filePath, 'utf-8')
|
|
58
|
+
const newSource = compiler(source, filePath)
|
|
59
|
+
fs.writeFileSync(filePath, newSource)
|
|
60
|
+
|
|
61
|
+
// only format the file if it was changed
|
|
62
|
+
if (source !== newSource) {
|
|
63
|
+
formatFileWithESLint(filePath)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function formatFileWithESLint(filePath) {
|
|
68
|
+
const command = `eslint "${filePath}" --fix`
|
|
69
|
+
|
|
70
|
+
exec(command, (error, stdout, stderr) => {
|
|
71
|
+
if (error) {
|
|
72
|
+
console.error(`Execution Error: ${error.message}`)
|
|
73
|
+
console.error(`Exit Code: ${error.code}`)
|
|
74
|
+
}
|
|
75
|
+
if (stderr) {
|
|
76
|
+
console.error(`ESLint Error: ${stderr}`)
|
|
77
|
+
}
|
|
78
|
+
if (stdout) {
|
|
79
|
+
console.log(`ESLint Output: ${stdout}`)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
precompileComponents()
|
package/src/components/Circle.js
CHANGED
|
@@ -19,9 +19,38 @@ import Component from '../component.js'
|
|
|
19
19
|
|
|
20
20
|
export default () =>
|
|
21
21
|
Component('Circle', {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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('color', component.color)
|
|
41
|
+
},
|
|
42
|
+
function anonymous(component, elms, context) {
|
|
43
|
+
elms[0].set('w', component.size)
|
|
44
|
+
},
|
|
45
|
+
function anonymous(component, elms, context) {
|
|
46
|
+
elms[0].set('h', component.size)
|
|
47
|
+
},
|
|
48
|
+
function anonymous(component, elms, context) {
|
|
49
|
+
elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
context: {},
|
|
53
|
+
},
|
|
25
54
|
props: [{ key: 'size', default: 40 }, 'color'],
|
|
26
55
|
computed: {
|
|
27
56
|
radius() {
|
|
@@ -0,0 +1,31 @@
|
|
|
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('Circle', {
|
|
22
|
+
template: `
|
|
23
|
+
<Element :color="$color" :w="$size" :h="$size" :effects="[$shader('radius', {radius: $radius})]"></Element>
|
|
24
|
+
`,
|
|
25
|
+
props: [{ key: 'size', default: 40 }, 'color'],
|
|
26
|
+
computed: {
|
|
27
|
+
radius() {
|
|
28
|
+
return this.size / 2
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|