@dxyl/utils 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +8985 -0
- package/dist/index.umd.js +28 -0
- package/lib/glslang/glslang.d.ts +14 -0
- package/lib/glslang/glslang.js +113 -0
- package/lib/glslang/glslang.wasm +0 -0
- package/lib/twgsl/twgsl.js +53 -0
- package/lib/twgsl/twgsl.wasm +0 -0
- package/package.json +27 -34
- package/readme.md +0 -0
- package/types/Color.d.ts +69 -0
- package/types/Options.d.ts +70 -0
- package/types/antv-util/color/arr2rgb.d.ts +12 -0
- package/types/antv-util/color/gradient.d.ts +6 -0
- package/types/antv-util/color/index.d.ts +4 -0
- package/types/antv-util/color/rgb2arr.d.ts +6 -0
- package/types/antv-util/color/tocssgradient.d.ts +1 -0
- package/types/antv-util/color/torgb.d.ts +6 -0
- package/types/antv-util/helper/index.d.ts +2 -0
- package/types/antv-util/helper/mod.d.ts +1 -0
- package/types/antv-util/helper/to-radian.d.ts +1 -0
- package/types/antv-util/index.d.ts +3 -0
- package/types/antv-util/matrix/index.d.ts +27 -0
- package/types/antv-util/path/convert/path-2-absolute.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-curve.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-string.d.ts +6 -0
- package/types/antv-util/path/index.d.ts +17 -0
- package/types/antv-util/path/parser/finalize-segment.d.ts +5 -0
- package/types/antv-util/path/parser/is-arc-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-digit-start.d.ts +6 -0
- package/types/antv-util/path/parser/is-path-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-space.d.ts +4 -0
- package/types/antv-util/path/parser/params-count.d.ts +13 -0
- package/types/antv-util/path/parser/params-parser.d.ts +10 -0
- package/types/antv-util/path/parser/parse-path-string.d.ts +6 -0
- package/types/antv-util/path/parser/path-parser.d.ts +16 -0
- package/types/antv-util/path/parser/scan-flag.d.ts +6 -0
- package/types/antv-util/path/parser/scan-param.d.ts +6 -0
- package/types/antv-util/path/parser/scan-segment.d.ts +6 -0
- package/types/antv-util/path/parser/skip-spaces.d.ts +7 -0
- package/types/antv-util/path/process/arc-2-cubic.d.ts +7 -0
- package/types/antv-util/path/process/clone-path.d.ts +2 -0
- package/types/antv-util/path/process/fix-arc.d.ts +2 -0
- package/types/antv-util/path/process/line-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/normalize-path.d.ts +8 -0
- package/types/antv-util/path/process/normalize-segment.d.ts +6 -0
- package/types/antv-util/path/process/quad-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/reverse-curve.d.ts +2 -0
- package/types/antv-util/path/process/round-path.d.ts +6 -0
- package/types/antv-util/path/process/segment-2-cubic.d.ts +2 -0
- package/types/antv-util/path/types.d.ts +122 -0
- package/types/antv-util/path/util/distance-square-root.d.ts +1 -0
- package/types/antv-util/path/util/equalize-segments.d.ts +2 -0
- package/types/antv-util/path/util/get-draw-direction.d.ts +2 -0
- package/types/antv-util/path/util/get-path-area.d.ts +8 -0
- package/types/antv-util/path/util/get-path-bbox-total-length.d.ts +5 -0
- package/types/antv-util/path/util/get-path-bbox.d.ts +5 -0
- package/types/antv-util/path/util/get-point-at-length.d.ts +5 -0
- package/types/antv-util/path/util/get-properties-at-length.d.ts +6 -0
- package/types/antv-util/path/util/get-properties-at-point.d.ts +7 -0
- package/types/antv-util/path/util/get-rotated-curve.d.ts +2 -0
- package/types/antv-util/path/util/get-total-length.d.ts +8 -0
- package/types/antv-util/path/util/is-absolute-array.d.ts +6 -0
- package/types/antv-util/path/util/is-curve-array.d.ts +9 -0
- package/types/antv-util/path/util/is-normalized-array.d.ts +7 -0
- package/types/antv-util/path/util/is-path-array.d.ts +5 -0
- package/types/antv-util/path/util/is-point-in-stroke.d.ts +5 -0
- package/types/antv-util/path/util/mid-point.d.ts +1 -0
- package/types/antv-util/path/util/path-length-factory.d.ts +7 -0
- package/types/antv-util/path/util/rotate-vector.d.ts +4 -0
- package/types/antv-util/path/util/segment-arc-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-cubic-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-line-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-quad-factory.d.ts +6 -0
- package/types/callbacks.d.ts +30 -0
- package/types/color/colord/src/colorModels/cmyk.d.ts +23 -0
- package/types/color/colord/src/colorModels/cmykString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hex.d.ts +5 -0
- package/types/color/colord/src/colorModels/hsl.d.ts +8 -0
- package/types/color/colord/src/colorModels/hslString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hsv.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwb.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/lab.d.ts +18 -0
- package/types/color/colord/src/colorModels/lch.d.ts +19 -0
- package/types/color/colord/src/colorModels/lchString.d.ts +7 -0
- package/types/color/colord/src/colorModels/rgb.d.ts +13 -0
- package/types/color/colord/src/colorModels/rgbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/xyz.d.ts +30 -0
- package/types/color/colord/src/colord.d.ts +103 -0
- package/types/color/colord/src/constants.d.ts +10 -0
- package/types/color/colord/src/extend.d.ts +4 -0
- package/types/color/colord/src/get/getBrightness.d.ts +7 -0
- package/types/color/colord/src/get/getContrast.d.ts +6 -0
- package/types/color/colord/src/get/getLuminance.d.ts +6 -0
- package/types/color/colord/src/get/getPerceivedDifference.d.ts +24 -0
- package/types/color/colord/src/helpers.d.ts +20 -0
- package/types/color/colord/src/index.d.ts +5 -0
- package/types/color/colord/src/manipulate/changeAlpha.d.ts +2 -0
- package/types/color/colord/src/manipulate/invert.d.ts +2 -0
- package/types/color/colord/src/manipulate/lighten.d.ts +2 -0
- package/types/color/colord/src/manipulate/mix.d.ts +2 -0
- package/types/color/colord/src/manipulate/saturate.d.ts +2 -0
- package/types/color/colord/src/parse.d.ts +8 -0
- package/types/color/colord/src/plugins/a11y.d.ts +38 -0
- package/types/color/colord/src/plugins/cmyk.d.ts +24 -0
- package/types/color/colord/src/plugins/harmonies.d.ts +16 -0
- package/types/color/colord/src/plugins/hwb.d.ts +23 -0
- package/types/color/colord/src/plugins/lab.d.ts +23 -0
- package/types/color/colord/src/plugins/lch.d.ts +24 -0
- package/types/color/colord/src/plugins/minify.d.ts +20 -0
- package/types/color/colord/src/plugins/mix.d.ts +27 -0
- package/types/color/colord/src/plugins/names.d.ts +19 -0
- package/types/color/colord/src/plugins/xyz.d.ts +14 -0
- package/types/color/colord/src/random.d.ts +2 -0
- package/types/color/colord/src/types.d.ts +67 -0
- package/types/data/immer.d.ts +262 -0
- package/types/data/immutable.d.ts +5127 -0
- package/types/data/mobx.d.ts +154 -0
- package/types/data/reactivity.d.ts +755 -0
- package/types/data/signals.d.ts +144 -0
- package/types/deepmerge.d.ts +16 -0
- package/types/events/eventTarget.d.ts +93 -0
- package/types/events/event_emiter.d.ts +43 -0
- package/types/events/eventemitter3.d.ts +135 -0
- package/types/events/mitt.d.ts +21 -0
- package/types/fast-deep-equal.d.ts +1 -0
- package/types/index.d.ts +20 -0
- package/types/ismobilejs.d.ts +46 -0
- package/types/lodash/augment.d.ts +2 -0
- package/types/lodash/cache.d.ts +14 -0
- package/types/lodash/clamp.d.ts +2 -0
- package/types/lodash/clear-animation-frame.d.ts +1 -0
- package/types/lodash/clone.d.ts +2 -0
- package/types/lodash/contains.d.ts +2 -0
- package/types/lodash/debounce.d.ts +2 -0
- package/types/lodash/deep-mix.d.ts +2 -0
- package/types/lodash/difference.d.ts +11 -0
- package/types/lodash/each.d.ts +2 -0
- package/types/lodash/ends-with.d.ts +3 -0
- package/types/lodash/every.d.ts +7 -0
- package/types/lodash/extend.d.ts +2 -0
- package/types/lodash/filter.d.ts +2 -0
- package/types/lodash/find-index.d.ts +2 -0
- package/types/lodash/find.d.ts +3 -0
- package/types/lodash/first-value.d.ts +2 -0
- package/types/lodash/fixed-base.d.ts +2 -0
- package/types/lodash/flatten-deep.d.ts +12 -0
- package/types/lodash/flatten.d.ts +11 -0
- package/types/lodash/for-in.d.ts +2 -0
- package/types/lodash/get-range.d.ts +6 -0
- package/types/lodash/get-type.d.ts +2 -0
- package/types/lodash/get-wrap-behavior.d.ts +9 -0
- package/types/lodash/get.d.ts +8 -0
- package/types/lodash/group-by.d.ts +6 -0
- package/types/lodash/group-to-map.d.ts +8 -0
- package/types/lodash/group.d.ts +2 -0
- package/types/lodash/has-key.d.ts +2 -0
- package/types/lodash/has-value.d.ts +2 -0
- package/types/lodash/has.d.ts +2 -0
- package/types/lodash/head.d.ts +1 -0
- package/types/lodash/identity.d.ts +2 -0
- package/types/lodash/index-of.d.ts +2 -0
- package/types/lodash/index.d.ts +108 -0
- package/types/lodash/is-arguments.d.ts +2 -0
- package/types/lodash/is-array-like.d.ts +2 -0
- package/types/lodash/is-array.d.ts +2 -0
- package/types/lodash/is-boolean.d.ts +2 -0
- package/types/lodash/is-date.d.ts +2 -0
- package/types/lodash/is-decimal.d.ts +2 -0
- package/types/lodash/is-element.d.ts +6 -0
- package/types/lodash/is-empty.d.ts +2 -0
- package/types/lodash/is-equal-with.d.ts +24 -0
- package/types/lodash/is-equal.d.ts +2 -0
- package/types/lodash/is-error.d.ts +2 -0
- package/types/lodash/is-even.d.ts +2 -0
- package/types/lodash/is-finite.d.ts +1 -0
- package/types/lodash/is-function.d.ts +2 -0
- package/types/lodash/is-integer.d.ts +2 -0
- package/types/lodash/is-match.d.ts +2 -0
- package/types/lodash/is-negative.d.ts +2 -0
- package/types/lodash/is-nil.d.ts +2 -0
- package/types/lodash/is-null.d.ts +2 -0
- package/types/lodash/is-number-equal.d.ts +1 -0
- package/types/lodash/is-number.d.ts +2 -0
- package/types/lodash/is-object-like.d.ts +2 -0
- package/types/lodash/is-object.d.ts +2 -0
- package/types/lodash/is-odd.d.ts +2 -0
- package/types/lodash/is-plain-object.d.ts +2 -0
- package/types/lodash/is-positive.d.ts +2 -0
- package/types/lodash/is-prototype.d.ts +2 -0
- package/types/lodash/is-reg-exp.d.ts +2 -0
- package/types/lodash/is-segment-equal.d.ts +2 -0
- package/types/lodash/is-string.d.ts +2 -0
- package/types/lodash/is-type.d.ts +2 -0
- package/types/lodash/is-undefined.d.ts +2 -0
- package/types/lodash/keys.d.ts +2 -0
- package/types/lodash/last.d.ts +1 -0
- package/types/lodash/lower-case.d.ts +2 -0
- package/types/lodash/lower-first.d.ts +2 -0
- package/types/lodash/map-values.d.ts +6 -0
- package/types/lodash/map.d.ts +2 -0
- package/types/lodash/max-by.d.ts +16 -0
- package/types/lodash/max.d.ts +19 -0
- package/types/lodash/memoize.d.ts +11 -0
- package/types/lodash/merge.d.ts +7 -0
- package/types/lodash/min-by.d.ts +16 -0
- package/types/lodash/min.d.ts +19 -0
- package/types/lodash/mix.d.ts +1 -0
- package/types/lodash/mod.d.ts +2 -0
- package/types/lodash/noop.d.ts +2 -0
- package/types/lodash/number2color.d.ts +2 -0
- package/types/lodash/omit.d.ts +3 -0
- package/types/lodash/parse-radius.d.ts +9 -0
- package/types/lodash/pick.d.ts +16 -0
- package/types/lodash/pull-at.d.ts +2 -0
- package/types/lodash/pull.d.ts +2 -0
- package/types/lodash/reduce.d.ts +3 -0
- package/types/lodash/remove.d.ts +2 -0
- package/types/lodash/request-animation-frame.d.ts +1 -0
- package/types/lodash/set.d.ts +8 -0
- package/types/lodash/size.d.ts +1 -0
- package/types/lodash/some.d.ts +7 -0
- package/types/lodash/sort-by.d.ts +7 -0
- package/types/lodash/starts-with.d.ts +3 -0
- package/types/lodash/substitute.d.ts +5 -0
- package/types/lodash/throttle.d.ts +6 -0
- package/types/lodash/to-array.d.ts +2 -0
- package/types/lodash/to-degree.d.ts +2 -0
- package/types/lodash/to-integer.d.ts +1 -0
- package/types/lodash/to-radian.d.ts +2 -0
- package/types/lodash/to-string.d.ts +2 -0
- package/types/lodash/types/index.d.ts +3 -0
- package/types/lodash/union.d.ts +2 -0
- package/types/lodash/uniq.d.ts +1 -0
- package/types/lodash/unique-id.d.ts +2 -0
- package/types/lodash/upper-case.d.ts +2 -0
- package/types/lodash/upper-first.d.ts +2 -0
- package/types/lodash/values-of-key.d.ts +2 -0
- package/types/lodash/values.d.ts +2 -0
- package/types/lodash/wrap-behavior.d.ts +9 -0
- package/types/parse-svg-path.d.ts +19 -0
- package/types/priority_queue.d.ts +41 -0
- package/types/radash/array.d.ts +209 -0
- package/types/radash/async.d.ts +99 -0
- package/types/radash/curry.d.ts +113 -0
- package/types/radash/index.d.ts +10 -0
- package/types/radash/number.d.ts +27 -0
- package/types/radash/object.d.ts +112 -0
- package/types/radash/random.d.ts +11 -0
- package/types/radash/series.d.ts +13 -0
- package/types/radash/string.d.ts +71 -0
- package/types/radash/typed.d.ts +26 -0
- package/types/stats.module.d.ts +3 -0
- package/README.md +0 -1
- package/dist/cjs/index.js +0 -19
- package/dist/umd/index.js +0 -23
- package/esm/extend.js +0 -3
- package/esm/index.js +0 -3
- package/lib/extend.js +0 -6
- package/lib/index.js +0 -6
- package/src/extend.ts +0 -6
- package/src/index.ts +0 -6
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc 信息
|
|
3
|
+
* @ref preact-signals
|
|
4
|
+
|
|
5
|
+
*/
|
|
6
|
+
declare const BRAND_SYMBOL: unique symbol;
|
|
7
|
+
type Node = {
|
|
8
|
+
_source: Signal;
|
|
9
|
+
_prevSource?: Node;
|
|
10
|
+
_nextSource?: Node;
|
|
11
|
+
_target: Computed | Effect;
|
|
12
|
+
_prevTarget?: Node;
|
|
13
|
+
_nextTarget?: Node;
|
|
14
|
+
_version: number;
|
|
15
|
+
_rollbackNode?: Node;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Combine multiple value updates into one "commit" at the end of the provided callback.
|
|
19
|
+
*
|
|
20
|
+
* Batches can be nested and changes are only flushed once the outermost batch callback
|
|
21
|
+
* completes.
|
|
22
|
+
*
|
|
23
|
+
* Accessing a signal that has been modified within a batch will reflect its updated
|
|
24
|
+
* value.
|
|
25
|
+
*
|
|
26
|
+
* @param fn The callback function.
|
|
27
|
+
* @returns The value returned by the callback.
|
|
28
|
+
*/
|
|
29
|
+
declare function batch<T>(fn: () => T): T;
|
|
30
|
+
/**
|
|
31
|
+
* Run a callback function that can access signal values without
|
|
32
|
+
* subscribing to the signal updates.
|
|
33
|
+
*
|
|
34
|
+
* @param fn The callback function.
|
|
35
|
+
* @returns The value returned by the callback.
|
|
36
|
+
*/
|
|
37
|
+
declare function untracked<T>(fn: () => T): T;
|
|
38
|
+
/**
|
|
39
|
+
* The base class for plain and computed signals.
|
|
40
|
+
*/
|
|
41
|
+
declare class Signal<T = any> {
|
|
42
|
+
/** @internal */
|
|
43
|
+
_value: unknown;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
* Version numbers should always be >= 0, because the special value -1 is used
|
|
47
|
+
* by Nodes to signify potentially unused but recyclable nodes.
|
|
48
|
+
*/
|
|
49
|
+
_version: number;
|
|
50
|
+
/** @internal */
|
|
51
|
+
_node?: Node;
|
|
52
|
+
/** @internal */
|
|
53
|
+
_targets?: Node;
|
|
54
|
+
constructor(value?: T);
|
|
55
|
+
/** @internal */
|
|
56
|
+
_refresh(): boolean;
|
|
57
|
+
/** @internal */
|
|
58
|
+
_subscribe(node: Node): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
_unsubscribe(node: Node): void;
|
|
61
|
+
subscribe(fn: (value: T) => void): () => void;
|
|
62
|
+
valueOf(): T;
|
|
63
|
+
toString(): string;
|
|
64
|
+
toJSON(): T;
|
|
65
|
+
peek(): T;
|
|
66
|
+
brand: typeof BRAND_SYMBOL;
|
|
67
|
+
get value(): T;
|
|
68
|
+
set value(value: T);
|
|
69
|
+
}
|
|
70
|
+
/** @internal */
|
|
71
|
+
declare function Signal(this: Signal, value?: unknown): void;
|
|
72
|
+
/**
|
|
73
|
+
* Create a new plain signal.
|
|
74
|
+
*
|
|
75
|
+
* @param value The initial value for the signal.
|
|
76
|
+
* @returns A new signal.
|
|
77
|
+
*/
|
|
78
|
+
export declare function signal<T>(value: T): Signal<T>;
|
|
79
|
+
export declare function signal<T = undefined>(): Signal<T | undefined>;
|
|
80
|
+
declare class Computed<T = any> extends Signal<T> {
|
|
81
|
+
_fn: () => T;
|
|
82
|
+
_sources?: Node;
|
|
83
|
+
_globalVersion: number;
|
|
84
|
+
_flags: number;
|
|
85
|
+
constructor(fn: () => T);
|
|
86
|
+
_notify(): void;
|
|
87
|
+
get value(): T;
|
|
88
|
+
}
|
|
89
|
+
declare function Computed(this: Computed, fn: () => unknown): void;
|
|
90
|
+
declare namespace Computed {
|
|
91
|
+
var prototype: Computed<any>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* An interface for read-only signals.
|
|
95
|
+
*/
|
|
96
|
+
interface ReadonlySignal<T = any> {
|
|
97
|
+
readonly value: T;
|
|
98
|
+
peek(): T;
|
|
99
|
+
subscribe(fn: (value: T) => void): () => void;
|
|
100
|
+
valueOf(): T;
|
|
101
|
+
toString(): string;
|
|
102
|
+
toJSON(): T;
|
|
103
|
+
brand: typeof BRAND_SYMBOL;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create a new signal that is computed based on the values of other signals.
|
|
107
|
+
*
|
|
108
|
+
* The returned computed signal is read-only, and its value is automatically
|
|
109
|
+
* updated when any signals accessed from within the callback function change.
|
|
110
|
+
*
|
|
111
|
+
* @param fn The effect callback.
|
|
112
|
+
* @returns A new read-only signal.
|
|
113
|
+
*/
|
|
114
|
+
declare function computed<T>(fn: () => T): ReadonlySignal<T>;
|
|
115
|
+
type EffectFn = () => void | (() => void);
|
|
116
|
+
declare class Effect {
|
|
117
|
+
_fn?: EffectFn;
|
|
118
|
+
_cleanup?: () => void;
|
|
119
|
+
_sources?: Node;
|
|
120
|
+
_nextBatchedEffect?: Effect;
|
|
121
|
+
_flags: number;
|
|
122
|
+
constructor(fn: EffectFn);
|
|
123
|
+
_callback(): void;
|
|
124
|
+
_start(): () => void;
|
|
125
|
+
_notify(): void;
|
|
126
|
+
_dispose(): void;
|
|
127
|
+
}
|
|
128
|
+
declare function Effect(this: Effect, fn: EffectFn): void;
|
|
129
|
+
/**
|
|
130
|
+
* Create an effect to run arbitrary code in response to signal changes.
|
|
131
|
+
*
|
|
132
|
+
* An effect tracks which signals are accessed within the given callback
|
|
133
|
+
* function `fn`, and re-runs the callback when those signals change.
|
|
134
|
+
*
|
|
135
|
+
* The callback may return a cleanup function. The cleanup function gets
|
|
136
|
+
* run once, either when the callback is next called or when the effect
|
|
137
|
+
* gets disposed, whichever happens first.
|
|
138
|
+
*
|
|
139
|
+
* @param fn The effect callback.
|
|
140
|
+
* @returns A function for disposing the effect.
|
|
141
|
+
*/
|
|
142
|
+
declare function effect(fn: EffectFn): () => void;
|
|
143
|
+
export { computed, effect, batch, untracked, Signal };
|
|
144
|
+
export type { ReadonlySignal };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
arrayMerge?(target: any[], source: any[], options?: ArrayMergeOptions): any[];
|
|
3
|
+
clone?: boolean;
|
|
4
|
+
customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined;
|
|
5
|
+
isMergeableObject?(value: object): boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ArrayMergeOptions {
|
|
8
|
+
isMergeableObject(value: object): boolean;
|
|
9
|
+
cloneUnlessOtherwiseSpecified(value: object, options?: Options): object;
|
|
10
|
+
}
|
|
11
|
+
declare function deepmerge<T>(target: Partial<T>, source: Partial<T>, options?: Options): T;
|
|
12
|
+
declare namespace deepmerge {
|
|
13
|
+
var all: typeof deepmergeAll;
|
|
14
|
+
}
|
|
15
|
+
declare function deepmergeAll(objects: object[], options?: Options): object;
|
|
16
|
+
export default deepmerge;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export interface EventListener<T = any> {
|
|
2
|
+
(evt: Event<T>): void;
|
|
3
|
+
}
|
|
4
|
+
interface EventListenerObject<T = any> {
|
|
5
|
+
handleEvent(object: Event<T>): void;
|
|
6
|
+
}
|
|
7
|
+
interface EventInit {
|
|
8
|
+
bubbles?: boolean;
|
|
9
|
+
cancelable?: boolean;
|
|
10
|
+
composed?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface EventListenerOptions {
|
|
13
|
+
capture?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type EventListenerOrEventListenerObject<T = any> = EventListener<T> | EventListenerObject<T>;
|
|
16
|
+
interface AddEventListenerOptions extends EventListenerOptions {
|
|
17
|
+
once?: boolean;
|
|
18
|
+
passive?: boolean;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export declare class Event<T = any> {
|
|
22
|
+
readonly NONE = 0;
|
|
23
|
+
readonly CAPTURING_PHASE = 1;
|
|
24
|
+
readonly AT_TARGET = 2;
|
|
25
|
+
readonly BUBBLING_PHASE = 3;
|
|
26
|
+
data: T | null;
|
|
27
|
+
/** 事件类型 */
|
|
28
|
+
type: string;
|
|
29
|
+
/** 事件是否冒泡 */
|
|
30
|
+
bubbles: boolean;
|
|
31
|
+
/** 阻止事件冒泡的标志 */
|
|
32
|
+
cancelBubble: boolean;
|
|
33
|
+
/** 事件是否可以取消 */
|
|
34
|
+
cancelable: boolean;
|
|
35
|
+
/** 事件是否支持跨文档冒泡 */
|
|
36
|
+
composed: boolean;
|
|
37
|
+
/** 事件是否被默认行为阻止 */
|
|
38
|
+
defaultPrevented: boolean;
|
|
39
|
+
/** 事件是否由用户操作生成 */
|
|
40
|
+
isTrusted: boolean;
|
|
41
|
+
/** 事件的目标对象 */
|
|
42
|
+
target: EventTarget | null;
|
|
43
|
+
/** 当前正在处理事件的对象 */
|
|
44
|
+
currentTarget: EventTarget | null;
|
|
45
|
+
/** 事件阶段 */
|
|
46
|
+
eventPhase: number;
|
|
47
|
+
/** 事件的时间戳 */
|
|
48
|
+
timeStamp: number;
|
|
49
|
+
/**
|
|
50
|
+
* 标记事件是否应该立即停止传播
|
|
51
|
+
*/
|
|
52
|
+
stopImmediatePropagationInternal: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 构造函数
|
|
55
|
+
* @param type 事件类型
|
|
56
|
+
* @param eventInitDict 可选的事件初始化字典
|
|
57
|
+
*/
|
|
58
|
+
constructor(type: string, eventInitDict?: EventInit);
|
|
59
|
+
setData(data: T): this;
|
|
60
|
+
/**
|
|
61
|
+
* 初始化事件对象的属性
|
|
62
|
+
* @param type 事件类型
|
|
63
|
+
* @param bubbles 是否冒泡
|
|
64
|
+
* @param cancelable 是否可以取消
|
|
65
|
+
*/
|
|
66
|
+
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
|
67
|
+
/**
|
|
68
|
+
* 阻止事件冒泡
|
|
69
|
+
*/
|
|
70
|
+
stopPropagation(): void;
|
|
71
|
+
/**
|
|
72
|
+
* 阻止事件的默认行为
|
|
73
|
+
*/
|
|
74
|
+
preventDefault(): void;
|
|
75
|
+
/**
|
|
76
|
+
* 阻止事件冒泡并停止调用事件监听器
|
|
77
|
+
*/
|
|
78
|
+
stopImmediatePropagation(): void;
|
|
79
|
+
/**
|
|
80
|
+
* 返回事件的目标对象及其祖先对象的路径
|
|
81
|
+
* @returns 事件路径的数组
|
|
82
|
+
*/
|
|
83
|
+
composedPath(): EventTarget[];
|
|
84
|
+
}
|
|
85
|
+
export declare class EventTarget<Events extends Record<string, any> = any> {
|
|
86
|
+
private listeners;
|
|
87
|
+
parentNode: EventTarget | null;
|
|
88
|
+
constructor();
|
|
89
|
+
addEventListener<E extends keyof Events>(type: E, callback: EventListenerOrEventListenerObject<Events[E]>, options?: AddEventListenerOptions | boolean): void;
|
|
90
|
+
dispatchEvent<E extends keyof Events>(event: Event<Events[E]>): boolean;
|
|
91
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type EventData = {
|
|
2
|
+
[Key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
type ListenerFunc<D extends EventData> = (e: EmitterEvent<D>) => void;
|
|
5
|
+
type ListenerObject<D extends EventData> = {
|
|
6
|
+
handleEvent(e: EmitterEvent<D>): void;
|
|
7
|
+
};
|
|
8
|
+
type ListenerFuncOrObject<D extends EventData> = ListenerFunc<D> | ListenerObject<D>;
|
|
9
|
+
type ListenerData<D extends EventData> = {
|
|
10
|
+
once: boolean;
|
|
11
|
+
listener: ListenerFuncOrObject<D>;
|
|
12
|
+
};
|
|
13
|
+
export declare class EmitterEvent<Data extends EventData> {
|
|
14
|
+
static NONE: number;
|
|
15
|
+
static AT_TARGET: number;
|
|
16
|
+
static BUBBLING_PHASE: number;
|
|
17
|
+
static new(type: string, data: any): EmitterEvent<any>;
|
|
18
|
+
type: string;
|
|
19
|
+
eventPhase: number;
|
|
20
|
+
data: Data;
|
|
21
|
+
target: EventEmitter<any> | null;
|
|
22
|
+
currentTarget: EventEmitter<any> | null;
|
|
23
|
+
composedPath: EventEmitter<any>[];
|
|
24
|
+
bubbles: boolean;
|
|
25
|
+
propagationStopped: boolean;
|
|
26
|
+
immediatePropagationStopped: boolean;
|
|
27
|
+
constructor(type: string, data: Data);
|
|
28
|
+
reset(): void;
|
|
29
|
+
stopPropagation(): void;
|
|
30
|
+
stopImmediatePropagation(): void;
|
|
31
|
+
}
|
|
32
|
+
declare const isEventEmitter_Property: unique symbol;
|
|
33
|
+
export declare class EventEmitter<EventListeners extends Record<string, EventData> = {}> {
|
|
34
|
+
static createEvent(type: string, data: any): EmitterEvent<any>;
|
|
35
|
+
[isEventEmitter_Property]: boolean;
|
|
36
|
+
parent?: EventEmitter;
|
|
37
|
+
listeners: Map<string, ListenerData<EventData>[]>;
|
|
38
|
+
hasEvent(type: string): boolean;
|
|
39
|
+
on<Type extends Extract<keyof EventListeners, string>>(type: Type, listener: ListenerFuncOrObject<EventListeners[Type]>, once?: boolean): boolean;
|
|
40
|
+
off<Type extends Extract<keyof EventListeners, string>>(type?: Type, listener?: ListenerFuncOrObject<EventListeners[Type]>): boolean;
|
|
41
|
+
emit(event: EmitterEvent<EventListeners[keyof EventListeners]>): void;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
3
|
+
* `EventEmitter` interface.
|
|
4
|
+
*/
|
|
5
|
+
declare class EventEmitter<
|
|
6
|
+
EventTypes extends EventEmitter.ValidEventTypes = string | symbol,
|
|
7
|
+
Context extends any = any
|
|
8
|
+
> {
|
|
9
|
+
static prefixed: string | boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return an array listing the events for which the emitter has registered
|
|
13
|
+
* listeners.
|
|
14
|
+
*/
|
|
15
|
+
eventNames(): Array<EventEmitter.EventNames<EventTypes>>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return the listeners registered for a given event.
|
|
19
|
+
*/
|
|
20
|
+
listeners<T extends EventEmitter.EventNames<EventTypes>>(
|
|
21
|
+
event: T
|
|
22
|
+
): Array<EventEmitter.EventListener<EventTypes, T>>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Return the number of listeners listening to a given event.
|
|
26
|
+
*/
|
|
27
|
+
listenerCount(event: EventEmitter.EventNames<EventTypes>): number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Calls each of the listeners registered for a given event.
|
|
31
|
+
*/
|
|
32
|
+
emit<T extends EventEmitter.EventNames<EventTypes>>(
|
|
33
|
+
event: T,
|
|
34
|
+
...args: EventEmitter.EventArgs<EventTypes, T>
|
|
35
|
+
): boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Add a listener for a given event.
|
|
39
|
+
*/
|
|
40
|
+
on<T extends EventEmitter.EventNames<EventTypes>>(
|
|
41
|
+
event: T,
|
|
42
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
43
|
+
context?: Context
|
|
44
|
+
): this;
|
|
45
|
+
addListener<T extends EventEmitter.EventNames<EventTypes>>(
|
|
46
|
+
event: T,
|
|
47
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
48
|
+
context?: Context
|
|
49
|
+
): this;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Add a one-time listener for a given event.
|
|
53
|
+
*/
|
|
54
|
+
once<T extends EventEmitter.EventNames<EventTypes>>(
|
|
55
|
+
event: T,
|
|
56
|
+
fn: EventEmitter.EventListener<EventTypes, T>,
|
|
57
|
+
context?: Context
|
|
58
|
+
): this;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Remove the listeners of a given event.
|
|
62
|
+
*/
|
|
63
|
+
removeListener<T extends EventEmitter.EventNames<EventTypes>>(
|
|
64
|
+
event: T,
|
|
65
|
+
fn?: EventEmitter.EventListener<EventTypes, T>,
|
|
66
|
+
context?: Context,
|
|
67
|
+
once?: boolean
|
|
68
|
+
): this;
|
|
69
|
+
off<T extends EventEmitter.EventNames<EventTypes>>(
|
|
70
|
+
event: T,
|
|
71
|
+
fn?: EventEmitter.EventListener<EventTypes, T>,
|
|
72
|
+
context?: Context,
|
|
73
|
+
once?: boolean
|
|
74
|
+
): this;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Remove all listeners, or those of the specified event.
|
|
78
|
+
*/
|
|
79
|
+
removeAllListeners(event?: EventEmitter.EventNames<EventTypes>): this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare namespace EventEmitter {
|
|
83
|
+
export interface ListenerFn<Args extends any[] = any[]> {
|
|
84
|
+
(...args: Args): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface EventEmitterStatic {
|
|
88
|
+
new <
|
|
89
|
+
EventTypes extends ValidEventTypes = string | symbol,
|
|
90
|
+
Context = any
|
|
91
|
+
>(): EventEmitter<EventTypes, Context>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* `object` should be in either of the following forms:
|
|
96
|
+
* ```
|
|
97
|
+
* interface EventTypes {
|
|
98
|
+
* 'event-with-parameters': any[]
|
|
99
|
+
* 'event-with-example-handler': (...args: any[]) => void
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export type ValidEventTypes = string | symbol | object;
|
|
104
|
+
|
|
105
|
+
export type EventNames<T extends ValidEventTypes> = T extends string | symbol
|
|
106
|
+
? T
|
|
107
|
+
: keyof T;
|
|
108
|
+
|
|
109
|
+
export type ArgumentMap<T extends object> = {
|
|
110
|
+
[K in keyof T]: T[K] extends (...args: any[]) => void
|
|
111
|
+
? Parameters<T[K]>
|
|
112
|
+
: T[K] extends any[]
|
|
113
|
+
? T[K]
|
|
114
|
+
: any[];
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type EventListener<
|
|
118
|
+
T extends ValidEventTypes,
|
|
119
|
+
K extends EventNames<T>
|
|
120
|
+
> = T extends string | symbol
|
|
121
|
+
? (...args: any[]) => void
|
|
122
|
+
: (
|
|
123
|
+
...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]
|
|
124
|
+
) => void;
|
|
125
|
+
|
|
126
|
+
export type EventArgs<
|
|
127
|
+
T extends ValidEventTypes,
|
|
128
|
+
K extends EventNames<T>
|
|
129
|
+
> = Parameters<EventListener<T, K>>;
|
|
130
|
+
|
|
131
|
+
export const EventEmitter: EventEmitterStatic;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { EventEmitter }
|
|
135
|
+
export default EventEmitter;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type EventType = string | symbol;
|
|
2
|
+
export type Handler<T = unknown> = (event: T) => void;
|
|
3
|
+
export type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void;
|
|
4
|
+
export type EventHandlerList<T = unknown> = Array<Handler<T>>;
|
|
5
|
+
export type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
|
|
6
|
+
export type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
|
|
7
|
+
export interface Emitter<Events extends Record<EventType, unknown>> {
|
|
8
|
+
all: EventHandlerMap<Events>;
|
|
9
|
+
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
|
|
10
|
+
on(type: '*', handler: WildcardHandler<Events>): void;
|
|
11
|
+
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
|
|
12
|
+
off(type: '*', handler: WildcardHandler<Events>): void;
|
|
13
|
+
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
|
|
14
|
+
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Mitt: Tiny (~200b) functional event emitter / pubsub.
|
|
18
|
+
* @name mitt
|
|
19
|
+
* @returns {Mitt}
|
|
20
|
+
*/
|
|
21
|
+
export default function mitt<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): Emitter<Events>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function equal(a: any, b: any): boolean;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './events/eventTarget';
|
|
2
|
+
export * from './events/eventemitter3';
|
|
3
|
+
export * from './events/mitt';
|
|
4
|
+
export * from './callbacks';
|
|
5
|
+
export * from './ismobilejs';
|
|
6
|
+
export * from './priority_queue';
|
|
7
|
+
export * from './stats.module';
|
|
8
|
+
export * from './parse-svg-path';
|
|
9
|
+
export * as radash from './radash';
|
|
10
|
+
export * as lodash from './lodash';
|
|
11
|
+
export * as antvUtil from './antv-util';
|
|
12
|
+
export * as immer from './data/immer';
|
|
13
|
+
export * as Immutable from './data/immutable';
|
|
14
|
+
export * as reactivity from './data/reactivity';
|
|
15
|
+
export * as signals from './data/signals';
|
|
16
|
+
export { Options } from './Options';
|
|
17
|
+
export type { OptionsProperties, OptionConfig } from './Options';
|
|
18
|
+
export { default as deepmerge } from './deepmerge';
|
|
19
|
+
export { default as fastDeepEqual } from './fast-deep-equal';
|
|
20
|
+
export * from './Color';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
const MSStream: any;
|
|
3
|
+
}
|
|
4
|
+
export type UserAgent = string;
|
|
5
|
+
export type Navigator = {
|
|
6
|
+
userAgent: string;
|
|
7
|
+
platform: string;
|
|
8
|
+
maxTouchPoints?: number;
|
|
9
|
+
};
|
|
10
|
+
export type isMobileResult = {
|
|
11
|
+
apple: {
|
|
12
|
+
phone: boolean;
|
|
13
|
+
ipod: boolean;
|
|
14
|
+
tablet: boolean;
|
|
15
|
+
universal: boolean;
|
|
16
|
+
device: boolean;
|
|
17
|
+
};
|
|
18
|
+
amazon: {
|
|
19
|
+
phone: boolean;
|
|
20
|
+
tablet: boolean;
|
|
21
|
+
device: boolean;
|
|
22
|
+
};
|
|
23
|
+
android: {
|
|
24
|
+
phone: boolean;
|
|
25
|
+
tablet: boolean;
|
|
26
|
+
device: boolean;
|
|
27
|
+
};
|
|
28
|
+
windows: {
|
|
29
|
+
phone: boolean;
|
|
30
|
+
tablet: boolean;
|
|
31
|
+
device: boolean;
|
|
32
|
+
};
|
|
33
|
+
other: {
|
|
34
|
+
blackberry: boolean;
|
|
35
|
+
blackberry10: boolean;
|
|
36
|
+
opera: boolean;
|
|
37
|
+
firefox: boolean;
|
|
38
|
+
chrome: boolean;
|
|
39
|
+
device: boolean;
|
|
40
|
+
};
|
|
41
|
+
phone: boolean;
|
|
42
|
+
tablet: boolean;
|
|
43
|
+
any: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type IsMobileParameter = UserAgent | Navigator;
|
|
46
|
+
export default function isMobile(param?: IsMobileParameter): isMobileResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* k-v 存储
|
|
3
|
+
*/
|
|
4
|
+
export default class<T> {
|
|
5
|
+
map: {
|
|
6
|
+
[key: string]: T;
|
|
7
|
+
};
|
|
8
|
+
has(key: string): boolean;
|
|
9
|
+
get(key: string, def?: T): T | undefined;
|
|
10
|
+
set(key: string, value: T): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
delete(key: string): void;
|
|
13
|
+
size(): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function cancelAnimationFrame(handler: number): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens `array` a single level deep.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} arr The array to inspect.
|
|
5
|
+
* @param {Array} values The values to exclude.
|
|
6
|
+
* @return {Array} Returns the new array of filtered values.
|
|
7
|
+
* @example
|
|
8
|
+
* difference([2, 1], [2, 3]); // => [1]
|
|
9
|
+
*/
|
|
10
|
+
declare const difference: <T>(arr: T[], values?: T[]) => T[];
|
|
11
|
+
export default difference;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens `array` a single level deep.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} arr The array to flatten.
|
|
5
|
+
* @param {Array} result The array to return.
|
|
6
|
+
* @return {Array} Returns the new flattened array.
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* flattenDeep([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5]
|
|
10
|
+
*/
|
|
11
|
+
declare const flattenDeep: (arr: any[], result?: any[]) => any[];
|
|
12
|
+
export default flattenDeep;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens `array` a single level deep.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} arr The array to flatten.
|
|
5
|
+
* @return {Array} Returns the new flattened array.
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
|
|
9
|
+
*/
|
|
10
|
+
declare const flatten: <T>(arr: T[]) => T[];
|
|
11
|
+
export default flatten;
|