@lightningjs/blits 0.3.0

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 (79) hide show
  1. package/.editorconfig +7 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.cjs +60 -0
  4. package/.vscode/extensions.json +6 -0
  5. package/.vscode/settings.json +9 -0
  6. package/LICENSE +202 -0
  7. package/NOTICE +3 -0
  8. package/README.md +11 -0
  9. package/bin/index.cjs +25 -0
  10. package/boilerplate/.editorconfig +7 -0
  11. package/boilerplate/.eslintignore +3 -0
  12. package/boilerplate/.eslintrc.js +38 -0
  13. package/boilerplate/.vscode/extensions.json +7 -0
  14. package/boilerplate/.vscode/launch.json +12 -0
  15. package/boilerplate/.vscode/settings.json +9 -0
  16. package/boilerplate/index.html +11 -0
  17. package/boilerplate/package.json +36 -0
  18. package/boilerplate/public/assets/logo.png +0 -0
  19. package/boilerplate/src/App.js +12 -0
  20. package/boilerplate/src/components/Loader.js +23 -0
  21. package/boilerplate/src/index.js +11 -0
  22. package/boilerplate/src/pages/Home.js +15 -0
  23. package/boilerplate/src/renderer.js +3 -0
  24. package/boilerplate/vite.config.js +23 -0
  25. package/docs/.nojekyll +0 -0
  26. package/docs/README.md +30 -0
  27. package/docs/_sidebar.md +9 -0
  28. package/docs/component_state.md +21 -0
  29. package/docs/components.md +27 -0
  30. package/docs/computed_properties.md +18 -0
  31. package/docs/getting_started.md +40 -0
  32. package/docs/index.html +47 -0
  33. package/docs/lifecycle_events.md +46 -0
  34. package/docs/props.md +44 -0
  35. package/docs/template_syntax.md +31 -0
  36. package/docs/user_input.md +64 -0
  37. package/docs/watchers.md +38 -0
  38. package/index.js +26 -0
  39. package/package.json +44 -0
  40. package/src/application.js +55 -0
  41. package/src/component.js +192 -0
  42. package/src/component.test.js +51 -0
  43. package/src/components/Circle.js +31 -0
  44. package/src/components/Image.js +33 -0
  45. package/src/components/RouterView.js +38 -0
  46. package/src/components/Sprite.js +56 -0
  47. package/src/components/Text.js +61 -0
  48. package/src/element.js +236 -0
  49. package/src/focus.js +65 -0
  50. package/src/helpers/sequence.js +26 -0
  51. package/src/launch.js +61 -0
  52. package/src/lib/codegenerator/generator.js +276 -0
  53. package/src/lib/codegenerator/generator.test.js +970 -0
  54. package/src/lib/colors/colors.js +70 -0
  55. package/src/lib/colors/colors.test.js +190 -0
  56. package/src/lib/colors/htmlColors.js +168 -0
  57. package/src/lib/componentId.js +27 -0
  58. package/src/lib/componentId.test.js +83 -0
  59. package/src/lib/eventListeners.js +55 -0
  60. package/src/lib/hooks.js +29 -0
  61. package/src/lib/log.js +106 -0
  62. package/src/lib/reactivity/effect.js +54 -0
  63. package/src/lib/reactivity/effect.test.js +35 -0
  64. package/src/lib/reactivity/reactive.js +113 -0
  65. package/src/lib/reactivity/reactive.test.js +27 -0
  66. package/src/lib/setup/base.js +218 -0
  67. package/src/lib/setup/computed.js +43 -0
  68. package/src/lib/setup/input.js +28 -0
  69. package/src/lib/setup/methods.js +35 -0
  70. package/src/lib/setup/props.js +53 -0
  71. package/src/lib/setup/props.test.js +205 -0
  72. package/src/lib/setup/routes.js +24 -0
  73. package/src/lib/setup/state.js +45 -0
  74. package/src/lib/setup/watch.js +33 -0
  75. package/src/lib/templateparser/parser.js +103 -0
  76. package/src/lib/templateparser/parser.test.js +769 -0
  77. package/src/router.js +67 -0
  78. package/src/settings.js +34 -0
  79. package/vite/index.js +1 -0
package/src/router.js ADDED
@@ -0,0 +1,67 @@
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 { Log } from './lib/log.js'
19
+
20
+ export const getHash = () => {
21
+ return (document.location.hash || '/').replace(/^#/, '')
22
+ }
23
+
24
+ export const matchHash = (path, routes = []) => {
25
+ const route = routes
26
+ .filter((r) => {
27
+ return r.path === path
28
+ })
29
+ .pop()
30
+ return route
31
+ }
32
+
33
+ export const navigate = function () {
34
+ if (this.parent.___routes) {
35
+ const hash = getHash()
36
+ const route = matchHash(hash, this.parent.___routes)
37
+ if (route) {
38
+ if (this.__currentView) {
39
+ for (let i = 0; i < this.__currentView.___children.length - 1; i++) {
40
+ if (this.__currentView.___children[i] && this.__currentView.___children[i].destroy) {
41
+ this.__currentView.___children[i].destroy()
42
+ this.__currentView.___children[i] = null
43
+ }
44
+ }
45
+ this.__currentView.destroy()
46
+ this.__currentView = null
47
+ }
48
+ this.___children[1] = this.__currentView = route.component(
49
+ this.___props,
50
+ this.___children[0],
51
+ this
52
+ )
53
+ this.__currentView.focus()
54
+ } else {
55
+ Log.error(`Route ${hash} not found`)
56
+ }
57
+ }
58
+ }
59
+
60
+ export const to = (location) => {
61
+ window.location.hash = `#${location}`
62
+ }
63
+
64
+ export default {
65
+ navigate,
66
+ to,
67
+ }
@@ -0,0 +1,34 @@
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
+ const settings = {
19
+ ___settings: {},
20
+ get(key, defaultValue = null) {
21
+ return (key in this.___settings && this.___settings[key]) || defaultValue
22
+ },
23
+ set(key, value) {
24
+ if (typeof key === 'object') {
25
+ Object.keys(key).forEach((k) => {
26
+ this.set(k, key[k])
27
+ })
28
+ } else {
29
+ this.___settings[key] = value
30
+ }
31
+ },
32
+ }
33
+
34
+ export default settings
package/vite/index.js ADDED
@@ -0,0 +1 @@
1
+ export { importChunkUrl as importChunkUrl } from '@lightningjs/vite-plugin-import-chunk-url'