@flowgram.ai/utils 0.1.0-alpha.2 → 0.1.0-alpha.20

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;
@@ -962,6 +1031,35 @@ declare class Emitter<T = any> {
962
1031
  dispose(): void;
963
1032
  }
964
1033
 
1034
+ /**
1035
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1036
+ * SPDX-License-Identifier: MIT
1037
+ */
1038
+
1039
+ declare class DisposableImpl implements Disposable {
1040
+ readonly toDispose: DisposableCollection;
1041
+ dispose(): void;
1042
+ get disposed(): boolean;
1043
+ get onDispose(): Event<void>;
1044
+ }
1045
+ declare class DisposableCollection implements Disposable {
1046
+ protected readonly disposables: Disposable[];
1047
+ protected readonly onDisposeEmitter: Emitter<void>;
1048
+ private _disposed;
1049
+ constructor(...toDispose: Disposable[]);
1050
+ get length(): number;
1051
+ get onDispose(): Event<void>;
1052
+ get disposed(): boolean;
1053
+ dispose(): void;
1054
+ push(disposable: Disposable): Disposable;
1055
+ pushAll(disposables: Disposable[]): Disposable[];
1056
+ }
1057
+
1058
+ /**
1059
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1060
+ * SPDX-License-Identifier: MIT
1061
+ */
1062
+
965
1063
  interface CancellationToken {
966
1064
  /**
967
1065
  * A flag signalling is cancellation has been requested.
@@ -999,6 +1097,11 @@ declare function cancelled(): Error;
999
1097
  declare function isCancelled(err: Error | undefined): boolean;
1000
1098
  declare function checkCancelled(token?: CancellationToken): void;
1001
1099
 
1100
+ /**
1101
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1102
+ * SPDX-License-Identifier: MIT
1103
+ */
1104
+
1002
1105
  /**
1003
1106
  * Simple implementation of the deferred pattern.
1004
1107
  * An object that exposes a promise and functions to resolve and reject it.
@@ -1035,6 +1138,11 @@ declare class PromisePool {
1035
1138
  run<T>(tasks: PromiseTask<T>[], checkIfRetry?: (res: T) => boolean): Promise<T[]>;
1036
1139
  }
1037
1140
 
1141
+ /**
1142
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1143
+ * SPDX-License-Identifier: MIT
1144
+ */
1145
+
1038
1146
  interface CacheManager<T, ITEM extends CacheOriginItem = CacheOriginItem> extends Disposable {
1039
1147
  get(): T;
1040
1148
  getMore(count: number, autoDelete?: boolean): T[];
@@ -1101,6 +1209,10 @@ declare namespace Cache {
1101
1209
  function createWeakCache(): WeakCache;
1102
1210
  }
1103
1211
 
1212
+ /**
1213
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1214
+ * SPDX-License-Identifier: MIT
1215
+ */
1104
1216
  declare namespace Compare {
1105
1217
  /**
1106
1218
  * 比较,默认浅比较
@@ -1120,6 +1232,11 @@ declare namespace Compare {
1120
1232
  function isArrayShallowChanged(arr1: any[], arr2: any[]): boolean;
1121
1233
  }
1122
1234
 
1235
+ /**
1236
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1237
+ * SPDX-License-Identifier: MIT
1238
+ */
1239
+
1123
1240
  type CSSStyle = {
1124
1241
  [P in keyof CSSStyleDeclaration]?: string | number | undefined;
1125
1242
  };
@@ -1153,10 +1270,18 @@ declare namespace domUtils {
1153
1270
  function createDOMCache<T extends DOMCache = DOMCache>(parent: HTMLElement, className: string | (() => HTMLElement), children?: string): CacheManager<T>;
1154
1271
  }
1155
1272
 
1273
+ /**
1274
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1275
+ * SPDX-License-Identifier: MIT
1276
+ */
1156
1277
  type LocalId = number;
1157
1278
  declare function generateLocalId(): LocalId;
1158
1279
  declare function _setIdx(idx: number): void;
1159
1280
 
1281
+ /**
1282
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1283
+ * SPDX-License-Identifier: MIT
1284
+ */
1160
1285
  declare function iterToArray<T = any>(iter: IterableIterator<T>): T[];
1161
1286
  declare function arrayToSet(arr: any[]): Set<any>;
1162
1287
  /**
@@ -1167,8 +1292,17 @@ declare function arrayToSet(arr: any[]): Set<any>;
1167
1292
  */
1168
1293
  declare function arrayUnion(arr: any[]): any[];
1169
1294
 
1295
+ /**
1296
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1297
+ * SPDX-License-Identifier: MIT
1298
+ */
1299
+
1170
1300
  declare function bindContributions(bind: interfaces.Bind, target: any, contribs: any[]): void;
1171
1301
 
1302
+ /**
1303
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1304
+ * SPDX-License-Identifier: MIT
1305
+ */
1172
1306
  type RequestFn = (...args: any[]) => Promise<any>;
1173
1307
  /**
1174
1308
  * 请求缓存
@@ -1178,12 +1312,22 @@ declare const RequestCache: Map<any, Promise<any>>;
1178
1312
  declare function clearRequestCache(): void;
1179
1313
  declare function requestWithMemo(req: RequestFn, cacheTime?: number, createCacheKey?: (...args: any[]) => any): RequestFn;
1180
1314
 
1315
+ /**
1316
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1317
+ * SPDX-License-Identifier: MIT
1318
+ */
1319
+
1181
1320
  type FuncMaybePromise<D> = (d: D, ...others: any[]) => MaybePromise<D>;
1182
1321
  type FuncPromise<D> = (d: D, ...others: any[]) => Promise<D>;
1183
1322
  type Func<D> = (d: D, ...others: any[]) => D;
1184
1323
  declare function composeAsync<D>(...fns: FuncMaybePromise<D>[]): FuncPromise<D>;
1185
1324
  declare function compose<D>(...fns: Func<D>[]): Func<D>;
1186
1325
 
1326
+ /**
1327
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1328
+ * SPDX-License-Identifier: MIT
1329
+ */
1330
+
1187
1331
  declare const ContributionProvider: unique symbol;
1188
1332
  interface ContributionProvider<T extends object> {
1189
1333
  getContributions(): T[];
@@ -1191,10 +1335,19 @@ interface ContributionProvider<T extends object> {
1191
1335
  }
1192
1336
  declare function bindContributionProvider(bind: interfaces.Bind, id: symbol): void;
1193
1337
 
1338
+ /**
1339
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1340
+ * SPDX-License-Identifier: MIT
1341
+ */
1342
+
1194
1343
  type EventListener<K extends keyof HTMLElementEventMap> = (this: HTMLElement, event: HTMLElementEventMap[K]) => any;
1195
1344
  type EventListenerOrEventListenerObject$1<K extends keyof HTMLElementEventMap> = EventListener<K>;
1196
1345
  declare function addEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject$1<K>, useCapture?: boolean): Disposable;
1197
1346
 
1347
+ /**
1348
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1349
+ * SPDX-License-Identifier: MIT
1350
+ */
1198
1351
  declare class Logger {
1199
1352
  isDevEnv(): boolean;
1200
1353
  info(...props: any): void;
@@ -1204,11 +1357,19 @@ declare class Logger {
1204
1357
  }
1205
1358
  declare const logger: Logger;
1206
1359
 
1360
+ /**
1361
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1362
+ * SPDX-License-Identifier: MIT
1363
+ */
1207
1364
  declare function createStyleElement(styleId: string, container?: HTMLElement): HTMLStyleElement;
1208
1365
  declare const DecorationStyle: {
1209
1366
  createStyleElement: typeof createStyleElement;
1210
1367
  };
1211
1368
 
1369
+ /**
1370
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1371
+ * SPDX-License-Identifier: MIT
1372
+ */
1212
1373
  declare function useRefresh(defaultValue?: any): (v?: any) => void;
1213
1374
 
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 };
1375
+ 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 };