@intrig/next 0.0.15-27 → 0.0.15-28
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/index.esm.js +48 -4
- package/package.json +1 -2
- package/src/intrig-provider.d.ts +12 -0
- package/src/intrig-provider.d.ts.map +1 -1
package/index.esm.js
CHANGED
|
@@ -3822,7 +3822,7 @@ function IntrigProvider({
|
|
|
3822
3822
|
children: children
|
|
3823
3823
|
}, void 0, false, {
|
|
3824
3824
|
fileName: _jsxFileName$1,
|
|
3825
|
-
lineNumber:
|
|
3825
|
+
lineNumber: 144,
|
|
3826
3826
|
columnNumber: 10
|
|
3827
3827
|
}, this);
|
|
3828
3828
|
}
|
|
@@ -3868,7 +3868,7 @@ function IntrigProviderStub({
|
|
|
3868
3868
|
children: children
|
|
3869
3869
|
}, void 0, false, {
|
|
3870
3870
|
fileName: _jsxFileName$1,
|
|
3871
|
-
lineNumber:
|
|
3871
|
+
lineNumber: 228,
|
|
3872
3872
|
columnNumber: 10
|
|
3873
3873
|
}, this);
|
|
3874
3874
|
}
|
|
@@ -3927,7 +3927,7 @@ function StatusTrap({
|
|
|
3927
3927
|
children: children
|
|
3928
3928
|
}, void 0, false, {
|
|
3929
3929
|
fileName: _jsxFileName$1,
|
|
3930
|
-
lineNumber:
|
|
3930
|
+
lineNumber: 298,
|
|
3931
3931
|
columnNumber: 5
|
|
3932
3932
|
}, this);
|
|
3933
3933
|
}
|
|
@@ -4073,6 +4073,50 @@ function useCentralPendingState() {
|
|
|
4073
4073
|
return result;
|
|
4074
4074
|
}
|
|
4075
4075
|
|
|
4076
|
+
/**
|
|
4077
|
+
* A hook for making transient calls that can be aborted and validated against schemas.
|
|
4078
|
+
* Returns a promise-based call function and an abort function.
|
|
4079
|
+
*
|
|
4080
|
+
* @param schema - Optional Zod schema for validating the response
|
|
4081
|
+
* @param errorSchema - Optional Zod schema for validating error responses
|
|
4082
|
+
* @returns A tuple of [call function, abort function]
|
|
4083
|
+
*/
|
|
4084
|
+
function useTransitionCall({
|
|
4085
|
+
schema,
|
|
4086
|
+
errorSchema
|
|
4087
|
+
}) {
|
|
4088
|
+
const ctx = useContext(Context);
|
|
4089
|
+
const controller = useRef(undefined);
|
|
4090
|
+
const schemaRef = useRef(schema);
|
|
4091
|
+
const errorSchemaRef = useRef(errorSchema);
|
|
4092
|
+
useEffect(() => {
|
|
4093
|
+
schemaRef.current = schema;
|
|
4094
|
+
errorSchemaRef.current = errorSchema;
|
|
4095
|
+
});
|
|
4096
|
+
const call = useCallback(async request => {
|
|
4097
|
+
var _controller$current;
|
|
4098
|
+
(_controller$current = controller.current) == null || _controller$current.abort();
|
|
4099
|
+
const abort = new AbortController();
|
|
4100
|
+
controller.current = abort;
|
|
4101
|
+
return new Promise((resolve, reject) => {
|
|
4102
|
+
ctx.execute(Object.assign({}, request, {
|
|
4103
|
+
signal: abort.signal
|
|
4104
|
+
}), state => {
|
|
4105
|
+
if (isSuccess(state)) {
|
|
4106
|
+
resolve(state.data);
|
|
4107
|
+
} else if (isError(state)) {
|
|
4108
|
+
reject(state.error);
|
|
4109
|
+
}
|
|
4110
|
+
}, schemaRef.current, errorSchemaRef.current);
|
|
4111
|
+
});
|
|
4112
|
+
}, [ctx]);
|
|
4113
|
+
const abort = useCallback(() => {
|
|
4114
|
+
var _controller$current2;
|
|
4115
|
+
(_controller$current2 = controller.current) == null || _controller$current2.abort();
|
|
4116
|
+
}, []);
|
|
4117
|
+
return [call, abort];
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4076
4120
|
var _jsxFileName = "/home/tiran-intrigsoft/IdeaProjects/intrig-core/lib/next-client/src/intrig-layout.tsx";
|
|
4077
4121
|
async function IntrigLayout({
|
|
4078
4122
|
children,
|
|
@@ -4221,4 +4265,4 @@ function useResolvedCachedValue(hook, options) {
|
|
|
4221
4265
|
return cachedValue;
|
|
4222
4266
|
}
|
|
4223
4267
|
|
|
4224
|
-
export { IntrigLayout, IntrigProvider, IntrigProviderStub, StatusTrap, error, init, isError, isInit, isNetworkError, isPending, isRequestValidationError, isResponseValidationError, isSuccess, isSuccessfulDispatch, isValidationError, networkError, pending, requestValidationError, responseValidationError, success, successfulDispatch, useAsNetworkState, useAsPromise, useCentralError, useCentralPendingState, useNetworkState, useResolvedCachedValue, useResolvedValue, validationError };
|
|
4268
|
+
export { IntrigLayout, IntrigProvider, IntrigProviderStub, StatusTrap, error, init, isError, isInit, isNetworkError, isPending, isRequestValidationError, isResponseValidationError, isSuccess, isSuccessfulDispatch, isValidationError, networkError, pending, requestValidationError, responseValidationError, success, successfulDispatch, useAsNetworkState, useAsPromise, useCentralError, useCentralPendingState, useNetworkState, useResolvedCachedValue, useResolvedValue, useTransitionCall, validationError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intrig/next",
|
|
3
|
-
"version": "0.0.15-
|
|
3
|
+
"version": "0.0.15-28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.esm.js",
|
|
6
6
|
"module": "./index.esm.js",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"exports": {
|
|
34
34
|
"./package.json": "./package.json",
|
|
35
35
|
".": {
|
|
36
|
-
"development": "./src/index.ts",
|
|
37
36
|
"types": "./index.esm.d.ts",
|
|
38
37
|
"import": "./index.esm.js",
|
|
39
38
|
"default": "./index.esm.js"
|
package/src/intrig-provider.d.ts
CHANGED
|
@@ -96,4 +96,16 @@ export declare function useCentralError(): {
|
|
|
96
96
|
* @return {NetworkState} The aggregated network state based on the pending states and their progress.
|
|
97
97
|
*/
|
|
98
98
|
export declare function useCentralPendingState(): NetworkState<unknown, unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* A hook for making transient calls that can be aborted and validated against schemas.
|
|
101
|
+
* Returns a promise-based call function and an abort function.
|
|
102
|
+
*
|
|
103
|
+
* @param schema - Optional Zod schema for validating the response
|
|
104
|
+
* @param errorSchema - Optional Zod schema for validating error responses
|
|
105
|
+
* @returns A tuple of [call function, abort function]
|
|
106
|
+
*/
|
|
107
|
+
export declare function useTransitionCall<T>({ schema, errorSchema, }: {
|
|
108
|
+
schema?: ZodSchema<T>;
|
|
109
|
+
errorSchema?: ZodSchema<any>;
|
|
110
|
+
}): [(request: RequestType) => Promise<T>, () => void];
|
|
99
111
|
//# sourceMappingURL=intrig-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intrig-provider.d.ts","sourceRoot":"","sources":["../../../lib/src/intrig-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EACZ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"intrig-provider.d.ts","sourceRoot":"","sources":["../../../lib/src/intrig-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EACZ,iBAAiB,EAQlB,MAAM,OAAO,CAAC;AACf,OAAO,EAKL,UAAU,EAKV,YAAY,EAIb,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGhC,OAAO,EAEL,WAAW,EACX,WAAW,EACX,cAAc,EACf,MAAM,kBAAkB,CAAC;AAmB1B,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAY,EACZ,SAAc,GACf,EAAE,mBAAmB,2CAiErB;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAC/B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACN,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACzB,EAAE,EAAE,CACF,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,EACP,QAA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