@flowgram.ai/utils 0.1.0-alpha.3 → 0.1.0-alpha.30

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.d.mts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { interfaces } from 'inversify';
2
2
 
3
+ /**
4
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
5
+ * SPDX-License-Identifier: MIT
6
+ */
3
7
  declare const PI: number;
4
8
  /** Two Pi. */
5
9
  declare const PI_2: number;
@@ -21,6 +25,10 @@ declare enum SHAPES {
21
25
  RREC = 4
22
26
  }
23
27
 
28
+ /**
29
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
30
+ * SPDX-License-Identifier: MIT
31
+ */
24
32
  declare class Vector2 {
25
33
  x: number;
26
34
  y: number;
@@ -35,6 +43,10 @@ declare class Vector2 {
35
43
  dot(v: Vector2): number;
36
44
  }
37
45
 
46
+ /**
47
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
48
+ * SPDX-License-Identifier: MIT
49
+ */
38
50
  /**
39
51
  * Common interface for points. Both Point and ObservablePoint implement it
40
52
  */
@@ -49,6 +61,10 @@ interface IPoint {
49
61
  y: number;
50
62
  }
51
63
 
64
+ /**
65
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
66
+ * SPDX-License-Identifier: MIT
67
+ */
52
68
  type SchemaType = 'string' | 'integer' | 'float' | 'boolean' | 'enum' | 'object' | 'range' | 'color' | 'array';
53
69
  interface SchemaMixinDefaults {
54
70
  [defaultKey: string]: any;
@@ -101,6 +117,11 @@ declare namespace Schema {
101
117
  function isBaseType(decoration: SchemaDecoration): boolean;
102
118
  }
103
119
 
120
+ /**
121
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
122
+ * SPDX-License-Identifier: MIT
123
+ */
124
+
104
125
  interface PositionSchema {
105
126
  x: number;
106
127
  y: number;
@@ -165,6 +186,11 @@ declare namespace SizeSchema {
165
186
  function empty(): SizeSchema;
166
187
  }
167
188
 
189
+ /**
190
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
191
+ * SPDX-License-Identifier: MIT
192
+ */
193
+
168
194
  type OpacitySchema = number;
169
195
  interface FlipSchema {
170
196
  x: boolean;
@@ -207,6 +233,11 @@ declare const ShadowSchemaDecoration: SchemaDecoration<ShadowSchema>;
207
233
  declare const TintSchemaDecoration: SchemaDecoration<TintSchema>;
208
234
  declare const OpacitySchemaDecoration: SchemaDecoration<OpacitySchema>;
209
235
 
236
+ /**
237
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
238
+ * SPDX-License-Identifier: MIT
239
+ */
240
+
210
241
  /**
211
242
  * Size object, contains width and height
212
243
  */
@@ -389,6 +420,11 @@ declare class OBBRect {
389
420
  getProjectionRadius(axis: Vector2): number;
390
421
  }
391
422
 
423
+ /**
424
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
425
+ * SPDX-License-Identifier: MIT
426
+ */
427
+
392
428
  /**
393
429
  * The Circle object is used to help draw graphics and can also be used to specify a hit area for displayObjects.
394
430
  */
@@ -425,6 +461,11 @@ declare class Circle {
425
461
  getBounds(): Rectangle;
426
462
  }
427
463
 
464
+ /**
465
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
466
+ * SPDX-License-Identifier: MIT
467
+ */
468
+
428
469
  /**
429
470
  * The Point object represents a location in a two-dimensional coordinate system, where x represents
430
471
  * the horizontal axis and y represents the vertical axis.
@@ -496,6 +537,11 @@ declare class ObservablePoint<T = any> implements IPoint {
496
537
  equals(p: IPoint): boolean;
497
538
  }
498
539
 
540
+ /**
541
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
542
+ * SPDX-License-Identifier: MIT
543
+ */
544
+
499
545
  /**
500
546
  * Transform that takes care about its versions
501
547
  *
@@ -564,6 +610,11 @@ declare class Transform {
564
610
  set rotation(value: number);
565
611
  }
566
612
 
613
+ /**
614
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
615
+ * SPDX-License-Identifier: MIT
616
+ */
617
+
567
618
  /**
568
619
  * The PIXIJS Matrix as a class makes it a lot faster.
569
620
  *
@@ -727,6 +778,11 @@ declare class Matrix {
727
778
  copyFrom(matrix: Matrix): this;
728
779
  }
729
780
 
781
+ /**
782
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
783
+ * SPDX-License-Identifier: MIT
784
+ */
785
+
730
786
  /**
731
787
  * The Point object represents a location in a two-dimensional coordinate system, where x represents
732
788
  * the horizontal axis and y represents the vertical axis.
@@ -811,6 +867,11 @@ declare namespace Point {
811
867
  function moveDistanceToDirection(current: IPoint, direction: IPoint, distance: number): IPoint;
812
868
  }
813
869
 
870
+ /**
871
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
872
+ * SPDX-License-Identifier: MIT
873
+ */
874
+
814
875
  declare namespace Angle {
815
876
  /**
816
877
  * Wrap an angle.
@@ -838,8 +899,18 @@ declare namespace Angle {
838
899
  function betweenPoints(point1: IPoint, point2: IPoint, originPoint?: IPoint): number;
839
900
  }
840
901
 
902
+ /**
903
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
904
+ * SPDX-License-Identifier: MIT
905
+ */
841
906
  declare function deepFreeze<T>(obj: T): T;
842
907
  declare function notEmpty<T>(arg: T | undefined | null): arg is T;
908
+ /**
909
+ * filter dangerous key, prevent prototype pollution injection
910
+ * @param key key to be filtered
911
+ * @returns filtered key
912
+ */
913
+ declare const safeKey: (key: string) => string;
843
914
  /**
844
915
  * `true` if the argument is an empty object. Otherwise, `false`.
845
916
  */
@@ -889,6 +960,10 @@ declare const NOOP: () => void;
889
960
  */
890
961
  declare function isPlainObject(obj: any): boolean;
891
962
 
963
+ /**
964
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
965
+ * SPDX-License-Identifier: MIT
966
+ */
892
967
  interface AsClass<T> {
893
968
  new (...args: any[]): T;
894
969
  }
@@ -905,7 +980,15 @@ type MaybePromise<T> = T | PromiseLike<T>;
905
980
  type RecursivePartial<T> = {
906
981
  [P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : RecursivePartial<T[P]>;
907
982
  };
983
+ type Without<T, U> = {
984
+ [P in Exclude<keyof T, keyof U>]?: never;
985
+ };
986
+ type Xor<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
908
987
 
988
+ /**
989
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
990
+ * SPDX-License-Identifier: MIT
991
+ */
909
992
  /**
910
993
  * An object that performs a cleanup operation when `.dispose()` is called.
911
994
  *
@@ -922,25 +1005,11 @@ declare namespace Disposable {
922
1005
  function create(func: () => void): Disposable;
923
1006
  const NULL: Readonly<Disposable>;
924
1007
  }
925
- declare class DisposableImpl implements Disposable {
926
- readonly toDispose: DisposableCollection;
927
- dispose(): void;
928
- get disposed(): boolean;
929
- get onDispose(): Event<void>;
930
- }
931
- declare class DisposableCollection implements Disposable {
932
- protected readonly disposables: (Disposable & {
933
- _origin: Disposable;
934
- })[];
935
- protected readonly onDisposeEmitter: Emitter<void>;
936
- private _disposed;
937
- constructor(...toDispose: Disposable[]);
938
- get onDispose(): Event<void>;
939
- get disposed(): boolean;
940
- dispose(): void;
941
- push(disposable: Disposable): Disposable;
942
- pushAll(disposables: Disposable[]): Disposable[];
943
- }
1008
+
1009
+ /**
1010
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1011
+ * SPDX-License-Identifier: MIT
1012
+ */
944
1013
 
945
1014
  interface EventListener$1<T> {
946
1015
  (args: T): void;
@@ -952,7 +1021,6 @@ declare namespace Event {
952
1021
  const None: Event<any>;
953
1022
  }
954
1023
  declare class Emitter<T = any> {
955
- static LEAK_WARNING_THRESHHOLD: number;
956
1024
  private _event?;
957
1025
  private _listeners?;
958
1026
  private _disposed;
@@ -962,6 +1030,35 @@ declare class Emitter<T = any> {
962
1030
  dispose(): void;
963
1031
  }
964
1032
 
1033
+ /**
1034
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1035
+ * SPDX-License-Identifier: MIT
1036
+ */
1037
+
1038
+ declare class DisposableImpl implements Disposable {
1039
+ readonly toDispose: DisposableCollection;
1040
+ dispose(): void;
1041
+ get disposed(): boolean;
1042
+ get onDispose(): Event<void>;
1043
+ }
1044
+ declare class DisposableCollection implements Disposable {
1045
+ protected readonly disposables: Disposable[];
1046
+ protected readonly onDisposeEmitter: Emitter<void>;
1047
+ private _disposed;
1048
+ constructor(...toDispose: Disposable[]);
1049
+ get length(): number;
1050
+ get onDispose(): Event<void>;
1051
+ get disposed(): boolean;
1052
+ dispose(): void;
1053
+ push(disposable: Disposable): Disposable;
1054
+ pushAll(disposables: Disposable[]): Disposable[];
1055
+ }
1056
+
1057
+ /**
1058
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1059
+ * SPDX-License-Identifier: MIT
1060
+ */
1061
+
965
1062
  interface CancellationToken {
966
1063
  /**
967
1064
  * A flag signalling is cancellation has been requested.
@@ -999,6 +1096,11 @@ declare function cancelled(): Error;
999
1096
  declare function isCancelled(err: Error | undefined): boolean;
1000
1097
  declare function checkCancelled(token?: CancellationToken): void;
1001
1098
 
1099
+ /**
1100
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1101
+ * SPDX-License-Identifier: MIT
1102
+ */
1103
+
1002
1104
  /**
1003
1105
  * Simple implementation of the deferred pattern.
1004
1106
  * An object that exposes a promise and functions to resolve and reject it.
@@ -1035,6 +1137,11 @@ declare class PromisePool {
1035
1137
  run<T>(tasks: PromiseTask<T>[], checkIfRetry?: (res: T) => boolean): Promise<T[]>;
1036
1138
  }
1037
1139
 
1140
+ /**
1141
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1142
+ * SPDX-License-Identifier: MIT
1143
+ */
1144
+
1038
1145
  interface CacheManager<T, ITEM extends CacheOriginItem = CacheOriginItem> extends Disposable {
1039
1146
  get(): T;
1040
1147
  getMore(count: number, autoDelete?: boolean): T[];
@@ -1101,6 +1208,10 @@ declare namespace Cache {
1101
1208
  function createWeakCache(): WeakCache;
1102
1209
  }
1103
1210
 
1211
+ /**
1212
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1213
+ * SPDX-License-Identifier: MIT
1214
+ */
1104
1215
  declare namespace Compare {
1105
1216
  /**
1106
1217
  * 比较,默认浅比较
@@ -1120,6 +1231,11 @@ declare namespace Compare {
1120
1231
  function isArrayShallowChanged(arr1: any[], arr2: any[]): boolean;
1121
1232
  }
1122
1233
 
1234
+ /**
1235
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1236
+ * SPDX-License-Identifier: MIT
1237
+ */
1238
+
1123
1239
  type CSSStyle = {
1124
1240
  [P in keyof CSSStyleDeclaration]?: string | number | undefined;
1125
1241
  };
@@ -1153,10 +1269,18 @@ declare namespace domUtils {
1153
1269
  function createDOMCache<T extends DOMCache = DOMCache>(parent: HTMLElement, className: string | (() => HTMLElement), children?: string): CacheManager<T>;
1154
1270
  }
1155
1271
 
1272
+ /**
1273
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1274
+ * SPDX-License-Identifier: MIT
1275
+ */
1156
1276
  type LocalId = number;
1157
1277
  declare function generateLocalId(): LocalId;
1158
1278
  declare function _setIdx(idx: number): void;
1159
1279
 
1280
+ /**
1281
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1282
+ * SPDX-License-Identifier: MIT
1283
+ */
1160
1284
  declare function iterToArray<T = any>(iter: IterableIterator<T>): T[];
1161
1285
  declare function arrayToSet(arr: any[]): Set<any>;
1162
1286
  /**
@@ -1167,8 +1291,17 @@ declare function arrayToSet(arr: any[]): Set<any>;
1167
1291
  */
1168
1292
  declare function arrayUnion(arr: any[]): any[];
1169
1293
 
1294
+ /**
1295
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1296
+ * SPDX-License-Identifier: MIT
1297
+ */
1298
+
1170
1299
  declare function bindContributions(bind: interfaces.Bind, target: any, contribs: any[]): void;
1171
1300
 
1301
+ /**
1302
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1303
+ * SPDX-License-Identifier: MIT
1304
+ */
1172
1305
  type RequestFn = (...args: any[]) => Promise<any>;
1173
1306
  /**
1174
1307
  * 请求缓存
@@ -1178,12 +1311,22 @@ declare const RequestCache: Map<any, Promise<any>>;
1178
1311
  declare function clearRequestCache(): void;
1179
1312
  declare function requestWithMemo(req: RequestFn, cacheTime?: number, createCacheKey?: (...args: any[]) => any): RequestFn;
1180
1313
 
1314
+ /**
1315
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1316
+ * SPDX-License-Identifier: MIT
1317
+ */
1318
+
1181
1319
  type FuncMaybePromise<D> = (d: D, ...others: any[]) => MaybePromise<D>;
1182
1320
  type FuncPromise<D> = (d: D, ...others: any[]) => Promise<D>;
1183
1321
  type Func<D> = (d: D, ...others: any[]) => D;
1184
1322
  declare function composeAsync<D>(...fns: FuncMaybePromise<D>[]): FuncPromise<D>;
1185
1323
  declare function compose<D>(...fns: Func<D>[]): Func<D>;
1186
1324
 
1325
+ /**
1326
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1327
+ * SPDX-License-Identifier: MIT
1328
+ */
1329
+
1187
1330
  declare const ContributionProvider: unique symbol;
1188
1331
  interface ContributionProvider<T extends object> {
1189
1332
  getContributions(): T[];
@@ -1191,10 +1334,19 @@ interface ContributionProvider<T extends object> {
1191
1334
  }
1192
1335
  declare function bindContributionProvider(bind: interfaces.Bind, id: symbol): void;
1193
1336
 
1337
+ /**
1338
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1339
+ * SPDX-License-Identifier: MIT
1340
+ */
1341
+
1194
1342
  type EventListener<K extends keyof HTMLElementEventMap> = (this: HTMLElement, event: HTMLElementEventMap[K]) => any;
1195
1343
  type EventListenerOrEventListenerObject$1<K extends keyof HTMLElementEventMap> = EventListener<K>;
1196
1344
  declare function addEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject$1<K>, useCapture?: boolean): Disposable;
1197
1345
 
1346
+ /**
1347
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1348
+ * SPDX-License-Identifier: MIT
1349
+ */
1198
1350
  declare class Logger {
1199
1351
  isDevEnv(): boolean;
1200
1352
  info(...props: any): void;
@@ -1204,11 +1356,19 @@ declare class Logger {
1204
1356
  }
1205
1357
  declare const logger: Logger;
1206
1358
 
1359
+ /**
1360
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1361
+ * SPDX-License-Identifier: MIT
1362
+ */
1207
1363
  declare function createStyleElement(styleId: string, container?: HTMLElement): HTMLStyleElement;
1208
1364
  declare const DecorationStyle: {
1209
1365
  createStyleElement: typeof createStyleElement;
1210
1366
  };
1211
1367
 
1368
+ /**
1369
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1370
+ * SPDX-License-Identifier: MIT
1371
+ */
1212
1372
  declare function useRefresh(defaultValue?: any): (v?: any) => void;
1213
1373
 
1214
- export { Angle, type AsClass, type CSSStyle, Cache, type CacheManager, type CacheOpts, type CacheOriginItem, CancellationToken, CancellationTokenSource, Circle, Compare, ContributionProvider, CropSchemaDecoration, DEG_TO_RAD, type DOMCache, DecorationStyle, Deferred, Disposable, DisposableCollection, DisposableImpl, Emitter, Event, type EventListener$1 as EventListener, type FlipSchema, FlipSchemaDecoration, type IPoint, type ISize, type LocalId, type MarginSchema, Matrix, type MaybeArray, type MaybePromise, MutableToken, NOOP, OBBRect, type OpacitySchema, OpacitySchemaDecoration, type OriginSchema, OriginSchemaDecoration, PI, PI_2, PaddingSchema, PaddingSchemaDecoration, Point, type PositionSchema, PositionSchemaDecoration, PromiseDeferred, PromisePool, type PromisePoolOpts, type PromiseTask, RAD_TO_DEG, Rectangle, RectangleAlignTitle, RectangleAlignType, type RecursivePartial, RequestCache, type RotationSchema, RotationSchemaDecoration, SHAPES, type ScaleSchema, ScaleSchemaDecoration, Schema, SchemaDecoration, type SchemaType, type ScrollSchema, type ShadowSchema, ShadowSchemaDecoration, type ShortCache, SizeSchema, SizeSchemaDecoration, type SkewSchema, SkewSchemaDecoration, TintSchema, TintSchemaDecoration, Transform, TransformSchema, TransformSchemaDecoration, type WeakCache, _setIdx, addEventListener, arrayToSet, arrayUnion, bindContributionProvider, bindContributions, cancelled, checkCancelled, clearRequestCache, compose, composeAsync, deepFreeze, delay, domUtils, each, filter, generateLocalId, getByKey, getTag, isCancelled, isEmpty, isFunction, isNumber, isObject, isPlainObject, isString, iterToArray, logger, mapKeys, mapValues, notEmpty, omit, pick, reduce, requestWithMemo, retry, setByKey, useRefresh, values };
1374
+ export { Angle, type AsClass, type CSSStyle, Cache, type CacheManager, type CacheOpts, type CacheOriginItem, CancellationToken, CancellationTokenSource, Circle, Compare, ContributionProvider, CropSchemaDecoration, DEG_TO_RAD, type DOMCache, DecorationStyle, Deferred, Disposable, DisposableCollection, DisposableImpl, Emitter, Event, type EventListener$1 as EventListener, type FlipSchema, FlipSchemaDecoration, type IPoint, type ISize, type LocalId, type MarginSchema, Matrix, type MaybeArray, type MaybePromise, MutableToken, NOOP, OBBRect, type OpacitySchema, OpacitySchemaDecoration, type OriginSchema, OriginSchemaDecoration, PI, PI_2, PaddingSchema, PaddingSchemaDecoration, Point, type PositionSchema, PositionSchemaDecoration, PromiseDeferred, PromisePool, type PromisePoolOpts, type PromiseTask, RAD_TO_DEG, Rectangle, RectangleAlignTitle, RectangleAlignType, type RecursivePartial, RequestCache, type RotationSchema, RotationSchemaDecoration, SHAPES, type ScaleSchema, ScaleSchemaDecoration, Schema, SchemaDecoration, type SchemaType, type ScrollSchema, type ShadowSchema, ShadowSchemaDecoration, type ShortCache, SizeSchema, SizeSchemaDecoration, type SkewSchema, SkewSchemaDecoration, TintSchema, TintSchemaDecoration, Transform, TransformSchema, TransformSchemaDecoration, type WeakCache, type Xor, _setIdx, addEventListener, arrayToSet, arrayUnion, bindContributionProvider, bindContributions, cancelled, checkCancelled, clearRequestCache, compose, composeAsync, deepFreeze, delay, domUtils, each, filter, generateLocalId, getByKey, getTag, isCancelled, isEmpty, isFunction, isNumber, isObject, isPlainObject, isString, iterToArray, logger, mapKeys, mapValues, notEmpty, omit, pick, reduce, requestWithMemo, retry, safeKey, setByKey, useRefresh, values };