@mxfb/tools 0.3.0 → 1.0.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 (201) hide show
  1. package/agnostic/scrapers/@meteociel/index.d.ts +36 -0
  2. package/agnostic/scrapers/@meteociel/index.js +194 -0
  3. package/agnostic/scrapers/@meteociel/index.test.d.ts +1 -0
  4. package/agnostic/scrapers/@meteociel/locations/index.d.ts +11 -0
  5. package/agnostic/scrapers/@meteociel/locations/index.js +6 -0
  6. package/agnostic/scrapers/@meteociel/types.d.ts +1 -0
  7. package/agnostic/weather/types.d.ts +181 -0
  8. package/agnostic/weather/types.js +0 -0
  9. package/chunks/chunk-JQLUR5LO.js +12 -0
  10. package/components/Comp/index.d.ts +1 -1
  11. package/components/Comp/index.js +0 -0
  12. package/node/index.d.ts +1 -2
  13. package/node/index.js +0 -0
  14. package/package.json +45 -14
  15. package/agnostic/_WIP_tennis/index.d.ts +0 -2
  16. package/agnostic/_WIP_tennis/index.js +0 -62
  17. package/agnostic/arrays/index.d.ts +0 -11
  18. package/agnostic/arrays/is-array-of/index.d.ts +0 -5
  19. package/agnostic/arrays/is-array-of/index.js +0 -23
  20. package/agnostic/async/index.d.ts +0 -8
  21. package/agnostic/async/index.js +0 -20
  22. package/agnostic/async/timeout-call/index.d.ts +0 -1
  23. package/agnostic/async/timeout-call/index.js +0 -6
  24. package/agnostic/async/transitions/index.d.ts +0 -41
  25. package/agnostic/async/transitions/index.js +0 -7
  26. package/agnostic/async/wait/index.d.ts +0 -1
  27. package/agnostic/async/wait/index.js +0 -6
  28. package/agnostic/booleans/index.d.ts +0 -8
  29. package/agnostic/booleans/index.js +0 -17
  30. package/agnostic/booleans/is-falsy/index.d.ts +0 -7
  31. package/agnostic/booleans/is-falsy/index.js +0 -11
  32. package/agnostic/css/bem/BEM.d.ts +0 -29
  33. package/agnostic/css/bem/getNamesArr.d.ts +0 -2
  34. package/agnostic/css/bem/index.d.ts +0 -7
  35. package/agnostic/css/bem/index.js +0 -9
  36. package/agnostic/css/generate-nice-color/index.d.ts +0 -2
  37. package/agnostic/css/generate-nice-color/index.js +0 -8
  38. package/agnostic/css/index.d.ts +0 -14
  39. package/agnostic/css/index.js +0 -177
  40. package/agnostic/css/is-valid-css-class-name/index.d.ts +0 -2
  41. package/agnostic/css/is-valid-css-class-name/index.js +0 -8
  42. package/agnostic/css/styles-set/index.d.ts +0 -37
  43. package/agnostic/errors/index.d.ts +0 -30
  44. package/agnostic/errors/index.js +0 -6
  45. package/agnostic/html/get-node-ancestors/index.d.ts +0 -1
  46. package/agnostic/html/get-node-ancestors/index.js +0 -6
  47. package/agnostic/html/get-position-inside-parent/index.d.ts +0 -1
  48. package/agnostic/html/get-position-inside-parent/index.js +0 -6
  49. package/agnostic/html/index.d.ts +0 -17
  50. package/agnostic/html/index.js +0 -39
  51. package/agnostic/html/insert-node/index.d.ts +0 -2
  52. package/agnostic/html/insert-node/index.js +0 -6
  53. package/agnostic/html/placeholders/index.d.ts +0 -9
  54. package/agnostic/html/placeholders/index.js +0 -6
  55. package/agnostic/html/sanitize/index.d.ts +0 -24
  56. package/agnostic/html/sanitize/index.js +0 -9
  57. package/agnostic/html/selector-to-element/index.d.ts +0 -1
  58. package/agnostic/html/selector-to-element/index.js +0 -9
  59. package/agnostic/html/string-to-nodes/index.d.ts +0 -7
  60. package/agnostic/html/string-to-nodes/index.js +0 -10
  61. package/agnostic/index.d.ts +0 -4
  62. package/agnostic/misc/assert/index.d.ts +0 -5
  63. package/agnostic/misc/assert/index.js +0 -6
  64. package/agnostic/misc/cast/index.d.ts +0 -9
  65. package/agnostic/misc/cast/index.js +0 -8
  66. package/agnostic/misc/crossenv/index.d.ts +0 -13
  67. package/agnostic/misc/crossenv/index.js +0 -6
  68. package/agnostic/misc/elo/index.d.ts +0 -31
  69. package/agnostic/misc/elo/index.js +0 -6
  70. package/agnostic/misc/get-current-downlink/index.d.ts +0 -1
  71. package/agnostic/misc/get-current-downlink/index.js +0 -6
  72. package/agnostic/misc/index.d.ts +0 -6
  73. package/agnostic/misc/index.js +0 -16
  74. package/agnostic/misc/is-constructor-function/index.d.ts +0 -2
  75. package/agnostic/misc/is-constructor-function/index.js +0 -6
  76. package/agnostic/misc/is-nullish/index.d.ts +0 -4
  77. package/agnostic/misc/is-nullish/index.js +0 -10
  78. package/agnostic/misc/logs/index.d.ts +0 -55
  79. package/agnostic/misc/logs/index.js +0 -6
  80. package/agnostic/misc/random/index.d.ts +0 -10
  81. package/agnostic/misc/random/index.js +0 -6
  82. package/agnostic/misc/tennis/index.d.ts +0 -60
  83. package/agnostic/misc/tennis/index.js +0 -6
  84. package/agnostic/numbers/absolute-modulo/index.d.ts +0 -1
  85. package/agnostic/numbers/absolute-modulo/index.js +0 -6
  86. package/agnostic/numbers/clamp/index.d.ts +0 -1
  87. package/agnostic/numbers/clamp/index.js +0 -6
  88. package/agnostic/numbers/index.d.ts +0 -13
  89. package/agnostic/numbers/index.js +0 -30
  90. package/agnostic/numbers/interpolate/index.d.ts +0 -1
  91. package/agnostic/numbers/interpolate/index.js +0 -6
  92. package/agnostic/numbers/responsive-harmonics/index.d.ts +0 -10
  93. package/agnostic/numbers/responsive-harmonics/index.js +0 -9
  94. package/agnostic/numbers/round/index.d.ts +0 -1
  95. package/agnostic/numbers/round/index.js +0 -6
  96. package/agnostic/objects/enums/index.d.ts +0 -4
  97. package/agnostic/objects/enums/index.js +0 -7
  98. package/agnostic/objects/enums/is-in-enum/index.d.ts +0 -1
  99. package/agnostic/objects/enums/is-in-enum/index.js +0 -6
  100. package/agnostic/objects/flatten-getters/index.d.ts +0 -1
  101. package/agnostic/objects/flatten-getters/index.js +0 -9
  102. package/agnostic/objects/index.d.ts +0 -12
  103. package/agnostic/objects/index.js +0 -32
  104. package/agnostic/objects/is-object/index.d.ts +0 -1
  105. package/agnostic/objects/is-object/index.js +0 -6
  106. package/agnostic/objects/is-record/index.d.ts +0 -1
  107. package/agnostic/objects/is-record/index.js +0 -6
  108. package/agnostic/objects/record-format/index.d.ts +0 -11
  109. package/agnostic/objects/record-format/index.js +0 -16
  110. package/agnostic/objects/validation/index.d.ts +0 -3
  111. package/agnostic/objects/validation/index.js +0 -6
  112. package/agnostic/optim/index.d.ts +0 -7
  113. package/agnostic/optim/index.js +0 -18
  114. package/agnostic/optim/memoize/index.d.ts +0 -3
  115. package/agnostic/optim/memoize/index.js +0 -6
  116. package/agnostic/optim/throttle-debounce/index.d.ts +0 -30
  117. package/agnostic/optim/throttle-debounce/index.js +0 -8
  118. package/agnostic/optim/throttle-debounce/types.d.ts +0 -2
  119. package/agnostic/regexps/index.d.ts +0 -23
  120. package/agnostic/regexps/index.js +0 -89
  121. package/agnostic/strings/char-codes/index.d.ts +0 -17
  122. package/agnostic/strings/char-codes/index.js +0 -6
  123. package/agnostic/strings/index.d.ts +0 -14
  124. package/agnostic/strings/index.js +0 -32
  125. package/agnostic/strings/matches/index.d.ts +0 -3
  126. package/agnostic/strings/matches/index.js +0 -10
  127. package/agnostic/strings/normalize-indent/index.d.ts +0 -1
  128. package/agnostic/strings/normalize-indent/index.js +0 -6
  129. package/agnostic/strings/replace-all/index.d.ts +0 -1
  130. package/agnostic/strings/replace-all/index.js +0 -6
  131. package/agnostic/strings/to-alphanum/index.d.ts +0 -1
  132. package/agnostic/strings/to-alphanum/index.js +0 -6
  133. package/chunks/chunk-32IRF4OP.js +0 -9
  134. package/chunks/chunk-34U4HX4V.js +0 -73
  135. package/chunks/chunk-4GDNHUCZ.js +0 -162
  136. package/chunks/chunk-4QQBKBYH.js +0 -59
  137. package/chunks/chunk-4VC5PT5T.js +0 -13
  138. package/chunks/chunk-5LNUCDQ6.js +0 -132
  139. package/chunks/chunk-7AWTHZLY.js +0 -12
  140. package/chunks/chunk-7DBNMU6N.js +0 -14
  141. package/chunks/chunk-COVPTTAD.js +0 -10
  142. package/chunks/chunk-DNIOWD7K.js +0 -8
  143. package/chunks/chunk-DQNJQBC6.js +0 -10
  144. package/chunks/chunk-E6MSDKON.js +0 -13
  145. package/chunks/chunk-EDVNAV3G.js +0 -72
  146. package/chunks/chunk-EW46EXFB.js +0 -8
  147. package/chunks/chunk-FPEW3A27.js +0 -14
  148. package/chunks/chunk-GJOU3UAL.js +0 -36
  149. package/chunks/chunk-HC6ZOHCS.js +0 -14
  150. package/chunks/chunk-HGCG2J77.js +0 -122
  151. package/chunks/chunk-IFD7GSGK.js +0 -130
  152. package/chunks/chunk-JQXNEJAP.js +0 -18
  153. package/chunks/chunk-JWBDZPQG.js +0 -18
  154. package/chunks/chunk-K37RALUX.js +0 -8
  155. package/chunks/chunk-KIONYWA7.js +0 -168
  156. package/chunks/chunk-KQT5CTGF.js +0 -21
  157. package/chunks/chunk-LEXQ6E6L.js +0 -31
  158. package/chunks/chunk-LQFKUNVQ.js +0 -19
  159. package/chunks/chunk-MF56TTC5.js +0 -15
  160. package/chunks/chunk-MT74WIQR.js +0 -41
  161. package/chunks/chunk-NRITRUZW.js +0 -10
  162. package/chunks/chunk-NRJQKVQV.js +0 -31
  163. package/chunks/chunk-OSAXBA7G.js +0 -10
  164. package/chunks/chunk-PO3V3I57.js +0 -23
  165. package/chunks/chunk-QXAJXTXV.js +0 -19
  166. package/chunks/chunk-RCO57B6F.js +0 -9
  167. package/chunks/chunk-SQZGZ3VT.js +0 -15
  168. package/chunks/chunk-TTZHPIH7.js +0 -237
  169. package/chunks/chunk-UYTXXUU7.js +0 -54
  170. package/chunks/chunk-VTPRO4NJ.js +0 -10
  171. package/chunks/chunk-VYW4IADX.js +0 -35
  172. package/chunks/chunk-VZDUZTW6.js +0 -113
  173. package/chunks/chunk-W5A2TON3.js +0 -10
  174. package/chunks/chunk-W7YBGJ4H.js +0 -28
  175. package/chunks/chunk-WLL3FNVL.js +0 -40
  176. package/chunks/chunk-WOAYU6LB.js +0 -13
  177. package/chunks/chunk-XA4HVHJ4.js +0 -18
  178. package/chunks/chunk-XN3PZIVL.js +0 -38
  179. package/chunks/chunk-Y3OZHZUF.js +0 -237
  180. package/chunks/chunk-YDIBNEGA.js +0 -9
  181. package/chunks/chunk-ZC5RZBNY.js +0 -33
  182. package/components/index.d.ts +0 -1
  183. package/index.d.ts +0 -3
  184. package/node/files/index.d.ts +0 -9
  185. package/node/files/index.js +0 -21
  186. package/node/files/is-in-directory/index.d.ts +0 -1
  187. package/node/files/is-in-directory/index.js +0 -6
  188. package/node/files/read-write/index.d.ts +0 -9
  189. package/node/files/read-write/index.js +0 -6
  190. package/node/files/subpaths/index.d.ts +0 -34
  191. package/node/files/subpaths/index.js +0 -7
  192. package/node/image/index.d.ts +0 -9
  193. package/node/image/index.js +0 -74
  194. package/node/mxfb-cli-config/index.d.ts +0 -19
  195. package/node/mxfb-cli-config/index.js +0 -113
  196. package/node/process/index.d.ts +0 -8
  197. package/node/process/index.js +0 -20
  198. package/node/process/on-exit/index.d.ts +0 -5
  199. package/node/process/on-exit/index.js +0 -14
  200. package/shared/errors/index.d.ts +0 -138
  201. /package/{shared/index.d.ts → agnostic/scrapers/@meteociel/types.js} +0 -0
@@ -1,21 +0,0 @@
1
- import {
2
- Subpaths
3
- } from "../../chunks/chunk-HGCG2J77.js";
4
- import {
5
- isInDirectory
6
- } from "../../chunks/chunk-NRITRUZW.js";
7
- import {
8
- readWrite
9
- } from "../../chunks/chunk-7DBNMU6N.js";
10
- import "../../chunks/chunk-LQFKUNVQ.js";
11
-
12
- // src/node/files/index.ts
13
- var Files;
14
- ((Files2) => {
15
- Files2.isInDirectory = isInDirectory;
16
- Files2.readWrite = readWrite;
17
- Files2.Subpaths = Subpaths;
18
- })(Files || (Files = {}));
19
- export {
20
- Files
21
- };
@@ -1 +0,0 @@
1
- export declare function isInDirectory(childPath: string, parentPath: string): boolean;
@@ -1,6 +0,0 @@
1
- import {
2
- isInDirectory
3
- } from "../../../chunks/chunk-NRITRUZW.js";
4
- export {
5
- isInDirectory
6
- };
@@ -1,9 +0,0 @@
1
- import { promises as fs } from 'node:fs';
2
- type Path = Parameters<typeof fs.writeFile>[0];
3
- type ReadFileData = Awaited<ReturnType<typeof fs.readFile>>;
4
- type WriteFileData = Parameters<typeof fs.writeFile>[1];
5
- type ReadOptions = Parameters<typeof fs.readFile>[1];
6
- type WriteOptions = Parameters<typeof fs.writeFile>[2];
7
- export type ReadWriteEditorFunc = (curr: ReadFileData) => WriteFileData;
8
- export declare function readWrite(path: Path, editor: ReadWriteEditorFunc, ...options: [ReadOptions?, WriteOptions?]): Promise<string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | import("stream").Stream>;
9
- export {};
@@ -1,6 +0,0 @@
1
- import {
2
- readWrite
3
- } from "../../../chunks/chunk-7DBNMU6N.js";
4
- export {
5
- readWrite
6
- };
@@ -1,34 +0,0 @@
1
- import { Stats } from 'node:fs';
2
- export declare namespace Subpaths {
3
- export type ChildType = 'file' | 'directory' | 'symlink';
4
- export type ChildDetails = {
5
- type: ChildType;
6
- hidden: boolean;
7
- realPath: string;
8
- };
9
- export type ListContext = {
10
- depth?: number;
11
- lstats?: Stats | null;
12
- rootPath?: string | null;
13
- };
14
- export const defaultListContext: Required<ListContext>;
15
- export const fillListContext: (input: ListContext) => Required<ListContext>;
16
- export type ListOptions = {
17
- directories?: boolean;
18
- files?: boolean;
19
- symlinks?: boolean;
20
- hidden?: boolean;
21
- followSimlinks?: boolean;
22
- dedupeSimlinksContents?: boolean;
23
- maxDepth?: number;
24
- returnRelative?: boolean;
25
- exclude?: RegExp | string | (RegExp | string)[] | null;
26
- include?: RegExp | string | (RegExp | string)[] | null;
27
- filter?: ((path: string, details: ChildDetails) => boolean | Promise<boolean>);
28
- };
29
- export const defaultListOptions: Required<ListOptions>;
30
- export const fillOptions: (input: ListOptions) => Required<ListOptions>;
31
- export function list(...args: Parameters<typeof listAbsoluteSubpaths>): Promise<string[]>;
32
- function listAbsoluteSubpaths(inputPath: string, _options?: ListOptions, __private_context?: ListContext): Promise<string[]>;
33
- export {};
34
- }
@@ -1,7 +0,0 @@
1
- import {
2
- Subpaths
3
- } from "../../../chunks/chunk-HGCG2J77.js";
4
- import "../../../chunks/chunk-LQFKUNVQ.js";
5
- export {
6
- Subpaths
7
- };
@@ -1,9 +0,0 @@
1
- export declare function getImageColorsFromUrl(url: string): Promise<string[]>;
2
- export declare const compressorExtensions: {
3
- jpgExtensions: string[];
4
- pngExtensions: string[];
5
- webpExtensions: string[];
6
- avifExtensions: string[];
7
- heifExtensions: string[];
8
- };
9
- export declare function compressImages(src: string, preExtension: string, sizes?: number[], qualities?: number[] | number): Promise<void>;
@@ -1,74 +0,0 @@
1
- // src/node/image/index.ts
2
- import path from "node:path";
3
- import fetch from "node-fetch";
4
- import getColors from "get-image-colors";
5
- import fse from "fs-extra";
6
- import sharp from "sharp";
7
- async function getImageColorsFromUrl(url) {
8
- const data = await fetch(url);
9
- const blob = await data.blob();
10
- const arrayBuffer = await blob.arrayBuffer();
11
- const buffer = Buffer.from(arrayBuffer);
12
- const colors = await getColors(buffer, blob.type);
13
- const result = colors.map((color) => color.hex());
14
- return result;
15
- }
16
- var compressorExtensions = {
17
- jpgExtensions: [".jpg", ".jpeg"],
18
- pngExtensions: [".png"],
19
- webpExtensions: [".wepb"],
20
- avifExtensions: [".avif", ".avifs"],
21
- heifExtensions: [".heif", ".heifs", ".hif"]
22
- };
23
- async function compressImages(src, preExtension, sizes = [], qualities = 100) {
24
- if (!path.isAbsolute(src)) throw new Error("Source path must be absolute.");
25
- const files = await fse.readdir(src);
26
- const {
27
- jpgExtensions,
28
- pngExtensions,
29
- webpExtensions,
30
- avifExtensions,
31
- heifExtensions
32
- } = compressorExtensions;
33
- const allowedExtensions = [
34
- ...jpgExtensions,
35
- ...pngExtensions,
36
- ...webpExtensions,
37
- ...avifExtensions,
38
- ...heifExtensions
39
- ].flat();
40
- for (const file of files) {
41
- const filePath = path.join(src, file);
42
- const isDirectory = (await fse.stat(filePath)).isDirectory();
43
- if (isDirectory) continue;
44
- const ext = path.extname(file);
45
- const extIsAllowed = allowedExtensions.includes(ext.toLowerCase());
46
- if (!extIsAllowed) continue;
47
- const nameWithPreExt = file.replace(new RegExp(`${ext}$`), "");
48
- let matchedPreExt = nameWithPreExt.split(".").slice(1).slice(-1)[0] ?? "";
49
- const preExt = matchedPreExt === "" ? matchedPreExt : `.${matchedPreExt}`;
50
- if (preExt === preExtension) continue;
51
- const name = nameWithPreExt.replace(new RegExp(`${preExtension}$`), "");
52
- for (const sizePos in sizes) {
53
- const size = sizes[sizePos];
54
- const dstFile = `${name}.${size}${preExtension}${ext}`;
55
- const dstFilePath = path.join(src, dstFile);
56
- const quality = Array.isArray(qualities) ? qualities[sizePos] ?? qualities.slice(-1)[0] ?? 100 : qualities;
57
- const resized = sharp(filePath).withMetadata().resize(size, size, { fit: "inside", withoutEnlargement: true });
58
- if (jpgExtensions.includes(ext)) await resized.jpeg({ quality }).toFile(dstFilePath);
59
- if (pngExtensions.includes(ext)) await resized.png({ quality }).toFile(dstFilePath);
60
- if (webpExtensions.includes(ext)) await resized.webp({ quality }).toFile(dstFilePath);
61
- if (avifExtensions.includes(ext)) await resized.avif({ quality }).toFile(dstFilePath);
62
- if (heifExtensions.includes(ext)) await resized.heif({ quality }).toFile(dstFilePath);
63
- console.log(dstFilePath);
64
- console.log("size", size);
65
- console.log("quality", quality);
66
- console.log("poids", (await fse.stat(dstFilePath)).size);
67
- }
68
- }
69
- }
70
- export {
71
- compressImages,
72
- compressorExtensions,
73
- getImageColorsFromUrl
74
- };
@@ -1,19 +0,0 @@
1
- export type Config = {
2
- mxfb_projects_sync?: {
3
- lm_path?: string;
4
- mxfb_path?: string;
5
- };
6
- };
7
- export declare const emptyConfigObj: Config;
8
- export declare function createConfigFile(force?: boolean): Promise<true | Error>;
9
- declare const deletionSecurityPhrase = "THIS IS A DESTRUCTIVE AND DEFINITIVE ACTION";
10
- export declare function deleteConfigDir(security: typeof deletionSecurityPhrase): Promise<true | Error>;
11
- export declare function deleteConfigFile(security: typeof deletionSecurityPhrase): Promise<true | Error>;
12
- export declare function ensureConfigFile(): Promise<true | Error>;
13
- export declare function getConfigFile(): Promise<string | Error>;
14
- export declare function validateConfigObj(configObj: any): configObj is Config;
15
- export declare function parseConfigFile(fileContents: string): Config | Error;
16
- export declare function getConfig(create?: boolean): Promise<Config | Error>;
17
- export type ConfigUpdater = Partial<Config> | ((curr: Config) => Config);
18
- export declare function updateConfig(updater: ConfigUpdater, create?: boolean): Promise<true | Error>;
19
- export {};
@@ -1,113 +0,0 @@
1
- // src/node/mxfb-cli-config/index.ts
2
- import os from "node:os";
3
- import { promises as fs } from "node:fs";
4
- import path from "node:path";
5
- var homeDirPath = os.homedir();
6
- var mxfbConfigDirPath = path.join(homeDirPath, ".config/mxfb-cli");
7
- var mxfbConfigFilePath = path.join(mxfbConfigDirPath, "config.json");
8
- var emptyConfigObj = {};
9
- async function createConfigFile(force = false) {
10
- await fs.mkdir(mxfbConfigDirPath, { recursive: true });
11
- try {
12
- await fs.stat(mxfbConfigFilePath);
13
- if (force === true) throw "create anyway";
14
- return true;
15
- } catch (err) {
16
- try {
17
- await fs.writeFile(
18
- mxfbConfigFilePath,
19
- `${JSON.stringify(emptyConfigObj, null, 2)}
20
- `,
21
- { encoding: "utf-8" }
22
- );
23
- return true;
24
- } catch (err2) {
25
- if (err2 instanceof Error) return err2;
26
- if (typeof err2 === "string") return new Error(err2);
27
- return new Error(`${err2}`);
28
- }
29
- }
30
- }
31
- var deletionSecurityPhrase = "THIS IS A DESTRUCTIVE AND DEFINITIVE ACTION";
32
- async function deleteConfigDir(security) {
33
- if (security !== deletionSecurityPhrase) return new Error("You must provide the security phrase");
34
- await fs.rm(mxfbConfigDirPath, { recursive: true, force: true });
35
- return true;
36
- }
37
- async function deleteConfigFile(security) {
38
- if (security !== deletionSecurityPhrase) return new Error("You must provide the security phrase");
39
- await fs.rm(mxfbConfigDirPath);
40
- return true;
41
- }
42
- async function ensureConfigFile() {
43
- try {
44
- await fs.stat(mxfbConfigFilePath);
45
- return true;
46
- } catch (err) {
47
- try {
48
- const created = await createConfigFile();
49
- if (created instanceof Error) throw created;
50
- return true;
51
- } catch (err2) {
52
- if (err2 instanceof Error) return err2;
53
- if (typeof err2 === "string") return new Error(err2);
54
- return new Error(`${err2}`);
55
- }
56
- }
57
- }
58
- async function getConfigFile() {
59
- try {
60
- const fileContents = await fs.readFile(mxfbConfigFilePath, { encoding: "utf-8" });
61
- return fileContents;
62
- } catch (err) {
63
- if (err instanceof Error) return err;
64
- if (typeof err === "string") return new Error(err);
65
- return new Error(`${err}`);
66
- }
67
- }
68
- function validateConfigObj(configObj) {
69
- return true;
70
- }
71
- function parseConfigFile(fileContents) {
72
- try {
73
- const parsed = JSON.parse(fileContents);
74
- const validated = validateConfigObj(parsed);
75
- if (!validated) throw new Error(`Invalid config file shape: ${fileContents}`);
76
- return parsed;
77
- } catch (err) {
78
- if (err instanceof Error) return err;
79
- if (typeof err === "string") return new Error(err);
80
- return new Error(`${err}`);
81
- }
82
- }
83
- async function getConfig(create = false) {
84
- if (create) {
85
- const created = await ensureConfigFile();
86
- if (created !== true) return created;
87
- }
88
- const configStr = await getConfigFile();
89
- if (configStr instanceof Error) return configStr;
90
- const parsed = parseConfigFile(configStr);
91
- if (parsed instanceof Error) return parsed;
92
- return parsed;
93
- }
94
- async function updateConfig(updater, create = false) {
95
- const currentConfig = await getConfig(create);
96
- if (currentConfig instanceof Error) return currentConfig;
97
- const updatedConfig = typeof updater === "function" ? updater(currentConfig) : { ...currentConfig, ...updater };
98
- const stringified = JSON.stringify(updatedConfig, null, 2);
99
- await fs.writeFile(mxfbConfigFilePath, stringified, { encoding: "utf-8" });
100
- return true;
101
- }
102
- export {
103
- createConfigFile,
104
- deleteConfigDir,
105
- deleteConfigFile,
106
- emptyConfigObj,
107
- ensureConfigFile,
108
- getConfig,
109
- getConfigFile,
110
- parseConfigFile,
111
- updateConfig,
112
- validateConfigObj
113
- };
@@ -1,8 +0,0 @@
1
- import { beforeForcedExit as beforeForcedExitFunc, beforeExit as beforeExitFunc, onExit as onExitFunc, onAllExits as onAllExitsFunc } from './on-exit';
2
- export declare namespace Process {
3
- const forceExitEvents: string[];
4
- const beforeForcedExit: typeof beforeForcedExitFunc;
5
- const beforeExit: typeof beforeExitFunc;
6
- const onExit: typeof onExitFunc;
7
- const onAllExits: typeof onAllExitsFunc;
8
- }
@@ -1,20 +0,0 @@
1
- import {
2
- beforeExit,
3
- beforeForcedExit,
4
- forceExitEvents,
5
- onAllExits,
6
- onExit
7
- } from "../../chunks/chunk-LEXQ6E6L.js";
8
-
9
- // src/node/process/index.ts
10
- var Process;
11
- ((Process2) => {
12
- Process2.forceExitEvents = forceExitEvents;
13
- Process2.beforeForcedExit = beforeForcedExit;
14
- Process2.beforeExit = beforeExit;
15
- Process2.onExit = onExit;
16
- Process2.onAllExits = onAllExits;
17
- })(Process || (Process = {}));
18
- export {
19
- Process
20
- };
@@ -1,5 +0,0 @@
1
- export declare const forceExitEvents: string[];
2
- export declare function beforeForcedExit(callback: () => void | Promise<void>): void;
3
- export declare function beforeExit(callback: () => void | Promise<void>): void;
4
- export declare function onExit(callback: () => void | Promise<void>): void;
5
- export declare function onAllExits(callback: () => void | Promise<void>): void;
@@ -1,14 +0,0 @@
1
- import {
2
- beforeExit,
3
- beforeForcedExit,
4
- forceExitEvents,
5
- onAllExits,
6
- onExit
7
- } from "../../../chunks/chunk-LEXQ6E6L.js";
8
- export {
9
- beforeExit,
10
- beforeForcedExit,
11
- forceExitEvents,
12
- onAllExits,
13
- onExit
14
- };
@@ -1,138 +0,0 @@
1
- import { Errors } from '@design-edito/tools/agnostic/errors';
2
- export declare enum Codes {
3
- NO_DOCUMENT = "no-window-document-on-runtime",
4
- NO_DOCUMENT_PLEASE_PROVIDE = "no-window-document-on-runtime-please-provide",
5
- IMPOSSIBLE_TO_PICK_IN_ARRAY = "impossible-to-pick-in-array"
6
- }
7
- export declare const register: {
8
- getMessage: <Code extends Codes>(code: Code) => Errors.Register.Message<{
9
- "no-window-document-on-runtime": {
10
- message: string;
11
- detailsMaker: () => undefined;
12
- };
13
- "no-window-document-on-runtime-please-provide": {
14
- message: string;
15
- detailsMaker: (tips?: string) => string | undefined;
16
- };
17
- "impossible-to-pick-in-array": {
18
- message: string;
19
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
20
- };
21
- }, Code>;
22
- getDetailsMaker: <Code extends Codes>(code: Code) => Errors.Register.DetailsMaker<{
23
- "no-window-document-on-runtime": {
24
- message: string;
25
- detailsMaker: () => undefined;
26
- };
27
- "no-window-document-on-runtime-please-provide": {
28
- message: string;
29
- detailsMaker: (tips?: string) => string | undefined;
30
- };
31
- "impossible-to-pick-in-array": {
32
- message: string;
33
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
34
- };
35
- }, Code>;
36
- getDetails: <Code extends Codes>(code: Code, ...params: Parameters<Errors.Register.DetailsMaker<{
37
- "no-window-document-on-runtime": {
38
- message: string;
39
- detailsMaker: () => undefined;
40
- };
41
- "no-window-document-on-runtime-please-provide": {
42
- message: string;
43
- detailsMaker: (tips?: string) => string | undefined;
44
- };
45
- "impossible-to-pick-in-array": {
46
- message: string;
47
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
48
- };
49
- }, Code>>) => ReturnType<Errors.Register.DetailsMaker<{
50
- "no-window-document-on-runtime": {
51
- message: string;
52
- detailsMaker: () => undefined;
53
- };
54
- "no-window-document-on-runtime-please-provide": {
55
- message: string;
56
- detailsMaker: (tips?: string) => string | undefined;
57
- };
58
- "impossible-to-pick-in-array": {
59
- message: string;
60
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
61
- };
62
- }, Code>>;
63
- getErrorData: <Code extends Codes>(code: Code, ...params: Parameters<Errors.Register.DetailsMaker<{
64
- "no-window-document-on-runtime": {
65
- message: string;
66
- detailsMaker: () => undefined;
67
- };
68
- "no-window-document-on-runtime-please-provide": {
69
- message: string;
70
- detailsMaker: (tips?: string) => string | undefined;
71
- };
72
- "impossible-to-pick-in-array": {
73
- message: string;
74
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
75
- };
76
- }, Code>>) => Errors.Register.ErrorData<{
77
- "no-window-document-on-runtime": {
78
- message: string;
79
- detailsMaker: () => undefined;
80
- };
81
- "no-window-document-on-runtime-please-provide": {
82
- message: string;
83
- detailsMaker: (tips?: string) => string | undefined;
84
- };
85
- "impossible-to-pick-in-array": {
86
- message: string;
87
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
88
- };
89
- }, Code>;
90
- getError: <Code extends Codes>(code: Code, ...params: Parameters<Errors.Register.DetailsMaker<{
91
- "no-window-document-on-runtime": {
92
- message: string;
93
- detailsMaker: () => undefined;
94
- };
95
- "no-window-document-on-runtime-please-provide": {
96
- message: string;
97
- detailsMaker: (tips?: string) => string | undefined;
98
- };
99
- "impossible-to-pick-in-array": {
100
- message: string;
101
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
102
- };
103
- }, Code>>) => {
104
- code: Code;
105
- details: ReturnType<Errors.Register.DetailsMaker<{
106
- "no-window-document-on-runtime": {
107
- message: string;
108
- detailsMaker: () => undefined;
109
- };
110
- "no-window-document-on-runtime-please-provide": {
111
- message: string;
112
- detailsMaker: (tips?: string) => string | undefined;
113
- };
114
- "impossible-to-pick-in-array": {
115
- message: string;
116
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
117
- };
118
- }, Code>>;
119
- name: string;
120
- message: string;
121
- stack?: string;
122
- cause?: unknown;
123
- };
124
- source: {
125
- "no-window-document-on-runtime": {
126
- message: string;
127
- detailsMaker: () => undefined;
128
- };
129
- "no-window-document-on-runtime-please-provide": {
130
- message: string;
131
- detailsMaker: (tips?: string) => string | undefined;
132
- };
133
- "impossible-to-pick-in-array": {
134
- message: string;
135
- detailsMaker: (array: any[]) => "Array cannot be empty" | "Too many exclusions";
136
- };
137
- };
138
- };