@arcote.tech/arc-react 0.7.27 → 0.7.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -318,6 +318,15 @@ import {
318
318
  useState as useState3
319
319
  } from "react";
320
320
  import { jsx as jsx5 } from "react/jsx-runtime";
321
+ function logMutationError(descriptor, err) {
322
+ const label = `${descriptor.element}.${descriptor.method}`;
323
+ const e = err;
324
+ if (e && e.arcCode === "VALIDATION" && Array.isArray(e.fields)) {
325
+ console.error(`[arc] mutacja ${label} — Invalid parameters, niepoprawne pola: ${e.fields.join(", ")}`, err);
326
+ } else {
327
+ console.error(`[arc] mutacja ${label} nie powiodła się:`, err);
328
+ }
329
+ }
321
330
  var modelProviderFactory = (context, options) => {
322
331
  const ModelContext = createContext4(null);
323
332
  const commandWire = options.remoteUrl ? new CommandWire(options.remoteUrl) : undefined;
@@ -623,7 +632,16 @@ Event payload:`, event.payload);
623
632
  const model = useModel();
624
633
  return useMemo3(() => {
625
634
  const scoped = syncPersistedToken(model, name);
626
- return buildContextAccessor(model.context, scoped.getAdapters(), "mutateContext", (_descriptor, execute) => execute());
635
+ return buildContextAccessor(model.context, scoped.getAdapters(), "mutateContext", (descriptor, execute) => {
636
+ const result = execute();
637
+ if (result && typeof result.then === "function") {
638
+ return result.then(undefined, (err) => {
639
+ logMutationError(descriptor, err);
640
+ throw err;
641
+ });
642
+ }
643
+ return result;
644
+ });
627
645
  }, [model]);
628
646
  }
629
647
  return {
@@ -682,4 +700,4 @@ export {
682
700
  Form
683
701
  };
684
702
 
685
- //# debugId=4CA84684BEAF949D64756E2164756E21
703
+ //# debugId=288F1FEFD48F54D564756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-react",
3
3
  "type": "module",
4
- "version": "0.7.27",
4
+ "version": "0.7.28",
5
5
  "private": false,
6
6
  "author": "Przemysław Krasiński [arcote.tech]",
7
7
  "description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
@@ -32,7 +32,7 @@
32
32
  "typescript": "^5.2.2"
33
33
  },
34
34
  "peerDependencies": {
35
- "@arcote.tech/arc": "^0.7.27",
35
+ "@arcote.tech/arc": "^0.7.28",
36
36
  "react": "^18.0.0 || ^19.0.0",
37
37
  "react-dom": "^18.0.0 || ^19.0.0",
38
38
  "typescript": "^5.0.0"