palistor 0.0.24 → 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 +19 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -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 +92 -42
- 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.d.ts.map +1 -1
- package/dist/store/buildProxy/buildProxy.js +84 -33
- package/dist/store/buildProxy/buildProxy.js.map +1 -1
- package/dist/store/buildProxy/computeProxyKeys.d.ts +8 -8
- package/dist/store/buildProxy/computeProxyKeys.d.ts.map +1 -1
- package/dist/store/buildProxy/computeProxyKeys.js +18 -13
- 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 +57 -38
- package/dist/store/constants.d.ts.map +1 -1
- package/dist/store/constants.js +70 -35
- package/dist/store/constants.js.map +1 -1
- 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 +17 -0
- package/dist/store/flow/buildFlowStepsProxy.d.ts.map +1 -0
- package/dist/store/flow/buildFlowStepsProxy.js +72 -0
- package/dist/store/flow/buildFlowStepsProxy.js.map +1 -0
- package/dist/store/flow/defineFlow.d.ts +92 -0
- package/dist/store/flow/defineFlow.d.ts.map +1 -0
- package/dist/store/flow/defineFlow.js +99 -0
- package/dist/store/flow/defineFlow.js.map +1 -0
- package/dist/store/flow/flowApi.d.ts +18 -0
- package/dist/store/flow/flowApi.d.ts.map +1 -0
- package/dist/store/flow/flowApi.js +18 -0
- package/dist/store/flow/flowApi.js.map +1 -0
- package/dist/store/flow/flowNavigation.d.ts +137 -0
- package/dist/store/flow/flowNavigation.d.ts.map +1 -0
- package/dist/store/flow/flowNavigation.js +384 -0
- package/dist/store/flow/flowNavigation.js.map +1 -0
- package/dist/store/flow/flowState.d.ts +41 -0
- package/dist/store/flow/flowState.d.ts.map +1 -0
- package/dist/store/flow/flowState.js +51 -0
- package/dist/store/flow/flowState.js.map +1 -0
- package/dist/store/flow/index.d.ts +10 -0
- package/dist/store/flow/index.d.ts.map +1 -0
- package/dist/store/flow/index.js +6 -0
- package/dist/store/flow/index.js.map +1 -0
- 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 +73 -42
- 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.d.ts.map +1 -1
- package/dist/store/resetPipeline/resetPipeline.js +17 -12
- 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 +69 -56
- package/dist/store/store/NodeRegistry/nodeRegistry.d.ts.map +1 -1
- package/dist/store/store/NodeRegistry/nodeRegistry.js +94 -78
- 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 +40 -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 +151 -165
- package/dist/store/store/palistor.js.map +1 -1
- package/dist/store/store/registerNodes.d.ts +10 -10
- package/dist/store/store/registerNodes.d.ts.map +1 -1
- package/dist/store/store/registerNodes.js +33 -18
- 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 +277 -223
- 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.d.ts.map +1 -1
- package/dist/store/submitPipeline/submitPipeline.js +15 -11
- 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
- package/dist/store/compute/recompute/collectGroupLeafNodes.d.ts +0 -11
- package/dist/store/compute/recompute/collectGroupLeafNodes.d.ts.map +0 -1
- package/dist/store/compute/recompute/collectGroupLeafNodes.js +0 -26
- package/dist/store/compute/recompute/collectGroupLeafNodes.js.map +0 -1
- package/dist/store/fieldMapping.typecheck.d.ts +0 -2
- package/dist/store/fieldMapping.typecheck.d.ts.map +0 -1
- package/dist/store/fieldMapping.typecheck.js +0 -71
- package/dist/store/fieldMapping.typecheck.js.map +0 -1
- package/dist/store/submitPipeline/getSubValues.d.ts +0 -9
- package/dist/store/submitPipeline/getSubValues.d.ts.map +0 -1
- package/dist/store/submitPipeline/getSubValues.js +0 -26
- package/dist/store/submitPipeline/getSubValues.js.map +0 -1
|
@@ -1,20 +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
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Reserved persist-snapshot key for flow navigation (defineFlow):
|
|
17
|
+
* `{ [flowPath]: { currentStepKey, visitStack, visitedKeys } }`.
|
|
18
|
+
* Step field values are stored as regular values; step statuses are not
|
|
19
|
+
* saved — derived from navigation on hydrate.
|
|
20
|
+
*/
|
|
21
|
+
const FLOWS_PERSIST_KEY = "__flows";
|
|
22
|
+
// ─── Field filtering ─────────────────────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* Filter values by pick/omit.
|
|
25
|
+
* pick takes priority. When neither is set — everything is returned.
|
|
18
26
|
*/
|
|
19
27
|
function filterValues(values, pick, omit) {
|
|
20
28
|
if (pick && pick.length > 0) {
|
|
@@ -36,29 +44,29 @@ function filterValues(values, pick, omit) {
|
|
|
36
44
|
}
|
|
37
45
|
return values;
|
|
38
46
|
}
|
|
39
|
-
// ───
|
|
47
|
+
// ─── Class ───────────────────────────────────────────────────────────────────
|
|
40
48
|
/**
|
|
41
|
-
*
|
|
49
|
+
* The form's persistence manager.
|
|
42
50
|
*
|
|
43
|
-
*
|
|
51
|
+
* Accesses all form data through the `kernel` (Palistor instance).
|
|
44
52
|
*/
|
|
45
53
|
export class PersistManager {
|
|
46
54
|
constructor(kernel) {
|
|
47
|
-
// ───
|
|
55
|
+
// ─── Internal state ───────────────────────────────────────────────────────
|
|
48
56
|
this.active = false;
|
|
49
57
|
this.currentKey = null;
|
|
50
58
|
this.currentDriver = null;
|
|
51
59
|
this.serialize = JSON.stringify;
|
|
52
60
|
this.deserialize = JSON.parse;
|
|
53
61
|
this.debounceMs = 100;
|
|
54
|
-
/**
|
|
62
|
+
/** Unsubscribe from subscribeGlobal. */
|
|
55
63
|
this.unsubscribe = null;
|
|
56
|
-
/**
|
|
64
|
+
/** Debounce timer ID. */
|
|
57
65
|
this.debounceTimer = null;
|
|
58
|
-
/**
|
|
66
|
+
/** Flag preventing saves during hydration. */
|
|
59
67
|
this.isHydrating = false;
|
|
60
68
|
/**
|
|
61
|
-
*
|
|
69
|
+
* Schedule a debounced save.
|
|
62
70
|
*/
|
|
63
71
|
this.scheduleSave = () => {
|
|
64
72
|
if (!this.active || this.isHydrating)
|
|
@@ -75,7 +83,7 @@ export class PersistManager {
|
|
|
75
83
|
};
|
|
76
84
|
this.kernel = kernel;
|
|
77
85
|
}
|
|
78
|
-
// ───
|
|
86
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
79
87
|
cancelDebounce() {
|
|
80
88
|
if (this.debounceTimer !== null) {
|
|
81
89
|
clearTimeout(this.debounceTimer);
|
|
@@ -83,23 +91,27 @@ export class PersistManager {
|
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
|
-
*
|
|
94
|
+
* Save the current values to storage (no debounce).
|
|
87
95
|
*/
|
|
88
96
|
async saveToStorage() {
|
|
89
97
|
if (!this.active || !this.currentKey || !this.currentDriver)
|
|
90
98
|
return;
|
|
91
99
|
const allValues = this.kernel.getValues();
|
|
92
100
|
const filtered = filterValues(allValues, this.pickFields, this.omitFields);
|
|
101
|
+
// Flow: navigation is stored under a separate reserved key, not subject
|
|
102
|
+
// to pick/omit (it is not a form field).
|
|
103
|
+
const flowNav = serializeFlowNav(this.kernel);
|
|
104
|
+
const payload = flowNav ? { ...filtered, [FLOWS_PERSIST_KEY]: flowNav } : filtered;
|
|
93
105
|
try {
|
|
94
|
-
const serialized = this.serialize(
|
|
106
|
+
const serialized = this.serialize(payload);
|
|
95
107
|
await Promise.resolve(this.currentDriver.setItem(this.currentKey, serialized));
|
|
96
108
|
}
|
|
97
109
|
catch {
|
|
98
|
-
//
|
|
110
|
+
// Serialization/write errors are silenced (production-safe)
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
|
-
*
|
|
114
|
+
* Read from storage and apply the values to nodeState.
|
|
103
115
|
*/
|
|
104
116
|
async hydrateFromStorage() {
|
|
105
117
|
if (!this.currentKey || !this.currentDriver)
|
|
@@ -116,36 +128,55 @@ export class PersistManager {
|
|
|
116
128
|
this.isHydrating = false;
|
|
117
129
|
return;
|
|
118
130
|
}
|
|
119
|
-
//
|
|
120
|
-
|
|
131
|
+
// Flow: extract the navigation snapshot before applying the values patch.
|
|
132
|
+
const flowSnapshots = values[FLOWS_PERSIST_KEY];
|
|
133
|
+
if (flowSnapshots !== undefined) {
|
|
134
|
+
delete values[FLOWS_PERSIST_KEY];
|
|
135
|
+
}
|
|
136
|
+
// Apply as a patch — applyPatch walks the config tree recursively
|
|
137
|
+
// (scalar/group fields; list nodes are skipped).
|
|
121
138
|
const patchedNodes = applyPatch(this.kernel.rootConfig, this.kernel.nodes.nodeState, values, new Set());
|
|
122
|
-
//
|
|
123
|
-
//
|
|
139
|
+
// Restore root and per-entity list membership from the snapshot.
|
|
140
|
+
// No-op for configs without lists (graceful for older snapshots).
|
|
124
141
|
const listChanged = this.kernel.restoreLists(values);
|
|
125
142
|
for (const n of listChanged)
|
|
126
143
|
patchedNodes.add(n);
|
|
127
|
-
//
|
|
144
|
+
// Flow: restore navigation (active step, stack, visited).
|
|
145
|
+
// Step statuses are recomputed from the navigation state.
|
|
146
|
+
let enteredFlows = [];
|
|
147
|
+
if (flowSnapshots && typeof flowSnapshots === "object") {
|
|
148
|
+
const { changed: flowChanged, entered } = restoreFlowNav(this.kernel, flowSnapshots);
|
|
149
|
+
for (const n of flowChanged)
|
|
150
|
+
patchedNodes.add(n);
|
|
151
|
+
enteredFlows = entered;
|
|
152
|
+
}
|
|
153
|
+
// Recompute, merge, and notify subscribers
|
|
128
154
|
recomputeAndNotify(patchedNodes, () => this.kernel.recompute(), (c) => this.kernel.notifyChanged(c));
|
|
155
|
+
// Flow: when the active step changed during hydration — the restored
|
|
156
|
+
// step is "entered" anew: onEnter → resolve → onReady.
|
|
157
|
+
for (const flowState of enteredFlows) {
|
|
158
|
+
runFlowEntryLifecycle(this.kernel, flowState);
|
|
159
|
+
}
|
|
129
160
|
}
|
|
130
161
|
catch {
|
|
131
|
-
//
|
|
162
|
+
// Deserialization errors are silenced
|
|
132
163
|
}
|
|
133
164
|
finally {
|
|
134
165
|
this.isHydrating = false;
|
|
135
166
|
}
|
|
136
167
|
}
|
|
137
|
-
// ───
|
|
168
|
+
// ─── Public API ────────────────────────────────────────────────────────────
|
|
138
169
|
/**
|
|
139
|
-
*
|
|
170
|
+
* Activate persistence: hydrate from storage + auto-save on changes.
|
|
140
171
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
172
|
+
* When persist is already active, the previous one is disabled first.
|
|
173
|
+
* Returns a Promise that resolves after successful hydration.
|
|
143
174
|
*/
|
|
144
175
|
enable(options) {
|
|
145
|
-
//
|
|
176
|
+
// Already active — disable the previous one
|
|
146
177
|
if (this.active)
|
|
147
178
|
this.disable();
|
|
148
|
-
//
|
|
179
|
+
// Store the settings
|
|
149
180
|
this.currentKey = options.key;
|
|
150
181
|
this.currentDriver = options.driver;
|
|
151
182
|
this.serialize = options.serialize ?? JSON.stringify;
|
|
@@ -154,12 +185,12 @@ export class PersistManager {
|
|
|
154
185
|
this.pickFields = options.pick;
|
|
155
186
|
this.omitFields = options.omit;
|
|
156
187
|
this.active = true;
|
|
157
|
-
//
|
|
188
|
+
// Subscribe to changes for auto-save
|
|
158
189
|
this.unsubscribe = this.kernel.hub.subscribeGlobal(this.scheduleSave);
|
|
159
|
-
//
|
|
190
|
+
// Hydrate
|
|
160
191
|
return this.hydrateFromStorage();
|
|
161
192
|
}
|
|
162
|
-
/**
|
|
193
|
+
/** Deactivate: unsubscribe from the store, cancel timers, clear state. */
|
|
163
194
|
disable() {
|
|
164
195
|
this.active = false;
|
|
165
196
|
this.cancelDebounce();
|
|
@@ -170,16 +201,16 @@ export class PersistManager {
|
|
|
170
201
|
this.currentKey = null;
|
|
171
202
|
this.currentDriver = null;
|
|
172
203
|
}
|
|
173
|
-
/**
|
|
204
|
+
/** Force-save the current values to storage (no debounce). */
|
|
174
205
|
async flush() {
|
|
175
206
|
this.cancelDebounce();
|
|
176
207
|
await this.saveToStorage();
|
|
177
208
|
}
|
|
178
|
-
/**
|
|
209
|
+
/** Force-hydrate from storage. */
|
|
179
210
|
async hydrate() {
|
|
180
211
|
await this.hydrateFromStorage();
|
|
181
212
|
}
|
|
182
|
-
/**
|
|
213
|
+
/** Remove the data from storage under the current key. */
|
|
183
214
|
async clear() {
|
|
184
215
|
if (!this.currentKey || !this.currentDriver)
|
|
185
216
|
return;
|
|
@@ -190,7 +221,7 @@ export class PersistManager {
|
|
|
190
221
|
// noop
|
|
191
222
|
}
|
|
192
223
|
}
|
|
193
|
-
/**
|
|
224
|
+
/** Whether persistence is currently active. */
|
|
194
225
|
isEnabled() {
|
|
195
226
|
return this.active;
|
|
196
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,EAA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AAE,CAAC;QAEtB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,8DAA8D;IAC9D,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAED,kCAAkC;IAClC,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAO;QAEpD,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,OAAO,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,eAAe,CAAC,IAAmB;IACjD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,IAA+B,CAAC,EAAE,CAAC;QAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAkB,CAAC;QACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAS;QAClD,IAAI,UAAU,CAAC,KAAK,CAAC;YAAE,SAAS,CAAC,
|
|
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,eAAe,CAAC,IAAmB;IACjD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,UAAU,CAAC,IAA+B,CAAC,EAAE,CAAC;QAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAkB,CAAC;QACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,SAAS;QAClD,IAAI,UAAU,CAAC,KAAK,CAAC;YAAE,SAAS,CAAC,0CAA0C;QAE3E,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;gBAAE,SAAS;YAChD,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPipeline.d.ts","sourceRoot":"","sources":["../../../store/resetPipeline/resetPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resetPipeline.d.ts","sourceRoot":"","sources":["../../../store/resetPipeline/resetPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAOlD;;;;;;;;;;GAUG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAEvD,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CA2C1E"}
|
|
@@ -2,16 +2,17 @@ import { applyPatch } from "../applyPatch/applyPatch";
|
|
|
2
2
|
import { setGroupRevalidate, captureInitialValues } from "../dirtyTracking";
|
|
3
3
|
import { recomputeAndNotify } from "../compute/recompute";
|
|
4
4
|
import { buildResetPatch } from "./buildResetPatch";
|
|
5
|
+
import { resetFlowNavForSubtree } from "../flow/flowNavigation";
|
|
5
6
|
/**
|
|
6
|
-
* ResetPipeline —
|
|
7
|
+
* ResetPipeline — resets a group node's values.
|
|
7
8
|
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
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.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
* - revalidate = false (
|
|
14
|
-
* -
|
|
13
|
+
* After the reset:
|
|
14
|
+
* - revalidate = false (validation mode cleared)
|
|
15
|
+
* - full recompute of computed props + subscriber notification
|
|
15
16
|
*/
|
|
16
17
|
export class ResetPipeline {
|
|
17
18
|
constructor(kernel) {
|
|
@@ -21,16 +22,16 @@ export class ResetPipeline {
|
|
|
21
22
|
const nodeState = this.kernel.nodes.nodeState;
|
|
22
23
|
const initialValueMap = this.kernel.dirty.initialValueMap;
|
|
23
24
|
const valuesCache = this.kernel.values;
|
|
24
|
-
//
|
|
25
|
-
//
|
|
25
|
+
// On a full form reset, clear entity-field resolve states so they run
|
|
26
|
+
// again when entities are loaded through the list resolver.
|
|
26
27
|
if (groupNode === this.kernel.rootConfig) {
|
|
27
28
|
this.kernel.resolveManager.entityStates.clearAll();
|
|
28
29
|
}
|
|
29
30
|
const patch = buildResetPatch(groupNode, initialValueMap, values);
|
|
30
31
|
const changed = applyPatch(groupNode, nodeState, patch, new Set(), valuesCache);
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
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.
|
|
34
35
|
if (groupNode === this.kernel.rootConfig) {
|
|
35
36
|
for (const { state } of this.kernel.entityRegistry.resetEntityListStates()) {
|
|
36
37
|
this.kernel.syncListValuesCache(state);
|
|
@@ -44,6 +45,10 @@ export class ResetPipeline {
|
|
|
44
45
|
for (const n of revalidateChanged)
|
|
45
46
|
changed.add(n);
|
|
46
47
|
recomputeAndNotify(changed, () => this.kernel.recompute(), (c) => this.kernel.notifyChanged(c));
|
|
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
|
+
resetFlowNavForSubtree(this.kernel, groupNode);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
//# sourceMappingURL=resetPipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPipeline.js","sourceRoot":"","sources":["../../../store/resetPipeline/resetPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resetPipeline.js","sourceRoot":"","sources":["../../../store/resetPipeline/resetPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACxB,YAA6B,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IAE3D,OAAO,CAAC,SAAwB,EAAE,MAAgC;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QAC9C,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAEvC,sEAAsE;QACtE,4DAA4D;QAC5D,IAAI,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACzC,IAAI,CAAC,MAAM,CAAC,cAAc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{ type PendingWrite } from "./createValuesTrackingProxy";
|
|
|
3
3
|
import type { FieldState } from "../compute/index";
|
|
4
4
|
import type { ValuesCache } from "../valuesCache/valuesCache";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Flushes all writes buffered during one resolver run into the real store.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Converts each flat (dot-separated) path back into the nested patch
|
|
9
|
+
* structure applyPatch() understands, then applies it.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Example:
|
|
12
12
|
* PendingWrite { path: "user.vehicleExists", value: false }
|
|
13
13
|
* → patch = { user: { vehicleExists: false } }
|
|
14
14
|
* → applyPatch(rootConfig, nodeState, patch, changed, valuesCache)
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* Deeper nesting works the same way:
|
|
17
17
|
* path: "a.b.c" → patch = { a: { b: { c: value } } }
|
|
18
18
|
*
|
|
19
|
-
* @param writes —
|
|
20
|
-
* @param rootConfig —
|
|
21
|
-
* @param nodeState —
|
|
22
|
-
* @param valuesCache —
|
|
23
|
-
* @returns —
|
|
19
|
+
* @param writes — writes buffered by createValuesTrackingProxy during the resolver run
|
|
20
|
+
* @param rootConfig — root of the field config tree (used by applyPatch to find nodes)
|
|
21
|
+
* @param nodeState — runtime node state (dirty flags, errors, etc.)
|
|
22
|
+
* @param valuesCache — mutable values cache that applyPatch updates in place
|
|
23
|
+
* @returns — set of config nodes whose value actually changed (for dependency tracking)
|
|
24
24
|
*/
|
|
25
25
|
export declare function applyPendingWrites(writes: PendingWrite[], rootConfig: AnyConfigNode, nodeState: WeakMap<object, FieldState>, valuesCache: ValuesCache): Set<object>;
|
|
26
26
|
//# sourceMappingURL=applyPendingWrites.d.ts.map
|