@lightningjs/blits 1.30.2 → 1.31.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 (152) hide show
  1. package/CHANGELOG.md +1029 -1019
  2. package/LICENSE +202 -202
  3. package/NOTICE +12 -12
  4. package/README.md +33 -33
  5. package/bin/index.js +8 -8
  6. package/blits.d.ts +6 -6
  7. package/index.d.ts +1099 -1099
  8. package/index.js +28 -28
  9. package/package.json +57 -56
  10. package/public/assets/fps_sprite.base64.js +1 -1
  11. package/scripts/postpublish.js +59 -59
  12. package/scripts/prepublishOnly.js +84 -84
  13. package/scripts/prepush.js +78 -78
  14. package/src/announcer/announcer.js +162 -162
  15. package/src/announcer/speechSynthesis.js +107 -107
  16. package/src/application.js +100 -100
  17. package/src/component/base/announcer.js +27 -27
  18. package/src/component/base/events.js +69 -69
  19. package/src/component/base/index.js +33 -33
  20. package/src/component/base/methods.js +244 -244
  21. package/src/component/base/router.js +41 -41
  22. package/src/component/base/timeouts_intervals.js +99 -99
  23. package/src/component/base/utils.js +72 -72
  24. package/src/component/setup/computed.js +48 -48
  25. package/src/component/setup/index.js +62 -62
  26. package/src/component/setup/input.js +30 -30
  27. package/src/component/setup/methods.js +37 -37
  28. package/src/component/setup/props.js +62 -62
  29. package/src/component/setup/routes.js +42 -42
  30. package/src/component/setup/state.js +59 -59
  31. package/src/component/setup/watch.js +35 -35
  32. package/src/component.js +437 -437
  33. package/src/components/Circle.js +73 -73
  34. package/src/components/FPScounter.js +1510 -1510
  35. package/src/components/RouterView.js +81 -81
  36. package/src/components/Sprite.js +94 -94
  37. package/src/components/index.js +28 -28
  38. package/src/constants.js +21 -21
  39. package/src/engine.js +1 -1
  40. package/src/engines/L3/element.js +744 -744
  41. package/src/engines/L3/fontLoader.js +38 -38
  42. package/src/engines/L3/index.js +7 -7
  43. package/src/engines/L3/launch.js +123 -123
  44. package/src/engines/L3/shaderLoader.js +12 -12
  45. package/src/engines/index.js +1 -1
  46. package/src/focus.js +90 -90
  47. package/src/helpers/deepEqualArray.js +50 -50
  48. package/src/helpers/fetchJson.js +34 -34
  49. package/src/helpers/sequence.js +26 -26
  50. package/src/launch.js +123 -123
  51. package/src/lib/blitsfileconverter/blitsfileconverter.js +52 -52
  52. package/src/lib/codegenerator/generator.js +788 -788
  53. package/src/lib/colors/colors.js +92 -92
  54. package/src/lib/colors/htmlColors.js +168 -168
  55. package/src/lib/componentId.js +49 -49
  56. package/src/lib/eventListeners.js +123 -123
  57. package/src/lib/hooks.js +59 -59
  58. package/src/lib/lifecycle.js +85 -85
  59. package/src/lib/log.js +117 -117
  60. package/src/lib/precompiler/precompiler.js +73 -73
  61. package/src/lib/reactivity/effect.js +93 -93
  62. package/src/lib/reactivity/reactive.js +208 -208
  63. package/src/lib/reactivityguard/computedprops.js +218 -218
  64. package/src/lib/symbols.js +108 -108
  65. package/src/lib/templateparser/parser.js +386 -386
  66. package/src/lib/utils.js +27 -27
  67. package/src/plugin.js +27 -27
  68. package/src/plugins/appstate.js +26 -26
  69. package/src/plugins/index.js +20 -20
  70. package/src/plugins/language.js +152 -152
  71. package/src/plugins/log.js +25 -25
  72. package/src/plugins/theme.js +94 -94
  73. package/src/router/router.js +516 -514
  74. package/src/router/transitions/fadeIn.js +27 -27
  75. package/src/router/transitions/fadeInOut.js +33 -33
  76. package/src/router/transitions/index.js +21 -21
  77. package/src/router/transitions/slideIn.js +28 -28
  78. package/src/router/transitions/slideInOut.js +33 -33
  79. package/src/settings.js +40 -40
  80. package/vite/blitsFileConverter.js +67 -67
  81. package/vite/index.js +28 -28
  82. package/vite/msdfGenerator.js +269 -269
  83. package/vite/preCompiler.js +47 -42
  84. package/vite/reactivityGuard.js +45 -45
  85. package/vscode/data/template-attributes.json +589 -589
  86. package/.editorconfig +0 -7
  87. package/.eslintignore +0 -1
  88. package/.eslintrc.cjs +0 -65
  89. package/.github/workflows/comment-lint-results.yml +0 -125
  90. package/.github/workflows/comment-test-results.yml +0 -109
  91. package/.github/workflows/deploy-docs.yml +0 -27
  92. package/.github/workflows/run-blits-tests.yml +0 -142
  93. package/.github/workflows/run-lint.yml +0 -128
  94. package/.husky/pre-commit +0 -1
  95. package/.husky/pre-push +0 -1
  96. package/.vscode/extensions.json +0 -7
  97. package/.vscode/settings.json +0 -9
  98. package/COPYING +0 -1
  99. package/banner.png +0 -0
  100. package/docs/.nojekyll +0 -0
  101. package/docs/README.md +0 -19
  102. package/docs/_sidebar.md +0 -37
  103. package/docs/built-in/directives.md +0 -50
  104. package/docs/built-in/for-loop.md +0 -204
  105. package/docs/built-in/layout.md +0 -168
  106. package/docs/components/component_state.md +0 -90
  107. package/docs/components/computed_properties.md +0 -45
  108. package/docs/components/lifecycle_events.md +0 -42
  109. package/docs/components/methods.md +0 -45
  110. package/docs/components/props.md +0 -56
  111. package/docs/components/user_input.md +0 -186
  112. package/docs/components/utility_methods.md +0 -320
  113. package/docs/components/watchers.md +0 -34
  114. package/docs/essentials/application_root.md +0 -19
  115. package/docs/essentials/components.md +0 -68
  116. package/docs/essentials/displaying_images.md +0 -67
  117. package/docs/essentials/displaying_text.md +0 -135
  118. package/docs/essentials/element_attributes.md +0 -195
  119. package/docs/essentials/settings.md +0 -117
  120. package/docs/essentials/template_syntax.md +0 -83
  121. package/docs/getting_started/file_structure.md +0 -58
  122. package/docs/getting_started/getting_started.md +0 -45
  123. package/docs/getting_started/intro.md +0 -20
  124. package/docs/index.html +0 -47
  125. package/docs/performance/lazy-loading.md +0 -161
  126. package/docs/plugins/global_app_state.md +0 -98
  127. package/docs/plugins/language.md +0 -172
  128. package/docs/plugins/text-to-speech-announcer.md +0 -120
  129. package/docs/plugins/theme.md +0 -176
  130. package/docs/router/basics.md +0 -175
  131. package/docs/router/hooks.md +0 -70
  132. package/docs/router/transitions.md +0 -146
  133. package/docs/sidebar.json +0 -171
  134. package/docs/transitions_animations/transitions.md +0 -150
  135. package/jsconfig.json +0 -12
  136. package/src/component/setup/props.test.js +0 -238
  137. package/src/component.test.js +0 -388
  138. package/src/components/Circle.orig.js +0 -31
  139. package/src/components/FPScounter.orig.js +0 -121
  140. package/src/components/RouterView.orig.js +0 -54
  141. package/src/components/Sprite.orig.js +0 -58
  142. package/src/components/index.orig.js +0 -28
  143. package/src/engines/L3/element.test.js +0 -579
  144. package/src/helpers/deepEqualArray.test.js +0 -127
  145. package/src/lib/codegenerator/generator.test.js +0 -3801
  146. package/src/lib/colors/colors.test.js +0 -290
  147. package/src/lib/componentId.test.js +0 -84
  148. package/src/lib/eventListeners.test.js +0 -236
  149. package/src/lib/reactivity/effect.test.js +0 -35
  150. package/src/lib/reactivity/reactive.test.js +0 -27
  151. package/src/lib/templateparser/parser.test.js +0 -1411
  152. package/src/router/router.test.js +0 -473
@@ -1,388 +0,0 @@
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 test from 'tape'
19
- import Component from './component.js'
20
- import { initLog } from './lib/log.js'
21
- import symbols from './lib/symbols.js'
22
- import util from 'node:util'
23
- import { renderer, stage } from './launch.js'
24
-
25
- initLog()
26
-
27
- test('Type', (assert) => {
28
- const expected = 'function'
29
- const actual = typeof Component
30
-
31
- assert.equal(actual, expected, 'Component should be a function')
32
- assert.end()
33
- })
34
-
35
- test('Component - Factory function', (assert) => {
36
- const expected = 'function'
37
- const actual = typeof Component('my component', {})
38
-
39
- assert.equal(actual, expected, 'Component should be a factory function (i.e. return a function)')
40
- assert.end()
41
- })
42
-
43
- test('Component - Factory requires a name to be passed', (assert) => {
44
- assert.throws(() => {
45
- Component()
46
- }, 'Throw an error when no name argument has been passed')
47
-
48
- assert.end()
49
- })
50
-
51
- test('Component - Factory requires a config to be passed', (assert) => {
52
- assert.throws(() => {
53
- Component('Foo')
54
- }, 'Throw an error when no config argument has been passed')
55
-
56
- assert.end()
57
- })
58
-
59
- test('Component - Instance should create internal id', (assert) => {
60
- const button = Component('Button', {})()
61
- const heading = Component('Heading', {})()
62
-
63
- assert.equal(button[symbols.id], 1, 'Button instance object should have correct internal id')
64
- assert.equal(heading[symbols.id], 2, 'Heading instance object should have correct internal id')
65
- assert.end()
66
- })
67
-
68
- test('Component - Instance should create component Id', (assert) => {
69
- const foo = Component('Foo', {})
70
- const bar = Component('Bar', {})
71
- const fooInstance0 = foo()
72
- const fooInstance1 = foo()
73
- const barInstance0 = bar()
74
-
75
- assert.equal(
76
- fooInstance0.componentId,
77
- 'BlitsComponent::Foo_1',
78
- 'First Foo instance should have correct id'
79
- )
80
- assert.equal(
81
- fooInstance1.componentId,
82
- 'BlitsComponent::Foo_2',
83
- 'Second Foo instance should have correct id'
84
- )
85
- assert.equal(
86
- barInstance0.componentId,
87
- 'BlitsComponent::Bar_1',
88
- 'First Bar instance should have correct id'
89
- )
90
- assert.end()
91
- })
92
-
93
- test('Component - Instance should initiate lifecycle object', (assert) => {
94
- const foo = Component('Foo', {})()
95
-
96
- assert.ok(foo.lifecycle, 'Lifecycle object should be initialized')
97
- assert.equal(
98
- foo.lifecycle.component,
99
- foo,
100
- 'Lifecycle object should have a reference to foo instance'
101
- )
102
- assert.equal(
103
- foo.lifecycle.previous,
104
- null,
105
- 'Lifecycle object should have previous state not initialized'
106
- )
107
- assert.equal(foo.lifecycle.current, 'init', 'Lifecycle object should have initial current state')
108
- assert.end()
109
- })
110
-
111
- test('Component - Instance should set a parent reference', (assert) => {
112
- const parentElement = {}
113
- const parentComponent = {}
114
-
115
- const foo = Component('Foo', {})({}, parentElement, parentComponent)
116
-
117
- assert.equal(
118
- foo.parent,
119
- parentComponent,
120
- 'Foo instance object should have parent component object reference'
121
- )
122
- assert.equal(
123
- foo[symbols.holder],
124
- parentElement,
125
- 'Foo instance object should have parent element object reference'
126
- )
127
- assert.end()
128
- })
129
-
130
- test('Component - Instance should set a root reference', (assert) => {
131
- const root = {}
132
-
133
- const foo = Component('Foo', {})({}, {}, {}, root)
134
-
135
- assert.equal(
136
- foo.rootParent,
137
- root,
138
- 'Foo instance object should have root component object reference'
139
- )
140
- assert.end()
141
- })
142
-
143
- test('Component - Instance should initialize reactive props', (assert) => {
144
- const foo = Component(
145
- 'Foo',
146
- {}
147
- )({
148
- props: { foo: 'bar' },
149
- })
150
-
151
- const props = foo[symbols.props]
152
-
153
- assert.ok(props, 'Foo instance should have props defined')
154
- assert.ok(util.types.isProxy(props), 'Foo instance props should be proxy')
155
- assert.equal(props.foo, 'bar')
156
- assert.end()
157
- })
158
-
159
- test('Component - Instance should initialize timeouts array', (assert) => {
160
- const foo = Component('Foo', {})()
161
-
162
- const timeouts = foo[symbols.timeouts]
163
-
164
- assert.ok(Array.isArray(timeouts), 'Foo instance timeouts should be an array')
165
- assert.end()
166
- })
167
-
168
- test('Component - Instance should initialize intervals array', (assert) => {
169
- const foo = Component('Foo', {})()
170
-
171
- const intervals = foo[symbols.intervals]
172
-
173
- assert.ok(Array.isArray(intervals), 'Foo instance intervals should be an array')
174
- assert.end()
175
- })
176
-
177
- test('Component - Instance should initialize originalState', (assert) => {
178
- const config = {
179
- state() {
180
- return {
181
- foo: 'bar',
182
- }
183
- },
184
- }
185
- const foo = Component('Foo', config)()
186
-
187
- const state = foo[symbols.originalState]
188
-
189
- assert.equal(state.foo, 'bar', 'Foo instance should store originalState properties')
190
- assert.equal(state.hasFocus, false, 'Foo instance should store originalState hasFocus property')
191
- assert.end()
192
- })
193
-
194
- test('Component - Instance should initialize reactive state', (assert) => {
195
- const config = {
196
- state() {
197
- return {
198
- foo: 'bar',
199
- }
200
- },
201
- }
202
- const foo = Component('Foo', config)()
203
-
204
- const state = foo[symbols.state]
205
-
206
- assert.ok(state, 'Foo instance should have state defined')
207
- assert.ok(util.types.isProxy(state), 'Foo instance state should be proxy')
208
- assert.equal(state.foo, 'bar')
209
- assert.end()
210
- })
211
-
212
- test('Component - Instance should initialize children', (assert) => {
213
- const parent = {}
214
- const expected = []
215
- const config = {
216
- code: {
217
- render: () => {},
218
- effects: [],
219
- },
220
- state() {
221
- return {
222
- foo: 'bar',
223
- }
224
- },
225
- }
226
- const capture = assert.capture(config.code, 'render', () => expected)
227
- const foo = Component('Foo', config)({}, parent)
228
-
229
- const children = foo[symbols.children]
230
-
231
- assert.ok(Array.isArray(children), 'Foo instance children should be an array')
232
- assert.equal(children, expected, 'Children should be an expected array')
233
- const args = capture()[0].args
234
- assert.equal(args[0], parent, 'Render should be called with parent parameter')
235
- assert.equal(args[1], foo, 'Render should be called with Foo component instance')
236
- assert.equal(args[2], config, 'Render should be called with config parameter')
237
- assert.ok(args[3].Sprite, 'Render should be called with global components object')
238
- assert.end()
239
- })
240
-
241
- test('Component - Instance should initialize wrapper', (assert) => {
242
- const expected = {}
243
- const config = {
244
- code: {
245
- render: () => [expected],
246
- effects: [],
247
- },
248
- }
249
- const foo = Component('Foo', config)()
250
-
251
- const wrapper = foo[symbols.wrapper]
252
-
253
- assert.equal(wrapper, expected, 'Wrapper should be a first element of the children')
254
- assert.end()
255
- })
256
-
257
- test('Component - Instance should initialize slots', (assert) => {
258
- const expected = {
259
- [symbols.isSlot]: true,
260
- }
261
- const config = {
262
- code: {
263
- render: () => [{}, {}, expected, {}],
264
- effects: [],
265
- },
266
- }
267
- const foo = Component('Foo', config)()
268
-
269
- const slots = foo[symbols.slots]
270
-
271
- assert.ok(Array.isArray(slots), 'Slots should be an array')
272
- assert.equal(slots[0], expected, 'Slot should be a expected element of the children')
273
- assert.end()
274
- })
275
-
276
- test('Component - Instance should initialize hook events', (assert) => {
277
- const wrapper = {
278
- node: {
279
- on() {},
280
- },
281
- }
282
- const rendererCapture = assert.capture(renderer, 'on')
283
- const nodeCapture = assert.capture(wrapper.node, 'on')
284
- const config = {
285
- code: {
286
- render: () => [wrapper],
287
- effects: [],
288
- },
289
- hooks: {
290
- frameTick() {},
291
- idle() {},
292
- attach() {},
293
- detach() {},
294
- enter() {},
295
- exit() {},
296
- },
297
- }
298
- Component('Foo', config)()
299
-
300
- const rendererCalls = rendererCapture()
301
- assert.equal(
302
- rendererCalls[0].args[0],
303
- 'frameTick',
304
- '`frameTick` event should be registered in Renderer'
305
- )
306
- assert.equal(rendererCalls[1].args[0], 'idle', '`idle` event should be registered in Renderer')
307
- const nodeCalls = nodeCapture()
308
- assert.equal(
309
- nodeCalls[0].args[0],
310
- 'inBounds',
311
- '`inBounds` event should be registered in the wrapper'
312
- )
313
- assert.equal(
314
- nodeCalls[1].args[0],
315
- 'outOfBounds',
316
- '`outOfBounds` event should be registered in the wrapper'
317
- )
318
- assert.equal(
319
- nodeCalls[2].args[0],
320
- 'inViewport',
321
- '`inViewport` event should be registered in the wrapper'
322
- )
323
- assert.equal(
324
- nodeCalls[3].args[0],
325
- 'outOfBounds',
326
- '`outOfBounds` event should be registered in the wrapper'
327
- )
328
- assert.end()
329
- })
330
-
331
- test('Component - Instance should execute all side effects', (assert) => {
332
- const root = {}
333
- const capture = assert.captureFn(() => {})
334
- const children = []
335
- const config = {
336
- code: {
337
- render: () => children,
338
- effects: [capture],
339
- },
340
- }
341
- const foo = Component('Foo', config)({}, {}, {}, root)
342
-
343
- const calls = capture.calls[0]
344
- // todo: look into this
345
- // assert.equals(calls.receiver, stage, 'Effect`s receiver should be the stage object')
346
- assert.equals(calls.args[0], foo, 'Effect should be invoked with foo component instance')
347
- assert.equals(calls.args[1], children, 'Effect should be invoked with component`s children')
348
- assert.equals(calls.args[2], config, 'Effect should be invoked with config object')
349
- assert.ok(calls.args[3].Sprite, 'Effect should be invoked with global components object')
350
- assert.equals(calls.args[4], root, 'Effect should be invoked with root component')
351
- assert.ok(typeof calls.args[5] === 'function', 'Effect should be invoked with effect function')
352
- assert.end()
353
- })
354
-
355
- test('Component - Instance should have all symbols configured', (assert) => {
356
- const config = {
357
- state() {
358
- return {
359
- foo: 'bar',
360
- }
361
- },
362
- watch: {
363
- foo(value, oldValue) {},
364
- },
365
- }
366
- const foo = Component('Foo', config)()
367
-
368
- Object.getOwnPropertySymbols(foo).forEach((symbol) => {
369
- const descriptor = Object.getOwnPropertyDescriptor(foo, symbol)
370
- assert.ok(descriptor.enumerable === true, `${symbol.description} should be be enumerable`)
371
- assert.ok(descriptor.configurable === true, `${symbol.description} should be configurable`)
372
- })
373
- assert.end()
374
- })
375
-
376
- test('Component - Instance should have ready state after the next process tick', (assert) => {
377
- assert.plan(1)
378
-
379
- const foo = Component('Foo', {})()
380
-
381
- setTimeout(() => {
382
- assert.equal(
383
- foo.lifecycle.state,
384
- 'ready',
385
- 'Foo component lifecycle should be eventually in a ready state'
386
- )
387
- })
388
- })
@@ -1,31 +0,0 @@
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
- })
@@ -1,121 +0,0 @@
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
- export default () =>
23
- Component('FPScounter', {
24
- template: `
25
- <Element>
26
- <Element y="15" x="20">
27
- <Element>
28
- <Sprite image="$image" w="43" h="25" map="$sprite" frame="fps" />
29
- <Element x="58" y="2">
30
- <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$fps[0]" />
31
- <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$fps[1]" />
32
- <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$fps[2]" />
33
- </Element>
34
- </Element>
35
-
36
- <Element x="150">
37
- <Sprite image="$image" y="2" w="48" h="25" map="$sprite" frame="avg" />
38
- <Element x="63" y="2">
39
- <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$avgFps[0]" />
40
- <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$avgFps[1]" />
41
- <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$avgFps[2]" />
42
- </Element>
43
- </Element>
44
-
45
- <Element x="0" y="40" >
46
- <Sprite image="$image" x="-2" w="47" h="25" map="$sprite" frame="min" />
47
- <Element x="58" y="2">
48
- <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$minFps[0]" />
49
- <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$minFps[1]" />
50
- <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$minFps[2]" />
51
- </Element>
52
- </Element>
53
-
54
- <Element x="150" y="40">
55
- <Sprite image="$image" w="53" h="25" map="$sprite" frame="max" />
56
- <Element x="63" y="2">
57
- <Sprite image="$image" x="0" h="20" w="20" map="$sprite" :frame="$maxFps[0]" />
58
- <Sprite image="$image" x="18" h="20" w="20" map="$sprite" :frame="$maxFps[1]" />
59
- <Sprite image="$image" x="36" h="20" w="20" map="$sprite" :frame="$maxFps[2]" />
60
- </Element>
61
- </Element>
62
- </Element>
63
- </Element>
64
- `,
65
- state() {
66
- return {
67
- image: fps_sprite,
68
- sprite: {
69
- defaults: {
70
- y: 1,
71
- w: 20,
72
- h: 20,
73
- },
74
- frames: {
75
- '-': { x: -1000 },
76
- 0: { x: 1 },
77
- 1: { x: 23 },
78
- 2: { x: 45 },
79
- 3: { x: 67 },
80
- 4: { x: 89 },
81
- 5: { x: 111 },
82
- 6: { x: 133 },
83
- 7: { x: 155 },
84
- 8: { x: 177 },
85
- 9: { x: 199 },
86
- avg: { x: 221, w: 48, h: 25 },
87
- fps: { x: 271, w: 43, h: 25 },
88
- max: { x: 316, w: 53, h: 25 },
89
- min: { x: 371, w: 47, h: 25 },
90
- },
91
- },
92
- fps: '---',
93
- avgFps: '---',
94
- minFps: '---',
95
- maxFps: '---',
96
- }
97
- },
98
- hooks: {
99
- ready() {
100
- let minFps = 10000
101
- let maxFps = 0
102
- let avgFps = 0
103
- let totalFps = 0
104
- let fpsUpdateCounter = 0
105
-
106
- // This leaks - might be L3 SubTexture issue
107
- // renderer.on('fpsUpdate', (rM, { fps }) => {
108
- // minFps = Math.min(fps, minFps)
109
- // maxFps = Math.max(fps, maxFps)
110
- // totalFps += fps
111
- // fpsUpdateCounter++
112
- // avgFps = Math.round(totalFps / fpsUpdateCounter)
113
-
114
- // this.fps = fps.toString().padStart(3, '0')
115
- // this.avgFps = avgFps.toString().padStart(3, '0')
116
- // this.minFps = minFps.toString().padStart(3, '0')
117
- // this.maxFps = maxFps.toString().padStart(3, '0')
118
- // })
119
- },
120
- },
121
- })
@@ -1,54 +0,0 @@
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 hashchangeHandler = null
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
- hashchangeHandler = () => Router.navigate.apply(this)
36
- Router.navigate.apply(this)
37
- window.addEventListener('hashchange', hashchangeHandler)
38
- },
39
- destroy() {
40
- window.removeEventListener('hashchange', hashchangeHandler, false)
41
- },
42
- focus() {
43
- this.activeView && this.activeView.$focus()
44
- },
45
- },
46
- input: {
47
- back(e) {
48
- const navigating = Router.back.call(this)
49
- if (navigating === false) {
50
- this.parent.$focus(e)
51
- }
52
- },
53
- },
54
- })
@@ -1,58 +0,0 @@
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="100%" h="100%" :texture="$texture" :color="$color" />
26
- `,
27
- props: ['image', 'map', 'frame', 'color'],
28
- state() {
29
- return {
30
- spriteTexture: null,
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 !== null && 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
- })
@@ -1,28 +0,0 @@
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 Circle from './Circle.js'
19
- import RouterView from './RouterView.js'
20
- import Sprite from './Sprite.js'
21
- import FPScounter from './FPScounter.js'
22
-
23
- export default () => ({
24
- Circle: Circle(),
25
- RouterView: RouterView(),
26
- Sprite: Sprite(),
27
- FPScounter: FPScounter(),
28
- })