Browse Source

Pull request #1720: KERNEL-6566 补充utils目录

Merge in VISUAL/fineui from ~ROY.LIU/fineui:master to master

* commit '609722a81116fa8360920b11c47a96a2ee5a610a':
  补充utils目录
master
Roy.Liu 4 years ago
parent
commit
9604a5fb24
  1. 5
      typescript/core/controller/controller.layer.ts
  2. 4
      typescript/core/utils/aes.ts
  3. 4
      typescript/core/utils/aspect.ts
  4. 4
      typescript/core/utils/base64.ts
  5. 14
      typescript/core/utils/cache.ts
  6. 47
      typescript/core/utils/cellSizeAndPositionManager.ts
  7. 3
      typescript/core/utils/chinesePY.ts
  8. 8
      typescript/core/utils/events/mousemovetracker.ts
  9. 4
      typescript/core/utils/events/wheelhandler.ts
  10. 13
      typescript/core/utils/heap.ts
  11. 34
      typescript/core/utils/index.ts
  12. 11
      typescript/core/utils/linkedHashMap.ts
  13. 14
      typescript/core/utils/lru.ts
  14. 19
      typescript/core/utils/prefixIntervalTree.ts
  15. 21
      typescript/core/utils/queue.ts
  16. 12
      typescript/core/utils/sectionManager.ts
  17. 50
      typescript/core/utils/tree.ts
  18. 18
      typescript/core/utils/vector.ts
  19. 4
      typescript/index.ts

5
typescript/core/controller/controller.layer.ts

@ -0,0 +1,5 @@
import { Controller } from '../controller';
export declare class LayerController extends Controller {
make(name: string, container: , op, context)
}

4
typescript/core/utils/aes.ts

@ -0,0 +1,4 @@
export type _aes = {
aesEncrypt: (text: string, key:string) => string
aesDecrypt: (text: string, key:string) => string
}

4
typescript/core/utils/aspect.ts

@ -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}
}

4
typescript/core/utils/base64.ts

@ -0,0 +1,4 @@
export type _base64 = {
encode: (input: string) => string
decode: (text: string) => string
}

14
typescript/core/utils/cache.ts

@ -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
}

47
typescript/core/utils/cellSizeAndPositionManager.ts

@ -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;
}

3
typescript/core/utils/chinesePY.ts

@ -0,0 +1,3 @@
export type _chinesePY = {
makeFirstPY: (str: string, options: { ignoreMulti?: boolean, splitChar?: string }) => string
}

8
typescript/core/utils/events/mousemovetracker.ts

@ -0,0 +1,8 @@
export declare class MouseMoveTracker {
captureMouseMoves(event: MouseEvent): void;
releaseMouseMoves(): void;
isDragging(): boolean;
_onMouseMove(event: MouseEvent): void;
_didMouseMove(): void;
_onMouseUp(): void;
}

4
typescript/core/utils/events/wheelhandler.ts

@ -0,0 +1,4 @@
export declare class WheelHandler {
onWheel(event: WheelEvent): void
_didWheel(): void
}

13
typescript/core/utils/heap.ts

@ -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;
}

34
typescript/core/utils/index.ts

@ -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
}

11
typescript/core/utils/linkedHashMap.ts

@ -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[];
}

14
typescript/core/utils/lru.ts

@ -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
}

19
typescript/core/utils/prefixIntervalTree.ts

@ -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;
}

21
typescript/core/utils/queue.ts

@ -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;
}

12
typescript/core/utils/sectionManager.ts

@ -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;
}

50
typescript/core/utils/tree.ts

@ -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;
}

18
typescript/core/utils/vector.ts

@ -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[];
}

4
typescript/index.ts

@ -144,8 +144,10 @@ import { FloatCenterLayout } from './core/wrapper/layout/middle/middle.float.cen
import { _msg } from './base/foundation/message';
import { _web } from './core/platform/web';
import { DynamicYearMonthPopup } from './widget/yearmonth/popup.yearmonth';
import { _utils } from './core/utils';
export interface BI extends _func, _i18n, _base, _inject, _var, _web {
export interface BI extends _func, _i18n, _base, _inject, _var, _web, _utils {
OB: typeof OB;
Plugin: _Plugin;
Widget: typeof Widget;

Loading…
Cancel
Save