@rg-dev/stdlib
Advanced tools
+113
-65
@@ -8,5 +8,2 @@ "use strict"; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __export = (target, all) => { | ||
@@ -34,61 +31,2 @@ for (var name in all) | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module2) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| return obj[property]; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } | ||
| module2.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module2.exports.ensureProperties = ensureProperties; | ||
| } | ||
| }); | ||
| // src/axios-helpers.ts | ||
@@ -106,4 +44,114 @@ var axios_helpers_exports = {}; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| // src/vendor/safe-json-stringify.mjs | ||
| function safeJsonStringify(data, replacer, space, opts) { | ||
| var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : []; | ||
| var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : []; | ||
| return JSON.stringify( | ||
| prepareObjForSerialization(data, redactedKeys, redactedPaths), | ||
| replacer, | ||
| space | ||
| ); | ||
| } | ||
| var MAX_DEPTH = 20; | ||
| var MAX_EDGES = 25e3; | ||
| var MIN_PRESERVED_DEPTH = 8; | ||
| var REPLACEMENT_NODE = "..."; | ||
| function isError(o) { | ||
| return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o)); | ||
| } | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function find(haystack, needle) { | ||
| for (var i = 0, len = haystack.length; i < len; i++) { | ||
| if (haystack[i] === needle) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isDescendent(paths, path) { | ||
| for (var i = 0, len = paths.length; i < len; i++) { | ||
| if (path.indexOf(paths[i]) === 0) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function shouldRedact(patterns, key) { | ||
| for (var i = 0, len = patterns.length; i < len; i++) { | ||
| if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase()) return true; | ||
| if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isArray(obj) { | ||
| return Object.prototype.toString.call(obj) === "[object Array]"; | ||
| } | ||
| function safelyGetProp(obj, prop) { | ||
| try { | ||
| return obj[prop]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| function prepareObjForSerialization(obj, redactedKeys, redactedPaths) { | ||
| var seen = []; | ||
| var edges = 0; | ||
| function visit(obj2, path) { | ||
| function edgesExceeded() { | ||
| return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES; | ||
| } | ||
| edges++; | ||
| if (path.length > MAX_DEPTH) return REPLACEMENT_NODE; | ||
| if (edgesExceeded()) return REPLACEMENT_NODE; | ||
| if (obj2 === null || typeof obj2 !== "object") return obj2; | ||
| if (find(seen, obj2)) return "[Circular]"; | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| edges--; | ||
| var fResult = visit(obj2.toJSON(), path); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| var er = isError(obj2); | ||
| if (er) { | ||
| edges--; | ||
| var eResult = visit({ name: obj2.name, message: obj2.message }, path); | ||
| seen.pop(); | ||
| return eResult; | ||
| } | ||
| if (isArray(obj2)) { | ||
| var aResult = []; | ||
| for (var i = 0, len = obj2.length; i < len; i++) { | ||
| if (edgesExceeded()) { | ||
| aResult.push(REPLACEMENT_NODE); | ||
| break; | ||
| } | ||
| aResult.push(visit(obj2[i], path.concat("[]"))); | ||
| } | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = {}; | ||
| try { | ||
| for (var prop in obj2) { | ||
| if (!Object.prototype.hasOwnProperty.call(obj2, prop)) continue; | ||
| if (isDescendent(redactedPaths, path.join(".")) && shouldRedact(redactedKeys, prop)) { | ||
| result[prop] = "[REDACTED]"; | ||
| continue; | ||
| } | ||
| if (edgesExceeded()) { | ||
| result[prop] = REPLACEMENT_NODE; | ||
| break; | ||
| } | ||
| result[prop] = visit(safelyGetProp(obj2, prop), path.concat(prop)); | ||
| } | ||
| } catch (e) { | ||
| } | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| return visit(obj, []); | ||
| } | ||
@@ -129,3 +177,3 @@ // src/axios-helpers.ts | ||
| fnName || (fnName = "Function Error"); | ||
| const nonAxiosError = String((e == null ? void 0 : e.message) || (0, import_safe_json_stringify.default)(e)) || "Unknown Error"; | ||
| const nonAxiosError = String((e == null ? void 0 : e.message) || safeJsonStringify(e)) || "Unknown Error"; | ||
| const error = Error(`${fnName} failed: ${String(nonAxiosError)}`); | ||
@@ -132,0 +180,0 @@ error.stack = e.stack; |
+109
-84
@@ -1,96 +0,121 @@ | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| // src/axios-helpers.ts | ||
| import axios from "axios"; | ||
| // src/index.ts | ||
| var VERSION = "1"; | ||
| // src/vendor/safe-json-stringify.mjs | ||
| function safeJsonStringify(data, replacer, space, opts) { | ||
| var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : []; | ||
| var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : []; | ||
| return JSON.stringify( | ||
| prepareObjForSerialization(data, redactedKeys, redactedPaths), | ||
| replacer, | ||
| space | ||
| ); | ||
| } | ||
| var MAX_DEPTH = 20; | ||
| var MAX_EDGES = 25e3; | ||
| var MIN_PRESERVED_DEPTH = 8; | ||
| var REPLACEMENT_NODE = "..."; | ||
| function isError(o) { | ||
| return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o)); | ||
| } | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function find(haystack, needle) { | ||
| for (var i = 0, len = haystack.length; i < len; i++) { | ||
| if (haystack[i] === needle) return true; | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| return false; | ||
| } | ||
| function isDescendent(paths, path) { | ||
| for (var i = 0, len = paths.length; i < len; i++) { | ||
| if (path.indexOf(paths[i]) === 0) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function shouldRedact(patterns, key) { | ||
| for (var i = 0, len = patterns.length; i < len; i++) { | ||
| if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase()) return true; | ||
| if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isArray(obj) { | ||
| return Object.prototype.toString.call(obj) === "[object Array]"; | ||
| } | ||
| function safelyGetProp(obj, prop) { | ||
| try { | ||
| return obj[prop]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| function prepareObjForSerialization(obj, redactedKeys, redactedPaths) { | ||
| var seen = []; | ||
| var edges = 0; | ||
| function visit(obj2, path) { | ||
| function edgesExceeded() { | ||
| return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| edges++; | ||
| if (path.length > MAX_DEPTH) return REPLACEMENT_NODE; | ||
| if (edgesExceeded()) return REPLACEMENT_NODE; | ||
| if (obj2 === null || typeof obj2 !== "object") return obj2; | ||
| if (find(seen, obj2)) return "[Circular]"; | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| edges--; | ||
| var fResult = visit(obj2.toJSON(), path); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| var er = isError(obj2); | ||
| if (er) { | ||
| edges--; | ||
| var eResult = visit({ name: obj2.name, message: obj2.message }, path); | ||
| seen.pop(); | ||
| return eResult; | ||
| } | ||
| if (isArray(obj2)) { | ||
| var aResult = []; | ||
| for (var i = 0, len = obj2.length; i < len; i++) { | ||
| if (edgesExceeded()) { | ||
| aResult.push(REPLACEMENT_NODE); | ||
| break; | ||
| } | ||
| aResult.push(visit(obj2[i], path.concat("[]"))); | ||
| } | ||
| return obj[property]; | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| var result = {}; | ||
| try { | ||
| for (var prop in obj2) { | ||
| if (!Object.prototype.hasOwnProperty.call(obj2, prop)) continue; | ||
| if (isDescendent(redactedPaths, path.join(".")) && shouldRedact(redactedKeys, prop)) { | ||
| result[prop] = "[REDACTED]"; | ||
| continue; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| if (edgesExceeded()) { | ||
| result[prop] = REPLACEMENT_NODE; | ||
| break; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| result[prop] = visit(safelyGetProp(obj2, prop), path.concat(prop)); | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } catch (e) { | ||
| } | ||
| module.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module.exports.ensureProperties = ensureProperties; | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| }); | ||
| return visit(obj, []); | ||
| } | ||
| // src/axios-helpers.ts | ||
| import axios from "axios"; | ||
| // src/index.ts | ||
| var VERSION = "1"; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| // src/axios-helpers.ts | ||
| axios.defaults.validateStatus = (status) => status < 400; | ||
@@ -114,3 +139,3 @@ function handleAxiosError(fnName, e) { | ||
| fnName || (fnName = "Function Error"); | ||
| const nonAxiosError = String((e == null ? void 0 : e.message) || (0, import_safe_json_stringify.default)(e)) || "Unknown Error"; | ||
| const nonAxiosError = String((e == null ? void 0 : e.message) || safeJsonStringify(e)) || "Unknown Error"; | ||
| const error = Error(`${fnName} failed: ${String(nonAxiosError)}`); | ||
@@ -117,0 +142,0 @@ error.stack = e.stack; |
+168
-74
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
@@ -7,5 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __typeError = (msg) => { | ||
| throw TypeError(msg); | ||
| }; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
@@ -23,5 +24,2 @@ var __spreadValues = (a, b) => { | ||
| }; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __export = (target, all) => { | ||
@@ -39,72 +37,9 @@ for (var name in all) | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); | ||
| var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); | ||
| var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); | ||
| var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module2) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| return obj[property]; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } | ||
| module2.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module2.exports.ensureProperties = ensureProperties; | ||
| } | ||
| }); | ||
| // src/common-env.ts | ||
@@ -125,6 +60,7 @@ var common_env_exports = {}; | ||
| joinURL: () => joinURL2, | ||
| lazyPromise: () => PLazy, | ||
| lazyValue: () => lazyValue, | ||
| promiseRetry: () => promiseRetry, | ||
| promiseWithTimeout: () => promiseWithTimeout, | ||
| safeJsonStringify: () => import_safe_json_stringify.default, | ||
| safeJsonStringify: () => safeJsonStringify, | ||
| sleep: () => sleep, | ||
@@ -279,4 +215,162 @@ useServer: () => useServer | ||
| // src/vendor/safe-json-stringify.mjs | ||
| function safeJsonStringify(data, replacer, space, opts) { | ||
| var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : []; | ||
| var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : []; | ||
| return JSON.stringify( | ||
| prepareObjForSerialization(data, redactedKeys, redactedPaths), | ||
| replacer, | ||
| space | ||
| ); | ||
| } | ||
| var MAX_DEPTH = 20; | ||
| var MAX_EDGES = 25e3; | ||
| var MIN_PRESERVED_DEPTH = 8; | ||
| var REPLACEMENT_NODE = "..."; | ||
| function isError(o) { | ||
| return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o)); | ||
| } | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function find(haystack, needle) { | ||
| for (var i = 0, len = haystack.length; i < len; i++) { | ||
| if (haystack[i] === needle) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isDescendent(paths, path) { | ||
| for (var i = 0, len = paths.length; i < len; i++) { | ||
| if (path.indexOf(paths[i]) === 0) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function shouldRedact(patterns, key) { | ||
| for (var i = 0, len = patterns.length; i < len; i++) { | ||
| if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase()) return true; | ||
| if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isArray(obj) { | ||
| return Object.prototype.toString.call(obj) === "[object Array]"; | ||
| } | ||
| function safelyGetProp(obj, prop) { | ||
| try { | ||
| return obj[prop]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| function prepareObjForSerialization(obj, redactedKeys, redactedPaths) { | ||
| var seen = []; | ||
| var edges = 0; | ||
| function visit(obj2, path) { | ||
| function edgesExceeded() { | ||
| return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES; | ||
| } | ||
| edges++; | ||
| if (path.length > MAX_DEPTH) return REPLACEMENT_NODE; | ||
| if (edgesExceeded()) return REPLACEMENT_NODE; | ||
| if (obj2 === null || typeof obj2 !== "object") return obj2; | ||
| if (find(seen, obj2)) return "[Circular]"; | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| edges--; | ||
| var fResult = visit(obj2.toJSON(), path); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| var er = isError(obj2); | ||
| if (er) { | ||
| edges--; | ||
| var eResult = visit({ name: obj2.name, message: obj2.message }, path); | ||
| seen.pop(); | ||
| return eResult; | ||
| } | ||
| if (isArray(obj2)) { | ||
| var aResult = []; | ||
| for (var i = 0, len = obj2.length; i < len; i++) { | ||
| if (edgesExceeded()) { | ||
| aResult.push(REPLACEMENT_NODE); | ||
| break; | ||
| } | ||
| aResult.push(visit(obj2[i], path.concat("[]"))); | ||
| } | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = {}; | ||
| try { | ||
| for (var prop in obj2) { | ||
| if (!Object.prototype.hasOwnProperty.call(obj2, prop)) continue; | ||
| if (isDescendent(redactedPaths, path.join(".")) && shouldRedact(redactedKeys, prop)) { | ||
| result[prop] = "[REDACTED]"; | ||
| continue; | ||
| } | ||
| if (edgesExceeded()) { | ||
| result[prop] = REPLACEMENT_NODE; | ||
| break; | ||
| } | ||
| result[prop] = visit(safelyGetProp(obj2, prop), path.concat(prop)); | ||
| } | ||
| } catch (e) { | ||
| } | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| return visit(obj, []); | ||
| } | ||
| // src/vendor/lazy-promise.js | ||
| var _executor, _promise; | ||
| var _PLazy = class _PLazy extends Promise { | ||
| constructor(executor) { | ||
| super((resolve) => { | ||
| resolve(); | ||
| }); | ||
| __privateAdd(this, _executor); | ||
| __privateAdd(this, _promise); | ||
| __privateSet(this, _executor, executor); | ||
| } | ||
| static from(function_) { | ||
| return new _PLazy((resolve) => { | ||
| resolve(function_()); | ||
| }); | ||
| } | ||
| static resolve(value) { | ||
| return new _PLazy((resolve) => { | ||
| resolve(value); | ||
| }); | ||
| } | ||
| static reject(error) { | ||
| return new _PLazy((resolve, reject) => { | ||
| reject(error); | ||
| }); | ||
| } | ||
| then(onFulfilled, onRejected) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).then(onFulfilled, onRejected); | ||
| } | ||
| catch(onRejected) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).catch(onRejected); | ||
| } | ||
| finally(onFinally) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).finally(onFinally); | ||
| } | ||
| }; | ||
| _executor = new WeakMap(); | ||
| _promise = new WeakMap(); | ||
| var PLazy = _PLazy; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| var Optional = class _Optional { | ||
@@ -283,0 +377,0 @@ constructor(value) { |
+37
-2
| export { VERSION } from './index.cjs'; | ||
| export { default as safeJsonStringify } from 'safe-json-stringify'; | ||
@@ -51,2 +50,38 @@ type Options = { | ||
| declare function safeJsonStringify( | ||
| value: any, | ||
| replacer?: ((this: any, key: string, value: any) => any) | undefined, | ||
| space?: string | number | undefined, | ||
| options?: { | ||
| redactedKeys?: Array<string | RegExp>; | ||
| redactedPaths?: string[]; | ||
| } | ||
| ): string; | ||
| /** | ||
| Create a lazy promise that defers execution until it's awaited or when `.then()`, `.catch()`, or `.finally()` is called. | ||
| */ | ||
| declare class PLazy<ValueType> extends Promise<ValueType> { // eslint-disable-line @typescript-eslint/naming-convention | ||
| /** | ||
| Create a `PLazy` promise from a promise-returning or async function. | ||
| @example | ||
| ``` | ||
| import PLazy from 'p-lazy'; | ||
| const lazyPromise = new PLazy(resolve => { | ||
| someHeavyOperation(resolve); | ||
| }); | ||
| // `someHeavyOperation` is not yet called | ||
| await doSomethingFun; | ||
| // `someHeavyOperation` is called | ||
| console.log(await lazyPromise); | ||
| ``` | ||
| */ | ||
| static from<ValueType>(function_: () => ValueType | PromiseLike<ValueType>): PLazy<ValueType>; | ||
| } | ||
| type MyFn<T extends Record<string, (...args: any[]) => any>> = { | ||
@@ -83,2 +118,2 @@ [K in keyof T]: (...args: Parameters<T[K]>) => void; | ||
| export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPost, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, joinURL, lazyValue, promiseRetry, promiseWithTimeout, sleep, useServer }; | ||
| export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPost, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, joinURL, PLazy as lazyPromise, lazyValue, promiseRetry, promiseWithTimeout, safeJsonStringify, sleep, useServer }; |
+37
-2
| export { VERSION } from './index.js'; | ||
| export { default as safeJsonStringify } from 'safe-json-stringify'; | ||
@@ -51,2 +50,38 @@ type Options = { | ||
| declare function safeJsonStringify( | ||
| value: any, | ||
| replacer?: ((this: any, key: string, value: any) => any) | undefined, | ||
| space?: string | number | undefined, | ||
| options?: { | ||
| redactedKeys?: Array<string | RegExp>; | ||
| redactedPaths?: string[]; | ||
| } | ||
| ): string; | ||
| /** | ||
| Create a lazy promise that defers execution until it's awaited or when `.then()`, `.catch()`, or `.finally()` is called. | ||
| */ | ||
| declare class PLazy<ValueType> extends Promise<ValueType> { // eslint-disable-line @typescript-eslint/naming-convention | ||
| /** | ||
| Create a `PLazy` promise from a promise-returning or async function. | ||
| @example | ||
| ``` | ||
| import PLazy from 'p-lazy'; | ||
| const lazyPromise = new PLazy(resolve => { | ||
| someHeavyOperation(resolve); | ||
| }); | ||
| // `someHeavyOperation` is not yet called | ||
| await doSomethingFun; | ||
| // `someHeavyOperation` is called | ||
| console.log(await lazyPromise); | ||
| ``` | ||
| */ | ||
| static from<ValueType>(function_: () => ValueType | PromiseLike<ValueType>): PLazy<ValueType>; | ||
| } | ||
| type MyFn<T extends Record<string, (...args: any[]) => any>> = { | ||
@@ -83,2 +118,2 @@ [K in keyof T]: (...args: Parameters<T[K]>) => void; | ||
| export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPost, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, joinURL, lazyValue, promiseRetry, promiseWithTimeout, sleep, useServer }; | ||
| export { type AsyncReturnType, type MaybeFunction, type MyFn, Optional, StringBuilder, catchInline, doSafe, fetchHelperJSON, fetchHelperPost, fetchHelperText, isNonEmptyString, isNumber, isRunningOnServer, joinURL, PLazy as lazyPromise, lazyValue, promiseRetry, promiseWithTimeout, safeJsonStringify, sleep, useServer }; |
+168
-85
@@ -1,9 +0,8 @@ | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
| var __typeError = (msg) => { | ||
| throw TypeError(msg); | ||
| }; | ||
| var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
@@ -21,82 +20,8 @@ var __spreadValues = (a, b) => { | ||
| }; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
| var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); | ||
| var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); | ||
| var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); | ||
| var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| return obj[property]; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } | ||
| module.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module.exports.ensureProperties = ensureProperties; | ||
| } | ||
| }); | ||
| // src/index.ts | ||
@@ -246,4 +171,162 @@ var VERSION = "1"; | ||
| // src/vendor/safe-json-stringify.mjs | ||
| function safeJsonStringify(data, replacer, space, opts) { | ||
| var redactedKeys = opts && opts.redactedKeys ? opts.redactedKeys : []; | ||
| var redactedPaths = opts && opts.redactedPaths ? opts.redactedPaths : []; | ||
| return JSON.stringify( | ||
| prepareObjForSerialization(data, redactedKeys, redactedPaths), | ||
| replacer, | ||
| space | ||
| ); | ||
| } | ||
| var MAX_DEPTH = 20; | ||
| var MAX_EDGES = 25e3; | ||
| var MIN_PRESERVED_DEPTH = 8; | ||
| var REPLACEMENT_NODE = "..."; | ||
| function isError(o) { | ||
| return o instanceof Error || /^\[object (Error|(Dom)?Exception)\]$/.test(Object.prototype.toString.call(o)); | ||
| } | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function find(haystack, needle) { | ||
| for (var i = 0, len = haystack.length; i < len; i++) { | ||
| if (haystack[i] === needle) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isDescendent(paths, path) { | ||
| for (var i = 0, len = paths.length; i < len; i++) { | ||
| if (path.indexOf(paths[i]) === 0) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function shouldRedact(patterns, key) { | ||
| for (var i = 0, len = patterns.length; i < len; i++) { | ||
| if (typeof patterns[i] === "string" && patterns[i].toLowerCase() === key.toLowerCase()) return true; | ||
| if (patterns[i] && typeof patterns[i].test === "function" && patterns[i].test(key)) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function isArray(obj) { | ||
| return Object.prototype.toString.call(obj) === "[object Array]"; | ||
| } | ||
| function safelyGetProp(obj, prop) { | ||
| try { | ||
| return obj[prop]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| function prepareObjForSerialization(obj, redactedKeys, redactedPaths) { | ||
| var seen = []; | ||
| var edges = 0; | ||
| function visit(obj2, path) { | ||
| function edgesExceeded() { | ||
| return path.length > MIN_PRESERVED_DEPTH && edges > MAX_EDGES; | ||
| } | ||
| edges++; | ||
| if (path.length > MAX_DEPTH) return REPLACEMENT_NODE; | ||
| if (edgesExceeded()) return REPLACEMENT_NODE; | ||
| if (obj2 === null || typeof obj2 !== "object") return obj2; | ||
| if (find(seen, obj2)) return "[Circular]"; | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| edges--; | ||
| var fResult = visit(obj2.toJSON(), path); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| var er = isError(obj2); | ||
| if (er) { | ||
| edges--; | ||
| var eResult = visit({ name: obj2.name, message: obj2.message }, path); | ||
| seen.pop(); | ||
| return eResult; | ||
| } | ||
| if (isArray(obj2)) { | ||
| var aResult = []; | ||
| for (var i = 0, len = obj2.length; i < len; i++) { | ||
| if (edgesExceeded()) { | ||
| aResult.push(REPLACEMENT_NODE); | ||
| break; | ||
| } | ||
| aResult.push(visit(obj2[i], path.concat("[]"))); | ||
| } | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = {}; | ||
| try { | ||
| for (var prop in obj2) { | ||
| if (!Object.prototype.hasOwnProperty.call(obj2, prop)) continue; | ||
| if (isDescendent(redactedPaths, path.join(".")) && shouldRedact(redactedKeys, prop)) { | ||
| result[prop] = "[REDACTED]"; | ||
| continue; | ||
| } | ||
| if (edgesExceeded()) { | ||
| result[prop] = REPLACEMENT_NODE; | ||
| break; | ||
| } | ||
| result[prop] = visit(safelyGetProp(obj2, prop), path.concat(prop)); | ||
| } | ||
| } catch (e) { | ||
| } | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| return visit(obj, []); | ||
| } | ||
| // src/vendor/lazy-promise.js | ||
| var _executor, _promise; | ||
| var _PLazy = class _PLazy extends Promise { | ||
| constructor(executor) { | ||
| super((resolve) => { | ||
| resolve(); | ||
| }); | ||
| __privateAdd(this, _executor); | ||
| __privateAdd(this, _promise); | ||
| __privateSet(this, _executor, executor); | ||
| } | ||
| static from(function_) { | ||
| return new _PLazy((resolve) => { | ||
| resolve(function_()); | ||
| }); | ||
| } | ||
| static resolve(value) { | ||
| return new _PLazy((resolve) => { | ||
| resolve(value); | ||
| }); | ||
| } | ||
| static reject(error) { | ||
| return new _PLazy((resolve, reject) => { | ||
| reject(error); | ||
| }); | ||
| } | ||
| then(onFulfilled, onRejected) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).then(onFulfilled, onRejected); | ||
| } | ||
| catch(onRejected) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).catch(onRejected); | ||
| } | ||
| finally(onFinally) { | ||
| var _a; | ||
| (_a = __privateGet(this, _promise)) != null ? _a : __privateSet(this, _promise, new Promise(__privateGet(this, _executor))); | ||
| return __privateGet(this, _promise).finally(onFinally); | ||
| } | ||
| }; | ||
| _executor = new WeakMap(); | ||
| _promise = new WeakMap(); | ||
| var PLazy = _PLazy; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| var Optional = class _Optional { | ||
@@ -374,3 +457,2 @@ constructor(value) { | ||
| } | ||
| var export_safeJsonStringify = import_safe_json_stringify.default; | ||
| export { | ||
@@ -389,8 +471,9 @@ Optional, | ||
| joinURL2 as joinURL, | ||
| PLazy as lazyPromise, | ||
| lazyValue, | ||
| promiseRetry, | ||
| promiseWithTimeout, | ||
| export_safeJsonStringify as safeJsonStringify, | ||
| safeJsonStringify, | ||
| sleep, | ||
| useServer | ||
| }; |
+30
-0
@@ -210,2 +210,3 @@ "use strict"; | ||
| VERSION: () => VERSION, | ||
| calculateSha256: () => calculateSha256, | ||
| checkCommandExistsOrThrow: () => checkCommandExistsOrThrow, | ||
@@ -220,2 +221,3 @@ checkIfDirExistsOrThrow: () => checkIfDirExistsOrThrow, | ||
| isWindows: () => isWindows, | ||
| md5FileSync: () => md5FileSync, | ||
| throwIfDirNotEmpty: () => throwIfDirNotEmpty, | ||
@@ -348,5 +350,11 @@ typedSystemArch: () => typedSystemArch | ||
| // src/node-env.ts | ||
| var import_fs = require("fs"); | ||
| // src/index.ts | ||
| var VERSION = "1"; | ||
| // src/node-env.ts | ||
| var import_crypto = __toESM(require("crypto"), 1); | ||
| // node_modules/env-paths/index.js | ||
@@ -409,2 +417,3 @@ var import_node_path = __toESM(require("path"), 1); | ||
| // src/node-env.ts | ||
| var import_crypto2 = require("crypto"); | ||
| function getEnvPaths(name, options) { | ||
@@ -513,1 +522,22 @@ return envPaths(name, options); | ||
| } | ||
| function calculateSha256(filePath) { | ||
| return new Promise( | ||
| (resolve, reject) => { | ||
| const hash = (0, import_crypto2.createHash)("sha256"); | ||
| const stream = (0, import_fs.createReadStream)(filePath); | ||
| stream.on("error", reject); | ||
| stream.on("data", (chunk) => hash.update(chunk)); | ||
| stream.on( | ||
| "end", | ||
| () => { | ||
| const digest = hash.digest("hex"); | ||
| resolve(digest); | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
| } | ||
| function md5FileSync(path3) { | ||
| const data = fs.readFileSync(path3); | ||
| return import_crypto.default.createHash("md5").update(data).digest("hex"); | ||
| } |
@@ -114,3 +114,5 @@ import { Response } from 'express'; | ||
| declare function isHaveRootPrivileges(): boolean; | ||
| declare function calculateSha256(filePath: string): Promise<string>; | ||
| declare function md5FileSync(path: string): string; | ||
| export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, throwIfDirNotEmpty, typedSystemArch }; | ||
| export { SSEClient, SSEResponse, type SystemArch, calculateSha256, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, md5FileSync, throwIfDirNotEmpty, typedSystemArch }; |
@@ -114,3 +114,5 @@ import { Response } from 'express'; | ||
| declare function isHaveRootPrivileges(): boolean; | ||
| declare function calculateSha256(filePath: string): Promise<string>; | ||
| declare function md5FileSync(path: string): string; | ||
| export { SSEClient, SSEResponse, type SystemArch, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, throwIfDirNotEmpty, typedSystemArch }; | ||
| export { SSEClient, SSEResponse, type SystemArch, calculateSha256, checkCommandExistsOrThrow, checkIfDirExistsOrThrow, checkIfFileExistsOrThrow, chmodPlusX, createTempDir, createTempFilePath, getEnvPaths, isHaveRootPrivileges, isWindows, md5FileSync, throwIfDirNotEmpty, typedSystemArch }; |
+30
-0
@@ -328,5 +328,11 @@ var __create = Object.create; | ||
| // src/node-env.ts | ||
| import { createReadStream } from "fs"; | ||
| // src/index.ts | ||
| var VERSION = "1"; | ||
| // src/node-env.ts | ||
| import crypto from "crypto"; | ||
| // node_modules/env-paths/index.js | ||
@@ -389,2 +395,3 @@ import path from "path"; | ||
| // src/node-env.ts | ||
| import { createHash } from "crypto"; | ||
| function getEnvPaths(name, options) { | ||
@@ -493,2 +500,23 @@ return envPaths(name, options); | ||
| } | ||
| function calculateSha256(filePath) { | ||
| return new Promise( | ||
| (resolve, reject) => { | ||
| const hash = createHash("sha256"); | ||
| const stream = createReadStream(filePath); | ||
| stream.on("error", reject); | ||
| stream.on("data", (chunk) => hash.update(chunk)); | ||
| stream.on( | ||
| "end", | ||
| () => { | ||
| const digest = hash.digest("hex"); | ||
| resolve(digest); | ||
| } | ||
| ); | ||
| } | ||
| ); | ||
| } | ||
| function md5FileSync(path3) { | ||
| const data = fs.readFileSync(path3); | ||
| return crypto.createHash("md5").update(data).digest("hex"); | ||
| } | ||
| export { | ||
@@ -498,2 +526,3 @@ SSEClient, | ||
| VERSION, | ||
| calculateSha256, | ||
| checkCommandExistsOrThrow, | ||
@@ -508,4 +537,5 @@ checkIfDirExistsOrThrow, | ||
| isWindows, | ||
| md5FileSync, | ||
| throwIfDirNotEmpty, | ||
| typedSystemArch | ||
| }; |
+0
-73
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __export = (target, all) => { | ||
@@ -23,71 +18,4 @@ for (var name in all) | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module2) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| return obj[property]; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } | ||
| module2.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module2.exports.ensureProperties = ensureProperties; | ||
| } | ||
| }); | ||
| // src/vite-helpers.ts | ||
@@ -105,3 +33,2 @@ var vite_helpers_exports = {}; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| function isNonEmptyString(str) { | ||
@@ -108,0 +35,0 @@ return typeof str == "string" && str.trim().length > 0; |
+0
-86
@@ -1,86 +0,1 @@ | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __commonJS = (cb, mod) => function __require() { | ||
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| // node_modules/safe-json-stringify/index.js | ||
| var require_safe_json_stringify = __commonJS({ | ||
| "node_modules/safe-json-stringify/index.js"(exports, module) { | ||
| "use strict"; | ||
| var hasProp = Object.prototype.hasOwnProperty; | ||
| function throwsMessage(err) { | ||
| return "[Throws: " + (err ? err.message : "?") + "]"; | ||
| } | ||
| function safeGetValueFromPropertyOnObject(obj, property) { | ||
| if (hasProp.call(obj, property)) { | ||
| try { | ||
| return obj[property]; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| return obj[property]; | ||
| } | ||
| function ensureProperties(obj) { | ||
| var seen = []; | ||
| function visit(obj2) { | ||
| if (obj2 === null || typeof obj2 !== "object") { | ||
| return obj2; | ||
| } | ||
| if (seen.indexOf(obj2) !== -1) { | ||
| return "[Circular]"; | ||
| } | ||
| seen.push(obj2); | ||
| if (typeof obj2.toJSON === "function") { | ||
| try { | ||
| var fResult = visit(obj2.toJSON()); | ||
| seen.pop(); | ||
| return fResult; | ||
| } catch (err) { | ||
| return throwsMessage(err); | ||
| } | ||
| } | ||
| if (Array.isArray(obj2)) { | ||
| var aResult = obj2.map(visit); | ||
| seen.pop(); | ||
| return aResult; | ||
| } | ||
| var result = Object.keys(obj2).reduce(function(result2, prop) { | ||
| result2[prop] = visit(safeGetValueFromPropertyOnObject(obj2, prop)); | ||
| return result2; | ||
| }, {}); | ||
| seen.pop(); | ||
| return result; | ||
| } | ||
| ; | ||
| return visit(obj); | ||
| } | ||
| module.exports = function(data, replacer, space) { | ||
| return JSON.stringify(ensureProperties(data), replacer, space); | ||
| }; | ||
| module.exports.ensureProperties = ensureProperties; | ||
| } | ||
| }); | ||
| // src/index.ts | ||
@@ -90,3 +5,2 @@ var VERSION = "1"; | ||
| // src/common-env.ts | ||
| var import_safe_json_stringify = __toESM(require_safe_json_stringify(), 1); | ||
| function isNonEmptyString(str) { | ||
@@ -93,0 +7,0 @@ return typeof str == "string" && str.trim().length > 0; |
+2
-4
| { | ||
| "name": "@rg-dev/stdlib", | ||
| "version": "1.0.64", | ||
| "version": "1.0.65", | ||
| "description": "", | ||
@@ -84,4 +84,3 @@ "scripts": { | ||
| "dependencies": { | ||
| "fs-extra": "^11.1.1", | ||
| "@types/safe-json-stringify": "^1.1.5" | ||
| "fs-extra": "^11.1.1" | ||
| }, | ||
@@ -92,3 +91,2 @@ "publishConfig": { | ||
| "devDependencies": { | ||
| "safe-json-stringify": "^1.2.0", | ||
| "@trpc/server": "^11.1.1", | ||
@@ -95,0 +93,0 @@ "@types/command-exists": "^1.2.3", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
618070
0.16%1
-50%16
-5.88%15528
0.42%11
22.22%- Removed
- Removed