@opengeoweb/api 5.2.1 → 6.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.
package/index.js
CHANGED
|
@@ -135,7 +135,10 @@ function _regeneratorRuntime() {
|
|
|
135
135
|
if ("executing" === state) throw new Error("Generator is already running");
|
|
136
136
|
if ("completed" === state) {
|
|
137
137
|
if ("throw" === method) throw arg;
|
|
138
|
-
return
|
|
138
|
+
return {
|
|
139
|
+
value: void 0,
|
|
140
|
+
done: !0
|
|
141
|
+
};
|
|
139
142
|
}
|
|
140
143
|
for (context.method = method, context.arg = arg;;) {
|
|
141
144
|
var delegate = context.delegate;
|
|
@@ -188,7 +191,7 @@ function _regeneratorRuntime() {
|
|
|
188
191
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
189
192
|
}
|
|
190
193
|
function values(iterable) {
|
|
191
|
-
if (iterable) {
|
|
194
|
+
if (iterable || "" === iterable) {
|
|
192
195
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
193
196
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
194
197
|
if ("function" == typeof iterable.next) return iterable;
|
|
@@ -201,15 +204,7 @@ function _regeneratorRuntime() {
|
|
|
201
204
|
return next.next = next;
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
|
-
|
|
205
|
-
next: doneResult
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function doneResult() {
|
|
209
|
-
return {
|
|
210
|
-
value: undefined,
|
|
211
|
-
done: !0
|
|
212
|
-
};
|
|
207
|
+
throw new TypeError(typeof iterable + " is not iterable");
|
|
213
208
|
}
|
|
214
209
|
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
215
210
|
value: GeneratorFunctionPrototype,
|
|
@@ -419,9 +414,9 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
419
414
|
var generateRandomId = function generateRandomId() {
|
|
420
415
|
return "-".concat(Math.random().toString(36).substr(2, 9));
|
|
421
416
|
};
|
|
417
|
+
var useApi = function useApi(
|
|
422
418
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
423
|
-
|
|
424
|
-
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
419
|
+
apiCall, params) {
|
|
425
420
|
var _useIsMounted = useIsMounted(),
|
|
426
421
|
isMounted = _useIsMounted.isMounted;
|
|
427
422
|
var _React$useState = React.useState(generateRandomId()),
|
|
@@ -440,8 +435,7 @@ var useApi = function useApi(apiCall) {
|
|
|
440
435
|
result = _React$useState8[0],
|
|
441
436
|
setResult = _React$useState8[1];
|
|
442
437
|
var debouncedParams = useDebounce(JSON.stringify(params), 300);
|
|
443
|
-
var fetchApiData = function fetchApiData() {
|
|
444
|
-
var _params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
438
|
+
var fetchApiData = function fetchApiData(_params) {
|
|
445
439
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
446
440
|
var response;
|
|
447
441
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -531,10 +525,13 @@ var ApiProvider = function ApiProvider(_a) {
|
|
|
531
525
|
return function () {
|
|
532
526
|
};
|
|
533
527
|
}, [handleNewApi, name]);
|
|
534
|
-
|
|
535
|
-
|
|
528
|
+
var contextValue = React.useMemo(function () {
|
|
529
|
+
return {
|
|
536
530
|
api: api
|
|
537
|
-
}
|
|
531
|
+
};
|
|
532
|
+
}, [api]);
|
|
533
|
+
return /*#__PURE__*/React.createElement(ApiContext.Provider, {
|
|
534
|
+
value: contextValue
|
|
538
535
|
}, children);
|
|
539
536
|
};
|
|
540
537
|
function useApiContext() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "GeoWeb API library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"types": "./src/index.d.ts",
|
|
14
14
|
"dependencies": {},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@opengeoweb/shared": "
|
|
17
|
-
"axios": "1.
|
|
16
|
+
"@opengeoweb/shared": "6.0.1",
|
|
17
|
+
"axios": "1.2.0",
|
|
18
18
|
"react": "18.2.0"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { ConfigType } from '@opengeoweb/shared';
|
|
2
|
+
export declare type ApiParams = string | ConfigType | {
|
|
3
|
+
[key: string]: string | undefined;
|
|
4
|
+
} | null;
|
|
1
5
|
export interface ApiHookProps {
|
|
2
6
|
isLoading: boolean;
|
|
3
7
|
error: Error;
|
|
4
8
|
result: any;
|
|
5
|
-
fetchApiData?: (params:
|
|
9
|
+
fetchApiData?: (params: ApiParams) => Promise<void>;
|
|
6
10
|
clearResults?: () => void;
|
|
7
11
|
}
|
|
8
|
-
export declare const useApi: (apiCall
|
|
12
|
+
export declare const useApi: (apiCall?: ((params?: ApiParams | undefined, id?: string | undefined) => Promise<any>) | undefined, params?: ApiParams | undefined) => ApiHookProps;
|