@lightningjs/renderer 2.6.1 → 2.7.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.
- package/dist/src/core/CoreNode.d.ts +6 -1
- package/dist/src/core/CoreNode.js +109 -64
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js +40 -3
- package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.d.ts +9 -1
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js +68 -0
- package/dist/src/core/renderers/canvas/internal/C2DShaderUtils.js.map +1 -1
- package/dist/src/core/renderers/canvas/internal/ColorUtils.d.ts +4 -0
- package/dist/src/core/renderers/canvas/internal/ColorUtils.js +13 -0
- package/dist/src/core/renderers/canvas/internal/ColorUtils.js.map +1 -1
- package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js +3 -3
- package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +23 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +65 -9
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +18 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +1 -1
- package/dist/src/main-api/Inspector.js +17 -15
- package/dist/src/main-api/Inspector.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/CoreNode.ts +125 -73
- package/src/core/renderers/canvas/CanvasCoreRenderer.ts +91 -2
- package/src/core/renderers/canvas/internal/C2DShaderUtils.ts +102 -1
- package/src/core/renderers/canvas/internal/ColorUtils.ts +14 -0
- package/src/core/renderers/canvas/shaders/UnsupportedShader.ts +3 -3
- package/src/core/renderers/webgl/WebGlCoreCtxTexture.ts +4 -1
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +78 -9
- package/src/core/renderers/webgl/shaders/effects/RadiusEffect.ts +0 -2
- package/src/core/renderers/webgl/shaders/effects/ShaderEffect.ts +0 -1
- package/src/main-api/Inspector.ts +23 -15
|
@@ -30,9 +30,10 @@ import {
|
|
|
30
30
|
type QuadOptions,
|
|
31
31
|
} from '../CoreRenderer.js';
|
|
32
32
|
import { CanvasCoreTexture } from './CanvasCoreTexture.js';
|
|
33
|
-
import { getRadius } from './internal/C2DShaderUtils.js';
|
|
33
|
+
import { getBorder, getRadius, strokeLine } from './internal/C2DShaderUtils.js';
|
|
34
34
|
import {
|
|
35
35
|
formatRgba,
|
|
36
|
+
parseColorRgba,
|
|
36
37
|
parseColor,
|
|
37
38
|
type IParsedColor,
|
|
38
39
|
} from './internal/ColorUtils.js';
|
|
@@ -133,7 +134,9 @@ export class CanvasCoreRenderer extends CoreRenderer {
|
|
|
133
134
|
const hasTransform = ta !== 1;
|
|
134
135
|
const hasClipping = clippingRect.width !== 0 && clippingRect.height !== 0;
|
|
135
136
|
const hasGradient = colorTl !== colorTr || colorTl !== colorBr;
|
|
136
|
-
const
|
|
137
|
+
const hasQuadShader = Boolean(quad.shader);
|
|
138
|
+
const radius = hasQuadShader ? getRadius(quad) : 0;
|
|
139
|
+
const border = hasQuadShader ? getBorder(quad) : undefined;
|
|
137
140
|
|
|
138
141
|
if (hasTransform || hasClipping || radius) {
|
|
139
142
|
ctx.save();
|
|
@@ -211,6 +214,92 @@ export class CanvasCoreRenderer extends CoreRenderer {
|
|
|
211
214
|
ctx.fillRect(tx, ty, width, height);
|
|
212
215
|
}
|
|
213
216
|
|
|
217
|
+
if (border && border.width) {
|
|
218
|
+
const borderWidth = border.width;
|
|
219
|
+
const borderInnerWidth = border.width / 2;
|
|
220
|
+
const borderColor = formatRgba(parseColorRgba(border.color ?? 0));
|
|
221
|
+
|
|
222
|
+
ctx.beginPath();
|
|
223
|
+
ctx.lineWidth = borderWidth;
|
|
224
|
+
ctx.strokeStyle = borderColor;
|
|
225
|
+
ctx.globalAlpha = alpha;
|
|
226
|
+
if (radius) {
|
|
227
|
+
ctx.roundRect(
|
|
228
|
+
tx + borderInnerWidth,
|
|
229
|
+
ty + borderInnerWidth,
|
|
230
|
+
width - borderWidth,
|
|
231
|
+
height - borderWidth,
|
|
232
|
+
radius,
|
|
233
|
+
);
|
|
234
|
+
ctx.stroke();
|
|
235
|
+
} else {
|
|
236
|
+
ctx.strokeRect(
|
|
237
|
+
tx + borderInnerWidth,
|
|
238
|
+
ty + borderInnerWidth,
|
|
239
|
+
width - borderWidth,
|
|
240
|
+
height - borderWidth,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
ctx.globalAlpha = 1;
|
|
244
|
+
} else if (hasQuadShader) {
|
|
245
|
+
const borderTop = getBorder(quad, 'Top');
|
|
246
|
+
const borderRight = getBorder(quad, 'Right');
|
|
247
|
+
const borderBottom = getBorder(quad, 'Bottom');
|
|
248
|
+
const borderLeft = getBorder(quad, 'Left');
|
|
249
|
+
|
|
250
|
+
if (borderTop) {
|
|
251
|
+
strokeLine(
|
|
252
|
+
ctx,
|
|
253
|
+
tx,
|
|
254
|
+
ty,
|
|
255
|
+
width,
|
|
256
|
+
height,
|
|
257
|
+
borderTop.width,
|
|
258
|
+
borderTop.color,
|
|
259
|
+
'Top',
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (borderRight) {
|
|
264
|
+
strokeLine(
|
|
265
|
+
ctx,
|
|
266
|
+
tx,
|
|
267
|
+
ty,
|
|
268
|
+
width,
|
|
269
|
+
height,
|
|
270
|
+
borderRight.width,
|
|
271
|
+
borderRight.color,
|
|
272
|
+
'Right',
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (borderBottom) {
|
|
277
|
+
strokeLine(
|
|
278
|
+
ctx,
|
|
279
|
+
tx,
|
|
280
|
+
ty,
|
|
281
|
+
width,
|
|
282
|
+
height,
|
|
283
|
+
borderBottom.width,
|
|
284
|
+
borderBottom.color,
|
|
285
|
+
'Bottom',
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (borderLeft) {
|
|
290
|
+
strokeLine(
|
|
291
|
+
ctx,
|
|
292
|
+
tx,
|
|
293
|
+
ty,
|
|
294
|
+
width,
|
|
295
|
+
height,
|
|
296
|
+
borderLeft.width,
|
|
297
|
+
borderLeft.color,
|
|
298
|
+
'Left',
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
214
303
|
if (hasTransform || hasClipping || radius) {
|
|
215
304
|
ctx.restore();
|
|
216
305
|
}
|
|
@@ -18,20 +18,121 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type { QuadOptions } from '../../CoreRenderer.js';
|
|
21
|
+
import type { BorderEffectProps } from '../../webgl/shaders/effects/BorderEffect.js';
|
|
22
|
+
import type { RadiusEffectProps } from '../../webgl/shaders/effects/RadiusEffect.js';
|
|
23
|
+
import type { EffectDescUnion } from '../../webgl/shaders/effects/ShaderEffect.js';
|
|
21
24
|
import {
|
|
22
25
|
ROUNDED_RECTANGLE_SHADER_TYPE,
|
|
23
26
|
UnsupportedShader,
|
|
24
27
|
} from '../shaders/UnsupportedShader.js';
|
|
28
|
+
import { formatRgba, parseColorRgba } from './ColorUtils.js';
|
|
29
|
+
|
|
30
|
+
type Direction = 'Top' | 'Right' | 'Bottom' | 'Left';
|
|
25
31
|
|
|
26
32
|
/**
|
|
27
33
|
* Extract `RoundedRectangle` shader radius to apply as a clipping
|
|
28
34
|
*/
|
|
29
|
-
export function getRadius(quad: QuadOptions):
|
|
35
|
+
export function getRadius(quad: QuadOptions): RadiusEffectProps['radius'] {
|
|
30
36
|
if (quad.shader instanceof UnsupportedShader) {
|
|
31
37
|
const shType = quad.shader.shType;
|
|
32
38
|
if (shType === ROUNDED_RECTANGLE_SHADER_TYPE) {
|
|
33
39
|
return (quad.shaderProps?.radius as number) ?? 0;
|
|
40
|
+
} else if (shType === 'DynamicShader') {
|
|
41
|
+
const effects = quad.shaderProps?.effects as
|
|
42
|
+
| EffectDescUnion[]
|
|
43
|
+
| undefined;
|
|
44
|
+
|
|
45
|
+
if (effects) {
|
|
46
|
+
const effect = effects.find((effect: EffectDescUnion) => {
|
|
47
|
+
return effect.type === 'radius' && effect?.props?.radius;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (effect && effect.type === 'radius' && effect.props.radius) || 0;
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
54
|
return 0;
|
|
37
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Extract `RoundedRectangle` shader radius to apply as a clipping */
|
|
59
|
+
export function getBorder(
|
|
60
|
+
quad: QuadOptions,
|
|
61
|
+
direction: '' | Direction = '',
|
|
62
|
+
): BorderEffectProps | undefined {
|
|
63
|
+
if (quad.shader instanceof UnsupportedShader) {
|
|
64
|
+
const shType = quad.shader.shType;
|
|
65
|
+
if (shType === 'DynamicShader') {
|
|
66
|
+
const effects = quad.shaderProps?.effects as
|
|
67
|
+
| EffectDescUnion[]
|
|
68
|
+
| undefined;
|
|
69
|
+
|
|
70
|
+
if (effects && effects.length) {
|
|
71
|
+
const effect = effects.find((effect: EffectDescUnion) => {
|
|
72
|
+
return (
|
|
73
|
+
effect.type === `border${direction}` &&
|
|
74
|
+
effect.props &&
|
|
75
|
+
effect.props.width
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return effect && effect.props;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function strokeLine(
|
|
88
|
+
ctx: CanvasRenderingContext2D,
|
|
89
|
+
x: number,
|
|
90
|
+
y: number,
|
|
91
|
+
width: number,
|
|
92
|
+
height: number,
|
|
93
|
+
lineWidth = 0,
|
|
94
|
+
color: number | undefined,
|
|
95
|
+
direction: Direction,
|
|
96
|
+
) {
|
|
97
|
+
if (!lineWidth) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let sx,
|
|
102
|
+
sy = 0;
|
|
103
|
+
let ex,
|
|
104
|
+
ey = 0;
|
|
105
|
+
|
|
106
|
+
switch (direction) {
|
|
107
|
+
case 'Top':
|
|
108
|
+
sx = x;
|
|
109
|
+
sy = y;
|
|
110
|
+
ex = width + x;
|
|
111
|
+
ey = y;
|
|
112
|
+
break;
|
|
113
|
+
case 'Right':
|
|
114
|
+
sx = x + width;
|
|
115
|
+
sy = y;
|
|
116
|
+
ex = x + width;
|
|
117
|
+
ey = y + height;
|
|
118
|
+
break;
|
|
119
|
+
case 'Bottom':
|
|
120
|
+
sx = x;
|
|
121
|
+
sy = y + height;
|
|
122
|
+
ex = x + width;
|
|
123
|
+
ey = y + height;
|
|
124
|
+
break;
|
|
125
|
+
case 'Left':
|
|
126
|
+
sx = x;
|
|
127
|
+
sy = y;
|
|
128
|
+
ex = x;
|
|
129
|
+
ey = y + height;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
ctx.beginPath();
|
|
133
|
+
ctx.lineWidth = lineWidth;
|
|
134
|
+
ctx.strokeStyle = formatRgba(parseColorRgba(color ?? 0));
|
|
135
|
+
ctx.moveTo(sx, sy);
|
|
136
|
+
ctx.lineTo(ex, ey);
|
|
137
|
+
ctx.stroke();
|
|
138
|
+
}
|
|
@@ -47,6 +47,20 @@ export function parseColor(abgr: number): IParsedColor {
|
|
|
47
47
|
return { isWhite: false, a, r, g, b };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Extract color components
|
|
52
|
+
*/
|
|
53
|
+
export function parseColorRgba(rgba: number): IParsedColor {
|
|
54
|
+
if (rgba === 0xffffffff) {
|
|
55
|
+
return WHITE;
|
|
56
|
+
}
|
|
57
|
+
const r = (rgba >>> 24) & 0xff;
|
|
58
|
+
const g = (rgba >>> 16) & 0xff & 0xff;
|
|
59
|
+
const b = (rgba >>> 8) & 0xff & 0xff;
|
|
60
|
+
const a = (rgba & 0xff & 0xff) / 255;
|
|
61
|
+
return { isWhite: false, r, g, b, a };
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
/**
|
|
51
65
|
* Format a parsed color into a rgba CSS color
|
|
52
66
|
*/
|
|
@@ -27,9 +27,9 @@ export class UnsupportedShader extends CoreShader {
|
|
|
27
27
|
constructor(shType: string) {
|
|
28
28
|
super();
|
|
29
29
|
this.shType = shType;
|
|
30
|
-
if (shType !== ROUNDED_RECTANGLE_SHADER_TYPE) {
|
|
31
|
-
|
|
32
|
-
}
|
|
30
|
+
// if (shType !== ROUNDED_RECTANGLE_SHADER_TYPE) {
|
|
31
|
+
// console.warn('Unsupported shader:', shType);
|
|
32
|
+
// }
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
bindRenderOp(): void {
|
|
@@ -88,7 +88,10 @@ export class WebGlCoreCtxTexture extends CoreContextTexture {
|
|
|
88
88
|
this._nativeCtxTexture = this.createNativeCtxTexture();
|
|
89
89
|
if (this._nativeCtxTexture === null) {
|
|
90
90
|
this._state = 'failed';
|
|
91
|
-
this.textureSource.setState(
|
|
91
|
+
this.textureSource.setState(
|
|
92
|
+
'failed',
|
|
93
|
+
new Error('Could not create WebGL Texture'),
|
|
94
|
+
);
|
|
92
95
|
console.error('Could not create WebGL Texture');
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
@@ -626,13 +626,88 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
-
|
|
630
|
-
|
|
629
|
+
this.insertRTTNodeInOrder(node);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Inserts an RTT node into `this.rttNodes` while maintaining the correct rendering order based on hierarchy.
|
|
634
|
+
*
|
|
635
|
+
* Rendering order for RTT nodes is critical when nested RTT nodes exist in a parent-child relationship.
|
|
636
|
+
* Specifically:
|
|
637
|
+
* - Child RTT nodes must be rendered before their RTT-enabled parents to ensure proper texture composition.
|
|
638
|
+
* - If an RTT node is added and it has existing RTT children, it should be rendered after those children.
|
|
639
|
+
*
|
|
640
|
+
* This function addresses both cases by:
|
|
641
|
+
* 1. **Checking Upwards**: It traverses the node's hierarchy upwards to identify any RTT parent
|
|
642
|
+
* already in `rttNodes`. If an RTT parent is found, the new node is placed before this parent.
|
|
643
|
+
* 2. **Checking Downwards**: It traverses the node’s children recursively to find any RTT-enabled
|
|
644
|
+
* children that are already in `rttNodes`. If such children are found, the new node is inserted
|
|
645
|
+
* after the last (highest index) RTT child node.
|
|
646
|
+
*
|
|
647
|
+
* The final calculated insertion index ensures the new node is positioned in `rttNodes` to respect
|
|
648
|
+
* both parent-before-child and child-before-parent rendering rules, preserving the correct order
|
|
649
|
+
* for the WebGL renderer.
|
|
650
|
+
*
|
|
651
|
+
* @param node - The RTT-enabled CoreNode to be added to `rttNodes` in the appropriate hierarchical position.
|
|
652
|
+
*/
|
|
653
|
+
private insertRTTNodeInOrder(node: CoreNode) {
|
|
654
|
+
let insertIndex = this.rttNodes.length; // Default to the end of the array
|
|
655
|
+
|
|
656
|
+
// 1. Traverse upwards to ensure the node is placed before its RTT parent (if any).
|
|
657
|
+
let currentNode: CoreNode = node;
|
|
658
|
+
while (currentNode) {
|
|
659
|
+
if (!currentNode.parent) {
|
|
660
|
+
break;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const parentIndex = this.rttNodes.indexOf(currentNode.parent);
|
|
664
|
+
if (parentIndex !== -1) {
|
|
665
|
+
// Found an RTT parent in the list; set insertIndex to place node before the parent
|
|
666
|
+
insertIndex = parentIndex;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
currentNode = currentNode.parent;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// 2. Traverse downwards to ensure the node is placed after any RTT children.
|
|
674
|
+
// Look through each child recursively to see if any are already in rttNodes.
|
|
675
|
+
const maxChildIndex = this.findMaxChildRTTIndex(node);
|
|
676
|
+
if (maxChildIndex !== -1) {
|
|
677
|
+
// Adjust insertIndex to be after the last child RTT node
|
|
678
|
+
insertIndex = Math.max(insertIndex, maxChildIndex + 1);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// 3. Insert the node at the calculated position
|
|
682
|
+
this.rttNodes.splice(insertIndex, 0, node);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// Helper function to find the highest index of any RTT children of a node within rttNodes
|
|
686
|
+
private findMaxChildRTTIndex(node: CoreNode): number {
|
|
687
|
+
let maxIndex = -1;
|
|
688
|
+
|
|
689
|
+
const traverseChildren = (currentNode: CoreNode) => {
|
|
690
|
+
const currentIndex = this.rttNodes.indexOf(currentNode);
|
|
691
|
+
if (currentIndex !== -1) {
|
|
692
|
+
maxIndex = Math.max(maxIndex, currentIndex);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// Recursively check all children of the current node
|
|
696
|
+
for (const child of currentNode.children) {
|
|
697
|
+
traverseChildren(child);
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
// Start traversal directly with the provided node
|
|
702
|
+
traverseChildren(node);
|
|
703
|
+
|
|
704
|
+
return maxIndex;
|
|
631
705
|
}
|
|
632
706
|
|
|
633
707
|
renderRTTNodes() {
|
|
634
708
|
const { glw } = this;
|
|
635
709
|
const { txManager } = this.stage;
|
|
710
|
+
|
|
636
711
|
// Render all associated RTT nodes to their textures
|
|
637
712
|
for (let i = 0; i < this.rttNodes.length; i++) {
|
|
638
713
|
const node = this.rttNodes[i];
|
|
@@ -662,16 +737,10 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
662
737
|
// Render all associated quads to the texture
|
|
663
738
|
for (let i = 0; i < node.children.length; i++) {
|
|
664
739
|
const child = node.children[i];
|
|
740
|
+
|
|
665
741
|
if (!child) {
|
|
666
742
|
continue;
|
|
667
743
|
}
|
|
668
|
-
child.update(this.stage.deltaTime, {
|
|
669
|
-
x: 0,
|
|
670
|
-
y: 0,
|
|
671
|
-
width: 0,
|
|
672
|
-
height: 0,
|
|
673
|
-
valid: false,
|
|
674
|
-
});
|
|
675
744
|
|
|
676
745
|
this.stage.addQuads(child);
|
|
677
746
|
child.hasRTTupdates = false;
|
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import type { DynamicShaderProps } from '../DynamicShader.js';
|
|
20
19
|
import { updateWebSafeRadius, validateArrayLength4 } from './EffectUtils.js';
|
|
21
20
|
import {
|
|
22
21
|
ShaderEffect,
|
|
23
22
|
type DefaultEffectProps,
|
|
24
23
|
type ShaderEffectUniforms,
|
|
25
|
-
type ShaderEffectValueMap,
|
|
26
24
|
} from './ShaderEffect.js';
|
|
27
25
|
|
|
28
26
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EffectMap } from '../../../../CoreShaderManager.js';
|
|
2
2
|
import type { ExtractProps } from '../../../../CoreTextureManager.js';
|
|
3
|
-
import type { WebGlContextWrapper } from '../../../../lib/WebGlContextWrapper.js';
|
|
4
3
|
import type {
|
|
5
4
|
AlphaShaderProp,
|
|
6
5
|
DimensionsShaderProp,
|
|
@@ -272,25 +272,33 @@ export class Inspector {
|
|
|
272
272
|
): CoreNode | CoreTextNode {
|
|
273
273
|
// Define traps for each property in knownProperties
|
|
274
274
|
knownProperties.forEach((property) => {
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
let originalProp = Object.getOwnPropertyDescriptor(node, property);
|
|
276
|
+
|
|
277
|
+
if (originalProp === undefined) {
|
|
278
|
+
// Search the prototype chain for the property descriptor
|
|
279
|
+
const proto = Object.getPrototypeOf(node) as CoreNode | CoreTextNode;
|
|
280
|
+
originalProp = Object.getOwnPropertyDescriptor(proto, property);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (originalProp === undefined) {
|
|
277
284
|
return;
|
|
278
285
|
}
|
|
279
286
|
|
|
280
|
-
Object.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
set(value)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
enumerable: true,
|
|
287
|
+
Object.defineProperty(node, property, {
|
|
288
|
+
get() {
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
290
|
+
return originalProp?.get?.call(node);
|
|
291
|
+
},
|
|
292
|
+
set: (value) => {
|
|
293
|
+
originalProp?.set?.call(node, value);
|
|
294
|
+
this.updateNodeProperty(
|
|
295
|
+
div,
|
|
296
|
+
property as keyof CoreNodeProps | keyof CoreTextNodeProps,
|
|
297
|
+
value,
|
|
298
|
+
);
|
|
293
299
|
},
|
|
300
|
+
configurable: true,
|
|
301
|
+
enumerable: true,
|
|
294
302
|
});
|
|
295
303
|
});
|
|
296
304
|
|