@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 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: TBD until market release
12
+ Questions: pnf036+anarchy@gmail.com
@@ -118,168 +118,217 @@ function getUnitsFromCssValue(value) {
118
118
 
119
119
  const getBrowserInfo = () => Bowser.parse(window.navigator.userAgent);
120
120
 
121
- // src/storages/globalConfig/globalConfig.ts
122
- var store;
123
- // @__NO_SIDE_EFFECTS__
124
- function getGlobalConfig(config2) {
125
- return {
126
- lang: config2?.lang ?? store?.lang,
127
- message: config2?.message,
128
- abortEarly: config2?.abortEarly ?? store?.abortEarly,
129
- abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
130
- };
131
- }
132
-
133
- // src/storages/globalMessage/globalMessage.ts
134
- var store2;
135
- // @__NO_SIDE_EFFECTS__
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
- return store2?.get(lang);
152
+ return store$3?.get(lang);
138
153
  }
139
154
 
140
- // src/storages/schemaMessage/schemaMessage.ts
141
- var store3;
142
- // @__NO_SIDE_EFFECTS__
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
- return store3?.get(lang);
167
+ return store$2?.get(lang);
145
168
  }
146
169
 
147
- // src/storages/specificMessage/specificMessage.ts
148
- var store4;
149
- // @__NO_SIDE_EFFECTS__
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
- return store4?.get(reference)?.get(lang);
183
+ return store$1?.get(reference)?.get(lang);
152
184
  }
153
185
 
154
- // src/utils/_stringify/_stringify.ts
155
- // @__NO_SIDE_EFFECTS__
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
- const type = typeof input;
158
- if (type === "string") {
159
- return `"${input}"`;
160
- }
161
- if (type === "number" || type === "bigint" || type === "boolean") {
162
- return `${input}`;
163
- }
164
- if (type === "object" || type === "function") {
165
- return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
166
- }
167
- return type;
168
- }
169
-
170
- // src/utils/_addIssue/_addIssue.ts
171
- function _addIssue(context, label, dataset, config2, other) {
172
- const input = dataset.value;
173
- const expected = context.expects ?? null;
174
- const received = _stringify(input);
175
- const issue = {
176
- kind: context.kind,
177
- type: context.type,
178
- input,
179
- expected,
180
- received,
181
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
182
- requirement: context.requirement,
183
- path: other?.path,
184
- issues: other?.issues,
185
- lang: config2.lang,
186
- abortEarly: config2.abortEarly,
187
- abortPipeEarly: config2.abortPipeEarly
188
- };
189
- const isSchema = context.kind === "schema";
190
- const message2 = context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
191
- if (message2 !== void 0) {
192
- issue.message = typeof message2 === "function" ? (
193
- // @ts-expect-error
194
- message2(issue)
195
- ) : message2;
196
- }
197
- if (isSchema) {
198
- dataset.typed = false;
199
- }
200
- if (dataset.issues) {
201
- dataset.issues.push(issue);
202
- } else {
203
- dataset.issues = [issue];
204
- }
205
- }
206
-
207
- // src/utils/_getStandardProps/_getStandardProps.ts
208
- // @__NO_SIDE_EFFECTS__
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
- return {
211
- version: 1,
212
- vendor: "valibot",
213
- validate(value2) {
214
- return context["~run"]({ value: value2 }, getGlobalConfig());
215
- }
216
- };
217
- }
218
-
219
- // src/actions/transform/transform.ts
220
- // @__NO_SIDE_EFFECTS__
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
- return {
223
- kind: "transformation",
224
- type: "transform",
225
- reference: transform,
226
- async: false,
227
- operation,
228
- "~run"(dataset) {
229
- dataset.value = this.operation(dataset.value);
230
- return dataset;
231
- }
232
- };
233
- }
234
-
235
- // src/schemas/string/string.ts
236
- // @__NO_SIDE_EFFECTS__
237
- function string(message2) {
238
- return {
239
- kind: "schema",
240
- type: "string",
241
- reference: string,
242
- expects: "string",
243
- async: false,
244
- message: message2,
245
- get "~standard"() {
246
- return _getStandardProps(this);
247
- },
248
- "~run"(dataset, config2) {
249
- if (typeof dataset.value === "string") {
250
- dataset.typed = true;
251
- } else {
252
- _addIssue(this, "type", dataset, config2);
253
- }
254
- return dataset;
255
- }
256
- };
257
- }
258
-
259
- // src/methods/pipe/pipe.ts
260
- // @__NO_SIDE_EFFECTS__
261
- function pipe(...pipe2) {
262
- return {
263
- ...pipe2[0],
264
- pipe: pipe2,
265
- get "~standard"() {
266
- return _getStandardProps(this);
267
- },
268
- "~run"(dataset, config2) {
269
- for (const item of pipe2) {
270
- if (item.kind !== "metadata") {
271
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
272
- dataset.typed = false;
273
- break;
274
- }
275
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
276
- dataset = item["~run"](dataset, config2);
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(