@netlisian/softconfig 0.0.0 → 0.0.2

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,10 @@ var SoftConfigProvider = ({
1899
1904
  children,
1900
1905
  hardConfig,
1901
1906
  softComponents,
1902
- overrides
1907
+ overrides,
1908
+ value
1903
1909
  }) => {
1904
- const store = (0, import_react5.useMemo)(
1910
+ const store = value != null ? value : (0, import_react5.useMemo)(
1905
1911
  () => createSoftConfigStore(hardConfig, softComponents, overrides),
1906
1912
  [hardConfig, softComponents, overrides]
1907
1913
  );
@@ -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,10 @@ var SoftConfigProvider = ({
1850
1855
  children,
1851
1856
  hardConfig,
1852
1857
  softComponents,
1853
- overrides
1858
+ overrides,
1859
+ value
1854
1860
  }) => {
1855
- const store = useMemo2(
1861
+ const store = value != null ? value : useMemo2(
1856
1862
  () => createSoftConfigStore(hardConfig, softComponents, overrides),
1857
1863
  [hardConfig, softComponents, overrides]
1858
1864
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlisian/softconfig",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -19,7 +19,8 @@
19
19
  "require": "./dist/puck/index.js"
20
20
  },
21
21
  "./styles.css": "./dist/index.css",
22
- "./dist/index.css": "./dist/index.css"
22
+ "./dist/index.css": "./dist/index.css",
23
+ "./puck/index.css": "./dist/puck/index.css"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@size-limit/esbuild": "^11.1.6",
@@ -36,16 +37,16 @@
36
37
  "@netlisian/eslint-config": "0.0.0",
37
38
  "@netlisian/tsconfig": "0.0.0"
38
39
  },
39
- "peerDependencies": {
40
- "@measured/puck": "0.20.x",
41
- "react": ">=18.0.0 <20.3.0"
42
- },
43
40
  "dependencies": {
44
41
  "classnames": "^2.5.1",
45
42
  "lucide-react": "^0.475.0",
46
43
  "uuid": "^11.0.0",
47
44
  "zustand": "^5.0.3"
48
45
  },
46
+ "peerDependencies": {
47
+ "@measured/puck": "0.20.x",
48
+ "react": ">=18.0.0 <20.3.0"
49
+ },
49
50
  "publishConfig": {
50
51
  "access": "public"
51
52
  },