@lightningjs/renderer 2.5.1 → 2.6.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.
Files changed (99) hide show
  1. package/dist/exports/index.d.ts +1 -0
  2. package/dist/exports/index.js.map +1 -1
  3. package/dist/src/core/CoreNode.d.ts +1 -2
  4. package/dist/src/core/CoreNode.js +45 -31
  5. package/dist/src/core/CoreNode.js.map +1 -1
  6. package/dist/src/core/CoreTextNode.d.ts +1 -1
  7. package/dist/src/core/CoreTextNode.js +2 -2
  8. package/dist/src/core/CoreTextNode.js.map +1 -1
  9. package/dist/src/core/Stage.d.ts +5 -0
  10. package/dist/src/core/Stage.js +10 -2
  11. package/dist/src/core/Stage.js.map +1 -1
  12. package/dist/src/core/lib/utils.d.ts +8 -0
  13. package/dist/src/core/lib/utils.js +10 -0
  14. package/dist/src/core/lib/utils.js.map +1 -1
  15. package/dist/src/core/utils.d.ts +1 -1
  16. package/dist/src/main-api/Inspector.js +52 -36
  17. package/dist/src/main-api/Inspector.js.map +1 -1
  18. package/dist/src/main-api/Renderer.d.ts +10 -0
  19. package/dist/src/main-api/Renderer.js +2 -1
  20. package/dist/src/main-api/Renderer.js.map +1 -1
  21. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  22. package/exports/index.ts +1 -0
  23. package/package.json +1 -1
  24. package/src/core/CoreNode.ts +58 -45
  25. package/src/core/CoreTextNode.ts +2 -2
  26. package/src/core/Stage.ts +12 -2
  27. package/src/core/lib/utils.ts +19 -0
  28. package/src/main-api/Inspector.ts +61 -44
  29. package/src/main-api/Renderer.ts +13 -2
  30. package/dist/exports/core-api.d.ts +0 -74
  31. package/dist/exports/core-api.js +0 -96
  32. package/dist/exports/core-api.js.map +0 -1
  33. package/dist/exports/main-api.d.ts +0 -30
  34. package/dist/exports/main-api.js +0 -45
  35. package/dist/exports/main-api.js.map +0 -1
  36. package/dist/src/core/CoreExtension.d.ts +0 -12
  37. package/dist/src/core/CoreExtension.js +0 -29
  38. package/dist/src/core/CoreExtension.js.map +0 -1
  39. package/dist/src/main-api/ICoreDriver.d.ts +0 -24
  40. package/dist/src/main-api/ICoreDriver.js +0 -20
  41. package/dist/src/main-api/ICoreDriver.js.map +0 -1
  42. package/dist/src/main-api/RendererMain.d.ts +0 -378
  43. package/dist/src/main-api/RendererMain.js +0 -367
  44. package/dist/src/main-api/RendererMain.js.map +0 -1
  45. package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.d.ts +0 -9
  46. package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js +0 -38
  47. package/dist/src/main-api/texture-usage-trackers/FinalizationRegistryTextureUsageTracker.js.map +0 -1
  48. package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.d.ts +0 -56
  49. package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js +0 -101
  50. package/dist/src/main-api/texture-usage-trackers/ManualCountTextureUsageTracker.js.map +0 -1
  51. package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.d.ts +0 -32
  52. package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js +0 -28
  53. package/dist/src/main-api/texture-usage-trackers/TextureUsageTracker.js.map +0 -1
  54. package/dist/src/render-drivers/main/MainCoreDriver.d.ts +0 -21
  55. package/dist/src/render-drivers/main/MainCoreDriver.js +0 -115
  56. package/dist/src/render-drivers/main/MainCoreDriver.js.map +0 -1
  57. package/dist/src/render-drivers/main/MainOnlyNode.d.ts +0 -101
  58. package/dist/src/render-drivers/main/MainOnlyNode.js +0 -425
  59. package/dist/src/render-drivers/main/MainOnlyNode.js.map +0 -1
  60. package/dist/src/render-drivers/main/MainOnlyTextNode.d.ts +0 -47
  61. package/dist/src/render-drivers/main/MainOnlyTextNode.js +0 -204
  62. package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +0 -1
  63. package/dist/src/render-drivers/threadx/NodeStruct.d.ts +0 -93
  64. package/dist/src/render-drivers/threadx/NodeStruct.js +0 -290
  65. package/dist/src/render-drivers/threadx/NodeStruct.js.map +0 -1
  66. package/dist/src/render-drivers/threadx/SharedNode.d.ts +0 -40
  67. package/dist/src/render-drivers/threadx/SharedNode.js +0 -61
  68. package/dist/src/render-drivers/threadx/SharedNode.js.map +0 -1
  69. package/dist/src/render-drivers/threadx/TextNodeStruct.d.ts +0 -44
  70. package/dist/src/render-drivers/threadx/TextNodeStruct.js +0 -203
  71. package/dist/src/render-drivers/threadx/TextNodeStruct.js.map +0 -1
  72. package/dist/src/render-drivers/threadx/ThreadXCoreDriver.d.ts +0 -25
  73. package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js +0 -232
  74. package/dist/src/render-drivers/threadx/ThreadXCoreDriver.js.map +0 -1
  75. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +0 -24
  76. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +0 -113
  77. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +0 -1
  78. package/dist/src/render-drivers/threadx/ThreadXMainNode.d.ts +0 -46
  79. package/dist/src/render-drivers/threadx/ThreadXMainNode.js +0 -160
  80. package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +0 -1
  81. package/dist/src/render-drivers/threadx/ThreadXMainTextNode.d.ts +0 -28
  82. package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js +0 -55
  83. package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js.map +0 -1
  84. package/dist/src/render-drivers/threadx/ThreadXRendererMessage.d.ts +0 -70
  85. package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js +0 -32
  86. package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js.map +0 -1
  87. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.d.ts +0 -19
  88. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +0 -184
  89. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +0 -1
  90. package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.d.ts +0 -27
  91. package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +0 -109
  92. package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js.map +0 -1
  93. package/dist/src/render-drivers/threadx/worker/renderer.d.ts +0 -1
  94. package/dist/src/render-drivers/threadx/worker/renderer.js +0 -147
  95. package/dist/src/render-drivers/threadx/worker/renderer.js.map +0 -1
  96. package/dist/src/render-drivers/utils.d.ts +0 -12
  97. package/dist/src/render-drivers/utils.js +0 -74
  98. package/dist/src/render-drivers/utils.js.map +0 -1
  99. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -46,6 +46,7 @@ import {
46
46
  createBound,
47
47
  boundInsideBound,
48
48
  boundLargeThanBound,
49
+ createPreloadBounds,
49
50
  } from './lib/utils.js';
50
51
  import { Matrix3d } from './lib/Matrix3d.js';
51
52
  import { RenderCoords } from './lib/RenderCoords.js';
@@ -862,22 +863,27 @@ export class CoreNode extends EventEmitter {
862
863
  setUpdateType(type: UpdateType): void {
863
864
  this.updateType |= type;
864
865
 
865
- // If we're updating this node at all, we need to inform the parent
866
- // (and all ancestors) that their children need updating as well
867
866
  const parent = this.props.parent;
868
- if (parent !== null && !(parent.updateType & UpdateType.Children)) {
867
+ if (!parent) return;
868
+
869
+ // Inform the parent if it doesn’t already have a child update
870
+ if ((parent.updateType & UpdateType.Children) === 0) {
869
871
  parent.setUpdateType(UpdateType.Children);
870
872
  }
871
873
 
872
- // If node is part of RTT texture
873
- // Flag that we need to update
874
- if (this.parentHasRenderTexture) {
875
- this.setRTTUpdates(type);
874
+ if (this.parentHasRenderTexture === false) return;
876
875
 
877
- if (parent !== null) {
876
+ if (this.rtt === false) {
877
+ if ((parent.updateType & UpdateType.RenderTexture) === 0) {
878
+ this.setRTTUpdates(type);
878
879
  parent.setUpdateType(UpdateType.RenderTexture);
879
880
  }
880
881
  }
882
+
883
+ // If this node has outstanding RTT updates, propagate them
884
+ if (this.hasRTTupdates) {
885
+ this.setRTTUpdates(type);
886
+ }
881
887
  }
882
888
 
883
889
  sortChildren() {
@@ -1154,6 +1160,7 @@ export class CoreNode extends EventEmitter {
1154
1160
  // being marked as out of bounds
1155
1161
  if (renderState === CoreNodeRenderState.OutOfBounds) {
1156
1162
  this.updateRenderState(renderState);
1163
+ this.updateIsRenderable();
1157
1164
  }
1158
1165
 
1159
1166
  // reset update type
@@ -1162,7 +1169,7 @@ export class CoreNode extends EventEmitter {
1162
1169
  }
1163
1170
 
1164
1171
  //check if CoreNode is renderable based on props
1165
- checkRenderProps(): boolean {
1172
+ hasRenderableProperties(): boolean {
1166
1173
  if (this.props.texture) {
1167
1174
  return true;
1168
1175
  }
@@ -1248,16 +1255,6 @@ export class CoreNode extends EventEmitter {
1248
1255
  return CoreNodeRenderState.OutOfBounds;
1249
1256
  }
1250
1257
 
1251
- createPreloadBounds(strictBound: Bound): Bound {
1252
- const renderM = this.stage.boundsMargin;
1253
- return createBound(
1254
- strictBound.x1 - renderM[3],
1255
- strictBound.y1 - renderM[0],
1256
- strictBound.x2 + renderM[1],
1257
- strictBound.y2 + renderM[2],
1258
- );
1259
- }
1260
-
1261
1258
  updateBoundingRect() {
1262
1259
  const { renderCoords, globalTransform: transform } = this;
1263
1260
  assertTruthy(transform);
@@ -1282,34 +1279,43 @@ export class CoreNode extends EventEmitter {
1282
1279
  createRenderBounds(): void {
1283
1280
  assertTruthy(this.stage);
1284
1281
 
1285
- // no clipping, use parent's bounds
1286
- if (this.clipping === false) {
1287
- if (this.parent !== null && this.parent.strictBound !== undefined) {
1288
- // we have a parent with a valid bound, copy it
1289
- this.strictBound = createBound(
1290
- this.parent.strictBound.x1,
1291
- this.parent.strictBound.y1,
1292
- this.parent.strictBound.x2,
1293
- this.parent.strictBound.y2,
1294
- );
1282
+ if (this.parent !== null && this.parent.strictBound !== undefined) {
1283
+ // we have a parent with a valid bound, copy it
1284
+ const parentBound = this.parent.strictBound;
1285
+ this.strictBound = createBound(
1286
+ parentBound.x1,
1287
+ parentBound.y1,
1288
+ parentBound.x2,
1289
+ parentBound.y2,
1290
+ );
1295
1291
 
1296
- this.preloadBound = this.createPreloadBounds(this.strictBound);
1297
- return;
1298
- } else {
1299
- // no parent or parent does not have a bound, take the stage dimensions
1300
- this.strictBound = createBound(
1301
- 0,
1302
- 0,
1303
- this.stage.root.width,
1304
- this.stage.root.height,
1305
- );
1292
+ this.preloadBound = createPreloadBounds(
1293
+ this.strictBound,
1294
+ this.stage.boundsMargin,
1295
+ );
1296
+ } else {
1297
+ // no parent or parent does not have a bound, take the stage boundaries
1298
+ this.strictBound = this.stage.strictBound;
1299
+ this.preloadBound = this.stage.preloadBound;
1300
+ }
1306
1301
 
1307
- this.preloadBound = this.createPreloadBounds(this.strictBound);
1308
- return;
1309
- }
1302
+ // if clipping is disabled, we're done
1303
+ if (this.props.clipping === false) {
1304
+ return;
1305
+ }
1306
+
1307
+ // only create local clipping bounds if node itself is in bounds
1308
+ // this can only be done if we have a render bound already
1309
+ if (this.renderBound === undefined) {
1310
+ return;
1310
1311
  }
1311
1312
 
1312
- // clipping is enabled create our own bounds
1313
+ // if we're out of bounds, we're done
1314
+ if (boundInsideBound(this.renderBound, this.strictBound) === false) {
1315
+ return;
1316
+ }
1317
+
1318
+ // clipping is enabled and we are in bounds create our own bounds
1313
1319
  const { x, y, width, height } = this.props;
1314
1320
  const { tx, ty } = this.globalTransform || {};
1315
1321
  const _x = tx ?? x;
@@ -1322,7 +1328,10 @@ export class CoreNode extends EventEmitter {
1322
1328
  this.strictBound,
1323
1329
  );
1324
1330
 
1325
- this.preloadBound = this.createPreloadBounds(this.strictBound);
1331
+ this.preloadBound = createPreloadBounds(
1332
+ this.strictBound,
1333
+ this.stage.boundsMargin,
1334
+ );
1326
1335
  }
1327
1336
 
1328
1337
  updateRenderState(renderState: CoreNodeRenderState) {
@@ -1347,7 +1356,7 @@ export class CoreNode extends EventEmitter {
1347
1356
  */
1348
1357
  updateIsRenderable() {
1349
1358
  let newIsRenderable;
1350
- if (this.worldAlpha === 0 || !this.checkRenderProps()) {
1359
+ if (this.worldAlpha === 0 || !this.hasRenderableProperties()) {
1351
1360
  newIsRenderable = false;
1352
1361
  } else {
1353
1362
  newIsRenderable = this.renderState > CoreNodeRenderState.OutOfBounds;
@@ -2150,6 +2159,10 @@ export class CoreNode extends EventEmitter {
2150
2159
  }
2151
2160
 
2152
2161
  setRTTUpdates(type: number) {
2162
+ if (this.hasRTTupdates === true) {
2163
+ return;
2164
+ }
2165
+
2153
2166
  this.hasRTTupdates = true;
2154
2167
  this.parent?.setRTTUpdates(type);
2155
2168
  }
@@ -368,11 +368,11 @@ export class CoreTextNode extends CoreNode implements CoreTextNodeProps {
368
368
  this.textRenderer.set.y(this.trState, this.globalTransform.ty);
369
369
  }
370
370
 
371
- override checkRenderProps(): boolean {
371
+ override hasRenderableProperties(): boolean {
372
372
  if (this.trState && this.trState.props.text !== '') {
373
373
  return true;
374
374
  }
375
- return super.checkRenderProps();
375
+ return super.hasRenderableProperties();
376
376
  }
377
377
 
378
378
  override onChangeIsRenderable(isRenderable: boolean) {
package/src/core/Stage.ts CHANGED
@@ -52,6 +52,7 @@ import { CoreTextNode, type CoreTextNodeProps } from './CoreTextNode.js';
52
52
  import { santizeCustomDataMap } from '../main-api/utils.js';
53
53
  import type { SdfTextRenderer } from './text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js';
54
54
  import type { CanvasTextRenderer } from './text-rendering/renderers/CanvasTextRenderer.js';
55
+ import { createBound, createPreloadBounds, type Bound } from './lib/utils.js';
55
56
 
56
57
  export interface StageOptions {
57
58
  appWidth: number;
@@ -71,6 +72,7 @@ export interface StageOptions {
71
72
  quadBufferSize: number;
72
73
  fontEngines: (typeof CanvasTextRenderer | typeof SdfTextRenderer)[];
73
74
  inspector: boolean;
75
+ strictBounds: boolean;
74
76
  }
75
77
 
76
78
  export type StageFpsUpdateHandler = (
@@ -98,6 +100,9 @@ export class Stage {
98
100
  public readonly root: CoreNode;
99
101
  public readonly boundsMargin: [number, number, number, number];
100
102
  public readonly defShaderCtr: BaseShaderController;
103
+ public readonly strictBound: Bound;
104
+ public readonly preloadBound: Bound;
105
+ public readonly strictBounds: boolean;
101
106
 
102
107
  /**
103
108
  * Renderer Event Bus for the Stage to emit events onto
@@ -147,6 +152,7 @@ export class Stage {
147
152
  this.shManager = new CoreShaderManager();
148
153
  this.animationManager = new AnimationManager();
149
154
  this.contextSpy = enableContextSpy ? new ContextSpy() : null;
155
+ this.strictBounds = options.strictBounds;
150
156
 
151
157
  let bm = [0, 0, 0, 0] as [number, number, number, number];
152
158
  if (boundsMargin) {
@@ -156,6 +162,10 @@ export class Stage {
156
162
  }
157
163
  this.boundsMargin = bm;
158
164
 
165
+ // precalculate our viewport bounds
166
+ this.strictBound = createBound(0, 0, appWidth, appHeight);
167
+ this.preloadBound = createPreloadBounds(this.strictBound, bm);
168
+
159
169
  const rendererOptions: CoreRendererOptions = {
160
170
  stage: this,
161
171
  canvas,
@@ -245,7 +255,7 @@ export class Stage {
245
255
  src: null,
246
256
  scale: 1,
247
257
  preventCleanup: false,
248
- strictBounds: false,
258
+ strictBounds: this.strictBounds,
249
259
  });
250
260
 
251
261
  this.root = rootNode;
@@ -631,7 +641,7 @@ export class Stage {
631
641
  data: data,
632
642
  preventCleanup: props.preventCleanup ?? false,
633
643
  imageType: props.imageType,
634
- strictBounds: props.strictBounds ?? false,
644
+ strictBounds: props.strictBounds ?? this.strictBounds,
635
645
  };
636
646
  }
637
647
  }
@@ -261,6 +261,25 @@ export function isRectPositive(rect: Rect): boolean {
261
261
  return rect.width > 0 && rect.height > 0;
262
262
  }
263
263
 
264
+ /**
265
+ * Create a preload bounds from a strict bound
266
+ *
267
+ * @param strictBound The strict boundary of the node
268
+ * @param boundsMargin Boundary margin to apply to the strictBound
269
+ * @returns
270
+ */
271
+ export function createPreloadBounds(
272
+ strictBound: Bound,
273
+ boundsMargin: [number, number, number, number],
274
+ ): Bound {
275
+ return createBound(
276
+ strictBound.x1 - boundsMargin[3],
277
+ strictBound.y1 - boundsMargin[0],
278
+ strictBound.x2 + boundsMargin[1],
279
+ strictBound.y2 + boundsMargin[2],
280
+ );
281
+ }
282
+
264
283
  export function convertUrlToAbsolute(url: string): string {
265
284
  // handle local file imports if the url isn't remote resource or data blob
266
285
  if (self.location.protocol === 'file:' && !PROTOCOL_REGEX.test(url)) {
@@ -142,6 +142,14 @@ const gradientColorPropertyMap = [
142
142
  'colorBr',
143
143
  ];
144
144
 
145
+ const knownProperties = new Set<string>([
146
+ ...Object.keys(stylePropertyMap),
147
+ ...Object.keys(domPropertyMap),
148
+ // ...gradientColorPropertyMap,
149
+ 'src',
150
+ 'parent',
151
+ ]);
152
+
145
153
  export class Inspector {
146
154
  private root: HTMLElement | null = null;
147
155
  private canvas: HTMLCanvasElement | null = null;
@@ -239,35 +247,22 @@ export class Inspector {
239
247
 
240
248
  createNode(node: CoreNode): CoreNode {
241
249
  const div = this.createDiv(node.id, node.props);
242
-
243
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
244
250
  (div as any).node = node;
245
-
246
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
247
251
  (node as any).div = div;
248
252
 
249
- node.on('inViewport', () => {
250
- div.setAttribute('state', 'inViewport');
251
- });
252
-
253
- node.on('inBounds', () => {
254
- div.setAttribute('state', 'inBounds');
255
- });
256
-
257
- node.on('outOfBounds', () => {
258
- div.setAttribute('state', 'outOfBounds');
259
- });
253
+ node.on('inViewport', () => div.setAttribute('state', 'inViewport'));
254
+ node.on('inBounds', () => div.setAttribute('state', 'inBounds'));
255
+ node.on('outOfBounds', () => div.setAttribute('state', 'outOfBounds'));
260
256
 
257
+ // Monitor only relevant properties by trapping with selective assignment
261
258
  return this.createProxy(node, div);
262
259
  }
263
260
 
264
261
  createTextNode(node: CoreNode): CoreTextNode {
265
262
  const div = this.createDiv(node.id, node.props);
266
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
267
263
  (div as any).node = node;
268
-
269
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
270
264
  (node as any).div = div;
265
+
271
266
  return this.createProxy(node, div) as CoreTextNode;
272
267
  }
273
268
 
@@ -275,36 +270,58 @@ export class Inspector {
275
270
  node: CoreNode | CoreTextNode,
276
271
  div: HTMLElement,
277
272
  ): CoreNode | CoreTextNode {
278
- return new Proxy(node, {
279
- set: (target, property: keyof CoreNodeProps, value) => {
280
- this.updateNodeProperty(div, property, value);
281
- return Reflect.set(target, property, value);
282
- },
283
- get: (target, property: keyof CoreNode, receiver: any): any => {
284
- if (property === 'destroy') {
285
- this.destroyNode(target.id);
286
- }
273
+ // Define traps for each property in knownProperties
274
+ knownProperties.forEach((property) => {
275
+ const originalProp = Object.getOwnPropertyDescriptor(node, property);
276
+ if (!originalProp) {
277
+ return;
278
+ }
287
279
 
288
- if (property === 'animate') {
289
- return (props: CoreNodeAnimateProps, settings: AnimationSettings) => {
290
- const anim = target.animate(props, settings);
291
-
292
- // Trap the animate start function so we can update the inspector accordingly
293
- return new Proxy(anim, {
294
- get: (target, property: keyof IAnimationController, receiver) => {
295
- if (property === 'start') {
296
- this.animateNode(div, props, settings);
297
- }
298
-
299
- return Reflect.get(target, property, receiver);
300
- },
301
- });
302
- };
303
- }
280
+ Object.defineProperties(node, {
281
+ [property]: {
282
+ get() {
283
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
284
+ return originalProp.get?.call(node);
285
+ },
286
+ set(value) {
287
+ originalProp.set?.call(node, value);
288
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
289
+ this.updateNodeProperty(div, property, value);
290
+ },
291
+ configurable: true,
292
+ enumerable: true,
293
+ },
294
+ });
295
+ });
304
296
 
305
- return Reflect.get(target, property, receiver);
297
+ const originalDestroy = node.destroy;
298
+ Object.defineProperty(node, 'destroy', {
299
+ value: () => {
300
+ this.destroyNode(node.id);
301
+ originalDestroy.call(node);
306
302
  },
307
303
  });
304
+
305
+ // eslint-disable-next-line @typescript-eslint/unbound-method
306
+ const originalAnimate = node.animate;
307
+ Object.defineProperty(node, 'animate', {
308
+ value: (
309
+ props: CoreNodeAnimateProps,
310
+ settings: AnimationSettings,
311
+ ): IAnimationController => {
312
+ const animationController = originalAnimate.call(node, props, settings);
313
+
314
+ return {
315
+ ...animationController,
316
+ start: () => {
317
+ this.animateNode(div, props, settings);
318
+ return animationController.start();
319
+ },
320
+ };
321
+ },
322
+ });
323
+
324
+ return node;
308
325
  }
309
326
 
310
327
  destroyNode(id: number) {
@@ -256,6 +256,17 @@ export interface RendererMainSettings {
256
256
  * @defaultValue `false`
257
257
  */
258
258
  forceWebGL2?: boolean;
259
+
260
+ /**
261
+ * Enable strictBounds
262
+ *
263
+ * @remarks
264
+ * Enable strict bounds for the renderer. This will ensure that the renderer
265
+ * will not render outside the bounds of the canvas.
266
+ *
267
+ * @defaultValue `true`
268
+ */
269
+ strictBounds?: boolean;
259
270
  }
260
271
 
261
272
  /**
@@ -346,6 +357,7 @@ export class RendererMain extends EventEmitter {
346
357
  renderEngine: settings.renderEngine,
347
358
  quadBufferSize: settings.quadBufferSize ?? 4 * 1024 * 1024,
348
359
  fontEngines: settings.fontEngines,
360
+ strictBounds: settings.strictBounds ?? true,
349
361
  };
350
362
  this.settings = resolvedSettings;
351
363
 
@@ -387,6 +399,7 @@ export class RendererMain extends EventEmitter {
387
399
  quadBufferSize: this.settings.quadBufferSize,
388
400
  fontEngines: this.settings.fontEngines,
389
401
  inspector: this.settings.inspector !== null,
402
+ strictBounds: this.settings.strictBounds,
390
403
  });
391
404
 
392
405
  // Extract the root node
@@ -432,8 +445,6 @@ export class RendererMain extends EventEmitter {
432
445
  createNode<
433
446
  ShCtr extends BaseShaderController = ShaderController<'DefaultShader'>,
434
447
  >(props: Partial<INodeProps<ShCtr>>): INode<ShCtr> {
435
- assertTruthy(this.stage, 'Stage is not initialized');
436
-
437
448
  const node = this.stage.createNode(props as Partial<CoreNodeProps>);
438
449
 
439
450
  if (this.inspector) {
@@ -1,74 +0,0 @@
1
- /**
2
- * Lightning 3 Renderer Core API
3
- *
4
- * @remarks
5
- * ```
6
- * import * from '@lightning/renderer/core';
7
- * ```
8
- *
9
- * The Core API is used by developers to extend the capabilities of the Renderer
10
- * by writing custom Shaders, Dynamic Shader Effects, Textures, Text Renderers,
11
- * etc.
12
- *
13
- * Custom capabilities as well as fonts can be loaded via Core Extensions.
14
- *
15
- * A core extension module is structured like so:
16
- * ```ts
17
- * import {
18
- * CoreExtension,
19
- * WebTrFontFace,
20
- * SdfTrFontFace,
21
- * type Stage
22
- * } from '@lightning/renderer/core';
23
- *
24
- * export default class MyCoreExtension extends CoreExtension {
25
- * async run(stage: Stage) {
26
- * stage.fontManager.addFontFace(
27
- * new WebTrFontFace('Ubuntu', {}, '/fonts/Ubuntu-Regular.ttf'),
28
- * );
29
- *
30
- * stage.fontManager.addFontFace(
31
- * new SdfTrFontFace(
32
- * 'Ubuntu',
33
- * {},
34
- * 'msdf',
35
- * stage,
36
- * '/fonts/Ubuntu-Regular.msdf.png',
37
- * '/fonts/Ubuntu-Regular.msdf.json',
38
- * ),
39
- * );
40
- * }
41
- * }
42
- * ```
43
- *
44
- * And then imported and registered in the application's entry point
45
- * using the `@lightningjs/vite-plugin-import-chunk-url` plugin:
46
- * ```ts
47
- * import coreExtensionModuleUrl from './MyCoreExtension.js?importChunkUrl';
48
- *
49
- * // Set up driver, etc.
50
- *
51
- * // Initialize the Renderer
52
- * const renderer = new RendererMain(
53
- * {
54
- * // Other Renderer Config...
55
- * coreExtensionModule: coreExtensionModuleUrl,
56
- * },
57
- * 'app',
58
- * driver,
59
- * );
60
- * ```
61
- *
62
- * @module
63
- */
64
- export * from '../src/core/renderers/webgl/WebGlCoreShader.js';
65
- export * from '../src/core/renderers/webgl/shaders/effects/ShaderEffect.js';
66
- export * from '../src/core/textures/Texture.js';
67
- export * from '../src/core/text-rendering/renderers/TextRenderer.js';
68
- export * from '../src/core/text-rendering/renderers/CanvasTextRenderer.js';
69
- export * from '../src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js';
70
- export * from '../src/core/text-rendering/font-face-types/TrFontFace.js';
71
- export * from '../src/core/text-rendering/font-face-types/WebTrFontFace.js';
72
- export * from '../src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js';
73
- export * from '../src/core/CoreExtension.js';
74
- export type * from '../src/core/Stage.js';
@@ -1,96 +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
- * Lightning 3 Renderer Core API
21
- *
22
- * @remarks
23
- * ```
24
- * import * from '@lightning/renderer/core';
25
- * ```
26
- *
27
- * The Core API is used by developers to extend the capabilities of the Renderer
28
- * by writing custom Shaders, Dynamic Shader Effects, Textures, Text Renderers,
29
- * etc.
30
- *
31
- * Custom capabilities as well as fonts can be loaded via Core Extensions.
32
- *
33
- * A core extension module is structured like so:
34
- * ```ts
35
- * import {
36
- * CoreExtension,
37
- * WebTrFontFace,
38
- * SdfTrFontFace,
39
- * type Stage
40
- * } from '@lightning/renderer/core';
41
- *
42
- * export default class MyCoreExtension extends CoreExtension {
43
- * async run(stage: Stage) {
44
- * stage.fontManager.addFontFace(
45
- * new WebTrFontFace('Ubuntu', {}, '/fonts/Ubuntu-Regular.ttf'),
46
- * );
47
- *
48
- * stage.fontManager.addFontFace(
49
- * new SdfTrFontFace(
50
- * 'Ubuntu',
51
- * {},
52
- * 'msdf',
53
- * stage,
54
- * '/fonts/Ubuntu-Regular.msdf.png',
55
- * '/fonts/Ubuntu-Regular.msdf.json',
56
- * ),
57
- * );
58
- * }
59
- * }
60
- * ```
61
- *
62
- * And then imported and registered in the application's entry point
63
- * using the `@lightningjs/vite-plugin-import-chunk-url` plugin:
64
- * ```ts
65
- * import coreExtensionModuleUrl from './MyCoreExtension.js?importChunkUrl';
66
- *
67
- * // Set up driver, etc.
68
- *
69
- * // Initialize the Renderer
70
- * const renderer = new RendererMain(
71
- * {
72
- * // Other Renderer Config...
73
- * coreExtensionModule: coreExtensionModuleUrl,
74
- * },
75
- * 'app',
76
- * driver,
77
- * );
78
- * ```
79
- *
80
- * @module
81
- */
82
- // Shaders
83
- export * from '../src/core/renderers/webgl/WebGlCoreShader.js';
84
- export * from '../src/core/renderers/webgl/shaders/effects/ShaderEffect.js';
85
- // Textures
86
- export * from '../src/core/textures/Texture.js';
87
- // Text Rendering & Fonts
88
- export * from '../src/core/text-rendering/renderers/TextRenderer.js';
89
- export * from '../src/core/text-rendering/renderers/CanvasTextRenderer.js';
90
- export * from '../src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js';
91
- export * from '../src/core/text-rendering/font-face-types/TrFontFace.js';
92
- export * from '../src/core/text-rendering/font-face-types/WebTrFontFace.js';
93
- export * from '../src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js';
94
- // Core Extensions
95
- export * from '../src/core/CoreExtension.js';
96
- //# sourceMappingURL=core-api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-api.js","sourceRoot":"","sources":["../../exports/core-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,UAAU;AACV,cAAc,gDAAgD,CAAC;AAC/D,cAAc,6DAA6D,CAAC;AAE5E,WAAW;AACX,cAAc,iCAAiC,CAAC;AAEhD,yBAAyB;AACzB,cAAc,sDAAsD,CAAC;AACrE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,yEAAyE,CAAC;AACxF,cAAc,0DAA0D,CAAC;AACzE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,2EAA2E,CAAC;AAE1F,kBAAkB;AAClB,cAAc,8BAA8B,CAAC"}
@@ -1,30 +0,0 @@
1
- /**
2
- * Lightning 3 Renderer Main API
3
- *
4
- * @remarks
5
- * This module exports the Main API for the Lightning 3 Renderer. You
6
- * can import the exports from this module like so:
7
- * ```ts
8
- * import { RendererMain } from '@lightning/renderer';
9
- * ```
10
- *
11
- * Generally developers/frameworks using the Renderer will use the Main API to
12
- * render applications.
13
- *
14
- * Do not confuse the Main API with the Core API which is used to extend
15
- * capabilities of the Renderer. The Main API code always runs from the main
16
- * thread.
17
- *
18
- * @module
19
- */
20
- export * from '../src/main-api/INode.js';
21
- export * from '../src/main-api/ICoreDriver.js';
22
- export * from '../src/main-api/RendererMain.js';
23
- export * from '../src/render-drivers/main/MainCoreDriver.js';
24
- export * from '../src/render-drivers/threadx/ThreadXCoreDriver.js';
25
- export * from '../src/common/IAnimationController.js';
26
- export * from '../src/common/CommonTypes.js';
27
- export type { TextRendererMap } from '../src/core/text-rendering/renderers/TextRenderer.js';
28
- export type { TrFontFaceMap } from '../src/core/text-rendering/font-face-types/TrFontFace.js';
29
- export type { AnimationSettings } from '../src/core/animations/CoreAnimation.js';
30
- export type { EffectProps, FadeOutEffectProps, LinearGradientEffectProps, RadialGradientEffectProps, GrayscaleEffectProps, GlitchEffectProps, RadialProgressEffectProps, } from '../src/core/CoreShaderManager.js';