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.
- package/dist/app/index.js +2 -2
- package/dist/app/index.js.map +2 -2
- package/dist/{chunk-e6nxs9xa.js → chunk-2j91yc5g.js} +1 -1
- package/dist/{chunk-mtbjk5px.js → chunk-5yz4jjwj.js} +2 -2
- package/dist/{chunk-mtbjk5px.js.map → chunk-5yz4jjwj.js.map} +1 -1
- package/dist/chunk-7pb9p4tj.js +4 -0
- package/dist/{chunk-fgafrjxy.js.map → chunk-7pb9p4tj.js.map} +5 -4
- package/dist/{chunk-bn4smbkm.js → chunk-hq6bnmbe.js} +2 -2
- package/dist/{chunk-bn4smbkm.js.map → chunk-hq6bnmbe.js.map} +1 -1
- package/dist/{chunk-vx4y92r0.js → chunk-jwcetzcw.js} +2 -2
- package/dist/{chunk-vx4y92r0.js.map → chunk-jwcetzcw.js.map} +1 -1
- package/dist/{chunk-f3ft8w3z.js → chunk-kejrbrr5.js} +2 -2
- package/dist/{chunk-f3ft8w3z.js.map → chunk-kejrbrr5.js.map} +1 -1
- package/dist/{chunk-grzfxg62.js → chunk-m88m39d2.js} +1 -1
- package/dist/{chunk-m69enj51.js → chunk-njj6q7xt.js} +2 -2
- package/dist/{chunk-m69enj51.js.map → chunk-njj6q7xt.js.map} +1 -1
- package/dist/{chunk-wa1dcgad.js → chunk-q04g7v20.js} +1 -1
- package/dist/chunk-shx43qev.js +3 -0
- package/dist/{chunk-an6sbmg2.js.map → chunk-shx43qev.js.map} +4 -7
- package/dist/{chunk-x77c0xjm.js → chunk-xg82xtdy.js} +2 -2
- package/dist/{chunk-x77c0xjm.js.map → chunk-xg82xtdy.js.map} +1 -1
- package/dist/{chunk-gdv7756c.js → chunk-zeyq4p6y.js} +2 -2
- package/dist/{chunk-gdv7756c.js.map → chunk-zeyq4p6y.js.map} +5 -5
- package/dist/client/auth/useUser.d.ts +27 -2
- package/dist/client/auth/useUser.d.ts.map +1 -1
- package/dist/client/index.js +29 -25
- package/dist/client/index.js.map +1 -1
- package/dist/client/isPlainObject.d.ts +2 -0
- package/dist/client/isPlainObject.d.ts.map +1 -0
- package/dist/client/useQuery.d.ts +6 -12
- package/dist/client/useQuery.d.ts.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +3 -3
- package/dist/facades/index.js.map +2 -2
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +3 -3
- package/dist/i18n/Dictionary.d.ts +6 -2
- package/dist/i18n/Dictionary.d.ts.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +3 -3
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +48 -48
- package/dist/services/index.js.map +4 -4
- package/dist/utils/type.d.ts +3 -0
- package/dist/utils/type.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-an6sbmg2.js +0 -4
- package/dist/chunk-fgafrjxy.js +0 -4
- package/dist/chunk-ny36ys64.js +0 -4
- package/dist/chunk-ny36ys64.js.map +0 -10
- /package/dist/{chunk-e6nxs9xa.js.map → chunk-2j91yc5g.js.map} +0 -0
- /package/dist/{chunk-grzfxg62.js.map → chunk-m88m39d2.js.map} +0 -0
- /package/dist/{chunk-wa1dcgad.js.map → chunk-q04g7v20.js.map} +0 -0
package/dist/client/index.js
CHANGED
|
@@ -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
|
|
299
|
+
function mutate(fn) {
|
|
297
300
|
return resource.mutate.call(resource, variantKey, (data) => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
310
|
+
throw new Error(
|
|
311
|
+
"Mutate function must return an object when the current data is an object."
|
|
312
|
+
);
|
|
322
313
|
}
|
|
323
|
-
|
|
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 {
|