@esposter/shared 2.21.0 → 2.23.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +421 -45
  2. package/dist/index.js +565 -101
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
9
  var __exportAll = (all, no_symbols) => {
10
10
  let target = {};
11
11
  for (var name in all) __defProp(target, name, {
@@ -27,6 +27,9 @@ var __copyProps = (to, from, except, desc) => {
27
27
  };
28
28
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  //#endregion
30
+ //#region src/util/function/noop.ts
31
+ const noop = () => {};
32
+ //#endregion
30
33
  //#region src/test/constants.ts
31
34
  const AllSpecialValues = [
32
35
  {
@@ -67,11 +70,11 @@ const AllSpecialValues = [
67
70
  },
68
71
  {
69
72
  isPlainObject: false,
70
- value: () => {}
73
+ value: noop
71
74
  },
72
75
  {
73
76
  isPlainObject: false,
74
- value: /* @__PURE__ */ new RegExp("")
77
+ value: /* @__PURE__ */ new RegExp("", "u")
75
78
  }
76
79
  ];
77
80
  //#endregion
@@ -180,9 +183,9 @@ let Operation = /* @__PURE__ */ function(Operation) {
180
183
  return Operation;
181
184
  }({});
182
185
  //#endregion
183
- //#region ../../node_modules/.pnpm/@vue+shared@3.5.32/node_modules/@vue/shared/dist/shared.esm-bundler.js
186
+ //#region ../../node_modules/.pnpm/@vue+shared@3.5.34/node_modules/@vue/shared/dist/shared.esm-bundler.js
184
187
  /**
185
- * @vue/shared v3.5.32
188
+ * @vue/shared v3.5.34
186
189
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
187
190
  * @license MIT
188
191
  **/
@@ -195,7 +198,6 @@ function makeMap(str) {
195
198
  const EMPTY_OBJ = Object.freeze({});
196
199
  Object.freeze([]);
197
200
  const NOOP = () => {};
198
- const NO = () => false;
199
201
  const extend = Object.assign;
200
202
  const remove = (arr, el) => {
201
203
  const i = arr.indexOf(el);
@@ -226,18 +228,9 @@ const cacheStringFunction$1 = (fn) => {
226
228
  return cache[str] || (cache[str] = fn(str));
227
229
  });
228
230
  };
229
- const camelizeRE$1 = /-\w/g;
230
- cacheStringFunction$1((str) => {
231
- return str.replace(camelizeRE$1, (c) => c.slice(1).toUpperCase());
232
- });
233
- const hyphenateRE$1 = /\B([A-Z])/g;
234
- cacheStringFunction$1((str) => str.replace(hyphenateRE$1, "-$1").toLowerCase());
235
231
  const capitalize$1 = cacheStringFunction$1((str) => {
236
232
  return str.charAt(0).toUpperCase() + str.slice(1);
237
233
  });
238
- const toHandlerKey = cacheStringFunction$1((str) => {
239
- return str ? `on${capitalize$1(str)}` : ``;
240
- });
241
234
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
242
235
  const def = (obj, key, value, writable = false) => {
243
236
  Object.defineProperty(obj, key, {
@@ -252,9 +245,9 @@ const getGlobalThis = () => {
252
245
  return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
253
246
  };
254
247
  //#endregion
255
- //#region ../../node_modules/.pnpm/@vue+reactivity@3.5.32/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
248
+ //#region ../../node_modules/.pnpm/@vue+reactivity@3.5.34/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
256
249
  /**
257
- * @vue/reactivity v3.5.32
250
+ * @vue/reactivity v3.5.34
258
251
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
259
252
  * @license MIT
260
253
  **/
@@ -1354,9 +1347,9 @@ function traverse(value, depth = Infinity, seen) {
1354
1347
  return value;
1355
1348
  }
1356
1349
  //#endregion
1357
- //#region ../../node_modules/.pnpm/@vue+runtime-core@3.5.32/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js
1350
+ //#region ../../node_modules/.pnpm/@vue+runtime-core@3.5.34/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js
1358
1351
  /**
1359
- * @vue/runtime-core v3.5.32
1352
+ * @vue/runtime-core v3.5.34
1360
1353
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
1361
1354
  * @license MIT
1362
1355
  **/
@@ -1828,34 +1821,6 @@ function createPathGetter(ctx, path) {
1828
1821
  }
1829
1822
  getGlobalThis().requestIdleCallback;
1830
1823
  getGlobalThis().cancelIdleCallback;
1831
- function injectHook(type, hook, target = currentInstance, prepend = false) {
1832
- if (target) {
1833
- const hooks = target[type] || (target[type] = []);
1834
- const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
1835
- pauseTracking();
1836
- const reset = setCurrentInstance(target);
1837
- const res = callWithAsyncErrorHandling(hook, target, type, args);
1838
- reset();
1839
- resetTracking();
1840
- return res;
1841
- });
1842
- if (prepend) hooks.unshift(wrappedHook);
1843
- else hooks.push(wrappedHook);
1844
- return wrappedHook;
1845
- } else warn$1(`${toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""))} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
1846
- }
1847
- const createHook = (lifecycle) => (hook, target = currentInstance) => {
1848
- if (!isInSSRComponentSetup || lifecycle === "sp") injectHook(lifecycle, (...args) => hook(...args), target);
1849
- };
1850
- createHook("bm");
1851
- createHook("m");
1852
- createHook("bu");
1853
- createHook("u");
1854
- createHook("bum");
1855
- createHook("um");
1856
- createHook("sp");
1857
- createHook("rtg");
1858
- createHook("rtc");
1859
1824
  const getPublicInstance = (i) => {
1860
1825
  if (!i) return null;
1861
1826
  if (isStatefulComponent(i)) return getComponentPublicInstance(i);
@@ -1911,10 +1876,8 @@ const PublicInstanceProxyHandlers = {
1911
1876
  const publicGetter = publicPropertiesMap[key];
1912
1877
  let cssModule, globalProperties;
1913
1878
  if (publicGetter) {
1914
- if (key === "$attrs") {
1915
- track(instance.attrs, "get", "");
1916
- markAttrsAccessed();
1917
- } else if (key === "$slots") track(instance, "get", key);
1879
+ if (key === "$attrs") track(instance.attrs, "get", "");
1880
+ else if (key === "$slots") track(instance, "get", key);
1918
1881
  return publicGetter(instance);
1919
1882
  } else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) return cssModule;
1920
1883
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
@@ -2056,36 +2019,13 @@ function mergeWatchOptions(to, from) {
2056
2019
  for (const key in from) merged[key] = mergeAsArray(to[key], from[key]);
2057
2020
  return merged;
2058
2021
  }
2059
- function createAppContext() {
2060
- return {
2061
- app: null,
2062
- config: {
2063
- isNativeTag: NO,
2064
- performance: false,
2065
- globalProperties: {},
2066
- optionMergeStrategies: {},
2067
- errorHandler: void 0,
2068
- warnHandler: void 0,
2069
- compilerOptions: {}
2070
- },
2071
- mixins: [],
2072
- components: {},
2073
- directives: {},
2074
- provides: /* @__PURE__ */ Object.create(null),
2075
- optionsCache: /* @__PURE__ */ new WeakMap(),
2076
- propsCache: /* @__PURE__ */ new WeakMap(),
2077
- emitsCache: /* @__PURE__ */ new WeakMap()
2078
- };
2079
- }
2080
2022
  let currentApp = null;
2081
- function markAttrsAccessed() {}
2082
2023
  const queuePostRenderEffect = queueEffectWithSuspense;
2083
2024
  function queueEffectWithSuspense(fn, suspense) {
2084
2025
  if (suspense && suspense.pendingBranch) if (isArray(fn)) suspense.effects.push(...fn);
2085
2026
  else suspense.effects.push(fn);
2086
2027
  else queuePostFlushCb(fn);
2087
2028
  }
2088
- createAppContext();
2089
2029
  let currentInstance = null;
2090
2030
  const getCurrentInstance = () => currentInstance || currentRenderingInstance;
2091
2031
  let internalSetCurrentInstance;
@@ -2313,9 +2253,9 @@ function initCustomFormatter() {
2313
2253
  else window.devtoolsFormatters = [formatter];
2314
2254
  }
2315
2255
  //#endregion
2316
- //#region ../../node_modules/.pnpm/vue@3.5.32_typescript@5.9.3/node_modules/vue/dist/vue.runtime.esm-bundler.js
2256
+ //#region ../../node_modules/.pnpm/vue@3.5.34_typescript@5.9.3/node_modules/vue/dist/vue.runtime.esm-bundler.js
2317
2257
  /**
2318
- * vue v3.5.32
2258
+ * vue v3.5.34
2319
2259
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
2320
2260
  * @license MIT
2321
2261
  **/
@@ -2329,18 +2269,6 @@ const getRawData = (data) => /* @__PURE__ */ isReactive(data) ? /* @__PURE__ */
2329
2269
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
2330
2270
  const toString = Object.prototype.toString;
2331
2271
  const isObject = (val) => toString.call(val) === "[object Object]";
2332
- function cacheStringFunction(fn) {
2333
- const cache = Object.create(null);
2334
- return ((str) => {
2335
- return cache[str] || (cache[str] = fn(str));
2336
- });
2337
- }
2338
- const hyphenateRE = /\B([A-Z])/g;
2339
- cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
2340
- const camelizeRE = /-(\w)/g;
2341
- cacheStringFunction((str) => {
2342
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
2343
- });
2344
2272
  //#endregion
2345
2273
  //#region src/util/reactivity/toRawDeep.ts
2346
2274
  const toRawDeep = (data) => {
@@ -2360,6 +2288,507 @@ var Serializable = class {
2360
2288
  }
2361
2289
  };
2362
2290
  //#endregion
2291
+ //#region src/services/error/toAppError.ts
2292
+ const toAppError = (error) => {
2293
+ if (error instanceof Error) return error;
2294
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") return new Error(error.message, { cause: error });
2295
+ return new Error(String(error), { cause: error });
2296
+ };
2297
+ //#endregion
2298
+ //#region ../../node_modules/.pnpm/neverthrow@8.2.0/node_modules/neverthrow/dist/index.es.js
2299
+ const defaultErrorConfig = { withStackTrace: false };
2300
+ const createNeverThrowError = (message, result, config = defaultErrorConfig) => {
2301
+ return {
2302
+ data: result.isOk() ? {
2303
+ type: "Ok",
2304
+ value: result.value
2305
+ } : {
2306
+ type: "Err",
2307
+ value: result.error
2308
+ },
2309
+ message,
2310
+ stack: config.withStackTrace ? (/* @__PURE__ */ new Error()).stack : void 0
2311
+ };
2312
+ };
2313
+ /******************************************************************************
2314
+ Copyright (c) Microsoft Corporation.
2315
+
2316
+ Permission to use, copy, modify, and/or distribute this software for any
2317
+ purpose with or without fee is hereby granted.
2318
+
2319
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2320
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2321
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2322
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2323
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2324
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2325
+ PERFORMANCE OF THIS SOFTWARE.
2326
+ ***************************************************************************** */
2327
+ function __awaiter(thisArg, _arguments, P, generator) {
2328
+ function adopt(value) {
2329
+ return value instanceof P ? value : new P(function(resolve) {
2330
+ resolve(value);
2331
+ });
2332
+ }
2333
+ return new (P || (P = Promise))(function(resolve, reject) {
2334
+ function fulfilled(value) {
2335
+ try {
2336
+ step(generator.next(value));
2337
+ } catch (e) {
2338
+ reject(e);
2339
+ }
2340
+ }
2341
+ function rejected(value) {
2342
+ try {
2343
+ step(generator["throw"](value));
2344
+ } catch (e) {
2345
+ reject(e);
2346
+ }
2347
+ }
2348
+ function step(result) {
2349
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
2350
+ }
2351
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2352
+ });
2353
+ }
2354
+ function __values(o) {
2355
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2356
+ if (m) return m.call(o);
2357
+ if (o && typeof o.length === "number") return { next: function() {
2358
+ if (o && i >= o.length) o = void 0;
2359
+ return {
2360
+ value: o && o[i++],
2361
+ done: !o
2362
+ };
2363
+ } };
2364
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2365
+ }
2366
+ function __await(v) {
2367
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
2368
+ }
2369
+ function __asyncGenerator(thisArg, _arguments, generator) {
2370
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2371
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
2372
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
2373
+ return this;
2374
+ }, i;
2375
+ function awaitReturn(f) {
2376
+ return function(v) {
2377
+ return Promise.resolve(v).then(f, reject);
2378
+ };
2379
+ }
2380
+ function verb(n, f) {
2381
+ if (g[n]) {
2382
+ i[n] = function(v) {
2383
+ return new Promise(function(a, b) {
2384
+ q.push([
2385
+ n,
2386
+ v,
2387
+ a,
2388
+ b
2389
+ ]) > 1 || resume(n, v);
2390
+ });
2391
+ };
2392
+ if (f) i[n] = f(i[n]);
2393
+ }
2394
+ }
2395
+ function resume(n, v) {
2396
+ try {
2397
+ step(g[n](v));
2398
+ } catch (e) {
2399
+ settle(q[0][3], e);
2400
+ }
2401
+ }
2402
+ function step(r) {
2403
+ r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
2404
+ }
2405
+ function fulfill(value) {
2406
+ resume("next", value);
2407
+ }
2408
+ function reject(value) {
2409
+ resume("throw", value);
2410
+ }
2411
+ function settle(f, v) {
2412
+ if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
2413
+ }
2414
+ }
2415
+ function __asyncDelegator(o) {
2416
+ var i, p;
2417
+ return i = {}, verb("next"), verb("throw", function(e) {
2418
+ throw e;
2419
+ }), verb("return"), i[Symbol.iterator] = function() {
2420
+ return this;
2421
+ }, i;
2422
+ function verb(n, f) {
2423
+ i[n] = o[n] ? function(v) {
2424
+ return (p = !p) ? {
2425
+ value: __await(o[n](v)),
2426
+ done: false
2427
+ } : f ? f(v) : v;
2428
+ } : f;
2429
+ }
2430
+ }
2431
+ function __asyncValues(o) {
2432
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2433
+ var m = o[Symbol.asyncIterator], i;
2434
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
2435
+ return this;
2436
+ }, i);
2437
+ function verb(n) {
2438
+ i[n] = o[n] && function(v) {
2439
+ return new Promise(function(resolve, reject) {
2440
+ v = o[n](v), settle(resolve, reject, v.done, v.value);
2441
+ });
2442
+ };
2443
+ }
2444
+ function settle(resolve, reject, d, v) {
2445
+ Promise.resolve(v).then(function(v) {
2446
+ resolve({
2447
+ value: v,
2448
+ done: d
2449
+ });
2450
+ }, reject);
2451
+ }
2452
+ }
2453
+ var ResultAsync = class ResultAsync {
2454
+ constructor(res) {
2455
+ this._promise = res;
2456
+ }
2457
+ static fromSafePromise(promise) {
2458
+ return new ResultAsync(promise.then((value) => new Ok(value)));
2459
+ }
2460
+ static fromPromise(promise, errorFn) {
2461
+ return new ResultAsync(promise.then((value) => new Ok(value)).catch((e) => new Err(errorFn(e))));
2462
+ }
2463
+ static fromThrowable(fn, errorFn) {
2464
+ return (...args) => {
2465
+ return new ResultAsync(__awaiter(this, void 0, void 0, function* () {
2466
+ try {
2467
+ return new Ok(yield fn(...args));
2468
+ } catch (error) {
2469
+ return new Err(errorFn ? errorFn(error) : error);
2470
+ }
2471
+ }));
2472
+ };
2473
+ }
2474
+ static combine(asyncResultList) {
2475
+ return combineResultAsyncList(asyncResultList);
2476
+ }
2477
+ static combineWithAllErrors(asyncResultList) {
2478
+ return combineResultAsyncListWithAllErrors(asyncResultList);
2479
+ }
2480
+ map(f) {
2481
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2482
+ if (res.isErr()) return new Err(res.error);
2483
+ return new Ok(yield f(res.value));
2484
+ })));
2485
+ }
2486
+ andThrough(f) {
2487
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2488
+ if (res.isErr()) return new Err(res.error);
2489
+ const newRes = yield f(res.value);
2490
+ if (newRes.isErr()) return new Err(newRes.error);
2491
+ return new Ok(res.value);
2492
+ })));
2493
+ }
2494
+ andTee(f) {
2495
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2496
+ if (res.isErr()) return new Err(res.error);
2497
+ try {
2498
+ yield f(res.value);
2499
+ } catch (e) {}
2500
+ return new Ok(res.value);
2501
+ })));
2502
+ }
2503
+ orTee(f) {
2504
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2505
+ if (res.isOk()) return new Ok(res.value);
2506
+ try {
2507
+ yield f(res.error);
2508
+ } catch (e) {}
2509
+ return new Err(res.error);
2510
+ })));
2511
+ }
2512
+ mapErr(f) {
2513
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2514
+ if (res.isOk()) return new Ok(res.value);
2515
+ return new Err(yield f(res.error));
2516
+ })));
2517
+ }
2518
+ andThen(f) {
2519
+ return new ResultAsync(this._promise.then((res) => {
2520
+ if (res.isErr()) return new Err(res.error);
2521
+ const newValue = f(res.value);
2522
+ return newValue instanceof ResultAsync ? newValue._promise : newValue;
2523
+ }));
2524
+ }
2525
+ orElse(f) {
2526
+ return new ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
2527
+ if (res.isErr()) return f(res.error);
2528
+ return new Ok(res.value);
2529
+ })));
2530
+ }
2531
+ match(ok, _err) {
2532
+ return this._promise.then((res) => res.match(ok, _err));
2533
+ }
2534
+ unwrapOr(t) {
2535
+ return this._promise.then((res) => res.unwrapOr(t));
2536
+ }
2537
+ /**
2538
+ * @deprecated will be removed in 9.0.0.
2539
+ *
2540
+ * You can use `safeTry` without this method.
2541
+ * @example
2542
+ * ```typescript
2543
+ * safeTry(async function* () {
2544
+ * const okValue = yield* yourResult
2545
+ * })
2546
+ * ```
2547
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
2548
+ */
2549
+ safeUnwrap() {
2550
+ return __asyncGenerator(this, arguments, function* safeUnwrap_1() {
2551
+ return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(yield __await(this._promise.then((res) => res.safeUnwrap()))))));
2552
+ });
2553
+ }
2554
+ then(successCallback, failureCallback) {
2555
+ return this._promise.then(successCallback, failureCallback);
2556
+ }
2557
+ [Symbol.asyncIterator]() {
2558
+ return __asyncGenerator(this, arguments, function* _a() {
2559
+ const result = yield __await(this._promise);
2560
+ if (result.isErr()) yield yield __await(errAsync(result.error));
2561
+ return yield __await(result.value);
2562
+ });
2563
+ }
2564
+ };
2565
+ function errAsync(err) {
2566
+ return new ResultAsync(Promise.resolve(new Err(err)));
2567
+ }
2568
+ ResultAsync.fromPromise;
2569
+ ResultAsync.fromSafePromise;
2570
+ ResultAsync.fromThrowable;
2571
+ /**
2572
+ * Short circuits on the FIRST Err value that we find
2573
+ */
2574
+ const combineResultList = (resultList) => {
2575
+ let acc = ok([]);
2576
+ for (const result of resultList) if (result.isErr()) {
2577
+ acc = err(result.error);
2578
+ break;
2579
+ } else acc.map((list) => list.push(result.value));
2580
+ return acc;
2581
+ };
2582
+ const combineResultAsyncList = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
2583
+ /**
2584
+ * Give a list of all the errors we find
2585
+ */
2586
+ const combineResultListWithAllErrors = (resultList) => {
2587
+ let acc = ok([]);
2588
+ for (const result of resultList) if (result.isErr() && acc.isErr()) acc.error.push(result.error);
2589
+ else if (result.isErr() && acc.isOk()) acc = err([result.error]);
2590
+ else if (result.isOk() && acc.isOk()) acc.value.push(result.value);
2591
+ return acc;
2592
+ };
2593
+ const combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
2594
+ var Result;
2595
+ (function(Result) {
2596
+ /**
2597
+ * Wraps a function with a try catch, creating a new function with the same
2598
+ * arguments but returning `Ok` if successful, `Err` if the function throws
2599
+ *
2600
+ * @param fn function to wrap with ok on success or err on failure
2601
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
2602
+ */
2603
+ function fromThrowable(fn, errorFn) {
2604
+ return (...args) => {
2605
+ try {
2606
+ return ok(fn(...args));
2607
+ } catch (e) {
2608
+ return err(errorFn ? errorFn(e) : e);
2609
+ }
2610
+ };
2611
+ }
2612
+ Result.fromThrowable = fromThrowable;
2613
+ function combine(resultList) {
2614
+ return combineResultList(resultList);
2615
+ }
2616
+ Result.combine = combine;
2617
+ function combineWithAllErrors(resultList) {
2618
+ return combineResultListWithAllErrors(resultList);
2619
+ }
2620
+ Result.combineWithAllErrors = combineWithAllErrors;
2621
+ })(Result || (Result = {}));
2622
+ function ok(value) {
2623
+ return new Ok(value);
2624
+ }
2625
+ function err(err) {
2626
+ return new Err(err);
2627
+ }
2628
+ var Ok = class {
2629
+ constructor(value) {
2630
+ this.value = value;
2631
+ }
2632
+ isOk() {
2633
+ return true;
2634
+ }
2635
+ isErr() {
2636
+ return !this.isOk();
2637
+ }
2638
+ map(f) {
2639
+ return ok(f(this.value));
2640
+ }
2641
+ mapErr(_f) {
2642
+ return ok(this.value);
2643
+ }
2644
+ andThen(f) {
2645
+ return f(this.value);
2646
+ }
2647
+ andThrough(f) {
2648
+ return f(this.value).map((_value) => this.value);
2649
+ }
2650
+ andTee(f) {
2651
+ try {
2652
+ f(this.value);
2653
+ } catch (e) {}
2654
+ return ok(this.value);
2655
+ }
2656
+ orTee(_f) {
2657
+ return ok(this.value);
2658
+ }
2659
+ orElse(_f) {
2660
+ return ok(this.value);
2661
+ }
2662
+ asyncAndThen(f) {
2663
+ return f(this.value);
2664
+ }
2665
+ asyncAndThrough(f) {
2666
+ return f(this.value).map(() => this.value);
2667
+ }
2668
+ asyncMap(f) {
2669
+ return ResultAsync.fromSafePromise(f(this.value));
2670
+ }
2671
+ unwrapOr(_v) {
2672
+ return this.value;
2673
+ }
2674
+ match(ok, _err) {
2675
+ return ok(this.value);
2676
+ }
2677
+ safeUnwrap() {
2678
+ const value = this.value;
2679
+ return (function* () {
2680
+ return value;
2681
+ })();
2682
+ }
2683
+ _unsafeUnwrap(_) {
2684
+ return this.value;
2685
+ }
2686
+ _unsafeUnwrapErr(config) {
2687
+ throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
2688
+ }
2689
+ *[Symbol.iterator]() {
2690
+ return this.value;
2691
+ }
2692
+ };
2693
+ var Err = class {
2694
+ constructor(error) {
2695
+ this.error = error;
2696
+ }
2697
+ isOk() {
2698
+ return false;
2699
+ }
2700
+ isErr() {
2701
+ return !this.isOk();
2702
+ }
2703
+ map(_f) {
2704
+ return err(this.error);
2705
+ }
2706
+ mapErr(f) {
2707
+ return err(f(this.error));
2708
+ }
2709
+ andThrough(_f) {
2710
+ return err(this.error);
2711
+ }
2712
+ andTee(_f) {
2713
+ return err(this.error);
2714
+ }
2715
+ orTee(f) {
2716
+ try {
2717
+ f(this.error);
2718
+ } catch (e) {}
2719
+ return err(this.error);
2720
+ }
2721
+ andThen(_f) {
2722
+ return err(this.error);
2723
+ }
2724
+ orElse(f) {
2725
+ return f(this.error);
2726
+ }
2727
+ asyncAndThen(_f) {
2728
+ return errAsync(this.error);
2729
+ }
2730
+ asyncAndThrough(_f) {
2731
+ return errAsync(this.error);
2732
+ }
2733
+ asyncMap(_f) {
2734
+ return errAsync(this.error);
2735
+ }
2736
+ unwrapOr(v) {
2737
+ return v;
2738
+ }
2739
+ match(_ok, err) {
2740
+ return err(this.error);
2741
+ }
2742
+ safeUnwrap() {
2743
+ const error = this.error;
2744
+ return (function* () {
2745
+ yield err(error);
2746
+ throw new Error("Do not use this generator out of `safeTry`");
2747
+ })();
2748
+ }
2749
+ _unsafeUnwrap(config) {
2750
+ throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
2751
+ }
2752
+ _unsafeUnwrapErr(_) {
2753
+ return this.error;
2754
+ }
2755
+ *[Symbol.iterator]() {
2756
+ const self = this;
2757
+ yield self;
2758
+ return self;
2759
+ }
2760
+ };
2761
+ const fromThrowable = Result.fromThrowable;
2762
+ //#endregion
2763
+ //#region src/services/error/getResult.ts
2764
+ const getResult = (fn) => fromThrowable(fn, toAppError)();
2765
+ //#endregion
2766
+ //#region src/services/error/getResultAsync.ts
2767
+ const getResultAsync = (fn) => ResultAsync.fromPromise(Promise.resolve().then(fn), toAppError);
2768
+ //#endregion
2769
+ //#region src/services/error/withFinalizer.ts
2770
+ const withFinalizer = (fn, finalizer) => {
2771
+ const result = getResult(fn);
2772
+ (finalizer ? getResult(finalizer) : void 0)?.match(noop, (error) => {
2773
+ throw error;
2774
+ });
2775
+ return result.match((value) => value, (error) => {
2776
+ throw error;
2777
+ });
2778
+ };
2779
+ //#endregion
2780
+ //#region src/services/error/withFinalizerAsync.ts
2781
+ const withFinalizerAsync = async (fn, finalizer) => {
2782
+ const result = await getResultAsync(async () => fn());
2783
+ if (finalizer) await getResultAsync(async () => finalizer()).match(noop, (error) => {
2784
+ if (result.isOk()) throw error;
2785
+ console.error(error);
2786
+ });
2787
+ return result.match((value) => value, (error) => {
2788
+ throw error;
2789
+ });
2790
+ };
2791
+ //#endregion
2363
2792
  //#region src/services/message/constants.ts
2364
2793
  const MENTION_ID_ATTRIBUTE = "data-id";
2365
2794
  const MENTION_LABEL_ATTRIBUTE = "data-label";
@@ -6651,6 +7080,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6651
7080
  this.endIndex = null;
6652
7081
  }
6653
7082
  Object.defineProperty(Node.prototype, "parentNode", {
7083
+ /**
7084
+ * Same as {@link parent}.
7085
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7086
+ */
6654
7087
  get: function() {
6655
7088
  return this.parent;
6656
7089
  },
@@ -6661,6 +7094,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6661
7094
  configurable: true
6662
7095
  });
6663
7096
  Object.defineProperty(Node.prototype, "previousSibling", {
7097
+ /**
7098
+ * Same as {@link prev}.
7099
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7100
+ */
6664
7101
  get: function() {
6665
7102
  return this.prev;
6666
7103
  },
@@ -6671,6 +7108,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6671
7108
  configurable: true
6672
7109
  });
6673
7110
  Object.defineProperty(Node.prototype, "nextSibling", {
7111
+ /**
7112
+ * Same as {@link next}.
7113
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7114
+ */
6674
7115
  get: function() {
6675
7116
  return this.next;
6676
7117
  },
@@ -6707,6 +7148,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6707
7148
  return _this;
6708
7149
  }
6709
7150
  Object.defineProperty(DataNode.prototype, "nodeValue", {
7151
+ /**
7152
+ * Same as {@link data}.
7153
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7154
+ */
6710
7155
  get: function() {
6711
7156
  return this.data;
6712
7157
  },
@@ -6794,6 +7239,7 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6794
7239
  return _this;
6795
7240
  }
6796
7241
  Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
7242
+ /** First child of the node. */
6797
7243
  get: function() {
6798
7244
  var _a;
6799
7245
  return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
@@ -6802,6 +7248,7 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6802
7248
  configurable: true
6803
7249
  });
6804
7250
  Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
7251
+ /** Last child of the node. */
6805
7252
  get: function() {
6806
7253
  return this.children.length > 0 ? this.children[this.children.length - 1] : null;
6807
7254
  },
@@ -6809,6 +7256,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6809
7256
  configurable: true
6810
7257
  });
6811
7258
  Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
7259
+ /**
7260
+ * Same as {@link children}.
7261
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7262
+ */
6812
7263
  get: function() {
6813
7264
  return this.children;
6814
7265
  },
@@ -6885,6 +7336,10 @@ var require_node = /* @__PURE__ */ __commonJSMin(((exports) => {
6885
7336
  configurable: true
6886
7337
  });
6887
7338
  Object.defineProperty(Element.prototype, "tagName", {
7339
+ /**
7340
+ * Same as {@link name}.
7341
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
7342
+ */
6888
7343
  get: function() {
6889
7344
  return this.name;
6890
7345
  },
@@ -12406,6 +12861,9 @@ var require_subselects = /* @__PURE__ */ __commonJSMin(((exports) => {
12406
12861
  };
12407
12862
  exports.subselects = {
12408
12863
  is,
12864
+ /**
12865
+ * `:matches` and `:where` are aliases for `:is`.
12866
+ */
12409
12867
  matches: is,
12410
12868
  where: is,
12411
12869
  not: function(next, token, options, context, compileToken) {
@@ -13300,7 +13758,8 @@ var require_html = /* @__PURE__ */ __commonJSMin(((exports) => {
13300
13758
  * @param {HTMLElement} newNode new node
13301
13759
  */
13302
13760
  exchangeChild(oldNode, newNode) {
13303
- this.childNodes = this.childNodes.map((child) => {
13761
+ const children = this.childNodes;
13762
+ this.childNodes = children.map((child) => {
13304
13763
  if (child === oldNode) return newNode;
13305
13764
  return child;
13306
13765
  });
@@ -13338,7 +13797,8 @@ var require_html = /* @__PURE__ */ __commonJSMin(((exports) => {
13338
13797
  return decode(this.rawText);
13339
13798
  }
13340
13799
  set textContent(val) {
13341
- this.childNodes = [new text_1.default(val, this)];
13800
+ const content = [new text_1.default(val, this)];
13801
+ this.childNodes = content;
13342
13802
  }
13343
13803
  /**
13344
13804
  * Get unescaped text value of current node and its children.
@@ -13490,10 +13950,11 @@ var require_html = /* @__PURE__ */ __commonJSMin(((exports) => {
13490
13950
  this.childNodes[o++] = node;
13491
13951
  });
13492
13952
  this.childNodes.length = o;
13493
- this.rawAttrs = Object.keys(this.rawAttributes).map((key) => {
13953
+ const attrs = Object.keys(this.rawAttributes).map((key) => {
13494
13954
  const val = this.rawAttributes[key];
13495
13955
  return `${key}=${JSON.stringify(val)}`;
13496
13956
  }).join(" ");
13957
+ this.rawAttrs = attrs;
13497
13958
  delete this._rawAttrs;
13498
13959
  return this;
13499
13960
  }
@@ -14353,17 +14814,17 @@ const isPlainObject = (data) => {
14353
14814
  };
14354
14815
  //#endregion
14355
14816
  //#region src/util/object/jsonDateParse.ts
14356
- const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.{0,1}\d*))(?:Z|(\+|-)([\d|:]*))?$/;
14357
- const reMsAjax = /^\/Date\((d|-|.*)\)[/|\\]$/;
14817
+ const ISO_DATE_REGEX = new RegExp(String.raw`^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.{0,1}\d*))(?:Z|(\+|-)([\d|:]*))?$`, "u");
14818
+ const MS_AJAX_DATE_REGEX = new RegExp(String.raw`^\/Date\((d|-|.*)\)[\/|\\]$`, "u");
14358
14819
  const jsonDateParse = (text) => JSON.parse(text, (_key, value) => {
14359
14820
  let parsedValue = value;
14360
14821
  if (typeof value === "string") {
14361
- let a = reISO.exec(value);
14822
+ let a = ISO_DATE_REGEX.exec(value);
14362
14823
  if (a) parsedValue = new Date(value);
14363
14824
  else {
14364
- a = reMsAjax.exec(value);
14825
+ a = MS_AJAX_DATE_REGEX.exec(value);
14365
14826
  if (a) {
14366
- const b = takeOne(a, 1).split(/[-+,.]/);
14827
+ const b = takeOne(a, 1).split(new RegExp(String.raw`[-+,.]`, "u"));
14367
14828
  parsedValue = new Date(b[0] ? Number(b[0]) : 0 - Number(b[1]));
14368
14829
  }
14369
14830
  }
@@ -14375,11 +14836,14 @@ const jsonDateParse = (text) => JSON.parse(text, (_key, value) => {
14375
14836
  const mergeObjectsStrict = (...objects) => Object.assign({}, ...objects);
14376
14837
  //#endregion
14377
14838
  //#region src/util/regex/escapeRegExp.ts
14378
- const escapeRegExp = (string) => string.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
14839
+ const escapeRegExp = (string) => string.replaceAll(/[.*+?^${}()|[\]\\]/gu, String.raw`\$&`);
14379
14840
  //#endregion
14380
14841
  //#region src/util/text/capitalize.ts
14381
14842
  const capitalize = (string) => `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
14382
14843
  //#endregion
14844
+ //#region src/util/text/normalizeString.ts
14845
+ const normalizeString = (value) => value?.trim() ?? "";
14846
+ //#endregion
14383
14847
  //#region src/util/text/streamToText.ts
14384
14848
  const streamToText = async (readable) => {
14385
14849
  readable.setEncoding("utf8");
@@ -14389,7 +14853,7 @@ const streamToText = async (readable) => {
14389
14853
  };
14390
14854
  //#endregion
14391
14855
  //#region src/util/text/toKebabCase.ts
14392
- const toKebabCase = (string) => string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)?.map((x) => x.toLowerCase()).join("-") ?? "";
14856
+ const toKebabCase = (string) => string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/gu)?.map((x) => x.toLowerCase()).join("-") ?? "";
14393
14857
  //#endregion
14394
14858
  //#region src/util/text/truncate.ts
14395
14859
  const truncate = (string, length) => string.length > length ? `${string.slice(0, length)}..."` : string;
@@ -14421,14 +14885,14 @@ const now = () => {
14421
14885
  //#endregion
14422
14886
  //#region src/util/validation/exhaustiveGuard.ts
14423
14887
  const exhaustiveGuard = (value) => {
14424
- throw new InvalidOperationError(Operation.Read, exhaustiveGuard.name, JSON.stringify(value));
14888
+ throw new InvalidOperationError("Read", exhaustiveGuard.name, JSON.stringify(value));
14425
14889
  };
14426
14890
  //#endregion
14427
14891
  //#region src/util/id/uuid/constants.ts
14428
14892
  const NIL = "00000000-0000-0000-0000-000000000000";
14429
- const UUIDV4_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
14893
+ const UUIDV4_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/iu;
14430
14894
  //#endregion
14431
14895
  //#region src/util/id/uuid/uuidValidateV4.ts
14432
14896
  const uuidValidateV4 = (uuid) => UUIDV4_REGEX.test(uuid);
14433
14897
  //#endregion
14434
- export { AllSpecialValues, ForbiddenError, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, NIL, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, SURVEY_DISPLAY_NAME, Serializable, UUIDV4_REGEX, applyItemMetadataMixin, capitalize, createItemEntityTypeSchema, css, escapeRegExp, exhaustiveGuard, getIsServer, getMentions, getPropertyNames, getRawData, hrtime, html, isPlainObject, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, now, streamToText, takeOne, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4 };
14898
+ export { AllSpecialValues, ForbiddenError, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, NIL, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, SURVEY_DISPLAY_NAME, Serializable, UUIDV4_REGEX, applyItemMetadataMixin, capitalize, createItemEntityTypeSchema, css, escapeRegExp, exhaustiveGuard, getIsServer, getMentions, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, isPlainObject, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };