@ciwergrp/nuxid 1.17.2 → 1.17.3

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
3
  "configKey": "nuxid",
4
- "version": "1.17.2",
4
+ "version": "1.17.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -5,9 +5,9 @@ export async function useCursorHttp(url, options) {
5
5
  if (!obj || typeof obj !== "object") {
6
6
  return sources;
7
7
  }
8
- for (const key2 in obj) {
9
- if (Object.prototype.hasOwnProperty.call(obj, key2)) {
10
- const value = obj[key2];
8
+ for (const key in obj) {
9
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
10
+ const value = obj[key];
11
11
  if (isRef(value)) {
12
12
  sources.push(value);
13
13
  } else if (typeof value === "object") {
@@ -22,15 +22,15 @@ export async function useCursorHttp(url, options) {
22
22
  return obj;
23
23
  }
24
24
  const unwrapped = Array.isArray(obj) ? [] : {};
25
- for (const key2 in obj) {
26
- if (Object.prototype.hasOwnProperty.call(obj, key2)) {
27
- const value = obj[key2];
25
+ for (const key in obj) {
26
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
27
+ const value = obj[key];
28
28
  if (isRef(value)) {
29
- unwrapped[key2] = value.value;
29
+ unwrapped[key] = value.value;
30
30
  } else if (typeof value === "object") {
31
- unwrapped[key2] = unwrapReactiveObject(value);
31
+ unwrapped[key] = unwrapReactiveObject(value);
32
32
  } else {
33
- unwrapped[key2] = value;
33
+ unwrapped[key] = value;
34
34
  }
35
35
  }
36
36
  }
@@ -58,8 +58,7 @@ export async function useCursorHttp(url, options) {
58
58
  fetchOptions,
59
59
  meta,
60
60
  itemKey = "id",
61
- cursorParam = "cursor",
62
- key
61
+ cursorParam = "cursor"
63
62
  } = options ?? {};
64
63
  const initialUrl = url;
65
64
  const data = ref();
@@ -201,43 +200,10 @@ export async function useCursorHttp(url, options) {
201
200
  }
202
201
  });
203
202
  if (immediate) {
204
- const asyncKey = key ?? `cursor:${String(url)}:${JSON.stringify(currentParams.value ?? {})}`;
205
203
  if (lazy) {
206
- const { data: asyncData, error: asyncError, pending: asyncPending } = useAsyncData(
207
- asyncKey,
208
- () => fetcherFn(initialUrl, currentParams.value),
209
- { lazy: true }
210
- );
211
- watch(asyncPending, (v) => loading.value = v, { immediate: true });
212
- watch(asyncData, (val) => {
213
- if (val) {
214
- const response = val;
215
- data.value = { ...response, data: [...response.data] };
216
- nextCursor.value = normalizeCursorValue(response.meta?.[cursorKey]);
217
- hasNextPage.value = response.meta?.[hasMoreKey] ?? false;
218
- }
219
- });
220
- watch(asyncError, (val) => {
221
- if (val) {
222
- error.value = normalizeFetchError(val);
223
- }
224
- });
204
+ void fetchData(initialUrl, currentParams.value);
225
205
  } else {
226
- loading.value = true;
227
- const { data: asyncData, error: asyncError } = await useAsyncData(
228
- asyncKey,
229
- () => fetcherFn(initialUrl, currentParams.value)
230
- );
231
- loading.value = false;
232
- if (asyncData.value) {
233
- const val = asyncData.value;
234
- data.value = { ...val, data: [...val.data] };
235
- nextCursor.value = normalizeCursorValue(val.meta?.[cursorKey]);
236
- hasNextPage.value = val.meta?.[hasMoreKey] ?? false;
237
- }
238
- if (asyncError.value) {
239
- error.value = normalizeFetchError(asyncError.value);
240
- }
206
+ await fetchData(initialUrl, currentParams.value);
241
207
  }
242
208
  }
243
209
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
4
4
  "description": "All-in-one essential modules for Nuxt",
5
5
  "repository": {
6
6
  "type": "git",