@fxhash/params 0.0.11 → 0.0.13
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 +214 -213
- package/dist/index.js +78 -83
- package/dist/index.js.map +1 -1
- package/dist/utils-BXUz-G9x.js +387 -0
- package/dist/{chunk-B3N473DY.js.map → utils-BXUz-G9x.js.map} +1 -1
- package/dist/utils-Bd4LPrAy.d.ts +136 -0
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +3 -3
- package/package.json +7 -10
- package/dist/chunk-B3N473DY.js +0 -412
- package/dist/utils-jEvPb5wq.d.ts +0 -141
- package/dist/utils.js.map +0 -1
package/dist/utils-jEvPb5wq.d.ts
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
type FxParamType = "number" | "bigint" | "boolean" | "color" | "string" | "bytes" | "select";
|
2
|
-
type FxParamOptionsMap = {
|
3
|
-
[Type in FxParamType]: {
|
4
|
-
number: {
|
5
|
-
min?: number;
|
6
|
-
max?: number;
|
7
|
-
step?: number;
|
8
|
-
};
|
9
|
-
bigint: {
|
10
|
-
min?: number | bigint;
|
11
|
-
max?: number | bigint;
|
12
|
-
};
|
13
|
-
boolean: undefined;
|
14
|
-
color: undefined;
|
15
|
-
string: {
|
16
|
-
minLength?: number;
|
17
|
-
maxLength?: number;
|
18
|
-
};
|
19
|
-
bytes: {
|
20
|
-
length: number;
|
21
|
-
};
|
22
|
-
select: {
|
23
|
-
options: string[];
|
24
|
-
};
|
25
|
-
}[Type];
|
26
|
-
};
|
27
|
-
type FxParamTypeMap = {
|
28
|
-
[Type in FxParamType]: {
|
29
|
-
number: number;
|
30
|
-
bigint: bigint;
|
31
|
-
boolean: boolean;
|
32
|
-
color: string;
|
33
|
-
string: string;
|
34
|
-
bytes: Uint8Array;
|
35
|
-
select: string;
|
36
|
-
}[Type];
|
37
|
-
};
|
38
|
-
type FxParamTransformationTypeMap = {
|
39
|
-
[Type in FxParamType]: {
|
40
|
-
number: number;
|
41
|
-
bigint: bigint;
|
42
|
-
boolean: boolean;
|
43
|
-
color: {
|
44
|
-
hex: {
|
45
|
-
rgb: string;
|
46
|
-
rgba: string;
|
47
|
-
};
|
48
|
-
obj: {
|
49
|
-
rgb: {
|
50
|
-
r: number;
|
51
|
-
g: number;
|
52
|
-
b: number;
|
53
|
-
};
|
54
|
-
rgba: {
|
55
|
-
r: number;
|
56
|
-
g: number;
|
57
|
-
b: number;
|
58
|
-
a: number;
|
59
|
-
};
|
60
|
-
};
|
61
|
-
arr: {
|
62
|
-
rgb: [number, number, number];
|
63
|
-
rgba: [number, number, number, number];
|
64
|
-
};
|
65
|
-
};
|
66
|
-
string: string;
|
67
|
-
bytes: Uint8Array;
|
68
|
-
select: string;
|
69
|
-
}[Type];
|
70
|
-
};
|
71
|
-
type FxParamUpdateMode = "page-reload" | "sync" | "code-driven";
|
72
|
-
type FxParamValue<Type extends FxParamType> = FxParamTypeMap[Type];
|
73
|
-
interface FxParamDefinition<Type extends FxParamType> {
|
74
|
-
id: string;
|
75
|
-
name?: string;
|
76
|
-
type: Type;
|
77
|
-
update?: FxParamUpdateMode;
|
78
|
-
default: FxParamTypeMap[Type];
|
79
|
-
value: FxParamTypeMap[Type];
|
80
|
-
options: FxParamOptionsMap[Type];
|
81
|
-
version?: string;
|
82
|
-
}
|
83
|
-
type FxParamDefinitions = FxParamDefinition<FxParamType>[];
|
84
|
-
type hexString = `#${string}`;
|
85
|
-
type FxParamProcessorTransformer<Type extends FxParamType> = (value: FxParamTypeMap[Type], definition?: FxParamDefinition<Type>) => FxParamTransformationTypeMap[Type];
|
86
|
-
type FxParamProcessorConstrainer<Type extends FxParamType> = (value: FxParamTypeMap[Type], definition: FxParamDefinition<Type>) => FxParamTypeMap[Type];
|
87
|
-
interface FxParamProcessor<Type extends FxParamType> {
|
88
|
-
serialize: (input: FxParamTypeMap[Type], definition: FxParamDefinition<Type>) => string;
|
89
|
-
deserialize: (input: string, definition: FxParamDefinition<Type>) => FxParamTypeMap[Type];
|
90
|
-
bytesLength: (definition: FxParamDefinition<Type>) => number;
|
91
|
-
transform?: FxParamProcessorTransformer<Type>;
|
92
|
-
constrain?: FxParamProcessorConstrainer<Type>;
|
93
|
-
random: (definition: FxParamDefinition<Type>) => FxParamTypeMap[Type];
|
94
|
-
}
|
95
|
-
type FxParamProcessors = {
|
96
|
-
[T in FxParamType]: FxParamProcessor<T>;
|
97
|
-
};
|
98
|
-
type FxParamTranformType = "transform" | "constrain";
|
99
|
-
type FxParamsData = Record<string, any>;
|
100
|
-
type FxParamsRaw = Record<string, FxParamValue<FxParamType>>;
|
101
|
-
type FxParamTransformation = FxParamTransformationTypeMap[FxParamType];
|
102
|
-
type FxParamsTransformed = Record<string, FxParamTransformation>;
|
103
|
-
|
104
|
-
declare function rgbaToHex(r: number, g: number, b: number, a: number): string;
|
105
|
-
declare function hexToRgba(hexCode: hexString): {
|
106
|
-
r: number;
|
107
|
-
g: number;
|
108
|
-
b: number;
|
109
|
-
a: number;
|
110
|
-
};
|
111
|
-
declare const MIN_SAFE_INT64: bigint;
|
112
|
-
declare const MAX_SAFE_INT64: bigint;
|
113
|
-
declare const ParameterProcessors: FxParamProcessors;
|
114
|
-
declare function serializeParams(params: any, definition: FxParamDefinition<any>[]): string;
|
115
|
-
declare function serializeParamsOrNull(params: FxParamsData, definition: FxParamDefinition<any>[]): string | null;
|
116
|
-
declare function deserializeParams(bytes: string, definition: FxParamDefinition<FxParamType>[], options: {
|
117
|
-
withTransform?: boolean;
|
118
|
-
transformType?: FxParamTranformType;
|
119
|
-
}): FxParamsRaw | FxParamsTransformed;
|
120
|
-
declare function consolidateParams(params: any, data: any): any[];
|
121
|
-
/**
|
122
|
-
* Given a definition and some params data, builds a clean params object where
|
123
|
-
* the values are first found in the data object, then in the definition if a
|
124
|
-
* default value exists, otherwise in randomizes the value using the param
|
125
|
-
* associated processor.
|
126
|
-
*
|
127
|
-
* @param definition an array of parameter definition
|
128
|
-
* @param data the params data used to reconstruct the final values
|
129
|
-
*/
|
130
|
-
declare function buildParamsObject(definition: FxParamDefinitions, data: FxParamsData | null): FxParamsData;
|
131
|
-
declare function getRandomParamValues(params: FxParamDefinition<FxParamType>[], options?: {
|
132
|
-
noTransform?: boolean;
|
133
|
-
randomizeAll?: boolean;
|
134
|
-
}): any;
|
135
|
-
declare function sumBytesParams(definitions: FxParamDefinition<FxParamType>[]): number;
|
136
|
-
declare function stringifyParamsData(data: FxParamsData): string;
|
137
|
-
declare function jsonStringifyBigint(data: any): string;
|
138
|
-
declare const processParam: (paramId: string, value: FxParamValue<FxParamType>, definitions: FxParamDefinition<FxParamType>[], transformType: FxParamTranformType) => FxParamValue<FxParamType> | FxParamTransformation;
|
139
|
-
declare const processParams: (values: FxParamsData, definitions: FxParamDefinition<FxParamType>[], transformType: FxParamTranformType) => Record<string, FxParamValue<FxParamType>>;
|
140
|
-
|
141
|
-
export { type FxParamTranformType as A, type FxParamsData as B, type FxParamsRaw as C, type FxParamTransformation as D, type FxParamsTransformed as E, type FxParamDefinition as F, MIN_SAFE_INT64 as M, ParameterProcessors as P, type FxParamType as a, MAX_SAFE_INT64 as b, serializeParamsOrNull as c, deserializeParams as d, consolidateParams as e, buildParamsObject as f, getRandomParamValues as g, hexToRgba as h, sumBytesParams as i, stringifyParamsData as j, jsonStringifyBigint as k, processParams as l, type FxParamOptionsMap as m, type FxParamTypeMap as n, type FxParamTransformationTypeMap as o, processParam as p, type FxParamUpdateMode as q, rgbaToHex as r, serializeParams as s, type FxParamValue as t, type FxParamDefinitions as u, type hexString as v, type FxParamProcessorTransformer as w, type FxParamProcessorConstrainer as x, type FxParamProcessor as y, type FxParamProcessors as z };
|
package/dist/utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
|