@lightningjs/blits 0.9.7 → 0.9.9

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 +21 -0
  2. package/docs/_sidebar.md +1 -0
  3. package/docs/built-in/directives.md +11 -3
  4. package/docs/built-in/for-loop.md +172 -0
  5. package/docs/components/component_state.md +1 -2
  6. package/docs/components/computed_properties.md +3 -4
  7. package/docs/components/methods.md +3 -3
  8. package/docs/components/props.md +1 -1
  9. package/docs/components/user_input.md +2 -2
  10. package/docs/components/watchers.md +1 -1
  11. package/docs/essentials/application_root.md +1 -1
  12. package/docs/essentials/components.md +3 -3
  13. package/docs/essentials/displaying_images.md +2 -2
  14. package/docs/essentials/displaying_text.md +12 -12
  15. package/docs/essentials/element_attributes.md +19 -13
  16. package/docs/essentials/template_syntax.md +8 -8
  17. package/docs/getting_started/file_structure.md +10 -11
  18. package/docs/getting_started/intro.md +3 -3
  19. package/docs/plugins/text-to-speech-announcer.md +2 -2
  20. package/docs/sidebar.json +4 -0
  21. package/docs/transitions_animations/transitions.md +12 -12
  22. package/package.json +2 -2
  23. package/src/application.d.ts +10 -10
  24. package/src/component/base/announcer.js +27 -0
  25. package/src/component/base/events.js +37 -0
  26. package/src/component/base/index.js +29 -0
  27. package/src/component/base/log.js +27 -0
  28. package/src/component/base/methods.js +136 -0
  29. package/src/component/base/router.js +40 -0
  30. package/src/component/base/timeouts_intervals.js +92 -0
  31. package/src/component/base/utils.js +29 -0
  32. package/src/{lib → component}/setup/computed.js +3 -3
  33. package/src/component/setup/index.js +61 -0
  34. package/src/{lib → component}/setup/input.js +4 -4
  35. package/src/{lib → component}/setup/methods.js +3 -3
  36. package/src/{lib → component}/setup/props.js +3 -3
  37. package/src/{lib → component}/setup/routes.js +3 -3
  38. package/src/{lib → component}/setup/state.js +13 -6
  39. package/src/{lib → component}/setup/watch.js +5 -5
  40. package/src/component.d.ts +157 -38
  41. package/src/component.js +145 -154
  42. package/src/components/Circle.js +5 -5
  43. package/src/components/FPScounter.js +57 -89
  44. package/src/components/Image.js +2 -2
  45. package/src/components/RouterView.js +1 -1
  46. package/src/components/Sprite.js +5 -5
  47. package/src/components/Sprite.orig.js +2 -2
  48. package/src/components/Text.js +11 -11
  49. package/src/components/index.js +32 -0
  50. package/src/components/index.orig.js +32 -0
  51. package/src/engines/L3/element.js +44 -35
  52. package/src/engines/L3/launch.js +2 -1
  53. package/src/launch.d.ts +11 -1
  54. package/src/lib/codegenerator/generator.js +7 -6
  55. package/src/router/router.js +0 -7
  56. package/src/lib/setup/base.js +0 -284
  57. /package/src/{lib → component}/setup/props.test.js +0 -0
@@ -8,23 +8,23 @@ Let's review the basic file structure, and take a closer look at the important o
8
8
 
9
9
  ### package.json
10
10
 
11
- In the root of your newly created app you will obviously find a `package.json` with all the necessary (dev) dependencies.
11
+ In the root of your newly created app, you will obviously find a `package.json` with all the necessary (dev) dependencies.
12
12
 
13
13
  In order to build a Blits based Lightning 3 app, all you need is `@lightningjs/blits` as a dependency. Blits will take care of hooking up the Lightning 3 renderer for you behind the scenes.
14
14
 
15
- Feel free to install and import any custom library that your App may need. But always be mindful of the size and impact an external dependency may have - especially when developing for low powered devices (as if often the case with Lightning apps).
15
+ Feel free to install and import any custom library that your App may need. But always be mindful of the size and impact an external dependency may have - especially when developing for low powered devices (as is often the case with Lightning apps).
16
16
 
17
17
  ### index.html
18
18
 
19
- You will also find an `index.html` in the root of your project. This is where the browser will be pointed to in order to launch your Blits App.
19
+ You will also find an `index.html` at the root of your project. This is where the browser will be pointed to, in order to launch your Blits App.
20
20
 
21
- If you inspect the source you will see some minimal html. The essential parts of the html are the `<div>` where the canvas will be injected into, and the `<script>`-tag that points to the `index.js` of the App.
21
+ If you inspect the source you will see some minimal HTML. The essential parts of the HTML are the `<div>` where the canvas will be injected into, and the `<script>`-tag that points to the `index.js` of the App.
22
22
 
23
23
  ### public
24
24
 
25
- There is also a `public` folder in your project. This folder is used for storing the public assets, such as App images and fonts.
25
+ There is also a `public` folder in your project. This folder is used for storing public assets, such as App images and fonts.
26
26
 
27
- During development your assets are loaded directly from this folder. And if you run a production build, the entire `public` folder is copied over to the distributable version.
27
+ During development, your assets are loaded directly from this folder. And if you run a production build, the entire `public` folder is copied over to the distributable version.
28
28
 
29
29
  ### src
30
30
 
@@ -37,7 +37,7 @@ The `src`-folder is where all your custom App code lives.
37
37
  The `Blits.Launch()`-method accepts 3 parameters:
38
38
 
39
39
  1) `app` - the root application component
40
- 2) `target` - the html target to append the canvas to. This can either by an `id` of an html element in `index.html`, or you can pass a reference the html element itself
40
+ 2) `target` - the HTML target to append the canvas to. This can either be an `id` of an HTML element in `index.html`, or you can pass a reference to HTML element itself
41
41
  3) `settings` - an `object` with settings
42
42
 
43
43
  #### App.js
@@ -46,16 +46,15 @@ The `Blits.Launch()`-method accepts 3 parameters:
46
46
 
47
47
  ### components and pages folder
48
48
 
49
- The rest of you App can be built out using components. You are free to organize your components as you wish, but we recommend
50
- to use a separate file for each component, and place them in the `src/components`-folder.
49
+ The rest of your App can be built out using components. You are free to organize your components as you wish, but we recommend using a separate file for each component and placing them in the `src/components`-folder.
51
50
 
52
51
  The convention is to start the component file name with a capital letter, matching the name of the component (e.g. `src/components/Loader.js` or `src/components/MenuItem.js`).
53
52
 
54
53
  Feel free to further organize and possibly nest your Component files to your own preferences.
55
54
 
56
- Pages in your App are technically just Blits components as well. But to keep thing clear, we often place them in a separate `pages`-folder alongside the `components`-folder (e.g. `src/pages/Home.js` and `src/pages/Details.js`)
55
+ Pages in your App are technically just Blits components as well. But to keep things clear, we often place them in a separate `pages`-folder alongside the `components`-folder (e.g. `src/pages/Home.js` and `src/pages/Details.js`)
57
56
 
58
57
  #### Custom code
59
58
 
60
- If your App needs libraries for specific (business) logic that can be shared accross components (such as API calls) you can place them anywhere in your `src` folder. For example in a folder named `src/lib` or `src/api`.
59
+ If your App needs libraries for specific (business) logic that can be shared across components (such as API calls) you can place them anywhere in your `src` folder. For example in a folder named `src/lib` or `src/api`.
61
60
 
@@ -10,11 +10,11 @@ The Blits framework uses a **readable** XML-style template syntax and comes with
10
10
 
11
11
  ## Why Blits?
12
12
 
13
- You may be wondering where the name Blits comes from?
13
+ You may be wondering where the name Blits comes from.
14
14
 
15
15
  Firstly, it's short, memorable and just has a nice ring to it.
16
16
 
17
- "Blits" is a Dutch word (a significant portion of the Lightning Open Source teams is based in the Netherlands). It means _flashy_ and it's often used to for things that are _great_ or _cool_.
17
+ "Blits" is a Dutch word (a significant portion of the Lightning Open Source teams is based in the Netherlands). It means _flashy_ and it's often used for things that are _great_ or _cool_.
18
18
 
19
- Finally it's a nerdy reference to the computer term "Bit Blits" commonly used in graphics processing, for rapidly moving a block of data into memory - quite similar to what Lightning is doing 🙂
19
+ Finally, it's a nerdy reference to the computer term "Bit Blits" commonly used in graphics processing, for rapidly moving a block of data into memory - quite similar to what Lightning is doing 🙂
20
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Text-to-Speech / Announcer
4
4
 
5
- Blits comes with a built-in Text-to-Speech / Announcer functionality, to easily make your App more accessible. This is something that's often overlooked when developing an App, but having speech assistance integrated into your App is a huge deal for those users that are visually impaired.
5
+ Blits comes with a built-in Text-to-Speech / Announcer functionality, to easily make your App more accessible. This is something that's often overlooked when developing an App, but having speech assistance integrated into your App is a huge deal for those users who are visually impaired.
6
6
 
7
7
  ### Integrated with the router
8
8
 
@@ -24,7 +24,7 @@ const routes = [
24
24
 
25
25
  ## Custom announcement messages
26
26
 
27
- Furthermore it's possible to speak out custom messages anywhere in your App logic, for example when a component receives focus, as a reaction to user input, or to announce error messages when an remote API call
27
+ Furthermore, it's possible to speak out custom messages anywhere in your App logic, for example when a component receives focus, as a reaction to user input, or to announce error messages when a remote API call
28
28
  fails.
29
29
 
30
30
  Each component in Blits has a `this.$announcer.speak()` available, which accepts `string` of a message to be announced.
package/docs/sidebar.json CHANGED
@@ -93,6 +93,10 @@
93
93
  {
94
94
  "text": "Directives",
95
95
  "link": "/built-in/directives"
96
+ },
97
+ {
98
+ "text": "For loop",
99
+ "link": "/built-in/for-loop"
96
100
  }
97
101
  ]
98
102
  },
@@ -10,7 +10,7 @@ We did learn how to _reactively_ changes values and trigger rerenders based on t
10
10
  ```js
11
11
  export default Blits('Gold', {
12
12
  template: `
13
- <Element color="gold" w="100" h="100" :x="$x" :y=:"$y" />
13
+ <Element color="gold" w="100" h="100" :x="$x" :y="$y" />
14
14
  `,
15
15
  state() {
16
16
  return {
@@ -35,7 +35,7 @@ Blits offers an easy and intuitive way to apply transitions. All you need to do
35
35
  ```js
36
36
  export default Blits('Gold', {
37
37
  template: `
38
- <Element color="gold" w="100" h="100" :x.transiton="$x" :y.transition=:"$y" />
38
+ <Element color="gold" w="100" h="100" :x.transition="$x" :y.transition="$y" />
39
39
  `,
40
40
  state() {
41
41
  return {
@@ -51,7 +51,7 @@ export default Blits('Gold', {
51
51
  },
52
52
  ```
53
53
 
54
- If we try out the modified example above, you'll notice how difference adding a simple transition makes.
54
+ If we try out the modified example above, you'll notice how much difference adding a simple transition makes.
55
55
 
56
56
  When the `.transition`-modifier is added to a reactive attribute, a default `ease-in` transition with a duration of `300ms` is applied
57
57
 
@@ -61,20 +61,20 @@ While the default transition will look pretty good out of the box and is great f
61
61
 
62
62
  Blits gives you full control over your transitions, with a simple to use format, right inside your template.
63
63
 
64
- Instead of referencing your component's state variable directly, you can also supply an inlien `object literal` in the attribute with a `.transition`-modifier. This will allow you to pass a number of options to change the way the transition will work.
64
+ Instead of referencing your component's state variable directly, you can also supply an inline `object literal`` in the attribute with a `.transition`-modifier. This will allow you to pass a number of options to change the way the transition will work.
65
65
 
66
66
  The transition object must have a `value` key, which references the state variable (or prop or computed property) that triggers the transition.
67
67
 
68
- Further more you can specify:
68
+ Furthermore, you can specify:
69
69
 
70
70
  - `duration` - the duration of the transition in `ms`
71
71
  - `delay` - the time in `ms` after which the transition should initiate
72
- - `easing` - the easing function of the transition. Can be one of the defaults easing options listed below, or a custom `cubic-bezier` definitions (i.e. `cubic-bezier(0,1.35,.99,-0.07)`).
72
+ - `easing` - the easing function of the transition. Can be one of the default easing options listed below, or a custom `cubic-bezier` definition (i.e. `cubic-bezier(0,1.35,.99,-0.07)`).
73
73
 
74
74
  ```xml
75
75
  <Element color="gold" w="100" h="100"
76
- :x.transiton="{value: $x, duration: 300, easing: 'ease-in-back', delay: 400}"
77
- :y.transition=:"{value: $x, duration: 300, easing: 'cubic-bezier(1,-0.64,0.39,1.44)'}">
76
+ :x.transition="{value: $x, duration: 300, easing: 'ease-in-back', delay: 400}"
77
+ :y.transition="{value: $x, duration: 300, easing: 'cubic-bezier(1,-0.64,0.39,1.44)'}">
78
78
  </Element>
79
79
  ```
80
80
 
@@ -82,7 +82,7 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
82
82
 
83
83
  ```xml
84
84
  <Element color="gold" w="100" h="100"
85
- :x.transiton="{value: $x, duration: $dynamicDuration, delay: $dynamicDelay}">
85
+ :x.transition="{value: $x, duration: $dynamicDuration, delay: $dynamicDelay}">
86
86
  </Element>
87
87
  ```
88
88
 
@@ -108,15 +108,15 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
108
108
 
109
109
  Sometimes you may want to perform an action when a transition ends or when it starts.
110
110
 
111
- You can easily hook into these transiti)on events by adding a `start` and `end` key to the transition object. Both value should be a function (or a reference to a `method` on your component).
111
+ You can easily hook into these transition events by adding a `start` and `end` key to the transition object. Both values should be a function (or a reference to a `method` on your component).
112
112
 
113
- The `start` function will be called when the transition actually starts (after a possible specified delay) and the `end` function is called as soon as the transitions is finished.
113
+ The `start` function will be called when the transition actually starts (after a possible specified delay) and the `end` function is called as soon as the transition is finished.
114
114
 
115
115
  ```js
116
116
  export default Blits('Gold', {
117
117
  template: `
118
118
  <Element color="gold" w="100" h="100"
119
- :x.transiton="{value: $x, start: $transitionBegin, end: $transitionEnd}"
119
+ :x.transition="{value: $x, start: $transitionBegin, end: $transitionEnd}"
120
120
  />
121
121
  `,
122
122
  ///
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -45,7 +45,7 @@
45
45
  "tape": "^5.5.0"
46
46
  },
47
47
  "dependencies": {
48
- "@lightningjs/renderer": "^0.8.2",
48
+ "@lightningjs/renderer": "^0.8.4",
49
49
  "@lightningjs/vite-plugin-import-chunk-url": "^0.3.0",
50
50
  "execa": "^8.0.1",
51
51
  "kolorist": "^1.8.0",
@@ -16,7 +16,7 @@
16
16
  * SPDX-License-Identifier: Apache-2.0
17
17
  */
18
18
 
19
- import {default as Component, ComponentInstance} from './component'
19
+ import {default as Component} from './component'
20
20
 
21
21
  declare namespace Application {
22
22
 
@@ -84,10 +84,6 @@ declare namespace Application {
84
84
  politeness?: 'off' | 'polite' | 'assertive'
85
85
  }
86
86
 
87
- function Application(
88
- config: Application.ApplicationConfig
89
- ) : Application.ApplicationInstance
90
-
91
87
  type RequireAtLeastOne<T> = {
92
88
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
93
89
  }[keyof T]
@@ -104,7 +100,7 @@ declare namespace Application {
104
100
  /**
105
101
  * Component to load when activating the route
106
102
  */
107
- component: typeof ComponentInstance,
103
+ component: Component,
108
104
  /**
109
105
  * Transition configuration for the route
110
106
  */
@@ -142,9 +138,9 @@ declare namespace Application {
142
138
  }
143
139
  }
144
140
 
145
- export interface ApplicationInstance extends ComponentInstance {}
141
+ export interface ApplicationInstance extends Component.ComponentInstance {}
146
142
 
147
- export interface ApplicationConfig extends Component.ComponentConfig {
143
+ export interface ApplicationConfig<Props extends string, S, M> extends Component.ComponentConfig<Props, S, M> {
148
144
  /**
149
145
  * Routes definition
150
146
  *
@@ -167,8 +163,12 @@ declare namespace Application {
167
163
  *
168
164
  * Root App component
169
165
  */
170
- declare function Application(
171
- config: Application.ApplicationConfig
166
+ declare function Application<
167
+ Props extends string,
168
+ S extends Component.State,
169
+ M extends Component.Methods
170
+ >(
171
+ config: Application.ApplicationConfig<Props, S, M>
172
172
  ) : Application.ApplicationInstance
173
173
 
174
174
  export default Application;
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright 2024 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 Announcer from '../../announcer/announcer.js'
19
+
20
+ export default {
21
+ $announcer: {
22
+ value: Announcer,
23
+ writable: false,
24
+ enumerable: true,
25
+ configurable: false,
26
+ },
27
+ }
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright 2024 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 eventListeners from '../../lib/eventListeners'
19
+
20
+ export default {
21
+ $emit: {
22
+ value: function (event, params) {
23
+ eventListeners.executeListeners(event, params)
24
+ },
25
+ writable: false,
26
+ enumerable: true,
27
+ configurable: false,
28
+ },
29
+ $listen: {
30
+ value: function (event, callback) {
31
+ eventListeners.registerListener(this, event, callback)
32
+ },
33
+ writable: false,
34
+ enumerable: true,
35
+ configurable: false,
36
+ },
37
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright 2024 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 methods from './methods.js'
19
+ import scheduling from './timeouts_intervals.js'
20
+ import events from './events.js'
21
+ import log from './log.js'
22
+ import router from './router.js'
23
+ import announcer from './announcer.js'
24
+ import utils from './utils.js'
25
+
26
+ export default Object.defineProperties(
27
+ {},
28
+ { ...methods, ...scheduling, ...events, ...log, ...router, ...announcer, ...utils }
29
+ )
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright 2024 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 default {
21
+ $log: {
22
+ value: log('App'),
23
+ writable: false,
24
+ enumerable: false,
25
+ configurable: false,
26
+ },
27
+ }
@@ -0,0 +1,136 @@
1
+ /*
2
+ * Copyright 2024 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 symbols from '../../lib/symbols.js'
19
+ import Focus from '../../focus.js'
20
+ import eventListeners from '../../lib/eventListeners.js'
21
+ import { trigger } from '../../lib/reactivity/effect.js'
22
+ import { Log } from '../../lib/log.js'
23
+
24
+ export default {
25
+ focus: {
26
+ value: function (e) {
27
+ this[symbols.state].hasFocus = true
28
+ Focus.set(this, e)
29
+ },
30
+ writable: false,
31
+ enumerable: true,
32
+ configurable: false,
33
+ },
34
+ unfocus: {
35
+ value: function () {
36
+ this[symbols.state].hasFocus = false
37
+ this.lifecycle.state = 'unfocus'
38
+ },
39
+ writable: false,
40
+ enumerable: true,
41
+ configurable: false,
42
+ },
43
+ destroy: {
44
+ value: function () {
45
+ this.lifecycle.state = 'destroy'
46
+ this.$clearTimeouts()
47
+ this.$clearIntervals()
48
+ eventListeners.removeListeners(this)
49
+ deleteChildren(this[symbols.children])
50
+ Log.debug(`Destroyed component ${this.componentId}`)
51
+ },
52
+ writable: false,
53
+ enumerable: true,
54
+ configurable: false,
55
+ },
56
+ select: {
57
+ value: function (ref) {
58
+ let selected = null
59
+ this[symbols.children].forEach((child) => {
60
+ if (Array.isArray(child)) {
61
+ child.forEach((c) => {
62
+ if (c['ref'] === ref) selected = c
63
+ })
64
+ } else if (Object.getPrototypeOf(child) === Object.prototype) {
65
+ Object.keys(child).forEach((k) => {
66
+ if (child[k]['ref'] === ref) selected = child[k]
67
+ })
68
+ } else {
69
+ if (child['ref'] === ref) selected = child
70
+ }
71
+ })
72
+ return selected
73
+ },
74
+ writable: false,
75
+ enumerable: true,
76
+ configurable: false,
77
+ },
78
+ trigger: {
79
+ value: function (key) {
80
+ // trigger with force set to true
81
+ trigger(this[symbols.originalState], key, true)
82
+ },
83
+ writable: false,
84
+ enumerable: true,
85
+ configurable: false,
86
+ },
87
+ $trigger: {
88
+ value: function (key) {
89
+ Log.warn('this.$trigger is deprecated, use this.trigger instead')
90
+ return this.trigger(key)
91
+ },
92
+ writable: false,
93
+ enumerable: true,
94
+ configurable: false,
95
+ },
96
+ shader: {
97
+ value: function (type, args) {
98
+ const target = type
99
+ return {
100
+ type: target,
101
+ props: args,
102
+ }
103
+ // const shaders = renderer.driver.stage.shManager.getRegisteredEffects()
104
+
105
+ // if (target in shaders) {
106
+ // return {
107
+ // type: target,
108
+ // props: args,
109
+ // }
110
+ // } else {
111
+ // Log.error(`Shader ${type} not found`)
112
+ // }
113
+ },
114
+ writable: false,
115
+ enumerable: true,
116
+ configurable: false,
117
+ },
118
+ }
119
+
120
+ const deleteChildren = function (children) {
121
+ for (let i = 0; i < children.length; i++) {
122
+ if (!children[i]) return
123
+ // call destroy when method is available on child
124
+ if (children[i].destroy && typeof children[i].destroy === 'function') {
125
+ children[i].destroy()
126
+ }
127
+ // recursively call deleteChildren when it's an object of items (happens when using a forloop construct)
128
+ else if (Object.getPrototypeOf(children[i]) === Object.prototype) {
129
+ deleteChildren(Object.values(children[i]))
130
+ }
131
+
132
+ children[i] = null
133
+ }
134
+
135
+ children.length = 0
136
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2024 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 symbols from '../../lib/symbols.js'
19
+ import { to, currentRoute, navigating, back } from '../../router/router.js'
20
+
21
+ export default {
22
+ $router: {
23
+ value: {
24
+ to,
25
+ back,
26
+ get currentRoute() {
27
+ return currentRoute
28
+ },
29
+ get routes() {
30
+ return this[symbols.routes]
31
+ },
32
+ get navigating() {
33
+ return navigating
34
+ },
35
+ },
36
+ writable: false,
37
+ enumerable: true,
38
+ configurable: false,
39
+ },
40
+ }
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright 2024 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 symbols from '../../lib/symbols.js'
19
+
20
+ export default {
21
+ $setTimeout: {
22
+ value: function (fn, ms, ...params) {
23
+ const timeoutId = setTimeout(
24
+ () => {
25
+ this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
26
+ fn.apply(null, params)
27
+ },
28
+ ms,
29
+ params
30
+ )
31
+ this[symbols.timeouts].push(timeoutId)
32
+ return timeoutId
33
+ },
34
+ writable: false,
35
+ enumerable: true,
36
+ configurable: false,
37
+ },
38
+ $clearTimeout: {
39
+ value: function (timeoutId) {
40
+ if (this[symbols.timeouts].indexOf(timeoutId) > -1) {
41
+ this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
42
+ clearTimeout(timeoutId)
43
+ }
44
+ },
45
+ writable: false,
46
+ enumerable: true,
47
+ configurable: false,
48
+ },
49
+ $clearTimeouts: {
50
+ value: function () {
51
+ for (let i = 0; i < this[symbols.timeouts].length; i++) {
52
+ clearTimeout(this[symbols.timeouts][i])
53
+ }
54
+ this[symbols.timeouts] = []
55
+ },
56
+ writable: false,
57
+ enumerable: true,
58
+ configurable: false,
59
+ },
60
+ $setInterval: {
61
+ value: function (fn, ms, ...params) {
62
+ const intervalId = setInterval(() => fn.apply(null, params), ms, params)
63
+ this[symbols.intervals].push(intervalId)
64
+ return intervalId
65
+ },
66
+ writable: false,
67
+ enumerable: true,
68
+ configurable: false,
69
+ },
70
+ $clearInterval: {
71
+ value: function (intervalId) {
72
+ if (this[symbols.intervals].indexOf(intervalId) > -1) {
73
+ this[symbols.intervals] = this[symbols.intervals].filter((id) => id !== intervalId)
74
+ clearInterval(intervalId)
75
+ }
76
+ },
77
+ writable: false,
78
+ enumerable: true,
79
+ configurable: false,
80
+ },
81
+ $clearIntervals: {
82
+ value: function () {
83
+ for (let i = 0; i < this[symbols.intervals].length; i++) {
84
+ clearInterval(this[symbols.intervals][i])
85
+ }
86
+ this[symbols.intervals] = []
87
+ },
88
+ writable: false,
89
+ enumerable: true,
90
+ configurable: false,
91
+ },
92
+ }