@hellpig/anarchy-shared 1.4.5 → 1.5.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 (42) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/Constants/CssUnits.d.ts +7 -0
  3. package/dist/Constants/FallBackFonts.d.ts +1 -0
  4. package/dist/Constants/FileSizes.d.ts +11 -0
  5. package/dist/Constants/Json.d.ts +15 -0
  6. package/dist/Constants/index.d.ts +4 -0
  7. package/dist/Constants/index.es.js +6 -0
  8. package/dist/Constants/index.es.js.map +1 -0
  9. package/dist/Models/TBrowserInfo.d.ts +2 -0
  10. package/dist/Models/TDeferredPromise.d.ts +5 -0
  11. package/dist/Models/index.d.ts +2 -0
  12. package/dist/Models/index.es.js +2 -0
  13. package/dist/Models/index.es.js.map +1 -0
  14. package/dist/Plugins/EmitDefineVitePlugin.d.ts +7 -0
  15. package/dist/Plugins/index.d.ts +1 -0
  16. package/dist/Plugins/index.es.js +17 -0
  17. package/dist/Plugins/index.es.js.map +1 -0
  18. package/dist/Utils/ArrayUtils.d.ts +8 -0
  19. package/dist/Utils/AsyncUtils.d.ts +2 -0
  20. package/dist/Utils/CheckUtils.d.ts +6 -0
  21. package/dist/Utils/CssUtils.d.ts +5 -0
  22. package/dist/Utils/DetectUtils.d.ts +2 -0
  23. package/dist/Utils/EnvSchemaUtils.d.ts +2 -0
  24. package/dist/Utils/FileUtils.d.ts +3 -0
  25. package/dist/Utils/MapUtils.d.ts +3 -0
  26. package/dist/Utils/MathUtils.d.ts +1 -0
  27. package/dist/Utils/ObjectUtils.d.ts +9 -0
  28. package/dist/Utils/RxJsUtils.d.ts +2 -0
  29. package/dist/Utils/SanitizeUtils.d.ts +4 -0
  30. package/dist/Utils/StringUtils.d.ts +2 -0
  31. package/dist/Utils/TrackingUtils.d.ts +4 -0
  32. package/dist/Utils/TypesUtils.d.ts +28 -0
  33. package/dist/Utils/UrlUtils.d.ts +2 -0
  34. package/dist/Utils/WebGlUtils.d.ts +2 -0
  35. package/dist/Utils/index.d.ts +17 -0
  36. package/dist/Utils/index.es.js +3687 -0
  37. package/dist/Utils/index.es.js.map +1 -0
  38. package/dist/assets/_constants.scss +18 -0
  39. package/dist/assets/_utils.scss +6 -0
  40. package/dist/chunks/Json.js +57 -0
  41. package/dist/chunks/Json.js.map +1 -0
  42. package/package.json +27 -2
package/CHANGELOG.md CHANGED
@@ -3,3 +3,4 @@
3
3
  - 1.2.0 More Object utils
4
4
  - 1.3.0 Vite plugin: emit json
5
5
  - 1.4.0 Json validation utils
6
+ - 1.5.0 Added proper building and npm packaging
@@ -0,0 +1,7 @@
1
+ export declare enum CssUnits {
2
+ Px = "px",
3
+ Em = "em",
4
+ Rem = "rem",
5
+ Percent = "%",
6
+ Pt = "pt"
7
+ }
@@ -0,0 +1 @@
1
+ export declare const FallBackFonts: string;
@@ -0,0 +1,11 @@
1
+ export declare enum FileSizes {
2
+ Bytes = "Bytes",
3
+ KB = "KB",
4
+ MB = "MB",
5
+ GB = "GB",
6
+ TB = "TB",
7
+ PB = "PB",
8
+ EB = "EB",
9
+ ZB = "ZB",
10
+ YB = "YB"
11
+ }
@@ -0,0 +1,15 @@
1
+ export declare const DefaultBannedInJsonKeys: ReadonlyArray<string>;
2
+ export declare enum JsonSpecialCharactersAscii {
3
+ TAB = 9,
4
+ LF = 10,
5
+ CR = 13,
6
+ MAX_CONTROL = 31,
7
+ DEL = 127
8
+ }
9
+ export declare enum JsonSpecialCharactersUnicode {
10
+ BOM = 65279,
11
+ QUOTE = 34,
12
+ BACKSLASH = 92,
13
+ LINE_SEPARATOR = 8232,
14
+ PARAGRAPH_SEPARATOR = 8233
15
+ }
@@ -0,0 +1,4 @@
1
+ export * from './CssUnits';
2
+ export * from './FallBackFonts';
3
+ export * from './FileSizes';
4
+ export * from './Json';
@@ -0,0 +1,6 @@
1
+ export { C as CssUnits, D as DefaultBannedInJsonKeys, F as FileSizes, J as JsonSpecialCharactersAscii, a as JsonSpecialCharactersUnicode } from '../chunks/Json.js';
2
+
3
+ const FallBackFonts = 'system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif';
4
+
5
+ export { FallBackFonts };
6
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../src/Constants/FallBackFonts.ts"],"sourcesContent":["export const FallBackFonts: string = 'system-ui, -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif';\n"],"names":[],"mappings":";;AAAO,MAAM,aAAA,GAAwB;;;;"}
@@ -0,0 +1,2 @@
1
+ import { Parser } from 'bowser';
2
+ export type TBrowserInfo = Parser.ParsedResult;
@@ -0,0 +1,5 @@
1
+ export type TDeferredPromise<T> = Readonly<{
2
+ resolve: (value: T | PromiseLike<T>) => void;
3
+ reject: (reason?: any) => void;
4
+ promise: Promise<T>;
5
+ }>;
@@ -0,0 +1,2 @@
1
+ export type * from './TBrowserInfo';
2
+ export type * from './TDeferredPromise';
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { Plugin } from 'vite';
2
+ type TOpts = Readonly<{
3
+ value: Record<string, string>;
4
+ fileName: string;
5
+ }>;
6
+ export declare function emitDefineJson({ fileName, value }: TOpts): Plugin;
7
+ export {};
@@ -0,0 +1 @@
1
+ export * from './EmitDefineVitePlugin';
@@ -0,0 +1,17 @@
1
+ function emitDefineJson({ fileName, value }) {
2
+ return {
3
+ name: "emit-define-json",
4
+ apply: "build",
5
+ generateBundle() {
6
+ const out = value;
7
+ this.emitFile({
8
+ type: "asset",
9
+ fileName,
10
+ source: JSON.stringify(out, null, 2)
11
+ });
12
+ }
13
+ };
14
+ }
15
+
16
+ export { emitDefineJson };
17
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../src/Plugins/EmitDefineVitePlugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\ntype TOpts = Readonly<{\n value: Record<string, string>;\n fileName: string;\n}>;\n\nexport function emitDefineJson({ fileName, value }: TOpts): Plugin {\n return {\n name: 'emit-define-json',\n apply: 'build',\n generateBundle(): void {\n const out: Record<string, unknown> = value;\n\n this.emitFile({\n type: 'asset',\n fileName,\n source: JSON.stringify(out, null, 2)\n });\n }\n };\n}\n"],"names":[],"mappings":"AAOO,SAAS,cAAA,CAAe,EAAE,QAAA,EAAU,KAAA,EAAM,EAAkB;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,kBAAA;AAAA,IACN,KAAA,EAAO,OAAA;AAAA,IACP,cAAA,GAAuB;AACrB,MAAA,MAAM,GAAA,GAA+B,KAAA;AAErC,MAAA,IAAA,CAAK,QAAA,CAAS;AAAA,QACZ,IAAA,EAAM,OAAA;AAAA,QACN,QAAA;AAAA,QACA,MAAA,EAAQ,IAAA,CAAK,SAAA,CAAU,GAAA,EAAK,MAAM,CAAC;AAAA,OACpC,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,8 @@
1
+ export declare function omitInArray<T>(array: ReadonlyArray<T>, item: T): ReadonlyArray<T>;
2
+ export declare function forEachEnum<T extends Record<string | number, string | number>>(enumType: T, callback: (value: number | string, key: number | string, index: number) => void): void;
3
+ export declare function removeDuplicates<T extends {
4
+ id: string;
5
+ }>(array: ReadonlyArray<T>): ReadonlyArray<T>;
6
+ export declare const removeDuplicatesStr: (arr: ReadonlyArray<string>) => ReadonlyArray<string>;
7
+ export declare function asRecord<T, K extends keyof T, V extends string | number | symbol = T[K] & (string | number | symbol)>(key: K, list: ReadonlyArray<T>): Record<V, T>;
8
+ export declare function findDuplicateString(arr: ReadonlyArray<string>): string | undefined;
@@ -0,0 +1,2 @@
1
+ import { TDeferredPromise } from '../Models';
2
+ export declare function createDeferredPromise<T>(): TDeferredPromise<T>;
@@ -0,0 +1,6 @@
1
+ export declare const isDefined: <T>(value: T | undefined | null) => value is T;
2
+ export declare const isAllDefined: <T>(values: ReadonlyArray<T | undefined | null>) => values is ReadonlyArray<T>;
3
+ export declare const isNotDefined: <T>(value: T | undefined | null) => value is undefined | null;
4
+ export declare const isAllNotDefined: <T>(values: ReadonlyArray<T | undefined | null>) => values is ReadonlyArray<undefined | null>;
5
+ export declare const isString: (value: unknown) => value is string;
6
+ export declare const isBoolean: (value: unknown) => value is boolean;
@@ -0,0 +1,5 @@
1
+ export declare function getBaseTextSize(): number;
2
+ export declare function toPx(value: string | number | undefined): string;
3
+ export declare function toRem(value: string | number | undefined): string;
4
+ export declare const stripUnits: (value: string) => number;
5
+ export declare function getUnitsFromCssValue(value: string): string;
@@ -0,0 +1,2 @@
1
+ import { TBrowserInfo } from '../Models';
2
+ export declare const getBrowserInfo: () => TBrowserInfo;
@@ -0,0 +1,2 @@
1
+ export declare const toBool: import('valibot').SchemaWithPipe<readonly [import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, boolean>]>;
2
+ export declare const toInt: import('valibot').SchemaWithPipe<readonly [import('valibot').StringSchema<undefined>, import('valibot').TransformAction<string, number>]>;
@@ -0,0 +1,3 @@
1
+ export declare function getHumanReadableMemorySize(bytes: number, decimals?: number): string;
2
+ export declare function getFileExtension(name: string): string | undefined;
3
+ export declare const toPosix: (s: string) => string;
@@ -0,0 +1,3 @@
1
+ export declare function findInMap<K, V>(map: Map<K, V>, cb: (value: V, key: K) => boolean): V | undefined;
2
+ export declare function findKeyInMap<K, V>(map: Map<K, V>, cb: (value: V, key: K) => boolean): K | undefined;
3
+ export declare function findKeyWithValue<K, V>(map: Map<K, V>, value: V): K | undefined;
@@ -0,0 +1 @@
1
+ export declare function clamp(val: number, minimum: number, maximum: number): number;
@@ -0,0 +1,9 @@
1
+ import { TDeepPartial } from './TypesUtils';
2
+ export declare function cleanObject<T extends Record<string, unknown>>(obj: T): void;
3
+ export declare function isObject(obj: unknown, shouldAllowCustomObjects?: boolean): obj is Record<string, unknown>;
4
+ export declare const isEmptyObject: (obj: Record<string, unknown>) => boolean;
5
+ export declare const omitInObjectWithoutMutation: <T extends Readonly<Record<string, unknown>>, K extends keyof T>(obj: T, keys: ReadonlyArray<K>) => Omit<T, K>;
6
+ export declare const omitInObjectWithMutation: <T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: ReadonlyArray<K>) => Omit<T, K>;
7
+ export declare function filterOutEmptyFields<T extends Record<string, unknown> | ReadonlyArray<unknown>>(item: T): T;
8
+ export declare function filterOutEmptyFieldsRecursive<T extends Record<string, unknown> | ReadonlyArray<unknown>>(input: T): T;
9
+ export declare function patchObject<T extends Record<string, any>>(base: T, patch?: TDeepPartial<T>): T;
@@ -0,0 +1,2 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare const toObservable$: <T>(x: T | Observable<T>) => Observable<T>;
@@ -0,0 +1,4 @@
1
+ export declare function validateJson<T = unknown>(json: string, dangerousKeys?: ReadonlyArray<string>, options?: Readonly<{
2
+ maxBytes?: number;
3
+ maxDepth?: number;
4
+ }>): T;
@@ -0,0 +1,2 @@
1
+ export declare function camelToKebab(str: string): string;
2
+ export declare function kebabToCamel(input: string): string;
@@ -0,0 +1,4 @@
1
+ export declare function parseDistName(distName: string | undefined | null): Readonly<{
2
+ platform: string;
3
+ arch: string;
4
+ }>;
@@ -0,0 +1,28 @@
1
+ export type TWriteable<T> = {
2
+ -readonly [P in keyof T]: T[P];
3
+ };
4
+ export type TDeepWriteable<T> = {
5
+ -readonly [P in keyof T]: TDeepWriteable<T[P]>;
6
+ };
7
+ export type TOptional<T> = {
8
+ [P in keyof T]?: T[P];
9
+ };
10
+ export type TWithNull<T> = {
11
+ [P in keyof T]: T[P] | null;
12
+ };
13
+ export type TWithUndefined<T> = {
14
+ [P in keyof T]: T[P] | undefined;
15
+ };
16
+ export type TWithoutNull<T> = {
17
+ [K in keyof T]: Exclude<T[K], null> extends never ? undefined : Exclude<T[K], null> | undefined;
18
+ };
19
+ export type TWithMandatoryField<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
20
+ export type TValueOf<T> = T[keyof T];
21
+ export type TNullToUndefined<T> = {
22
+ [K in keyof T]: T[K] extends null ? undefined : T[K] extends null | infer U ? U | undefined : T[K];
23
+ };
24
+ export declare function nullsToUndefined<T extends Record<string, any>>(obj: T): TNullToUndefined<T>;
25
+ export type TUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
26
+ export type TDeepPartial<T> = T extends ReadonlyArray<infer U> ? ReadonlyArray<TDeepPartial<U>> : T extends object ? {
27
+ readonly [K in keyof T]?: TDeepPartial<T[K]>;
28
+ } : T;
@@ -0,0 +1,2 @@
1
+ export declare const getQueryParams: (urlString?: string) => Readonly<Record<string, string>>;
2
+ export declare function buildPublicUrl(baseUrl: string, relPath: string): string;
@@ -0,0 +1,2 @@
1
+ export declare function isWebGLAvailable(): boolean;
2
+ export declare function isWebGL2Available(): boolean;
@@ -0,0 +1,17 @@
1
+ export * from './ArrayUtils';
2
+ export * from './AsyncUtils';
3
+ export * from './CheckUtils';
4
+ export * from './CssUtils';
5
+ export * from './DetectUtils';
6
+ export * from './EnvSchemaUtils';
7
+ export * from './FileUtils';
8
+ export * from './MapUtils';
9
+ export * from './MathUtils';
10
+ export * from './ObjectUtils';
11
+ export * from './RxJsUtils';
12
+ export * from './SanitizeUtils';
13
+ export * from './StringUtils';
14
+ export * from './TrackingUtils';
15
+ export * from './TypesUtils';
16
+ export * from './UrlUtils';
17
+ export * from './WebGlUtils';