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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-state",
3
- "version": "0.5.443",
3
+ "version": "0.5.444",
4
4
  "description": "React state management library with form controls and server sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
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
- // The cast is fine because the exported function signature is what matters.
720
- return createCogsState(initialState) as any;
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 {