@lightningtv/solid 3.0.0-21 → 3.0.0-22
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/dist/src/core/animation.js +1 -2
- package/dist/src/core/animation.js.map +1 -1
- package/dist/src/core/dom-renderer/domRenderer.d.ts +137 -0
- package/dist/src/core/dom-renderer/domRenderer.js +1545 -0
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -0
- package/dist/src/core/dom-renderer/domRendererTypes.d.ts +117 -0
- package/dist/src/core/dom-renderer/domRendererTypes.js +2 -0
- package/dist/src/core/dom-renderer/domRendererTypes.js.map +1 -0
- package/dist/src/core/dom-renderer/domRendererUtils.d.ts +16 -0
- package/dist/src/core/dom-renderer/domRendererUtils.js +132 -0
- package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -0
- package/dist/src/core/elementNode.d.ts +260 -6
- package/dist/src/core/elementNode.js +17 -16
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusManager.js +10 -3
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/primitives/utils/createSpriteMap.js +2 -2
- package/dist/src/primitives/utils/createSpriteMap.js.map +1 -1
- package/dist/src/primitives/utils/handleNavigation.js +3 -3
- package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
- package/dist/src/render.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/src/core/animation.ts +4 -2
- package/src/core/elementNode.ts +279 -28
- package/src/core/focusManager.ts +11 -1
- package/src/primitives/utils/createSpriteMap.ts +2 -2
- package/src/primitives/utils/handleNavigation.ts +3 -3
- package/src/core/timings.ts +0 -261
package/src/core/timings.ts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Core Utility Functions
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export const EPSILON = 0.000001;
|
|
27
|
-
export let ARRAY_TYPE =
|
|
28
|
-
typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
29
|
-
export const RANDOM = Math.random;
|
|
30
|
-
export const ANGLE_ORDER = 'zyx';
|
|
31
|
-
const degree = Math.PI / 180;
|
|
32
|
-
|
|
33
|
-
export const setMatrixArrayType = (
|
|
34
|
-
type: Float32ArrayConstructor | ArrayConstructor,
|
|
35
|
-
) => {
|
|
36
|
-
ARRAY_TYPE = type;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Merges two colors based on a given progress value.
|
|
41
|
-
*
|
|
42
|
-
* This function takes two colors (c1 and c2) represented as 32-bit integers
|
|
43
|
-
* in RGBA format and blends them based on the provided progress value (p).
|
|
44
|
-
* The result is a new color that is a weighted combination of the input colors,
|
|
45
|
-
* where the weight is determined by the progress value.
|
|
46
|
-
*
|
|
47
|
-
* @param {number} c1 - The first color in RGBA format (32-bit integer).
|
|
48
|
-
* @param {number} c2 - The second color in RGBA format (32-bit integer).
|
|
49
|
-
* @param {number} p - The progress value between 0 and 1.
|
|
50
|
-
* @returns {number} The merged color as a 32-bit integer in RGBA format.
|
|
51
|
-
*/
|
|
52
|
-
export function mergeColorProgress(
|
|
53
|
-
rgba1: number,
|
|
54
|
-
rgba2: number,
|
|
55
|
-
p: number,
|
|
56
|
-
): number {
|
|
57
|
-
const r1 = Math.trunc(rgba1 >>> 24);
|
|
58
|
-
const g1 = Math.trunc((rgba1 >>> 16) & 0xff);
|
|
59
|
-
const b1 = Math.trunc((rgba1 >>> 8) & 0xff);
|
|
60
|
-
const a1 = Math.trunc(rgba1 & 0xff);
|
|
61
|
-
|
|
62
|
-
const r2 = Math.trunc(rgba2 >>> 24);
|
|
63
|
-
const g2 = Math.trunc((rgba2 >>> 16) & 0xff);
|
|
64
|
-
const b2 = Math.trunc((rgba2 >>> 8) & 0xff);
|
|
65
|
-
const a2 = Math.trunc(rgba2 & 0xff);
|
|
66
|
-
|
|
67
|
-
const r = Math.round(r2 * p + r1 * (1 - p));
|
|
68
|
-
const g = Math.round(g2 * p + g1 * (1 - p));
|
|
69
|
-
const b = Math.round(b2 * p + b1 * (1 - p));
|
|
70
|
-
const a = Math.round(a2 * p + a1 * (1 - p));
|
|
71
|
-
|
|
72
|
-
return ((r << 24) | (g << 16) | (b << 8) | a) >>> 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const toRadian = (a: number) => {
|
|
76
|
-
return a * degree;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const equals = (a: number, b: number) => {
|
|
80
|
-
return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const rand = (min: number, max: number) => {
|
|
84
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const isPowerOfTwo = (value: number) => {
|
|
88
|
-
return value && !(value & (value - 1));
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const getTimingBezier = (
|
|
92
|
-
a: number,
|
|
93
|
-
b: number,
|
|
94
|
-
c: number,
|
|
95
|
-
d: number,
|
|
96
|
-
): ((time: number) => number | undefined) => {
|
|
97
|
-
const xc = 3.0 * a;
|
|
98
|
-
const xb = 3.0 * (c - a) - xc;
|
|
99
|
-
const xa = 1.0 - xc - xb;
|
|
100
|
-
const yc = 3.0 * b;
|
|
101
|
-
const yb = 3.0 * (d - b) - yc;
|
|
102
|
-
const ya = 1.0 - yc - yb;
|
|
103
|
-
|
|
104
|
-
return function (time: number): number | undefined {
|
|
105
|
-
if (time >= 1.0) {
|
|
106
|
-
return 1;
|
|
107
|
-
}
|
|
108
|
-
if (time <= 0) {
|
|
109
|
-
return 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let t = 0.5,
|
|
113
|
-
cbx,
|
|
114
|
-
cbxd,
|
|
115
|
-
dx;
|
|
116
|
-
|
|
117
|
-
for (let it = 0; it < 20; it++) {
|
|
118
|
-
cbx = t * (t * (t * xa + xb) + xc);
|
|
119
|
-
dx = time - cbx;
|
|
120
|
-
if (dx > -1e-8 && dx < 1e-8) {
|
|
121
|
-
return t * (t * (t * ya + yb) + yc);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Cubic bezier derivative.
|
|
125
|
-
cbxd = t * (t * (3 * xa) + 2 * xb) + xc;
|
|
126
|
-
|
|
127
|
-
if (cbxd > 1e-10 && cbxd < 1e-10) {
|
|
128
|
-
// Problematic. Fall back to binary search method.
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
t += dx / cbxd;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Fallback: binary search method. This is more reliable when there are near-0 slopes.
|
|
136
|
-
let minT = 0;
|
|
137
|
-
let maxT = 1;
|
|
138
|
-
for (let it = 0; it < 20; it++) {
|
|
139
|
-
t = 0.5 * (minT + maxT);
|
|
140
|
-
|
|
141
|
-
cbx = t * (t * (t * xa + xb) + xc);
|
|
142
|
-
|
|
143
|
-
dx = time - cbx;
|
|
144
|
-
if (dx > -1e-8 && dx < 1e-8) {
|
|
145
|
-
// Solution found!
|
|
146
|
-
return t * (t * (t * ya + yb) + yc);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (dx < 0) {
|
|
150
|
-
maxT = t;
|
|
151
|
-
} else {
|
|
152
|
-
minT = t;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
interface TimingFunctionMap {
|
|
159
|
-
[key: string]: (time: number) => number | undefined;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
type TimingLookupArray = number[];
|
|
163
|
-
interface TimingLookup {
|
|
164
|
-
[key: string]: TimingLookupArray;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const timingMapping: TimingFunctionMap = {};
|
|
168
|
-
|
|
169
|
-
const timingLookup: TimingLookup = {
|
|
170
|
-
ease: [0.25, 0.1, 0.25, 1.0],
|
|
171
|
-
'ease-in': [0.42, 0, 1.0, 1.0],
|
|
172
|
-
'ease-out': [0, 0, 0.58, 1.0],
|
|
173
|
-
'ease-in-out': [0.42, 0, 0.58, 1.0],
|
|
174
|
-
'ease-in-sine': [0.12, 0, 0.39, 0],
|
|
175
|
-
'ease-out-sine': [0.12, 0, 0.39, 0],
|
|
176
|
-
'ease-in-out-sine': [0.37, 0, 0.63, 1],
|
|
177
|
-
'ease-in-cubic': [0.32, 0, 0.67, 0],
|
|
178
|
-
'ease-out-cubic': [0.33, 1, 0.68, 1],
|
|
179
|
-
'ease-in-out-cubic': [0.65, 0, 0.35, 1],
|
|
180
|
-
'ease-in-circ': [0.55, 0, 1, 0.45],
|
|
181
|
-
'ease-out-circ': [0, 0.55, 0.45, 1],
|
|
182
|
-
'ease-in-out-circ': [0.85, 0, 0.15, 1],
|
|
183
|
-
'ease-in-back': [0.36, 0, 0.66, -0.56],
|
|
184
|
-
'ease-out-back': [0.34, 1.56, 0.64, 1],
|
|
185
|
-
'ease-in-out-back': [0.68, -0.6, 0.32, 1.6],
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const defaultTiming = (t: number): number => t;
|
|
189
|
-
|
|
190
|
-
const parseCubicBezier = (str: string) => {
|
|
191
|
-
//cubic-bezier(0.84, 0.52, 0.56, 0.6)
|
|
192
|
-
const regex = /-?\d*\.?\d+/g;
|
|
193
|
-
const match = str.match(regex);
|
|
194
|
-
|
|
195
|
-
if (match) {
|
|
196
|
-
const [num1, num2, num3, num4] = match;
|
|
197
|
-
const a = parseFloat(num1 || '0.42');
|
|
198
|
-
const b = parseFloat(num2 || '0');
|
|
199
|
-
const c = parseFloat(num3 || '1');
|
|
200
|
-
const d = parseFloat(num4 || '1');
|
|
201
|
-
|
|
202
|
-
const timing = getTimingBezier(a, b, c, d);
|
|
203
|
-
timingMapping[str] = timing;
|
|
204
|
-
|
|
205
|
-
return timing;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// parse failed, return linear
|
|
209
|
-
console.warn('Unknown cubic-bezier timing: ' + str);
|
|
210
|
-
return defaultTiming;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export const getTimingFunction = (
|
|
214
|
-
str: string,
|
|
215
|
-
): ((time: number) => number | undefined) => {
|
|
216
|
-
if (str === 'linear') {
|
|
217
|
-
return defaultTiming;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (timingMapping[str] !== undefined) {
|
|
221
|
-
return timingMapping[str] || defaultTiming;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (str === 'step-start') {
|
|
225
|
-
return () => {
|
|
226
|
-
return 1;
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (str === 'step-end') {
|
|
231
|
-
return (time: number) => {
|
|
232
|
-
return time === 1 ? 1 : 0;
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const lookup = timingLookup[str];
|
|
237
|
-
if (lookup !== undefined) {
|
|
238
|
-
const [a, b, c, d] = lookup;
|
|
239
|
-
// @ts-ignore - TS doesn't understand that we've checked for undefined
|
|
240
|
-
const timing = getTimingBezier(a, b, c, d);
|
|
241
|
-
timingMapping[str] = timing;
|
|
242
|
-
return timing;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (str.startsWith('cubic-bezier')) {
|
|
246
|
-
return parseCubicBezier(str);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
console.warn('Unknown timing function: ' + str);
|
|
250
|
-
return defaultTiming;
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Convert bytes to string of megabytes with 2 decimal points
|
|
255
|
-
*
|
|
256
|
-
* @param bytes
|
|
257
|
-
* @returns
|
|
258
|
-
*/
|
|
259
|
-
export function bytesToMb(bytes: number) {
|
|
260
|
-
return (bytes / 1024 / 1024).toFixed(2);
|
|
261
|
-
}
|