cogsbox-state 0.5.443 → 0.5.444
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.
- package/dist/CogsState.d.ts.map +1 -1
- package/dist/CogsState.jsx +153 -149
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +11 -2
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -704,6 +704,8 @@ export const createCogsState = <State extends Record<StateKeys, unknown>>(
|
|
|
704
704
|
export function createCogsStateFromSync<TSchema extends CogsSyncSchema>(
|
|
705
705
|
syncSchema: TSchema
|
|
706
706
|
): CogsApi<TSchema> {
|
|
707
|
+
// The internal implementation doesn't need complex types.
|
|
708
|
+
// It just needs to provide the functions.
|
|
707
709
|
if (syncSchema.notifications) {
|
|
708
710
|
getGlobalStore
|
|
709
711
|
.getState()
|
|
@@ -716,8 +718,15 @@ export function createCogsStateFromSync<TSchema extends CogsSyncSchema>(
|
|
|
716
718
|
initialState[key] = schemas[key]?.schemas?.defaultValues || {};
|
|
717
719
|
}
|
|
718
720
|
|
|
719
|
-
//
|
|
720
|
-
|
|
721
|
+
// Get the real hook and options functions from your library
|
|
722
|
+
const { useCogsState, setCogsOptions } = createCogsState(initialState);
|
|
723
|
+
|
|
724
|
+
// Return the functions, casting the result to our perfect, explicit CogsApi type.
|
|
725
|
+
// This is the bridge between the untyped internals and the strongly-typed public API.
|
|
726
|
+
return {
|
|
727
|
+
useCogsState,
|
|
728
|
+
setCogsOptions,
|
|
729
|
+
} as CogsApi<TSchema>;
|
|
721
730
|
}
|
|
722
731
|
|
|
723
732
|
const {
|