@rg-dev/stdlib 1.0.56 → 1.0.58

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.
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/axios-helpers.ts
31
+ var axios_helpers_exports = {};
32
+ __export(axios_helpers_exports, {
33
+ VERSION: () => VERSION,
34
+ handleAxiosError: () => handleAxiosError
35
+ });
36
+ module.exports = __toCommonJS(axios_helpers_exports);
37
+ var import_axios = __toESM(require("axios"), 1);
38
+
39
+ // src/index.ts
40
+ var VERSION = "1";
41
+
42
+ // src/axios-helpers.ts
43
+ import_axios.default.defaults.validateStatus = (status) => status < 400;
44
+ function handleAxiosError(fnName, e) {
45
+ var _a, _b;
46
+ if (e instanceof import_axios.default.AxiosError) {
47
+ fnName || (fnName = "Axios Request");
48
+ let errorData = ((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.data) || "";
49
+ if (typeof errorData != "string") {
50
+ errorData = JSON.stringify(errorData);
51
+ }
52
+ const errorDetails = errorData.trim().slice(0, 300);
53
+ const msg = (e == null ? void 0 : e.message) || JSON.stringify(e);
54
+ const errorString = JSON.stringify({ error: msg, data: errorDetails, url: ((_b = e.config) == null ? void 0 : _b.url) || "" }, null, 2);
55
+ const err = new Error(`${fnName} failed: ${errorString}`);
56
+ err.stack = e.stack;
57
+ return err;
58
+ }
59
+ fnName || (fnName = "Function Error");
60
+ const nonAxiosError = String((e == null ? void 0 : e.message) || JSON.stringify(e)) || "Unknown Error";
61
+ const error = Error(`${fnName} failed: ${String(nonAxiosError)}`);
62
+ error.stack = e.stack;
63
+ return error;
64
+ }
@@ -0,0 +1,5 @@
1
+ export { VERSION } from './index.cjs';
2
+
3
+ declare function handleAxiosError(fnName: string, e: any): Error;
4
+
5
+ export { handleAxiosError };
@@ -0,0 +1,5 @@
1
+ export { VERSION } from './index.js';
2
+
3
+ declare function handleAxiosError(fnName: string, e: any): Error;
4
+
5
+ export { handleAxiosError };
@@ -0,0 +1,33 @@
1
+ // src/axios-helpers.ts
2
+ import axios from "axios";
3
+
4
+ // src/index.ts
5
+ var VERSION = "1";
6
+
7
+ // src/axios-helpers.ts
8
+ axios.defaults.validateStatus = (status) => status < 400;
9
+ function handleAxiosError(fnName, e) {
10
+ var _a, _b;
11
+ if (e instanceof axios.AxiosError) {
12
+ fnName || (fnName = "Axios Request");
13
+ let errorData = ((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.data) || "";
14
+ if (typeof errorData != "string") {
15
+ errorData = JSON.stringify(errorData);
16
+ }
17
+ const errorDetails = errorData.trim().slice(0, 300);
18
+ const msg = (e == null ? void 0 : e.message) || JSON.stringify(e);
19
+ const errorString = JSON.stringify({ error: msg, data: errorDetails, url: ((_b = e.config) == null ? void 0 : _b.url) || "" }, null, 2);
20
+ const err = new Error(`${fnName} failed: ${errorString}`);
21
+ err.stack = e.stack;
22
+ return err;
23
+ }
24
+ fnName || (fnName = "Function Error");
25
+ const nonAxiosError = String((e == null ? void 0 : e.message) || JSON.stringify(e)) || "Unknown Error";
26
+ const error = Error(`${fnName} failed: ${String(nonAxiosError)}`);
27
+ error.stack = e.stack;
28
+ return error;
29
+ }
30
+ export {
31
+ VERSION,
32
+ handleAxiosError
33
+ };
package/lib/index.d.cts CHANGED
@@ -3,5 +3,7 @@ import './node-env'
3
3
  import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
+ import './axios-helpers'
7
+ import './vite-helpers'
6
8
 
7
9
  export declare const VERSION:string
package/lib/index.d.ts CHANGED
@@ -3,5 +3,7 @@ import './node-env'
3
3
  import './common-env'
4
4
  import './node-download'
5
5
  import './trpc-helpers'
6
+ import './axios-helpers'
7
+ import './vite-helpers'
6
8
 
7
9
  export declare const VERSION:string
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/vite-helpers.ts
21
+ var vite_helpers_exports = {};
22
+ __export(vite_helpers_exports, {
23
+ VERSION: () => VERSION,
24
+ createViteMiddleware: () => createViteMiddleware
25
+ });
26
+ module.exports = __toCommonJS(vite_helpers_exports);
27
+
28
+ // src/index.ts
29
+ var VERSION = "1";
30
+
31
+ // src/common-env.ts
32
+ function isNonEmptyString(str) {
33
+ return typeof str == "string" && str.trim().length > 0;
34
+ }
35
+
36
+ // src/vite-helpers.ts
37
+ async function createViteMiddleware(rootPath, editHtmlFn) {
38
+ if (!isNonEmptyString(rootPath)) {
39
+ throw new Error("invalid rootPath");
40
+ }
41
+ console.log(`starting vite middleware in ${rootPath}`);
42
+ const vite = await require(Function(`return 'vite'`)()).createServer(
43
+ {
44
+ root: rootPath,
45
+ logLevel: "info",
46
+ server: {
47
+ middlewareMode: true,
48
+ watch: {
49
+ usePolling: true,
50
+ interval: 300
51
+ }
52
+ },
53
+ plugins: [
54
+ {
55
+ name: "html-base-url",
56
+ transformIndexHtml(html) {
57
+ return (editHtmlFn == null ? void 0 : editHtmlFn(html)) || html;
58
+ }
59
+ }
60
+ ]
61
+ }
62
+ );
63
+ return vite.middlewares;
64
+ }
@@ -0,0 +1,6 @@
1
+ import { Handler } from 'express';
2
+ export { VERSION } from './index.cjs';
3
+
4
+ declare function createViteMiddleware(rootPath: string, editHtmlFn?: (html: string) => string): Promise<Handler>;
5
+
6
+ export { createViteMiddleware };
@@ -0,0 +1,6 @@
1
+ import { Handler } from 'express';
2
+ export { VERSION } from './index.js';
3
+
4
+ declare function createViteMiddleware(rootPath: string, editHtmlFn?: (html: string) => string): Promise<Handler>;
5
+
6
+ export { createViteMiddleware };
@@ -0,0 +1,48 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/index.ts
9
+ var VERSION = "1";
10
+
11
+ // src/common-env.ts
12
+ function isNonEmptyString(str) {
13
+ return typeof str == "string" && str.trim().length > 0;
14
+ }
15
+
16
+ // src/vite-helpers.ts
17
+ async function createViteMiddleware(rootPath, editHtmlFn) {
18
+ if (!isNonEmptyString(rootPath)) {
19
+ throw new Error("invalid rootPath");
20
+ }
21
+ console.log(`starting vite middleware in ${rootPath}`);
22
+ const vite = await __require(Function(`return 'vite'`)()).createServer(
23
+ {
24
+ root: rootPath,
25
+ logLevel: "info",
26
+ server: {
27
+ middlewareMode: true,
28
+ watch: {
29
+ usePolling: true,
30
+ interval: 300
31
+ }
32
+ },
33
+ plugins: [
34
+ {
35
+ name: "html-base-url",
36
+ transformIndexHtml(html) {
37
+ return (editHtmlFn == null ? void 0 : editHtmlFn(html)) || html;
38
+ }
39
+ }
40
+ ]
41
+ }
42
+ );
43
+ return vite.middlewares;
44
+ }
45
+ export {
46
+ VERSION,
47
+ createViteMiddleware
48
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -28,6 +28,12 @@
28
28
  ],
29
29
  "lib/node-download": [
30
30
  "lib/node-download.d.ts"
31
+ ],
32
+ "lib/axios-helpers": [
33
+ "lib/axios-helpers.d.ts"
34
+ ],
35
+ "lib/vite-helpers": [
36
+ "lib/vite-helpers.d.ts"
31
37
  ]
32
38
  }
33
39
  },
@@ -38,6 +44,11 @@
38
44
  "import": "./lib/index.js",
39
45
  "require": "./lib/index.cjs",
40
46
  "types": "./lib/index.d.ts"
47
+ },
48
+ "./lib/axios-helpers": {
49
+ "import": "./lib/axios-helpers.js",
50
+ "require": "./lib/axios-helpers.cjs",
51
+ "types": "./lib/axios-helpers.d.ts"
41
52
  },
42
53
  "./lib/trpc-helpers": {
43
54
  "import": "./lib/trpc-helpers.js",
@@ -62,6 +73,11 @@
62
73
  "import": "./lib/node-download.js",
63
74
  "require": "./lib/node-download.cjs",
64
75
  "types": "./lib/node-download.d.ts"
76
+ },
77
+ "./lib/vite-helpers": {
78
+ "import": "./lib/vite-helpers.js",
79
+ "require": "./lib/vite-helpers.cjs",
80
+ "types": "./lib/vite-helpers.d.ts"
65
81
  }
66
82
  },
67
83
  "dependencies": {