palistor 0.0.25 → 0.0.26
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/README.md +574 -542
- package/README.ru.md +979 -0
- package/dist/index.d.ts +16 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -28
- package/dist/index.js.map +1 -1
- package/dist/react/createTrackingProxy.d.ts +27 -27
- package/dist/react/createTrackingProxy.d.ts.map +1 -1
- package/dist/react/createTrackingProxy.js +54 -53
- package/dist/react/createTrackingProxy.js.map +1 -1
- package/dist/react/useForm.d.ts +42 -43
- package/dist/react/useForm.d.ts.map +1 -1
- package/dist/react/useForm.js +38 -38
- package/dist/react/useForm.js.map +1 -1
- package/dist/react/usePersist.d.ts +14 -14
- package/dist/react/usePersist.js +18 -18
- package/dist/react/usePersist.js.map +1 -1
- package/dist/react/useStoreContext.d.ts +11 -11
- package/dist/react/useStoreContext.js +11 -11
- package/dist/react/useTranslator.d.ts +12 -12
- package/dist/react/useTranslator.js +12 -12
- package/dist/store/applyPatch/applyPatch.d.ts +8 -8
- package/dist/store/applyPatch/applyPatch.js +12 -12
- package/dist/store/applyPatch/applyPatch.js.map +1 -1
- package/dist/store/buildProxy/buildEntityProjectionProxy.js +6 -6
- package/dist/store/buildProxy/buildEntityProjectionProxy.js.map +1 -1
- package/dist/store/buildProxy/buildListProxy.d.ts +8 -8
- package/dist/store/buildProxy/buildListProxy.js +30 -30
- package/dist/store/buildProxy/buildListProxy.js.map +1 -1
- package/dist/store/buildProxy/buildProxy.d.ts +8 -8
- package/dist/store/buildProxy/buildProxy.js +39 -39
- package/dist/store/buildProxy/buildProxy.js.map +1 -1
- package/dist/store/buildProxy/computeProxyKeys.d.ts +8 -8
- package/dist/store/buildProxy/computeProxyKeys.js +9 -9
- package/dist/store/buildProxy/computeProxyKeys.js.map +1 -1
- package/dist/store/buildProxy/handleLazyResolve.d.ts +3 -3
- package/dist/store/buildProxy/handleLazyResolve.js +3 -3
- package/dist/store/buildProxy/initProxyCaches.d.ts +5 -5
- package/dist/store/buildProxy/initProxyCaches.js +5 -5
- package/dist/store/compute/computeFieldState.d.ts +3 -3
- package/dist/store/compute/computeFieldState.js +8 -8
- package/dist/store/compute/computeFieldState.js.map +1 -1
- package/dist/store/compute/fieldStateChanged.d.ts +1 -1
- package/dist/store/compute/fieldStateChanged.js +1 -1
- package/dist/store/compute/recompute/collectGroupComputeNodes.d.ts +4 -4
- package/dist/store/compute/recompute/collectGroupComputeNodes.js +7 -7
- package/dist/store/compute/recompute/collectGroupComputeNodes.js.map +1 -1
- package/dist/store/compute/recompute/recomputeAndNotify.d.ts +3 -3
- package/dist/store/compute/recompute/recomputeAndNotify.js +3 -3
- package/dist/store/compute/recompute/recomputeLeaves.d.ts +11 -10
- package/dist/store/compute/recompute/recomputeLeaves.d.ts.map +1 -1
- package/dist/store/compute/recompute/recomputeLeaves.js +26 -27
- package/dist/store/compute/recompute/recomputeLeaves.js.map +1 -1
- package/dist/store/compute/recompute/recomputeTargeted.d.ts +7 -7
- package/dist/store/compute/recompute/recomputeTargeted.js +12 -12
- package/dist/store/compute/recompute/recomputeTargeted.js.map +1 -1
- package/dist/store/compute/recompute/topologicalSortComputed.d.ts +4 -4
- package/dist/store/compute/recompute/topologicalSortComputed.d.ts.map +1 -1
- package/dist/store/compute/recompute/topologicalSortComputed.js +11 -13
- package/dist/store/compute/recompute/topologicalSortComputed.js.map +1 -1
- package/dist/store/compute/recompute/types.d.ts +4 -4
- package/dist/store/compute/resolveFlag.d.ts +2 -2
- package/dist/store/compute/resolveFlag.js +2 -2
- package/dist/store/compute/resolveString.d.ts +5 -5
- package/dist/store/compute/resolveString.js +6 -6
- package/dist/store/compute/resolveString.js.map +1 -1
- package/dist/store/compute/types.d.ts +3 -3
- package/dist/store/constants.d.ts +48 -48
- package/dist/store/constants.d.ts.map +1 -1
- package/dist/store/constants.js +45 -45
- package/dist/store/defineFieldMapping.d.ts +21 -19
- package/dist/store/defineFieldMapping.d.ts.map +1 -1
- package/dist/store/defineFieldMapping.js +21 -19
- package/dist/store/defineFieldMapping.js.map +1 -1
- package/dist/store/dirtyTracking/collectInitialSnapshot.js +1 -1
- package/dist/store/dirtyTracking/collectInitialSnapshot.js.map +1 -1
- package/dist/store/dirtyTracking/recomputeDirtyTargeted.d.ts +3 -3
- package/dist/store/dirtyTracking/recomputeDirtyTargeted.js +11 -11
- package/dist/store/dirtyTracking/recomputeDirtyTargeted.js.map +1 -1
- package/dist/store/dirtyTracking/setGroupRevalidate.d.ts +6 -6
- package/dist/store/dirtyTracking/setGroupRevalidate.js +7 -7
- package/dist/store/dirtyTracking/setGroupRevalidate.js.map +1 -1
- package/dist/store/entityRegistry/entityRegistry.d.ts +72 -72
- package/dist/store/entityRegistry/entityRegistry.d.ts.map +1 -1
- package/dist/store/entityRegistry/entityRegistry.js +91 -91
- package/dist/store/entityRegistry/entityRegistry.js.map +1 -1
- package/dist/store/entityRegistry/generateId.d.ts +3 -3
- package/dist/store/entityRegistry/generateId.js +3 -3
- package/dist/store/entityRegistry/types.d.ts +17 -17
- package/dist/store/entityRegistry/types.d.ts.map +1 -1
- package/dist/store/flow/buildFlowStepsProxy.d.ts +9 -9
- package/dist/store/flow/buildFlowStepsProxy.js +13 -13
- package/dist/store/flow/buildFlowStepsProxy.js.map +1 -1
- package/dist/store/flow/defineFlow.d.ts +27 -25
- package/dist/store/flow/defineFlow.d.ts.map +1 -1
- package/dist/store/flow/defineFlow.js +15 -13
- package/dist/store/flow/defineFlow.js.map +1 -1
- package/dist/store/flow/flowApi.d.ts +3 -2
- package/dist/store/flow/flowApi.d.ts.map +1 -1
- package/dist/store/flow/flowApi.js +1 -1
- package/dist/store/flow/flowApi.js.map +1 -1
- package/dist/store/flow/flowNavigation.d.ts +65 -63
- package/dist/store/flow/flowNavigation.d.ts.map +1 -1
- package/dist/store/flow/flowNavigation.js +74 -72
- package/dist/store/flow/flowNavigation.js.map +1 -1
- package/dist/store/flow/flowState.d.ts +16 -16
- package/dist/store/flow/flowState.d.ts.map +1 -1
- package/dist/store/flow/flowState.js +5 -5
- package/dist/store/flow/flowState.js.map +1 -1
- package/dist/store/groupDeps/createGroupDeps.d.ts +3 -3
- package/dist/store/groupDeps/createGroupDeps.js +6 -6
- package/dist/store/groupDeps/createGroupDeps.js.map +1 -1
- package/dist/store/groupDeps/createTrackingValues.d.ts +9 -9
- package/dist/store/groupDeps/createTrackingValues.js +11 -11
- package/dist/store/groupDeps/createTrackingValues.js.map +1 -1
- package/dist/store/groupDeps/getNodeGroupPath.d.ts +3 -3
- package/dist/store/groupDeps/getNodeGroupPath.js +5 -5
- package/dist/store/groupDeps/getNodeGroupPath.js.map +1 -1
- package/dist/store/groupDeps/getRecipientGroups.d.ts +1 -1
- package/dist/store/groupDeps/getRecipientGroups.js +1 -1
- package/dist/store/groupDeps/groupDeps.d.ts +7 -7
- package/dist/store/groupDeps/groupDeps.js +7 -7
- package/dist/store/groupDeps/pairKey.d.ts +3 -3
- package/dist/store/groupDeps/pairKey.d.ts.map +1 -1
- package/dist/store/groupDeps/pairKey.js +4 -4
- package/dist/store/groupDeps/pairKey.js.map +1 -1
- package/dist/store/groupDeps/resolveGroupByPath.d.ts +3 -3
- package/dist/store/groupDeps/resolveGroupByPath.js +3 -3
- package/dist/store/init/createNotificationHub.d.ts +31 -31
- package/dist/store/init/createNotificationHub.d.ts.map +1 -1
- package/dist/store/init/createNotificationHub.js +36 -37
- package/dist/store/init/createNotificationHub.js.map +1 -1
- package/dist/store/init/createResolveManager.d.ts +72 -69
- package/dist/store/init/createResolveManager.d.ts.map +1 -1
- package/dist/store/init/createResolveManager.js +101 -98
- package/dist/store/init/createResolveManager.js.map +1 -1
- package/dist/store/init/initGroupSubmitting.d.ts +2 -2
- package/dist/store/init/initGroupSubmitting.js +4 -4
- package/dist/store/init/initGroupSubmitting.js.map +1 -1
- package/dist/store/normalizeConfig.d.ts +20 -18
- package/dist/store/normalizeConfig.d.ts.map +1 -1
- package/dist/store/normalizeConfig.js +31 -29
- package/dist/store/normalizeConfig.js.map +1 -1
- package/dist/store/onChangePipeline/computeFieldKey.d.ts +2 -2
- package/dist/store/onChangePipeline/computeFieldKey.js +2 -2
- package/dist/store/onChangePipeline/findOnChangeAncestors.d.ts +2 -2
- package/dist/store/onChangePipeline/findOnChangeAncestors.js +4 -4
- package/dist/store/onChangePipeline/findOnChangeAncestors.js.map +1 -1
- package/dist/store/onChangePipeline/onChangePipeline.d.ts +13 -12
- package/dist/store/onChangePipeline/onChangePipeline.d.ts.map +1 -1
- package/dist/store/onChangePipeline/onChangePipeline.js +14 -13
- package/dist/store/onChangePipeline/onChangePipeline.js.map +1 -1
- package/dist/store/persist/drivers.d.ts +7 -7
- package/dist/store/persist/drivers.js +8 -8
- package/dist/store/persist/drivers.js.map +1 -1
- package/dist/store/persist/index.d.ts +1 -1
- package/dist/store/persist/persistManager.d.ts +23 -23
- package/dist/store/persist/persistManager.d.ts.map +1 -1
- package/dist/store/persist/persistManager.js +51 -51
- package/dist/store/persist/persistManager.js.map +1 -1
- package/dist/store/persist/types.d.ts +23 -23
- package/dist/store/persist/types.d.ts.map +1 -1
- package/dist/store/persist/types.js +4 -4
- package/dist/store/resetPipeline/buildResetPatch.d.ts +5 -5
- package/dist/store/resetPipeline/buildResetPatch.js +5 -5
- package/dist/store/resetPipeline/collectDefaults.d.ts +5 -5
- package/dist/store/resetPipeline/collectDefaults.js +6 -6
- package/dist/store/resetPipeline/collectDefaults.js.map +1 -1
- package/dist/store/resetPipeline/resetPipeline.d.ts +7 -7
- package/dist/store/resetPipeline/resetPipeline.js +15 -15
- package/dist/store/resetPipeline/resetPipeline.js.map +1 -1
- package/dist/store/resolvePipeline/applyPendingWrites.d.ts +10 -10
- package/dist/store/resolvePipeline/applyPendingWrites.d.ts.map +1 -1
- package/dist/store/resolvePipeline/applyPendingWrites.js +35 -38
- package/dist/store/resolvePipeline/applyPendingWrites.js.map +1 -1
- package/dist/store/resolvePipeline/createContextTrackingProxy.d.ts +8 -7
- package/dist/store/resolvePipeline/createContextTrackingProxy.d.ts.map +1 -1
- package/dist/store/resolvePipeline/createContextTrackingProxy.js +6 -5
- package/dist/store/resolvePipeline/createContextTrackingProxy.js.map +1 -1
- package/dist/store/resolvePipeline/createValuesTrackingProxy.d.ts +43 -43
- package/dist/store/resolvePipeline/createValuesTrackingProxy.d.ts.map +1 -1
- package/dist/store/resolvePipeline/createValuesTrackingProxy.js +70 -70
- package/dist/store/resolvePipeline/createValuesTrackingProxy.js.map +1 -1
- package/dist/store/resolvePipeline/executeListResolve.d.ts +14 -14
- package/dist/store/resolvePipeline/executeListResolve.js +27 -27
- package/dist/store/resolvePipeline/executeListResolve.js.map +1 -1
- package/dist/store/resolvePipeline/executeResolve.d.ts +15 -15
- package/dist/store/resolvePipeline/executeResolve.js +46 -46
- package/dist/store/resolvePipeline/executeResolve.js.map +1 -1
- package/dist/store/store/NodeRegistry/nodeRegistry.d.ts +61 -61
- package/dist/store/store/NodeRegistry/nodeRegistry.d.ts.map +1 -1
- package/dist/store/store/NodeRegistry/nodeRegistry.js +85 -86
- package/dist/store/store/NodeRegistry/nodeRegistry.js.map +1 -1
- package/dist/store/store/NodeRegistry/nodeUtils.d.ts +5 -5
- package/dist/store/store/NodeRegistry/nodeUtils.d.ts.map +1 -1
- package/dist/store/store/NodeRegistry/nodeUtils.js +5 -5
- package/dist/store/store/NodeRegistry/nodeUtils.js.map +1 -1
- package/dist/store/store/groupDepsMap.d.ts +23 -23
- package/dist/store/store/groupDepsMap.d.ts.map +1 -1
- package/dist/store/store/groupDepsMap.js +35 -34
- package/dist/store/store/groupDepsMap.js.map +1 -1
- package/dist/store/store/hasComputedProps.d.ts +2 -2
- package/dist/store/store/hasComputedProps.js +2 -2
- package/dist/store/store/nodeMap.d.ts +5 -5
- package/dist/store/store/nodeMap.js +7 -7
- package/dist/store/store/nodeMap.js.map +1 -1
- package/dist/store/store/palistor.d.ts +80 -80
- package/dist/store/store/palistor.d.ts.map +1 -1
- package/dist/store/store/palistor.js +149 -169
- package/dist/store/store/palistor.js.map +1 -1
- package/dist/store/store/registerNodes.d.ts +10 -10
- package/dist/store/store/registerNodes.js +15 -15
- package/dist/store/store/registerNodes.js.map +1 -1
- package/dist/store/store/serviceRegistry.d.ts +8 -8
- package/dist/store/store/serviceRegistry.d.ts.map +1 -1
- package/dist/store/store/serviceRegistry.js +8 -8
- package/dist/store/store/serviceRegistry.js.map +1 -1
- package/dist/store/store/types.d.ts +236 -234
- package/dist/store/store/types.d.ts.map +1 -1
- package/dist/store/submitPipeline/applyLeafBeforeSubmit.d.ts +2 -2
- package/dist/store/submitPipeline/applyLeafBeforeSubmit.js +2 -2
- package/dist/store/submitPipeline/collectLeafStates.d.ts +2 -2
- package/dist/store/submitPipeline/collectLeafStates.js +2 -2
- package/dist/store/submitPipeline/submitPipeline.d.ts +8 -8
- package/dist/store/submitPipeline/submitPipeline.js +12 -12
- package/dist/store/submitPipeline/submitPipeline.js.map +1 -1
- package/dist/store/submitPipeline/types.d.ts +1 -1
- package/dist/store/submitPipeline/types.d.ts.map +1 -1
- package/dist/store/traversal/nodeClassifier.d.ts +9 -9
- package/dist/store/traversal/nodeClassifier.d.ts.map +1 -1
- package/dist/store/traversal/nodeClassifier.js +11 -11
- package/dist/store/traversal/nodeClassifier.js.map +1 -1
- package/dist/store/traversal/walkFull.d.ts +14 -14
- package/dist/store/traversal/walkFull.js +2 -2
- package/dist/store/valuesCache/valuesCache.d.ts +9 -9
- package/dist/store/valuesCache/valuesCache.d.ts.map +1 -1
- package/dist/store/valuesCache/valuesCache.js +6 -6
- package/dist/store/writePipeline/formatPatch.d.ts +5 -5
- package/dist/store/writePipeline/formatPatch.js +7 -7
- package/dist/store/writePipeline/formatPatch.js.map +1 -1
- package/dist/store/writePipeline/formatValue.d.ts +5 -5
- package/dist/store/writePipeline/formatValue.js +5 -5
- package/dist/store/writePipeline/mergeChanged.d.ts +4 -4
- package/dist/store/writePipeline/mergeChanged.js +4 -4
- package/dist/store/writePipeline/runSetter.d.ts +6 -6
- package/dist/store/writePipeline/runSetter.js +8 -8
- package/dist/store/writePipeline/storeValue.d.ts +3 -3
- package/dist/store/writePipeline/storeValue.js +3 -3
- package/dist/store/writePipeline/types.d.ts +4 -4
- package/dist/store/writePipeline/types.d.ts.map +1 -1
- package/dist/store/writePipeline/writePipeline.d.ts +7 -7
- package/dist/store/writePipeline/writePipeline.d.ts.map +1 -1
- package/dist/store/writePipeline/writePipeline.js +15 -15
- package/dist/store/writePipeline/writePipeline.js.map +1 -1
- package/package.json +11 -4
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PersistManager —
|
|
2
|
+
* PersistManager — manages hydration and auto-saving of form state.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Instantiated inside Palistor.
|
|
5
|
+
* React-independent — can be wired up from any environment.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* 1.
|
|
9
|
-
* 2.
|
|
10
|
-
* 3.
|
|
7
|
+
* Lifecycle:
|
|
8
|
+
* 1. Created by new Palistor(...) (inactive).
|
|
9
|
+
* 2. Activated via enable(options) — hydration + auto-save.
|
|
10
|
+
* 3. Deactivated via disable() — unsubscribes from the store, cancels timers.
|
|
11
11
|
*/
|
|
12
12
|
import { applyPatch } from "../applyPatch/applyPatch";
|
|
13
13
|
import { recomputeAndNotify } from "../compute/recompute";
|
|
14
14
|
import { restoreFlowNav, runFlowEntryLifecycle, serializeFlowNav, } from "../flow/flowNavigation";
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Reserved persist-snapshot key for flow navigation (defineFlow):
|
|
17
17
|
* `{ [flowPath]: { currentStepKey, visitStack, visitedKeys } }`.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Step field values are stored as regular values; step statuses are not
|
|
19
|
+
* saved — derived from navigation on hydrate.
|
|
20
20
|
*/
|
|
21
21
|
const FLOWS_PERSIST_KEY = "__flows";
|
|
22
|
-
// ───
|
|
22
|
+
// ─── Field filtering ─────────────────────────────────────────────────────────
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* pick
|
|
24
|
+
* Filter values by pick/omit.
|
|
25
|
+
* pick takes priority. When neither is set — everything is returned.
|
|
26
26
|
*/
|
|
27
27
|
function filterValues(values, pick, omit) {
|
|
28
28
|
if (pick && pick.length > 0) {
|
|
@@ -44,29 +44,29 @@ function filterValues(values, pick, omit) {
|
|
|
44
44
|
}
|
|
45
45
|
return values;
|
|
46
46
|
}
|
|
47
|
-
// ───
|
|
47
|
+
// ─── Class ───────────────────────────────────────────────────────────────────
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* The form's persistence manager.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
51
|
+
* Accesses all form data through the `kernel` (Palistor instance).
|
|
52
52
|
*/
|
|
53
53
|
export class PersistManager {
|
|
54
54
|
constructor(kernel) {
|
|
55
|
-
// ───
|
|
55
|
+
// ─── Internal state ───────────────────────────────────────────────────────
|
|
56
56
|
this.active = false;
|
|
57
57
|
this.currentKey = null;
|
|
58
58
|
this.currentDriver = null;
|
|
59
59
|
this.serialize = JSON.stringify;
|
|
60
60
|
this.deserialize = JSON.parse;
|
|
61
61
|
this.debounceMs = 100;
|
|
62
|
-
/**
|
|
62
|
+
/** Unsubscribe from subscribeGlobal. */
|
|
63
63
|
this.unsubscribe = null;
|
|
64
|
-
/**
|
|
64
|
+
/** Debounce timer ID. */
|
|
65
65
|
this.debounceTimer = null;
|
|
66
|
-
/**
|
|
66
|
+
/** Flag preventing saves during hydration. */
|
|
67
67
|
this.isHydrating = false;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Schedule a debounced save.
|
|
70
70
|
*/
|
|
71
71
|
this.scheduleSave = () => {
|
|
72
72
|
if (!this.active || this.isHydrating)
|
|
@@ -83,7 +83,7 @@ export class PersistManager {
|
|
|
83
83
|
};
|
|
84
84
|
this.kernel = kernel;
|
|
85
85
|
}
|
|
86
|
-
// ───
|
|
86
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
87
87
|
cancelDebounce() {
|
|
88
88
|
if (this.debounceTimer !== null) {
|
|
89
89
|
clearTimeout(this.debounceTimer);
|
|
@@ -91,15 +91,15 @@ export class PersistManager {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
94
|
+
* Save the current values to storage (no debounce).
|
|
95
95
|
*/
|
|
96
96
|
async saveToStorage() {
|
|
97
97
|
if (!this.active || !this.currentKey || !this.currentDriver)
|
|
98
98
|
return;
|
|
99
99
|
const allValues = this.kernel.getValues();
|
|
100
100
|
const filtered = filterValues(allValues, this.pickFields, this.omitFields);
|
|
101
|
-
// Flow:
|
|
102
|
-
//
|
|
101
|
+
// Flow: navigation is stored under a separate reserved key, not subject
|
|
102
|
+
// to pick/omit (it is not a form field).
|
|
103
103
|
const flowNav = serializeFlowNav(this.kernel);
|
|
104
104
|
const payload = flowNav ? { ...filtered, [FLOWS_PERSIST_KEY]: flowNav } : filtered;
|
|
105
105
|
try {
|
|
@@ -107,11 +107,11 @@ export class PersistManager {
|
|
|
107
107
|
await Promise.resolve(this.currentDriver.setItem(this.currentKey, serialized));
|
|
108
108
|
}
|
|
109
109
|
catch {
|
|
110
|
-
//
|
|
110
|
+
// Serialization/write errors are silenced (production-safe)
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Read from storage and apply the values to nodeState.
|
|
115
115
|
*/
|
|
116
116
|
async hydrateFromStorage() {
|
|
117
117
|
if (!this.currentKey || !this.currentDriver)
|
|
@@ -128,21 +128,21 @@ export class PersistManager {
|
|
|
128
128
|
this.isHydrating = false;
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
// Flow:
|
|
131
|
+
// Flow: extract the navigation snapshot before applying the values patch.
|
|
132
132
|
const flowSnapshots = values[FLOWS_PERSIST_KEY];
|
|
133
133
|
if (flowSnapshots !== undefined) {
|
|
134
134
|
delete values[FLOWS_PERSIST_KEY];
|
|
135
135
|
}
|
|
136
|
-
//
|
|
137
|
-
// (
|
|
136
|
+
// Apply as a patch — applyPatch walks the config tree recursively
|
|
137
|
+
// (scalar/group fields; list nodes are skipped).
|
|
138
138
|
const patchedNodes = applyPatch(this.kernel.rootConfig, this.kernel.nodes.nodeState, values, new Set());
|
|
139
|
-
//
|
|
140
|
-
//
|
|
139
|
+
// Restore root and per-entity list membership from the snapshot.
|
|
140
|
+
// No-op for configs without lists (graceful for older snapshots).
|
|
141
141
|
const listChanged = this.kernel.restoreLists(values);
|
|
142
142
|
for (const n of listChanged)
|
|
143
143
|
patchedNodes.add(n);
|
|
144
|
-
// Flow:
|
|
145
|
-
//
|
|
144
|
+
// Flow: restore navigation (active step, stack, visited).
|
|
145
|
+
// Step statuses are recomputed from the navigation state.
|
|
146
146
|
let enteredFlows = [];
|
|
147
147
|
if (flowSnapshots && typeof flowSnapshots === "object") {
|
|
148
148
|
const { changed: flowChanged, entered } = restoreFlowNav(this.kernel, flowSnapshots);
|
|
@@ -150,33 +150,33 @@ export class PersistManager {
|
|
|
150
150
|
patchedNodes.add(n);
|
|
151
151
|
enteredFlows = entered;
|
|
152
152
|
}
|
|
153
|
-
//
|
|
153
|
+
// Recompute, merge, and notify subscribers
|
|
154
154
|
recomputeAndNotify(patchedNodes, () => this.kernel.recompute(), (c) => this.kernel.notifyChanged(c));
|
|
155
|
-
// Flow:
|
|
156
|
-
//
|
|
155
|
+
// Flow: when the active step changed during hydration — the restored
|
|
156
|
+
// step is "entered" anew: onEnter → resolve → onReady.
|
|
157
157
|
for (const flowState of enteredFlows) {
|
|
158
158
|
runFlowEntryLifecycle(this.kernel, flowState);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
catch {
|
|
162
|
-
//
|
|
162
|
+
// Deserialization errors are silenced
|
|
163
163
|
}
|
|
164
164
|
finally {
|
|
165
165
|
this.isHydrating = false;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
// ───
|
|
168
|
+
// ─── Public API ────────────────────────────────────────────────────────────
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
170
|
+
* Activate persistence: hydrate from storage + auto-save on changes.
|
|
171
171
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
172
|
+
* When persist is already active, the previous one is disabled first.
|
|
173
|
+
* Returns a Promise that resolves after successful hydration.
|
|
174
174
|
*/
|
|
175
175
|
enable(options) {
|
|
176
|
-
//
|
|
176
|
+
// Already active — disable the previous one
|
|
177
177
|
if (this.active)
|
|
178
178
|
this.disable();
|
|
179
|
-
//
|
|
179
|
+
// Store the settings
|
|
180
180
|
this.currentKey = options.key;
|
|
181
181
|
this.currentDriver = options.driver;
|
|
182
182
|
this.serialize = options.serialize ?? JSON.stringify;
|
|
@@ -185,12 +185,12 @@ export class PersistManager {
|
|
|
185
185
|
this.pickFields = options.pick;
|
|
186
186
|
this.omitFields = options.omit;
|
|
187
187
|
this.active = true;
|
|
188
|
-
//
|
|
188
|
+
// Subscribe to changes for auto-save
|
|
189
189
|
this.unsubscribe = this.kernel.hub.subscribeGlobal(this.scheduleSave);
|
|
190
|
-
//
|
|
190
|
+
// Hydrate
|
|
191
191
|
return this.hydrateFromStorage();
|
|
192
192
|
}
|
|
193
|
-
/**
|
|
193
|
+
/** Deactivate: unsubscribe from the store, cancel timers, clear state. */
|
|
194
194
|
disable() {
|
|
195
195
|
this.active = false;
|
|
196
196
|
this.cancelDebounce();
|
|
@@ -201,16 +201,16 @@ export class PersistManager {
|
|
|
201
201
|
this.currentKey = null;
|
|
202
202
|
this.currentDriver = null;
|
|
203
203
|
}
|
|
204
|
-
/**
|
|
204
|
+
/** Force-save the current values to storage (no debounce). */
|
|
205
205
|
async flush() {
|
|
206
206
|
this.cancelDebounce();
|
|
207
207
|
await this.saveToStorage();
|
|
208
208
|
}
|
|
209
|
-
/**
|
|
209
|
+
/** Force-hydrate from storage. */
|
|
210
210
|
async hydrate() {
|
|
211
211
|
await this.hydrateFromStorage();
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
213
|
+
/** Remove the data from storage under the current key. */
|
|
214
214
|
async clear() {
|
|
215
215
|
if (!this.currentKey || !this.currentDriver)
|
|
216
216
|
return;
|
|
@@ -221,7 +221,7 @@ export class PersistManager {
|
|
|
221
221
|
// noop
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
/**
|
|
224
|
+
/** Whether persistence is currently active. */
|
|
225
225
|
isEnabled() {
|
|
226
226
|
return this.active;
|
|
227
227
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistManager.js","sourceRoot":"","sources":["../../../store/persist/persistManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,gFAAgF;AAEhF;;;GAGG;AACH,SAAS,YAAY,CACnB,MAA+B,EAC/B,IAAe,EACf,IAAe;IAEf,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,GAAG,IAAI,MAAM;gBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;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O,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACxE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Persist —
|
|
2
|
+
* Persist — the abstract storage driver interface and persistence options.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A driver can be synchronous (localStorage) or asynchronous (IndexedDB).
|
|
5
|
+
* All methods return `T | Promise<T>` — the persist manager handles both
|
|
6
|
+
* uniformly via `Promise.resolve()`.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Storage driver interface.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* localStorage, sessionStorage, IndexedDB, AsyncStorage,
|
|
11
|
+
* Implement this interface for any backend:
|
|
12
|
+
* localStorage, sessionStorage, IndexedDB, AsyncStorage, the file system, etc.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
@@ -21,45 +21,45 @@
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export interface PersistDriver {
|
|
24
|
-
/**
|
|
24
|
+
/** Read a value by key. `null` when not found. */
|
|
25
25
|
getItem(key: string): string | null | Promise<string | null>;
|
|
26
|
-
/**
|
|
26
|
+
/** Write a value by key. */
|
|
27
27
|
setItem(key: string, value: string): void | Promise<void>;
|
|
28
|
-
/**
|
|
28
|
+
/** Remove a value by key. */
|
|
29
29
|
removeItem(key: string): void | Promise<void>;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Persistence options for the ProxyStore.
|
|
33
33
|
*
|
|
34
|
-
* @template TValues —
|
|
34
|
+
* @template TValues — the form values type
|
|
35
35
|
*/
|
|
36
36
|
export interface PersistOptions<TValues = Record<string, unknown>> {
|
|
37
|
-
/**
|
|
37
|
+
/** Unique storage key. */
|
|
38
38
|
key: string;
|
|
39
|
-
/**
|
|
39
|
+
/** Storage driver (localStorage, IndexedDB, …). */
|
|
40
40
|
driver: PersistDriver;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Custom serializer (defaults to `JSON.stringify`).
|
|
43
|
+
* Useful for binary formats, encryption, etc.
|
|
44
44
|
*/
|
|
45
45
|
serialize?: (values: Partial<TValues>) => string;
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Custom deserializer (defaults to `JSON.parse`).
|
|
48
48
|
*/
|
|
49
49
|
deserialize?: (raw: string) => Partial<TValues>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* Write delay in ms (debounce). Default 100 ms.
|
|
52
|
+
* Set 0 for immediate writes.
|
|
53
53
|
*/
|
|
54
54
|
debounce?: number;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* Persist only the listed top-level fields.
|
|
57
|
+
* When set, `omit` is ignored.
|
|
58
58
|
*/
|
|
59
59
|
pick?: (keyof TValues & string)[];
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* Exclude the listed top-level fields from persistence.
|
|
62
|
+
* Ignored when `pick` is set.
|
|
63
63
|
*/
|
|
64
64
|
omit?: (keyof TValues & string)[];
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../store/persist/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../store/persist/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE7D,4BAA4B;IAC5B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,6BAA6B;IAC7B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAID;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IAEZ,mDAAmD;IACnD,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC;IAEjD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC;IAElC;;;OAGG;IACH,IAAI,CAAC,EAAE,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC;CACnC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Persist —
|
|
2
|
+
* Persist — the abstract storage driver interface and persistence options.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* A driver can be synchronous (localStorage) or asynchronous (IndexedDB).
|
|
5
|
+
* All methods return `T | Promise<T>` — the persist manager handles both
|
|
6
|
+
* uniformly via `Promise.resolve()`.
|
|
7
7
|
*/
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AnyConfigNode } from "../store/types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Builds the patch for a group reset.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* 1.
|
|
7
|
-
* 2.
|
|
8
|
-
*
|
|
5
|
+
* Priority:
|
|
6
|
+
* 1. Explicit `values` → used as the patch directly.
|
|
7
|
+
* 2. Otherwise the initial snapshot (or config defaults as a fallback),
|
|
8
|
+
* then the group's reset transformer (if any) is applied.
|
|
9
9
|
*/
|
|
10
10
|
export declare function buildResetPatch(groupNode: AnyConfigNode, initialValueMap: WeakMap<object, unknown> | undefined, values: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
11
11
|
//# sourceMappingURL=buildResetPatch.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { collectDefaults } from "./collectDefaults";
|
|
2
2
|
import { collectInitialSnapshot } from "../dirtyTracking";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Builds the patch for a group reset.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* 1.
|
|
8
|
-
* 2.
|
|
9
|
-
*
|
|
6
|
+
* Priority:
|
|
7
|
+
* 1. Explicit `values` → used as the patch directly.
|
|
8
|
+
* 2. Otherwise the initial snapshot (or config defaults as a fallback),
|
|
9
|
+
* then the group's reset transformer (if any) is applied.
|
|
10
10
|
*/
|
|
11
11
|
export function buildResetPatch(groupNode, initialValueMap, values) {
|
|
12
12
|
if (values !== undefined)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AnyConfigNode } from "../store/types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Recursively collects default values from the config.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
5
|
+
* For leaf nodes:
|
|
6
|
+
* - static value → taken as-is
|
|
7
|
+
* - function (computed) → "" as a fallback
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Stops at nested groups with their own `reset` (reset boundary).
|
|
10
10
|
*/
|
|
11
11
|
export declare function collectDefaults(node: AnyConfigNode): Record<string, unknown>;
|
|
12
12
|
//# sourceMappingURL=collectDefaults.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { configKeys, isLeafNode, isListNode } from "../traversal";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Recursively collects default values from the config.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
5
|
+
* For leaf nodes:
|
|
6
|
+
* - static value → taken as-is
|
|
7
|
+
* - function (computed) → "" as a fallback
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Stops at nested groups with their own `reset` (reset boundary).
|
|
10
10
|
*/
|
|
11
11
|
export function collectDefaults(node) {
|
|
12
12
|
const result = {};
|
|
@@ -15,7 +15,7 @@ export function collectDefaults(node) {
|
|
|
15
15
|
if (!child || typeof child !== "object")
|
|
16
16
|
continue;
|
|
17
17
|
if (isListNode(child))
|
|
18
|
-
continue; // ListNode —
|
|
18
|
+
continue; // ListNode — skipped, restored separately
|
|
19
19
|
if (isLeafNode(child)) {
|
|
20
20
|
const raw = child.value;
|
|
21
21
|
result[key] = typeof raw === "function" ? "" : raw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectDefaults.js","sourceRoot":"","sources":["../../../store/resetPipeline/collectDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGlE;;;;;;;;GAQG;AACH,MAAM,UAAU,eA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AC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { AnyConfigNode } from "../store/types";
|
|
2
2
|
import type { Palistor } from "../store/palistor";
|
|
3
3
|
/**
|
|
4
|
-
* ResetPipeline —
|
|
4
|
+
* ResetPipeline — resets a group node's values.
|
|
5
5
|
*
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
6
|
+
* - When `values` is passed explicitly — applied as a patch (new baseline → dirty = false).
|
|
7
|
+
* - Otherwise the initial snapshot is restored (or config defaults as a
|
|
8
|
+
* fallback), optionally transformed by the group's reset function.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* - revalidate = false (
|
|
12
|
-
* -
|
|
10
|
+
* After the reset:
|
|
11
|
+
* - revalidate = false (validation mode cleared)
|
|
12
|
+
* - full recompute of computed props + subscriber notification
|
|
13
13
|
*/
|
|
14
14
|
export declare class ResetPipeline {
|
|
15
15
|
private readonly kernel;
|
|
@@ -4,15 +4,15 @@ import { recomputeAndNotify } from "../compute/recompute";
|
|
|
4
4
|
import { buildResetPatch } from "./buildResetPatch";
|
|
5
5
|
import { resetFlowNavForSubtree } from "../flow/flowNavigation";
|
|
6
6
|
/**
|
|
7
|
-
* ResetPipeline —
|
|
7
|
+
* ResetPipeline — resets a group node's values.
|
|
8
8
|
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
9
|
+
* - When `values` is passed explicitly — applied as a patch (new baseline → dirty = false).
|
|
10
|
+
* - Otherwise the initial snapshot is restored (or config defaults as a
|
|
11
|
+
* fallback), optionally transformed by the group's reset function.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
* - revalidate = false (
|
|
15
|
-
* -
|
|
13
|
+
* After the reset:
|
|
14
|
+
* - revalidate = false (validation mode cleared)
|
|
15
|
+
* - full recompute of computed props + subscriber notification
|
|
16
16
|
*/
|
|
17
17
|
export class ResetPipeline {
|
|
18
18
|
constructor(kernel) {
|
|
@@ -22,16 +22,16 @@ export class ResetPipeline {
|
|
|
22
22
|
const nodeState = this.kernel.nodes.nodeState;
|
|
23
23
|
const initialValueMap = this.kernel.dirty.initialValueMap;
|
|
24
24
|
const valuesCache = this.kernel.values;
|
|
25
|
-
//
|
|
26
|
-
//
|
|
25
|
+
// On a full form reset, clear entity-field resolve states so they run
|
|
26
|
+
// again when entities are loaded through the list resolver.
|
|
27
27
|
if (groupNode === this.kernel.rootConfig) {
|
|
28
28
|
this.kernel.resolveManager.entityStates.clearAll();
|
|
29
29
|
}
|
|
30
30
|
const patch = buildResetPatch(groupNode, initialValueMap, values);
|
|
31
31
|
const changed = applyPatch(groupNode, nodeState, patch, new Set(), valuesCache);
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
32
|
+
// On a full reset, restore per-entity list membership to initial and bump
|
|
33
|
+
// their EntityListState versions → React redraws the lists. The owner's
|
|
34
|
+
// projectionObj is re-synced so getValues() returns the initial state.
|
|
35
35
|
if (groupNode === this.kernel.rootConfig) {
|
|
36
36
|
for (const { state } of this.kernel.entityRegistry.resetEntityListStates()) {
|
|
37
37
|
this.kernel.syncListValuesCache(state);
|
|
@@ -45,9 +45,9 @@ export class ResetPipeline {
|
|
|
45
45
|
for (const n of revalidateChanged)
|
|
46
46
|
changed.add(n);
|
|
47
47
|
recomputeAndNotify(changed, () => this.kernel.recompute(), (c) => this.kernel.notifyChanged(c));
|
|
48
|
-
// Flow:
|
|
49
|
-
//
|
|
50
|
-
//
|
|
48
|
+
// Flow: reset flow navigation inside the reset subtree — the first step is
|
|
49
|
+
// active again, step resolve states go idle, and the first step's entry
|
|
50
|
+
// lifecycle runs anew.
|
|
51
51
|
resetFlowNavForSubtree(this.kernel, groupNode);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPipeline.js","sourceRoot":"","sources":["../../../store/resetPipeline/resetPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,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