@lightningjs/renderer 3.0.0 → 3.0.2
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/CoreNode.d.ts +1 -1
- package/dist/src/core/CoreTextNode.js +8 -0
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/lib/ImageWorker.d.ts +2 -2
- package/dist/src/core/lib/ImageWorker.js +12 -31
- package/dist/src/core/lib/ImageWorker.js.map +1 -1
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +60 -109
- package/dist/src/core/lib/WebGlContextWrapper.js +158 -164
- package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -1
- package/dist/src/core/lib/textureCompression.js +10 -19
- package/dist/src/core/lib/textureCompression.js.map +1 -1
- package/dist/src/core/lib/validateImageBitmap.d.ts +1 -2
- package/dist/src/core/lib/validateImageBitmap.js +4 -4
- package/dist/src/core/lib/validateImageBitmap.js.map +1 -1
- package/dist/src/core/platform.js +5 -2
- package/dist/src/core/platform.js.map +1 -1
- package/dist/src/core/platforms/web/WebGlContextWrapper.d.ts +5 -5
- package/dist/src/core/renderers/webgl/WebGlCoreShader.destroy.d.ts +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.destroy.js +2 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.destroy.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlRenderer.js +5 -3
- package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +4 -1
- package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +1 -2
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +0 -1
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +14 -35
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +8 -25
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/CoreTextNode.ts +9 -0
- package/src/core/renderers/webgl/WebGlCtxTexture.test.ts +113 -0
- package/src/core/renderers/webgl/WebGlRenderer.ts +4 -3
- package/src/core/renderers/webgl/WebGlShaderProgram.ts +3 -1
- package/src/core/renderers/webgl/internal/RendererUtils.ts +1 -2
- package/dist/src/core/AutosizeManager.d.ts +0 -29
- package/dist/src/core/AutosizeManager.js +0 -169
- package/dist/src/core/AutosizeManager.js.map +0 -1
- package/dist/src/core/animations/Animation.d.ts +0 -21
- package/dist/src/core/animations/Animation.js +0 -194
- package/dist/src/core/animations/Animation.js.map +0 -1
- package/dist/src/core/animations/Playback.d.ts +0 -64
- package/dist/src/core/animations/Playback.js +0 -169
- package/dist/src/core/animations/Playback.js.map +0 -1
- package/dist/src/core/animations/Transition.d.ts +0 -27
- package/dist/src/core/animations/Transition.js +0 -52
- package/dist/src/core/animations/Transition.js.map +0 -1
- package/dist/src/core/animations/utils.d.ts +0 -2
- package/dist/src/core/animations/utils.js +0 -136
- package/dist/src/core/animations/utils.js.map +0 -1
- package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +0 -45
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js +0 -127
- package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +0 -1
- package/dist/src/core/shaders/webgl/SdfShadowShader.d.ts +0 -9
- package/dist/src/core/shaders/webgl/SdfShadowShader.js +0 -100
- package/dist/src/core/shaders/webgl/SdfShadowShader.js.map +0 -1
- package/dist/src/core/text-rendering/CanvasFont.d.ts +0 -14
- package/dist/src/core/text-rendering/CanvasFont.js +0 -111
- package/dist/src/core/text-rendering/CanvasFont.js.map +0 -1
- package/dist/src/core/text-rendering/CoreFont.d.ts +0 -33
- package/dist/src/core/text-rendering/CoreFont.js +0 -48
- package/dist/src/core/text-rendering/CoreFont.js.map +0 -1
- package/dist/src/core/text-rendering/FontManager.d.ts +0 -11
- package/dist/src/core/text-rendering/FontManager.js +0 -42
- package/dist/src/core/text-rendering/FontManager.js.map +0 -1
- package/dist/src/core/text-rendering/SdfFont.d.ts +0 -29
- package/dist/src/core/text-rendering/SdfFont.js +0 -142
- package/dist/src/core/text-rendering/SdfFont.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,52 +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
|
-
export function easedProgressFn(p) {
|
|
20
|
-
return this.from + (this.to - this.from) * this.easing(p);
|
|
21
|
-
}
|
|
22
|
-
export function linearProgressFn(p) {
|
|
23
|
-
return this.from + (this.to - this.from) * p;
|
|
24
|
-
}
|
|
25
|
-
export function updateTransition(animationTime) {
|
|
26
|
-
//calculate progress of transition
|
|
27
|
-
let p = (animationTime - this.delay) / this.duration;
|
|
28
|
-
if (p >= 1) {
|
|
29
|
-
p = 1;
|
|
30
|
-
return (this.current = this.to);
|
|
31
|
-
}
|
|
32
|
-
if (p < 0) {
|
|
33
|
-
p = 0;
|
|
34
|
-
return (this.current = this.from);
|
|
35
|
-
}
|
|
36
|
-
return (this.current = this.progressFn(p));
|
|
37
|
-
}
|
|
38
|
-
export function createTransition(props) {
|
|
39
|
-
const easing = props.easing;
|
|
40
|
-
//cast props to Transition to add new properties and methods without creating a new object
|
|
41
|
-
const transition = props;
|
|
42
|
-
// Convert string values to numbers and add new properties
|
|
43
|
-
transition.to = props.to;
|
|
44
|
-
transition.from = props.from;
|
|
45
|
-
transition.current = (props.from ?? props.to);
|
|
46
|
-
transition.easing = easing;
|
|
47
|
-
transition.update = updateTransition;
|
|
48
|
-
transition.progressFn =
|
|
49
|
-
easing !== undefined ? easedProgressFn : linearProgressFn;
|
|
50
|
-
return transition;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=Transition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transition.js","sourceRoot":"","sources":["../../../../src/core/animations/Transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAgCH,MAAM,UAAU,eAAe,CAA6B,CAAS;IACnE,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAA6B,CAAS;IACpE,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAE9B,aAAqB;IAErB,kCAAkC;IAClC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;IACrD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACX,CAAC,GAAG,CAAC,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,CAAC,GAAG,CAAC,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAoC,CAAC;IAC1D,0FAA0F;IAC1F,MAAM,UAAU,GAAG,KAAmB,CAAC;IAEvC,0DAA0D;IAC1D,UAAU,CAAC,EAAE,GAAG,KAAK,CAAC,EAAY,CAAC;IACnC,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC,IAAc,CAAC;IACvC,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAW,CAAC;IACxD,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;IAC3B,UAAU,CAAC,MAAM,GAAG,gBAAgB,CAAC;IACrC,UAAU,CAAC,UAAU;QACnB,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAE5D,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,136 +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
|
-
const tfCache = {};
|
|
20
|
-
const cubicBezierMap = {
|
|
21
|
-
ease: [0.25, 0.1, 0.25, 1.0],
|
|
22
|
-
'ease-in': [0.42, 0, 1.0, 1.0],
|
|
23
|
-
'ease-out': [0, 0, 0.58, 1.0],
|
|
24
|
-
'ease-in-out': [0.42, 0, 0.58, 1.0],
|
|
25
|
-
'ease-in-sine': [0.12, 0, 0.39, 0],
|
|
26
|
-
'ease-out-sine': [0.12, 0, 0.39, 0],
|
|
27
|
-
'ease-in-out-sine': [0.37, 0, 0.63, 1],
|
|
28
|
-
'ease-in-cubic': [0.32, 0, 0.67, 0],
|
|
29
|
-
'ease-out-cubic': [0.33, 1, 0.68, 1],
|
|
30
|
-
'ease-in-out-cubic': [0.65, 0, 0.35, 1],
|
|
31
|
-
'ease-in-circ': [0.55, 0, 1, 0.45],
|
|
32
|
-
'ease-out-circ': [0, 0.55, 0.45, 1],
|
|
33
|
-
'ease-in-out-circ': [0.85, 0, 0.15, 1],
|
|
34
|
-
'ease-in-back': [0.36, 0, 0.66, -0.56],
|
|
35
|
-
'ease-out-back': [0.34, 1.56, 0.64, 1],
|
|
36
|
-
'ease-in-out-back': [0.68, -0.6, 0.32, 1.6],
|
|
37
|
-
};
|
|
38
|
-
const createCubicBezierFunction = (a, b, c, d) => {
|
|
39
|
-
const xc = 3.0 * a;
|
|
40
|
-
const xb = 3.0 * (c - a) - xc;
|
|
41
|
-
const xa = 1.0 - xc - xb;
|
|
42
|
-
const yc = 3.0 * b;
|
|
43
|
-
const yb = 3.0 * (d - b) - yc;
|
|
44
|
-
const ya = 1.0 - yc - yb;
|
|
45
|
-
return function (time) {
|
|
46
|
-
if (time >= 1.0) {
|
|
47
|
-
return 1;
|
|
48
|
-
}
|
|
49
|
-
if (time <= 0) {
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
let t = 0.5;
|
|
53
|
-
let cbx;
|
|
54
|
-
let cbxd;
|
|
55
|
-
let dx;
|
|
56
|
-
for (let it = 0; it < 20; it++) {
|
|
57
|
-
cbx = t * (t * (t * xa + xb) + xc);
|
|
58
|
-
dx = time - cbx;
|
|
59
|
-
if (dx > -1e-8 && dx < 1e-8) {
|
|
60
|
-
return t * (t * (t * ya + yb) + yc);
|
|
61
|
-
}
|
|
62
|
-
// Cubic bezier derivative.
|
|
63
|
-
cbxd = t * (t * (3 * xa) + 2 * xb) + xc;
|
|
64
|
-
if (cbxd > 1e-10 && cbxd < 1e-10) {
|
|
65
|
-
// Problematic. Fall back to binary search method.
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
t += dx / cbxd;
|
|
69
|
-
}
|
|
70
|
-
// Fallback: binary search method. This is more reliable when there are near-0 slopes.
|
|
71
|
-
let minT = 0;
|
|
72
|
-
let maxT = 1;
|
|
73
|
-
for (let it = 0; it < 20; it++) {
|
|
74
|
-
t = 0.5 * (minT + maxT);
|
|
75
|
-
cbx = t * (t * (t * xa + xb) + xc);
|
|
76
|
-
dx = time - cbx;
|
|
77
|
-
if (dx > -1e-8 && dx < 1e-8) {
|
|
78
|
-
// Solution found!
|
|
79
|
-
return t * (t * (t * ya + yb) + yc);
|
|
80
|
-
}
|
|
81
|
-
if (dx < 0) {
|
|
82
|
-
maxT = t;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
minT = t;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return time;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
const parseCubicBezier = (str) => {
|
|
92
|
-
//cubic-bezier(0.84, 0.52, 0.56, 0.6)
|
|
93
|
-
const regex = /-?\d*\.?\d+/g;
|
|
94
|
-
const match = str.match(regex);
|
|
95
|
-
if (match) {
|
|
96
|
-
const [num1, num2, num3, num4] = match;
|
|
97
|
-
const a = parseFloat(num1 || '0.42');
|
|
98
|
-
const b = parseFloat(num2 || '0');
|
|
99
|
-
const c = parseFloat(num3 || '1');
|
|
100
|
-
const d = parseFloat(num4 || '1');
|
|
101
|
-
const timing = createCubicBezierFunction(a, b, c, d);
|
|
102
|
-
tfCache[str] = timing;
|
|
103
|
-
return timing;
|
|
104
|
-
}
|
|
105
|
-
// parse failed, return linear
|
|
106
|
-
console.warn('cubic-bezier invalid' + str);
|
|
107
|
-
return undefined;
|
|
108
|
-
};
|
|
109
|
-
export const normalizeTimingFunction = (something) => {
|
|
110
|
-
if (typeof something !== 'string' && typeof something !== 'function') {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
//predefined timing functions
|
|
114
|
-
if (typeof something === 'function') {
|
|
115
|
-
return something;
|
|
116
|
-
}
|
|
117
|
-
if (tfCache[something] !== undefined) {
|
|
118
|
-
return tfCache[something];
|
|
119
|
-
}
|
|
120
|
-
if (cubicBezierMap[something] !== undefined) {
|
|
121
|
-
const [a, b, c, d] = cubicBezierMap[something];
|
|
122
|
-
const tf = createCubicBezierFunction(a, b, c, d);
|
|
123
|
-
tfCache[something] = tf;
|
|
124
|
-
return tf;
|
|
125
|
-
}
|
|
126
|
-
//custom cubic-bezier
|
|
127
|
-
if (something.startsWith('cubic-bezier')) {
|
|
128
|
-
const tf = parseCubicBezier(something);
|
|
129
|
-
if (tf !== undefined) {
|
|
130
|
-
tfCache[something] = tf;
|
|
131
|
-
}
|
|
132
|
-
return tf;
|
|
133
|
-
}
|
|
134
|
-
return undefined;
|
|
135
|
-
};
|
|
136
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["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AAC;QAC5C,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,EAAE,GAAG,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,qBAAqB;IACrB,IAAI,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QACzC,MAAM,EAAE,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACvC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { CoreRenderOp } from '../CoreRenderOp.js';
|
|
2
|
-
import type { WebGlCtxTexture } from './WebGlCtxTexture.js';
|
|
3
|
-
import type { WebGlRenderer } from './WebGlRenderer.js';
|
|
4
|
-
import type { BufferCollection } from './internal/BufferCollection.js';
|
|
5
|
-
import type { WebGlShaderNode } from './WebGlShaderNode.js';
|
|
6
|
-
import type { QuadOptions } from '../CoreRenderer.js';
|
|
7
|
-
import type { CoreTextNode } from '../../CoreTextNode.js';
|
|
8
|
-
import type { RectWithValid } from '../../lib/utils.js';
|
|
9
|
-
import type { Dimensions } from '../../../common/CommonTypes.js';
|
|
10
|
-
type ReqQuad = 'alpha' | 'shader' | 'parentHasRenderTexture' | 'rtt' | 'clippingRect' | 'height' | 'width' | 'time';
|
|
11
|
-
type RenderOpQuadOptions = Pick<QuadOptions, ReqQuad> & Partial<Omit<QuadOptions, ReqQuad>> & {
|
|
12
|
-
sdfShaderProps?: Record<string, unknown>;
|
|
13
|
-
sdfBuffers?: BufferCollection;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Can render multiple quads with multiple textures (up to vertex shader texture limit)
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export declare class WebGlRenderOp extends CoreRenderOp {
|
|
20
|
-
readonly renderer: WebGlRenderer;
|
|
21
|
-
readonly bufferIdx: number;
|
|
22
|
-
numQuads: number;
|
|
23
|
-
textures: WebGlCtxTexture[];
|
|
24
|
-
/**
|
|
25
|
-
* need to improve this when TextRenderers are refactored
|
|
26
|
-
*/
|
|
27
|
-
readonly sdfShaderProps: Record<string, unknown> | undefined;
|
|
28
|
-
readonly sdfNode: CoreTextNode | undefined;
|
|
29
|
-
readonly maxTextures: number;
|
|
30
|
-
readonly buffers: BufferCollection;
|
|
31
|
-
readonly shader: WebGlShaderNode;
|
|
32
|
-
readonly width: number;
|
|
33
|
-
readonly height: number;
|
|
34
|
-
readonly clippingRect: RectWithValid;
|
|
35
|
-
readonly rtt: boolean;
|
|
36
|
-
readonly parentHasRenderTexture: boolean;
|
|
37
|
-
readonly framebufferDimensions: Dimensions | null;
|
|
38
|
-
readonly alpha: number;
|
|
39
|
-
readonly pixelRatio: number;
|
|
40
|
-
readonly time?: number | null;
|
|
41
|
-
constructor(renderer: WebGlRenderer, quad: RenderOpQuadOptions, bufferIdx: number);
|
|
42
|
-
addTexture(texture: WebGlCtxTexture): number;
|
|
43
|
-
draw(): void;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,127 +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
|
-
import { CoreRenderOp } from '../CoreRenderOp.js';
|
|
20
|
-
/**
|
|
21
|
-
* Can render multiple quads with multiple textures (up to vertex shader texture limit)
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
export class WebGlRenderOp extends CoreRenderOp {
|
|
25
|
-
renderer;
|
|
26
|
-
bufferIdx;
|
|
27
|
-
numQuads = 0;
|
|
28
|
-
textures = [];
|
|
29
|
-
/**
|
|
30
|
-
* need to improve this when TextRenderers are refactored
|
|
31
|
-
*/
|
|
32
|
-
sdfShaderProps;
|
|
33
|
-
sdfNode;
|
|
34
|
-
maxTextures;
|
|
35
|
-
buffers;
|
|
36
|
-
shader;
|
|
37
|
-
width;
|
|
38
|
-
height;
|
|
39
|
-
clippingRect;
|
|
40
|
-
rtt;
|
|
41
|
-
parentHasRenderTexture;
|
|
42
|
-
framebufferDimensions;
|
|
43
|
-
alpha;
|
|
44
|
-
pixelRatio;
|
|
45
|
-
time;
|
|
46
|
-
constructor(renderer, quad, bufferIdx) {
|
|
47
|
-
super();
|
|
48
|
-
this.renderer = renderer;
|
|
49
|
-
this.bufferIdx = bufferIdx;
|
|
50
|
-
this.buffers = quad.sdfBuffers || renderer.quadBufferCollection;
|
|
51
|
-
this.shader = quad.shader;
|
|
52
|
-
this.width = quad.width;
|
|
53
|
-
this.height = quad.height;
|
|
54
|
-
this.clippingRect = quad.clippingRect;
|
|
55
|
-
this.parentHasRenderTexture = quad.parentHasRenderTexture;
|
|
56
|
-
this.framebufferDimensions = quad.framebufferDimensions || null;
|
|
57
|
-
this.rtt = quad.rtt;
|
|
58
|
-
this.alpha = quad.alpha;
|
|
59
|
-
this.pixelRatio =
|
|
60
|
-
this.parentHasRenderTexture === true ? 1 : renderer.stage.pixelRatio;
|
|
61
|
-
this.time = quad.time;
|
|
62
|
-
/**
|
|
63
|
-
* related to line 51
|
|
64
|
-
*/
|
|
65
|
-
this.sdfShaderProps = quad.sdfShaderProps;
|
|
66
|
-
this.maxTextures = this.shader.program.supportsIndexedTextures
|
|
67
|
-
? renderer.glw.getParameter(renderer.glw.MAX_VERTEX_TEXTURE_IMAGE_UNITS)
|
|
68
|
-
: 1;
|
|
69
|
-
}
|
|
70
|
-
addTexture(texture) {
|
|
71
|
-
const { textures, maxTextures } = this;
|
|
72
|
-
let existingIdx = -1;
|
|
73
|
-
const texturesLength = textures.length;
|
|
74
|
-
for (let i = 0; i < texturesLength; i++) {
|
|
75
|
-
const t = textures[i];
|
|
76
|
-
if (t === texture) {
|
|
77
|
-
existingIdx = i;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (existingIdx !== -1) {
|
|
82
|
-
return existingIdx;
|
|
83
|
-
}
|
|
84
|
-
if (texturesLength >= maxTextures) {
|
|
85
|
-
return 0xffffffff;
|
|
86
|
-
}
|
|
87
|
-
this.textures.push(texture);
|
|
88
|
-
return texturesLength;
|
|
89
|
-
}
|
|
90
|
-
draw() {
|
|
91
|
-
const { glw, options, stage } = this.renderer;
|
|
92
|
-
stage.shManager.useShader(this.shader.program);
|
|
93
|
-
this.shader.program.bindRenderOp(this);
|
|
94
|
-
// Clipping
|
|
95
|
-
if (this.clippingRect.valid === true) {
|
|
96
|
-
const clipX = Math.round(this.clippingRect.x * this.pixelRatio);
|
|
97
|
-
const clipWidth = Math.round(this.clippingRect.width * this.pixelRatio);
|
|
98
|
-
const clipHeight = Math.round(this.clippingRect.height * this.pixelRatio);
|
|
99
|
-
let clipY = Math.round(options.canvas.height -
|
|
100
|
-
clipHeight -
|
|
101
|
-
this.clippingRect.y * this.pixelRatio);
|
|
102
|
-
// if parent has render texture, we need to adjust the scissor rect
|
|
103
|
-
// to be relative to the parent's framebuffer
|
|
104
|
-
if (this.parentHasRenderTexture) {
|
|
105
|
-
clipY = this.framebufferDimensions
|
|
106
|
-
? this.framebufferDimensions.h - this.height
|
|
107
|
-
: 0;
|
|
108
|
-
}
|
|
109
|
-
glw.setScissorTest(true);
|
|
110
|
-
glw.scissor(clipX, clipY, clipWidth, clipHeight);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
glw.setScissorTest(false);
|
|
114
|
-
}
|
|
115
|
-
// Check if this is SDF rendering (has sdfBuffers)
|
|
116
|
-
if (this.sdfShaderProps !== undefined) {
|
|
117
|
-
// SDF rendering uses drawArrays with explicit triangle vertices (6 vertices per quad)
|
|
118
|
-
glw.drawArrays(glw.TRIANGLES, 0, 6 * this.numQuads);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
// Regular rendering uses drawElements with index buffer (4 vertices per quad)
|
|
122
|
-
const quadIdx = (this.bufferIdx / 32) * 6 * 2;
|
|
123
|
-
glw.drawElements(glw.TRIANGLES, 6 * this.numQuads, glw.UNSIGNED_SHORT, quadIdx);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=WebGlRenderOp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebGlRenderOp.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlRenderOp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAyBlD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAuBlC;IAEA;IAxBX,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,GAAsB,EAAE,CAAC;IAEjC;;OAEG;IACM,cAAc,CAAsC;IACpD,OAAO,CAA2B;IAClC,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Y,CACd,GAAG,CAAC,SAAS,EACb,CAAC,GAAG,IAAI,CAAC,QAAQ,EACjB,GAAG,CAAC,cAAc,EAClB,OAAO,CACR,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
|
|
2
|
-
import { type SdfShaderProps } from './SdfShader.js';
|
|
3
|
-
export type SdfShadowShaderProps = SdfShaderProps & {
|
|
4
|
-
shadowColor: number;
|
|
5
|
-
shadowBlur: number;
|
|
6
|
-
shadowOffsetX: number;
|
|
7
|
-
shadowOffsetY: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const SdfShadow: WebGlShaderType<SdfShadowShaderProps>;
|
|
@@ -1,100 +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
|
-
import { getNormalizedRgbaComponents } from '../../lib/utils.js';
|
|
20
|
-
import { Sdf } from './SdfShader.js';
|
|
21
|
-
export const SdfShadow = {
|
|
22
|
-
props: {
|
|
23
|
-
...Sdf.props,
|
|
24
|
-
shadowColor: 0x000000ff,
|
|
25
|
-
shadowBlur: 0,
|
|
26
|
-
shadowOffsetX: 0,
|
|
27
|
-
shadowOffsetY: 0,
|
|
28
|
-
},
|
|
29
|
-
onSdfBind(props) {
|
|
30
|
-
Sdf.onSdfBind.call(this, props);
|
|
31
|
-
this.uniform4fa('u_shadowColor', getNormalizedRgbaComponents(props.shadowColor));
|
|
32
|
-
this.uniform1f('u_shadowBlur', props.shadowBlur);
|
|
33
|
-
this.uniform2f('u_shadowOffset', props.shadowOffsetX, props.shadowOffsetY);
|
|
34
|
-
},
|
|
35
|
-
vertex: `
|
|
36
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
37
|
-
precision highp float;
|
|
38
|
-
# else
|
|
39
|
-
precision mediump float;
|
|
40
|
-
# endif
|
|
41
|
-
// an attribute is an input (in) to a vertex shader.
|
|
42
|
-
// It will receive data from a buffer
|
|
43
|
-
attribute vec2 a_position;
|
|
44
|
-
attribute vec2 a_textureCoords;
|
|
45
|
-
|
|
46
|
-
uniform vec2 u_resolution;
|
|
47
|
-
uniform mat3 u_transform;
|
|
48
|
-
uniform float u_pixelRatio;
|
|
49
|
-
uniform float u_size;
|
|
50
|
-
uniform float u_distanceRange;
|
|
51
|
-
uniform vec2 u_shadowOffset;
|
|
52
|
-
|
|
53
|
-
varying vec2 v_texcoord;
|
|
54
|
-
varying float v_scaledDistRange;
|
|
55
|
-
|
|
56
|
-
void main() {
|
|
57
|
-
vec2 scrolledPosition = a_position * u_size;
|
|
58
|
-
vec2 transformedPosition = (u_transform * vec3(scrolledPosition, 1)).xy;
|
|
59
|
-
|
|
60
|
-
// Apply shadow offset after transform
|
|
61
|
-
transformedPosition += u_shadowOffset;
|
|
62
|
-
|
|
63
|
-
// Calculate screen space with pixel ratio
|
|
64
|
-
vec2 screenSpace = (transformedPosition * u_pixelRatio / u_resolution * 2.0 - 1.0) * vec2(1, -1);
|
|
65
|
-
|
|
66
|
-
gl_Position = vec4(screenSpace, 0.0, 1.0);
|
|
67
|
-
v_texcoord = a_textureCoords;
|
|
68
|
-
v_scaledDistRange = u_distanceRange * u_pixelRatio;
|
|
69
|
-
}
|
|
70
|
-
`,
|
|
71
|
-
fragment: `
|
|
72
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
73
|
-
precision highp float;
|
|
74
|
-
# else
|
|
75
|
-
precision mediump float;
|
|
76
|
-
# endif
|
|
77
|
-
uniform vec4 u_color;
|
|
78
|
-
uniform sampler2D u_texture;
|
|
79
|
-
uniform float u_shadowBlur;
|
|
80
|
-
uniform float u_size;
|
|
81
|
-
uniform vec4 u_shadowColor;
|
|
82
|
-
varying vec2 v_texcoord;
|
|
83
|
-
varying float v_scaledDistRange;
|
|
84
|
-
|
|
85
|
-
float median(float r, float g, float b) {
|
|
86
|
-
return clamp(b, min(r, g), max(r, g));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
void main() {
|
|
90
|
-
vec3 sample = texture2D(u_texture, v_texcoord).rgb;
|
|
91
|
-
float sigDist = v_scaledDistRange * (median(sample.r, sample.g, sample.b) - 0.5);
|
|
92
|
-
float opacity = clamp(sigDist + 0.5, 0.0, 1.0) * u_shadowColor.a;
|
|
93
|
-
|
|
94
|
-
// Build the final color.
|
|
95
|
-
// IMPORTANT: We must premultiply the color by the alpha value before returning it.
|
|
96
|
-
gl_FragColor = vec4(u_shadowColor.r * opacity, u_shadowColor.g * opacity, u_shadowColor.b * opacity, opacity);
|
|
97
|
-
}
|
|
98
|
-
`,
|
|
99
|
-
};
|
|
100
|
-
//# sourceMappingURL=SdfShadowShader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdfShadowShader.js","sourceRoot":"","sources":["../../../../../src/core/shaders/webgl/SdfShadowShader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,GAAG,EAAuB,MAAM,gBAAgB,CAAC;AAS1D,MAAM,CAAC,MAAM,SAAS,GAA0C;IAC9D,KAAK,EAAE;QACL,GAAI,GAAG,CAAC,KAAwB;QAChC,WAAW,EAAE,UAAU;QACvB,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,CAAC;QAChB,aAAa,EAAE,CAAC;KACjB;IACD,SAAS,CAAC,KAA2B;QACnC,GAAG,CAAC,SAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CACb,eAAe,EACf,2BAA2B,CAAC,KAAK,CAAC,WAAW,CAAC,CAC/C,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACjD,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7E,CAAC;IACD,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCP;IACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BT;CACF,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CoreFont, type CoreFontProps } from './CoreFont.js';
|
|
2
|
-
import type { NormalizedFontMetrics, TextRenderer } from './TextRenderer.js';
|
|
3
|
-
export type CanvasFontProps = CoreFontProps & {
|
|
4
|
-
url: string;
|
|
5
|
-
};
|
|
6
|
-
export declare class CanvasFont extends CoreFont {
|
|
7
|
-
private measureContext;
|
|
8
|
-
type: string;
|
|
9
|
-
url: string;
|
|
10
|
-
constructor(textRenderer: TextRenderer, props: CanvasFontProps, measureContext: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D);
|
|
11
|
-
load(): void;
|
|
12
|
-
measureText(text: string, letterSpacing: number): number;
|
|
13
|
-
getMetrics(fontSize: number): NormalizedFontMetrics;
|
|
14
|
-
}
|
|
@@ -1,111 +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 2025 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
|
-
import { CoreFont, FontState } from './CoreFont.js';
|
|
20
|
-
import { normalizeFontMetrics } from './TextLayoutEngine.js';
|
|
21
|
-
import { hasZeroWidthSpace } from './Utils.js';
|
|
22
|
-
export class CanvasFont extends CoreFont {
|
|
23
|
-
measureContext;
|
|
24
|
-
type = 'canvas';
|
|
25
|
-
url;
|
|
26
|
-
constructor(textRenderer, props, measureContext) {
|
|
27
|
-
super(textRenderer, props);
|
|
28
|
-
this.measureContext = measureContext;
|
|
29
|
-
this.url = props.url;
|
|
30
|
-
this.metrics = props.metrics;
|
|
31
|
-
}
|
|
32
|
-
load() {
|
|
33
|
-
if (this.state !== FontState.Created) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.state = FontState.Loading;
|
|
37
|
-
const waitingNodes = this.waitingNodes;
|
|
38
|
-
new FontFace(this.family, `url(${this.url})`)
|
|
39
|
-
.load()
|
|
40
|
-
.then((loadedFont) => {
|
|
41
|
-
document.fonts.add(loadedFont);
|
|
42
|
-
this.onLoaded();
|
|
43
|
-
})
|
|
44
|
-
.catch((error) => {
|
|
45
|
-
this.state = FontState.Failed;
|
|
46
|
-
console.error(`Failed to load font: ${this.family}`, error);
|
|
47
|
-
this.emit('failed');
|
|
48
|
-
throw error;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
measureText(text, letterSpacing) {
|
|
52
|
-
if (letterSpacing === 0) {
|
|
53
|
-
return this.measureContext.measureText(text).width;
|
|
54
|
-
}
|
|
55
|
-
if (hasZeroWidthSpace(text) === false) {
|
|
56
|
-
return (this.measureContext.measureText(text).width +
|
|
57
|
-
letterSpacing * text.length);
|
|
58
|
-
}
|
|
59
|
-
return text.split('').reduce((acc, char) => {
|
|
60
|
-
if (hasZeroWidthSpace(char) === true) {
|
|
61
|
-
return acc;
|
|
62
|
-
}
|
|
63
|
-
return acc + this.measureContext.measureText(char).width + letterSpacing;
|
|
64
|
-
}, 0);
|
|
65
|
-
}
|
|
66
|
-
getMetrics(fontSize) {
|
|
67
|
-
let m = this.normalizedMetrics[fontSize];
|
|
68
|
-
if (m !== undefined) {
|
|
69
|
-
return m;
|
|
70
|
-
}
|
|
71
|
-
let metrics = this.metrics;
|
|
72
|
-
if (metrics === undefined) {
|
|
73
|
-
metrics = calculateCanvasMetrics(this.family, fontSize, this.measureContext);
|
|
74
|
-
}
|
|
75
|
-
m = this.normalizedMetrics[fontSize] = normalizeFontMetrics(metrics, fontSize);
|
|
76
|
-
return m;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function calculateCanvasMetrics(fontFamily, fontSize, measureContext) {
|
|
80
|
-
// If the font face doesn't have metrics defined, we fallback to using the
|
|
81
|
-
// browser's measureText method to calculate take a best guess at the font
|
|
82
|
-
// actual font's metrics.
|
|
83
|
-
// - fontBoundingBox[Ascent|Descent] is the best estimate but only supported
|
|
84
|
-
// in Chrome 87+ (2020), Firefox 116+ (2023), and Safari 11.1+ (2018).
|
|
85
|
-
// - It is an estimate as it can vary between browsers.
|
|
86
|
-
// - actualBoundingBox[Ascent|Descent] is less accurate and supported in
|
|
87
|
-
// Chrome 77+ (2019), Firefox 74+ (2020), and Safari 11.1+ (2018).
|
|
88
|
-
// - If neither are supported, we'll use some default values which will
|
|
89
|
-
// get text on the screen but likely not be great.
|
|
90
|
-
// NOTE: It's been decided not to rely on fontBoundingBox[Ascent|Descent]
|
|
91
|
-
// as it's browser support is limited and it also tends to produce higher than
|
|
92
|
-
// expected values. It is instead HIGHLY RECOMMENDED that developers provide
|
|
93
|
-
// explicit metrics in the font face definition.
|
|
94
|
-
measureContext.font = `normal ${fontSize}px Unknown, ${fontFamily}`;
|
|
95
|
-
const metrics = measureContext.measureText('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
|
|
96
|
-
console.warn(`Font metrics not provided for Canvas Web font ${fontFamily}. ` +
|
|
97
|
-
'Using fallback values. It is HIGHLY recommended you use the latest ' +
|
|
98
|
-
'version of the Lightning 3 `msdf-generator` tool to extract the default ' +
|
|
99
|
-
'metrics for the font and provide them in the Canvas Web font definition.');
|
|
100
|
-
const ascender = metrics.fontBoundingBoxAscent ?? metrics.actualBoundingBoxAscent ?? 0;
|
|
101
|
-
const descender = metrics.fontBoundingBoxDescent ?? metrics.actualBoundingBoxDescent ?? 0;
|
|
102
|
-
return {
|
|
103
|
-
ascender,
|
|
104
|
-
descender: -descender,
|
|
105
|
-
lineGap: (metrics.emHeightAscent ?? 0) +
|
|
106
|
-
(metrics.emHeightDescent ?? 0) -
|
|
107
|
-
(ascender + descender),
|
|
108
|
-
unitsPerEm: (metrics.emHeightAscent ?? 0) + (metrics.emHeightDescent ?? 0),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=CanvasFont.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasFont.js","sourceRoot":"","sources":["../../../../src/core/text-rendering/CanvasFont.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAsB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,M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