@hamak/ui-store-impl 0.4.16 → 0.5.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 (41) hide show
  1. package/dist/autosave/autosave-config-resolver.d.ts +45 -0
  2. package/dist/autosave/autosave-config-resolver.d.ts.map +1 -0
  3. package/dist/autosave/autosave-config-resolver.js +107 -0
  4. package/dist/autosave/autosave-middleware.d.ts +37 -0
  5. package/dist/autosave/autosave-middleware.d.ts.map +1 -0
  6. package/dist/autosave/autosave-middleware.js +297 -0
  7. package/dist/autosave/autosave-registry.d.ts +15 -0
  8. package/dist/autosave/autosave-registry.d.ts.map +1 -0
  9. package/dist/autosave/autosave-registry.js +33 -0
  10. package/dist/autosave/autosave-sync-middleware.d.ts +24 -0
  11. package/dist/autosave/autosave-sync-middleware.d.ts.map +1 -0
  12. package/dist/autosave/autosave-sync-middleware.js +98 -0
  13. package/dist/autosave/index.d.ts +8 -0
  14. package/dist/autosave/index.d.ts.map +1 -0
  15. package/dist/autosave/index.js +7 -0
  16. package/dist/core/store-manager.d.ts +4 -1
  17. package/dist/core/store-manager.d.ts.map +1 -1
  18. package/dist/core/store-manager.js +28 -15
  19. package/dist/es2015/autosave/autosave-config-resolver.js +110 -0
  20. package/dist/es2015/autosave/autosave-middleware.js +311 -0
  21. package/dist/es2015/autosave/autosave-registry.js +33 -0
  22. package/dist/es2015/autosave/autosave-sync-middleware.js +98 -0
  23. package/dist/es2015/autosave/index.js +7 -0
  24. package/dist/es2015/core/store-manager.js +28 -15
  25. package/dist/es2015/fs/commands/fs-commands.js +36 -7
  26. package/dist/es2015/fs/core/fs-adapter.js +16 -5
  27. package/dist/es2015/index.js +1 -0
  28. package/dist/es2015/plugin/store-plugin-factory.js +26 -1
  29. package/dist/fs/commands/fs-commands.d.ts +13 -2
  30. package/dist/fs/commands/fs-commands.d.ts.map +1 -1
  31. package/dist/fs/commands/fs-commands.js +39 -7
  32. package/dist/fs/core/fs-adapter.d.ts +4 -1
  33. package/dist/fs/core/fs-adapter.d.ts.map +1 -1
  34. package/dist/fs/core/fs-adapter.js +16 -5
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1 -0
  38. package/dist/plugin/store-plugin-factory.d.ts +1 -0
  39. package/dist/plugin/store-plugin-factory.d.ts.map +1 -1
  40. package/dist/plugin/store-plugin-factory.js +26 -1
  41. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Store Manager Implementation
3
3
  */
4
- import { createStore, applyMiddleware, compose } from 'redux';
4
+ import { configureStore } from '@reduxjs/toolkit';
5
5
  import { MiddlewareRegistry } from './middleware-registry';
6
6
  import { ReducerRegistry } from './reducer-registry';
7
7
  export class StoreManager {
@@ -9,6 +9,7 @@ export class StoreManager {
9
9
  this.store = null;
10
10
  this.initialized = false;
11
11
  this.config = null;
12
+ this.fileSystemAdapter = null;
12
13
  this.middlewareRegistry = new MiddlewareRegistry();
13
14
  this.reducerRegistry = new ReducerRegistry((rootReducer) => {
14
15
  // Hot replacement callback
@@ -23,6 +24,12 @@ export class StoreManager {
23
24
  getReducerRegistry() {
24
25
  return this.reducerRegistry;
25
26
  }
27
+ setFileSystemAdapter(adapter) {
28
+ this.fileSystemAdapter = adapter;
29
+ }
30
+ getFileSystemAdapter() {
31
+ return this.fileSystemAdapter;
32
+ }
26
33
  isInitialized() {
27
34
  return this.initialized;
28
35
  }
@@ -39,20 +46,26 @@ export class StoreManager {
39
46
  const rootReducer = this.reducerRegistry.getCombinedReducer();
40
47
  // Create enhancers
41
48
  const enhancers = config.enhancers || [];
42
- // Setup Redux DevTools
43
- let composeEnhancers = compose;
44
- if (config.devTools !== false && typeof window !== 'undefined') {
45
- const devToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
46
- if (devToolsExtension) {
47
- composeEnhancers = devToolsExtension({
48
- trace: true,
49
- traceLimit: 25,
50
- });
51
- }
52
- }
53
- // Create store
54
- const enhancer = composeEnhancers(applyMiddleware(...middleware), ...enhancers);
55
- this.store = createStore(rootReducer, config.preloadedState, enhancer);
49
+ // Create store using configureStore (modern Redux Toolkit API)
50
+ this.store = configureStore({
51
+ reducer: rootReducer,
52
+ preloadedState: config.preloadedState,
53
+ // Use only our custom middleware (disabling Redux Toolkit defaults to maintain exact behavior)
54
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
55
+ // Disable all default middleware to maintain exact parity with old createStore behavior
56
+ thunk: false,
57
+ serializableCheck: false,
58
+ immutableCheck: false,
59
+ actionCreatorCheck: false,
60
+ }).concat(...middleware),
61
+ // Add custom enhancers if provided
62
+ enhancers: (getDefaultEnhancers) => getDefaultEnhancers().concat(enhancers),
63
+ // Configure DevTools with trace support
64
+ devTools: config.devTools !== false ? {
65
+ trace: true,
66
+ traceLimit: 25,
67
+ } : false,
68
+ });
56
69
  this.initialized = true;
57
70
  console.log('[StoreManager] Store initialized with:', {
58
71
  reducers: this.reducerRegistry.getAllRegistrations().map(r => r.key),
@@ -28,10 +28,14 @@ export function getFileSystemNode(fsNode, path) {
28
28
  /**
29
29
  * Create a directory node
30
30
  */
31
- function createDirectoryNode(step) {
31
+ function createDirectoryNode(step, extensionStates) {
32
+ const state = fileSystemNodeInitialState();
33
+ if (extensionStates) {
34
+ state.extensionStates = Object.assign(Object.assign({}, state.extensionStates), extensionStates);
35
+ }
32
36
  return {
33
37
  type: 'directory',
34
- state: fileSystemNodeInitialState(),
38
+ state,
35
39
  name: step,
36
40
  children: {}
37
41
  };
@@ -39,7 +43,10 @@ function createDirectoryNode(step) {
39
43
  /**
40
44
  * Create a file node
41
45
  */
42
- function createFileNode(name, content, schema, state) {
46
+ function createFileNode(name, content, schema, state, extensionStates) {
47
+ if (extensionStates) {
48
+ state.extensionStates = Object.assign(Object.assign({}, state.extensionStates), extensionStates);
49
+ }
43
50
  return { type: 'file', name, content, schema, state };
44
51
  }
45
52
  /**
@@ -56,10 +63,11 @@ export class FileSystemCommandHandler {
56
63
  case 'update-file-content': return this.executeContentCommand(state, command);
57
64
  case 'set-file-content': return this.executeSetContentCommand(state, command);
58
65
  case 'remove': return this.executeRemove(state, command);
66
+ case 'set-extension-state': return this.executeSetExtensionState(state, command);
59
67
  }
60
68
  }
61
69
  executeMkdir(state, command) {
62
- const { path, parents } = command;
70
+ const { path, parents, extensionStates } = command;
63
71
  const steps = pathSteps(path);
64
72
  return produce(state, draft => {
65
73
  const { root } = draft;
@@ -69,7 +77,7 @@ export class FileSystemCommandHandler {
69
77
  if (i + 1 === steps.length) {
70
78
  // Last step is the element to create
71
79
  if (dir.children[step] === undefined) {
72
- dir.children[step] = createDirectoryNode(step);
80
+ dir.children[step] = createDirectoryNode(step, extensionStates);
73
81
  }
74
82
  }
75
83
  else {
@@ -116,7 +124,7 @@ export class FileSystemCommandHandler {
116
124
  });
117
125
  }
118
126
  executeSetFile(state, command) {
119
- const { path, content, schema, override, contentIsPresent } = command;
127
+ const { path, content, schema, override, contentIsPresent, extensionStates } = command;
120
128
  const steps = pathSteps(path);
121
129
  return produce(state, draft => {
122
130
  const { root } = draft;
@@ -129,7 +137,7 @@ export class FileSystemCommandHandler {
129
137
  const last = steps[steps.length - 1];
130
138
  const child = parentDir.children[last];
131
139
  if (child === undefined || override === true) {
132
- parentDir.children[last] = createFileNode(last, content, schema, fileSystemNodeInitialState(contentIsPresent));
140
+ parentDir.children[last] = createFileNode(last, content, schema, fileSystemNodeInitialState(contentIsPresent), extensionStates);
133
141
  }
134
142
  else {
135
143
  console.warn(`File already exists at location`, path);
@@ -210,6 +218,27 @@ export class FileSystemCommandHandler {
210
218
  }
211
219
  });
212
220
  }
221
+ executeSetExtensionState(state, command) {
222
+ const { path, key, state: extensionState } = command;
223
+ return produce(state, draft => {
224
+ const { root } = draft;
225
+ const node = getFileSystemNode(root, path);
226
+ if (node !== undefined) {
227
+ if (node.state === undefined) {
228
+ node.state = fileSystemNodeInitialState();
229
+ }
230
+ if (node.state.extensionStates === undefined) {
231
+ node.state.extensionStates = {};
232
+ }
233
+ // Merge the new state with existing state for this key
234
+ const existing = node.state.extensionStates[key];
235
+ node.state.extensionStates[key] = Object.assign(Object.assign({}, existing), extensionState);
236
+ }
237
+ else {
238
+ console.warn(`No node found at location`, path);
239
+ }
240
+ });
241
+ }
213
242
  current(o) {
214
243
  if (o === null || o === undefined) {
215
244
  return o;
@@ -63,12 +63,14 @@ export class FileSystemNodeActions {
63
63
  this._removeType = `${this.sliceName}/removeNode`;
64
64
  this._updateFileContentType = `${this.sliceName}/updateFileContent`;
65
65
  this._setFileContentType = `${this.sliceName}/setFileContent`;
66
+ this._setExtensionStateType = `${this.sliceName}/setExtensionState`;
66
67
  this.actionTypeSet = new Set([
67
68
  this._mkdirType,
68
69
  this._setFileType,
69
70
  this._removeType,
70
71
  this._updateFileContentType,
71
- this._setFileContentType
72
+ this._setFileContentType,
73
+ this._setExtensionStateType
72
74
  ]);
73
75
  }
74
76
  get mkdirType() {
@@ -86,20 +88,23 @@ export class FileSystemNodeActions {
86
88
  get setFileContentType() {
87
89
  return this._setFileContentType;
88
90
  }
91
+ get setExtensionStateType() {
92
+ return this._setExtensionStateType;
93
+ }
89
94
  isFileSystemNodeAction(action) {
90
95
  return this.actionTypeSet.has(action.type);
91
96
  }
92
- mkdir(path, parents) {
97
+ mkdir(path, parents, extensionStates) {
93
98
  return {
94
99
  type: this.mkdirType,
95
- command: { name: 'mkdir', path, parents }
100
+ command: { name: 'mkdir', path, parents, extensionStates }
96
101
  };
97
102
  }
98
103
  setFile(path, content, schema, params = { override: true, contentIsPresent: true }) {
99
- const { override, contentIsPresent } = params;
104
+ const { override, contentIsPresent, extensionStates } = params;
100
105
  return {
101
106
  type: this.setFileType,
102
- command: { name: 'set-file', path, content, schema, override, contentIsPresent }
107
+ command: { name: 'set-file', path, content, schema, override, contentIsPresent, extensionStates }
103
108
  };
104
109
  }
105
110
  updateFileContent(path, contentCommand) {
@@ -120,4 +125,10 @@ export class FileSystemNodeActions {
120
125
  command: { name: 'remove', path, recursive }
121
126
  };
122
127
  }
128
+ setExtensionState(path, key, state) {
129
+ return {
130
+ type: this.setExtensionStateType,
131
+ command: { name: 'set-extension-state', path, key, state }
132
+ };
133
+ }
123
134
  }
@@ -6,3 +6,4 @@ export * from './core';
6
6
  export * from './middleware';
7
7
  export * from './plugin';
8
8
  export * from './fs';
9
+ export * from './autosave';
@@ -15,11 +15,16 @@ import { STORE_MANAGER_TOKEN, MIDDLEWARE_REGISTRY_TOKEN, REDUCER_REGISTRY_TOKEN,
15
15
  import { StoreManager } from '../core/store-manager';
16
16
  import { createEventBridgeMiddleware, createLoggerMiddleware, } from '../middleware';
17
17
  import { applyStoreExtensions, createStoreExtensionsCollector, } from '../extensions/store-extensions';
18
+ import { createFileSystemAdapter } from '../fs/core/fs-adapter';
19
+ // DI token for filesystem adapter
20
+ export const FILESYSTEM_ADAPTER_TOKEN = 'FILESYSTEM_ADAPTER';
18
21
  export function createStorePlugin(config = {}) {
19
22
  const storeManager = new StoreManager();
20
23
  const middlewareRegistry = storeManager.getMiddlewareRegistry();
21
24
  const reducerRegistry = storeManager.getReducerRegistry();
22
25
  const extensionsCollector = createStoreExtensionsCollector();
26
+ // Create filesystem adapter with 'fs' slice name
27
+ const fileSystemAdapter = createFileSystemAdapter('fs');
23
28
  const registerDefaultMiddleware = (hooks) => {
24
29
  extensionsCollector.register('ui-store:event-bridge', {
25
30
  middleware: [
@@ -58,6 +63,18 @@ export function createStorePlugin(config = {}) {
58
63
  middleware,
59
64
  });
60
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
+ }
61
78
  if (config.reducers && Object.keys(config.reducers).length) {
62
79
  extensionsCollector.register('ui-store-config:reducers', {
63
80
  reducers: config.reducers,
@@ -67,6 +84,10 @@ export function createStorePlugin(config = {}) {
67
84
  return {
68
85
  initialize(ctx) {
69
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());
70
91
  // Register services via DI
71
92
  ctx.provide({ provide: STORE_MANAGER_TOKEN, useValue: storeManager });
72
93
  ctx.provide({
@@ -81,9 +102,13 @@ export function createStorePlugin(config = {}) {
81
102
  provide: STORE_EXTENSIONS_TOKEN,
82
103
  useValue: extensionsCollector,
83
104
  });
105
+ ctx.provide({
106
+ provide: FILESYSTEM_ADAPTER_TOKEN,
107
+ useValue: fileSystemAdapter,
108
+ });
84
109
  registerDefaultMiddleware(ctx.hooks);
85
110
  registerConfigExtensions();
86
- console.log('[ui-store] Plugin initialized');
111
+ console.log('[ui-store] Plugin initialized with filesystem support');
87
112
  });
88
113
  },
89
114
  activate(ctx) {
@@ -5,7 +5,7 @@ import { DataUpdater } from '../utils/data-updater';
5
5
  * Base interface for filesystem commands
6
6
  */
7
7
  export interface FsCommandBase {
8
- name: 'mkdir' | 'set-file' | 'remove' | 'update-file-content' | 'set-file-content';
8
+ name: 'mkdir' | 'set-file' | 'remove' | 'update-file-content' | 'set-file-content' | 'set-extension-state';
9
9
  path: string | string[];
10
10
  }
11
11
  /**
@@ -14,6 +14,7 @@ export interface FsCommandBase {
14
14
  export interface MkdirCommand extends FsCommandBase {
15
15
  name: 'mkdir';
16
16
  parents?: boolean;
17
+ extensionStates?: Record<string, unknown>;
17
18
  }
18
19
  /**
19
20
  * Remove file or directory command
@@ -31,6 +32,7 @@ export interface SetFileCommand extends FsCommandBase {
31
32
  schema: FileContentSchema;
32
33
  override?: boolean;
33
34
  contentIsPresent?: boolean;
35
+ extensionStates?: Record<string, unknown>;
34
36
  }
35
37
  /**
36
38
  * Update file content with structure command
@@ -47,10 +49,18 @@ export interface SetFileContentCommand extends FsCommandBase {
47
49
  content: any;
48
50
  fromRemote?: boolean;
49
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
+ }
50
60
  /**
51
61
  * Union type for all filesystem commands
52
62
  */
53
- export type FileSystemCommand = MkdirCommand | RemoveCommand | SetFileCommand | UpdateFileContentCommand | SetFileContentCommand;
63
+ export type FileSystemCommand = MkdirCommand | RemoveCommand | SetFileCommand | UpdateFileContentCommand | SetFileContentCommand | SetExtensionStateCommand;
54
64
  export { pathSteps, parentPathSteps } from '@hamak/shared-utils';
55
65
  /**
56
66
  * Get filesystem node at path
@@ -68,6 +78,7 @@ export declare class FileSystemCommandHandler {
68
78
  private executeContentCommand;
69
79
  private contentMayChange;
70
80
  private executeSetContentCommand;
81
+ private executeSetExtensionState;
71
82
  protected current<T = any>(o: T): T;
72
83
  protected original<T = any>(o: T): T | undefined;
73
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fs-commands.d.ts","sourceRoot":"","sources":["../../../src/fs/commands/fs-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,qBAAqB,GAAG,kBAAkB,CAAA;IACnF,IAAI,EAAG,MAAM,GAAG,MA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GAAG,MAAM,EAAE,GAAI,cAAc,GAAG,SAAS,CAe/G;AA4BD;;GAEG;AACH,qBAAa,wBAAwB;IACnC,QAAQ,CAAC,qBAAqB,4BAAkC;IAEhE,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,GAAG,eAAe;IAW5E,OAAO,CAAC,YAAY;IAoCpB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,qBAAqB;IA0B7B,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,wBAAwB;IAmChC,OAAO,CAAC,wBAAwB;IA0BhC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAG,CAAC,GAAE,CAAC;IAQnC,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAG,CAAC,GAAE,CAAC,GAAG,SAAS;CAOjD;AAED;;GAEG;AACH,qBAAa,yBAAyB;IACpC,QAAQ,CAAC,OAAO,cAAoB;IAEpC,OAAO,CAAC,IAAI,EAAG,QAAQ,EAAE,OAAO,EAAE,oBAAoB;IAoBtD,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACI,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;CAKxD"}
@@ -28,10 +28,14 @@ export function getFileSystemNode(fsNode, path) {
28
28
  /**
29
29
  * Create a directory node
30
30
  */
31
- function createDirectoryNode(step) {
31
+ function createDirectoryNode(step, extensionStates) {
32
+ const state = fileSystemNodeInitialState();
33
+ if (extensionStates) {
34
+ state.extensionStates = { ...state.extensionStates, ...extensionStates };
35
+ }
32
36
  return {
33
37
  type: 'directory',
34
- state: fileSystemNodeInitialState(),
38
+ state,
35
39
  name: step,
36
40
  children: {}
37
41
  };
@@ -39,7 +43,10 @@ function createDirectoryNode(step) {
39
43
  /**
40
44
  * Create a file node
41
45
  */
42
- function createFileNode(name, content, schema, state) {
46
+ function createFileNode(name, content, schema, state, extensionStates) {
47
+ if (extensionStates) {
48
+ state.extensionStates = { ...state.extensionStates, ...extensionStates };
49
+ }
43
50
  return { type: 'file', name, content, schema, state };
44
51
  }
45
52
  /**
@@ -56,10 +63,11 @@ export class FileSystemCommandHandler {
56
63
  case 'update-file-content': return this.executeContentCommand(state, command);
57
64
  case 'set-file-content': return this.executeSetContentCommand(state, command);
58
65
  case 'remove': return this.executeRemove(state, command);
66
+ case 'set-extension-state': return this.executeSetExtensionState(state, command);
59
67
  }
60
68
  }
61
69
  executeMkdir(state, command) {
62
- const { path, parents } = command;
70
+ const { path, parents, extensionStates } = command;
63
71
  const steps = pathSteps(path);
64
72
  return produce(state, draft => {
65
73
  const { root } = draft;
@@ -69,7 +77,7 @@ export class FileSystemCommandHandler {
69
77
  if (i + 1 === steps.length) {
70
78
  // Last step is the element to create
71
79
  if (dir.children[step] === undefined) {
72
- dir.children[step] = createDirectoryNode(step);
80
+ dir.children[step] = createDirectoryNode(step, extensionStates);
73
81
  }
74
82
  }
75
83
  else {
@@ -116,7 +124,7 @@ export class FileSystemCommandHandler {
116
124
  });
117
125
  }
118
126
  executeSetFile(state, command) {
119
- const { path, content, schema, override, contentIsPresent } = command;
127
+ const { path, content, schema, override, contentIsPresent, extensionStates } = command;
120
128
  const steps = pathSteps(path);
121
129
  return produce(state, draft => {
122
130
  const { root } = draft;
@@ -129,7 +137,7 @@ export class FileSystemCommandHandler {
129
137
  const last = steps[steps.length - 1];
130
138
  const child = parentDir.children[last];
131
139
  if (child === undefined || override === true) {
132
- parentDir.children[last] = createFileNode(last, content, schema, fileSystemNodeInitialState(contentIsPresent));
140
+ parentDir.children[last] = createFileNode(last, content, schema, fileSystemNodeInitialState(contentIsPresent), extensionStates);
133
141
  }
134
142
  else {
135
143
  console.warn(`File already exists at location`, path);
@@ -210,6 +218,30 @@ export class FileSystemCommandHandler {
210
218
  }
211
219
  });
212
220
  }
221
+ executeSetExtensionState(state, command) {
222
+ const { path, key, state: extensionState } = command;
223
+ return produce(state, draft => {
224
+ const { root } = draft;
225
+ const node = getFileSystemNode(root, path);
226
+ if (node !== undefined) {
227
+ if (node.state === undefined) {
228
+ node.state = fileSystemNodeInitialState();
229
+ }
230
+ if (node.state.extensionStates === undefined) {
231
+ node.state.extensionStates = {};
232
+ }
233
+ // Merge the new state with existing state for this key
234
+ const existing = node.state.extensionStates[key];
235
+ node.state.extensionStates[key] = {
236
+ ...existing,
237
+ ...extensionState
238
+ };
239
+ }
240
+ else {
241
+ console.warn(`No node found at location`, path);
242
+ }
243
+ });
244
+ }
213
245
  current(o) {
214
246
  if (o === null || o === undefined) {
215
247
  return o;
@@ -40,6 +40,7 @@ export declare class FileSystemNodeActions {
40
40
  private readonly _removeType;
41
41
  private readonly _updateFileContentType;
42
42
  private readonly _setFileContentType;
43
+ private readonly _setExtensionStateType;
43
44
  private actionTypeSet;
44
45
  constructor(sliceName: string);
45
46
  get mkdirType(): string;
@@ -47,11 +48,13 @@ export declare class FileSystemNodeActions {
47
48
  get removeType(): string;
48
49
  get updateFileContentType(): string;
49
50
  get setFileContentType(): string;
51
+ get setExtensionStateType(): string;
50
52
  isFileSystemNodeAction(action: Action): action is FileSystemNodeAction;
51
- mkdir(path: string | string[], parents?: boolean): FileSystemNodeAction;
53
+ mkdir(path: string | string[], parents?: boolean, extensionStates?: Record<string, unknown>): FileSystemNodeAction;
52
54
  setFile(path: string | string[], content: any, schema: FileContentSchema, params?: FileSystemNodeActionParams): FileSystemNodeAction;
53
55
  updateFileContent(path: string | string[], contentCommand: StructureNodeCommand): FileSystemNodeAction;
54
56
  setFileContent(path: string | string[], content: any, fromRemote?: boolean): FileSystemNodeAction;
55
57
  removeNode(path: string | string[], recursive?: boolean): FileSystemNodeAction;
58
+ setExtensionState(path: string | string[], key: string, state: Record<string, unknown>): FileSystemNodeAction;
56
59
  }
57
60
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G,oBAAoB;CAOrH"}
@@ -63,12 +63,14 @@ export class FileSystemNodeActions {
63
63
  this._removeType = `${this.sliceName}/removeNode`;
64
64
  this._updateFileContentType = `${this.sliceName}/updateFileContent`;
65
65
  this._setFileContentType = `${this.sliceName}/setFileContent`;
66
+ this._setExtensionStateType = `${this.sliceName}/setExtensionState`;
66
67
  this.actionTypeSet = new Set([
67
68
  this._mkdirType,
68
69
  this._setFileType,
69
70
  this._removeType,
70
71
  this._updateFileContentType,
71
- this._setFileContentType
72
+ this._setFileContentType,
73
+ this._setExtensionStateType
72
74
  ]);
73
75
  }
74
76
  get mkdirType() {
@@ -86,20 +88,23 @@ export class FileSystemNodeActions {
86
88
  get setFileContentType() {
87
89
  return this._setFileContentType;
88
90
  }
91
+ get setExtensionStateType() {
92
+ return this._setExtensionStateType;
93
+ }
89
94
  isFileSystemNodeAction(action) {
90
95
  return this.actionTypeSet.has(action.type);
91
96
  }
92
- mkdir(path, parents) {
97
+ mkdir(path, parents, extensionStates) {
93
98
  return {
94
99
  type: this.mkdirType,
95
- command: { name: 'mkdir', path, parents }
100
+ command: { name: 'mkdir', path, parents, extensionStates }
96
101
  };
97
102
  }
98
103
  setFile(path, content, schema, params = { override: true, contentIsPresent: true }) {
99
- const { override, contentIsPresent } = params;
104
+ const { override, contentIsPresent, extensionStates } = params;
100
105
  return {
101
106
  type: this.setFileType,
102
- command: { name: 'set-file', path, content, schema, override, contentIsPresent }
107
+ command: { name: 'set-file', path, content, schema, override, contentIsPresent, extensionStates }
103
108
  };
104
109
  }
105
110
  updateFileContent(path, contentCommand) {
@@ -120,4 +125,10 @@ export class FileSystemNodeActions {
120
125
  command: { name: 'remove', path, recursive }
121
126
  };
122
127
  }
128
+ setExtensionState(path, key, state) {
129
+ return {
130
+ type: this.setExtensionStateType,
131
+ command: { name: 'set-extension-state', path, key, state }
132
+ };
133
+ }
123
134
  }
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * from './core';
6
6
  export * from './middleware';
7
7
  export * from './plugin';
8
8
  export * from './fs';
9
+ export * from './autosave';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -6,3 +6,4 @@ export * from './core';
6
6
  export * from './middleware';
7
7
  export * from './plugin';
8
8
  export * from './fs';
9
+ export * from './autosave';
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { PluginModule } from '@hamak/microkernel-spi';
6
6
  import { type StorePluginExtensions } from '@hamak/ui-store-api';
7
+ export declare const FILESYSTEM_ADAPTER_TOKEN = "FILESYSTEM_ADAPTER";
7
8
  export interface StorePluginConfig extends StorePluginExtensions {
8
9
  /** Enable Redux DevTools integration */
9
10
  devTools?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"store-plugin-factory.d.ts","sourceRoot":"","sources":["../../src/plugin/store-plugin-factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAML,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAW7B,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,iBAAsB,GAC7B,YAAY,CA2Gd"}
1
+ {"version":3,"file":"store-plugin-factory.d.ts","sourceRoot":"","sources":["../../src/plugin/store-plugin-factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAML,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAa7B,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,iBAAsB,GAC7B,YAAY,CAqId"}
@@ -6,11 +6,16 @@ import { STORE_MANAGER_TOKEN, MIDDLEWARE_REGISTRY_TOKEN, REDUCER_REGISTRY_TOKEN,
6
6
  import { StoreManager } from '../core/store-manager';
7
7
  import { createEventBridgeMiddleware, createLoggerMiddleware, } from '../middleware';
8
8
  import { applyStoreExtensions, createStoreExtensionsCollector, } from '../extensions/store-extensions';
9
+ import { createFileSystemAdapter } from '../fs/core/fs-adapter';
10
+ // DI token for filesystem adapter
11
+ export const FILESYSTEM_ADAPTER_TOKEN = 'FILESYSTEM_ADAPTER';
9
12
  export function createStorePlugin(config = {}) {
10
13
  const storeManager = new StoreManager();
11
14
  const middlewareRegistry = storeManager.getMiddlewareRegistry();
12
15
  const reducerRegistry = storeManager.getReducerRegistry();
13
16
  const extensionsCollector = createStoreExtensionsCollector();
17
+ // Create filesystem adapter with 'fs' slice name
18
+ const fileSystemAdapter = createFileSystemAdapter('fs');
14
19
  const registerDefaultMiddleware = (hooks) => {
15
20
  extensionsCollector.register('ui-store:event-bridge', {
16
21
  middleware: [
@@ -48,6 +53,18 @@ export function createStorePlugin(config = {}) {
48
53
  middleware,
49
54
  });
50
55
  }
56
+ // Call middlewareFactory if provided, passing the fileSystemAdapter
57
+ if (config.middlewareFactory) {
58
+ const factoryMiddleware = config.middlewareFactory(fileSystemAdapter);
59
+ if (factoryMiddleware?.length) {
60
+ extensionsCollector.register('ui-store-config:middleware-factory', {
61
+ middleware: factoryMiddleware.map((mw) => ({
62
+ ...mw,
63
+ plugin: mw.plugin ?? 'ui-store-config',
64
+ })),
65
+ });
66
+ }
67
+ }
51
68
  if (config.reducers && Object.keys(config.reducers).length) {
52
69
  extensionsCollector.register('ui-store-config:reducers', {
53
70
  reducers: config.reducers,
@@ -56,6 +73,10 @@ export function createStorePlugin(config = {}) {
56
73
  };
57
74
  return {
58
75
  async initialize(ctx) {
76
+ // Set filesystem adapter on store manager
77
+ storeManager.setFileSystemAdapter(fileSystemAdapter);
78
+ // Register filesystem reducer
79
+ reducerRegistry.register('fs', fileSystemAdapter.getReducer());
59
80
  // Register services via DI
60
81
  ctx.provide({ provide: STORE_MANAGER_TOKEN, useValue: storeManager });
61
82
  ctx.provide({
@@ -70,9 +91,13 @@ export function createStorePlugin(config = {}) {
70
91
  provide: STORE_EXTENSIONS_TOKEN,
71
92
  useValue: extensionsCollector,
72
93
  });
94
+ ctx.provide({
95
+ provide: FILESYSTEM_ADAPTER_TOKEN,
96
+ useValue: fileSystemAdapter,
97
+ });
73
98
  registerDefaultMiddleware(ctx.hooks);
74
99
  registerConfigExtensions();
75
- console.log('[ui-store] Plugin initialized');
100
+ console.log('[ui-store] Plugin initialized with filesystem support');
76
101
  },
77
102
  async activate(ctx) {
78
103
  applyStoreExtensions(extensionsCollector, middlewareRegistry, reducerRegistry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamak/ui-store-impl",
3
- "version": "0.4.16",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "UI Store Implementation - Redux store implementation with middleware",