@hamak/ui-store-impl 0.11.0 → 0.12.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 (89) hide show
  1. package/package.json +2 -2
  2. package/dist/autosave/autosave-config-resolver.d.ts +0 -45
  3. package/dist/autosave/autosave-config-resolver.d.ts.map +0 -1
  4. package/dist/autosave/autosave-config-resolver.js +0 -107
  5. package/dist/autosave/autosave-middleware.d.ts +0 -37
  6. package/dist/autosave/autosave-middleware.d.ts.map +0 -1
  7. package/dist/autosave/autosave-middleware.js +0 -297
  8. package/dist/autosave/autosave-registry.d.ts +0 -15
  9. package/dist/autosave/autosave-registry.d.ts.map +0 -1
  10. package/dist/autosave/autosave-registry.js +0 -33
  11. package/dist/autosave/autosave-sync-middleware.d.ts +0 -24
  12. package/dist/autosave/autosave-sync-middleware.d.ts.map +0 -1
  13. package/dist/autosave/autosave-sync-middleware.js +0 -98
  14. package/dist/autosave/index.d.ts +0 -8
  15. package/dist/autosave/index.d.ts.map +0 -1
  16. package/dist/autosave/index.js +0 -7
  17. package/dist/core/index.d.ts +0 -4
  18. package/dist/core/index.d.ts.map +0 -1
  19. package/dist/core/index.js +0 -3
  20. package/dist/core/middleware-registry.d.ts +0 -21
  21. package/dist/core/middleware-registry.d.ts.map +0 -1
  22. package/dist/core/middleware-registry.js +0 -50
  23. package/dist/core/reducer-registry.d.ts +0 -18
  24. package/dist/core/reducer-registry.d.ts.map +0 -1
  25. package/dist/core/reducer-registry.js +0 -54
  26. package/dist/core/store-manager.d.ts +0 -29
  27. package/dist/core/store-manager.d.ts.map +0 -1
  28. package/dist/core/store-manager.js +0 -104
  29. package/dist/es2015/autosave/autosave-config-resolver.js +0 -110
  30. package/dist/es2015/autosave/autosave-middleware.js +0 -311
  31. package/dist/es2015/autosave/autosave-registry.js +0 -33
  32. package/dist/es2015/autosave/autosave-sync-middleware.js +0 -98
  33. package/dist/es2015/autosave/index.js +0 -7
  34. package/dist/es2015/core/index.js +0 -3
  35. package/dist/es2015/core/middleware-registry.js +0 -47
  36. package/dist/es2015/core/reducer-registry.js +0 -54
  37. package/dist/es2015/core/store-manager.js +0 -104
  38. package/dist/es2015/extensions/store-extensions.js +0 -61
  39. package/dist/es2015/fs/commands/fs-commands.js +0 -327
  40. package/dist/es2015/fs/commands/structure-commands.js +0 -21
  41. package/dist/es2015/fs/core/fs-adapter.js +0 -134
  42. package/dist/es2015/fs/core/fs-facade.js +0 -78
  43. package/dist/es2015/fs/index.js +0 -11
  44. package/dist/es2015/fs/utils/data-updater.js +0 -251
  45. package/dist/es2015/fs/utils/deep-equal.js +0 -28
  46. package/dist/es2015/middleware/event-bridge-middleware.js +0 -19
  47. package/dist/es2015/middleware/index.js +0 -5
  48. package/dist/es2015/middleware/logger-middleware.js +0 -18
  49. package/dist/es2015/plugin/index.js +0 -4
  50. package/dist/es2015/plugin/store-plugin-factory.js +0 -137
  51. package/dist/extensions/store-extensions.d.ts +0 -23
  52. package/dist/extensions/store-extensions.d.ts.map +0 -1
  53. package/dist/extensions/store-extensions.js +0 -61
  54. package/dist/fs/commands/fs-commands.d.ts +0 -100
  55. package/dist/fs/commands/fs-commands.d.ts.map +0 -1
  56. package/dist/fs/commands/fs-commands.js +0 -330
  57. package/dist/fs/commands/structure-commands.d.ts +0 -76
  58. package/dist/fs/commands/structure-commands.d.ts.map +0 -1
  59. package/dist/fs/commands/structure-commands.js +0 -21
  60. package/dist/fs/core/fs-adapter.d.ts +0 -60
  61. package/dist/fs/core/fs-adapter.d.ts.map +0 -1
  62. package/dist/fs/core/fs-adapter.js +0 -134
  63. package/dist/fs/core/fs-facade.d.ts +0 -37
  64. package/dist/fs/core/fs-facade.d.ts.map +0 -1
  65. package/dist/fs/core/fs-facade.js +0 -78
  66. package/dist/fs/index.d.ts +0 -8
  67. package/dist/fs/index.d.ts.map +0 -1
  68. package/dist/fs/index.js +0 -11
  69. package/dist/fs/utils/data-updater.d.ts +0 -43
  70. package/dist/fs/utils/data-updater.d.ts.map +0 -1
  71. package/dist/fs/utils/data-updater.js +0 -255
  72. package/dist/fs/utils/deep-equal.d.ts +0 -5
  73. package/dist/fs/utils/deep-equal.d.ts.map +0 -1
  74. package/dist/fs/utils/deep-equal.js +0 -28
  75. package/dist/middleware/event-bridge-middleware.d.ts +0 -7
  76. package/dist/middleware/event-bridge-middleware.d.ts.map +0 -1
  77. package/dist/middleware/event-bridge-middleware.js +0 -19
  78. package/dist/middleware/index.d.ts +0 -6
  79. package/dist/middleware/index.d.ts.map +0 -1
  80. package/dist/middleware/index.js +0 -5
  81. package/dist/middleware/logger-middleware.d.ts +0 -7
  82. package/dist/middleware/logger-middleware.d.ts.map +0 -1
  83. package/dist/middleware/logger-middleware.js +0 -18
  84. package/dist/plugin/index.d.ts +0 -5
  85. package/dist/plugin/index.d.ts.map +0 -1
  86. package/dist/plugin/index.js +0 -4
  87. package/dist/plugin/store-plugin-factory.d.ts +0 -15
  88. package/dist/plugin/store-plugin-factory.d.ts.map +0 -1
  89. package/dist/plugin/store-plugin-factory.js +0 -121
@@ -1,251 +0,0 @@
1
- import { isDraft, original } from 'immer';
2
- import { navigate, ensurePath, areSameItineraryStep } from '@hamak/shared-utils';
3
- /**
4
- * Type guard for checking if a value is an object
5
- */
6
- function isObject(o) {
7
- if (o === undefined || o === null) {
8
- return false;
9
- }
10
- return (isDraft(o) && typeof original(o) === 'object')
11
- || typeof o === 'object';
12
- }
13
- /**
14
- * Type guard for checking if a value is an array
15
- */
16
- function isArray(o) {
17
- if (o === undefined || o === null) {
18
- return false;
19
- }
20
- return (isDraft(o) && Array.isArray(original(o)))
21
- || Array.isArray(o);
22
- }
23
- /**
24
- * DataUpdater class handles operations on data structures using itineraries
25
- */
26
- export class DataUpdater {
27
- /**
28
- * Delete a value at the specified itinerary
29
- */
30
- executeDelete(data, itinerary) {
31
- if (itinerary === undefined) {
32
- return { deleted: false, reason: 'itinerary-not-provided' };
33
- }
34
- const { parent, value: step } = itinerary;
35
- const parentNode = navigate(data, parent);
36
- if (parentNode === undefined) {
37
- return { deleted: false, reason: 'parent-not-found' };
38
- }
39
- if (isArray(parentNode)) {
40
- let position;
41
- if (step.type === 'position') {
42
- position = step.position;
43
- }
44
- else if (step.type === 'lookup') {
45
- position = parentNode.findIndex(element => element !== undefined
46
- && element !== null
47
- && step.keys.every(({ propertyName, propertyValue }) => element[propertyName] === propertyValue));
48
- }
49
- else {
50
- return { deleted: false, reason: 'array-step-not-supported' };
51
- }
52
- if (!Number.isInteger(position) || position < 0 || position >= parentNode.length) {
53
- return { deleted: false, reason: 'target-not-found' };
54
- }
55
- parentNode.splice(position, 1);
56
- return { deleted: true };
57
- }
58
- if (isObject(parentNode)) {
59
- if (step.type !== 'property') {
60
- return { deleted: false, reason: 'object-step-not-supported' };
61
- }
62
- if (!Object.prototype.hasOwnProperty.call(parentNode, step.propertyName)) {
63
- return { deleted: false, reason: 'target-not-found' };
64
- }
65
- delete parentNode[step.propertyName];
66
- return { deleted: true };
67
- }
68
- return { deleted: false, reason: 'parent-not-container' };
69
- }
70
- /**
71
- * Set a value at the specified itinerary
72
- */
73
- executeSet(data, itinerary, value, prototypeToParent) {
74
- if (itinerary === undefined) {
75
- return;
76
- }
77
- const { parent, value: step } = itinerary;
78
- const parentNode = ensurePath(data, parent, prototypeToParent);
79
- if (!(parentNode === undefined)) {
80
- if (isArray(parentNode)) {
81
- if (step.type === 'position') {
82
- parentNode[step.position] = value;
83
- }
84
- else {
85
- // TODO log expected PositionStep
86
- }
87
- }
88
- else if (isObject(parentNode)) {
89
- if (step.type === 'property') {
90
- if (parentNode !== null) {
91
- parentNode[step.propertyName] = value;
92
- }
93
- }
94
- else {
95
- // TODO log expected PropertyStep
96
- }
97
- }
98
- else {
99
- // TODO log expected object
100
- }
101
- }
102
- else {
103
- // TODO log Parent Node not found
104
- }
105
- }
106
- /**
107
- * Add a value at the specified itinerary
108
- */
109
- executeAdd(data, itinerary, value, prototypeToParent) {
110
- const targetNode = ensurePath(data, itinerary, prototypeToParent);
111
- if (!(targetNode === undefined)) {
112
- if (isArray(targetNode)) {
113
- targetNode.push(value);
114
- }
115
- else {
116
- // TODO log expected object
117
- }
118
- }
119
- else {
120
- // TODO log Parent Node not found
121
- }
122
- }
123
- /**
124
- * Insert a value at the specified position
125
- */
126
- executeInsert(data, itinerary, value, prototypeToParent) {
127
- const { value: step, parent } = itinerary;
128
- if (step.type === 'position') {
129
- const parentNode = ensurePath(data, parent, prototypeToParent);
130
- if (parentNode !== undefined) {
131
- if (isArray(parentNode)) {
132
- parentNode.splice(step.position, 0, value);
133
- }
134
- else {
135
- // TODO log expected object
136
- }
137
- }
138
- else {
139
- // TODO log Parent Node not found
140
- }
141
- }
142
- else {
143
- // TODO log expecting position step
144
- }
145
- }
146
- /**
147
- * Rebase a pending command's itinerary on top of an altering command.
148
- * Returns null if the pending command should be dropped (e.g., targets a deleted element).
149
- * Enhanced: Handles rebasing for nested itineraries, not just at the first divergence.
150
- */
151
- rebasePendingCommandOn(alteringCmd, pendingCmd) {
152
- // Convert itinerary stack to array (root to leaf)
153
- function itineraryToArray(it) {
154
- const arr = [];
155
- let current = it;
156
- while (current) {
157
- arr.push(current.value);
158
- current = current.parent;
159
- }
160
- return arr.reverse();
161
- }
162
- // Convert array back to itinerary stack (leaf to root)
163
- function arrayToItinerary(arr) {
164
- // Assumes arr.length > 0
165
- let it = { parent: undefined, value: arr[0] };
166
- for (let i = 1; i < arr.length; i++) {
167
- it = { parent: it, value: arr[i] };
168
- }
169
- return it;
170
- }
171
- // Rebase a single position step if needed
172
- function rebasePositionStep(alteringStep, alteringCmd, pendingStep) {
173
- if (pendingStep.type !== 'position' || alteringStep.type !== 'position')
174
- return pendingStep;
175
- let { position: pendingIdx } = pendingStep;
176
- const { position: alteringIdx } = alteringStep;
177
- if (alteringCmd.name === 'insert-at' && pendingIdx >= alteringIdx) {
178
- pendingIdx += 1;
179
- }
180
- else if (alteringCmd.name === 'delete-at') {
181
- if (pendingIdx > alteringIdx) {
182
- pendingIdx -= 1;
183
- }
184
- // If pendingIdx === alteringIdx, leave unchanged (may be dropped by batch context)
185
- }
186
- return pendingIdx !== pendingStep.position
187
- ? Object.assign(Object.assign({}, pendingStep), { position: pendingIdx }) : pendingStep;
188
- }
189
- const alteringArr = itineraryToArray(alteringCmd.itinerary);
190
- const pendingArr = itineraryToArray(pendingCmd.itinerary);
191
- // Find first index where steps differ
192
- let commonLength = 0;
193
- while (commonLength < alteringArr.length &&
194
- commonLength < pendingArr.length &&
195
- areSameItineraryStep(alteringArr[commonLength], pendingArr[commonLength])) {
196
- commonLength++;
197
- }
198
- // Rebase all position steps after the divergence point
199
- const rebasedArr = pendingArr.slice();
200
- for (let i = 0; i < alteringArr.length; i++) {
201
- if (alteringArr[i].type === 'position' &&
202
- pendingArr.length > i &&
203
- pendingArr[i].type === 'position') {
204
- // Only rebase if the pending itinerary matches the altering up to this step
205
- const isDescendant = alteringArr
206
- .slice(0, i)
207
- .every((step, j) => areSameItineraryStep(step, pendingArr[j]));
208
- if (isDescendant) {
209
- rebasedArr[i] = rebasePositionStep(alteringArr[i], alteringCmd, pendingArr[i]);
210
- }
211
- }
212
- }
213
- // If no itinerary, return as is
214
- if (rebasedArr.length === 0)
215
- return pendingCmd;
216
- return Object.assign(Object.assign({}, pendingCmd), { itinerary: arrayToItinerary(rebasedArr) });
217
- }
218
- /**
219
- * Executes a batch of commands, rebasing each on previous mutations.
220
- * @param data The data object to mutate
221
- * @param command The batch update command
222
- */
223
- executeBatch(data, command) {
224
- const { commands } = command;
225
- const applied = [];
226
- for (let i = 0; i < commands.length; i++) {
227
- let rebased = commands[i];
228
- for (let j = 0; j < applied.length && rebased != null; j++) {
229
- rebased = this.rebasePendingCommandOn(applied[j], rebased);
230
- }
231
- if (rebased != null) {
232
- switch (rebased.name) {
233
- case 'add-at':
234
- this.executeAdd(data, rebased.itinerary, rebased.value, rebased.prototypes);
235
- break;
236
- case 'insert-at':
237
- this.executeInsert(data, rebased.itinerary, rebased.value, rebased.prototypes);
238
- break;
239
- case 'set-at':
240
- this.executeSet(data, rebased.itinerary, rebased.value, rebased.prototypes);
241
- break;
242
- case 'delete-at':
243
- this.executeDelete(data, rebased.itinerary);
244
- break;
245
- }
246
- applied.push(rebased);
247
- }
248
- // If rebased is null, skip this command (it targets a deleted element)
249
- }
250
- }
251
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Deep equality check for objects and arrays
3
- */
4
- export function deepEqual(obj1, obj2) {
5
- if (obj1 === obj2) {
6
- return true;
7
- }
8
- if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
9
- return false;
10
- }
11
- if (Array.isArray(obj1) !== Array.isArray(obj2)) {
12
- return false;
13
- }
14
- const keys1 = Object.keys(obj1);
15
- const keys2 = Object.keys(obj2);
16
- if (keys1.length !== keys2.length) {
17
- return false;
18
- }
19
- for (const key of keys1) {
20
- if (!keys2.includes(key)) {
21
- return false;
22
- }
23
- if (!deepEqual(obj1[key], obj2[key])) {
24
- return false;
25
- }
26
- }
27
- return true;
28
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Event Bridge Middleware
3
- * Bridges Redux actions to microkernel event bus
4
- */
5
- export function createEventBridgeMiddleware(hooks) {
6
- return (store) => (next) => (action) => {
7
- // Emit before action
8
- hooks === null || hooks === void 0 ? void 0 : hooks.emit('redux:action:before', { action, state: store.getState() });
9
- // Execute action
10
- const result = next(action);
11
- // Emit after action
12
- hooks === null || hooks === void 0 ? void 0 : hooks.emit('redux:action:after', { action, state: store.getState() });
13
- // Emit specific action type event
14
- if (action === null || action === void 0 ? void 0 : action.type) {
15
- hooks === null || hooks === void 0 ? void 0 : hooks.emit(`redux:action:${action.type}`, action);
16
- }
17
- return result;
18
- };
19
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Middleware Export
3
- */
4
- export * from './event-bridge-middleware.js';
5
- export * from './logger-middleware.js';
@@ -1,18 +0,0 @@
1
- /**
2
- * Logger Middleware
3
- * Development logger for Redux actions
4
- */
5
- export function createLoggerMiddleware() {
6
- return (store) => (next) => (action) => {
7
- if (typeof (action === null || action === void 0 ? void 0 : action.type) === 'string') {
8
- console.group(`[Redux] ${action.type}`);
9
- console.log('Prev State:', store.getState());
10
- console.log('Action:', action);
11
- const result = next(action);
12
- console.log('Next State:', store.getState());
13
- console.groupEnd();
14
- return result;
15
- }
16
- return next(action);
17
- };
18
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Plugin Export
3
- */
4
- export * from './store-plugin-factory.js';
@@ -1,137 +0,0 @@
1
- /**
2
- * Store Plugin Factory
3
- * Creates a microkernel plugin for Redux store management
4
- */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- import { STORE_MANAGER_TOKEN, MIDDLEWARE_REGISTRY_TOKEN, REDUCER_REGISTRY_TOKEN, STORE_EXTENSIONS_TOKEN, } from '@hamak/ui-store-api';
15
- import { StoreManager } from '../core/store-manager.js';
16
- import { createEventBridgeMiddleware, createLoggerMiddleware, } from '../middleware/index.js';
17
- import { applyStoreExtensions, createStoreExtensionsCollector, } from '../extensions/store-extensions.js';
18
- import { createFileSystemAdapter } from '../fs/core/fs-adapter.js';
19
- // DI token for filesystem adapter
20
- export const FILESYSTEM_ADAPTER_TOKEN = 'FILESYSTEM_ADAPTER';
21
- export function createStorePlugin(config = {}) {
22
- const storeManager = new StoreManager();
23
- const middlewareRegistry = storeManager.getMiddlewareRegistry();
24
- const reducerRegistry = storeManager.getReducerRegistry();
25
- const extensionsCollector = createStoreExtensionsCollector();
26
- // Create filesystem adapter with 'fs' slice name
27
- const fileSystemAdapter = createFileSystemAdapter('fs');
28
- const registerDefaultMiddleware = (hooks) => {
29
- extensionsCollector.register('ui-store:event-bridge', {
30
- middleware: [
31
- {
32
- id: 'event-bridge',
33
- middleware: createEventBridgeMiddleware(hooks),
34
- priority: 1000,
35
- plugin: 'ui-store',
36
- description: 'Bridges Redux actions to microkernel events',
37
- },
38
- ],
39
- });
40
- if (config.logger !== false &&
41
- process.env.NODE_ENV === 'development') {
42
- extensionsCollector.register('ui-store:logger', {
43
- middleware: [
44
- {
45
- id: 'logger',
46
- middleware: createLoggerMiddleware(),
47
- priority: -1000,
48
- plugin: 'ui-store',
49
- description: 'Development logger',
50
- },
51
- ],
52
- });
53
- }
54
- };
55
- const registerConfigExtensions = () => {
56
- var _a;
57
- if ((_a = config.middleware) === null || _a === void 0 ? void 0 : _a.length) {
58
- const middleware = config.middleware.map((mw) => {
59
- var _a;
60
- return (Object.assign(Object.assign({}, mw), { plugin: (_a = mw.plugin) !== null && _a !== void 0 ? _a : 'ui-store-config' }));
61
- });
62
- extensionsCollector.register('ui-store-config:middleware', {
63
- middleware,
64
- });
65
- }
66
- // Call middlewareFactory if provided, passing the fileSystemAdapter
67
- if (config.middlewareFactory) {
68
- const factoryMiddleware = config.middlewareFactory(fileSystemAdapter);
69
- if (factoryMiddleware === null || factoryMiddleware === void 0 ? void 0 : factoryMiddleware.length) {
70
- extensionsCollector.register('ui-store-config:middleware-factory', {
71
- middleware: factoryMiddleware.map((mw) => {
72
- var _a;
73
- return (Object.assign(Object.assign({}, mw), { plugin: (_a = mw.plugin) !== null && _a !== void 0 ? _a : 'ui-store-config' }));
74
- }),
75
- });
76
- }
77
- }
78
- if (config.reducers && Object.keys(config.reducers).length) {
79
- extensionsCollector.register('ui-store-config:reducers', {
80
- reducers: config.reducers,
81
- });
82
- }
83
- };
84
- return {
85
- initialize(ctx) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- // Set filesystem adapter on store manager
88
- storeManager.setFileSystemAdapter(fileSystemAdapter);
89
- // Register filesystem reducer
90
- reducerRegistry.register('fs', fileSystemAdapter.getReducer());
91
- // Register services via DI
92
- ctx.provide({ provide: STORE_MANAGER_TOKEN, useValue: storeManager });
93
- ctx.provide({
94
- provide: MIDDLEWARE_REGISTRY_TOKEN,
95
- useValue: middlewareRegistry,
96
- });
97
- ctx.provide({
98
- provide: REDUCER_REGISTRY_TOKEN,
99
- useValue: reducerRegistry,
100
- });
101
- ctx.provide({
102
- provide: STORE_EXTENSIONS_TOKEN,
103
- useValue: extensionsCollector,
104
- });
105
- ctx.provide({
106
- provide: FILESYSTEM_ADAPTER_TOKEN,
107
- useValue: fileSystemAdapter,
108
- });
109
- registerDefaultMiddleware(ctx.hooks);
110
- registerConfigExtensions();
111
- console.log('[ui-store] Plugin initialized with filesystem support');
112
- });
113
- },
114
- activate(ctx) {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- applyStoreExtensions(extensionsCollector, middlewareRegistry, reducerRegistry);
117
- // Initialize the store after all plugins have registered middleware/reducers
118
- const store = storeManager.initialize({
119
- devTools: config.devTools,
120
- });
121
- // Bridge Redux state changes to microkernel events
122
- store.subscribe(() => {
123
- ctx.hooks.emit('redux:state-changed', store.getState());
124
- });
125
- // Emit ready event
126
- ctx.hooks.emit('ui-store:ready', { store });
127
- console.log('[ui-store] Plugin activated');
128
- });
129
- },
130
- deactivate() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- storeManager.destroy();
133
- console.log('[ui-store] Plugin deactivated');
134
- });
135
- },
136
- };
137
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Store extensions collector
3
- */
4
- import type { IMiddlewareRegistry, IReducerRegistry, StoreExtensionsRegistry, StorePluginExtensions } from '@hamak/ui-store-api';
5
- interface StoreExtensionsEntry {
6
- source: string;
7
- extensions: StorePluginExtensions;
8
- }
9
- /**
10
- * Collects middleware and reducer contributions until the store boots
11
- */
12
- export declare class StoreExtensionsCollector implements StoreExtensionsRegistry {
13
- private entries;
14
- register(source: string, extensions: StorePluginExtensions): void;
15
- /**
16
- * Drain collected extensions (used internally by the plugin)
17
- */
18
- drain(): StoreExtensionsEntry[];
19
- }
20
- export declare function applyStoreExtensions(collector: StoreExtensionsCollector, middlewareRegistry: IMiddlewareRegistry, reducerRegistry: IReducerRegistry): void;
21
- export declare function createStoreExtensionsCollector(): StoreExtensionsCollector;
22
- export {};
23
- //# sourceMappingURL=store-extensions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store-extensions.d.ts","sourceRoot":"","sources":["../../src/extensions/store-extensions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAE7B,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,wBAAyB,YAAW,uBAAuB;IACtE,OAAO,CAAC,OAAO,CAA8B;IAE7C,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAiBjE;;OAEG;IACH,KAAK,IAAI,oBAAoB,EAAE;CAKhC;AAgBD,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,wBAAwB,EACnC,kBAAkB,EAAE,mBAAmB,EACvC,eAAe,EAAE,gBAAgB,GAChC,IAAI,CAiBN;AAED,wBAAgB,8BAA8B,IAAI,wBAAwB,CAEzE"}
@@ -1,61 +0,0 @@
1
- /**
2
- * Store extensions collector
3
- */
4
- /**
5
- * Collects middleware and reducer contributions until the store boots
6
- */
7
- export class StoreExtensionsCollector {
8
- constructor() {
9
- this.entries = [];
10
- }
11
- register(source, extensions) {
12
- const hasMiddleware = Boolean(extensions.middleware?.length);
13
- const hasReducers = Boolean(extensions.reducers && Object.keys(extensions.reducers).length);
14
- if (!hasMiddleware && !hasReducers) {
15
- return;
16
- }
17
- this.entries.push({
18
- source,
19
- extensions: {
20
- middleware: extensions.middleware,
21
- reducers: extensions.reducers,
22
- },
23
- });
24
- }
25
- /**
26
- * Drain collected extensions (used internally by the plugin)
27
- */
28
- drain() {
29
- const snapshot = this.entries;
30
- this.entries = [];
31
- return snapshot;
32
- }
33
- }
34
- function withSourceMetadata(middleware, source) {
35
- if (!middleware) {
36
- return undefined;
37
- }
38
- return {
39
- plugin: middleware.plugin ?? source,
40
- ...middleware,
41
- };
42
- }
43
- export function applyStoreExtensions(collector, middlewareRegistry, reducerRegistry) {
44
- const entries = collector.drain();
45
- entries.forEach(({ source, extensions }) => {
46
- extensions.middleware?.forEach((mw) => {
47
- const middleware = withSourceMetadata(mw, source);
48
- if (middleware) {
49
- middlewareRegistry.register(middleware);
50
- }
51
- });
52
- if (extensions.reducers) {
53
- Object.entries(extensions.reducers).forEach(([key, reducer]) => {
54
- reducerRegistry.register(key, reducer);
55
- });
56
- }
57
- });
58
- }
59
- export function createStoreExtensionsCollector() {
60
- return new StoreExtensionsCollector();
61
- }
@@ -1,100 +0,0 @@
1
- import { FileNode, FileSystemNode, FileSystemState, FileContentSchema } from '@hamak/ui-store-api';
2
- import { StructureNodeCommand } from './structure-commands.js';
3
- import { DataUpdater } from '../utils/data-updater.js';
4
- /**
5
- * Base interface for filesystem commands
6
- */
7
- export interface FsCommandBase {
8
- name: 'mkdir' | 'set-file' | 'remove' | 'update-file-content' | 'set-file-content' | 'set-extension-state';
9
- path: string | string[];
10
- }
11
- /**
12
- * Create directory command
13
- */
14
- export interface MkdirCommand extends FsCommandBase {
15
- name: 'mkdir';
16
- parents?: boolean;
17
- extensionStates?: Record<string, unknown>;
18
- }
19
- /**
20
- * Remove file or directory command
21
- */
22
- export interface RemoveCommand extends FsCommandBase {
23
- name: 'remove';
24
- recursive?: boolean;
25
- }
26
- /**
27
- * Set file command (create or update)
28
- */
29
- export interface SetFileCommand extends FsCommandBase {
30
- name: 'set-file';
31
- content: any;
32
- schema: FileContentSchema;
33
- override?: boolean;
34
- contentIsPresent?: boolean;
35
- extensionStates?: Record<string, unknown>;
36
- }
37
- /**
38
- * Update file content with structure command
39
- */
40
- export interface UpdateFileContentCommand extends FsCommandBase {
41
- name: 'update-file-content';
42
- contentCommand: StructureNodeCommand;
43
- }
44
- /**
45
- * Set file content directly
46
- */
47
- export interface SetFileContentCommand extends FsCommandBase {
48
- name: 'set-file-content';
49
- content: any;
50
- fromRemote?: boolean;
51
- }
52
- /**
53
- * Set extension state on a node
54
- */
55
- export interface SetExtensionStateCommand extends FsCommandBase {
56
- name: 'set-extension-state';
57
- key: string;
58
- state: Record<string, unknown>;
59
- }
60
- /**
61
- * Union type for all filesystem commands
62
- */
63
- export type FileSystemCommand = MkdirCommand | RemoveCommand | SetFileCommand | UpdateFileContentCommand | SetFileContentCommand | SetExtensionStateCommand;
64
- export { pathSteps, parentPathSteps } from '@hamak/shared-utils';
65
- /**
66
- * Get filesystem node at path
67
- */
68
- export declare function getFileSystemNode(fsNode: FileSystemNode, path: string | string[]): FileSystemNode | undefined;
69
- /**
70
- * FileSystem command handler - executes filesystem operations
71
- */
72
- export declare class FileSystemCommandHandler {
73
- readonly contentCommandHandler: FileContentCommandHandler;
74
- execute(state: FileSystemState, command: FileSystemCommand): FileSystemState;
75
- private executeMkdir;
76
- private executeRemove;
77
- private executeSetFile;
78
- private executeContentCommand;
79
- private contentMayChange;
80
- private executeSetContentCommand;
81
- private executeSetExtensionState;
82
- protected current<T = any>(o: T): T;
83
- protected original<T = any>(o: T): T | undefined;
84
- }
85
- /**
86
- * File content command handler - handles structure commands on file content
87
- */
88
- export declare class FileContentCommandHandler {
89
- readonly updater: DataUpdater;
90
- execute(file: FileNode, command: StructureNodeCommand): void;
91
- private executeDelete;
92
- private executeSet;
93
- private executeAdd;
94
- private executeInsert;
95
- /**
96
- * Executes a batch of commands, rebasing each on previous mutations.
97
- */
98
- executeBatch(file: FileNode, command: any): void;
99
- }
100
- //# sourceMappingURL=fs-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