@base-framework/base 3.7.76 → 3.7.78

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.
@@ -64,13 +64,9 @@ export class Component extends Unit {
64
64
  /**
65
65
  * This will resume the data during persistence.
66
66
  *
67
- * For components with externally-provided data (temp components
68
- * created by { data: localVar } in layouts), we use the fresh
69
- * data instance from setData() so closure references stay valid.
70
- *
71
- * For regular components, the persisted data is the source of
72
- * truth — it holds accumulated state (list items, filters, etc.)
73
- * that should be preserved until the component fetches updates.
67
+ * Delegates to DataResumeHelper which owns the fresh-vs-persisted
68
+ * reconciliation, retain/refresh-state policy, silent stage writes,
69
+ * and stale-publish queue draining.
74
70
  *
75
71
  * @protected
76
72
  * @param {Data|null} persistedData
@@ -0,0 +1,125 @@
1
+ /** @typedef {import('../data/data.js').Data} Data */
2
+ /**
3
+ * DataResumeHelper
4
+ *
5
+ * Owns the data-merge logic used when a persisted component is
6
+ * resumed (e.g. when the router re-activates a cached route).
7
+ *
8
+ * The component delegates here so its own surface stays focused
9
+ * on lifecycle, leaving all of the
10
+ * - fresh-vs-persisted reconciliation,
11
+ * - retain/refresh-state policy,
12
+ * - silent stage writes, and
13
+ * - batched-publish queue draining
14
+ * in one auditable place.
15
+ *
16
+ * @class
17
+ */
18
+ export class DataResumeHelper {
19
+ /**
20
+ * This will resume the data for a component during persistence.
21
+ *
22
+ * @param {object} component - host component (mutated: component.data is set)
23
+ * @param {Data|null} persistedData
24
+ * @returns {void}
25
+ */
26
+ static resume(component: object, persistedData: Data | null): void;
27
+ /**
28
+ * Refresh the host component's data with fresh prop-derived
29
+ * values from setData(), then refresh context data from parent.
30
+ *
31
+ * @param {object} component
32
+ * @returns {void}
33
+ */
34
+ static refresh(component: object): void;
35
+ /**
36
+ * Push parent-context changes into the persisted context data.
37
+ * Only reference-changed keys are written, via the silent API,
38
+ * to avoid republishing the entire context tree on resume.
39
+ *
40
+ * @param {object} component
41
+ * @returns {void}
42
+ */
43
+ static refreshContext(component: object): void;
44
+ /**
45
+ * Resume path for temp components created by
46
+ * `{ data: localVar }` in layouts.
47
+ *
48
+ * The fresh data instance must win as the *reference*
49
+ * so closures in the parent atom still point at the
50
+ * same Data object, but the persisted *values* are the
51
+ * source of truth (the user's prior interactions —
52
+ * activeFilter, scroll position, etc.). Merging the
53
+ * persisted stage onto the fresh instance preserves
54
+ * both.
55
+ *
56
+ * Policy matches `_resumeOwned`:
57
+ * - retainState: persisted wins for ALL keys (incl. null).
58
+ * - refreshState: fresh wins; only persisted keys missing
59
+ * from fresh are copied.
60
+ * - default: persisted non-null values win on changed keys;
61
+ * null/undefined persisted values are ignored so fresh
62
+ * defaults stay and async refetches can repopulate.
63
+ *
64
+ * @protected
65
+ * @param {object} component
66
+ * @param {Data|null} persistedData
67
+ * @returns {void}
68
+ */
69
+ protected static _resumeExternal(component: object, persistedData: Data | null): void;
70
+ /**
71
+ * Diff persisted stage against fresh stage for external data.
72
+ *
73
+ * - retain=true: persisted values win for every key.
74
+ * - refresh=true: only persisted keys missing from fresh are
75
+ * copied (so async-added properties survive).
76
+ * - default: persisted non-null values win on changed keys;
77
+ * null/undefined persisted values are ignored.
78
+ *
79
+ * Reference-equal values are skipped to avoid the deep
80
+ * Publisher.publish cascade on unchanged subtrees.
81
+ *
82
+ * @protected
83
+ * @param {object} old
84
+ * @param {object} freshStage
85
+ * @param {boolean} retain
86
+ * @param {boolean} refresh
87
+ * @returns {Object<string, *>}
88
+ */
89
+ protected static _buildExternalUpdates(old: object, freshStage: object, retain: boolean, refresh: boolean): {
90
+ [x: string]: any;
91
+ };
92
+ /**
93
+ * Resume path for regular components: fresh data from
94
+ * setData() (already in component.data via _setupData)
95
+ * is the base; persisted values are merged in silently
96
+ * unless retainState is flagged (then persisted wins
97
+ * outright) or refreshState is flagged (then only keys
98
+ * missing from fresh are copied).
99
+ *
100
+ * @protected
101
+ * @param {object} component
102
+ * @param {Data|null} persistedData
103
+ * @returns {void}
104
+ */
105
+ protected static _resumeOwned(component: object, persistedData: Data | null): void;
106
+ /**
107
+ * Diff persisted stage against the fresh owned-data stage.
108
+ *
109
+ * - refresh=true: fresh values are authoritative; only
110
+ * persisted keys missing from fresh are copied.
111
+ * - refresh=false: persisted non-null values win on changed
112
+ * keys; null/undefined are ignored so fresh defaults stay,
113
+ * allowing the component to re-fetch on resume.
114
+ *
115
+ * @protected
116
+ * @param {object} old
117
+ * @param {object} currentStage
118
+ * @param {boolean} refresh
119
+ * @returns {Object<string, *>}
120
+ */
121
+ protected static _buildOwnedUpdates(old: object, currentStage: object, refresh: boolean): {
122
+ [x: string]: any;
123
+ };
124
+ }
125
+ export type Data = import("../data/data.js").Data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-framework/base",
3
- "version": "3.7.76",
3
+ "version": "3.7.78",
4
4
  "description": "This is a javascript framework.",
5
5
  "main": "./dist/base.js",
6
6
  "type": "module",