@lightningtv/solid 3.1.9 → 3.1.10

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.
@@ -235,9 +235,7 @@ function updateNodeParent(node: DOMNode | DOMText) {
235
235
  function updateNodeStyles(node: DOMNode | DOMText) {
236
236
  let { props } = node;
237
237
 
238
- let style = `position: absolute; z-index: ${props.zIndex};`;
239
-
240
- if (props.alpha !== 1) style += `opacity: ${props.alpha};`;
238
+ let style = `position: absolute; z-index: ${props.zIndex}; opacity: ${props.alpha ?? 1};`;
241
239
 
242
240
  if (props.clipping) {
243
241
  style += `overflow: hidden;`;
@@ -273,6 +271,12 @@ function updateNodeStyles(node: DOMNode | DOMText) {
273
271
  if (transform.length > 0) {
274
272
  style += `transform: ${transform};`;
275
273
  }
274
+
275
+ let pivotX = props.pivotX ?? props.pivot ?? 0.5;
276
+ let pivotY = props.pivotY ?? props.pivot ?? 0.5;
277
+ if (pivotX !== 0.5 || pivotY !== 0.5) {
278
+ style += `transform-origin: ${pivotX * 100}% ${pivotY * 100}%;`;
279
+ }
276
280
  }
277
281
 
278
282
  // <Text>
@@ -297,7 +301,7 @@ function updateNodeStyles(node: DOMNode | DOMText) {
297
301
  if (textProps.fontStretch && textProps.fontStretch !== 'normal') {
298
302
  style += `font-stretch: ${textProps.fontStretch};`;
299
303
  }
300
- if (textProps.lineHeight != null) {
304
+ if (textProps.lineHeight) {
301
305
  style += `line-height: ${textProps.lineHeight}px;`;
302
306
  }
303
307
  if (textProps.letterSpacing) {
@@ -358,6 +362,25 @@ function updateNodeStyles(node: DOMNode | DOMText) {
358
362
  -webkit-box-orient: vertical;`;
359
363
  }
360
364
 
365
+ if (textProps.offsetY != null && textProps.offsetY !== 0) {
366
+ style += `margin-top: ${textProps.offsetY}px;`;
367
+ }
368
+
369
+ if (textProps.wordBreak) {
370
+ const wb = textProps.wordBreak as string;
371
+ if (wb !== 'normal') {
372
+ if (wb === 'break-all') {
373
+ style += `word-break: break-all;`;
374
+ } else if (wb === 'keep-all') {
375
+ style += `word-break: keep-all;`;
376
+ } else if (wb === 'break-word') {
377
+ style += `word-wrap: break-word; overflow-wrap: break-word;`;
378
+ } else {
379
+ style += `overflow-wrap: break-word;`;
380
+ }
381
+ }
382
+ }
383
+
361
384
  // if (node.overflowSuffix) style += `overflow-suffix: ${node.overflowSuffix};`
362
385
  // if (node.verticalAlign) style += `vertical-align: ${node.verticalAlign};`
363
386
  }
@@ -491,7 +514,7 @@ function updateNodeStyles(node: DOMNode | DOMText) {
491
514
  let borderWidth = shaderProps['border-w'];
492
515
  let borderColor = shaderProps['border-color'];
493
516
  let borderGap = shaderProps['border-gap'] ?? 0;
494
- let borderInset = shaderProps['border-inset'] ?? true;
517
+ let borderAlign = shaderProps['border-align'] ?? 'outside';
495
518
  let radius = shaderProps['radius'];
496
519
 
497
520
  // Border
@@ -502,8 +525,14 @@ function updateNodeStyles(node: DOMNode | DOMText) {
502
525
  borderColor !== 0
503
526
  ) {
504
527
  const rgbaColor = colorToRgba(borderColor);
505
- // Handle inset borders by making gap negative
506
- let gap = borderInset ? -(borderWidth + borderGap) : borderGap;
528
+
529
+ let gap = borderGap;
530
+ if (borderAlign === 'inside') {
531
+ gap = -(borderWidth + borderGap);
532
+ } else if (borderAlign === 'center') {
533
+ gap = -(borderWidth / 2) + borderGap;
534
+ }
535
+
507
536
  borderStyle += `outline: ${borderWidth}px solid ${rgbaColor};`;
508
537
  borderStyle += `outline-offset: ${gap}px;`;
509
538
  }
@@ -832,16 +861,14 @@ function updateDOMTextSize(node: DOMText): void {
832
861
  case 'width':
833
862
  size = getElSize(node);
834
863
  if (node.props.h !== size.height) {
835
- node.props.h = size.height;
836
- updateNodeStyles(node);
864
+ node.h = size.height;
837
865
  }
838
866
  break;
839
867
  case 'none':
840
868
  size = getElSize(node);
841
869
  if (node.props.h !== size.height || node.props.w !== size.width) {
842
- node.props.w = size.width;
843
- node.props.h = size.height;
844
- updateNodeStyles(node);
870
+ node.w = size.width;
871
+ node.h = size.height;
845
872
  }
846
873
  break;
847
874
  }
@@ -1291,69 +1318,98 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1291
1318
  set scale(v) {
1292
1319
  if (this.props.scale === v) return;
1293
1320
  this.props.scale = v;
1321
+ this.boundsDirty = true;
1322
+ this.markChildrenBoundsDirty();
1294
1323
  updateNodeStyles(this);
1295
1324
  }
1296
1325
  get scaleX() {
1297
1326
  return this.props.scaleX;
1298
1327
  }
1299
1328
  set scaleX(v) {
1329
+ if (this.props.scaleX === v) return;
1300
1330
  this.props.scaleX = v;
1331
+ this.boundsDirty = true;
1332
+ this.markChildrenBoundsDirty();
1301
1333
  updateNodeStyles(this);
1302
1334
  }
1303
1335
  get scaleY() {
1304
1336
  return this.props.scaleY;
1305
1337
  }
1306
1338
  set scaleY(v) {
1339
+ if (this.props.scaleY === v) return;
1307
1340
  this.props.scaleY = v;
1341
+ this.boundsDirty = true;
1342
+ this.markChildrenBoundsDirty();
1308
1343
  updateNodeStyles(this);
1309
1344
  }
1310
1345
  get mount() {
1311
1346
  return this.props.mount;
1312
1347
  }
1313
1348
  set mount(v) {
1349
+ if (this.props.mount === v) return;
1314
1350
  this.props.mount = v;
1351
+ this.boundsDirty = true;
1352
+ this.markChildrenBoundsDirty();
1315
1353
  updateNodeStyles(this);
1316
1354
  }
1317
1355
  get mountX() {
1318
1356
  return this.props.mountX;
1319
1357
  }
1320
1358
  set mountX(v) {
1359
+ if (this.props.mountX === v) return;
1321
1360
  this.props.mountX = v;
1361
+ this.boundsDirty = true;
1362
+ this.markChildrenBoundsDirty();
1322
1363
  updateNodeStyles(this);
1323
1364
  }
1324
1365
  get mountY() {
1325
1366
  return this.props.mountY;
1326
1367
  }
1327
1368
  set mountY(v) {
1369
+ if (this.props.mountY === v) return;
1328
1370
  this.props.mountY = v;
1371
+ this.boundsDirty = true;
1372
+ this.markChildrenBoundsDirty();
1329
1373
  updateNodeStyles(this);
1330
1374
  }
1331
1375
  get pivot() {
1332
1376
  return this.props.pivot;
1333
1377
  }
1334
1378
  set pivot(v) {
1379
+ if (this.props.pivot === v) return;
1335
1380
  this.props.pivot = v;
1381
+ this.boundsDirty = true;
1382
+ this.markChildrenBoundsDirty();
1336
1383
  updateNodeStyles(this);
1337
1384
  }
1338
1385
  get pivotX() {
1339
1386
  return this.props.pivotX;
1340
1387
  }
1341
1388
  set pivotX(v) {
1389
+ if (this.props.pivotX === v) return;
1342
1390
  this.props.pivotX = v;
1391
+ this.boundsDirty = true;
1392
+ this.markChildrenBoundsDirty();
1343
1393
  updateNodeStyles(this);
1344
1394
  }
1345
1395
  get pivotY() {
1346
1396
  return this.props.pivotY;
1347
1397
  }
1348
1398
  set pivotY(v) {
1399
+ if (this.props.pivotY === v) return;
1349
1400
  this.props.pivotY = v;
1401
+ this.boundsDirty = true;
1402
+ this.markChildrenBoundsDirty();
1350
1403
  updateNodeStyles(this);
1351
1404
  }
1352
1405
  get rotation() {
1353
1406
  return this.props.rotation;
1354
1407
  }
1355
1408
  set rotation(v) {
1409
+ if (this.props.rotation === v) return;
1356
1410
  this.props.rotation = v;
1411
+ this.boundsDirty = true;
1412
+ this.markChildrenBoundsDirty();
1357
1413
  updateNodeStyles(this);
1358
1414
  }
1359
1415
  get rtt() {
@@ -43,7 +43,7 @@ export function getNodeLineHeight(props: {
43
43
  fontSize: number;
44
44
  }): number {
45
45
  return (
46
- props.lineHeight ?? Config.fontSettings.lineHeight ?? 1.2 * props.fontSize
46
+ props.lineHeight || Config.fontSettings.lineHeight || 1.2 * props.fontSize
47
47
  );
48
48
  }
49
49
 
@@ -184,10 +184,11 @@ function interpolate(start: number, end: number, t: number): number {
184
184
 
185
185
  function interpolateColor(start: number, end: number, t: number): number {
186
186
  return (
187
- (interpolate((start >> 24) & 0xff, (end >> 24) & 0xff, t) << 24) |
188
- (interpolate((start >> 16) & 0xff, (end >> 16) & 0xff, t) << 16) |
189
- (interpolate((start >> 8) & 0xff, (end >> 8) & 0xff, t) << 8) |
190
- interpolate(start & 0xff, end & 0xff, t)
187
+ ((interpolate((start >> 24) & 0xff, (end >> 24) & 0xff, t) << 24) |
188
+ (interpolate((start >> 16) & 0xff, (end >> 16) & 0xff, t) << 16) |
189
+ (interpolate((start >> 8) & 0xff, (end >> 8) & 0xff, t) << 8) |
190
+ interpolate(start & 0xff, end & 0xff, t)) >>>
191
+ 0
191
192
  );
192
193
  }
193
194
 
@@ -786,7 +786,8 @@ export class ElementNode extends Object {
786
786
  (Config.fontWeightAlias &&
787
787
  (Config.fontWeightAlias[v as string] as number | string)) ??
788
788
  v;
789
- (this.lng as any).fontFamily = `${this.fontFamily}${weight}`;
789
+ (this.lng as any).fontFamily =
790
+ `${this.fontFamily || Config.fontSettings?.fontFamily}${weight}`;
790
791
  }
791
792
 
792
793
  get fontWeight() {
@@ -799,7 +800,7 @@ export class ElementNode extends Object {
799
800
  }
800
801
 
801
802
  get fontFamily() {
802
- return this._fontFamily || Config.fontSettings?.fontFamily;
803
+ return this._fontFamily;
803
804
  }
804
805
 
805
806
  insertChild(
@@ -1077,10 +1078,7 @@ export class ElementNode extends Object {
1077
1078
  // Keys set in JSX are more important
1078
1079
  for (const key in this._style) {
1079
1080
  // be careful of 0 values
1080
- if (
1081
- this[key as keyof Styles] === undefined ||
1082
- (key === 'fontFamily' && this._fontFamily === undefined)
1083
- ) {
1081
+ if (this[key as keyof Styles] === undefined) {
1084
1082
  this[key as keyof Styles] = this._style[key as keyof Styles];
1085
1083
  }
1086
1084
  }
@@ -23,13 +23,19 @@ export type AddColorString<T> = {
23
23
  [K in keyof T]: K extends `color${string}` ? string | number : T[K];
24
24
  };
25
25
 
26
- export interface BorderStyleObject extends Partial<lngr.BorderProps> {
26
+ export interface BorderStyleObject
27
+ extends AddColorString<Partial<lngr.BorderProps>> {
27
28
  width?: number | [number, number, number, number];
29
+ gap?: number;
30
+ align?: 'inside' | 'outside' | 'center';
28
31
  }
29
32
 
30
- export interface SingleBorderStyleObject extends Partial<lngr.BorderProps> {
33
+ export interface SingleBorderStyleObject
34
+ extends AddColorString<Partial<lngr.BorderProps>> {
31
35
  width?: number;
32
36
  w?: number;
37
+ gap?: number;
38
+ align?: 'inside' | 'outside' | 'center';
33
39
  }
34
40
 
35
41
  export type DollarString = `$${string}`;