@lightningjs/blits 0.6.8 → 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.
Files changed (55) hide show
  1. package/CHANGELOG.md +16 -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 -5
  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/components/Circle.js +32 -3
  16. package/src/components/Circle.orig.js +31 -0
  17. package/src/components/FPScounter.js +1127 -0
  18. package/src/components/FPScounter.orig.js +122 -0
  19. package/src/components/Image.js +23 -2
  20. package/src/components/Image.orig.js +33 -0
  21. package/src/components/RouterView.js +22 -3
  22. package/src/components/RouterView.orig.js +51 -0
  23. package/src/components/Sprite.js +26 -3
  24. package/src/components/Sprite.orig.js +58 -0
  25. package/src/components/Text.js +56 -20
  26. package/src/components/Text.orig.js +79 -0
  27. package/src/launch.d.ts +10 -1
  28. package/src/launch.js +1 -0
  29. package/src/lib/codegenerator/generator.js +6 -2
  30. package/src/lib/precompiler/precompiler.js +64 -0
  31. package/src/lib/setup/base.js +2 -0
  32. package/src/router/router.js +8 -3
  33. package/vite/index.js +17 -0
  34. package/vite/preCompiler.js +19 -39
  35. package/bin/index.cjs +0 -25
  36. package/boilerplate/.vscode/settings.json +0 -10
  37. /package/boilerplate/{.editorconfig → common/eslint/.editorconfig} +0 -0
  38. /package/boilerplate/{.eslintignore → common/eslint/.eslintignore} +0 -0
  39. /package/boilerplate/{.eslintrc.cjs → common/eslint/.eslintrc.cjs} +0 -0
  40. /package/boilerplate/{.vscode → common/ide/.vscode}/extensions.json +0 -0
  41. /package/boilerplate/{.vscode → common/ide/.vscode}/launch.json +0 -0
  42. /package/boilerplate/{public → common/public}/assets/logo.png +0 -0
  43. /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.json +0 -0
  44. /package/boilerplate/{public → common/public}/fonts/Lato-Regular.msdf.png +0 -0
  45. /package/boilerplate/{public → common/public}/fonts/OpenSans-Medium.ttf +0 -0
  46. /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.json +0 -0
  47. /package/boilerplate/{public → common/public}/fonts/Raleway-ExtraBold.msdf.png +0 -0
  48. /package/boilerplate/{index.html → js/default/index.html} +0 -0
  49. /package/boilerplate/{src → js/default/src}/App.js +0 -0
  50. /package/boilerplate/{src → js/default/src}/components/Loader.js +0 -0
  51. /package/boilerplate/{src → js/default/src}/fontloader.js +0 -0
  52. /package/boilerplate/{src → js/default/src}/index.js +0 -0
  53. /package/boilerplate/{src → js/default/src}/pages/Home.js +0 -0
  54. /package/boilerplate/{src → js/default/src}/renderer.js +0 -0
  55. /package/boilerplate/{vite.config.js → js/default/vite.config.js} +0 -0
@@ -30,6 +30,7 @@ const cacheMap = new WeakMap()
30
30
  const history = []
31
31
  let overrideOptions = {}
32
32
  let navigatingBack = false
33
+ let previousFocus
33
34
 
34
35
  export const getHash = () => {
35
36
  return (document.location.hash || '/').replace(/^#/, '')
@@ -97,6 +98,12 @@ export const navigate = async function () {
97
98
 
98
99
  this[symbols.children].push(view)
99
100
 
101
+ // keep reference to the previous focus for storing in cache
102
+ previousFocus = Focus.get()
103
+
104
+ // set focus to the view that we're routing to
105
+ focus ? Focus.set(focus) : Focus.set(view)
106
+
100
107
  // apply before settings to holder element
101
108
  if (route.transition.before) {
102
109
  if (Array.isArray(route.transition.before)) {
@@ -143,8 +150,6 @@ export const navigate = async function () {
143
150
  Announcer.speak(route.announce.message, route.announce.politeness)
144
151
  }
145
152
 
146
- // focus the new view
147
- focus ? Focus.set(focus) : view.focus()
148
153
  this.activeView = this[symbols.children][this[symbols.children].length - 1]
149
154
  } else {
150
155
  Log.error(`Route ${hash} not found`)
@@ -172,7 +177,7 @@ const removeView = async (route, view, transition) => {
172
177
 
173
178
  // cache the page when it's as 'keepAlive' instead of destroying
174
179
  if (route.options && route.options.keepAlive === true) {
175
- cacheMap.set(route, { view: view, focus: Focus.get() })
180
+ cacheMap.set(route, { view: view, focus: previousFocus })
176
181
  } else {
177
182
  // remove and cleanup
178
183
  for (let i = 0; i < view[symbols.children].length - 1; i++) {
package/vite/index.js CHANGED
@@ -1,3 +1,20 @@
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
+
1
18
  import preCompiler from './preCompiler.js'
2
19
  import { importChunkUrl } from '@lightningjs/vite-plugin-import-chunk-url'
3
20
 
@@ -1,6 +1,21 @@
1
- import parser from '../src/lib/templateparser/parser.js'
2
- import generator from '../src/lib/codegenerator/generator.js'
3
- import path from 'path'
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 compiler from '../src/lib/precompiler/precompiler.js'
4
19
 
5
20
  export default function () {
6
21
  let config
@@ -11,42 +26,7 @@ export default function () {
11
26
  },
12
27
  transform(source, filePath) {
13
28
  if (config.blits && config.blits.precompile === false) return source
14
- if (source.indexOf('Blits.Component(') > -1 || source.indexOf('Blits.Application(') > -1) {
15
- // get the start of the template key in de component configuration object
16
- const templateKeyRegex = /template:\s*([`"'])*/g
17
- const templateStartResult = templateKeyRegex.exec(source)
18
- const typeOfQuotesUsed = templateStartResult[1]
19
- const templateStartIndex = templateStartResult.index
20
-
21
- // get the template contents from the configuration object
22
- const templateContentsRegex = new RegExp(
23
- `${typeOfQuotesUsed}([\\s\\S]*?)${typeOfQuotesUsed}`
24
- )
25
-
26
- const templateContentResult = templateContentsRegex.exec(source.slice(templateStartIndex))
27
- const templateEndIndex =
28
- templateStartIndex + templateContentResult.index + templateContentResult[0].length
29
-
30
- // Parse the template
31
- let resourceName = 'Blits.Application'
32
- if (source.indexOf('Blits.Component(') > -1) {
33
- resourceName = source.match(/Blits\.Component\(['"](.*)['"]\s*,/)[1]
34
- }
35
- const componentPath = path.relative(process.cwd(), filePath)
36
- const parsed = parser(templateContentResult[1], resourceName, null, componentPath)
37
-
38
- // Generate the code
39
- const code = generator.call({ components: {} }, parsed)
40
-
41
- // Insert the code in the component using the 'code' key, replacing the template key
42
- const replacement = `code: { render: ${code.render.toString()}, effects: [${code.effects.map(
43
- (fn) => fn.toString() + ','
44
- )}], context: {}}`
45
- const newSource =
46
- source.substring(0, templateStartIndex) + replacement + source.substring(templateEndIndex)
47
-
48
- return newSource
49
- }
29
+ return compiler(source, filePath)
50
30
  },
51
31
  }
52
32
  }
package/bin/index.cjs DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require('path')
4
- const fs = require('fs')
5
-
6
- const folder = process.argv.slice(2).pop()
7
-
8
- if (!folder) {
9
- console.error('Please specify a folder for your new Lightning 3 App')
10
- } else {
11
- if (fs.existsSync(folder)) {
12
- console.error(`The directory ${folder} already exists! Choose a different location.`)
13
- } else {
14
- fs.cpSync(path.join(__dirname, '..', 'boilerplate'), folder, { recursive: true })
15
- console.log(
16
- '================================== ⚡️⚡️⚡️⚡️ ================================== '
17
- )
18
- console.log('Your new boilerplate Lightning 3 App has been created!')
19
- console.log('')
20
- console.log(`Go to ${folder}, run npm install, followed by npm run dev to get started`)
21
- console.log(
22
- '================================== ⚡️⚡️⚡️⚡️ ================================== '
23
- )
24
- }
25
- }
@@ -1,10 +0,0 @@
1
- {
2
- "editor.formatOnSave": false,
3
- "eslint.validate": [
4
- "javascript"
5
- ],
6
- "editor.codeActionsOnSave": {
7
- "source.fixAll.eslint": true
8
- },
9
- "js/ts.implicitProjectConfig.checkJs": true
10
- }
File without changes
File without changes
File without changes