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

@leafer/event

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/event - npm Package Compare versions

Comparing version
1.8.0
to
1.9.0
+6
-5
package.json
{
"name": "@leafer/event",
"version": "1.8.0",
"version": "1.9.0",
"description": "@leafer/event",

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

"dependencies": {
"@leafer/decorator": "1.8.0",
"@leafer/math": "1.8.0",
"@leafer/platform": "1.8.0"
"@leafer/decorator": "1.9.0",
"@leafer/math": "1.9.0",
"@leafer/data": "1.9.0",
"@leafer/platform": "1.9.0"
},
"devDependencies": {
"@leafer/interface": "1.8.0"
"@leafer/interface": "1.9.0"
}
}
import { IEventListener, IEventListenerMap, IEventListenerItem, IEventListenerId, IEvent, IObject, IEventTarget, IEventOption, IEventer, IEventParamsMap, InnerId, IEventParams, IFunction } from '@leafer/interface'
import { EventCreator } from '@leafer/platform'
import { isArray, isObject, isString, isUndefined } from '@leafer/data'

@@ -30,4 +31,4 @@ import { BoundsEvent, boundsEventMap } from './BoundsEvent'

let event: IFunction | [IFunction, IEventOption]
if (type instanceof Array) (type as IEventParams[]).forEach(item => this.on(item[0], item[1], item[2]))
else for (let key in type as IEventParamsMap) (event = (type as IEventParamsMap)[key]) instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event)
if (isArray(type)) (type as IEventParams[]).forEach(item => this.on(item[0], item[1], item[2]))
else for (let key in type as IEventParamsMap) isArray(event = (type as IEventParamsMap)[key]) ? this.on(key, event[0], event[1]) : this.on(key, event)
return

@@ -50,3 +51,3 @@ }

const map = __getListenerMap(this, capture, true)
const typeList = typeof type === 'string' ? type.split(' ') : type as string[]
const typeList = isString(type) ? type.split(' ') : type as string[]
const item = once ? { listener, once } : { listener }

@@ -71,3 +72,3 @@

const typeList = typeof type === 'string' ? type.split(' ') : type
const typeList = isString(type) ? type.split(' ') : type

@@ -114,3 +115,3 @@ if (listener) {

public on_(type: string | string[] | IEventParams[], listener?: IEventListener, bind?: IObject, options?: IEventOption): IEventListenerId {
if (!listener) (type instanceof Array) && (type as IEventParams[]).forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]))
if (!listener) isArray(type) && (type as IEventParams[]).forEach(item => this.on(item[0], item[2] ? item[1] = item[1].bind(item[2]) : item[1], item[3]))
else this.on(type, bind ? listener = listener.bind(bind) : listener, options)

@@ -122,5 +123,5 @@ return { type, current: this as any, listener, options }

if (!id) return
const list = id instanceof Array ? id : [id]
const list = isArray(id) ? id : [id]
list.forEach(item => {
if (!item.listener) (item.type instanceof Array) && (item.type as IEventParams[]).forEach(v => item.current.off(v[0], v[1], v[3]))
if (!item.listener) isArray(item.type) && (item.type as IEventParams[]).forEach(v => item.current.off(v[0], v[1], v[3]))
else item.current.off(item.type as string | string[], item.listener, item.options)

@@ -132,4 +133,4 @@ })

public once(type: string | string[] | IEventParams[], listener?: IEventListener, captureOrBind?: boolean | IObject, capture?: boolean): void {
if (!listener) return (type instanceof Array) && (type as IEventParams[]).forEach(item => this.once(item[0], item[1], item[2], item[3]))
if (typeof captureOrBind === 'object') listener = listener.bind(captureOrBind)
if (!listener) return isArray(type) && (type as IEventParams[]).forEach(item => this.once(item[0], item[1], item[2], item[3]))
if (isObject(captureOrBind)) listener = listener.bind(captureOrBind)
else capture = captureOrBind

@@ -171,3 +172,3 @@ this.on(type, listener, { once: true, capture })

const hasB = b && b[type], hasC = c && c[type]
return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB))
return !!(isUndefined(capture) ? (hasB || hasC) : (capture ? hasC : hasB))
}

@@ -174,0 +175,0 @@

@@ -9,5 +9,5 @@ export { ChildEvent } from './ChildEvent'

export { RenderEvent } from './RenderEvent'
export { LeaferEvent } from './LeaferEvent'
export { LeaferEvent, leaferTransformAttrMap } from './LeaferEvent'
export { Event } from './Event'
export { Eventer } from './Eventer'

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

import { ILeaferEvent } from '@leafer/interface'
import { ILeaferEvent, IStringMap } from '@leafer/interface'

@@ -23,2 +23,21 @@ import { Event } from './Event'

// 变换操作
static TRANSFORM = 'leafer.transform'
static MOVE = 'leafer.move'
static SCALE = 'leafer.scale'
static ROTATE = 'leafer.rotate'
static SKEW = 'leafer.skew'
}
const { MOVE, SCALE, ROTATE, SKEW } = LeaferEvent
export const leaferTransformAttrMap: IStringMap = {
x: MOVE,
y: MOVE,
scaleX: SCALE,
scaleY: SCALE,
rotation: ROTATE,
skewX: SKEW,
skewY: SKEW
}
import { ILeaf, INumberMap, IResizeEvent, IScreenSizeData } from '@leafer/interface'
import { isObject, isUndefined } from '@leafer/data'

@@ -34,3 +35,3 @@ import { Event } from './Event'

constructor(size: IScreenSizeData | string, oldSize?: IScreenSizeData) {
if (typeof size === 'object') {
if (isObject(size)) {
super(ResizeEvent.RESIZE)

@@ -45,5 +46,5 @@ Object.assign(this, size)

static isResizing(leaf: ILeaf): boolean {
return this.resizingKeys && this.resizingKeys[leaf.innerId] !== undefined
return this.resizingKeys && !isUndefined(this.resizingKeys[leaf.innerId])
}
}

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

import { IEvent, IObject, IEventTarget, IChildEvent, ILeaf, IPropertyEvent, IImageEvent, ILeaferImage, IBoundsEvent, IResizeEvent, INumberMap, IScreenSizeData, IWatchEvent, IWatchEventData, ILayoutEvent, ILayoutBlockData, IRenderEvent, IBounds, IRenderOptions, ILeaferEvent, IEventer, InnerId, IEventListenerMap, IEventParamsMap, IEventParams, IEventListener, IEventOption, IEventListenerId } from '@leafer/interface';
import { IEvent, IObject, IEventTarget, IChildEvent, ILeaf, IPropertyEvent, IImageEvent, ILeaferImage, IBoundsEvent, IResizeEvent, INumberMap, IScreenSizeData, IWatchEvent, IWatchEventData, ILayoutEvent, ILayoutBlockData, IRenderEvent, IBounds, IRenderOptions, ILeaferEvent, IStringMap, IEventer, InnerId, IEventListenerMap, IEventParamsMap, IEventParams, IEventListener, IEventOption, IEventListenerId } from '@leafer/interface';

@@ -122,3 +122,9 @@ declare class Event implements IEvent {

static END: string;
static TRANSFORM: string;
static MOVE: string;
static SCALE: string;
static ROTATE: string;
static SKEW: string;
}
declare const leaferTransformAttrMap: IStringMap;

@@ -144,2 +150,2 @@ declare class Eventer implements IEventer {

export { BoundsEvent, ChildEvent, Event, Eventer, ImageEvent, LayoutEvent, LeaferEvent, PropertyEvent, RenderEvent, ResizeEvent, WatchEvent };
export { BoundsEvent, ChildEvent, Event, Eventer, ImageEvent, LayoutEvent, LeaferEvent, PropertyEvent, RenderEvent, ResizeEvent, WatchEvent, leaferTransformAttrMap };