forked from fanruan/fineui
Browse Source
Merge in VISUAL/fineui from ~ROY.LIU/fineui:master to master * commit '609722a81116fa8360920b11c47a96a2ee5a610a': 补充utils目录master
Roy.Liu
4 years ago
19 changed files with 288 additions and 1 deletions
@ -0,0 +1,5 @@
|
||||
import { Controller } from '../controller'; |
||||
|
||||
export declare class LayerController extends Controller { |
||||
make(name: string, container: , op, context)
|
||||
} |
@ -0,0 +1,4 @@
|
||||
export type _aes = { |
||||
aesEncrypt: (text: string, key:string) => string |
||||
aesDecrypt: (text: string, key:string) => string |
||||
} |
@ -0,0 +1,4 @@
|
||||
export type _aspect = { |
||||
before: (target: object, methodName: string, advice: Function) => { advice: Function, index: number, remove: () => void} |
||||
after: (target: object, methodName: string, advice: Function) => { advice: Function, index: number, remove: () => void} |
||||
} |
@ -0,0 +1,4 @@
|
||||
export type _base64 = { |
||||
encode: (input: string) => string |
||||
decode: (text: string) => string |
||||
} |
@ -0,0 +1,14 @@
|
||||
export type _cache = { |
||||
setUsername: (username: string) => void |
||||
getUsername: () => string |
||||
_getKeyPrefix: () => string |
||||
_generateKey: (key?: string) => void |
||||
getItem: (key?: string) => string |
||||
setItem: (key: string, value: any) => void |
||||
removeItem: (key: string) => void |
||||
clear: () => void |
||||
keys: () => string[] |
||||
addCookie: (name: string, value: any, path?: string, expiresHours?: number) => void |
||||
getCookie: (name: string) => string |
||||
deleteCookie: (name: string, path?: string) => void |
||||
} |
@ -0,0 +1,47 @@
|
||||
export declare class CellSizeAndPositionManager { |
||||
_cellSizeGetter: (index: number) => number; |
||||
_cellCount: number; |
||||
_estimatedCellSize: number; |
||||
_cellSizeAndPositionData: object; |
||||
_lastMeasuredIndex: number; |
||||
|
||||
constructor(cellCount: number, cellSizeGetter: (index: number) => number, estimatedCellSize: number); |
||||
|
||||
configure(cellCount: number, estimatedCellSize: number): void; |
||||
getCellCount(): number; |
||||
getEstimatedCellSize(): number; |
||||
getLastMeasuredIndex(): number; |
||||
getSizeAndPositionOfCell(index: number): { offset: number, size: number}; |
||||
getSizeAndPositionOfLastMeasuredCell(): { offset: number, size: number}; |
||||
getTotalSize(): number; |
||||
getUpdatedOffsetForIndex(align: string, containerSize:number, currentOffset:number, targetIndex:number): number; |
||||
getVisibleCellRange(containerSize: number, offset: number): { start: number, stop: number}; |
||||
resetCell(index: number): void; |
||||
_binarySearch(high: number, low: number, offset: number): number; |
||||
_exponentialSearch(index: number, offset: number): number; |
||||
_findNearestCell(offset: number):number; |
||||
|
||||
} |
||||
|
||||
export declare class ScalingCellSizeAndPositionManager { |
||||
_cellSizeAndPositionManager: CellSizeAndPositionManager; |
||||
_maxScrollSize: number; |
||||
|
||||
constructor(cellCount: number, cellSizeGetter: (index: number) => number, estimatedCellSize: number, maxScrollSize: number); |
||||
|
||||
configure(): void; |
||||
getCellCount(): number; |
||||
getEstimatedCellSize(): number; |
||||
getLastMeasuredIndex(): number; |
||||
getOffsetAdjustment(containerSize: number, offset: number):number; |
||||
getSizeAndPositionOfCell(index: number): number; |
||||
getSizeAndPositionOfLastMeasuredCell(): number; |
||||
getTotalSize(): number; |
||||
getUpdatedOffsetForIndex(align: number, containerSize: number, currentOffset: number, targetIndex: number): number; |
||||
getVisibleCellRange(containerSize: number, offset: number): { start: number, stop: number}; |
||||
resetCell(index: number): void; |
||||
_getOffsetPercentage(containerSize: number, offset: number, totalSize: number): number; |
||||
_offsetToSafeOffset(containerSize: number, offset: number): number; |
||||
_safeOffsetToOffset(containerSize: number, offset: number): number; |
||||
|
||||
} |
@ -0,0 +1,3 @@
|
||||
export type _chinesePY = { |
||||
makeFirstPY: (str: string, options: { ignoreMulti?: boolean, splitChar?: string }) => string |
||||
} |
@ -0,0 +1,8 @@
|
||||
export declare class MouseMoveTracker { |
||||
captureMouseMoves(event: MouseEvent): void; |
||||
releaseMouseMoves(): void; |
||||
isDragging(): boolean; |
||||
_onMouseMove(event: MouseEvent): void; |
||||
_didMouseMove(): void; |
||||
_onMouseUp(): void; |
||||
} |
@ -0,0 +1,4 @@
|
||||
export declare class WheelHandler { |
||||
onWheel(event: WheelEvent): void |
||||
_didWheel(): void |
||||
} |
@ -0,0 +1,13 @@
|
||||
export declare class Heap<T> { |
||||
_items: T[]; |
||||
_size: number; |
||||
_comparator: (a: T, b: T) => boolean; |
||||
|
||||
constructor(items: T[], comparator?: (a: T, b: T) => boolean); |
||||
|
||||
empty(): boolean; |
||||
pop(): T; |
||||
push(item: T): void; |
||||
size(): number; |
||||
peek(): T; |
||||
} |
@ -0,0 +1,34 @@
|
||||
import { _aes } from './aes'; |
||||
import { _aspect } from './aspect'; |
||||
import { _base64 } from './base64'; |
||||
import { _cache } from './cache'; |
||||
import { _chinesePY } from './chinesePY'; |
||||
import { MouseMoveTracker } from './events/mousemovetracker'; |
||||
import { WheelHandler } from './events/wheelhandler'; |
||||
import { CellSizeAndPositionManager, ScalingCellSizeAndPositionManager } from './cellSizeAndPositionManager'; |
||||
import { Heap } from './heap'; |
||||
import { LinkedHashMap } from './linkedHashMap'; |
||||
import { LRU } from './lru'; |
||||
import { PrefixIntervalTree } from './prefixIntervalTree'; |
||||
import { Queue } from './queue'; |
||||
import { Section } from './sectionManager'; |
||||
import { Tree } from './tree'; |
||||
import { Vector, Region } from './vector'; |
||||
|
||||
export interface _utils extends _aes, _base64, _chinesePY { |
||||
aspect: _aspect |
||||
Cache: _cache |
||||
MouseMoveTracker: typeof MouseMoveTracker |
||||
WheelHandler: typeof WheelHandler |
||||
CellSizeAndPositionManager: typeof CellSizeAndPositionManager |
||||
ScalingCellSizeAndPositionManager: typeof ScalingCellSizeAndPositionManager |
||||
Heap: typeof Heap |
||||
LinkedHashMap: typeof LinkedHashMap |
||||
LRU: typeof LRU |
||||
PrefixIntervalTree: typeof PrefixIntervalTree |
||||
Queue: typeof Queue |
||||
Section: typeof Section |
||||
Tree: typeof Tree |
||||
Vector: typeof Vector |
||||
Region: typeof Region |
||||
} |
@ -0,0 +1,11 @@
|
||||
export declare class LinkedHashMap { |
||||
array: any[]; |
||||
map: object; |
||||
has(key: any): boolean; |
||||
add(key: any,value: any): void; |
||||
remove(key: any): void; |
||||
size(): number; |
||||
each(fn: (key?: any, value?: any, i?: number, array?: any[], map?: object) => any): void; |
||||
get(key: any): any; |
||||
toArray(): any[]; |
||||
} |
@ -0,0 +1,14 @@
|
||||
export declare class LRU { |
||||
size: number; |
||||
limit: number; |
||||
head: object; |
||||
tail: object; |
||||
_keymap: object; |
||||
|
||||
constructor(limit?: number); |
||||
|
||||
put(key: any, value: any):void |
||||
shift(): object; |
||||
get(key: any, returnEntry?: boolean): any; |
||||
has(key: any): boolean |
||||
} |
@ -0,0 +1,19 @@
|
||||
export declare class PrefixIntervalTree { |
||||
_size: number; |
||||
_half: number; |
||||
_heap: Int32Array; |
||||
constructor(xs: any[]); |
||||
set(index: number, value: any): void; |
||||
get(index: number): any; |
||||
getSize(): number; |
||||
sumUntil(end: number):number; |
||||
sumTo(inclusiveEnd: number): number; |
||||
sum(begin: number, end: number):number; |
||||
greatestLowerBound(t: number): number; |
||||
greatestStrictLowerBound(t: number): number; |
||||
leastUpperBound(t: number): number; |
||||
leastStrictUpperBound(t: number): number; |
||||
static uniform(size: number, initialValue: any): PrefixIntervalTree; |
||||
static empty(size: number, initialValue: any): PrefixIntervalTree; |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
export declare class Queue { |
||||
capacity: number; |
||||
array: any[]; |
||||
constructor(capacity: number); |
||||
contains(v: any): boolean; |
||||
indexOf(v: any): boolean; |
||||
getElementByIndex(index: number): any; |
||||
push(v: any): void; |
||||
pop(): void; |
||||
shift(): void; |
||||
unshift(v: any): void; |
||||
remove(v: any): void; |
||||
splice(...args: any[]): void; |
||||
slice(start?: number, end?: number): void; |
||||
size(): number; |
||||
each(fn: (i?: number, item?: any, array?: any[]) => any, scope: object): void |
||||
toArray(): any[]; |
||||
fromArray(array: any[]): void |
||||
clear(): void;
|
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
export declare class Section { |
||||
height: number; |
||||
width: number; |
||||
x: number; |
||||
y: number; |
||||
constructor(height: number, width: number, x: number, y: number); |
||||
addCellIndex(index: any): void; |
||||
getCellIndices(): any[]; |
||||
getSections(height: number, width: number, x: number, y: number): Section[]; |
||||
getTotalSectionCount(): number; |
||||
registerCell(cellMetadatum: { height: number, width: number, x: number, y: number }, index: any): void; |
||||
} |
@ -0,0 +1,50 @@
|
||||
export declare class Node { |
||||
id: any; |
||||
set(key: any, value: any): void; |
||||
get(key: any): any; |
||||
isLeaf(): boolean; |
||||
getChildren(): Node[]; |
||||
getChildrenLength(): number; |
||||
getFirstChild(): Node; |
||||
getLastChild(): Node; |
||||
setLeft(left: Node): void; |
||||
getLeft(): Node; |
||||
setRight(left: Node): void; |
||||
getRight(): Node; |
||||
setParent(parent: Node): void; |
||||
getParent(): Node; |
||||
getChild(index: number): Node; |
||||
getChildIndex(id: any): Node; |
||||
removeChild(id: any): void; |
||||
removeChildByIndex(index: number): void; |
||||
removeAllChilds(): void; |
||||
addChild(child: Node, index: number): void; |
||||
equals(obj: Node): boolean; |
||||
clear(): void; |
||||
} |
||||
|
||||
|
||||
export declare class Tree { |
||||
root: Node; |
||||
addNode(node: Node, newNode: Node, index: number):void; |
||||
isRoot(node: Node): boolean; |
||||
getRoot(): Node; |
||||
clear():void; |
||||
initTree(nodes: any[]):void; |
||||
toJSON(node: Node): object[]; |
||||
toJSONWithNode(node: Node): object[]; |
||||
search(root: Node, target: any, param?: any): boolean; |
||||
traverse(callback: Function): void; |
||||
recursion(callback: Function): void; |
||||
inOrderTraverse(callback: Function): void; |
||||
nrInOrderTraverse(callback: Function): void; |
||||
preOrderTraverse(callback: Function): void; |
||||
nrPreOrderTraverse(callback: Function): void; |
||||
postOrderTraverse(callback: Function): void; |
||||
nrPostOrderTraverse(callback: Function): void; |
||||
static transformToArrayFormat(nodes: Node | Node[], pId: any): Node[]; |
||||
static arrayFormat(nodes: Node | Node[], pId: any): Node[]; |
||||
static transformToTreeFormat(sNodes: Node | Node[]): Node[]; |
||||
static treeFormat(sNodes: Node | Node[]): Node[]; |
||||
static traversal(array: Node[], callback: Function, pNode: Node): void; |
||||
} |
@ -0,0 +1,18 @@
|
||||
export declare class Vector { |
||||
x: number; |
||||
y: number; |
||||
constructor(x: number,y: number); |
||||
cross(v: Vector): number; |
||||
length(v: Vector): number; |
||||
} |
||||
|
||||
export declare class Region { |
||||
x: number; |
||||
y: number; |
||||
w: number; |
||||
h: number; |
||||
constructor(x: number,y: number,w: number,h: number); |
||||
isIntersects(obj: { x: number,y: number,w: number,h: number }):boolean; |
||||
isPointInside(x: number,y: number): boolean; |
||||
getPosition(): number[]; |
||||
} |
Loading…
Reference in new issue