@bravostudioai/react 0.1.28 → 0.1.30

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.
@@ -3,32 +3,76 @@ import { create } from "zustand";
3
3
 
4
4
  import { CONST_APPS_SERVICE_URL } from "../../constants";
5
5
 
6
- type EncoreState = {
6
+ /**
7
+ * Global state for the Encore runtime
8
+ *
9
+ * Manages app data, form inputs, authentication, and UI state across
10
+ * all Encore components in the application.
11
+ */
12
+ export type EncoreState = {
13
+ /** Current app definition loaded from Encore service */
7
14
  app: any;
15
+
16
+ /** Base URL for Encore service API requests */
8
17
  baseURL: string;
18
+
19
+ /** Authentication token with expiration and refresh capability */
9
20
  accessToken?: {
10
21
  expireAt: number;
11
22
  token: string;
12
23
  refreshToken: string;
13
24
  params: string;
14
25
  };
26
+
27
+ /** Currently loaded app ID */
15
28
  appId?: string;
29
+
30
+ /** Form input values organized by page ID, then by component ID */
16
31
  formInputs: Record<string, Record<string, any>>;
32
+
33
+ /** Currently loaded page ID */
17
34
  pageId?: string;
35
+
36
+ /** Component variant selections for stateful sets */
18
37
  statefulSetVariants: Record<string, string>;
19
- inputGroups: Record<string, string>; // Maps group name to active element name
38
+
39
+ /** Input group selections - maps group name to active element name */
40
+ inputGroups: Record<string, string>;
41
+
42
+ /** Asset lookup by ID (images, videos, etc.) */
20
43
  assetsById: Record<string, any>;
44
+
45
+ /** Font family names by font ID */
21
46
  fontsById: Record<string, string>;
47
+
48
+ /** Full font metadata by font ID */
22
49
  fontsByIdFull: Record<string, { family: string; postScriptName?: string }>;
23
50
 
51
+ /** Clear all form inputs across all pages */
24
52
  resetFormInputs: () => void;
53
+
54
+ /** Set authentication token */
25
55
  setAccessToken: (accessToken: EncoreState["accessToken"]) => void;
56
+
57
+ /** Set app definition and extract assets/fonts */
26
58
  setApp: (app: any) => void;
59
+
60
+ /** Set current app ID */
27
61
  setAppId: (appId: string) => void;
62
+
63
+ /** Set form input value for current page */
28
64
  setFormInputValue: (nodeId: string, value: any) => void;
65
+
66
+ /** Set current page ID */
29
67
  setPageId: (pageId: string) => void;
68
+
69
+ /** Set active variant for a stateful set component */
30
70
  setStatefulSetVariant: (statefulSetId: string, variant: string) => void;
71
+
72
+ /** Set active element for an input group */
31
73
  setInputGroupValue: (groupName: string, elementName: string) => void;
74
+
75
+ /** Set base URL for Encore service */
32
76
  setBaseURL: (baseURL: string) => void;
33
77
  };
34
78
 
@@ -126,4 +170,20 @@ const useEncoreState = create<EncoreState>((set) => ({
126
170
  setBaseURL: (baseURL) => set((state) => ({ ...state, baseURL })),
127
171
  }));
128
172
 
173
+ /**
174
+ * Global Zustand store for Encore runtime state
175
+ *
176
+ * Provides centralized state management for app data, form inputs,
177
+ * authentication, and UI state across all Encore components.
178
+ *
179
+ * @example
180
+ * // Access state in a component
181
+ * const app = useEncoreState((state) => state.app);
182
+ * const setFormValue = useEncoreState((state) => state.setFormInputValue);
183
+ *
184
+ * @example
185
+ * // Access state outside React components
186
+ * const currentApp = useEncoreState.getState().app;
187
+ * useEncoreState.getState().setAppId('01ABC123');
188
+ */
129
189
  export default useEncoreState;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = "0.1.28";
1
+ export const PACKAGE_VERSION = "0.1.30";