@mui/toolpad-utils
Advanced tools
Comparing version 0.1.15 to 0.1.16
@@ -13,3 +13,3 @@ export declare function asArray<T>(maybeArray: T | T[]): T[]; | ||
/** | ||
* Maps `obj` to a new object. The `mapper` function receices an entry array of jey and value and | ||
* Maps `obj` to a new object. The `mapper` function receives an entry array of key and value and | ||
* is allowed to manipulate both. It can also return `null` to omit a property from the result. | ||
@@ -16,0 +16,0 @@ */ |
@@ -9,3 +9,3 @@ import { | ||
mapValues | ||
} from "./chunk-4I25YBNA.js"; | ||
} from "./chunk-DP5G656E.js"; | ||
export { | ||
@@ -20,1 +20,2 @@ asArray, | ||
}; | ||
//# sourceMappingURL=collections.js.map |
@@ -0,1 +1,6 @@ | ||
declare global { | ||
interface Error { | ||
code?: unknown; | ||
} | ||
} | ||
export type PlainObject = Record<string, unknown>; | ||
@@ -2,0 +7,0 @@ export interface SerializedError extends PlainObject { |
import { | ||
hasOwnProperty | ||
} from "./chunk-4I25YBNA.js"; | ||
import { | ||
truncate | ||
} from "./chunk-E5XTMSD4.js"; | ||
// src/errors.ts | ||
function serializeError(error) { | ||
const { message, name, stack, code } = error; | ||
return { message, name, stack, code }; | ||
} | ||
function errorFrom(maybeError) { | ||
if (maybeError instanceof Error) { | ||
return maybeError; | ||
} | ||
if (typeof maybeError === "object" && maybeError && hasOwnProperty(maybeError, "message") && typeof maybeError.message === "string") { | ||
return new Error(maybeError.message, { cause: maybeError }); | ||
} | ||
if (typeof maybeError === "string") { | ||
return new Error(maybeError, { cause: maybeError }); | ||
} | ||
const message = truncate(JSON.stringify(maybeError), 500); | ||
return new Error(message, { cause: maybeError }); | ||
} | ||
errorFrom, | ||
serializeError | ||
} from "./chunk-22SQFP4C.js"; | ||
import "./chunk-DP5G656E.js"; | ||
import "./chunk-KHQ5PB5A.js"; | ||
export { | ||
@@ -30,1 +11,2 @@ errorFrom, | ||
}; | ||
//# sourceMappingURL=errors.js.map |
import { | ||
Emitter | ||
} from "./chunk-UL5SNADH.js"; | ||
} from "./chunk-P4EBKAZE.js"; | ||
export { | ||
Emitter | ||
}; | ||
//# sourceMappingURL=events.js.map |
import { | ||
useBoolean | ||
} from "../chunk-ASPYK2I2.js"; | ||
} from "../chunk-GNJHDIVW.js"; | ||
import { | ||
usePageTitle | ||
} from "../chunk-CZRFTYTR.js"; | ||
} from "../chunk-WKEABV4J.js"; | ||
export { | ||
@@ -11,1 +11,2 @@ useBoolean, | ||
}; | ||
//# sourceMappingURL=index.js.map |
import { | ||
useBoolean | ||
} from "../chunk-ASPYK2I2.js"; | ||
} from "../chunk-GNJHDIVW.js"; | ||
export { | ||
useBoolean as default | ||
}; | ||
//# sourceMappingURL=useBoolean.js.map |
import { | ||
usePageTitle | ||
} from "../chunk-CZRFTYTR.js"; | ||
} from "../chunk-WKEABV4J.js"; | ||
export { | ||
usePageTitle as default | ||
}; | ||
//# sourceMappingURL=usePageTitle.js.map |
@@ -9,1 +9,2 @@ // src/promises.ts | ||
}; | ||
//# sourceMappingURL=promises.js.map |
@@ -19,1 +19,6 @@ import * as React from 'react'; | ||
export declare function createProvidedContext<T>(name?: string): [() => T, React.ComponentType<React.ProviderProps<T>>]; | ||
export declare function useAssertedContext<T>(context: React.Context<T | undefined>): T; | ||
/** | ||
* Debugging tool that logs updates to props. | ||
*/ | ||
export declare function useTraceUpdates<P extends object>(prefix: string, props: P): void; |
import { | ||
Emitter | ||
} from "./chunk-UL5SNADH.js"; | ||
} from "./chunk-P4EBKAZE.js"; | ||
@@ -56,2 +56,24 @@ // src/react.tsx | ||
} | ||
function useAssertedContext(context) { | ||
const value = React.useContext(context); | ||
if (value === void 0) { | ||
throw new Error("context was used without a Provider"); | ||
} | ||
return value; | ||
} | ||
function useTraceUpdates(prefix, props) { | ||
const prev = React.useRef(props); | ||
React.useEffect(() => { | ||
const changedProps = {}; | ||
for (const key of Object.keys(props)) { | ||
if (!Object.is(prev.current[key], props[key])) { | ||
changedProps[key] = props[key]; | ||
} | ||
} | ||
if (Object.keys(changedProps).length > 0) { | ||
console.log(`${prefix} changed props:`, changedProps); | ||
} | ||
prev.current = props; | ||
}); | ||
} | ||
export { | ||
@@ -61,3 +83,6 @@ createGlobalState, | ||
interleave, | ||
useNonNullableContext | ||
useAssertedContext, | ||
useNonNullableContext, | ||
useTraceUpdates | ||
}; | ||
//# sourceMappingURL=react.js.map |
@@ -18,3 +18,3 @@ import { | ||
uncapitalize | ||
} from "./chunk-E5XTMSD4.js"; | ||
} from "./chunk-KHQ5PB5A.js"; | ||
export { | ||
@@ -38,1 +38,2 @@ camelCase, | ||
}; | ||
//# sourceMappingURL=strings.js.map |
{ | ||
"name": "@mui/toolpad-utils", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Build MUI apps quickly", | ||
@@ -56,3 +56,5 @@ "author": "MUI Toolpad team", | ||
"dependencies": { | ||
"react-is": "18.2.0" | ||
"react-is": "18.2.0", | ||
"yaml": "2.3.1", | ||
"yaml-diff-patch": "2.0.0" | ||
}, | ||
@@ -62,3 +64,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "1ca88be01a8dffd9a390ffde8c2a1b4164496b33" | ||
"gitHead": "ef8f76b53caebbd2f463555e77a0f4a15cdc834e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
136735
77
1611
4
2
+ Addedyaml@2.3.1
+ Addedyaml-diff-patch@2.0.0
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedfast-json-patch@3.1.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedoppa@0.4.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedyaml@2.3.1(transitive)
+ Addedyaml-diff-patch@2.0.0(transitive)