@lightningjs/renderer 3.0.0-beta11 → 3.0.0-beta12

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 (132) hide show
  1. package/dist/src/common/CommonTypes.d.ts +2 -2
  2. package/dist/src/core/CoreNode.d.ts +8 -7
  3. package/dist/src/core/CoreNode.js +57 -61
  4. package/dist/src/core/CoreNode.js.map +1 -1
  5. package/dist/src/core/CoreTextNode.js +9 -9
  6. package/dist/src/core/CoreTextNode.js.map +1 -1
  7. package/dist/src/core/Stage.js +4 -4
  8. package/dist/src/core/Stage.js.map +1 -1
  9. package/dist/src/core/lib/textureCompression.js +4 -4
  10. package/dist/src/core/lib/textureCompression.js.map +1 -1
  11. package/dist/src/core/renderers/CoreShaderNode.js +2 -2
  12. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
  13. package/dist/src/core/renderers/canvas/CanvasRenderer.js +1 -1
  14. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
  15. package/dist/src/core/renderers/canvas/CanvasTexture.js +5 -5
  16. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -1
  17. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +5 -6
  18. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -1
  19. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +13 -0
  20. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +34 -5
  21. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -1
  22. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +21 -21
  23. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
  24. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +1 -1
  25. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -1
  26. package/dist/src/core/renderers/webgl/WebGlRenderer.js +12 -11
  27. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
  28. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +2 -2
  29. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
  30. package/dist/src/core/shaders/canvas/Border.js +4 -4
  31. package/dist/src/core/shaders/canvas/Border.js.map +1 -1
  32. package/dist/src/core/shaders/canvas/HolePunch.js +3 -3
  33. package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
  34. package/dist/src/core/shaders/canvas/LinearGradient.js +2 -2
  35. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
  36. package/dist/src/core/shaders/canvas/RadialGradient.js +4 -4
  37. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
  38. package/dist/src/core/shaders/canvas/Rounded.js +1 -1
  39. package/dist/src/core/shaders/canvas/Rounded.js.map +1 -1
  40. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +3 -3
  41. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
  42. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +3 -3
  43. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
  44. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +1 -1
  45. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
  46. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +1 -1
  47. package/dist/src/core/shaders/templates/BorderTemplate.js +10 -10
  48. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
  49. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +2 -2
  50. package/dist/src/core/shaders/templates/HolePunchTemplate.js +2 -2
  51. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
  52. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +2 -2
  53. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +2 -2
  54. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -1
  55. package/dist/src/core/shaders/webgl/Border.js +1 -1
  56. package/dist/src/core/shaders/webgl/Border.js.map +1 -1
  57. package/dist/src/core/shaders/webgl/HolePunch.js +2 -2
  58. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
  59. package/dist/src/core/shaders/webgl/RadialGradient.js +2 -2
  60. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
  61. package/dist/src/core/shaders/webgl/Rounded.js +1 -1
  62. package/dist/src/core/shaders/webgl/Rounded.js.map +1 -1
  63. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +2 -2
  64. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
  65. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +2 -2
  66. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
  67. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +1 -1
  68. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -1
  69. package/dist/src/core/textures/ColorTexture.js +1 -1
  70. package/dist/src/core/textures/ColorTexture.js.map +1 -1
  71. package/dist/src/core/textures/ImageTexture.d.ts +2 -2
  72. package/dist/src/core/textures/ImageTexture.js +11 -11
  73. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  74. package/dist/src/core/textures/NoiseTexture.d.ts +2 -2
  75. package/dist/src/core/textures/NoiseTexture.js +6 -6
  76. package/dist/src/core/textures/NoiseTexture.js.map +1 -1
  77. package/dist/src/core/textures/RenderTexture.d.ts +6 -6
  78. package/dist/src/core/textures/RenderTexture.js +10 -10
  79. package/dist/src/core/textures/RenderTexture.js.map +1 -1
  80. package/dist/src/core/textures/SubTexture.d.ts +4 -4
  81. package/dist/src/core/textures/SubTexture.js +8 -8
  82. package/dist/src/core/textures/SubTexture.js.map +1 -1
  83. package/dist/src/core/textures/Texture.d.ts +3 -4
  84. package/dist/src/core/textures/Texture.js +4 -4
  85. package/dist/src/core/textures/Texture.js.map +1 -1
  86. package/dist/src/main-api/Inspector.js +7 -7
  87. package/dist/src/main-api/Inspector.js.map +1 -1
  88. package/dist/src/main-api/Renderer.js +2 -2
  89. package/dist/src/main-api/Renderer.js.map +1 -1
  90. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  91. package/package.json +1 -1
  92. package/src/common/CommonTypes.ts +2 -2
  93. package/src/core/CoreNode.test.ts +12 -12
  94. package/src/core/CoreNode.ts +67 -77
  95. package/src/core/CoreTextNode.ts +9 -9
  96. package/src/core/Stage.ts +4 -4
  97. package/src/core/lib/textureCompression.ts +4 -4
  98. package/src/core/renderers/CoreShaderNode.ts +2 -2
  99. package/src/core/renderers/canvas/CanvasRenderer.ts +2 -2
  100. package/src/core/renderers/canvas/CanvasTexture.ts +5 -5
  101. package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +5 -15
  102. package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +50 -5
  103. package/src/core/renderers/webgl/WebGlCtxTexture.ts +21 -30
  104. package/src/core/renderers/webgl/WebGlRenderOp.ts +1 -1
  105. package/src/core/renderers/webgl/WebGlRenderer.ts +12 -13
  106. package/src/core/renderers/webgl/WebGlShaderProgram.ts +2 -2
  107. package/src/core/shaders/canvas/Border.ts +4 -4
  108. package/src/core/shaders/canvas/HolePunch.ts +4 -11
  109. package/src/core/shaders/canvas/LinearGradient.ts +2 -2
  110. package/src/core/shaders/canvas/RadialGradient.ts +4 -4
  111. package/src/core/shaders/canvas/Rounded.ts +2 -2
  112. package/src/core/shaders/canvas/RoundedWithBorder.ts +4 -6
  113. package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +4 -6
  114. package/src/core/shaders/canvas/RoundedWithShadow.ts +2 -2
  115. package/src/core/shaders/templates/BorderTemplate.ts +11 -11
  116. package/src/core/shaders/templates/HolePunchTemplate.ts +4 -4
  117. package/src/core/shaders/templates/RadialGradientTemplate.ts +4 -4
  118. package/src/core/shaders/webgl/Border.ts +1 -1
  119. package/src/core/shaders/webgl/HolePunch.ts +2 -2
  120. package/src/core/shaders/webgl/RadialGradient.ts +3 -3
  121. package/src/core/shaders/webgl/Rounded.ts +1 -5
  122. package/src/core/shaders/webgl/RoundedWithBorder.ts +2 -6
  123. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +2 -2
  124. package/src/core/shaders/webgl/RoundedWithShadow.ts +1 -5
  125. package/src/core/textures/ColorTexture.ts +1 -1
  126. package/src/core/textures/ImageTexture.ts +15 -15
  127. package/src/core/textures/NoiseTexture.ts +8 -8
  128. package/src/core/textures/RenderTexture.ts +12 -12
  129. package/src/core/textures/SubTexture.ts +10 -10
  130. package/src/core/textures/Texture.ts +7 -7
  131. package/src/main-api/Inspector.ts +8 -8
  132. package/src/main-api/Renderer.ts +2 -2
@@ -67,12 +67,12 @@ export interface ImageTextureProps {
67
67
  * Width of the image to be used as a texture. If not provided, the image's
68
68
  * natural width will be used.
69
69
  */
70
- width?: number | null;
70
+ w?: number | null;
71
71
  /**
72
72
  * Height of the image to be used as a texture. If not provided, the image's
73
73
  * natural height will be used.
74
74
  */
75
- height?: number | null;
75
+ h?: number | null;
76
76
  /**
77
77
  * Type, indicate an image type for overriding type detection
78
78
  *
@@ -276,21 +276,21 @@ export class ImageTexture extends Texture {
276
276
  };
277
277
  }
278
278
 
279
- let width, height;
279
+ let w, h;
280
280
  // check if resp.data is typeof Uint8ClampedArray else
281
281
  // use resp.data.width and resp.data.height
282
282
  if (resp.data instanceof Uint8Array) {
283
- width = this.props.width ?? 0;
284
- height = this.props.height ?? 0;
283
+ w = this.props.w ?? 0;
284
+ h = this.props.h ?? 0;
285
285
  } else {
286
- width = resp.data?.width ?? (this.props.width || 0);
287
- height = resp.data?.height ?? (this.props.height || 0);
286
+ w = resp.data?.width ?? (this.props.w || 0);
287
+ h = resp.data?.height ?? (this.props.h || 0);
288
288
  }
289
289
 
290
290
  // we're loaded!
291
291
  this.setState('fetched', {
292
- width,
293
- height,
292
+ w,
293
+ h,
294
294
  });
295
295
 
296
296
  return {
@@ -336,8 +336,8 @@ export class ImageTexture extends Texture {
336
336
  if (type === 'svg') {
337
337
  return loadSvg(
338
338
  absoluteSrc,
339
- this.props.width,
340
- this.props.height,
339
+ this.props.w,
340
+ this.props.h,
341
341
  this.props.sx,
342
342
  this.props.sy,
343
343
  this.props.sw,
@@ -348,8 +348,8 @@ export class ImageTexture extends Texture {
348
348
  if (isSvgImage(src) === true) {
349
349
  return loadSvg(
350
350
  absoluteSrc,
351
- this.props.width,
352
- this.props.height,
351
+ this.props.w,
352
+ this.props.h,
353
353
  this.props.sx,
354
354
  this.props.sy,
355
355
  this.props.sw,
@@ -405,8 +405,8 @@ export class ImageTexture extends Texture {
405
405
  premultiplyAlpha: props.premultiplyAlpha ?? true, // null,
406
406
  key: props.key ?? null,
407
407
  type: props.type ?? null,
408
- width: props.width ?? null,
409
- height: props.height ?? null,
408
+ w: props.w ?? null,
409
+ h: props.h ?? null,
410
410
  sx: props.sx ?? null,
411
411
  sy: props.sy ?? null,
412
412
  sw: props.sw ?? null,
@@ -29,13 +29,13 @@ export interface NoiseTextureProps {
29
29
  *
30
30
  * @default 128
31
31
  */
32
- width?: number;
32
+ w?: number;
33
33
  /**
34
34
  * Height of texture
35
35
  *
36
36
  * @default 128
37
37
  */
38
- height?: number;
38
+ h?: number;
39
39
  /**
40
40
  * A number value that can be varied to force new textures to be generated
41
41
  *
@@ -64,8 +64,8 @@ export class NoiseTexture extends Texture {
64
64
  }
65
65
 
66
66
  override async getTextureSource(): Promise<TextureData> {
67
- const { width, height } = this.props;
68
- const size = width * height * 4;
67
+ const { w, h } = this.props;
68
+ const size = w * h * 4;
69
69
  const pixelData8 = new Uint8ClampedArray(size);
70
70
  for (let i = 0; i < size; i += 4) {
71
71
  const v = Math.floor(Math.random() * 256);
@@ -78,7 +78,7 @@ export class NoiseTexture extends Texture {
78
78
  this.setState('fetched');
79
79
 
80
80
  return {
81
- data: new ImageData(pixelData8, width, height),
81
+ data: new ImageData(pixelData8, w, h),
82
82
  };
83
83
  }
84
84
 
@@ -87,15 +87,15 @@ export class NoiseTexture extends Texture {
87
87
  return false;
88
88
  }
89
89
  const resolvedProps = NoiseTexture.resolveDefaults(props);
90
- return `NoiseTexture,${resolvedProps.width},${resolvedProps.height},${resolvedProps.cacheId}`;
90
+ return `NoiseTexture,${resolvedProps.w},${resolvedProps.h},${resolvedProps.cacheId}`;
91
91
  }
92
92
 
93
93
  static override resolveDefaults(
94
94
  props: NoiseTextureProps,
95
95
  ): Required<NoiseTextureProps> {
96
96
  return {
97
- width: props.width ?? 128,
98
- height: props.height ?? 128,
97
+ w: props.w ?? 128,
98
+ h: props.h ?? 128,
99
99
  cacheId: props.cacheId ?? 0,
100
100
  };
101
101
  }
@@ -28,13 +28,13 @@ export interface RenderTextureProps {
28
28
  * WebGL Texture width
29
29
  * @default 256
30
30
  */
31
- width?: number;
31
+ w?: number;
32
32
 
33
33
  /**
34
34
  * WebGL Texture height
35
35
  * @default 256
36
36
  */
37
- height?: number;
37
+ h?: number;
38
38
  }
39
39
 
40
40
  export class RenderTexture extends Texture {
@@ -47,20 +47,20 @@ export class RenderTexture extends Texture {
47
47
  this.props = RenderTexture.resolveDefaults(props || {});
48
48
  }
49
49
 
50
- get width() {
51
- return this.props.width;
50
+ get w() {
51
+ return this.props.w;
52
52
  }
53
53
 
54
- set width(value: number) {
55
- this.props.width = value;
54
+ set w(value: number) {
55
+ this.props.w = value;
56
56
  }
57
57
 
58
- get height() {
59
- return this.props.height;
58
+ get h() {
59
+ return this.props.h;
60
60
  }
61
61
 
62
- set height(value: number) {
63
- this.props.height = value;
62
+ set h(value: number) {
63
+ this.props.h = value;
64
64
  }
65
65
 
66
66
  override async getTextureSource(): Promise<TextureData> {
@@ -76,8 +76,8 @@ export class RenderTexture extends Texture {
76
76
  props: RenderTextureProps,
77
77
  ): Required<RenderTextureProps> {
78
78
  return {
79
- width: props.width || 256,
80
- height: props.height || 256,
79
+ w: props.w || 256,
80
+ h: props.h || 256,
81
81
  };
82
82
  }
83
83
 
@@ -60,12 +60,12 @@ export interface SubTextureProps {
60
60
  *
61
61
  * @default 0
62
62
  */
63
- width?: number;
63
+ w?: number;
64
64
 
65
65
  /**
66
66
  * The height of the sub-texture in pixels
67
67
  **/
68
- height?: number;
68
+ h?: number;
69
69
  }
70
70
 
71
71
  /**
@@ -75,8 +75,8 @@ export interface SubTextureProps {
75
75
  * The parent texture can be a Sprite Sheet/Texture Atlas and set using the
76
76
  * {@link SubTextureProps.texture} prop. The sub-region relative to the parent
77
77
  * texture is defined with the {@link SubTextureProps.x},
78
- * {@link SubTextureProps.y}, {@link SubTextureProps.width}, and
79
- * {@link SubTextureProps.height} pixel values.
78
+ * {@link SubTextureProps.y}, {@link SubTextureProps.w}, and
79
+ * {@link SubTextureProps.h} pixel values.
80
80
  */
81
81
  export class SubTexture extends Texture {
82
82
  props: Required<SubTextureProps>;
@@ -134,8 +134,8 @@ export class SubTexture extends Texture {
134
134
  // We ignore the parent's passed dimensions, and simply use the SubTexture's
135
135
  // configured dimensions (because that's all that matters here)
136
136
  this.forwardParentTxState('loaded', {
137
- width: this.props.width,
138
- height: this.props.height,
137
+ w: this.props.w,
138
+ h: this.props.h,
139
139
  });
140
140
  };
141
141
 
@@ -145,8 +145,8 @@ export class SubTexture extends Texture {
145
145
 
146
146
  private onParentTxFetched = () => {
147
147
  this.forwardParentTxState('fetched', {
148
- width: this.props.width,
149
- height: this.props.height,
148
+ w: this.props.w,
149
+ h: this.props.h,
150
150
  });
151
151
  };
152
152
 
@@ -196,8 +196,8 @@ export class SubTexture extends Texture {
196
196
  texture: props.texture,
197
197
  x: props.x || 0,
198
198
  y: props.y || 0,
199
- width: props.width || 0,
200
- height: props.height || 0,
199
+ w: props.w || 0,
200
+ h: props.h || 0,
201
201
  };
202
202
  }
203
203
 
@@ -45,7 +45,7 @@ export type TextureLoadedEventHandler = (
45
45
  /**
46
46
  * Represents compressed texture data.
47
47
  */
48
- interface CompressedData {
48
+ export interface CompressedData {
49
49
  /**
50
50
  * GLenum spcifying compression format
51
51
  */
@@ -66,12 +66,12 @@ interface CompressedData {
66
66
  *
67
67
  * @default 0
68
68
  */
69
- width: number;
69
+ w: number;
70
70
 
71
71
  /**
72
72
  * The height of the compressed texture in pixels.
73
73
  **/
74
- height: number;
74
+ h: number;
75
75
  }
76
76
 
77
77
  /**
@@ -296,10 +296,10 @@ export abstract class Texture extends EventEmitter {
296
296
  if (state === 'loaded') {
297
297
  if (
298
298
  errorOrDimensions !== undefined &&
299
- 'width' in errorOrDimensions === true &&
300
- 'height' in errorOrDimensions === true &&
301
- errorOrDimensions.width !== undefined &&
302
- errorOrDimensions.height !== undefined
299
+ 'w' in errorOrDimensions === true &&
300
+ 'h' in errorOrDimensions === true &&
301
+ errorOrDimensions.w !== undefined &&
302
+ errorOrDimensions.h !== undefined
303
303
  ) {
304
304
  this._dimensions = errorOrDimensions;
305
305
  }
@@ -462,14 +462,14 @@ export class Inspector {
462
462
  let value = mappedStyleResponse.value;
463
463
  if (property === 'x') {
464
464
  const mount = props.mountX;
465
- const width = props.width;
465
+ const width = props.w;
466
466
 
467
467
  if (mount) {
468
468
  value = `${parseInt(value) - width * mount}px`;
469
469
  }
470
470
  } else if (property === 'y') {
471
471
  const mount = props.mountY;
472
- const height = props.height;
472
+ const height = props.h;
473
473
 
474
474
  if (mount) {
475
475
  value = `${parseInt(value) - height * mount}px`;
@@ -538,8 +538,8 @@ export class Inspector {
538
538
  const {
539
539
  x,
540
540
  y,
541
- width,
542
- height,
541
+ w,
542
+ h,
543
543
  alpha = 1,
544
544
  rotation = 0,
545
545
  scale = 1,
@@ -551,10 +551,10 @@ export class Inspector {
551
551
  // ignoring loops and repeats for now, as that might be a bit too much for the inspector
552
552
  function animate() {
553
553
  setTimeout(() => {
554
- div.style.top = `${y - height * mountY}px`;
555
- div.style.left = `${x - width * mountX}px`;
556
- div.style.width = `${width}px`;
557
- div.style.height = `${height}px`;
554
+ div.style.top = `${y - h * mountY}px`;
555
+ div.style.left = `${x - w * mountX}px`;
556
+ div.style.width = `${w}px`;
557
+ div.style.height = `${h}px`;
558
558
  div.style.opacity = `${alpha}`;
559
559
  div.style.rotate = `${rotation}rad`;
560
560
  div.style.scale = `${scale}`;
@@ -824,8 +824,8 @@ export class RendererMain extends EventEmitter {
824
824
 
825
825
  this.stage.renderer.updateViewport();
826
826
 
827
- this.root.width = appWidth;
828
- this.root.height = appHeight;
827
+ this.root.w = appWidth;
828
+ this.root.h = appHeight;
829
829
  this.stage.updateViewportBounds();
830
830
  }
831
831