@netlisian/softconfig 0.0.0-alpha-20251026130436 → 0.0.1

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.
@@ -236,11 +236,12 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
236
236
  };
237
237
  }>;
238
238
 
239
- declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overrides }: {
239
+ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overrides, value, }: {
240
240
  children: (softConfig: Config, softComponents: SoftComponents) => ReactNode;
241
241
  hardConfig: Config;
242
242
  softComponents: SoftComponents;
243
243
  overrides: Overrides;
244
+ value?: StoreApi<AppStore>;
244
245
  }) => react_jsx_runtime.JSX.Element;
245
246
 
246
247
  declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T) => T;
@@ -236,11 +236,12 @@ declare const createSoftConfigStore: (hardConfig?: Config, softComponents?: Soft
236
236
  };
237
237
  }>;
238
238
 
239
- declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overrides }: {
239
+ declare const SoftConfigProvider: ({ children, hardConfig, softComponents, overrides, value, }: {
240
240
  children: (softConfig: Config, softComponents: SoftComponents) => ReactNode;
241
241
  hardConfig: Config;
242
242
  softComponents: SoftComponents;
243
243
  overrides: Overrides;
244
+ value?: StoreApi<AppStore>;
244
245
  }) => react_jsx_runtime.JSX.Element;
245
246
 
246
247
  declare const createUseSoftConfig: () => <T>(selector: (state: AppStore) => T) => T;
@@ -312,10 +312,15 @@ var import_react2 = require("react");
312
312
  // src/puck/context/useStore.ts
313
313
  var import_react = require("react");
314
314
  var import_zustand = require("zustand");
315
- var appStoreContext = (0, import_react.createContext)(createSoftConfigStore());
315
+ var appStoreContext = (0, import_react.createContext)(null);
316
316
  var createUseSoftConfig = () => {
317
317
  return function useSoftConfig2(selector) {
318
318
  const context = (0, import_react.useContext)(appStoreContext);
319
+ if (!context) {
320
+ throw new Error(
321
+ "useSoftConfig must be used inside a SoftConfigProvider. Wrap your tree with <SoftConfigProvider value={store}>"
322
+ );
323
+ }
319
324
  return (0, import_zustand.useStore)(context, selector);
320
325
  };
321
326
  };
@@ -1899,9 +1904,14 @@ var SoftConfigProvider = ({
1899
1904
  children,
1900
1905
  hardConfig,
1901
1906
  softComponents,
1902
- overrides
1907
+ overrides,
1908
+ // optional externally created store instance. When provided, use that
1909
+ // instead of creating one internally. This enables:
1910
+ // const store = useMemo(() => createSoftConfigStore(), []);
1911
+ // <SoftConfigProvider value={store}>{children}</SoftConfigProvider>
1912
+ value
1903
1913
  }) => {
1904
- const store = (0, import_react5.useMemo)(
1914
+ const store = value != null ? value : (0, import_react5.useMemo)(
1905
1915
  () => createSoftConfigStore(hardConfig, softComponents, overrides),
1906
1916
  [hardConfig, softComponents, overrides]
1907
1917
  );
@@ -263,10 +263,15 @@ import { useEffect } from "react";
263
263
  // src/puck/context/useStore.ts
264
264
  import { createContext, useContext } from "react";
265
265
  import { useStore } from "zustand";
266
- var appStoreContext = createContext(createSoftConfigStore());
266
+ var appStoreContext = createContext(null);
267
267
  var createUseSoftConfig = () => {
268
268
  return function useSoftConfig2(selector) {
269
269
  const context = useContext(appStoreContext);
270
+ if (!context) {
271
+ throw new Error(
272
+ "useSoftConfig must be used inside a SoftConfigProvider. Wrap your tree with <SoftConfigProvider value={store}>"
273
+ );
274
+ }
270
275
  return useStore(context, selector);
271
276
  };
272
277
  };
@@ -1850,9 +1855,14 @@ var SoftConfigProvider = ({
1850
1855
  children,
1851
1856
  hardConfig,
1852
1857
  softComponents,
1853
- overrides
1858
+ overrides,
1859
+ // optional externally created store instance. When provided, use that
1860
+ // instead of creating one internally. This enables:
1861
+ // const store = useMemo(() => createSoftConfigStore(), []);
1862
+ // <SoftConfigProvider value={store}>{children}</SoftConfigProvider>
1863
+ value
1854
1864
  }) => {
1855
- const store = useMemo2(
1865
+ const store = value != null ? value : useMemo2(
1856
1866
  () => createSoftConfigStore(hardConfig, softComponents, overrides),
1857
1867
  [hardConfig, softComponents, overrides]
1858
1868
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlisian/softconfig",
3
- "version": "0.0.0-alpha-20251026130436",
3
+ "version": "0.0.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -11,17 +11,11 @@
11
11
  ],
12
12
  "exports": {
13
13
  ".": {
14
- "import": {
15
- "development": "./src/index.tsx",
16
- "default": "./dist/index.mjs"
17
- },
14
+ "import": "./dist/index.mjs",
18
15
  "require": "./dist/index.js"
19
16
  },
20
17
  "./puck": {
21
- "import": {
22
- "development": "./src/puck/index.tsx",
23
- "default": "./dist/puck/index.mjs"
24
- },
18
+ "import": "./dist/puck/index.mjs",
25
19
  "require": "./dist/puck/index.js"
26
20
  },
27
21
  "./styles.css": "./dist/index.css",