gemi 0.19.0 → 0.19.2

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.
Files changed (58) hide show
  1. package/dist/app/index.js +2 -2
  2. package/dist/app/index.js.map +2 -2
  3. package/dist/{chunk-e6nxs9xa.js → chunk-2j91yc5g.js} +1 -1
  4. package/dist/{chunk-mtbjk5px.js → chunk-5yz4jjwj.js} +2 -2
  5. package/dist/{chunk-mtbjk5px.js.map → chunk-5yz4jjwj.js.map} +1 -1
  6. package/dist/chunk-7pb9p4tj.js +4 -0
  7. package/dist/{chunk-fgafrjxy.js.map → chunk-7pb9p4tj.js.map} +5 -4
  8. package/dist/{chunk-bn4smbkm.js → chunk-hq6bnmbe.js} +2 -2
  9. package/dist/{chunk-bn4smbkm.js.map → chunk-hq6bnmbe.js.map} +1 -1
  10. package/dist/{chunk-vx4y92r0.js → chunk-jwcetzcw.js} +2 -2
  11. package/dist/{chunk-vx4y92r0.js.map → chunk-jwcetzcw.js.map} +1 -1
  12. package/dist/{chunk-f3ft8w3z.js → chunk-kejrbrr5.js} +2 -2
  13. package/dist/{chunk-f3ft8w3z.js.map → chunk-kejrbrr5.js.map} +1 -1
  14. package/dist/{chunk-grzfxg62.js → chunk-m88m39d2.js} +1 -1
  15. package/dist/{chunk-m69enj51.js → chunk-njj6q7xt.js} +2 -2
  16. package/dist/{chunk-m69enj51.js.map → chunk-njj6q7xt.js.map} +1 -1
  17. package/dist/{chunk-wa1dcgad.js → chunk-q04g7v20.js} +1 -1
  18. package/dist/chunk-shx43qev.js +3 -0
  19. package/dist/{chunk-an6sbmg2.js.map → chunk-shx43qev.js.map} +4 -7
  20. package/dist/{chunk-x77c0xjm.js → chunk-xg82xtdy.js} +2 -2
  21. package/dist/{chunk-x77c0xjm.js.map → chunk-xg82xtdy.js.map} +1 -1
  22. package/dist/{chunk-gdv7756c.js → chunk-zeyq4p6y.js} +2 -2
  23. package/dist/{chunk-gdv7756c.js.map → chunk-zeyq4p6y.js.map} +5 -5
  24. package/dist/client/auth/useUser.d.ts +27 -2
  25. package/dist/client/auth/useUser.d.ts.map +1 -1
  26. package/dist/client/index.js +29 -25
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/client/isPlainObject.d.ts +2 -0
  29. package/dist/client/isPlainObject.d.ts.map +1 -0
  30. package/dist/client/useQuery.d.ts +6 -12
  31. package/dist/client/useQuery.d.ts.map +1 -1
  32. package/dist/email/index.js +2 -2
  33. package/dist/email/index.js.map +1 -1
  34. package/dist/facades/index.js +3 -3
  35. package/dist/facades/index.js.map +2 -2
  36. package/dist/http/HttpRequest.d.ts.map +1 -1
  37. package/dist/http/index.js +2 -2
  38. package/dist/http/index.js.map +3 -3
  39. package/dist/i18n/Dictionary.d.ts +6 -2
  40. package/dist/i18n/Dictionary.d.ts.map +1 -1
  41. package/dist/i18n/index.js +2 -2
  42. package/dist/i18n/index.js.map +3 -3
  43. package/dist/kernel/index.js +2 -2
  44. package/dist/kernel/index.js.map +2 -2
  45. package/dist/server/index.js +2 -2
  46. package/dist/server/index.js.map +1 -1
  47. package/dist/services/index.js +48 -48
  48. package/dist/services/index.js.map +4 -4
  49. package/dist/utils/type.d.ts +3 -0
  50. package/dist/utils/type.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/chunk-an6sbmg2.js +0 -4
  53. package/dist/chunk-fgafrjxy.js +0 -4
  54. package/dist/chunk-ny36ys64.js +0 -4
  55. package/dist/chunk-ny36ys64.js.map +0 -10
  56. /package/dist/{chunk-e6nxs9xa.js.map → chunk-2j91yc5g.js.map} +0 -0
  57. /package/dist/{chunk-grzfxg62.js.map → chunk-m88m39d2.js.map} +0 -0
  58. /package/dist/{chunk-wa1dcgad.js.map → chunk-q04g7v20.js.map} +0 -0
@@ -213,6 +213,9 @@ function useRouteData() {
213
213
  const { data, i18n, prefetchedData, breadcrumbs } = useContext(RouteStateContext);
214
214
  return { data, i18n, prefetchedData, breadcrumbs };
215
215
  }
216
+ function isPlainObject(value) {
217
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
218
+ }
216
219
  const defaultConfig = {
217
220
  fallbackData: null,
218
221
  keepPreviousData: true,
@@ -293,34 +296,35 @@ function useQuery(url, ...args) {
293
296
  clearInterval(retryIntervalRef.current);
294
297
  };
295
298
  }, [variantKey, resource]);
296
- function mutate(fn, value) {
299
+ function mutate(fn) {
297
300
  return resource.mutate.call(resource, variantKey, (data) => {
298
- try {
299
- if (typeof fn === "function") {
300
- if (Array.isArray(data)) {
301
- return [...data, ...fn(data)];
302
- }
303
- return { ...data, ...fn(data) };
304
- } else if (typeof fn === "string") {
305
- const keys = fn.split(".");
306
- let current = structuredClone(data);
307
- for (let i = 0; i < keys.length - 1; i++) {
308
- const subKey = keys[i];
309
- current[subKey] = current[subKey] || {};
310
- current = current[subKey];
311
- }
312
- let newValue = value;
313
- if (typeof value === "function") {
314
- newValue = value(current[keys[keys.length - 1]]);
315
- }
316
- current[keys[keys.length - 1]] = newValue;
317
- return current;
301
+ if (data === void 0 || data === null) {
302
+ console.warn("Mutate function called before the query.");
303
+ return;
304
+ }
305
+ const updatedData = typeof fn === "function" ? fn(data) : fn;
306
+ if (isPlainObject(data)) {
307
+ if (isPlainObject(updatedData)) {
308
+ return { ...data, ...updatedData };
318
309
  }
319
- return { ...data, ...fn };
320
- } catch (err) {
321
- console.log(err);
310
+ throw new Error(
311
+ "Mutate function must return an object when the current data is an object."
312
+ );
322
313
  }
323
- return data;
314
+ if (Array.isArray(data)) {
315
+ if (Array.isArray(updatedData)) {
316
+ return [...data, ...updatedData];
317
+ }
318
+ throw new Error(
319
+ "Mutate function must return an array when the current data is an array."
320
+ );
321
+ }
322
+ if (typeof data !== typeof updatedData) {
323
+ throw new Error(
324
+ "Mutate function must return the same type as the current data."
325
+ );
326
+ }
327
+ return updatedData;
324
328
  });
325
329
  }
326
330
  return {