@flowgram.ai/utils 0.2.16 → 0.2.18

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.ts 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,6 +899,10 @@ 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;
843
908
  /**
@@ -889,6 +954,10 @@ declare const NOOP: () => void;
889
954
  */
890
955
  declare function isPlainObject(obj: any): boolean;
891
956
 
957
+ /**
958
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
959
+ * SPDX-License-Identifier: MIT
960
+ */
892
961
  interface AsClass<T> {
893
962
  new (...args: any[]): T;
894
963
  }
@@ -906,6 +975,10 @@ type RecursivePartial<T> = {
906
975
  [P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : RecursivePartial<T[P]>;
907
976
  };
908
977
 
978
+ /**
979
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
980
+ * SPDX-License-Identifier: MIT
981
+ */
909
982
  /**
910
983
  * An object that performs a cleanup operation when `.dispose()` is called.
911
984
  *
@@ -923,6 +996,11 @@ declare namespace Disposable {
923
996
  const NULL: Readonly<Disposable>;
924
997
  }
925
998
 
999
+ /**
1000
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1001
+ * SPDX-License-Identifier: MIT
1002
+ */
1003
+
926
1004
  interface EventListener$1<T> {
927
1005
  (args: T): void;
928
1006
  }
@@ -943,6 +1021,11 @@ declare class Emitter<T = any> {
943
1021
  dispose(): void;
944
1022
  }
945
1023
 
1024
+ /**
1025
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1026
+ * SPDX-License-Identifier: MIT
1027
+ */
1028
+
946
1029
  declare class DisposableImpl implements Disposable {
947
1030
  readonly toDispose: DisposableCollection;
948
1031
  dispose(): void;
@@ -962,6 +1045,11 @@ declare class DisposableCollection implements Disposable {
962
1045
  pushAll(disposables: Disposable[]): Disposable[];
963
1046
  }
964
1047
 
1048
+ /**
1049
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1050
+ * SPDX-License-Identifier: MIT
1051
+ */
1052
+
965
1053
  interface CancellationToken {
966
1054
  /**
967
1055
  * A flag signalling is cancellation has been requested.
@@ -999,6 +1087,11 @@ declare function cancelled(): Error;
999
1087
  declare function isCancelled(err: Error | undefined): boolean;
1000
1088
  declare function checkCancelled(token?: CancellationToken): void;
1001
1089
 
1090
+ /**
1091
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1092
+ * SPDX-License-Identifier: MIT
1093
+ */
1094
+
1002
1095
  /**
1003
1096
  * Simple implementation of the deferred pattern.
1004
1097
  * An object that exposes a promise and functions to resolve and reject it.
@@ -1035,6 +1128,11 @@ declare class PromisePool {
1035
1128
  run<T>(tasks: PromiseTask<T>[], checkIfRetry?: (res: T) => boolean): Promise<T[]>;
1036
1129
  }
1037
1130
 
1131
+ /**
1132
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1133
+ * SPDX-License-Identifier: MIT
1134
+ */
1135
+
1038
1136
  interface CacheManager<T, ITEM extends CacheOriginItem = CacheOriginItem> extends Disposable {
1039
1137
  get(): T;
1040
1138
  getMore(count: number, autoDelete?: boolean): T[];
@@ -1101,6 +1199,10 @@ declare namespace Cache {
1101
1199
  function createWeakCache(): WeakCache;
1102
1200
  }
1103
1201
 
1202
+ /**
1203
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1204
+ * SPDX-License-Identifier: MIT
1205
+ */
1104
1206
  declare namespace Compare {
1105
1207
  /**
1106
1208
  * 比较,默认浅比较
@@ -1120,6 +1222,11 @@ declare namespace Compare {
1120
1222
  function isArrayShallowChanged(arr1: any[], arr2: any[]): boolean;
1121
1223
  }
1122
1224
 
1225
+ /**
1226
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1227
+ * SPDX-License-Identifier: MIT
1228
+ */
1229
+
1123
1230
  type CSSStyle = {
1124
1231
  [P in keyof CSSStyleDeclaration]?: string | number | undefined;
1125
1232
  };
@@ -1153,10 +1260,18 @@ declare namespace domUtils {
1153
1260
  function createDOMCache<T extends DOMCache = DOMCache>(parent: HTMLElement, className: string | (() => HTMLElement), children?: string): CacheManager<T>;
1154
1261
  }
1155
1262
 
1263
+ /**
1264
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1265
+ * SPDX-License-Identifier: MIT
1266
+ */
1156
1267
  type LocalId = number;
1157
1268
  declare function generateLocalId(): LocalId;
1158
1269
  declare function _setIdx(idx: number): void;
1159
1270
 
1271
+ /**
1272
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1273
+ * SPDX-License-Identifier: MIT
1274
+ */
1160
1275
  declare function iterToArray<T = any>(iter: IterableIterator<T>): T[];
1161
1276
  declare function arrayToSet(arr: any[]): Set<any>;
1162
1277
  /**
@@ -1167,8 +1282,17 @@ declare function arrayToSet(arr: any[]): Set<any>;
1167
1282
  */
1168
1283
  declare function arrayUnion(arr: any[]): any[];
1169
1284
 
1285
+ /**
1286
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1287
+ * SPDX-License-Identifier: MIT
1288
+ */
1289
+
1170
1290
  declare function bindContributions(bind: interfaces.Bind, target: any, contribs: any[]): void;
1171
1291
 
1292
+ /**
1293
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1294
+ * SPDX-License-Identifier: MIT
1295
+ */
1172
1296
  type RequestFn = (...args: any[]) => Promise<any>;
1173
1297
  /**
1174
1298
  * 请求缓存
@@ -1178,12 +1302,22 @@ declare const RequestCache: Map<any, Promise<any>>;
1178
1302
  declare function clearRequestCache(): void;
1179
1303
  declare function requestWithMemo(req: RequestFn, cacheTime?: number, createCacheKey?: (...args: any[]) => any): RequestFn;
1180
1304
 
1305
+ /**
1306
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1307
+ * SPDX-License-Identifier: MIT
1308
+ */
1309
+
1181
1310
  type FuncMaybePromise<D> = (d: D, ...others: any[]) => MaybePromise<D>;
1182
1311
  type FuncPromise<D> = (d: D, ...others: any[]) => Promise<D>;
1183
1312
  type Func<D> = (d: D, ...others: any[]) => D;
1184
1313
  declare function composeAsync<D>(...fns: FuncMaybePromise<D>[]): FuncPromise<D>;
1185
1314
  declare function compose<D>(...fns: Func<D>[]): Func<D>;
1186
1315
 
1316
+ /**
1317
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1318
+ * SPDX-License-Identifier: MIT
1319
+ */
1320
+
1187
1321
  declare const ContributionProvider: unique symbol;
1188
1322
  interface ContributionProvider<T extends object> {
1189
1323
  getContributions(): T[];
@@ -1191,10 +1325,19 @@ interface ContributionProvider<T extends object> {
1191
1325
  }
1192
1326
  declare function bindContributionProvider(bind: interfaces.Bind, id: symbol): void;
1193
1327
 
1328
+ /**
1329
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1330
+ * SPDX-License-Identifier: MIT
1331
+ */
1332
+
1194
1333
  type EventListener<K extends keyof HTMLElementEventMap> = (this: HTMLElement, event: HTMLElementEventMap[K]) => any;
1195
1334
  type EventListenerOrEventListenerObject$1<K extends keyof HTMLElementEventMap> = EventListener<K>;
1196
1335
  declare function addEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject$1<K>, useCapture?: boolean): Disposable;
1197
1336
 
1337
+ /**
1338
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1339
+ * SPDX-License-Identifier: MIT
1340
+ */
1198
1341
  declare class Logger {
1199
1342
  isDevEnv(): boolean;
1200
1343
  info(...props: any): void;
@@ -1204,11 +1347,19 @@ declare class Logger {
1204
1347
  }
1205
1348
  declare const logger: Logger;
1206
1349
 
1350
+ /**
1351
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1352
+ * SPDX-License-Identifier: MIT
1353
+ */
1207
1354
  declare function createStyleElement(styleId: string, container?: HTMLElement): HTMLStyleElement;
1208
1355
  declare const DecorationStyle: {
1209
1356
  createStyleElement: typeof createStyleElement;
1210
1357
  };
1211
1358
 
1359
+ /**
1360
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
1361
+ * SPDX-License-Identifier: MIT
1362
+ */
1212
1363
  declare function useRefresh(defaultValue?: any): (v?: any) => void;
1213
1364
 
1214
1365
  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 };