effectable 0.1.0

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.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/build/LICENSE +21 -0
  4. package/build/bootstrap/bootstrap.d.ts +32 -0
  5. package/build/bootstrap/bootstrap.d.ts.map +1 -0
  6. package/build/bootstrap/bootstrap.js +179 -0
  7. package/build/bootstrap/bootstrap.js.map +1 -0
  8. package/build/bootstrap/index.d.ts +9 -0
  9. package/build/bootstrap/index.d.ts.map +1 -0
  10. package/build/bootstrap/index.js +14 -0
  11. package/build/bootstrap/index.js.map +1 -0
  12. package/build/bootstrap/types.d.ts +105 -0
  13. package/build/bootstrap/types.d.ts.map +1 -0
  14. package/build/bootstrap/types.js +26 -0
  15. package/build/bootstrap/types.js.map +1 -0
  16. package/build/component/Component.d.ts +126 -0
  17. package/build/component/Component.d.ts.map +1 -0
  18. package/build/component/Component.js +123 -0
  19. package/build/component/Component.js.map +1 -0
  20. package/build/component/GraphRuntime.d.ts +457 -0
  21. package/build/component/GraphRuntime.d.ts.map +1 -0
  22. package/build/component/GraphRuntime.js +1168 -0
  23. package/build/component/GraphRuntime.js.map +1 -0
  24. package/build/component/constants.d.ts +1 -0
  25. package/build/component/constants.d.ts.map +1 -0
  26. package/build/component/constants.js +2 -0
  27. package/build/component/constants.js.map +1 -0
  28. package/build/component/context.d.ts +199 -0
  29. package/build/component/context.d.ts.map +1 -0
  30. package/build/component/context.js +262 -0
  31. package/build/component/context.js.map +1 -0
  32. package/build/component/graphRuntime.constants.d.ts +13 -0
  33. package/build/component/graphRuntime.constants.d.ts.map +1 -0
  34. package/build/component/graphRuntime.constants.js +15 -0
  35. package/build/component/graphRuntime.constants.js.map +1 -0
  36. package/build/component/h.d.ts +48 -0
  37. package/build/component/h.d.ts.map +1 -0
  38. package/build/component/h.js +72 -0
  39. package/build/component/h.js.map +1 -0
  40. package/build/component/index.d.ts +19 -0
  41. package/build/component/index.d.ts.map +1 -0
  42. package/build/component/index.js +39 -0
  43. package/build/component/index.js.map +1 -0
  44. package/build/component/lifecycle.d.ts +179 -0
  45. package/build/component/lifecycle.d.ts.map +1 -0
  46. package/build/component/lifecycle.js +367 -0
  47. package/build/component/lifecycle.js.map +1 -0
  48. package/build/component/refs.d.ts +105 -0
  49. package/build/component/refs.d.ts.map +1 -0
  50. package/build/component/refs.js +128 -0
  51. package/build/component/refs.js.map +1 -0
  52. package/build/component/types.d.ts +169 -0
  53. package/build/component/types.d.ts.map +1 -0
  54. package/build/component/types.js +40 -0
  55. package/build/component/types.js.map +1 -0
  56. package/build/connect/connect.d.ts +31 -0
  57. package/build/connect/connect.d.ts.map +1 -0
  58. package/build/connect/connect.js +500 -0
  59. package/build/connect/connect.js.map +1 -0
  60. package/build/connect/index.d.ts +8 -0
  61. package/build/connect/index.d.ts.map +1 -0
  62. package/build/connect/index.js +11 -0
  63. package/build/connect/index.js.map +1 -0
  64. package/build/connect/types.d.ts +90 -0
  65. package/build/connect/types.d.ts.map +1 -0
  66. package/build/connect/types.js +8 -0
  67. package/build/connect/types.js.map +1 -0
  68. package/build/index.d.ts +26 -0
  69. package/build/index.d.ts.map +1 -0
  70. package/build/index.js +60 -0
  71. package/build/index.js.map +1 -0
  72. package/build/runtime/BusDecorators.d.ts +113 -0
  73. package/build/runtime/BusDecorators.d.ts.map +1 -0
  74. package/build/runtime/BusDecorators.js +302 -0
  75. package/build/runtime/BusDecorators.js.map +1 -0
  76. package/build/runtime/CommandBus.d.ts +43 -0
  77. package/build/runtime/CommandBus.d.ts.map +1 -0
  78. package/build/runtime/CommandBus.js +65 -0
  79. package/build/runtime/CommandBus.js.map +1 -0
  80. package/build/runtime/EventBus.d.ts +50 -0
  81. package/build/runtime/EventBus.d.ts.map +1 -0
  82. package/build/runtime/EventBus.js +90 -0
  83. package/build/runtime/EventBus.js.map +1 -0
  84. package/build/runtime/HandleRegistry.d.ts +143 -0
  85. package/build/runtime/HandleRegistry.d.ts.map +1 -0
  86. package/build/runtime/HandleRegistry.js +244 -0
  87. package/build/runtime/HandleRegistry.js.map +1 -0
  88. package/build/runtime/QueryBus.d.ts +43 -0
  89. package/build/runtime/QueryBus.d.ts.map +1 -0
  90. package/build/runtime/QueryBus.js +65 -0
  91. package/build/runtime/QueryBus.js.map +1 -0
  92. package/build/runtime/index.d.ts +13 -0
  93. package/build/runtime/index.d.ts.map +1 -0
  94. package/build/runtime/index.js +32 -0
  95. package/build/runtime/index.js.map +1 -0
  96. package/build/runtime/types.d.ts +79 -0
  97. package/build/runtime/types.d.ts.map +1 -0
  98. package/build/runtime/types.js +8 -0
  99. package/build/runtime/types.js.map +1 -0
  100. package/build/store/createStore.d.ts +36 -0
  101. package/build/store/createStore.d.ts.map +1 -0
  102. package/build/store/createStore.js +131 -0
  103. package/build/store/createStore.js.map +1 -0
  104. package/build/store/index.d.ts +14 -0
  105. package/build/store/index.d.ts.map +1 -0
  106. package/build/store/index.js +39 -0
  107. package/build/store/index.js.map +1 -0
  108. package/build/store/middleware.d.ts +38 -0
  109. package/build/store/middleware.d.ts.map +1 -0
  110. package/build/store/middleware.js +99 -0
  111. package/build/store/middleware.js.map +1 -0
  112. package/build/store/selector.d.ts +62 -0
  113. package/build/store/selector.d.ts.map +1 -0
  114. package/build/store/selector.js +226 -0
  115. package/build/store/selector.js.map +1 -0
  116. package/build/store/semanticStateTree.d.ts +91 -0
  117. package/build/store/semanticStateTree.d.ts.map +1 -0
  118. package/build/store/semanticStateTree.js +263 -0
  119. package/build/store/semanticStateTree.js.map +1 -0
  120. package/build/store/types.d.ts +259 -0
  121. package/build/store/types.d.ts.map +1 -0
  122. package/build/store/types.js +28 -0
  123. package/build/store/types.js.map +1 -0
  124. package/package.json +109 -0
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ /* eslint-disable no-redeclare */
3
+ /**
4
+ * Selector System with Memoization
5
+ *
6
+ * Implements a memoized selector system similar to the reselect library.
7
+ * Selectors recompute only when dependencies change,
8
+ * which optimizes performance of reactive subscriptions.
9
+ *
10
+ * @module Effectable/store/selector
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.createSelector = createSelector;
14
+ exports.createStructuredSelector = createStructuredSelector;
15
+ /**
16
+ * Simple memoization for a single argument (state)
17
+ *
18
+ * Caches the function result based on a shallow equality check of the argument.
19
+ * If the argument has not changed (shallow equal), returns the cached result.
20
+ *
21
+ * @template F - Type of the function to memoize
22
+ * @param func - Function to memoize
23
+ * @returns Memoized function with extra methods
24
+ *
25
+ * @example
26
+ * const expensive = (state) => state.items.map(x => x * 2);
27
+ * const memoized = defaultMemoize(expensive);
28
+ *
29
+ * memoized(state1); // Computed
30
+ * memoized(state1); // Returns cache
31
+ * memoized(state2); // Recomputed
32
+ */
33
+ function defaultMemoize(func) {
34
+ let lastArg = null;
35
+ let lastResult = null;
36
+ let called = false;
37
+ let recomputationCount = 0;
38
+ const memoized = (arg) => {
39
+ // If never called or the argument changed — recompute
40
+ if (!called || !shallowEqual(arg, lastArg)) {
41
+ lastArg = arg;
42
+ lastResult = func(arg);
43
+ called = true;
44
+ recomputationCount++;
45
+ }
46
+ return lastResult;
47
+ };
48
+ // Cache reset method
49
+ memoized.resetMemoization = () => {
50
+ lastArg = null;
51
+ lastResult = null;
52
+ called = false;
53
+ recomputationCount = 0;
54
+ };
55
+ // Method returning recomputation count (for debugging)
56
+ memoized.recomputations = () => recomputationCount;
57
+ return memoized;
58
+ }
59
+ /**
60
+ * Shallow equality for primitives and objects
61
+ *
62
+ * Compares two values:
63
+ * - For primitives uses ===
64
+ * - For objects compares all top-level fields
65
+ * - For arrays compares length and elements
66
+ *
67
+ * @param a - First value
68
+ * @param b - Second value
69
+ * @returns true if values are equal (shallow)
70
+ */
71
+ function shallowEqual(a, b) {
72
+ // Strict equality (for primitives and references)
73
+ if (a === b) {
74
+ return true;
75
+ }
76
+ // Different types or null/undefined
77
+ if (typeof a !== 'object' || typeof b !== 'object') {
78
+ return false;
79
+ }
80
+ if (a === null || b === null) {
81
+ return false;
82
+ }
83
+ // For arrays
84
+ if (Array.isArray(a) && Array.isArray(b)) {
85
+ if (a.length !== b.length) {
86
+ return false;
87
+ }
88
+ for (let i = 0; i < a.length; i++) {
89
+ if (a[i] !== b[i]) {
90
+ return false;
91
+ }
92
+ }
93
+ return true;
94
+ }
95
+ // For objects
96
+ const keysA = Object.keys(a);
97
+ const keysB = Object.keys(b);
98
+ if (keysA.length !== keysB.length) {
99
+ return false;
100
+ }
101
+ for (const key of keysA) {
102
+ if (a[key] !== b[key]) {
103
+ return false;
104
+ }
105
+ }
106
+ return true;
107
+ }
108
+ /**
109
+ * Creates a memoized selector
110
+ *
111
+ * Takes input selectors and a combiner function.
112
+ * Input selectors extract dependencies from state.
113
+ * Combiner combines input selector results into the final result.
114
+ *
115
+ * The selector recomputes only when:
116
+ * - At least one input selector result changed (shallow equality)
117
+ *
118
+ * @template S - State type
119
+ * @template T - Result type
120
+ *
121
+ * @param args - Input selectors + combiner function at the end
122
+ * @returns Memoized selector
123
+ *
124
+ * @example
125
+ * // Simple selector
126
+ * const selectCount = createSelector(
127
+ * [(state) => state.count],
128
+ * (count) => count * 2
129
+ * );
130
+ *
131
+ * @example
132
+ * // Selector composition
133
+ * const selectUsers = (state) => state.users;
134
+ * const selectFilter = (state) => state.filter;
135
+ *
136
+ * const selectFilteredUsers = createSelector(
137
+ * [selectUsers, selectFilter],
138
+ * (users, filter) => users.filter(u => u.name.includes(filter))
139
+ * );
140
+ *
141
+ * @example
142
+ * // Usage with store.select()
143
+ * store.select(selectFilteredUsers).subscribe(users => {
144
+ * console.log('Filtered users:', users);
145
+ * });
146
+ */
147
+ function createSelector(...args) {
148
+ // Last argument is the combiner function
149
+ const combiner = args[args.length - 1];
150
+ // Remaining arguments are input selectors
151
+ // Two formats are supported:
152
+ // 1. createSelector(sel1, sel2, combiner) - selectors as separate arguments
153
+ // 2. createSelector([sel1, sel2], combiner) - selectors as an array
154
+ let inputSelectors;
155
+ if (Array.isArray(args[0])) {
156
+ // Format: createSelector([sel1, sel2], combiner)
157
+ inputSelectors = args[0];
158
+ }
159
+ else {
160
+ // Format: createSelector(sel1, sel2, combiner)
161
+ inputSelectors = args.slice(0, -1);
162
+ }
163
+ // Memoize the combiner function.
164
+ // IMPORTANT: defaultMemoize memoizes on a SINGLE argument only, so
165
+ // we pass the dependency array as one argument and then
166
+ // "spread" it into the combiner (as in reselect).
167
+ const memoizedCombiner = defaultMemoize((params) => combiner(...params));
168
+ /**
169
+ * Resulting selector
170
+ *
171
+ * Calls all input selectors, collects results into an array,
172
+ * and passes them to the memoized combiner.
173
+ */
174
+ const selector = (state) => {
175
+ // Get results of all input selectors
176
+ const params = inputSelectors.map((inputSelector) => inputSelector(state));
177
+ // Apply the memoized combiner
178
+ // Memoization is based on shallow equality of the params array
179
+ return memoizedCombiner(params);
180
+ };
181
+ // Add methods for debugging and cache control
182
+ const memoizedSelector = selector;
183
+ memoizedSelector.resetMemoization = () => {
184
+ memoizedCombiner.resetMemoization();
185
+ };
186
+ memoizedSelector.recomputations = () => {
187
+ return memoizedCombiner.recomputations();
188
+ };
189
+ return memoizedSelector;
190
+ }
191
+ /**
192
+ * Creates a structured selector from an object of selectors
193
+ *
194
+ * Convenient utility for creating a selector that returns an object
195
+ * with results of several selectors.
196
+ *
197
+ * @template S - State type
198
+ * @template T - Result type (object with selectors)
199
+ *
200
+ * @param selectorsObj - Object where keys are field names and values are selectors
201
+ * @returns Memoized selector returning an object of results
202
+ *
203
+ * @example
204
+ * const selectNavigation = createStructuredSelector({
205
+ * currentPath: (state) => state.navigation.currentPath,
206
+ * breadcrumb: (state) => state.navigation.breadcrumb,
207
+ * canGoBack: (state) => state.navigation.history.backStack.length > 0,
208
+ * });
209
+ *
210
+ * // Result: { currentPath: '...', breadcrumb: [...], canGoBack: true }
211
+ * store.select(selectNavigation).subscribe(nav => {
212
+ * console.log('Navigation:', nav);
213
+ * });
214
+ */
215
+ function createStructuredSelector(selectorsObj) {
216
+ const keys = Object.keys(selectorsObj);
217
+ const selectors = keys.map((key) => selectorsObj[key]);
218
+ return createSelector(selectors, (...values) => {
219
+ const result = {};
220
+ keys.forEach((key, index) => {
221
+ result[key] = values[index];
222
+ });
223
+ return result;
224
+ });
225
+ }
226
+ //# sourceMappingURL=selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.js","sourceRoot":"","sources":["../../src/store/selector.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC;;;;;;;;GAQG;;AAuNH,wCAmDC;AA0BD,4DAaC;AApSD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAS,cAAc,CAA+B,IAAO;IAC3D,IAAI,OAAO,GAAQ,IAAI,CAAC;IACxB,IAAI,UAAU,GAAQ,IAAI,CAAC;IAC3B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,kBAAkB,GAAG,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,CAAC,GAAQ,EAAE,EAAE;QAC5B,sDAAsD;QACtD,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC;YAC3C,OAAO,GAAG,GAAG,CAAC;YACd,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACvB,MAAM,GAAG,IAAI,CAAC;YACd,kBAAkB,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;IAEF,qBAAqB;IACrB,QAAQ,CAAC,gBAAgB,GAAG,GAAG,EAAE;QAC/B,OAAO,GAAG,IAAI,CAAC;QACf,UAAU,GAAG,IAAI,CAAC;QAClB,MAAM,GAAG,KAAK,CAAC;QACf,kBAAkB,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,uDAAuD;IACvD,QAAQ,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC,kBAAkB,CAAC;IAEnD,OAAO,QAAgC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;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AC;IAEF,gBAAgB,CAAC,cAAc,GAAG,GAAG,EAAE;QACrC,OAAO,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,wBAAwB,CACtC,YAAmD;IAEnD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAmB,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,OAAO,cAAc,CAAC,SAAS,EAAE,CAAC,GAAG,MAAa,EAAE,EAAE;QACpD,MAAM,MAAM,GAAG,EAAO,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Builds a semantic JSON tree from a store state snapshot / reducer map.
3
+ *
4
+ * Reducers at runtime do not describe data shape without initial state, so
5
+ * the walk is performed over the provided `initialState` (or `store.getState()`),
6
+ * and the `{ slice: reducer }` map is used to align slice keys with the root state.
7
+ *
8
+ * @module Effectable/store/semanticStateTree
9
+ */
10
+ import type { Action, Reducer, Store } from './types';
11
+ /**
12
+ * Primitive kind in the semantic tree.
13
+ */
14
+ export type SemanticJsonPrimitiveKind = 'null' | 'undefined' | 'boolean' | 'number' | 'string' | 'bigint' | 'symbol';
15
+ /**
16
+ * Semantic tree node suitable for `JSON.stringify`.
17
+ */
18
+ export type SemanticJsonNode = {
19
+ kind: 'primitive';
20
+ valueType: SemanticJsonPrimitiveKind;
21
+ } | {
22
+ kind: 'date';
23
+ iso: string;
24
+ } | {
25
+ kind: 'array';
26
+ length: number;
27
+ item: SemanticJsonNode | null;
28
+ } | {
29
+ kind: 'object';
30
+ keys: Record<string, SemanticJsonNode>;
31
+ } | {
32
+ kind: 'reference';
33
+ reused: true;
34
+ } | {
35
+ kind: 'truncated';
36
+ maxDepthExceeded: true;
37
+ } | {
38
+ kind: 'nonSerializable';
39
+ description: string;
40
+ };
41
+ /**
42
+ * Options for building the tree.
43
+ */
44
+ export interface BuildSemanticStateTreeOptions {
45
+ /**
46
+ * Maximum nesting depth (root counts as depth 0).
47
+ */
48
+ maxDepth?: number;
49
+ /**
50
+ * Maximum keys on a single object (the rest are listed as `__overflow`).
51
+ */
52
+ maxKeysPerObject?: number;
53
+ }
54
+ /**
55
+ * Build a semantic tree from an arbitrary state snapshot (root is a single node).
56
+ *
57
+ * @param {unknown} state - root state or any fragment
58
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
59
+ * @returns {SemanticJsonNode} tree serializable to JSON
60
+ */
61
+ export declare function buildSemanticStateTree(state: unknown, options?: BuildSemanticStateTreeOptions): SemanticJsonNode;
62
+ /**
63
+ * Build a semantic tree from the store's current state.
64
+ *
65
+ * @template S - store state type
66
+ * @template A - store action type
67
+ * @param {Store<S, A>} store - store instance from `createStore`
68
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
69
+ * @returns {SemanticJsonNode} state tree
70
+ */
71
+ export declare function buildSemanticStateTreeFromStore<S, A extends Action = Action>(store: Store<S, A>, options?: BuildSemanticStateTreeOptions): SemanticJsonNode;
72
+ /**
73
+ * Build a semantic tree from a reducer map and a matching initial state.
74
+ * Keys of `reducerMap` and `initialState` must match as sets (otherwise an error is thrown).
75
+ *
76
+ * @param {Record<string, Reducer<unknown, Action>>} reducerMap - map of slice names to reducers
77
+ * @param {Record<string, unknown>} initialState - initial state with the same keys
78
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
79
+ * @returns {SemanticJsonNode} state tree
80
+ */
81
+ export declare function buildSemanticStateTreeFromReducerMap(reducerMap: Record<string, Reducer<unknown, Action>>, initialState: Record<string, unknown>, options?: BuildSemanticStateTreeOptions): SemanticJsonNode;
82
+ /**
83
+ * Serialize a semantic tree to a JSON string (with indentation by default).
84
+ *
85
+ * @param {unknown} state - root state
86
+ * @param {BuildSemanticStateTreeOptions} [options] - tree options
87
+ * @param {number | string} [space] - indent for `JSON.stringify` (default 2)
88
+ * @returns {string} JSON string
89
+ */
90
+ export declare function semanticStateTreeToJsonString(state: unknown, options?: BuildSemanticStateTreeOptions, space?: number | string): string;
91
+ //# sourceMappingURL=semanticStateTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticStateTree.d.ts","sourceRoot":"","sources":["../../src/store/semanticStateTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACA,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,yBAAyB,CAAC;CACtC,GACC;IACA,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GACC;IACA,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC/B,GACC;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACxC,GACC;IACA,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,IAAI,CAAC;CACd,GACC;IACA,IAAI,EAAE,WAAW,CAAC;IAClB,gBAAgB,EAAE,IAAI,CAAC;CACxB,GACC;IACA,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAwND;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,6BAA6B,GAAG,gBAAgB,CAIjH;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAC1E,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAElB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAClD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAwBlB;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,6BAA6B,EACvC,KAAK,GAAE,MAAM,GAAG,MAAU,GACzB,MAAM,CAGR"}
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ /**
3
+ * Builds a semantic JSON tree from a store state snapshot / reducer map.
4
+ *
5
+ * Reducers at runtime do not describe data shape without initial state, so
6
+ * the walk is performed over the provided `initialState` (or `store.getState()`),
7
+ * and the `{ slice: reducer }` map is used to align slice keys with the root state.
8
+ *
9
+ * @module Effectable/store/semanticStateTree
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.buildSemanticStateTree = buildSemanticStateTree;
13
+ exports.buildSemanticStateTreeFromStore = buildSemanticStateTreeFromStore;
14
+ exports.buildSemanticStateTreeFromReducerMap = buildSemanticStateTreeFromReducerMap;
15
+ exports.semanticStateTreeToJsonString = semanticStateTreeToJsonString;
16
+ const DEFAULT_MAX_DEPTH = 32;
17
+ const DEFAULT_MAX_KEYS = 500;
18
+ /**
19
+ * Resolve tree-building options.
20
+ *
21
+ * @param {BuildSemanticStateTreeOptions | undefined} options - user options
22
+ * @returns {ResolvedBuildSemanticStateTreeOptions} values with defaults
23
+ */
24
+ function resolveOptions(options) {
25
+ const maxDepth = typeof options?.maxDepth === 'number' && Number.isFinite(options.maxDepth) && options.maxDepth >= 0
26
+ ? Math.floor(options.maxDepth)
27
+ : DEFAULT_MAX_DEPTH;
28
+ const maxKeysPerObject = typeof options?.maxKeysPerObject === 'number' &&
29
+ Number.isFinite(options.maxKeysPerObject) &&
30
+ options.maxKeysPerObject >= 1
31
+ ? Math.floor(options.maxKeysPerObject)
32
+ : DEFAULT_MAX_KEYS;
33
+ return {
34
+ maxDepth,
35
+ maxKeysPerObject,
36
+ };
37
+ }
38
+ /**
39
+ * Check for a “plain” object (not an array and not null).
40
+ *
41
+ * @param {unknown} value - value to check
42
+ * @returns {boolean} true if it is a plain object
43
+ */
44
+ function isPlainObject(value) {
45
+ if (typeof value !== 'object' || value === null) {
46
+ return false;
47
+ }
48
+ if (Array.isArray(value)) {
49
+ return false;
50
+ }
51
+ const proto = Object.getPrototypeOf(value);
52
+ if (proto === null) {
53
+ return true;
54
+ }
55
+ if (proto === Object.prototype) {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+ /**
61
+ * Build a tree node for an arbitrary value.
62
+ *
63
+ * @param {unknown} value - value from state
64
+ * @param {number} depth - current depth
65
+ * @param {WeakSet<object>} visited - already visited objects (for references)
66
+ * @param {ResolvedBuildSemanticStateTreeOptions} options - resolved options
67
+ * @returns {SemanticJsonNode} tree node
68
+ */
69
+ function buildNode(value, depth, visited, options) {
70
+ if (depth > options.maxDepth) {
71
+ return {
72
+ kind: 'truncated',
73
+ maxDepthExceeded: true,
74
+ };
75
+ }
76
+ if (value === null) {
77
+ return {
78
+ kind: 'primitive',
79
+ valueType: 'null',
80
+ };
81
+ }
82
+ if (value === undefined) {
83
+ return {
84
+ kind: 'primitive',
85
+ valueType: 'undefined',
86
+ };
87
+ }
88
+ const typeofValue = typeof value;
89
+ if (typeofValue === 'boolean') {
90
+ return {
91
+ kind: 'primitive',
92
+ valueType: 'boolean',
93
+ };
94
+ }
95
+ if (typeofValue === 'number') {
96
+ return {
97
+ kind: 'primitive',
98
+ valueType: 'number',
99
+ };
100
+ }
101
+ if (typeofValue === 'string') {
102
+ return {
103
+ kind: 'primitive',
104
+ valueType: 'string',
105
+ };
106
+ }
107
+ if (typeofValue === 'bigint') {
108
+ return {
109
+ kind: 'primitive',
110
+ valueType: 'bigint',
111
+ };
112
+ }
113
+ if (typeofValue === 'symbol') {
114
+ return {
115
+ kind: 'primitive',
116
+ valueType: 'symbol',
117
+ };
118
+ }
119
+ if (typeofValue === 'function') {
120
+ return {
121
+ kind: 'nonSerializable',
122
+ description: 'function',
123
+ };
124
+ }
125
+ if (typeof value === 'object') {
126
+ if (value instanceof Date) {
127
+ return {
128
+ kind: 'date',
129
+ iso: value.toISOString(),
130
+ };
131
+ }
132
+ if (visited.has(value)) {
133
+ return {
134
+ kind: 'reference',
135
+ reused: true,
136
+ };
137
+ }
138
+ visited.add(value);
139
+ if (Array.isArray(value)) {
140
+ const length = value.length;
141
+ let item = null;
142
+ if (length > 0) {
143
+ item = buildNode(value[0], depth + 1, visited, options);
144
+ }
145
+ return {
146
+ kind: 'array',
147
+ length,
148
+ item,
149
+ };
150
+ }
151
+ if (isPlainObject(value)) {
152
+ const keys = Object.keys(value);
153
+ const keysOut = {};
154
+ const limit = options.maxKeysPerObject;
155
+ let processed = 0;
156
+ for (let i = 0; i < keys.length; i++) {
157
+ if (processed >= limit) {
158
+ break;
159
+ }
160
+ const key = keys[i];
161
+ if (key === undefined) {
162
+ continue;
163
+ }
164
+ if (!Object.hasOwn(value, key)) {
165
+ continue;
166
+ }
167
+ const child = Reflect.get(value, key);
168
+ keysOut[key] = buildNode(child, depth + 1, visited, options);
169
+ processed = processed + 1;
170
+ }
171
+ const omitted = keys.length - processed;
172
+ if (omitted > 0) {
173
+ keysOut['__semanticOverflow'] = {
174
+ kind: 'nonSerializable',
175
+ description: `omitted keys: ${String(omitted)}`,
176
+ };
177
+ }
178
+ return {
179
+ kind: 'object',
180
+ keys: keysOut,
181
+ };
182
+ }
183
+ const ctor = value.constructor;
184
+ const name = ctor !== undefined && ctor !== null && typeof ctor.name === 'string' ? ctor.name : 'Object';
185
+ return {
186
+ kind: 'nonSerializable',
187
+ description: `instance:${name}`,
188
+ };
189
+ }
190
+ return {
191
+ kind: 'nonSerializable',
192
+ description: 'unknown',
193
+ };
194
+ }
195
+ /**
196
+ * Build a semantic tree from an arbitrary state snapshot (root is a single node).
197
+ *
198
+ * @param {unknown} state - root state or any fragment
199
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
200
+ * @returns {SemanticJsonNode} tree serializable to JSON
201
+ */
202
+ function buildSemanticStateTree(state, options) {
203
+ const resolved = resolveOptions(options);
204
+ const visited = new WeakSet();
205
+ return buildNode(state, 0, visited, resolved);
206
+ }
207
+ /**
208
+ * Build a semantic tree from the store's current state.
209
+ *
210
+ * @template S - store state type
211
+ * @template A - store action type
212
+ * @param {Store<S, A>} store - store instance from `createStore`
213
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
214
+ * @returns {SemanticJsonNode} state tree
215
+ */
216
+ function buildSemanticStateTreeFromStore(store, options) {
217
+ return buildSemanticStateTree(store.getState(), options);
218
+ }
219
+ /**
220
+ * Build a semantic tree from a reducer map and a matching initial state.
221
+ * Keys of `reducerMap` and `initialState` must match as sets (otherwise an error is thrown).
222
+ *
223
+ * @param {Record<string, Reducer<unknown, Action>>} reducerMap - map of slice names to reducers
224
+ * @param {Record<string, unknown>} initialState - initial state with the same keys
225
+ * @param {BuildSemanticStateTreeOptions} [options] - depth and key-count limits
226
+ * @returns {SemanticJsonNode} state tree
227
+ */
228
+ function buildSemanticStateTreeFromReducerMap(reducerMap, initialState, options) {
229
+ const reducerKeys = Object.keys(reducerMap);
230
+ for (let i = 0; i < reducerKeys.length; i++) {
231
+ const key = reducerKeys[i];
232
+ if (key === undefined) {
233
+ continue;
234
+ }
235
+ if (!Object.hasOwn(initialState, key)) {
236
+ throw new Error(`buildSemanticStateTreeFromReducerMap: initialState does not contain key "${key}" from reducerMap`);
237
+ }
238
+ }
239
+ const stateKeys = Object.keys(initialState);
240
+ for (let i = 0; i < stateKeys.length; i++) {
241
+ const key = stateKeys[i];
242
+ if (key === undefined) {
243
+ continue;
244
+ }
245
+ if (!Object.hasOwn(reducerMap, key)) {
246
+ throw new Error(`buildSemanticStateTreeFromReducerMap: reducerMap does not contain key "${key}" from initialState`);
247
+ }
248
+ }
249
+ return buildSemanticStateTree(initialState, options);
250
+ }
251
+ /**
252
+ * Serialize a semantic tree to a JSON string (with indentation by default).
253
+ *
254
+ * @param {unknown} state - root state
255
+ * @param {BuildSemanticStateTreeOptions} [options] - tree options
256
+ * @param {number | string} [space] - indent for `JSON.stringify` (default 2)
257
+ * @returns {string} JSON string
258
+ */
259
+ function semanticStateTreeToJsonString(state, options, space = 2) {
260
+ const tree = buildSemanticStateTree(state, options);
261
+ return JSON.stringify(tree, null, space);
262
+ }
263
+ //# sourceMappingURL=semanticStateTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticStateTree.js","sourceRoot":"","sources":["../../src/store/semanticStateTree.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA6RH,wDAIC;AAWD,0EAKC;AAWD,oFA4BC;AAUD,sEAOC;AAzSD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,gBAAgB,GAAG,GA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