From bec210cf90104b9215bd26193ec9d0f4e0729090 Mon Sep 17 00:00:00 2001 From: Maikel Brons Date: Mon, 20 Nov 2023 20:12:50 +0100 Subject: [PATCH 1/3] Renamed RenderDriver to CoreDriver. --- exports/main-api.ts | 2 +- src/main-api/{IRenderDriver.ts => CoreDriver.ts} | 2 +- src/main-api/RendererMain.ts | 6 +++--- src/render-drivers/main/MainRenderDriver.ts | 4 ++-- src/render-drivers/threadx/ThreadXRenderDriver.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename src/main-api/{IRenderDriver.ts => CoreDriver.ts} (98%) diff --git a/exports/main-api.ts b/exports/main-api.ts index a7c29392..16063c6a 100644 --- a/exports/main-api.ts +++ b/exports/main-api.ts @@ -37,7 +37,7 @@ * @module */ export * from '../src/main-api/INode.js'; -export * from '../src/main-api/IRenderDriver.js'; +export * from '../src/main-api/CoreDriver.js'; export * from '../src/main-api/RendererMain.js'; export * from '../src/render-drivers/main/MainRenderDriver.js'; export * from '../src/render-drivers/threadx/ThreadXRenderDriver.js'; diff --git a/src/main-api/IRenderDriver.ts b/src/main-api/CoreDriver.ts similarity index 98% rename from src/main-api/IRenderDriver.ts rename to src/main-api/CoreDriver.ts index 29a4db01..d7980a0f 100644 --- a/src/main-api/IRenderDriver.ts +++ b/src/main-api/CoreDriver.ts @@ -33,7 +33,7 @@ import type { RendererMain, RendererMainSettings } from './RendererMain.js'; * that implement this interface to support both the single-threaded and * multi-threaded Core modes. */ -export interface IRenderDriver { +export interface CoreDriver { init( rendererMain: RendererMain, rendererSettings: Required, diff --git a/src/main-api/RendererMain.ts b/src/main-api/RendererMain.ts index a27962bb..25d4abf7 100644 --- a/src/main-api/RendererMain.ts +++ b/src/main-api/RendererMain.ts @@ -30,7 +30,7 @@ import type { ITextNode, ITextNodeWritableProps, } from './INode.js'; -import type { IRenderDriver } from './IRenderDriver.js'; +import type { CoreDriver } from './CoreDriver.js'; import { ManualCountTextureUsageTracker, type ManualCountTextureUsageTrackerOptions, @@ -228,7 +228,7 @@ export interface RendererMainSettings { */ export class RendererMain { readonly root: INode | null = null; - readonly driver: IRenderDriver; + readonly driver: CoreDriver; readonly canvas: HTMLCanvasElement; readonly settings: Readonly>; private nodes: Map = new Map(); @@ -252,7 +252,7 @@ export class RendererMain { constructor( settings: RendererMainSettings, target: string | HTMLElement, - driver: IRenderDriver, + driver: CoreDriver, ) { const resolvedSettings: Required = { appWidth: settings.appWidth || 1920, diff --git a/src/render-drivers/main/MainRenderDriver.ts b/src/render-drivers/main/MainRenderDriver.ts index f80037d5..2c2b4179 100644 --- a/src/render-drivers/main/MainRenderDriver.ts +++ b/src/render-drivers/main/MainRenderDriver.ts @@ -18,7 +18,7 @@ */ import { assertTruthy } from '../../utils.js'; -import type { IRenderDriver } from '../../main-api/IRenderDriver.js'; +import type { CoreDriver } from '../../main-api/CoreDriver.js'; import type { INode, INodeWritableProps, @@ -33,7 +33,7 @@ import type { import { MainOnlyTextNode } from './MainOnlyTextNode.js'; import { loadCoreExtension } from '../utils.js'; -export class MainRenderDriver implements IRenderDriver { +export class MainRenderDriver implements CoreDriver { private root: MainOnlyNode | null = null; private stage: Stage | null = null; private rendererMain: RendererMain | null = null; diff --git a/src/render-drivers/threadx/ThreadXRenderDriver.ts b/src/render-drivers/threadx/ThreadXRenderDriver.ts index a97914dd..c9cc9602 100644 --- a/src/render-drivers/threadx/ThreadXRenderDriver.ts +++ b/src/render-drivers/threadx/ThreadXRenderDriver.ts @@ -25,7 +25,7 @@ import type { ITextNodeWritableProps, } from '../../main-api/INode.js'; import { NodeStruct, type NodeStructWritableProps } from './NodeStruct.js'; -import type { IRenderDriver } from '../../main-api/IRenderDriver.js'; +import type { CoreDriver } from '../../main-api/CoreDriver.js'; import { ThreadXMainNode } from './ThreadXMainNode.js'; import { assertTruthy } from '../../utils.js'; import type { @@ -46,7 +46,7 @@ export interface ThreadXRendererSettings { coreWorkerUrl: string; } -export class ThreadXRenderDriver implements IRenderDriver { +export class ThreadXRenderDriver implements CoreDriver { private settings: ThreadXRendererSettings; private threadx: ThreadX; private rendererMain: RendererMain | null = null; From dce9bf6c6a77aef94a31abade26849d4027ad6b3 Mon Sep 17 00:00:00 2001 From: Maikel Brons Date: Wed, 29 Nov 2023 16:50:54 +0100 Subject: [PATCH 2/3] Add I in front of coredriver --- exports/main-api.ts | 2 +- src/main-api/{CoreDriver.ts => ICoreDriver.ts} | 2 +- src/main-api/RendererMain.ts | 6 +++--- src/render-drivers/main/MainRenderDriver.ts | 4 ++-- src/render-drivers/threadx/ThreadXRenderDriver.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) rename src/main-api/{CoreDriver.ts => ICoreDriver.ts} (98%) diff --git a/exports/main-api.ts b/exports/main-api.ts index 16063c6a..833f55d0 100644 --- a/exports/main-api.ts +++ b/exports/main-api.ts @@ -37,7 +37,7 @@ * @module */ export * from '../src/main-api/INode.js'; -export * from '../src/main-api/CoreDriver.js'; +export * from '../src/main-api/ICoreDriver.js'; export * from '../src/main-api/RendererMain.js'; export * from '../src/render-drivers/main/MainRenderDriver.js'; export * from '../src/render-drivers/threadx/ThreadXRenderDriver.js'; diff --git a/src/main-api/CoreDriver.ts b/src/main-api/ICoreDriver.ts similarity index 98% rename from src/main-api/CoreDriver.ts rename to src/main-api/ICoreDriver.ts index d7980a0f..4decb31e 100644 --- a/src/main-api/CoreDriver.ts +++ b/src/main-api/ICoreDriver.ts @@ -33,7 +33,7 @@ import type { RendererMain, RendererMainSettings } from './RendererMain.js'; * that implement this interface to support both the single-threaded and * multi-threaded Core modes. */ -export interface CoreDriver { +export interface ICoreDriver { init( rendererMain: RendererMain, rendererSettings: Required, diff --git a/src/main-api/RendererMain.ts b/src/main-api/RendererMain.ts index 25d4abf7..9dd75935 100644 --- a/src/main-api/RendererMain.ts +++ b/src/main-api/RendererMain.ts @@ -30,7 +30,7 @@ import type { ITextNode, ITextNodeWritableProps, } from './INode.js'; -import type { CoreDriver } from './CoreDriver.js'; +import type { ICoreDriver } from './ICoreDriver.js'; import { ManualCountTextureUsageTracker, type ManualCountTextureUsageTrackerOptions, @@ -228,7 +228,7 @@ export interface RendererMainSettings { */ export class RendererMain { readonly root: INode | null = null; - readonly driver: CoreDriver; + readonly driver: ICoreDriver; readonly canvas: HTMLCanvasElement; readonly settings: Readonly>; private nodes: Map = new Map(); @@ -252,7 +252,7 @@ export class RendererMain { constructor( settings: RendererMainSettings, target: string | HTMLElement, - driver: CoreDriver, + driver: ICoreDriver, ) { const resolvedSettings: Required = { appWidth: settings.appWidth || 1920, diff --git a/src/render-drivers/main/MainRenderDriver.ts b/src/render-drivers/main/MainRenderDriver.ts index 2c2b4179..f6b36477 100644 --- a/src/render-drivers/main/MainRenderDriver.ts +++ b/src/render-drivers/main/MainRenderDriver.ts @@ -18,7 +18,7 @@ */ import { assertTruthy } from '../../utils.js'; -import type { CoreDriver } from '../../main-api/CoreDriver.js'; +import type { ICoreDriver } from '../../main-api/ICoreDriver.js'; import type { INode, INodeWritableProps, @@ -33,7 +33,7 @@ import type { import { MainOnlyTextNode } from './MainOnlyTextNode.js'; import { loadCoreExtension } from '../utils.js'; -export class MainRenderDriver implements CoreDriver { +export class MainRenderDriver implements ICoreDriver { private root: MainOnlyNode | null = null; private stage: Stage | null = null; private rendererMain: RendererMain | null = null; diff --git a/src/render-drivers/threadx/ThreadXRenderDriver.ts b/src/render-drivers/threadx/ThreadXRenderDriver.ts index c9cc9602..593b2bbb 100644 --- a/src/render-drivers/threadx/ThreadXRenderDriver.ts +++ b/src/render-drivers/threadx/ThreadXRenderDriver.ts @@ -25,7 +25,7 @@ import type { ITextNodeWritableProps, } from '../../main-api/INode.js'; import { NodeStruct, type NodeStructWritableProps } from './NodeStruct.js'; -import type { CoreDriver } from '../../main-api/CoreDriver.js'; +import type { ICoreDriver } from '../../main-api/ICoreDriver.js'; import { ThreadXMainNode } from './ThreadXMainNode.js'; import { assertTruthy } from '../../utils.js'; import type { @@ -46,7 +46,7 @@ export interface ThreadXRendererSettings { coreWorkerUrl: string; } -export class ThreadXRenderDriver implements CoreDriver { +export class ThreadXRenderDriver implements ICoreDriver { private settings: ThreadXRendererSettings; private threadx: ThreadX; private rendererMain: RendererMain | null = null; From 29c685cfe0dd13af1981de6057ac3f4bbd0a5a60 Mon Sep 17 00:00:00 2001 From: Maikel Brons Date: Wed, 29 Nov 2023 17:13:34 +0100 Subject: [PATCH 3/3] Changed remaining Renderdriver naming --- README.md | 8 +++--- examples/index.ts | 25 +++++++++++-------- exports/main-api.ts | 4 +-- src/main-api/ICoreDriver.ts | 2 +- src/main-api/INode.ts | 4 +-- src/main-api/RendererMain.ts | 4 +-- ...{MainRenderDriver.ts => MainCoreDriver.ts} | 2 +- ...dXRenderDriver.ts => ThreadXCoreDriver.ts} | 2 +- 8 files changed, 27 insertions(+), 24 deletions(-) rename src/render-drivers/main/{MainRenderDriver.ts => MainCoreDriver.ts} (98%) rename src/render-drivers/threadx/{ThreadXRenderDriver.ts => ThreadXCoreDriver.ts} (99%) diff --git a/README.md b/README.md index 9dd52fc0..441d2ac2 100644 --- a/README.md +++ b/README.md @@ -87,14 +87,14 @@ The Main Core Driver renders your application on the web page's main thread. It can be configured into the Renderer like so: ```ts -import { MainRenderDriver, RendererMain } from '@lightningjs/renderer'; +import { MainCoreDriver, RendererMain } from '@lightningjs/renderer'; const renderer = new RendererMain( { // App Config }, 'app', // App div ID - new MainRenderDriver(), // Main Render driver + new MainCoreDriver(), // Main Render driver ); // ... @@ -109,7 +109,7 @@ It can be configured into the Renderer like so: ```ts import { - ThreadXRenderDriver, + ThreadXCoreDriver, RendererMain, } from '@lightningjs/renderer'; @@ -121,7 +121,7 @@ const renderer = new RendererMain( // App Config }, 'app', // App div ID - new ThreadXRenderDriver({ + new ThreadXCoreDriver({ coreWorkerUrl, }); ); diff --git a/examples/index.ts b/examples/index.ts index 6a2401e4..4dad0c81 100644 --- a/examples/index.ts +++ b/examples/index.ts @@ -18,11 +18,11 @@ */ import { - MainRenderDriver, + MainCoreDriver, RendererMain, - ThreadXRenderDriver, - type IRenderDriver, - type LoadedPayload, + ThreadXCoreDriver, + type ICoreDriver, + type NodeLoadedPayload, type RendererMainSettings, } from '@lightningjs/renderer'; import { assertTruthy } from '@lightningjs/renderer/utils'; @@ -54,12 +54,12 @@ import type { ExampleSettings } from './common/ExampleSettings.js'; driverName = 'main'; } - let driver: IRenderDriver | null = null; + let driver: ICoreDriver | null = null; if (driverName === 'main') { - driver = new MainRenderDriver(); + driver = new MainCoreDriver(); } else { - driver = new ThreadXRenderDriver({ + driver = new ThreadXCoreDriver({ coreWorkerUrl, }); } @@ -92,10 +92,13 @@ import type { ExampleSettings } from './common/ExampleSettings.js'; parent: renderer.root, fontSize: 50, }); - overlayText.once('loaded', (target: any, { dimensions }: LoadedPayload) => { - overlayText.x = renderer.settings.appWidth - dimensions.width - 20; - overlayText.y = renderer.settings.appHeight - dimensions.height - 20; - }); + overlayText.once( + 'loaded', + (target: any, { dimensions }: NodeLoadedPayload) => { + overlayText.x = renderer.settings.appWidth - dimensions.width - 20; + overlayText.y = renderer.settings.appHeight - dimensions.height - 20; + }, + ); } const exampleSettings: ExampleSettings = { diff --git a/exports/main-api.ts b/exports/main-api.ts index 833f55d0..75f1197c 100644 --- a/exports/main-api.ts +++ b/exports/main-api.ts @@ -39,8 +39,8 @@ export * from '../src/main-api/INode.js'; export * from '../src/main-api/ICoreDriver.js'; export * from '../src/main-api/RendererMain.js'; -export * from '../src/render-drivers/main/MainRenderDriver.js'; -export * from '../src/render-drivers/threadx/ThreadXRenderDriver.js'; +export * from '../src/render-drivers/main/MainCoreDriver.js'; +export * from '../src/render-drivers/threadx/ThreadXCoreDriver.js'; export * from '../src/common/IAnimationController.js'; export * from '../src/common/CommonTypes.js'; diff --git a/src/main-api/ICoreDriver.ts b/src/main-api/ICoreDriver.ts index 4decb31e..6c675014 100644 --- a/src/main-api/ICoreDriver.ts +++ b/src/main-api/ICoreDriver.ts @@ -29,7 +29,7 @@ import type { RendererMain, RendererMainSettings } from './RendererMain.js'; * This interface is to be implemented by Core Drivers * * @remarks - * Both the {@link MainRenderDriver} and the {@link ThreadXRenderDriver} exist + * Both the {@link MainCoreDriver} and the {@link ThreadXCoreDriver} exist * that implement this interface to support both the single-threaded and * multi-threaded Core modes. */ diff --git a/src/main-api/INode.ts b/src/main-api/INode.ts index ce935900..0acbe4c6 100644 --- a/src/main-api/INode.ts +++ b/src/main-api/INode.ts @@ -417,8 +417,8 @@ export interface INodeEvents { * For text rendering, see {@link ITextNode}. * * Nodes are represented by an interface since they may be implemented in - * different ways depending on the Core Driver. For example, the MainRenderDriver - * implements it with it's `MainOnlyNode` while the ThreadXRenderDriver implements + * different ways depending on the Core Driver. For example, the MainCoreDriver + * implements it with it's `MainOnlyNode` while the ThreadXCoreDriver implements * it with it's `ThreadXMainNode`. */ export interface INode extends INodeWritableProps, IEventEmitter { diff --git a/src/main-api/RendererMain.ts b/src/main-api/RendererMain.ts index 9dd75935..4b60d8cd 100644 --- a/src/main-api/RendererMain.ts +++ b/src/main-api/RendererMain.ts @@ -213,7 +213,7 @@ export interface RendererMainSettings { * * Example: * ```ts - * import { RendererMain, MainRenderDriver } from '@lightningjs/renderer'; + * import { RendererMain, MainCoreDriver } from '@lightningjs/renderer'; * * // Initialize the Renderer * const renderer = new RendererMain( @@ -222,7 +222,7 @@ export interface RendererMainSettings { * appHeight: 1080 * }, * 'app', - * new MainRenderDriver(), + * new MainCoreDriver(), * ); * ``` */ diff --git a/src/render-drivers/main/MainRenderDriver.ts b/src/render-drivers/main/MainCoreDriver.ts similarity index 98% rename from src/render-drivers/main/MainRenderDriver.ts rename to src/render-drivers/main/MainCoreDriver.ts index f6b36477..3a982a98 100644 --- a/src/render-drivers/main/MainRenderDriver.ts +++ b/src/render-drivers/main/MainCoreDriver.ts @@ -33,7 +33,7 @@ import type { import { MainOnlyTextNode } from './MainOnlyTextNode.js'; import { loadCoreExtension } from '../utils.js'; -export class MainRenderDriver implements ICoreDriver { +export class MainCoreDriver implements ICoreDriver { private root: MainOnlyNode | null = null; private stage: Stage | null = null; private rendererMain: RendererMain | null = null; diff --git a/src/render-drivers/threadx/ThreadXRenderDriver.ts b/src/render-drivers/threadx/ThreadXCoreDriver.ts similarity index 99% rename from src/render-drivers/threadx/ThreadXRenderDriver.ts rename to src/render-drivers/threadx/ThreadXCoreDriver.ts index 593b2bbb..7ee064f4 100644 --- a/src/render-drivers/threadx/ThreadXRenderDriver.ts +++ b/src/render-drivers/threadx/ThreadXCoreDriver.ts @@ -46,7 +46,7 @@ export interface ThreadXRendererSettings { coreWorkerUrl: string; } -export class ThreadXRenderDriver implements ICoreDriver { +export class ThreadXCoreDriver implements ICoreDriver { private settings: ThreadXRendererSettings; private threadx: ThreadX; private rendererMain: RendererMain | null = null;