You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@leafer/renderer

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafer/renderer - npm Package Compare versions

Comparing version
1.5.3
to
1.6.0
+3
-3
package.json
{
"name": "@leafer/renderer",
"version": "1.5.3",
"version": "1.6.0",
"description": "@leafer/renderer",

@@ -25,7 +25,7 @@ "author": "Chao (Leafer) Wan",

"dependencies": {
"@leafer/core": "1.5.3"
"@leafer/core": "1.6.0"
},
"devDependencies": {
"@leafer/interface": "1.5.3"
"@leafer/interface": "1.6.0"
}
}

@@ -1,2 +0,2 @@

import { ILeaf, ILeaferCanvas, IRenderer, IRendererConfig, IEventListenerId, IBounds, IFunction, IRenderOptions } from '@leafer/interface'
import { ILeaf, ILeaferBase, ILeaferCanvas, IRenderer, IRendererConfig, IEventListenerId, IBounds, IFunction, IRenderOptions } from '@leafer/interface'
import { LayoutEvent, RenderEvent, ResizeEvent, ImageManager, Bounds, DataHelper, Platform, Debug, Run } from '@leafer/core'

@@ -29,2 +29,4 @@

static clipSpread = 10
protected renderBounds: IBounds

@@ -64,2 +66,9 @@ protected renderOptions: IRenderOptions

public checkRender(): void {
if (this.running) {
if (this.changed && this.canvas.view) this.render()
this.target.emit(RenderEvent.NEXT)
}
}
public render(callback?: IFunction): void {

@@ -75,3 +84,2 @@ if (!(this.running && this.canvas.view)) return this.update()

try {
if (!target.isApp) target.app.emit(RenderEvent.CHILD_START, target)
this.emitRender(RenderEvent.START)

@@ -152,19 +160,11 @@ this.renderOnce(callback)

const t = Run.start('PartRender')
const { canvas } = this
const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds)
const bounds = block.getIntersect(canvas.bounds)
const includes = block.includes(this.target.__world)
const realBounds = new Bounds(bounds)
canvas.save()
if (includes && !Debug.showRepaint) {
canvas.clear()
} else {
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil()
canvas.clearWorld(bounds, true)
canvas.clipWorld(bounds, true)
}
bounds.spread(Renderer.clipSpread).ceil()
canvas.clearWorld(bounds, true)
canvas.clipWorld(bounds, true)
this.__render(bounds, includes, realBounds)
this.__render(bounds, block.includes(this.target.__world), realBounds)
canvas.restore()

@@ -188,8 +188,8 @@

protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds,): void {
const options: IRenderOptions = bounds.includes(this.target.__world) ? { includes } : { bounds, includes }
const { canvas } = this, options: IRenderOptions = includes ? { includes } : { bounds, includes }
if (this.needFill) this.canvas.fillWorld(bounds, this.config.fill)
if (Debug.showRepaint) this.canvas.strokeWorld(bounds, 'red')
if (this.needFill) canvas.fillWorld(bounds, this.config.fill)
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds)
this.target.__render(this.canvas, options)
this.target.__render(canvas, options)

@@ -200,11 +200,5 @@ this.renderBounds = realBounds = realBounds || bounds

if (Debug.showHitView) this.renderHitView(options)
if (Debug.showBoundsView) this.renderBoundsView(options)
this.canvas.updateRender(realBounds)
canvas.updateRender(realBounds)
}
public renderHitView(_options: IRenderOptions): void { }
public renderBoundsView(_options: IRenderOptions): void { }
public addBlock(block: IBounds): void {

@@ -226,2 +220,4 @@ if (!this.updateBlocks) this.updateBlocks = []

protected __requestRender(): void {
const target = this.target as ILeaferBase
if (target.parentApp) return target.parentApp.renderer.update(false) // App 模式下统一走 app 控制渲染帧
if (this.requestTime) return

@@ -231,9 +227,17 @@

Platform.requestRender(() => {
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)))
this.requestTime = 0
if (this.running) {
if (this.changed && this.canvas.view) this.render()
this.target.emit(RenderEvent.NEXT)
if (target.isApp) {
target.emit(RenderEvent.CHILD_START, target);
(target.children as ILeaferBase[]).forEach(leafer => {
leafer.renderer.FPS = this.FPS
leafer.renderer.checkRender()
})
target.emit(RenderEvent.CHILD_END, target)
}
this.checkRender()
})

@@ -240,0 +244,0 @@ }

@@ -17,2 +17,3 @@ import { IRenderer, ILeaf, ILeaferCanvas, IBounds, IRendererConfig, IRenderOptions, IEventListenerId, IFunction } from '@leafer/interface';

config: IRendererConfig;
static clipSpread: number;
protected renderBounds: IBounds;

@@ -29,2 +30,3 @@ protected renderOptions: IRenderOptions;

requestLayout(): void;
checkRender(): void;
render(callback?: IFunction): void;

@@ -37,4 +39,2 @@ renderAgain(): void;

protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds): void;
renderHitView(_options: IRenderOptions): void;
renderBoundsView(_options: IRenderOptions): void;
addBlock(block: IBounds): void;

@@ -41,0 +41,0 @@ mergeBlocks(): void;