@hellpig/anarchy-shared 1.5.0 → 1.5.2
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/NOTICE.md +1 -1
- package/dist/Utils/index.es.js +199 -150
- package/dist/Utils/index.es.js.map +1 -1
- package/legal/DISCLAIMER.md +1 -1
- package/legal/EULA.md +2 -2
- package/legal/NOTICE.md +1 -1
- package/legal/PRIVACY.md +5 -5
- package/legal/SECURITY.md +3 -3
- package/legal/THIRD_PARTY_LICENSES.md +1 -1
- package/package.json +6 -5
package/NOTICE.md
CHANGED
|
@@ -9,4 +9,4 @@ Full attributions and license texts are provided **offline** at:
|
|
|
9
9
|
|
|
10
10
|
Nothing in this pointer modifies third-party licenses. If there is any conflict between this note and a third-party license, the third-party license controls.
|
|
11
11
|
|
|
12
|
-
Questions:
|
|
12
|
+
Questions: pnf036+anarchy@gmail.com
|
package/dist/Utils/index.es.js
CHANGED
|
@@ -118,168 +118,217 @@ function getUnitsFromCssValue(value) {
|
|
|
118
118
|
|
|
119
119
|
const getBrowserInfo = () => Bowser.parse(window.navigator.userAgent);
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
//#region src/storages/globalConfig/globalConfig.ts
|
|
122
|
+
let store$4;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the global configuration.
|
|
125
|
+
*
|
|
126
|
+
* @param config The config to merge.
|
|
127
|
+
*
|
|
128
|
+
* @returns The configuration.
|
|
129
|
+
*/
|
|
130
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
131
|
+
function getGlobalConfig(config$1) {
|
|
132
|
+
return {
|
|
133
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
134
|
+
message: config$1?.message,
|
|
135
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
136
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/storages/globalMessage/globalMessage.ts
|
|
142
|
+
let store$3;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a global error message.
|
|
145
|
+
*
|
|
146
|
+
* @param lang The language of the message.
|
|
147
|
+
*
|
|
148
|
+
* @returns The error message.
|
|
149
|
+
*/
|
|
150
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
136
151
|
function getGlobalMessage(lang) {
|
|
137
|
-
|
|
152
|
+
return store$3?.get(lang);
|
|
138
153
|
}
|
|
139
154
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/storages/schemaMessage/schemaMessage.ts
|
|
157
|
+
let store$2;
|
|
158
|
+
/**
|
|
159
|
+
* Returns a schema error message.
|
|
160
|
+
*
|
|
161
|
+
* @param lang The language of the message.
|
|
162
|
+
*
|
|
163
|
+
* @returns The error message.
|
|
164
|
+
*/
|
|
165
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
143
166
|
function getSchemaMessage(lang) {
|
|
144
|
-
|
|
167
|
+
return store$2?.get(lang);
|
|
145
168
|
}
|
|
146
169
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/storages/specificMessage/specificMessage.ts
|
|
172
|
+
let store$1;
|
|
173
|
+
/**
|
|
174
|
+
* Returns a specific error message.
|
|
175
|
+
*
|
|
176
|
+
* @param reference The identifier reference.
|
|
177
|
+
* @param lang The language of the message.
|
|
178
|
+
*
|
|
179
|
+
* @returns The error message.
|
|
180
|
+
*/
|
|
181
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
150
182
|
function getSpecificMessage(reference, lang) {
|
|
151
|
-
|
|
183
|
+
return store$1?.get(reference)?.get(lang);
|
|
152
184
|
}
|
|
153
185
|
|
|
154
|
-
|
|
155
|
-
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/utils/_stringify/_stringify.ts
|
|
188
|
+
/**
|
|
189
|
+
* Stringifies an unknown input to a literal or type string.
|
|
190
|
+
*
|
|
191
|
+
* @param input The unknown input.
|
|
192
|
+
*
|
|
193
|
+
* @returns A literal or type string.
|
|
194
|
+
*
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
156
198
|
function _stringify(input) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
const type = typeof input;
|
|
200
|
+
if (type === "string") return `"${input}"`;
|
|
201
|
+
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
202
|
+
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
203
|
+
return type;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/utils/_addIssue/_addIssue.ts
|
|
208
|
+
/**
|
|
209
|
+
* Adds an issue to the dataset.
|
|
210
|
+
*
|
|
211
|
+
* @param context The issue context.
|
|
212
|
+
* @param label The issue label.
|
|
213
|
+
* @param dataset The input dataset.
|
|
214
|
+
* @param config The configuration.
|
|
215
|
+
* @param other The optional props.
|
|
216
|
+
*
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
function _addIssue(context, label, dataset, config$1, other) {
|
|
220
|
+
const input = dataset.value;
|
|
221
|
+
const expected = context.expects ?? null;
|
|
222
|
+
const received = /* @__PURE__ */ _stringify(input);
|
|
223
|
+
const issue = {
|
|
224
|
+
kind: context.kind,
|
|
225
|
+
type: context.type,
|
|
226
|
+
input,
|
|
227
|
+
expected,
|
|
228
|
+
received,
|
|
229
|
+
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
230
|
+
requirement: context.requirement,
|
|
231
|
+
path: other?.path,
|
|
232
|
+
issues: other?.issues,
|
|
233
|
+
lang: config$1.lang,
|
|
234
|
+
abortEarly: config$1.abortEarly,
|
|
235
|
+
abortPipeEarly: config$1.abortPipeEarly
|
|
236
|
+
};
|
|
237
|
+
const isSchema = context.kind === "schema";
|
|
238
|
+
const message$1 = context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
239
|
+
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
240
|
+
if (isSchema) dataset.typed = false;
|
|
241
|
+
if (dataset.issues) dataset.issues.push(issue);
|
|
242
|
+
else dataset.issues = [issue];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region src/utils/_getStandardProps/_getStandardProps.ts
|
|
247
|
+
/**
|
|
248
|
+
* Returns the Standard Schema properties.
|
|
249
|
+
*
|
|
250
|
+
* @param context The schema context.
|
|
251
|
+
*
|
|
252
|
+
* @returns The Standard Schema properties.
|
|
253
|
+
*/
|
|
254
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
209
255
|
function _getStandardProps(context) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
256
|
+
return {
|
|
257
|
+
version: 1,
|
|
258
|
+
vendor: "valibot",
|
|
259
|
+
validate(value$1) {
|
|
260
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/actions/transform/transform.ts
|
|
267
|
+
/**
|
|
268
|
+
* Creates a custom transformation action.
|
|
269
|
+
*
|
|
270
|
+
* @param operation The transformation operation.
|
|
271
|
+
*
|
|
272
|
+
* @returns A transform action.
|
|
273
|
+
*/
|
|
274
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
221
275
|
function transform(operation) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return dataset;
|
|
281
|
-
}
|
|
282
|
-
};
|
|
276
|
+
return {
|
|
277
|
+
kind: "transformation",
|
|
278
|
+
type: "transform",
|
|
279
|
+
reference: transform,
|
|
280
|
+
async: false,
|
|
281
|
+
operation,
|
|
282
|
+
"~run"(dataset) {
|
|
283
|
+
dataset.value = this.operation(dataset.value);
|
|
284
|
+
return dataset;
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/schemas/string/string.ts
|
|
291
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
292
|
+
function string(message$1) {
|
|
293
|
+
return {
|
|
294
|
+
kind: "schema",
|
|
295
|
+
type: "string",
|
|
296
|
+
reference: string,
|
|
297
|
+
expects: "string",
|
|
298
|
+
async: false,
|
|
299
|
+
message: message$1,
|
|
300
|
+
get "~standard"() {
|
|
301
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
302
|
+
},
|
|
303
|
+
"~run"(dataset, config$1) {
|
|
304
|
+
if (typeof dataset.value === "string") dataset.typed = true;
|
|
305
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
306
|
+
return dataset;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/methods/pipe/pipe.ts
|
|
313
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
314
|
+
function pipe(...pipe$1) {
|
|
315
|
+
return {
|
|
316
|
+
...pipe$1[0],
|
|
317
|
+
pipe: pipe$1,
|
|
318
|
+
get "~standard"() {
|
|
319
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
320
|
+
},
|
|
321
|
+
"~run"(dataset, config$1) {
|
|
322
|
+
for (const item of pipe$1) if (item.kind !== "metadata") {
|
|
323
|
+
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
324
|
+
dataset.typed = false;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
|
|
328
|
+
}
|
|
329
|
+
return dataset;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
283
332
|
}
|
|
284
333
|
|
|
285
334
|
const toBool = pipe(
|