@yiin/reactive-proxy-state 1.0.35 → 1.0.36
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/index.cjs +5 -2
- package/dist/index.js +5 -2
- package/dist/integrations/vue3.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4030,7 +4030,7 @@ function markRaw(obj) {
|
|
|
4030
4030
|
var import_vue = require("vue");
|
|
4031
4031
|
var import_reactivity = __toESM(require_reactivity_cjs(), 1);
|
|
4032
4032
|
function trackVueReactiveEvents(vueState, emit, options = {}) {
|
|
4033
|
-
const { emitInitialReplace = true } = options;
|
|
4033
|
+
const { emitInitialReplace = true, onDiffError } = options;
|
|
4034
4034
|
if (emitInitialReplace) {
|
|
4035
4035
|
try {
|
|
4036
4036
|
emit({ action: "replace", path: [], newValue: deepClone(vueState) });
|
|
@@ -4054,9 +4054,12 @@ function trackVueReactiveEvents(vueState, emit, options = {}) {
|
|
|
4054
4054
|
prev[k] = result;
|
|
4055
4055
|
}
|
|
4056
4056
|
} catch (e) {
|
|
4057
|
-
|
|
4057
|
+
const errorPath = pathStack.slice();
|
|
4058
4058
|
pathStack.length = 0;
|
|
4059
4059
|
prev[k] = deepClone(vueState[k]);
|
|
4060
|
+
if (onDiffError) {
|
|
4061
|
+
onDiffError({ key: k, path: errorPath, error: e });
|
|
4062
|
+
}
|
|
4060
4063
|
return;
|
|
4061
4064
|
}
|
|
4062
4065
|
pathStack.pop();
|
package/dist/index.js
CHANGED
|
@@ -3970,7 +3970,7 @@ function markRaw(obj) {
|
|
|
3970
3970
|
var import_reactivity = __toESM(require_reactivity_cjs(), 1);
|
|
3971
3971
|
import { watchEffect as watchEffect2 } from "vue";
|
|
3972
3972
|
function trackVueReactiveEvents(vueState, emit, options = {}) {
|
|
3973
|
-
const { emitInitialReplace = true } = options;
|
|
3973
|
+
const { emitInitialReplace = true, onDiffError } = options;
|
|
3974
3974
|
if (emitInitialReplace) {
|
|
3975
3975
|
try {
|
|
3976
3976
|
emit({ action: "replace", path: [], newValue: deepClone(vueState) });
|
|
@@ -3994,9 +3994,12 @@ function trackVueReactiveEvents(vueState, emit, options = {}) {
|
|
|
3994
3994
|
prev[k] = result;
|
|
3995
3995
|
}
|
|
3996
3996
|
} catch (e) {
|
|
3997
|
-
|
|
3997
|
+
const errorPath = pathStack.slice();
|
|
3998
3998
|
pathStack.length = 0;
|
|
3999
3999
|
prev[k] = deepClone(vueState[k]);
|
|
4000
|
+
if (onDiffError) {
|
|
4001
|
+
onDiffError({ key: k, path: errorPath, error: e });
|
|
4002
|
+
}
|
|
4000
4003
|
return;
|
|
4001
4004
|
}
|
|
4002
4005
|
pathStack.pop();
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { StateEvent } from "../types";
|
|
2
|
+
export type DiffErrorContext = {
|
|
3
|
+
key: string;
|
|
4
|
+
path: (string | number | symbol)[];
|
|
5
|
+
error: unknown;
|
|
6
|
+
};
|
|
2
7
|
export type TrackVueReactiveEventsOptions = {
|
|
3
8
|
emitInitialReplace?: boolean;
|
|
9
|
+
onDiffError?: (ctx: DiffErrorContext) => void;
|
|
4
10
|
};
|
|
5
11
|
/**
|
|
6
12
|
* Observe a Vue 3 reactive object and emit RPS-compatible StateEvents
|