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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyPendingWrites.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/applyPendingWrites.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAiB9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,GAAG,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"applyPendingWrites.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/applyPendingWrites.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAiB9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,GAAG,CAAC,MAAM,CAAC,CA+Bb"}
|
|
@@ -1,68 +1,65 @@
|
|
|
1
1
|
import { applyPatch } from "../applyPatch/applyPatch";
|
|
2
|
-
// ───
|
|
2
|
+
// ─── Applying buffered writes ────────────────────────────────────────────────
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// This is the second half of the deferred-write pipeline.
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
// 1.
|
|
8
|
-
// 2.
|
|
9
|
-
// PendingWrite { path: "x.y", value: z } —
|
|
10
|
-
// 3.
|
|
11
|
-
//
|
|
12
|
-
// 4.
|
|
13
|
-
//
|
|
14
|
-
// 5. applyPatch()
|
|
15
|
-
// 6.
|
|
6
|
+
// FLOW OVERVIEW:
|
|
7
|
+
// 1. The resolver runs with the proxy from createValuesTrackingProxy().
|
|
8
|
+
// 2. Every `values.x.y = z` inside the resolver is intercepted and stored as
|
|
9
|
+
// PendingWrite { path: "x.y", value: z } — nothing is mutated.
|
|
10
|
+
// 3. After the resolver returns, applyPendingWrites() is called with the
|
|
11
|
+
// collected PendingWrite list.
|
|
12
|
+
// 4. For each write, the nested patch object applyPatch() expects is rebuilt,
|
|
13
|
+
// then applyPatch() performs the real store write.
|
|
14
|
+
// 5. applyPatch() records the config nodes that changed into the `changed` set.
|
|
15
|
+
// 6. The caller uses `changed` to decide which dependent resolvers to re-run.
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Flushes all writes buffered during one resolver run into the real store.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Converts each flat (dot-separated) path back into the nested patch
|
|
20
|
+
* structure applyPatch() understands, then applies it.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Example:
|
|
23
23
|
* PendingWrite { path: "user.vehicleExists", value: false }
|
|
24
24
|
* → patch = { user: { vehicleExists: false } }
|
|
25
25
|
* → applyPatch(rootConfig, nodeState, patch, changed, valuesCache)
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* Deeper nesting works the same way:
|
|
28
28
|
* path: "a.b.c" → patch = { a: { b: { c: value } } }
|
|
29
29
|
*
|
|
30
|
-
* @param writes —
|
|
31
|
-
* @param rootConfig —
|
|
32
|
-
* @param nodeState —
|
|
33
|
-
* @param valuesCache —
|
|
34
|
-
* @returns —
|
|
30
|
+
* @param writes — writes buffered by createValuesTrackingProxy during the resolver run
|
|
31
|
+
* @param rootConfig — root of the field config tree (used by applyPatch to find nodes)
|
|
32
|
+
* @param nodeState — runtime node state (dirty flags, errors, etc.)
|
|
33
|
+
* @param valuesCache — mutable values cache that applyPatch updates in place
|
|
34
|
+
* @returns — set of config nodes whose value actually changed (for dependency tracking)
|
|
35
35
|
*/
|
|
36
36
|
export function applyPendingWrites(writes, rootConfig, nodeState, valuesCache) {
|
|
37
|
-
//
|
|
38
|
-
//
|
|
37
|
+
// Accumulates all config nodes whose value actually changed during this flush.
|
|
38
|
+
// Returned to the caller so it can schedule re-runs of dependent resolvers.
|
|
39
39
|
const changed = new Set();
|
|
40
40
|
for (const { path, value } of writes) {
|
|
41
|
-
// ──
|
|
42
|
-
// applyPatch()
|
|
43
|
-
//
|
|
41
|
+
// ── Rebuild the nested patch from the dot-path ───────────────────────────
|
|
42
|
+
// applyPatch() expects a nested object mirroring the config tree, not a
|
|
43
|
+
// flat path. Build it manually by nesting objects along the path segments.
|
|
44
44
|
//
|
|
45
|
-
//
|
|
45
|
+
// Example: path = "user.vehicleExists"
|
|
46
46
|
// parts = ["user", "vehicleExists"]
|
|
47
|
-
//
|
|
47
|
+
// After the loop: patch = { user: { vehicleExists: <value> } }
|
|
48
48
|
const parts = path.split(".");
|
|
49
49
|
let patch = {};
|
|
50
|
-
let current = patch; //
|
|
50
|
+
let current = patch; // the `current` cursor descends into the nested object being built
|
|
51
51
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
52
|
-
// Создаём промежуточный пустой объект для каждого сегмента пути, кроме последнего.
|
|
53
52
|
current[parts[i]] = {};
|
|
54
53
|
current = current[parts[i]];
|
|
55
54
|
}
|
|
56
|
-
//
|
|
55
|
+
// Place the actual value at the leaf (the last segment).
|
|
57
56
|
current[parts[parts.length - 1]] = value;
|
|
58
|
-
// ──
|
|
59
|
-
// applyPatch
|
|
60
|
-
// valuesCache,
|
|
61
|
-
//
|
|
57
|
+
// ── Apply the patch to the real store ────────────────────────────────────
|
|
58
|
+
// applyPatch walks rootConfig following the patch shape, writes values into
|
|
59
|
+
// valuesCache, updates nodeState (dirty flags etc.) and records every node
|
|
60
|
+
// whose value changed into `changed`.
|
|
62
61
|
applyPatch(rootConfig, nodeState, patch, changed, valuesCache);
|
|
63
62
|
}
|
|
64
|
-
// Возвращаем множество изменённых узлов, чтобы пайплайн резолвов мог
|
|
65
|
-
// запланировать повторные запуски для всего, что зависело от этих значений.
|
|
66
63
|
return changed;
|
|
67
64
|
}
|
|
68
65
|
//# sourceMappingURL=applyPendingWrites.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyPendingWrites.js","sourceRoot":"","sources":["../../../store/resolvePipeline/applyPendingWrites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD
|
|
1
|
+
{"version":3,"file":"applyPendingWrites.js","sourceRoot":"","sources":["../../../store/resolvePipeline/applyPendingWrites.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAMtD,gFAAgF;AAChF,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,iBAAiB;AACjB,0EAA0E;AAC1E,+EAA+E;AAC/E,oEAAoE;AACpE,2EAA2E;AAC3E,oCAAoC;AACpC,gFAAgF;AAChF,wDAAwD;AACxD,kFAAkF;AAClF,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAsB,EACtB,UAAyB,EACzB,SAAsC,EACtC,WAAwB;IAExB,+EAA+E;IAC/E,4EAA4E;IAC5E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QACrC,4EAA4E;QAC5E,wEAAwE;QACxE,2EAA2E;QAC3E,EAAE;QACF,uCAAuC;QACvC,sCAAsC;QACtC,iEAAiE;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,KAAK,GAA4B,EAAE,CAAC;QACxC,IAAI,OAAO,GAAG,KAAK,CAAC,CAAC,mEAAmE;QACxF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YACvB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAA4B,CAAC;QACzD,CAAC;QACD,yDAAyD;QACzD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAEzC,4EAA4E;QAC5E,4EAA4E;QAC5E,2EAA2E;QAC3E,sCAAsC;QACtC,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createContextTrackingProxy —
|
|
3
|
-
*
|
|
2
|
+
* createContextTrackingProxy — wraps the flat context object in a read-only
|
|
3
|
+
* Proxy that records the keys the resolver accessed.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Used in executeResolve to detect context dependencies automatically:
|
|
6
|
+
* when a resolver reads `store.context.accountId`, `$context.accountId` is
|
|
7
|
+
* added to the auto-deps, and the resolver re-runs when that key changes via
|
|
8
|
+
* `setContext`.
|
|
8
9
|
*/
|
|
9
10
|
export interface ContextTrackingResult {
|
|
10
|
-
/**
|
|
11
|
+
/** Proxy over the context — handed to the resolver inside storeProxy */
|
|
11
12
|
proxy: Record<string, unknown>;
|
|
12
|
-
/**
|
|
13
|
+
/** Context keys the resolver accessed */
|
|
13
14
|
getAccessedKeys: () => Set<string>;
|
|
14
15
|
}
|
|
15
16
|
export declare function createContextTrackingProxy(context: Record<string, unknown>): ContextTrackingResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContextTrackingProxy.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/createContextTrackingProxy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"createContextTrackingProxy.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/createContextTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,yCAAyC;IACzC,eAAe,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;CACpC;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,qBAAqB,CAoBvB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createContextTrackingProxy —
|
|
3
|
-
*
|
|
2
|
+
* createContextTrackingProxy — wraps the flat context object in a read-only
|
|
3
|
+
* Proxy that records the keys the resolver accessed.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Used in executeResolve to detect context dependencies automatically:
|
|
6
|
+
* when a resolver reads `store.context.accountId`, `$context.accountId` is
|
|
7
|
+
* added to the auto-deps, and the resolver re-runs when that key changes via
|
|
8
|
+
* `setContext`.
|
|
8
9
|
*/
|
|
9
10
|
export function createContextTrackingProxy(context) {
|
|
10
11
|
const accessedKeys = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContextTrackingProxy.js","sourceRoot":"","sources":["../../../store/resolvePipeline/createContextTrackingProxy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"createContextTrackingProxy.js","sourceRoot":"","sources":["../../../store/resolvePipeline/createContextTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,MAAM,UAAU,0BAA0B,CACxC,OAAgC;IAEhC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IAEvC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;QAC/B,GAAG,CAAC,OAAO,EAAE,GAAG;YACd,8DAA8D;YAC9D,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAC9D,YAAY,CAAC,GAAG,CAAC,GAAa,CAAC,CAAC;YAChC,OAAO,OAAO,CAAC,GAAa,CAAC,CAAC;QAChC,CAAC;QACD,GAAG;YACD,wCAAwC;YACxC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;QACtE,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,eAAe,EAAE,GAAG,EAAE,CAAC,YAAY;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createValuesTrackingProxy —
|
|
3
|
-
* -
|
|
4
|
-
* -
|
|
2
|
+
* createValuesTrackingProxy — wraps the values tree in a Proxy that:
|
|
3
|
+
* - READS: tracks accessed paths (automatic dependencies for resolver re-runs)
|
|
4
|
+
* - WRITES: buffers side effects (batch mode, no intermediate re-renders)
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Used inside resolver execution: the resolver receives this proxy instead of
|
|
7
|
+
* the real object. After the resolver finishes, the accessed paths are stored
|
|
8
|
+
* for dependency tracking and the buffered writes are flushed in one batch.
|
|
9
9
|
*
|
|
10
|
-
* ───
|
|
10
|
+
* ─── HOW IT WORKS ────────────────────────────────────────────────────────────
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The values tree looks like a regular nested object:
|
|
13
13
|
* { user: { name: "Alice", vehicleExists: true }, payment: { amount: 100 } }
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* When the resolver runs, it receives this proxy instead of the real object.
|
|
16
|
+
* The proxy intercepts every property access:
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* →
|
|
20
|
-
* →
|
|
21
|
-
* →
|
|
18
|
+
* READ: values.user.name
|
|
19
|
+
* → the proxy returns a nested proxy for "user"
|
|
20
|
+
* → the nested proxy intercepts "name", records the path "user.name" in accessedPaths
|
|
21
|
+
* → returns the real value
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* →
|
|
25
|
-
*
|
|
26
|
-
* →
|
|
23
|
+
* WRITE: values.user.vehicleExists = false
|
|
24
|
+
* → the proxy intercepts the assignment, records { path: "user.vehicleExists", value: false }
|
|
25
|
+
* into pendingWrites[]
|
|
26
|
+
* → the real values object is NOT touched — the write is deferred!
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
* 1. getAccessedPaths() →
|
|
30
|
-
* (
|
|
31
|
-
* 2. getPendingWrites() →
|
|
32
|
-
*
|
|
28
|
+
* After the resolver returns:
|
|
29
|
+
* 1. getAccessedPaths() → used to rebuild this resolver's dependency graph
|
|
30
|
+
* (the resolver re-runs the next time any of these paths changes)
|
|
31
|
+
* 2. getPendingWrites() → passed to applyPendingWrites(), which turns each
|
|
32
|
+
* path back into a nested patch and calls applyPatch() on the real store
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
* -
|
|
36
|
-
* -
|
|
37
|
-
* -
|
|
34
|
+
* WHY BUFFER WRITES instead of applying immediately?
|
|
35
|
+
* - Prevents cascading re-renders in the middle of a resolver run
|
|
36
|
+
* - All mutations are applied in one atomic batch → consistent state after every pipeline tick
|
|
37
|
+
* - Resolver A's writes don't accidentally trigger resolver B mid-run
|
|
38
38
|
*/
|
|
39
39
|
export interface PendingWrite {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* applyPendingWrites()
|
|
41
|
+
* Dot-separated path in the values tree, e.g. "user.vehicleExists" or "payment.amount".
|
|
42
|
+
* Mirrors the structure of the values object (like valuesCache.values).
|
|
43
|
+
* applyPendingWrites() splits this path on "." to build a nested patch object.
|
|
44
44
|
*/
|
|
45
45
|
path: string;
|
|
46
|
-
/**
|
|
46
|
+
/** The new value the resolver wants to write at this path. */
|
|
47
47
|
value: unknown;
|
|
48
48
|
}
|
|
49
49
|
export interface ValuesTrackingResult {
|
|
50
|
-
/**
|
|
50
|
+
/** Writable tracking proxy handed to the resolver. Reads are tracked, writes buffered. */
|
|
51
51
|
proxy: Record<string, unknown>;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Returns all (dot-separated) paths that were READ during the resolver run.
|
|
54
|
+
* Used after the resolver returns to update the dependency graph:
|
|
55
|
+
* the resolver re-runs when any of these paths changes.
|
|
56
56
|
*/
|
|
57
57
|
getAccessedPaths: () => Set<string>;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* Returns all write operations buffered during the resolver run.
|
|
60
|
+
* None of these writes has been applied to the real store yet —
|
|
61
|
+
* they are flushed in one batch via applyPendingWrites() after the resolver returns.
|
|
62
62
|
*/
|
|
63
63
|
getPendingWrites: () => PendingWrite[];
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Creates a writable tracking proxy for the values tree.
|
|
67
67
|
*
|
|
68
|
-
* -
|
|
69
|
-
* -
|
|
70
|
-
* -
|
|
68
|
+
* - Reading a primitive records the full path (e.g. "user.id") in accessedPaths
|
|
69
|
+
* - Reading an object returns a nested proxy (recursively); not tracked until a leaf is read
|
|
70
|
+
* - Writing to ANY path buffers the assignment in pendingWrites[] without touching real data
|
|
71
71
|
*
|
|
72
|
-
* @param values —
|
|
72
|
+
* @param values — current values snapshot (from valuesCache.values), treated as read-only here
|
|
73
73
|
*/
|
|
74
74
|
export declare function createValuesTrackingProxy(values: Record<string, unknown>): ValuesTrackingResult;
|
|
75
75
|
//# sourceMappingURL=createValuesTrackingProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createValuesTrackingProxy.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/createValuesTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"createValuesTrackingProxy.d.ts","sourceRoot":"","sources":["../../../store/resolvePipeline/createValuesTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,YAAY,EAAE,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,oBAAoB,CAwFtB"}
|
|
@@ -1,123 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createValuesTrackingProxy —
|
|
3
|
-
* -
|
|
4
|
-
* -
|
|
2
|
+
* createValuesTrackingProxy — wraps the values tree in a Proxy that:
|
|
3
|
+
* - READS: tracks accessed paths (automatic dependencies for resolver re-runs)
|
|
4
|
+
* - WRITES: buffers side effects (batch mode, no intermediate re-renders)
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Used inside resolver execution: the resolver receives this proxy instead of
|
|
7
|
+
* the real object. After the resolver finishes, the accessed paths are stored
|
|
8
|
+
* for dependency tracking and the buffered writes are flushed in one batch.
|
|
9
9
|
*
|
|
10
|
-
* ───
|
|
10
|
+
* ─── HOW IT WORKS ────────────────────────────────────────────────────────────
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* The values tree looks like a regular nested object:
|
|
13
13
|
* { user: { name: "Alice", vehicleExists: true }, payment: { amount: 100 } }
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* When the resolver runs, it receives this proxy instead of the real object.
|
|
16
|
+
* The proxy intercepts every property access:
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* →
|
|
20
|
-
* →
|
|
21
|
-
* →
|
|
18
|
+
* READ: values.user.name
|
|
19
|
+
* → the proxy returns a nested proxy for "user"
|
|
20
|
+
* → the nested proxy intercepts "name", records the path "user.name" in accessedPaths
|
|
21
|
+
* → returns the real value
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
* →
|
|
25
|
-
*
|
|
26
|
-
* →
|
|
23
|
+
* WRITE: values.user.vehicleExists = false
|
|
24
|
+
* → the proxy intercepts the assignment, records { path: "user.vehicleExists", value: false }
|
|
25
|
+
* into pendingWrites[]
|
|
26
|
+
* → the real values object is NOT touched — the write is deferred!
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
* 1. getAccessedPaths() →
|
|
30
|
-
* (
|
|
31
|
-
* 2. getPendingWrites() →
|
|
32
|
-
*
|
|
28
|
+
* After the resolver returns:
|
|
29
|
+
* 1. getAccessedPaths() → used to rebuild this resolver's dependency graph
|
|
30
|
+
* (the resolver re-runs the next time any of these paths changes)
|
|
31
|
+
* 2. getPendingWrites() → passed to applyPendingWrites(), which turns each
|
|
32
|
+
* path back into a nested patch and calls applyPatch() on the real store
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
* -
|
|
36
|
-
* -
|
|
37
|
-
* -
|
|
34
|
+
* WHY BUFFER WRITES instead of applying immediately?
|
|
35
|
+
* - Prevents cascading re-renders in the middle of a resolver run
|
|
36
|
+
* - All mutations are applied in one atomic batch → consistent state after every pipeline tick
|
|
37
|
+
* - Resolver A's writes don't accidentally trigger resolver B mid-run
|
|
38
38
|
*/
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Creates a writable tracking proxy for the values tree.
|
|
41
41
|
*
|
|
42
|
-
* -
|
|
43
|
-
* -
|
|
44
|
-
* -
|
|
42
|
+
* - Reading a primitive records the full path (e.g. "user.id") in accessedPaths
|
|
43
|
+
* - Reading an object returns a nested proxy (recursively); not tracked until a leaf is read
|
|
44
|
+
* - Writing to ANY path buffers the assignment in pendingWrites[] without touching real data
|
|
45
45
|
*
|
|
46
|
-
* @param values —
|
|
46
|
+
* @param values — current values snapshot (from valuesCache.values), treated as read-only here
|
|
47
47
|
*/
|
|
48
48
|
export function createValuesTrackingProxy(values) {
|
|
49
|
-
//
|
|
50
|
-
//
|
|
49
|
+
// Collects every primitive path the resolver reads.
|
|
50
|
+
// Example after a resolver run: Set { "user.name", "user.vehicleExists" }
|
|
51
51
|
const accessedPaths = new Set();
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
52
|
+
// Collects every write the resolver performs, in order of appearance.
|
|
53
|
+
// None is applied until applyPendingWrites() runs after the resolver returns.
|
|
54
|
+
// Example: [{ path: "user.vehicleExists", value: false }, { path: "payment.amount", value: 200 }]
|
|
55
55
|
const pendingWrites = [];
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
56
|
+
// Caches nested proxies by their path prefix so repeated access to the same
|
|
57
|
+
// nested object returns the same proxy instance.
|
|
58
|
+
// Key: dot-separated path prefix (e.g. "user"), or "__root__" for the root level.
|
|
59
59
|
const proxyCache = new Map();
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Recursively wraps `target` in a Proxy that tracks reads and buffers writes.
|
|
62
62
|
*
|
|
63
|
-
* @param target —
|
|
64
|
-
* @param parentPath —
|
|
63
|
+
* @param target — the real values object (or nested sub-object) to wrap
|
|
64
|
+
* @param parentPath — accumulated dot-path prefix, e.g. "" for the root or "user" for a nested one
|
|
65
65
|
*/
|
|
66
66
|
function buildValuesProxy(target, parentPath) {
|
|
67
|
-
//
|
|
68
|
-
//
|
|
67
|
+
// Return the cached proxy for this path so we don't create duplicate
|
|
68
|
+
// proxies for one node (matters for referential equality checks inside resolvers).
|
|
69
69
|
const cacheKey = parentPath || "__root__";
|
|
70
70
|
if (proxyCache.has(cacheKey))
|
|
71
71
|
return proxyCache.get(cacheKey);
|
|
72
72
|
const p = new Proxy(target, {
|
|
73
|
-
// ─── GET
|
|
74
|
-
//
|
|
75
|
-
// •
|
|
76
|
-
// (
|
|
77
|
-
// •
|
|
73
|
+
// ─── GET trap ─────────────────────────────────────────────────────────
|
|
74
|
+
// Intercepts every property read. Builds the full dot-path, then:
|
|
75
|
+
// • nested plain object → returns a nested proxy
|
|
76
|
+
// (intermediate paths are not tracked, only leaf reads)
|
|
77
|
+
// • primitive → records the path in accessedPaths and returns it
|
|
78
78
|
get(_t, key) {
|
|
79
|
-
//
|
|
80
|
-
//
|
|
79
|
+
// Ignore symbol keys (e.g. Symbol.toPrimitive, Symbol.iterator) —
|
|
80
|
+
// framework/runtime internals, not part of the values tree.
|
|
81
81
|
if (typeof key === "symbol")
|
|
82
82
|
return undefined;
|
|
83
|
-
//
|
|
83
|
+
// Full dot-path for this access, e.g. "user" + "." + "name" = "user.name"
|
|
84
84
|
const fullPath = parentPath ? `${parentPath}.${key}` : key;
|
|
85
85
|
const val = target[key];
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
86
|
+
// Plain objects are wrapped in another proxy to keep tracking deeper
|
|
87
|
+
// reads, e.g. values.user.address.city.
|
|
88
|
+
// Arrays and Dates are treated as leaf values (no recursion).
|
|
89
89
|
if (val !== null && typeof val === "object" && !Array.isArray(val) && !(val instanceof Date)) {
|
|
90
90
|
return buildValuesProxy(val, fullPath);
|
|
91
91
|
}
|
|
92
|
-
//
|
|
93
|
-
//
|
|
92
|
+
// Leaf read — record the path so the resolver can be re-triggered
|
|
93
|
+
// later when this specific value changes in the store.
|
|
94
94
|
accessedPaths.add(fullPath);
|
|
95
95
|
return val;
|
|
96
96
|
},
|
|
97
|
-
// ─── SET
|
|
98
|
-
//
|
|
99
|
-
//
|
|
97
|
+
// ─── SET trap ─────────────────────────────────────────────────────────
|
|
98
|
+
// Intercepts every assignment. Instead of mutating the real values
|
|
99
|
+
// object, pushes a PendingWrite descriptor into the buffer.
|
|
100
100
|
//
|
|
101
|
-
//
|
|
102
|
-
// 1.
|
|
103
|
-
// 2. applyPendingWrites()
|
|
104
|
-
//
|
|
105
|
-
// 3.
|
|
101
|
+
// Writes are deliberately deferred:
|
|
102
|
+
// 1. A resolver may perform several writes in a row; collect them all first.
|
|
103
|
+
// 2. applyPendingWrites() runs after the resolver returns, so all
|
|
104
|
+
// mutations are applied atomically in a single applyPatch() call.
|
|
105
|
+
// 3. The resolver cannot observe its own partially applied writes.
|
|
106
106
|
set(_t, key, newValue) {
|
|
107
107
|
if (typeof key === "symbol")
|
|
108
108
|
return false;
|
|
109
109
|
const fullPath = parentPath ? `${parentPath}.${key}` : key;
|
|
110
|
-
//
|
|
110
|
+
// Buffer the write — the real store is untouched for now.
|
|
111
111
|
pendingWrites.push({ path: fullPath, value: newValue });
|
|
112
|
-
//
|
|
113
|
-
// (
|
|
112
|
+
// Returning true tells the Proxy the assignment was "accepted"
|
|
113
|
+
// (prevents a strict-mode TypeError despite no real mutation happening).
|
|
114
114
|
return true;
|
|
115
115
|
},
|
|
116
116
|
});
|
|
117
117
|
proxyCache.set(cacheKey, p);
|
|
118
118
|
return p;
|
|
119
119
|
}
|
|
120
|
-
//
|
|
120
|
+
// Build the root-level proxy (parentPath = "" means no prefix).
|
|
121
121
|
const proxy = buildValuesProxy(values, "");
|
|
122
122
|
return {
|
|
123
123
|
proxy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createValuesTrackingProxy.js","sourceRoot":"","sources":["../../../store/resolvePipeline/createValuesTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AA8BH;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA+B;IAE/B,
|
|
1
|
+
{"version":3,"file":"createValuesTrackingProxy.js","sourceRoot":"","sources":["../../../store/resolvePipeline/createValuesTrackingProxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AA8BH;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA+B;IAE/B,oDAAoD;IACpD,0EAA0E;IAC1E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAExC,sEAAsE;IACtE,8EAA8E;IAC9E,kGAAkG;IAClG,MAAM,aAAa,GAAmB,EAAE,CAAC;IAEzC,4EAA4E;IAC5E,iDAAiD;IACjD,kFAAkF;IAClF,MAAM,UAAU,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE9C;;;;;OAKG;IACH,SAAS,gBAAgB,CAAC,MAA+B,EAAE,UAAkB;QAC3E,qEAAqE;QACrE,mFAAmF;QACnF,MAAM,QAAQ,GAAG,UAAU,IAAI,UAAU,CAAC;QAC1C,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,CAA4B,CAAC;QAEzF,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE;YAC1B,yEAAyE;YACzE,kEAAkE;YAClE,mDAAmD;YACnD,4DAA4D;YAC5D,mEAAmE;YACnE,GAAG,CAAC,EAAE,EAAE,GAAoB;gBAC1B,kEAAkE;gBAClE,4DAA4D;gBAC5D,IAAI,OAAO,GAAG,KAAK,QAAQ;oBAAE,OAAO,SAAS,CAAC;gBAE9C,0EAA0E;gBAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBAExB,qEAAqE;gBACrE,wCAAwC;gBACxC,8DAA8D;gBAC9D,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,EAAE,CAAC;oBAC7F,OAAO,gBAAgB,CAAC,GAA8B,EAAE,QAAQ,CAAC,CAAC;gBACpE,CAAC;gBAED,kEAAkE;gBAClE,uDAAuD;gBACvD,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,GAAG,CAAC;YACb,CAAC;YAED,yEAAyE;YACzE,mEAAmE;YACnE,4DAA4D;YAC5D,EAAE;YACF,oCAAoC;YACpC,+EAA+E;YAC/E,oEAAoE;YACpE,uEAAuE;YACvE,qEAAqE;YACrE,GAAG,CAAC,EAAE,EAAE,GAAoB,EAAE,QAAiB;gBAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ;oBAAE,OAAO,KAAK,CAAC;gBAE1C,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC3D,0DAA0D;gBAC1D,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACxD,+DAA+D;gBAC/D,yEAAyE;gBACzE,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;QAEH,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,CAA4B,CAAC;IACtC,CAAC;IAED,gEAAgE;IAChE,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAE3C,OAAO;QACL,KAAK;QACL,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa;QACrC,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa;KACtC,CAAC;AACJ,CAAC"}
|