@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/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"file":"index.js","names":["parameterDefinition: FxParamDefinition<FxParamType>"],"sources":["../src/validation.ts"],"sourcesContent":["import { SafeParseError, SafeParseSuccess, z } from \"zod\"\nimport { FxParamDefinition, FxParamType } from \"./types\"\n\nconst ControllerTypeSchema = z.enum([\n \"number\",\n \"bigint\",\n \"color\",\n \"string\",\n \"bytes\",\n \"boolean\",\n \"select\",\n])\n\nconst FxParamOptions_bigintSchema = z.object({\n min: z.number().or(z.bigint()).optional(),\n max: z.number().or(z.bigint()).optional(),\n})\n\nconst FxParamOptions_numberSchema = z.object({\n min: z.number().gte(Number.MIN_SAFE_INTEGER).optional(),\n max: z.number().lte(Number.MAX_SAFE_INTEGER).optional(),\n step: z.number().optional(),\n})\n\nconst FxParamOptions_stringSchema = z.object({\n minLength: z.number().gte(0).optional(),\n maxLength: z.number().optional(),\n})\n\nconst FxParamOptions_bytesSchema = z.object({\n length: z.number().gt(0),\n})\n\nconst FxParamOptions_selectSchema = z.object({\n options: z.string().array().nonempty(),\n})\n\nexport const BaseControllerDefinitionSchema = z.object({\n id: z.string(),\n name: z.string().optional(),\n exposedAsFeature: z.boolean().optional(),\n})\n\nconst StringControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.string),\n options: FxParamOptions_stringSchema.optional(),\n default: z.string().optional(),\n})\n\nconst BytesControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.bytes),\n options: FxParamOptions_bytesSchema,\n default: z.any().optional(),\n update: z.literal(\"code-driven\", {\n invalid_type_error: \"Bytes parameters must be code-driven\",\n required_error: \"Bytes parameters must be code-driven\",\n }),\n})\n\nconst NumberControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.number),\n options: FxParamOptions_numberSchema.optional(),\n default: z\n .number()\n .gte(Number.MIN_SAFE_INTEGER)\n .lte(Number.MAX_SAFE_INTEGER)\n .optional(),\n})\n\nconst BigIntControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.bigint),\n options: FxParamOptions_bigintSchema.optional(),\n default: z.bigint().optional(),\n})\n\nconst SelectControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.select),\n options: FxParamOptions_selectSchema,\n default: z.string().optional(),\n})\n\nconst BooleanControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.boolean),\n options: z.undefined(),\n default: z.boolean().optional(),\n})\n\nconst ColorControllerSchema = BaseControllerDefinitionSchema.extend({\n type: z.literal(ControllerTypeSchema.enum.color),\n options: z.undefined(),\n default: z.string().optional(),\n})\n\nconst ControllerDefinitionSchema = z.union([\n StringControllerSchema,\n NumberControllerSchema,\n BigIntControllerSchema,\n SelectControllerSchema,\n BytesControllerSchema,\n BooleanControllerSchema,\n ColorControllerSchema,\n])\n\nexport type ControllerDefinitionSchemaType = z.infer<\n typeof ControllerDefinitionSchema\n>\n\nconst controllerSchema = {\n number: NumberControllerSchema,\n bigint: BigIntControllerSchema,\n color: ColorControllerSchema,\n string: StringControllerSchema,\n bytes: BytesControllerSchema,\n boolean: BooleanControllerSchema,\n select: SelectControllerSchema,\n}\n\nexport function validateParameterDefinition(\n parameterDefinition: FxParamDefinition<FxParamType>\n):\n | SafeParseError<ControllerDefinitionSchemaType>\n | SafeParseSuccess<ControllerDefinitionSchemaType>\n | undefined {\n return controllerSchema[parameterDefinition.type]?.safeParse(\n parameterDefinition\n )\n}\n"],"mappings":";;;;AAGA,MAAM,uBAAuB,EAAE,KAAK;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACD,EAAC;AAEF,MAAM,8BAA8B,EAAE,OAAO;CAC3C,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,UAAU;CACzC,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,UAAU;AAC1C,EAAC;AAEF,MAAM,8BAA8B,EAAE,OAAO;CAC3C,KAAK,EAAE,QAAQ,CAAC,IAAI,OAAO,iBAAiB,CAAC,UAAU;CACvD,KAAK,EAAE,QAAQ,CAAC,IAAI,OAAO,iBAAiB,CAAC,UAAU;CACvD,MAAM,EAAE,QAAQ,CAAC,UAAU;AAC5B,EAAC;AAEF,MAAM,8BAA8B,EAAE,OAAO;CAC3C,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU;CACvC,WAAW,EAAE,QAAQ,CAAC,UAAU;AACjC,EAAC;AAEF,MAAM,6BAA6B,EAAE,OAAO,EAC1C,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,CACzB,EAAC;AAEF,MAAM,8BAA8B,EAAE,OAAO,EAC3C,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CACvC,EAAC;AAEF,MAAa,iCAAiC,EAAE,OAAO;CACrD,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,kBAAkB,EAAE,SAAS,CAAC,UAAU;AACzC,EAAC;AAEF,MAAM,yBAAyB,+BAA+B,OAAO;CACnE,MAAM,EAAE,QAAQ,qBAAqB,KAAK,OAA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AAQ;CACR,OAAO;CACP,QAAQ;CACR,OAAO;CACP,SAAS;CACT,QAAQ;AACT;AAED,SAAgB,4BACdA,qBAIY;AACZ,QAAO,iBAAiB,oBAAoB,OAAO,UACjD,oBACD;AACF"}
|
@@ -0,0 +1,387 @@
|
|
1
|
+
//#region src/utils.ts
|
2
|
+
function rgbaToHex(r, g, b, a) {
|
3
|
+
const outParts = [
|
4
|
+
r.toString(16),
|
5
|
+
g.toString(16),
|
6
|
+
b.toString(16),
|
7
|
+
Math.round(a * 255).toString(16).substring(0, 2)
|
8
|
+
];
|
9
|
+
outParts.forEach(function(part, i) {
|
10
|
+
if (part.length === 1) outParts[i] = "0" + part;
|
11
|
+
});
|
12
|
+
return "#" + outParts.join("");
|
13
|
+
}
|
14
|
+
function completeHexColor(hexCode) {
|
15
|
+
let hex = hexCode.replace("#", "");
|
16
|
+
if (hex.length === 6) hex = `${hex}ff`;
|
17
|
+
if (hex.length === 3) hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}ff`;
|
18
|
+
return hex;
|
19
|
+
}
|
20
|
+
function hexToRgba(hexCode) {
|
21
|
+
const hex = completeHexColor(hexCode);
|
22
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
23
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
24
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
25
|
+
const a = Math.round((parseInt(hex.substring(6, 8), 16) / 255 + Number.EPSILON) * 100) / 100;
|
26
|
+
return {
|
27
|
+
r,
|
28
|
+
g,
|
29
|
+
b,
|
30
|
+
a
|
31
|
+
};
|
32
|
+
}
|
33
|
+
const stringToHex = function(s) {
|
34
|
+
let rtn = "";
|
35
|
+
for (let i = 0; i < s.length; i++) rtn += s.charCodeAt(i).toString(16).padStart(4, "0");
|
36
|
+
return rtn;
|
37
|
+
};
|
38
|
+
const hexToString = function(h) {
|
39
|
+
const hx = h.match(/.{1,4}/g) || [];
|
40
|
+
let rtn = "";
|
41
|
+
for (let i = 0; i < hx.length; i++) {
|
42
|
+
const int = parseInt(hx[i], 16);
|
43
|
+
if (int === 0) break;
|
44
|
+
rtn += String.fromCharCode(int);
|
45
|
+
}
|
46
|
+
return rtn;
|
47
|
+
};
|
48
|
+
const MIN_SAFE_INT64 = BigInt("-9223372036854775808");
|
49
|
+
const MAX_SAFE_INT64 = BigInt("9223372036854775807");
|
50
|
+
const ParameterProcessors = {
|
51
|
+
number: {
|
52
|
+
serialize: (input) => {
|
53
|
+
const view = new DataView(new ArrayBuffer(8));
|
54
|
+
view.setFloat64(0, input);
|
55
|
+
return view.getBigUint64(0).toString(16).padStart(16, "0");
|
56
|
+
},
|
57
|
+
deserialize: (input) => {
|
58
|
+
const view = new DataView(new ArrayBuffer(8));
|
59
|
+
for (let i = 0; i < 8; i++) view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16));
|
60
|
+
return view.getFloat64(0);
|
61
|
+
},
|
62
|
+
bytesLength: () => 8,
|
63
|
+
constrain: (value, definition) => {
|
64
|
+
let min = Number.MIN_SAFE_INTEGER;
|
65
|
+
if (typeof definition.options?.min !== "undefined") min = Number(definition.options.min);
|
66
|
+
let max = Number.MAX_SAFE_INTEGER;
|
67
|
+
if (typeof definition.options?.max !== "undefined") max = Number(definition.options.max);
|
68
|
+
max = Math.min(max, Number.MAX_SAFE_INTEGER);
|
69
|
+
min = Math.max(min, Number.MIN_SAFE_INTEGER);
|
70
|
+
const v = Math.min(Math.max(value, min), max);
|
71
|
+
if (definition?.options?.step) {
|
72
|
+
const t = 1 / definition?.options?.step;
|
73
|
+
return Math.round(v * t) / t;
|
74
|
+
}
|
75
|
+
return v;
|
76
|
+
},
|
77
|
+
random: (definition) => {
|
78
|
+
let min = Number.MIN_SAFE_INTEGER;
|
79
|
+
if (typeof definition.options?.min !== "undefined") min = Number(definition.options.min);
|
80
|
+
let max = Number.MAX_SAFE_INTEGER;
|
81
|
+
if (typeof definition.options?.max !== "undefined") max = Number(definition.options.max);
|
82
|
+
max = Math.min(max, Number.MAX_SAFE_INTEGER);
|
83
|
+
min = Math.max(min, Number.MIN_SAFE_INTEGER);
|
84
|
+
const v = Math.random() * (max - min) + min;
|
85
|
+
if (definition?.options?.step) {
|
86
|
+
const t = 1 / definition?.options?.step;
|
87
|
+
return Math.round(v * t) / t;
|
88
|
+
}
|
89
|
+
return v;
|
90
|
+
}
|
91
|
+
},
|
92
|
+
bigint: {
|
93
|
+
serialize: (input) => {
|
94
|
+
const view = new DataView(new ArrayBuffer(8));
|
95
|
+
view.setBigInt64(0, BigInt(input));
|
96
|
+
return view.getBigUint64(0).toString(16).padStart(16, "0");
|
97
|
+
},
|
98
|
+
deserialize: (input) => {
|
99
|
+
const view = new DataView(new ArrayBuffer(8));
|
100
|
+
for (let i = 0; i < 8; i++) view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16));
|
101
|
+
return view.getBigInt64(0);
|
102
|
+
},
|
103
|
+
bytesLength: () => 8,
|
104
|
+
random: (definition) => {
|
105
|
+
let min = MIN_SAFE_INT64;
|
106
|
+
let max = MAX_SAFE_INT64;
|
107
|
+
if (typeof definition.options?.min !== "undefined") min = BigInt(definition.options.min);
|
108
|
+
if (typeof definition.options?.max !== "undefined") max = BigInt(definition.options.max);
|
109
|
+
const range = max - min;
|
110
|
+
const bits = range.toString(2).length;
|
111
|
+
let random;
|
112
|
+
do
|
113
|
+
random = BigInt("0b" + Array.from(crypto.getRandomValues(new Uint8Array(Math.ceil(bits / 8)))).map((b) => b.toString(2).padStart(8, "0")).join(""));
|
114
|
+
while (random > range);
|
115
|
+
return random + min;
|
116
|
+
}
|
117
|
+
},
|
118
|
+
boolean: {
|
119
|
+
serialize: (input) => {
|
120
|
+
return typeof input === "boolean" ? input ? "01" : "00" : typeof input === "string" ? input === "true" ? "01" : "00" : "00";
|
121
|
+
},
|
122
|
+
deserialize: (input) => {
|
123
|
+
return input === "00" ? false : true;
|
124
|
+
},
|
125
|
+
bytesLength: () => 1,
|
126
|
+
random: () => Math.random() < .5
|
127
|
+
},
|
128
|
+
color: {
|
129
|
+
serialize: (input) => {
|
130
|
+
return completeHexColor(input);
|
131
|
+
},
|
132
|
+
deserialize: (input) => {
|
133
|
+
return input;
|
134
|
+
},
|
135
|
+
bytesLength: () => 4,
|
136
|
+
transform: (input) => {
|
137
|
+
const color = completeHexColor(input);
|
138
|
+
const r = parseInt(color.slice(0, 2), 16);
|
139
|
+
const g = parseInt(color.slice(2, 4), 16);
|
140
|
+
const b = parseInt(color.slice(4, 6), 16);
|
141
|
+
const a = parseInt(color.slice(6, 8), 16);
|
142
|
+
return {
|
143
|
+
hex: {
|
144
|
+
rgb: "#" + input.slice(0, 6),
|
145
|
+
rgba: "#" + input
|
146
|
+
},
|
147
|
+
obj: {
|
148
|
+
rgb: {
|
149
|
+
r,
|
150
|
+
g,
|
151
|
+
b
|
152
|
+
},
|
153
|
+
rgba: {
|
154
|
+
r,
|
155
|
+
g,
|
156
|
+
b,
|
157
|
+
a
|
158
|
+
}
|
159
|
+
},
|
160
|
+
arr: {
|
161
|
+
rgb: [
|
162
|
+
r,
|
163
|
+
g,
|
164
|
+
b
|
165
|
+
],
|
166
|
+
rgba: [
|
167
|
+
r,
|
168
|
+
g,
|
169
|
+
b,
|
170
|
+
a
|
171
|
+
]
|
172
|
+
}
|
173
|
+
};
|
174
|
+
},
|
175
|
+
constrain: (value) => {
|
176
|
+
const hex = value.replace("#", "");
|
177
|
+
return hex.slice(0, 8).padEnd(8, "f");
|
178
|
+
},
|
179
|
+
random: () => `${[...Array(8)].map(() => Math.floor(Math.random() * 16).toString(16)).join("")}`
|
180
|
+
},
|
181
|
+
string: {
|
182
|
+
serialize: (input, def) => {
|
183
|
+
if (!def.version) {
|
184
|
+
let hex$1 = stringToHex(input.substring(0, 64));
|
185
|
+
hex$1 = hex$1.padEnd(64 * 4, "0");
|
186
|
+
return hex$1;
|
187
|
+
}
|
188
|
+
let max = 64;
|
189
|
+
if (typeof def.options?.maxLength !== "undefined") max = Number(def.options.maxLength);
|
190
|
+
let hex = stringToHex(input.substring(0, max));
|
191
|
+
hex = hex.padEnd(max * 4, "0");
|
192
|
+
return hex;
|
193
|
+
},
|
194
|
+
deserialize: (input) => {
|
195
|
+
return hexToString(input);
|
196
|
+
},
|
197
|
+
bytesLength: (def) => {
|
198
|
+
if (!def.version) return 64 * 2;
|
199
|
+
if (typeof def.options?.maxLength !== "undefined") return Number(def.options.maxLength) * 2;
|
200
|
+
return 64 * 2;
|
201
|
+
},
|
202
|
+
random: (definition) => {
|
203
|
+
let min = 0;
|
204
|
+
if (typeof definition.options?.minLength !== "undefined") min = definition.options.minLength;
|
205
|
+
let max = 64;
|
206
|
+
if (typeof definition.options?.maxLength !== "undefined") max = definition.options.maxLength;
|
207
|
+
const length = Math.round(Math.random() * (max - min) + min);
|
208
|
+
return [...Array(length)].map((i) => (~~(Math.random() * 36)).toString(36)).join("");
|
209
|
+
},
|
210
|
+
constrain: (value, definition) => {
|
211
|
+
let min = 0;
|
212
|
+
if (typeof definition.options?.minLength !== "undefined") min = definition.options.minLength;
|
213
|
+
let max = 64;
|
214
|
+
if (typeof definition.options?.maxLength !== "undefined") max = definition.options.maxLength;
|
215
|
+
const v = value.slice(0, max);
|
216
|
+
if (v.length < min) return v.padEnd(min);
|
217
|
+
return v;
|
218
|
+
}
|
219
|
+
},
|
220
|
+
bytes: {
|
221
|
+
serialize: (input, def) => {
|
222
|
+
return Array.from(input).map((i) => i.toString(16).padStart(2, "0")).join("");
|
223
|
+
},
|
224
|
+
deserialize: (input, def) => {
|
225
|
+
const len = input.length / 2;
|
226
|
+
const uint8 = new Uint8Array(len);
|
227
|
+
let idx;
|
228
|
+
for (let i = 0; i < len; i++) {
|
229
|
+
idx = i * 2;
|
230
|
+
uint8[i] = parseInt(`${input[idx]}${input[idx + 1]}`, 16);
|
231
|
+
}
|
232
|
+
return uint8;
|
233
|
+
},
|
234
|
+
bytesLength: (def) => def.options.length,
|
235
|
+
random: (def) => {
|
236
|
+
const len = def.options?.length || 0;
|
237
|
+
const uint8 = new Uint8Array(len);
|
238
|
+
for (let i = 0; i < len; i++) uint8[i] = Math.random() * 255 | 0;
|
239
|
+
return uint8;
|
240
|
+
}
|
241
|
+
},
|
242
|
+
select: {
|
243
|
+
serialize: (input, def) => {
|
244
|
+
return Math.min(255, def.options?.options?.indexOf(input) || 0).toString(16).padStart(2, "0");
|
245
|
+
},
|
246
|
+
deserialize: (input, def) => {
|
247
|
+
const idx = parseInt(input, 16);
|
248
|
+
return def.options?.options?.[idx] || def.options?.options?.[0] || "";
|
249
|
+
},
|
250
|
+
bytesLength: () => 1,
|
251
|
+
constrain: (value, definition) => {
|
252
|
+
if (definition.options.options.includes(value)) return value;
|
253
|
+
return definition.options.options[0];
|
254
|
+
},
|
255
|
+
random: (definition) => {
|
256
|
+
const index = Math.round(Math.random() * (definition.options.options.length - 1) + 0);
|
257
|
+
return definition?.options?.options[index];
|
258
|
+
}
|
259
|
+
}
|
260
|
+
};
|
261
|
+
function serializeParams(params, definition) {
|
262
|
+
let bytes = "";
|
263
|
+
if (!definition) return bytes;
|
264
|
+
for (const def of definition) {
|
265
|
+
const { id, type } = def;
|
266
|
+
const processor = ParameterProcessors[type];
|
267
|
+
const v = params[id];
|
268
|
+
const val = typeof v !== "undefined" ? v : typeof def.default !== "undefined" ? def.default : processor.random(def);
|
269
|
+
const serialized = processor.serialize(val, def);
|
270
|
+
bytes += serialized;
|
271
|
+
}
|
272
|
+
return bytes;
|
273
|
+
}
|
274
|
+
function serializeParamsOrNull(params, definition) {
|
275
|
+
const serialized = serializeParams(params, definition || []);
|
276
|
+
if (serialized.length === 0) return null;
|
277
|
+
return serialized;
|
278
|
+
}
|
279
|
+
function deserializeParams(bytes, definition, options) {
|
280
|
+
const params = {};
|
281
|
+
for (const def of definition) {
|
282
|
+
const processor = ParameterProcessors[def.type];
|
283
|
+
const transformer = options.withTransform && processor[options.transformType || "transform"];
|
284
|
+
if (!bytes) {
|
285
|
+
let v;
|
286
|
+
if (typeof def.default === "undefined") v = processor.random(def);
|
287
|
+
else v = def.default;
|
288
|
+
params[def.id] = transformer ? transformer(v, def) : v;
|
289
|
+
continue;
|
290
|
+
}
|
291
|
+
const bytesLen = processor.bytesLength(def);
|
292
|
+
const valueBytes = bytes.substring(0, bytesLen * 2);
|
293
|
+
bytes = bytes.substring(bytesLen * 2);
|
294
|
+
const val = processor.deserialize(valueBytes, def);
|
295
|
+
params[def.id] = transformer ? transformer(val, def) : val;
|
296
|
+
}
|
297
|
+
return params;
|
298
|
+
}
|
299
|
+
function consolidateParams(params, data) {
|
300
|
+
if (!params) return [];
|
301
|
+
const rtn = [...params];
|
302
|
+
for (const p in rtn) {
|
303
|
+
const definition = rtn[p];
|
304
|
+
const { id, type, default: def } = definition;
|
305
|
+
if (data && data.hasOwnProperty(id)) rtn[p].value = data[id];
|
306
|
+
else {
|
307
|
+
const processor = ParameterProcessors[type];
|
308
|
+
let v;
|
309
|
+
if (typeof def === "undefined") v = processor.random(definition);
|
310
|
+
else v = def;
|
311
|
+
rtn[p].value = processor.transform?.(v) || v;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
return rtn;
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* Given a definition and some params data, builds a clean params object where
|
318
|
+
* the values are first found in the data object, then in the definition if a
|
319
|
+
* default value exists, otherwise in randomizes the value using the param
|
320
|
+
* associated processor.
|
321
|
+
*
|
322
|
+
* @param definition an array of parameter definition
|
323
|
+
* @param data the params data used to reconstruct the final values
|
324
|
+
*/
|
325
|
+
function buildParamsObject(definition, data) {
|
326
|
+
if (!definition) return {};
|
327
|
+
const out = {};
|
328
|
+
for (const def of definition) {
|
329
|
+
if (data?.hasOwnProperty(def.id)) {
|
330
|
+
out[def.id] = data[def.id];
|
331
|
+
continue;
|
332
|
+
}
|
333
|
+
if (def.hasOwnProperty("default")) {
|
334
|
+
out[def.id] = def.default;
|
335
|
+
continue;
|
336
|
+
}
|
337
|
+
const processor = ParameterProcessors[def.type];
|
338
|
+
const rand = processor.random(def);
|
339
|
+
out[def.id] = processor.transform?.(rand) || rand;
|
340
|
+
}
|
341
|
+
return out;
|
342
|
+
}
|
343
|
+
function getRandomParamValues(params, options) {
|
344
|
+
return params.reduce((acc, definition) => {
|
345
|
+
const processor = ParameterProcessors[definition.type];
|
346
|
+
let v = definition.value || definition.default;
|
347
|
+
if (definition.update !== "code-driven" || options?.randomizeAll) v = processor.random(definition);
|
348
|
+
if (v) acc[definition.id] = options?.noTransform ? v : processor.transform?.(v) || v;
|
349
|
+
return acc;
|
350
|
+
}, {});
|
351
|
+
}
|
352
|
+
function sumBytesParams(definitions) {
|
353
|
+
return definitions?.reduce((acc, def) => acc + ParameterProcessors[def.type].bytesLength(def), 0) || 0;
|
354
|
+
}
|
355
|
+
function stringifyParamsData(data) {
|
356
|
+
return JSON.stringify(data, (key, value) => {
|
357
|
+
if (typeof value === "bigint") return value.toString();
|
358
|
+
return value;
|
359
|
+
});
|
360
|
+
}
|
361
|
+
function jsonStringifyBigint(data) {
|
362
|
+
return JSON.stringify(data, (key, value) => {
|
363
|
+
if (typeof value === "bigint") return value.toString();
|
364
|
+
return value;
|
365
|
+
});
|
366
|
+
}
|
367
|
+
const processParam = (paramId, value, definitions, transformType) => {
|
368
|
+
const definition = definitions.find((d) => d.id === paramId);
|
369
|
+
if (!definition) throw new Error(`No definition found for param ${paramId}`);
|
370
|
+
const processor = ParameterProcessors[definition.type];
|
371
|
+
const transformer = processor[transformType];
|
372
|
+
return transformer?.(value, definition) || value;
|
373
|
+
};
|
374
|
+
const processParams = (values, definitions, transformType) => {
|
375
|
+
const paramValues = {};
|
376
|
+
for (const definition of definitions) {
|
377
|
+
const processor = ParameterProcessors[definition.type];
|
378
|
+
const value = values[definition.id];
|
379
|
+
const transformer = processor[transformType];
|
380
|
+
paramValues[definition.id] = transformer?.(value, definition) || value;
|
381
|
+
}
|
382
|
+
return paramValues;
|
383
|
+
};
|
384
|
+
|
385
|
+
//#endregion
|
386
|
+
export { MAX_SAFE_INT64, MIN_SAFE_INT64, ParameterProcessors, buildParamsObject, consolidateParams, deserializeParams, getRandomParamValues, hexToRgba, jsonStringifyBigint, processParam, processParams, rgbaToHex, serializeParams, serializeParamsOrNull, stringifyParamsData, sumBytesParams };
|
387
|
+
//# sourceMappingURL=utils-BXUz-G9x.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/utils.ts"],"names":["hex"],"mappings":";AAiBO,SAAS,SAAU,CAAA,CAAA,EAAW,CAAW,EAAA,CAAA,EAAW,CAAmB,EAAA;AAC5E,EAAA,MAAM,QAAW,GAAA;AAAA,IACf,CAAA,CAAE,SAAS,EAAE,CAAA;AAAA,IACb,CAAA,CAAE,SAAS,EAAE,CAAA;AAAA,IACb,CAAA,CAAE,SAAS,EAAE,CAAA;AAAA,IACb,IAAA,CAAK,KAAM,CAAA,CAAA,GAAI,GAAG,CAAA,CACf,SAAS,EAAE,CAAA,CACX,SAAU,CAAA,CAAA,EAAG,CAAC;AAAA,GACnB;AAGA,EAAS,QAAA,CAAA,OAAA,CAAQ,SAAU,IAAA,EAAM,CAAG,EAAA;AAClC,IAAI,IAAA,IAAA,CAAK,WAAW,CAAG,EAAA;AACrB,MAAS,QAAA,CAAA,CAAC,IAAI,GAAM,GAAA,IAAA;AAAA;AACtB,GACD,CAAA;AAED,EAAO,OAAA,GAAA,GAAM,QAAS,CAAA,IAAA,CAAK,EAAE,CAAA;AAC/B;AAEA,SAAS,iBAAiB,OAAqC,EAAA;AAC7D,EAAA,IAAI,GAAM,GAAA,OAAA,CAAQ,OAAQ,CAAA,GAAA,EAAK,EAAE,CAAA;AACjC,EAAI,IAAA,GAAA,CAAI,WAAW,CAAG,EAAA;AACpB,IAAA,GAAA,GAAM,GAAG,GAAG,CAAA,EAAA,CAAA;AAAA;AAEd,EAAI,IAAA,GAAA,CAAI,WAAW,CAAG,EAAA;AACpB,IAAM,GAAA,GAAA,CAAA,EAAG,IAAI,CAAC,CAAC,GAAG,GAAI,CAAA,CA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A;AAElC,IAAM,MAAA,WAAA,GAAc,UAClB,aACF,CAAA;AACA,IAAA,WAAA,CAAY,WAAW,EAAE,CAAA,GAAI,WAAc,GAAA,KAAA,EAAO,UAAU,CAAK,IAAA,KAAA;AAAA;AAEnE,EAAO,OAAA,WAAA;AACT","file":"chunk-B3N473DY.js","sourcesContent":["import {\n hexString,\n FxParamDefinition,\n FxParamProcessor,\n FxParamProcessors,\n FxParamTypeMap,\n FxParamType,\n FxParamsData,\n FxParamValue,\n FxParamTranformType,\n FxParamProcessorTransformer,\n FxParamTransformation,\n FxParamsRaw,\n FxParamsTransformed,\n FxParamDefinitions,\n} from \"./types\"\n\nexport function rgbaToHex(r: number, g: number, b: number, a: number): string {\n const outParts = [\n r.toString(16),\n g.toString(16),\n b.toString(16),\n Math.round(a * 255)\n .toString(16)\n .substring(0, 2),\n ]\n\n // Pad single-digit output values\n outParts.forEach(function (part, i) {\n if (part.length === 1) {\n outParts[i] = \"0\" + part\n }\n })\n\n return \"#\" + outParts.join(\"\")\n}\n\nfunction completeHexColor(hexCode: hexString | string): string {\n let hex = hexCode.replace(\"#\", \"\")\n if (hex.length === 6) {\n hex = `${hex}ff`\n }\n if (hex.length === 3) {\n hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}ff`\n }\n return hex\n}\n\nexport function hexToRgba(hexCode: hexString) {\n const hex = completeHexColor(hexCode)\n\n const r = parseInt(hex.substring(0, 2), 16)\n const g = parseInt(hex.substring(2, 4), 16)\n const b = parseInt(hex.substring(4, 6), 16)\n const a =\n Math.round(\n (parseInt(hex.substring(6, 8), 16) / 255 + Number.EPSILON) * 100\n ) / 100\n\n return { r, g, b, a }\n}\n\nconst stringToHex = function (s: string) {\n let rtn = \"\"\n for (let i = 0; i < s.length; i++) {\n rtn += s.charCodeAt(i).toString(16).padStart(4, \"0\")\n }\n return rtn\n}\nconst hexToString = function (h: string) {\n const hx = h.match(/.{1,4}/g) || []\n let rtn = \"\"\n for (let i = 0; i < hx.length; i++) {\n const int = parseInt(hx[i], 16)\n if (int === 0) break\n rtn += String.fromCharCode(int)\n }\n return rtn\n}\n\nexport const MIN_SAFE_INT64 = BigInt(\"-9223372036854775808\")\nexport const MAX_SAFE_INT64 = BigInt(\"9223372036854775807\")\n\nexport const ParameterProcessors: FxParamProcessors = {\n number: {\n serialize: input => {\n const view = new DataView(new ArrayBuffer(8))\n view.setFloat64(0, input)\n return view.getBigUint64(0).toString(16).padStart(16, \"0\")\n },\n deserialize: input => {\n const view = new DataView(new ArrayBuffer(8))\n for (let i = 0; i < 8; i++) {\n view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16))\n }\n return view.getFloat64(0)\n },\n bytesLength: () => 8,\n constrain: (value, definition) => {\n let min = Number.MIN_SAFE_INTEGER\n if (typeof definition.options?.min !== \"undefined\")\n min = Number(definition.options.min)\n let max = Number.MAX_SAFE_INTEGER\n if (typeof definition.options?.max !== \"undefined\")\n max = Number(definition.options.max)\n max = Math.min(max, Number.MAX_SAFE_INTEGER)\n min = Math.max(min, Number.MIN_SAFE_INTEGER)\n const v = Math.min(Math.max(value, min), max)\n if (definition?.options?.step) {\n const t = 1.0 / definition?.options?.step\n return Math.round(v * t) / t\n }\n return v\n },\n random: definition => {\n let min = Number.MIN_SAFE_INTEGER\n if (typeof definition.options?.min !== \"undefined\")\n min = Number(definition.options.min)\n let max = Number.MAX_SAFE_INTEGER\n if (typeof definition.options?.max !== \"undefined\")\n max = Number(definition.options.max)\n max = Math.min(max, Number.MAX_SAFE_INTEGER)\n min = Math.max(min, Number.MIN_SAFE_INTEGER)\n const v = Math.random() * (max - min) + min\n if (definition?.options?.step) {\n const t = 1.0 / definition?.options?.step\n return Math.round(v * t) / t\n }\n return v\n },\n },\n bigint: {\n serialize: (input: any) => {\n const view = new DataView(new ArrayBuffer(8))\n view.setBigInt64(0, BigInt(input))\n return view.getBigUint64(0).toString(16).padStart(16, \"0\")\n },\n deserialize: (input: any) => {\n const view = new DataView(new ArrayBuffer(8))\n for (let i = 0; i < 8; i++) {\n view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16))\n }\n return view.getBigInt64(0)\n },\n bytesLength: () => 8,\n random: definition => {\n let min = MIN_SAFE_INT64\n let max = MAX_SAFE_INT64\n if (typeof definition.options?.min !== \"undefined\")\n min = BigInt(definition.options.min)\n if (typeof definition.options?.max !== \"undefined\")\n max = BigInt(definition.options.max)\n const range = max - min\n const bits = range.toString(2).length\n let random\n do {\n random = BigInt(\n \"0b\" +\n Array.from(\n crypto.getRandomValues(new Uint8Array(Math.ceil(bits / 8)))\n )\n .map(b => b.toString(2).padStart(8, \"0\"))\n .join(\"\")\n )\n } while (random > range)\n return random + min\n },\n },\n boolean: {\n serialize: input => {\n return typeof input === \"boolean\"\n ? input\n ? \"01\"\n : \"00\"\n : typeof input === \"string\"\n ? input === \"true\"\n ? \"01\"\n : \"00\"\n : \"00\"\n },\n deserialize: input => {\n return input === \"00\" ? false : true\n },\n bytesLength: () => 1,\n random: () => Math.random() < 0.5,\n },\n\n color: {\n serialize: (input: string) => {\n return completeHexColor(input)\n },\n\n deserialize: (input): hexString => {\n return input as hexString\n },\n bytesLength: () => 4,\n transform: (input: string) => {\n const color = completeHexColor(input)\n const r = parseInt(color.slice(0, 2), 16)\n const g = parseInt(color.slice(2, 4), 16)\n const b = parseInt(color.slice(4, 6), 16)\n const a = parseInt(color.slice(6, 8), 16)\n return {\n hex: {\n rgb: \"#\" + input.slice(0, 6),\n rgba: \"#\" + input,\n },\n obj: {\n rgb: { r, g, b },\n rgba: { r, g, b, a },\n },\n arr: {\n rgb: [r, g, b],\n rgba: [r, g, b, a],\n },\n }\n },\n constrain: value => {\n const hex = value.replace(\"#\", \"\")\n return hex.slice(0, 8).padEnd(8, \"f\")\n },\n random: () =>\n `${[...Array(8)]\n .map(() => Math.floor(Math.random() * 16).toString(16))\n .join(\"\")}`,\n },\n\n string: {\n serialize: (input, def) => {\n if (!def.version) {\n let hex = stringToHex(input.substring(0, 64))\n hex = hex.padEnd(64 * 4, \"0\")\n return hex\n }\n let max = 64\n if (typeof def.options?.maxLength !== \"undefined\")\n max = Number(def.options.maxLength)\n let hex = stringToHex(input.substring(0, max))\n hex = hex.padEnd(max * 4, \"0\")\n return hex\n },\n deserialize: input => {\n return hexToString(input)\n },\n\n bytesLength: def => {\n if (!def.version) {\n return 64 * 2\n }\n if (typeof def.options?.maxLength !== \"undefined\")\n return Number(def.options.maxLength) * 2\n return 64 * 2\n },\n random: definition => {\n let min = 0\n if (typeof definition.options?.minLength !== \"undefined\")\n min = definition.options.minLength\n let max = 64\n if (typeof definition.options?.maxLength !== \"undefined\")\n max = definition.options.maxLength\n const length = Math.round(Math.random() * (max - min) + min)\n return [...Array(length)]\n .map(i => (~~(Math.random() * 36)).toString(36))\n .join(\"\")\n },\n constrain: (value, definition) => {\n let min = 0\n if (typeof definition.options?.minLength !== \"undefined\")\n min = definition.options.minLength\n let max = 64\n if (typeof definition.options?.maxLength !== \"undefined\")\n max = definition.options.maxLength\n const v = value.slice(0, max)\n if (v.length < min) {\n return v.padEnd(min)\n }\n return v\n },\n },\n\n bytes: {\n serialize: (input, def) => {\n return Array.from(input)\n .map(i => i.toString(16).padStart(2, \"0\"))\n .join(\"\")\n },\n deserialize: (input, def) => {\n const len = input.length / 2\n const uint8 = new Uint8Array(len)\n let idx\n for (let i = 0; i < len; i++) {\n idx = i * 2\n uint8[i] = parseInt(`${input[idx]}${input[idx + 1]}`, 16)\n }\n return uint8\n },\n bytesLength: def => def.options.length,\n random: def => {\n const len = def.options?.length || 0\n const uint8 = new Uint8Array(len)\n for (let i = 0; i < len; i++) {\n uint8[i] = (Math.random() * 255) | 0\n }\n return uint8\n },\n },\n\n select: {\n serialize: (input, def) => {\n // find the index of the input in the array of options\n return Math.min(255, def.options?.options?.indexOf(input) || 0)\n .toString(16)\n .padStart(2, \"0\")\n },\n\n deserialize: (input, def) => {\n // get the index, which is the input\n const idx = parseInt(input, 16)\n return def.options?.options?.[idx] || def.options?.options?.[0] || \"\"\n },\n\n bytesLength: () => 1, // index between 0 and 255\n constrain: (value, definition) => {\n if (definition.options.options.includes(value)) {\n return value\n }\n return definition.options.options[0]\n },\n random: definition => {\n const index = Math.round(\n Math.random() * (definition.options.options.length - 1) + 0\n )\n return definition?.options?.options[index]\n },\n },\n}\n\n// params are injected into the piece using the binary representation of the\n// numbers, to keep precision\nexport function serializeParams(\n params: any,\n definition: FxParamDefinition<any>[]\n) {\n // a single hex string will be used for all the params\n let bytes = \"\"\n if (!definition) return bytes\n // loop through each parameter from the definition to find the associated\n // parameter as set on the UI\n for (const def of definition) {\n const { id, type } = def\n const processor = ParameterProcessors[\n type as FxParamType\n ] as FxParamProcessor<any>\n // if the param is definined in the object\n\n const v = params[id] as FxParamTypeMap[]\n const val =\n typeof v !== \"undefined\"\n ? v\n : typeof def.default !== \"undefined\"\n ? def.default\n : processor.random(def)\n const serialized = processor.serialize(val, def)\n bytes += serialized\n }\n\n return bytes\n}\n\n// call seralizeParams(), returns nullif no params\nexport function serializeParamsOrNull(\n params: FxParamsData,\n definition: FxParamDefinition<any>[]\n) {\n const serialized = serializeParams(params, definition || [])\n if (serialized.length === 0) return null\n return serialized\n}\n\n// takes an array of bytes, in hexadecimal format, and a parametric space\n// definition and outputs an array of parameters, mapping the definition and\n// validating input based on the definition constraints\nexport function deserializeParams(\n bytes: string,\n definition: FxParamDefinition<FxParamType>[],\n options: { withTransform?: boolean; transformType?: FxParamTranformType }\n) {\n const params: FxParamsRaw | FxParamsTransformed = {}\n for (const def of definition) {\n const processor = ParameterProcessors[\n def.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n const transformer =\n options.withTransform &&\n (processor[\n options.transformType || \"transform\"\n ] as FxParamProcessorTransformer<FxParamType>)\n if (!bytes) {\n let v\n if (typeof def.default === \"undefined\") v = processor.random(def)\n else v = def.default\n params[def.id] = transformer ? transformer(v, def) : v\n continue\n }\n // extract the length from the bytes & shift the initial bytes string\n const bytesLen = processor.bytesLength(def)\n const valueBytes = bytes.substring(0, bytesLen * 2)\n bytes = bytes.substring(bytesLen * 2)\n // deserialize the bytes into the params\n const val = processor.deserialize(\n valueBytes,\n def\n ) as FxParamValue<FxParamType>\n params[def.id] = transformer ? transformer(val, def) : val\n }\n return params\n}\n\n// Consolidates parameters from both a params object provided by the token\n// and the dat object of params, which is stored by the controls component.\nexport function consolidateParams(params: any, data: any) {\n if (!params) return []\n\n const rtn = [...params]\n\n for (const p in rtn) {\n const definition = rtn[p]\n const { id, type, default: def } = definition\n if (data && data.hasOwnProperty(id)) {\n rtn[p].value = data[id]\n } else {\n const processor = ParameterProcessors[\n type as FxParamType\n ] as FxParamProcessor<any>\n let v\n if (typeof def === \"undefined\") v = processor.random(definition)\n else v = def\n rtn[p].value = processor.transform?.(v) || v\n }\n }\n\n return rtn\n}\n\n/**\n * Given a definition and some params data, builds a clean params object where\n * the values are first found in the data object, then in the definition if a\n * default value exists, otherwise in randomizes the value using the param\n * associated processor.\n *\n * @param definition an array of parameter definition\n * @param data the params data used to reconstruct the final values\n */\nexport function buildParamsObject(\n definition: FxParamDefinitions,\n data: FxParamsData | null\n) {\n if (!definition) return {}\n\n const out: FxParamsData = {}\n for (const def of definition) {\n // find if the data object has the propery\n if (data?.hasOwnProperty(def.id)) {\n out[def.id] = data[def.id]\n continue\n }\n // find if the definition object has a default value\n if (def.hasOwnProperty(\"default\")) {\n out[def.id] = def.default\n continue\n }\n // otherwise use the param processor randomizer\n const processor = ParameterProcessors[def.type] as FxParamProcessor<any>\n const rand = processor.random(def)\n out[def.id] = processor.transform?.(rand) || rand\n }\n return out\n}\n\nexport function getRandomParamValues(\n params: FxParamDefinition<FxParamType>[],\n options?: { noTransform?: boolean; randomizeAll?: boolean }\n): any {\n return params.reduce(\n (acc, definition) => {\n const processor = ParameterProcessors[\n definition.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n let v = (definition.value || definition.default) as FxParamType\n if (definition.update !== \"code-driven\" || options?.randomizeAll) {\n v = processor.random(definition) as FxParamType\n }\n if (v) {\n acc[definition.id] = options?.noTransform\n ? v\n : processor.transform?.(v) || v\n }\n return acc\n },\n {} as Record<string, any>\n )\n}\n\nexport function sumBytesParams(\n definitions: FxParamDefinition<FxParamType>[]\n): number {\n return (\n definitions?.reduce(\n (acc, def) =>\n acc +\n (\n ParameterProcessors[\n def.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n ).bytesLength(def),\n 0\n ) || 0\n )\n}\n\nexport function stringifyParamsData(data: FxParamsData) {\n return JSON.stringify(data, (key, value) => {\n if (typeof value === \"bigint\") return value.toString()\n return value\n })\n}\n\nexport function jsonStringifyBigint(data: any): string {\n return JSON.stringify(data, (key, value) => {\n if (typeof value === \"bigint\") return value.toString()\n return value\n })\n}\n\nexport const processParam = (\n paramId: string,\n value: FxParamValue<FxParamType>,\n definitions: FxParamDefinition<FxParamType>[],\n transformType: FxParamTranformType\n): FxParamValue<FxParamType> | FxParamTransformation => {\n const definition = definitions.find(d => d.id === paramId)\n if (!definition) {\n throw new Error(`No definition found for param ${paramId}`)\n }\n const processor = ParameterProcessors[definition.type]\n const transformer = processor[\n transformType\n ] as FxParamProcessorTransformer<FxParamType>\n return transformer?.(value, definition) || value\n}\n\nexport const processParams = (\n values: FxParamsData,\n definitions: FxParamDefinition<FxParamType>[],\n transformType: FxParamTranformType\n): Record<string, FxParamValue<FxParamType>> => {\n const paramValues: Record<string, FxParamValue<FxParamType>> = {}\n for (const definition of definitions) {\n const processor = ParameterProcessors[definition.type]\n const value = values[definition.id]\n // deserialize the bytes into the params\n const transformer = processor[\n transformType\n ] as FxParamProcessorTransformer<FxParamType>\n paramValues[definition.id] = transformer?.(value, definition) || value\n }\n return paramValues\n}\n"]}
|
1
|
+
{"version":3,"file":"utils-BXUz-G9x.js","names":["r: number","g: number","b: number","a: number","hexCode: hexString | string","hexCode: hexString","s: string","h: string","ParameterProcessors: FxParamProcessors","input: any","input: string","hex","params: any","definition: FxParamDefinition<any>[]","params: FxParamsData","bytes: string","definition: FxParamDefinition<FxParamType>[]","options: { withTransform?: boolean; transformType?: FxParamTranformType }","params: FxParamsRaw | FxParamsTransformed","data: any","definition: FxParamDefinitions","data: FxParamsData | null","out: FxParamsData","params: FxParamDefinition<FxParamType>[]","options?: { noTransform?: boolean; randomizeAll?: boolean }","definitions: FxParamDefinition<FxParamType>[]","data: FxParamsData","paramId: string","value: FxParamValue<FxParamType>","transformType: FxParamTranformType","values: FxParamsData","paramValues: Record<string, FxParamValue<FxParamType>>"],"sources":["../src/utils.ts"],"sourcesContent":["import {\n hexString,\n FxParamDefinition,\n FxParamProcessor,\n FxParamProcessors,\n FxParamTypeMap,\n FxParamType,\n FxParamsData,\n FxParamValue,\n FxParamTranformType,\n FxParamProcessorTransformer,\n FxParamTransformation,\n FxParamsRaw,\n FxParamsTransformed,\n FxParamDefinitions,\n} from \"./types\"\n\nexport function rgbaToHex(r: number, g: number, b: number, a: number): string {\n const outParts = [\n r.toString(16),\n g.toString(16),\n b.toString(16),\n Math.round(a * 255)\n .toString(16)\n .substring(0, 2),\n ]\n\n // Pad single-digit output values\n outParts.forEach(function (part, i) {\n if (part.length === 1) {\n outParts[i] = \"0\" + part\n }\n })\n\n return \"#\" + outParts.join(\"\")\n}\n\nfunction completeHexColor(hexCode: hexString | string): string {\n let hex = hexCode.replace(\"#\", \"\")\n if (hex.length === 6) {\n hex = `${hex}ff`\n }\n if (hex.length === 3) {\n hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}ff`\n }\n return hex\n}\n\nexport function hexToRgba(hexCode: hexString) {\n const hex = completeHexColor(hexCode)\n\n const r = parseInt(hex.substring(0, 2), 16)\n const g = parseInt(hex.substring(2, 4), 16)\n const b = parseInt(hex.substring(4, 6), 16)\n const a =\n Math.round(\n (parseInt(hex.substring(6, 8), 16) / 255 + Number.EPSILON) * 100\n ) / 100\n\n return { r, g, b, a }\n}\n\nconst stringToHex = function (s: string) {\n let rtn = \"\"\n for (let i = 0; i < s.length; i++) {\n rtn += s.charCodeAt(i).toString(16).padStart(4, \"0\")\n }\n return rtn\n}\nconst hexToString = function (h: string) {\n const hx = h.match(/.{1,4}/g) || []\n let rtn = \"\"\n for (let i = 0; i < hx.length; i++) {\n const int = parseInt(hx[i], 16)\n if (int === 0) break\n rtn += String.fromCharCode(int)\n }\n return rtn\n}\n\nexport const MIN_SAFE_INT64 = BigInt(\"-9223372036854775808\")\nexport const MAX_SAFE_INT64 = BigInt(\"9223372036854775807\")\n\nexport const ParameterProcessors: FxParamProcessors = {\n number: {\n serialize: input => {\n const view = new DataView(new ArrayBuffer(8))\n view.setFloat64(0, input)\n return view.getBigUint64(0).toString(16).padStart(16, \"0\")\n },\n deserialize: input => {\n const view = new DataView(new ArrayBuffer(8))\n for (let i = 0; i < 8; i++) {\n view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16))\n }\n return view.getFloat64(0)\n },\n bytesLength: () => 8,\n constrain: (value, definition) => {\n let min = Number.MIN_SAFE_INTEGER\n if (typeof definition.options?.min !== \"undefined\")\n min = Number(definition.options.min)\n let max = Number.MAX_SAFE_INTEGER\n if (typeof definition.options?.max !== \"undefined\")\n max = Number(definition.options.max)\n max = Math.min(max, Number.MAX_SAFE_INTEGER)\n min = Math.max(min, Number.MIN_SAFE_INTEGER)\n const v = Math.min(Math.max(value, min), max)\n if (definition?.options?.step) {\n const t = 1.0 / definition?.options?.step\n return Math.round(v * t) / t\n }\n return v\n },\n random: definition => {\n let min = Number.MIN_SAFE_INTEGER\n if (typeof definition.options?.min !== \"undefined\")\n min = Number(definition.options.min)\n let max = Number.MAX_SAFE_INTEGER\n if (typeof definition.options?.max !== \"undefined\")\n max = Number(definition.options.max)\n max = Math.min(max, Number.MAX_SAFE_INTEGER)\n min = Math.max(min, Number.MIN_SAFE_INTEGER)\n const v = Math.random() * (max - min) + min\n if (definition?.options?.step) {\n const t = 1.0 / definition?.options?.step\n return Math.round(v * t) / t\n }\n return v\n },\n },\n bigint: {\n serialize: (input: any) => {\n const view = new DataView(new ArrayBuffer(8))\n view.setBigInt64(0, BigInt(input))\n return view.getBigUint64(0).toString(16).padStart(16, \"0\")\n },\n deserialize: (input: any) => {\n const view = new DataView(new ArrayBuffer(8))\n for (let i = 0; i < 8; i++) {\n view.setUint8(i, parseInt(input.substring(i * 2, i * 2 + 2), 16))\n }\n return view.getBigInt64(0)\n },\n bytesLength: () => 8,\n random: definition => {\n let min = MIN_SAFE_INT64\n let max = MAX_SAFE_INT64\n if (typeof definition.options?.min !== \"undefined\")\n min = BigInt(definition.options.min)\n if (typeof definition.options?.max !== \"undefined\")\n max = BigInt(definition.options.max)\n const range = max - min\n const bits = range.toString(2).length\n let random\n do {\n random = BigInt(\n \"0b\" +\n Array.from(\n crypto.getRandomValues(new Uint8Array(Math.ceil(bits / 8)))\n )\n .map(b => b.toString(2).padStart(8, \"0\"))\n .join(\"\")\n )\n } while (random > range)\n return random + min\n },\n },\n boolean: {\n serialize: input => {\n return typeof input === \"boolean\"\n ? input\n ? \"01\"\n : \"00\"\n : typeof input === \"string\"\n ? input === \"true\"\n ? \"01\"\n : \"00\"\n : \"00\"\n },\n deserialize: input => {\n return input === \"00\" ? false : true\n },\n bytesLength: () => 1,\n random: () => Math.random() < 0.5,\n },\n\n color: {\n serialize: (input: string) => {\n return completeHexColor(input)\n },\n\n deserialize: (input): hexString => {\n return input as hexString\n },\n bytesLength: () => 4,\n transform: (input: string) => {\n const color = completeHexColor(input)\n const r = parseInt(color.slice(0, 2), 16)\n const g = parseInt(color.slice(2, 4), 16)\n const b = parseInt(color.slice(4, 6), 16)\n const a = parseInt(color.slice(6, 8), 16)\n return {\n hex: {\n rgb: \"#\" + input.slice(0, 6),\n rgba: \"#\" + input,\n },\n obj: {\n rgb: { r, g, b },\n rgba: { r, g, b, a },\n },\n arr: {\n rgb: [r, g, b],\n rgba: [r, g, b, a],\n },\n }\n },\n constrain: value => {\n const hex = value.replace(\"#\", \"\")\n return hex.slice(0, 8).padEnd(8, \"f\")\n },\n random: () =>\n `${[...Array(8)]\n .map(() => Math.floor(Math.random() * 16).toString(16))\n .join(\"\")}`,\n },\n\n string: {\n serialize: (input, def) => {\n if (!def.version) {\n let hex = stringToHex(input.substring(0, 64))\n hex = hex.padEnd(64 * 4, \"0\")\n return hex\n }\n let max = 64\n if (typeof def.options?.maxLength !== \"undefined\")\n max = Number(def.options.maxLength)\n let hex = stringToHex(input.substring(0, max))\n hex = hex.padEnd(max * 4, \"0\")\n return hex\n },\n deserialize: input => {\n return hexToString(input)\n },\n\n bytesLength: def => {\n if (!def.version) {\n return 64 * 2\n }\n if (typeof def.options?.maxLength !== \"undefined\")\n return Number(def.options.maxLength) * 2\n return 64 * 2\n },\n random: definition => {\n let min = 0\n if (typeof definition.options?.minLength !== \"undefined\")\n min = definition.options.minLength\n let max = 64\n if (typeof definition.options?.maxLength !== \"undefined\")\n max = definition.options.maxLength\n const length = Math.round(Math.random() * (max - min) + min)\n return [...Array(length)]\n .map(i => (~~(Math.random() * 36)).toString(36))\n .join(\"\")\n },\n constrain: (value, definition) => {\n let min = 0\n if (typeof definition.options?.minLength !== \"undefined\")\n min = definition.options.minLength\n let max = 64\n if (typeof definition.options?.maxLength !== \"undefined\")\n max = definition.options.maxLength\n const v = value.slice(0, max)\n if (v.length < min) {\n return v.padEnd(min)\n }\n return v\n },\n },\n\n bytes: {\n serialize: (input, def) => {\n return Array.from(input)\n .map(i => i.toString(16).padStart(2, \"0\"))\n .join(\"\")\n },\n deserialize: (input, def) => {\n const len = input.length / 2\n const uint8 = new Uint8Array(len)\n let idx\n for (let i = 0; i < len; i++) {\n idx = i * 2\n uint8[i] = parseInt(`${input[idx]}${input[idx + 1]}`, 16)\n }\n return uint8\n },\n bytesLength: def => def.options.length,\n random: def => {\n const len = def.options?.length || 0\n const uint8 = new Uint8Array(len)\n for (let i = 0; i < len; i++) {\n uint8[i] = (Math.random() * 255) | 0\n }\n return uint8\n },\n },\n\n select: {\n serialize: (input, def) => {\n // find the index of the input in the array of options\n return Math.min(255, def.options?.options?.indexOf(input) || 0)\n .toString(16)\n .padStart(2, \"0\")\n },\n\n deserialize: (input, def) => {\n // get the index, which is the input\n const idx = parseInt(input, 16)\n return def.options?.options?.[idx] || def.options?.options?.[0] || \"\"\n },\n\n bytesLength: () => 1, // index between 0 and 255\n constrain: (value, definition) => {\n if (definition.options.options.includes(value)) {\n return value\n }\n return definition.options.options[0]\n },\n random: definition => {\n const index = Math.round(\n Math.random() * (definition.options.options.length - 1) + 0\n )\n return definition?.options?.options[index]\n },\n },\n}\n\n// params are injected into the piece using the binary representation of the\n// numbers, to keep precision\nexport function serializeParams(\n params: any,\n definition: FxParamDefinition<any>[]\n) {\n // a single hex string will be used for all the params\n let bytes = \"\"\n if (!definition) return bytes\n // loop through each parameter from the definition to find the associated\n // parameter as set on the UI\n for (const def of definition) {\n const { id, type } = def\n const processor = ParameterProcessors[\n type as FxParamType\n ] as FxParamProcessor<any>\n // if the param is definined in the object\n\n const v = params[id] as FxParamTypeMap[]\n const val =\n typeof v !== \"undefined\"\n ? v\n : typeof def.default !== \"undefined\"\n ? def.default\n : processor.random(def)\n const serialized = processor.serialize(val, def)\n bytes += serialized\n }\n\n return bytes\n}\n\n// call seralizeParams(), returns nullif no params\nexport function serializeParamsOrNull(\n params: FxParamsData,\n definition: FxParamDefinition<any>[]\n) {\n const serialized = serializeParams(params, definition || [])\n if (serialized.length === 0) return null\n return serialized\n}\n\n// takes an array of bytes, in hexadecimal format, and a parametric space\n// definition and outputs an array of parameters, mapping the definition and\n// validating input based on the definition constraints\nexport function deserializeParams(\n bytes: string,\n definition: FxParamDefinition<FxParamType>[],\n options: { withTransform?: boolean; transformType?: FxParamTranformType }\n) {\n const params: FxParamsRaw | FxParamsTransformed = {}\n for (const def of definition) {\n const processor = ParameterProcessors[\n def.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n const transformer =\n options.withTransform &&\n (processor[\n options.transformType || \"transform\"\n ] as FxParamProcessorTransformer<FxParamType>)\n if (!bytes) {\n let v\n if (typeof def.default === \"undefined\") v = processor.random(def)\n else v = def.default\n params[def.id] = transformer ? transformer(v, def) : v\n continue\n }\n // extract the length from the bytes & shift the initial bytes string\n const bytesLen = processor.bytesLength(def)\n const valueBytes = bytes.substring(0, bytesLen * 2)\n bytes = bytes.substring(bytesLen * 2)\n // deserialize the bytes into the params\n const val = processor.deserialize(\n valueBytes,\n def\n ) as FxParamValue<FxParamType>\n params[def.id] = transformer ? transformer(val, def) : val\n }\n return params\n}\n\n// Consolidates parameters from both a params object provided by the token\n// and the dat object of params, which is stored by the controls component.\nexport function consolidateParams(params: any, data: any) {\n if (!params) return []\n\n const rtn = [...params]\n\n for (const p in rtn) {\n const definition = rtn[p]\n const { id, type, default: def } = definition\n if (data && data.hasOwnProperty(id)) {\n rtn[p].value = data[id]\n } else {\n const processor = ParameterProcessors[\n type as FxParamType\n ] as FxParamProcessor<any>\n let v\n if (typeof def === \"undefined\") v = processor.random(definition)\n else v = def\n rtn[p].value = processor.transform?.(v) || v\n }\n }\n\n return rtn\n}\n\n/**\n * Given a definition and some params data, builds a clean params object where\n * the values are first found in the data object, then in the definition if a\n * default value exists, otherwise in randomizes the value using the param\n * associated processor.\n *\n * @param definition an array of parameter definition\n * @param data the params data used to reconstruct the final values\n */\nexport function buildParamsObject(\n definition: FxParamDefinitions,\n data: FxParamsData | null\n) {\n if (!definition) return {}\n\n const out: FxParamsData = {}\n for (const def of definition) {\n // find if the data object has the propery\n if (data?.hasOwnProperty(def.id)) {\n out[def.id] = data[def.id]\n continue\n }\n // find if the definition object has a default value\n if (def.hasOwnProperty(\"default\")) {\n out[def.id] = def.default\n continue\n }\n // otherwise use the param processor randomizer\n const processor = ParameterProcessors[def.type] as FxParamProcessor<any>\n const rand = processor.random(def)\n out[def.id] = processor.transform?.(rand) || rand\n }\n return out\n}\n\nexport function getRandomParamValues(\n params: FxParamDefinition<FxParamType>[],\n options?: { noTransform?: boolean; randomizeAll?: boolean }\n): any {\n return params.reduce(\n (acc, definition) => {\n const processor = ParameterProcessors[\n definition.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n let v = (definition.value || definition.default) as FxParamType\n if (definition.update !== \"code-driven\" || options?.randomizeAll) {\n v = processor.random(definition) as FxParamType\n }\n if (v) {\n acc[definition.id] = options?.noTransform\n ? v\n : processor.transform?.(v) || v\n }\n return acc\n },\n {} as Record<string, any>\n )\n}\n\nexport function sumBytesParams(\n definitions: FxParamDefinition<FxParamType>[]\n): number {\n return (\n definitions?.reduce(\n (acc, def) =>\n acc +\n (\n ParameterProcessors[\n def.type as FxParamType\n ] as FxParamProcessor<FxParamType>\n ).bytesLength(def),\n 0\n ) || 0\n )\n}\n\nexport function stringifyParamsData(data: FxParamsData) {\n return JSON.stringify(data, (key, value) => {\n if (typeof value === \"bigint\") return value.toString()\n return value\n })\n}\n\nexport function jsonStringifyBigint(data: any): string {\n return JSON.stringify(data, (key, value) => {\n if (typeof value === \"bigint\") return value.toString()\n return value\n })\n}\n\nexport const processParam = (\n paramId: string,\n value: FxParamValue<FxParamType>,\n definitions: FxParamDefinition<FxParamType>[],\n transformType: FxParamTranformType\n): FxParamValue<FxParamType> | FxParamTransformation => {\n const definition = definitions.find(d => d.id === paramId)\n if (!definition) {\n throw new Error(`No definition found for param ${paramId}`)\n }\n const processor = ParameterProcessors[definition.type]\n const transformer = processor[\n transformType\n ] as FxParamProcessorTransformer<FxParamType>\n return transformer?.(value, definition) || value\n}\n\nexport const processParams = (\n values: FxParamsData,\n definitions: FxParamDefinition<FxParamType>[],\n transformType: FxParamTranformType\n): Record<string, FxParamValue<FxParamType>> => {\n const paramValues: Record<string, FxParamValue<FxParamType>> = {}\n for (const definition of definitions) {\n const processor = ParameterProcessors[definition.type]\n const value = values[definition.id]\n // deserialize the bytes into the params\n const transformer = processor[\n transformType\n ] as FxParamProcessorTransformer<FxParamType>\n paramValues[definition.id] = transformer?.(value, definition) || value\n }\n return paramValues\n}\n"],"mappings":";AAiBA,SAAgB,UAAUA,GAAWC,G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