@resistdesign/voltra 3.0.0-alpha.48 → 3.0.0-alpha.49

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/app/index.d.ts CHANGED
@@ -8,14 +8,15 @@
8
8
  * ```ts
9
9
  * import {
10
10
  * createFormRenderer,
11
+ * getApplicationStateIdentifier,
11
12
  * useApplicationStateLoader,
12
- * useApplicationStateValueStructure,
13
+ * useApplicationStateValue,
13
14
  * type RemoteProcedureCall,
14
15
  * } from "@resistdesign/voltra/app";
15
16
  * ```
16
17
  *
17
- * @see {@link useApplicationStateValueStructure} and
18
- * {@link useApplicationStateLoader} for good starting points.
18
+ * @see {@link useApplicationStateValue} and {@link useApplicationStateLoader}
19
+ * for good starting points.
19
20
  *
20
21
  * Reference examples:
21
22
  * - `examples/README.md`
@@ -24,17 +25,22 @@
24
25
  * @example
25
26
  * ```tsx
26
27
  * import {
28
+ * getApplicationStateIdentifier,
27
29
  * useApplicationStateLoader,
28
- * useApplicationStateValueStructure,
30
+ * useApplicationStateValue,
29
31
  * type RemoteProcedureCall,
30
32
  * } from "@resistdesign/voltra/app";
31
33
  * import { useCallback } from "react";
32
34
  *
35
+ * const loginUsernameId = getApplicationStateIdentifier<string>();
36
+ * const loginPasswordId = getApplicationStateIdentifier<string>();
37
+ * const loginLoggedInId = getApplicationStateIdentifier<boolean>();
38
+ *
33
39
  * const APP_STATE_IDENTIFIERS = {
34
40
  * LOGIN: {
35
- * USERNAME: {},
36
- * PASSWORD: {},
37
- * LOGGED_IN: {},
41
+ * USERNAME: loginUsernameId,
42
+ * PASSWORD: loginPasswordId,
43
+ * LOGGED_IN: loginLoggedInId,
38
44
  * },
39
45
  * };
40
46
  *
@@ -52,27 +58,24 @@
52
58
  *
53
59
  * export const LoginController = () => {
54
60
  * const {
55
- * valueStructure: {
56
- * username: username = "",
57
- * password: password = "",
58
- * loggedIn: loggedIn = false,
59
- * },
60
- * onChangeStructure: {
61
- * username: setUsername,
62
- * password: setPassword,
63
- * loggedIn: setLoggedIn,
64
- * },
65
- * } = useApplicationStateValueStructure<{
66
- * username: string;
67
- * password: string;
68
- * loggedIn: boolean;
69
- * }>({
70
- * username: APP_STATE_IDENTIFIERS.LOGIN.USERNAME,
71
- * password: APP_STATE_IDENTIFIERS.LOGIN.PASSWORD,
72
- * loggedIn: APP_STATE_IDENTIFIERS.LOGIN.LOGGED_IN,
73
- * });
61
+ * value: username = "",
62
+ * onChange: setUsername,
63
+ * } = useApplicationStateValue(APP_STATE_IDENTIFIERS.LOGIN.USERNAME);
64
+ * const {
65
+ * value: password = "",
66
+ * onChange: setPassword,
67
+ * } = useApplicationStateValue(APP_STATE_IDENTIFIERS.LOGIN.PASSWORD);
68
+ * const {
69
+ * value: loggedIn = false,
70
+ * onChange: setLoggedIn,
71
+ * } = useApplicationStateValue(APP_STATE_IDENTIFIERS.LOGIN.LOGGED_IN);
74
72
  *
75
- * const { loading: loadingLogin, makeRemoteProcedureCall } =
73
+ * const {
74
+ * value: latestLoginState,
75
+ * modified: loginStateModified,
76
+ * loading: loadingLogin,
77
+ * makeRemoteProcedureCall,
78
+ * } =
76
79
  * useApplicationStateLoader({
77
80
  * identifier: APP_STATE_IDENTIFIERS.LOGIN.LOGGED_IN,
78
81
  * remoteProcedureCall: LOGIN_RPC,
@@ -83,7 +86,18 @@
83
86
  * makeRemoteProcedureCall(username, password);
84
87
  * }, [username, password, makeRemoteProcedureCall]);
85
88
  *
86
- * return { username, password, loggedIn, setUsername, setPassword, onSubmit, loadingLogin };
89
+ * return {
90
+ * username,
91
+ * password,
92
+ * loggedIn,
93
+ * latestLoginState,
94
+ * loginStateModified,
95
+ * setUsername,
96
+ * setPassword,
97
+ * setLoggedIn,
98
+ * onSubmit,
99
+ * loadingLogin,
100
+ * };
87
101
  * };
88
102
  * ```
89
103
  *
package/app/index.js CHANGED
@@ -5,21 +5,16 @@ import '../chunk-RUNXRISF.js';
5
5
  import '../chunk-3HVYVX3S.js';
6
6
  import { mergeStringPaths, PATH_DELIMITER } from '../chunk-2JDOM6PB.js';
7
7
  import '../chunk-I2KLQ2HA.js';
8
- import { createContext, useContext, useRef, useMemo, useCallback, useState, useEffect } from 'react';
8
+ import { createContext, useContext, useMemo, useCallback, useState, useRef, useEffect } from 'react';
9
9
  import { jsx } from 'react/jsx-runtime';
10
10
 
11
- var getApplicationStateIdentifier = (subStateIdMap) => subStateIdMap ? subStateIdMap : {};
11
+ function getApplicationStateIdentifier(subStateIdMap) {
12
+ return subStateIdMap ? subStateIdMap : {};
13
+ }
12
14
  var getApplicationStateModified = (identifier, modificationState) => !!modificationState.get(identifier);
13
15
  var getApplicationStateValue = (identifier, applicationState) => applicationState.get(identifier);
14
16
  var setApplicationStateModified = (identifier, value, modificationState) => new Map(modificationState).set(identifier, value);
15
17
  var setApplicationStateValue = (identifier, value, applicationState) => new Map(applicationState).set(identifier, value);
16
- var getApplicationStateValueStructure = (idStructure, applicationState) => Object.keys(idStructure).reduce(
17
- (acc, k) => ({
18
- ...acc,
19
- [k]: getApplicationStateValue(idStructure[k], applicationState)
20
- }),
21
- {}
22
- );
23
18
  var ApplicationStateContext = createContext({
24
19
  modified: /* @__PURE__ */ new Map(),
25
20
  value: /* @__PURE__ */ new Map(),
@@ -36,10 +31,6 @@ var useApplicationStateValue = (identifier) => {
36
31
  onChange: setApplicationState,
37
32
  setModified: setModificationState
38
33
  } = useContext(ApplicationStateContext);
39
- const appStateRef = useRef(applicationState);
40
- appStateRef.current = applicationState;
41
- const modificationStateRef = useRef(modificationState);
42
- modificationStateRef.current = modificationState;
43
34
  const modified = useMemo(
44
35
  () => getApplicationStateModified(identifier, modificationState),
45
36
  [identifier, modificationState]
@@ -51,23 +42,30 @@ var useApplicationStateValue = (identifier) => {
51
42
  const setModified = useCallback(
52
43
  (isModified) => {
53
44
  setModificationState(
54
- setApplicationStateModified(
55
- identifier,
56
- isModified,
57
- modificationStateRef.current
58
- )
45
+ (previousModified) => setApplicationStateModified(identifier, isModified, previousModified)
59
46
  );
60
47
  },
61
48
  [identifier, setModificationState]
62
49
  );
63
50
  const onChange = useCallback(
64
51
  (newValue) => {
65
- setApplicationState(
66
- setApplicationStateValue(identifier, newValue, appStateRef.current)
52
+ setApplicationState((previousState) => {
53
+ const previousValue = getApplicationStateValue(
54
+ identifier,
55
+ previousState
56
+ );
57
+ const resolvedValue = typeof newValue === "function" ? newValue(previousValue) : newValue;
58
+ return setApplicationStateValue(
59
+ identifier,
60
+ resolvedValue,
61
+ previousState
62
+ );
63
+ });
64
+ setModificationState(
65
+ (previousModified) => setApplicationStateModified(identifier, true, previousModified)
67
66
  );
68
- setModified(true);
69
67
  },
70
- [identifier, setApplicationState]
68
+ [identifier, setApplicationState, setModificationState]
71
69
  );
72
70
  const controller = useMemo(
73
71
  () => ({
@@ -80,41 +78,6 @@ var useApplicationStateValue = (identifier) => {
80
78
  );
81
79
  return controller;
82
80
  };
83
- var useApplicationStateValueStructure = (idStructure) => {
84
- const { value: applicationState, onChange: setApplicationState } = useContext(
85
- ApplicationStateContext
86
- );
87
- const valueStructure = useMemo(
88
- () => getApplicationStateValueStructure(idStructure, applicationState),
89
- [applicationState, idStructure]
90
- );
91
- const onChangeStructure = useMemo(
92
- () => Object.keys(idStructure).reduce(
93
- (acc, k) => ({
94
- ...acc,
95
- [k]: (newValue) => {
96
- setApplicationState(
97
- setApplicationStateValue(
98
- idStructure[k],
99
- newValue,
100
- applicationState
101
- )
102
- );
103
- }
104
- }),
105
- {}
106
- ),
107
- [applicationState, idStructure, setApplicationState]
108
- );
109
- const controller = useMemo(
110
- () => ({
111
- valueStructure,
112
- onChangeStructure
113
- }),
114
- [onChangeStructure, valueStructure]
115
- );
116
- return controller;
117
- };
118
81
  var ApplicationStateProvider = ({
119
82
  children
120
83
  }) => {
@@ -200,13 +163,14 @@ var useApplicationStateLoader = (config) => {
200
163
  const [cacheValidity, setCacheValidity] = useState({});
201
164
  const [loading, setLoading] = useState(false);
202
165
  const [latestError, setLatestError] = useState();
203
- const { onChange, setModified } = useApplicationStateValue(identifier);
166
+ const valueController = useApplicationStateValue(identifier);
167
+ const { onChange, setModified } = valueController;
204
168
  const invalidate = useCallback(() => {
205
169
  setCacheValidity({});
206
170
  }, []);
207
171
  const makeRemoteProcedureCall = useCallback(
208
172
  async (...directArgs) => {
209
- let success;
173
+ let success = false;
210
174
  setLoading(true);
211
175
  setLatestError(void 0);
212
176
  try {
@@ -234,12 +198,13 @@ var useApplicationStateLoader = (config) => {
234
198
  );
235
199
  const appStateLoader = useMemo(
236
200
  () => ({
201
+ ...valueController,
237
202
  loading,
238
203
  latestError,
239
204
  invalidate,
240
205
  makeRemoteProcedureCall
241
206
  }),
242
- [loading, latestError, invalidate, makeRemoteProcedureCall]
207
+ [valueController, loading, latestError, invalidate, makeRemoteProcedureCall]
243
208
  );
244
209
  useEffect(() => {
245
210
  if (!manual && argsRef.current) {
@@ -580,4 +545,4 @@ var withRendererOverride = (kind, renderer) => ({
580
545
  }
581
546
  });
582
547
 
583
- export { ApplicationStateContext, ApplicationStateProvider, TypeInfoORMClient, getApplicationStateIdentifier, getApplicationStateModified, getApplicationStateValue, getApplicationStateValueStructure, getChangedDependencyIndexes, getFullUrl, handleRequest, mergeSuites, requestHandlerFactory, sendServiceRequest, setApplicationStateModified, setApplicationStateValue, useApplicationStateLoader, useApplicationStateValue, useApplicationStateValueStructure, useController, useDebugDependencies, useTypeInfoORMAPI, withRendererOverride };
548
+ export { ApplicationStateContext, ApplicationStateProvider, TypeInfoORMClient, getApplicationStateIdentifier, getApplicationStateModified, getApplicationStateValue, getChangedDependencyIndexes, getFullUrl, handleRequest, mergeSuites, requestHandlerFactory, sendServiceRequest, setApplicationStateModified, setApplicationStateValue, useApplicationStateLoader, useApplicationStateValue, useController, useDebugDependencies, useTypeInfoORMAPI, withRendererOverride };
@@ -3,39 +3,56 @@
3
3
  *
4
4
  * Application-level state container built on React context and maps. Use
5
5
  * {@link ApplicationStateProvider} to host state, then access values with
6
- * {@link useApplicationStateValue} or {@link useApplicationStateValueStructure}.
6
+ * {@link useApplicationStateValue}.
7
7
  */
8
- import { FC, PropsWithChildren } from "react";
8
+ import { FC, PropsWithChildren, type Dispatch, type SetStateAction } from "react";
9
9
  /**
10
- * An object, nested or not, used as the identifier or identifier path for a state value.
10
+ * An object, nested or not, used as the identifier or identifier path for a
11
+ * state value.
12
+ *
13
+ * The generic parameter exists purely for TypeScript. It lets a consumer make
14
+ * the identifier itself the source of truth for what value type lives at that
15
+ * location in application state, without changing the runtime shape.
11
16
  * */
12
- export interface ApplicationStateIdentifier extends Record<string, ApplicationStateIdentifier | {}> {
17
+ declare const applicationStateIdentifierValueTypeSymbol: unique symbol;
18
+ export interface ApplicationStateIdentifier<ValueType = unknown> extends Record<string, ApplicationStateIdentifier<any> | {}> {
19
+ readonly [applicationStateIdentifierValueTypeSymbol]?: ValueType;
13
20
  }
14
21
  /**
15
22
  * The stored value type for application state entries.
16
23
  * */
17
- export type ApplicationStateValue = any;
24
+ export type ApplicationStateValue = unknown;
25
+ /**
26
+ * React-style state action for a specific application-state value.
27
+ *
28
+ * Passing a function follows the same contract as React `useState`: the
29
+ * function receives the previous value and returns the next value.
30
+ * */
31
+ export type ApplicationStateSetAction<ValueType> = ValueType | ((previousValue: ValueType) => ValueType);
32
+ /**
33
+ * React-style stable setter for a specific application-state value.
34
+ * */
35
+ export type ApplicationStateSetter<ValueType> = (value: ApplicationStateSetAction<ValueType>) => void;
18
36
  /**
19
37
  * Map of state identifiers to a "modified" boolean.
20
38
  * */
21
- export type ApplicationStateModificationState = Map<ApplicationStateIdentifier, boolean>;
39
+ export type ApplicationStateModificationState = Map<ApplicationStateIdentifier<any>, boolean>;
22
40
  /**
23
41
  * Map of state identifiers to stored values.
24
42
  * */
25
- export type ApplicationState = Map<ApplicationStateIdentifier, ApplicationStateValue>;
43
+ export type ApplicationState = Map<ApplicationStateIdentifier<any>, ApplicationStateValue>;
26
44
  /**
27
- * Determines the identifier shape for a specific sub-state.
45
+ * Create or forward an application-state identifier.
28
46
  *
29
- * @typeParam SpecificType - The identifier shape, if provided.
30
- * */
31
- export type ApplicationStateIdentifierSubStateType<SpecificType> = SpecificType extends undefined ? ApplicationStateIdentifier : SpecificType extends ApplicationStateIdentifier ? SpecificType : never;
32
- /**
33
- * Normalize a sub-state identifier map to an ApplicationStateIdentifier.
47
+ * Call with no argument to create a new identifier object and attach a value
48
+ * type at the type level:
49
+ * `const profileId = getApplicationStateIdentifier<UserProfile>()`
34
50
  *
35
- * @param subStateIdMap - Optional sub-state identifier map.
36
- * @returns The identifier map or an empty identifier object.
51
+ * Call with an existing identifier object to preserve that exact object
52
+ * reference while keeping its type information intact.
37
53
  * */
38
- export declare const getApplicationStateIdentifier: <SubStateIdStructure extends ApplicationStateIdentifier>(subStateIdMap?: SubStateIdStructure) => ApplicationStateIdentifierSubStateType<SubStateIdStructure>;
54
+ export declare function getApplicationStateIdentifier<ValueType = ApplicationStateValue>(): ApplicationStateIdentifier<ValueType>;
55
+ export declare function getApplicationStateIdentifier<IdentifierType extends ApplicationStateIdentifier<any>>(subStateIdMap: IdentifierType): IdentifierType;
39
56
  /**
40
57
  * Read the modification status for a specific identifier.
41
58
  *
@@ -43,7 +60,7 @@ export declare const getApplicationStateIdentifier: <SubStateIdStructure extends
43
60
  * @param modificationState - The modification map to read from.
44
61
  * @returns Whether the identifier is marked as modified.
45
62
  * */
46
- export declare const getApplicationStateModified: (identifier: ApplicationStateIdentifier, modificationState: ApplicationStateModificationState) => boolean;
63
+ export declare const getApplicationStateModified: (identifier: ApplicationStateIdentifier<any>, modificationState: ApplicationStateModificationState) => boolean;
47
64
  /**
48
65
  * Read the stored value for an identifier.
49
66
  *
@@ -51,7 +68,7 @@ export declare const getApplicationStateModified: (identifier: ApplicationStateI
51
68
  * @param applicationState - The application state map.
52
69
  * @returns The stored value, if any.
53
70
  * */
54
- export declare const getApplicationStateValue: (identifier: ApplicationStateIdentifier, applicationState: ApplicationState) => ApplicationStateValue;
71
+ export declare const getApplicationStateValue: <ValueType = ApplicationStateValue>(identifier: ApplicationStateIdentifier<ValueType>, applicationState: ApplicationState) => ValueType | undefined;
55
72
  /**
56
73
  * Set the modification status for an identifier.
57
74
  *
@@ -60,7 +77,7 @@ export declare const getApplicationStateValue: (identifier: ApplicationStateIden
60
77
  * @param modificationState - The current modification map.
61
78
  * @returns A new modification map with the updated flag.
62
79
  * */
63
- export declare const setApplicationStateModified: (identifier: ApplicationStateIdentifier, value: boolean, modificationState: ApplicationStateModificationState) => ApplicationStateModificationState;
80
+ export declare const setApplicationStateModified: (identifier: ApplicationStateIdentifier<any>, value: boolean, modificationState: ApplicationStateModificationState) => ApplicationStateModificationState;
64
81
  /**
65
82
  * Set the stored value for an identifier.
66
83
  *
@@ -69,15 +86,7 @@ export declare const setApplicationStateModified: (identifier: ApplicationStateI
69
86
  * @param applicationState - The current application state map.
70
87
  * @returns A new application state map with the updated value.
71
88
  * */
72
- export declare const setApplicationStateValue: (identifier: ApplicationStateIdentifier, value: ApplicationStateValue, applicationState: ApplicationState) => ApplicationState;
73
- /**
74
- * Resolve a structured map of identifiers into their current values.
75
- *
76
- * @param idStructure - Map of structure keys to identifiers.
77
- * @param applicationState - The application state map.
78
- * @returns An object of the same shape containing resolved values.
79
- * */
80
- export declare const getApplicationStateValueStructure: <ReturnStructureType extends Record<string, any>>(idStructure: Record<keyof ReturnStructureType, ApplicationStateIdentifier>, applicationState: ApplicationState) => ReturnStructureType;
89
+ export declare const setApplicationStateValue: <ValueType = ApplicationStateValue>(identifier: ApplicationStateIdentifier<ValueType>, value: ValueType, applicationState: ApplicationState) => ApplicationState;
81
90
  /**
82
91
  * Context state and updater hooks for application state.
83
92
  * */
@@ -93,11 +102,11 @@ export type ApplicationStateContextType = {
93
102
  /**
94
103
  * Replace the current application state map.
95
104
  * */
96
- onChange: (newValue: ApplicationState) => void;
105
+ onChange: Dispatch<SetStateAction<ApplicationState>>;
97
106
  /**
98
107
  * Replace the current modification state map.
99
108
  * */
100
- setModified: (newValue: ApplicationStateModificationState) => void;
109
+ setModified: Dispatch<SetStateAction<ApplicationStateModificationState>>;
101
110
  };
102
111
  /**
103
112
  * React context for application state and modification tracking.
@@ -106,7 +115,7 @@ export declare const ApplicationStateContext: import("react").Context<Applicatio
106
115
  /**
107
116
  * Used to access and update application state values.
108
117
  * */
109
- export type ApplicationStateValueController = {
118
+ export type ApplicationStateValueController<ValueType = ApplicationStateValue> = {
110
119
  /**
111
120
  * Whether the value is marked as modified.
112
121
  * */
@@ -114,13 +123,17 @@ export type ApplicationStateValueController = {
114
123
  /**
115
124
  * The current value for the identifier.
116
125
  * */
117
- value: ApplicationStateValue;
126
+ value: ValueType | undefined;
118
127
  /**
119
- * Update the current value.
128
+ * Update the current value with React `useState` semantics.
120
129
  *
121
- * @param value - The new value to store.
130
+ * The setter is intentionally stable so consumers can safely depend on it
131
+ * like a normal React state setter.
132
+ *
133
+ * @param value - The next value, or a function that derives it from the
134
+ * previous value.
122
135
  * */
123
- onChange: (value: ApplicationStateValue) => void;
136
+ onChange: ApplicationStateSetter<ValueType | undefined>;
124
137
  /**
125
138
  * Update the modified flag.
126
139
  *
@@ -134,27 +147,7 @@ export type ApplicationStateValueController = {
134
147
  * @param identifier - Identifier to read and update.
135
148
  * @returns Controller for the identifier value and modified flag.
136
149
  * */
137
- export declare const useApplicationStateValue: (identifier: ApplicationStateIdentifier) => ApplicationStateValueController;
138
- /**
139
- * A mapped structure of application state value controllers.
140
- * */
141
- export type ApplicationStateValueStructureController<StructureType extends Record<string, any>> = {
142
- /**
143
- * The resolved value structure.
144
- * */
145
- valueStructure: StructureType;
146
- /**
147
- * Per-field change handlers for the structure.
148
- * */
149
- onChangeStructure: Record<keyof StructureType, (newValue: any) => void>;
150
- };
151
- /**
152
- * Use an object that is a collection of application state value controllers.
153
- *
154
- * @param idStructure - Map of structure keys to identifiers.
155
- * @returns Controller with the resolved values and per-field change handlers.
156
- * */
157
- export declare const useApplicationStateValueStructure: <StructureType extends Record<string, any>>(idStructure: Record<keyof StructureType, ApplicationStateIdentifier>) => ApplicationStateValueStructureController<StructureType>;
150
+ export declare const useApplicationStateValue: <ValueType = ApplicationStateValue>(identifier: ApplicationStateIdentifier<ValueType>) => ApplicationStateValueController<ValueType>;
158
151
  /**
159
152
  * Props for ApplicationStateProvider.
160
153
  * */
@@ -165,3 +158,4 @@ export type ApplicationStateProviderProps = PropsWithChildren<{}>;
165
158
  * @param children - React children to render in the provider.
166
159
  * */
167
160
  export declare const ApplicationStateProvider: FC<ApplicationStateProviderProps>;
161
+ export {};
@@ -4,12 +4,12 @@
4
4
  * Loader hook for remote application state values. Calls a service endpoint,
5
5
  * tracks loading/error state, and populates ApplicationState via identifiers.
6
6
  */
7
- import { ApplicationStateIdentifier } from "./ApplicationState";
7
+ import { ApplicationStateIdentifier, type ApplicationStateValue, type ApplicationStateValueController } from "./ApplicationState";
8
8
  import { ServiceConfig } from "./Service";
9
9
  /**
10
10
  * Access and track the loading of an application state value.
11
11
  * */
12
- export type ApplicationStateLoader = {
12
+ export type ApplicationStateLoader<ValueType = ApplicationStateValue, ArgsType extends any[] = any[]> = ApplicationStateValueController<ValueType> & {
13
13
  /**
14
14
  * Whether the current request is in flight.
15
15
  * */
@@ -27,12 +27,12 @@ export type ApplicationStateLoader = {
27
27
  *
28
28
  * @param args - Arguments to send with the request.
29
29
  * */
30
- makeRemoteProcedureCall: (...args: any[]) => Promise<void>;
30
+ makeRemoteProcedureCall: (...args: ArgsType) => Promise<void>;
31
31
  };
32
32
  /**
33
33
  * The service, path and arguments to use for a remote procedure call.
34
34
  * */
35
- export type RemoteProcedureCall = {
35
+ export type RemoteProcedureCall<ArgsType extends any[] = any[]> = {
36
36
  /**
37
37
  * Configuration for the target service endpoint.
38
38
  * */
@@ -44,20 +44,20 @@ export type RemoteProcedureCall = {
44
44
  /**
45
45
  * Default args to send when the call auto-runs.
46
46
  * */
47
- args?: any[];
47
+ args?: ArgsType;
48
48
  };
49
49
  /**
50
50
  * The configuration for an application state loader.
51
51
  * */
52
- export type ApplicationStateLoaderConfig = {
52
+ export type ApplicationStateLoaderConfig<ValueType = ApplicationStateValue, ArgsType extends any[] = any[]> = {
53
53
  /**
54
54
  * Identifier for the value to update in application state.
55
55
  * */
56
- identifier: ApplicationStateIdentifier;
56
+ identifier: ApplicationStateIdentifier<ValueType>;
57
57
  /**
58
58
  * RPC target configuration and arguments.
59
59
  * */
60
- remoteProcedureCall: RemoteProcedureCall;
60
+ remoteProcedureCall: RemoteProcedureCall<ArgsType>;
61
61
  /**
62
62
  * Clear the application state value on error.
63
63
  *
@@ -80,7 +80,12 @@ export type ApplicationStateLoaderConfig = {
80
80
  /**
81
81
  * Load, track and access an application state value.
82
82
  *
83
+ * The returned object intentionally combines the remote-loading lifecycle with
84
+ * the same stable local controller contract as
85
+ * {@link useApplicationStateValue}. That keeps a loader-backed state value
86
+ * usable like normal React state once it has been identified.
87
+ *
83
88
  * @param config - Loader configuration for state identifier and RPC details.
84
89
  * @returns Loader controls and request state.
85
90
  * */
86
- export declare const useApplicationStateLoader: (config: ApplicationStateLoaderConfig) => ApplicationStateLoader;
91
+ export declare const useApplicationStateLoader: <ValueType = ApplicationStateValue, ArgsType extends any[] = any[]>(config: ApplicationStateLoaderConfig<ValueType, ArgsType>) => ApplicationStateLoader<ValueType, ArgsType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resistdesign/voltra",
3
- "version": "3.0.0-alpha.48",
3
+ "version": "3.0.0-alpha.49",
4
4
  "description": "With our powers combined!",
5
5
  "homepage": "https://voltra.app",
6
6
  "repository": "git@github.com:resistdesign/voltra.git",