@hamak/ui-store-impl 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/autosave/autosave-config-resolver.d.ts +0 -45
- package/dist/autosave/autosave-config-resolver.d.ts.map +0 -1
- package/dist/autosave/autosave-config-resolver.js +0 -107
- package/dist/autosave/autosave-middleware.d.ts +0 -37
- package/dist/autosave/autosave-middleware.d.ts.map +0 -1
- package/dist/autosave/autosave-middleware.js +0 -297
- package/dist/autosave/autosave-registry.d.ts +0 -15
- package/dist/autosave/autosave-registry.d.ts.map +0 -1
- package/dist/autosave/autosave-registry.js +0 -33
- package/dist/autosave/autosave-sync-middleware.d.ts +0 -24
- package/dist/autosave/autosave-sync-middleware.d.ts.map +0 -1
- package/dist/autosave/autosave-sync-middleware.js +0 -98
- package/dist/autosave/index.d.ts +0 -8
- package/dist/autosave/index.d.ts.map +0 -1
- package/dist/autosave/index.js +0 -7
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -3
- package/dist/core/middleware-registry.d.ts +0 -21
- package/dist/core/middleware-registry.d.ts.map +0 -1
- package/dist/core/middleware-registry.js +0 -50
- package/dist/core/reducer-registry.d.ts +0 -18
- package/dist/core/reducer-registry.d.ts.map +0 -1
- package/dist/core/reducer-registry.js +0 -54
- package/dist/core/store-manager.d.ts +0 -29
- package/dist/core/store-manager.d.ts.map +0 -1
- package/dist/core/store-manager.js +0 -104
- package/dist/es2015/autosave/autosave-config-resolver.js +0 -110
- package/dist/es2015/autosave/autosave-middleware.js +0 -311
- package/dist/es2015/autosave/autosave-registry.js +0 -33
- package/dist/es2015/autosave/autosave-sync-middleware.js +0 -98
- package/dist/es2015/autosave/index.js +0 -7
- package/dist/es2015/core/index.js +0 -3
- package/dist/es2015/core/middleware-registry.js +0 -47
- package/dist/es2015/core/reducer-registry.js +0 -54
- package/dist/es2015/core/store-manager.js +0 -104
- package/dist/es2015/extensions/store-extensions.js +0 -61
- package/dist/es2015/fs/commands/fs-commands.js +0 -327
- package/dist/es2015/fs/commands/structure-commands.js +0 -21
- package/dist/es2015/fs/core/fs-adapter.js +0 -134
- package/dist/es2015/fs/core/fs-facade.js +0 -78
- package/dist/es2015/fs/index.js +0 -11
- package/dist/es2015/fs/utils/data-updater.js +0 -251
- package/dist/es2015/fs/utils/deep-equal.js +0 -28
- package/dist/es2015/middleware/event-bridge-middleware.js +0 -19
- package/dist/es2015/middleware/index.js +0 -5
- package/dist/es2015/middleware/logger-middleware.js +0 -18
- package/dist/es2015/plugin/index.js +0 -4
- package/dist/es2015/plugin/store-plugin-factory.js +0 -137
- package/dist/extensions/store-extensions.d.ts +0 -23
- package/dist/extensions/store-extensions.d.ts.map +0 -1
- package/dist/extensions/store-extensions.js +0 -61
- package/dist/fs/commands/fs-commands.d.ts +0 -100
- package/dist/fs/commands/fs-commands.d.ts.map +0 -1
- package/dist/fs/commands/fs-commands.js +0 -330
- package/dist/fs/commands/structure-commands.d.ts +0 -76
- package/dist/fs/commands/structure-commands.d.ts.map +0 -1
- package/dist/fs/commands/structure-commands.js +0 -21
- package/dist/fs/core/fs-adapter.d.ts +0 -60
- package/dist/fs/core/fs-adapter.d.ts.map +0 -1
- package/dist/fs/core/fs-adapter.js +0 -134
- package/dist/fs/core/fs-facade.d.ts +0 -37
- package/dist/fs/core/fs-facade.d.ts.map +0 -1
- package/dist/fs/core/fs-facade.js +0 -78
- package/dist/fs/index.d.ts +0 -8
- package/dist/fs/index.d.ts.map +0 -1
- package/dist/fs/index.js +0 -11
- package/dist/fs/utils/data-updater.d.ts +0 -43
- package/dist/fs/utils/data-updater.d.ts.map +0 -1
- package/dist/fs/utils/data-updater.js +0 -255
- package/dist/fs/utils/deep-equal.d.ts +0 -5
- package/dist/fs/utils/deep-equal.d.ts.map +0 -1
- package/dist/fs/utils/deep-equal.js +0 -28
- package/dist/middleware/event-bridge-middleware.d.ts +0 -7
- package/dist/middleware/event-bridge-middleware.d.ts.map +0 -1
- package/dist/middleware/event-bridge-middleware.js +0 -19
- package/dist/middleware/index.d.ts +0 -6
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -5
- package/dist/middleware/logger-middleware.d.ts +0 -7
- package/dist/middleware/logger-middleware.d.ts.map +0 -1
- package/dist/middleware/logger-middleware.js +0 -18
- package/dist/plugin/index.d.ts +0 -5
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -4
- package/dist/plugin/store-plugin-factory.d.ts +0 -15
- package/dist/plugin/store-plugin-factory.d.ts.map +0 -1
- package/dist/plugin/store-plugin-factory.js +0 -121
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { createSelector } from '@reduxjs/toolkit';
|
|
2
|
-
import { Pathway, RelativePathwayResolver } from '@hamak/shared-utils';
|
|
3
|
-
/**
|
|
4
|
-
* StoreFileSystemFacade - High-level API for filesystem operations
|
|
5
|
-
*/
|
|
6
|
-
export class StoreFileSystemFacade {
|
|
7
|
-
constructor(fileSystemSelector, adapter) {
|
|
8
|
-
this.fileSystemSelector = fileSystemSelector;
|
|
9
|
-
this.adapter = adapter;
|
|
10
|
-
}
|
|
11
|
-
getActions() {
|
|
12
|
-
return this.adapter.getActions();
|
|
13
|
-
}
|
|
14
|
-
createSelector(path) {
|
|
15
|
-
return this.adapter.createSelector(this.fileSystemSelector, path);
|
|
16
|
-
}
|
|
17
|
-
createFileSelector(path) {
|
|
18
|
-
const nodeSelector = this.adapter.createSelector(this.fileSystemSelector, path);
|
|
19
|
-
return createSelector([nodeSelector], (f) => {
|
|
20
|
-
if (f?.type === 'file') {
|
|
21
|
-
return f;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
selectFromRoot(state, path = []) {
|
|
29
|
-
const fileSystemState = this.fileSystemSelector(state);
|
|
30
|
-
if (fileSystemState === undefined || fileSystemState === null) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const root = fileSystemState.root;
|
|
35
|
-
return (path ?? []).reduce((acc, step) => {
|
|
36
|
-
if (acc === undefined || acc === null) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
switch (acc.type) {
|
|
41
|
-
case "directory": return acc.children[step];
|
|
42
|
-
case "file": return undefined;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, root);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
selectFileFromRoot(state, path = []) {
|
|
49
|
-
const fsNode = this.selectFromRoot(state, path);
|
|
50
|
-
if (fsNode === undefined) {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
if (fsNode.type === "file") {
|
|
55
|
-
return fsNode;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw new Error(`Expecting file at path '${Pathway.of(path).toString()}' but got '${fsNode.type}'`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* StoreFileSystemPathwayResolver - Pathway resolver for filesystem state
|
|
65
|
-
*/
|
|
66
|
-
export class StoreFileSystemPathwayResolver {
|
|
67
|
-
constructor(state, fs) {
|
|
68
|
-
this.state = state;
|
|
69
|
-
this.fs = fs;
|
|
70
|
-
}
|
|
71
|
-
resolve(path) {
|
|
72
|
-
const segments = Pathway.of(path).getSegments();
|
|
73
|
-
return this.fs.selectFromRoot(this.state, segments);
|
|
74
|
-
}
|
|
75
|
-
relativeTo(path) {
|
|
76
|
-
return new RelativePathwayResolver(this, path);
|
|
77
|
-
}
|
|
78
|
-
}
|
package/dist/fs/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './core/fs-adapter.js';
|
|
2
|
-
export * from './core/fs-facade.js';
|
|
3
|
-
export * from './commands/fs-commands.js';
|
|
4
|
-
export * from './commands/structure-commands.js';
|
|
5
|
-
export { pathSteps, parentPathSteps } from '@hamak/shared-utils';
|
|
6
|
-
export * from './utils/data-updater.js';
|
|
7
|
-
export * from './utils/deep-equal.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/fs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fs/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGjE,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
|
package/dist/fs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Core filesystem functionality
|
|
2
|
-
export * from './core/fs-adapter.js';
|
|
3
|
-
export * from './core/fs-facade.js';
|
|
4
|
-
// Commands
|
|
5
|
-
export * from './commands/fs-commands.js';
|
|
6
|
-
export * from './commands/structure-commands.js';
|
|
7
|
-
// Re-export path utilities from shared-utils for backward compatibility
|
|
8
|
-
export { pathSteps, parentPathSteps } from '@hamak/shared-utils';
|
|
9
|
-
// Utilities
|
|
10
|
-
export * from './utils/data-updater.js';
|
|
11
|
-
export * from './utils/deep-equal.js';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Itinerary, StackElement } from '@hamak/shared-utils';
|
|
2
|
-
import { UnitaryStructureNodeCommand, BatchUpdateStructureNodeCommand } from '../commands/structure-commands.js';
|
|
3
|
-
export type DeleteFailureReason = 'itinerary-not-provided' | 'parent-not-found' | 'parent-not-container' | 'array-step-not-supported' | 'object-step-not-supported' | 'target-not-found';
|
|
4
|
-
export type DeleteResult = {
|
|
5
|
-
deleted: true;
|
|
6
|
-
} | {
|
|
7
|
-
deleted: false;
|
|
8
|
-
reason: DeleteFailureReason;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* DataUpdater class handles operations on data structures using itineraries
|
|
12
|
-
*/
|
|
13
|
-
export declare class DataUpdater {
|
|
14
|
-
/**
|
|
15
|
-
* Delete a value at the specified itinerary
|
|
16
|
-
*/
|
|
17
|
-
executeDelete(data: any, itinerary: Itinerary | undefined): DeleteResult;
|
|
18
|
-
/**
|
|
19
|
-
* Set a value at the specified itinerary
|
|
20
|
-
*/
|
|
21
|
-
executeSet(data: any, itinerary: Itinerary | undefined, value: any, prototypeToParent?: StackElement<any>): void;
|
|
22
|
-
/**
|
|
23
|
-
* Add a value at the specified itinerary
|
|
24
|
-
*/
|
|
25
|
-
executeAdd(data: any, itinerary: Itinerary | undefined, value: any, prototypeToParent?: StackElement<any>): void;
|
|
26
|
-
/**
|
|
27
|
-
* Insert a value at the specified position
|
|
28
|
-
*/
|
|
29
|
-
executeInsert(data: any, itinerary: Itinerary, value: any, prototypeToParent?: StackElement<any>): void;
|
|
30
|
-
/**
|
|
31
|
-
* Rebase a pending command's itinerary on top of an altering command.
|
|
32
|
-
* Returns null if the pending command should be dropped (e.g., targets a deleted element).
|
|
33
|
-
* Enhanced: Handles rebasing for nested itineraries, not just at the first divergence.
|
|
34
|
-
*/
|
|
35
|
-
rebasePendingCommandOn(alteringCmd: UnitaryStructureNodeCommand, pendingCmd: UnitaryStructureNodeCommand): UnitaryStructureNodeCommand | null;
|
|
36
|
-
/**
|
|
37
|
-
* Executes a batch of commands, rebasing each on previous mutations.
|
|
38
|
-
* @param data The data object to mutate
|
|
39
|
-
* @param command The batch update command
|
|
40
|
-
*/
|
|
41
|
-
executeBatch(data: any, command: BatchUpdateStructureNodeCommand): void;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=data-updater.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-updater.d.ts","sourceRoot":"","sources":["../../../src/fs/utils/data-updater.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAC3B,wBAAwB,GACxB,kBAAkB,GAClB,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,GAC3B,kBAAkB,CAAA;AAEtB,MAAM,MAAM,YAAY,GACpB;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAA;AAyBnD;;GAEG;AACH,qBAAa,WAAW;IAEtB;;OAEG;IACI,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY;IAkD/E;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC;IA+BhH;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC;IAahH;;OAEG;IACI,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC;IAkBvG;;;;OAIG;IACI,sBAAsB,CAC3B,WAAW,EAAE,2BAA2B,EACxC,UAAU,EAAE,2BAA2B,GACtC,2BAA2B,GAAG,IAAI;IAqFrC;;;;OAIG;IACI,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,+BAA+B,GAAG,IAAI;CA4B/E"}
|
|
@@ -1,255 +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
|
-
? { ...pendingStep, position: pendingIdx }
|
|
188
|
-
: pendingStep;
|
|
189
|
-
}
|
|
190
|
-
const alteringArr = itineraryToArray(alteringCmd.itinerary);
|
|
191
|
-
const pendingArr = itineraryToArray(pendingCmd.itinerary);
|
|
192
|
-
// Find first index where steps differ
|
|
193
|
-
let commonLength = 0;
|
|
194
|
-
while (commonLength < alteringArr.length &&
|
|
195
|
-
commonLength < pendingArr.length &&
|
|
196
|
-
areSameItineraryStep(alteringArr[commonLength], pendingArr[commonLength])) {
|
|
197
|
-
commonLength++;
|
|
198
|
-
}
|
|
199
|
-
// Rebase all position steps after the divergence point
|
|
200
|
-
const rebasedArr = pendingArr.slice();
|
|
201
|
-
for (let i = 0; i < alteringArr.length; i++) {
|
|
202
|
-
if (alteringArr[i].type === 'position' &&
|
|
203
|
-
pendingArr.length > i &&
|
|
204
|
-
pendingArr[i].type === 'position') {
|
|
205
|
-
// Only rebase if the pending itinerary matches the altering up to this step
|
|
206
|
-
const isDescendant = alteringArr
|
|
207
|
-
.slice(0, i)
|
|
208
|
-
.every((step, j) => areSameItineraryStep(step, pendingArr[j]));
|
|
209
|
-
if (isDescendant) {
|
|
210
|
-
rebasedArr[i] = rebasePositionStep(alteringArr[i], alteringCmd, pendingArr[i]);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
// If no itinerary, return as is
|
|
215
|
-
if (rebasedArr.length === 0)
|
|
216
|
-
return pendingCmd;
|
|
217
|
-
return {
|
|
218
|
-
...pendingCmd,
|
|
219
|
-
itinerary: arrayToItinerary(rebasedArr),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Executes a batch of commands, rebasing each on previous mutations.
|
|
224
|
-
* @param data The data object to mutate
|
|
225
|
-
* @param command The batch update command
|
|
226
|
-
*/
|
|
227
|
-
executeBatch(data, command) {
|
|
228
|
-
const { commands } = command;
|
|
229
|
-
const applied = [];
|
|
230
|
-
for (let i = 0; i < commands.length; i++) {
|
|
231
|
-
let rebased = commands[i];
|
|
232
|
-
for (let j = 0; j < applied.length && rebased != null; j++) {
|
|
233
|
-
rebased = this.rebasePendingCommandOn(applied[j], rebased);
|
|
234
|
-
}
|
|
235
|
-
if (rebased != null) {
|
|
236
|
-
switch (rebased.name) {
|
|
237
|
-
case 'add-at':
|
|
238
|
-
this.executeAdd(data, rebased.itinerary, rebased.value, rebased.prototypes);
|
|
239
|
-
break;
|
|
240
|
-
case 'insert-at':
|
|
241
|
-
this.executeInsert(data, rebased.itinerary, rebased.value, rebased.prototypes);
|
|
242
|
-
break;
|
|
243
|
-
case 'set-at':
|
|
244
|
-
this.executeSet(data, rebased.itinerary, rebased.value, rebased.prototypes);
|
|
245
|
-
break;
|
|
246
|
-
case 'delete-at':
|
|
247
|
-
this.executeDelete(data, rebased.itinerary);
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
applied.push(rebased);
|
|
251
|
-
}
|
|
252
|
-
// If rebased is null, skip this command (it targets a deleted element)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deep-equal.d.ts","sourceRoot":"","sources":["../../../src/fs/utils/deep-equal.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CA+BvD"}
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-bridge-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/event-bridge-middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,GAAG,GAAG,UAAU,CAkBlE"}
|
|
@@ -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?.emit('redux:action:before', { action, state: store.getState() });
|
|
9
|
-
// Execute action
|
|
10
|
-
const result = next(action);
|
|
11
|
-
// Emit after action
|
|
12
|
-
hooks?.emit('redux:action:after', { action, state: store.getState() });
|
|
13
|
-
// Emit specific action type event
|
|
14
|
-
if (action?.type) {
|
|
15
|
-
hooks?.emit(`redux:action:${action.type}`, action);
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
|
package/dist/middleware/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger-middleware.d.ts","sourceRoot":"","sources":["../../src/middleware/logger-middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC,wBAAgB,sBAAsB,IAAI,UAAU,CAiBnD"}
|
|
@@ -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?.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
|
-
}
|
package/dist/plugin/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,wBAAwB,CAAC"}
|
package/dist/plugin/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store Plugin Factory
|
|
3
|
-
* Creates a microkernel plugin for Redux store management
|
|
4
|
-
*/
|
|
5
|
-
import type { PluginModule } from '@hamak/microkernel-spi';
|
|
6
|
-
import { type StorePluginExtensions } from '@hamak/ui-store-api';
|
|
7
|
-
export declare const FILESYSTEM_ADAPTER_TOKEN = "FILESYSTEM_ADAPTER";
|
|
8
|
-
export interface StorePluginConfig extends StorePluginExtensions {
|
|
9
|
-
/** Enable Redux DevTools integration */
|
|
10
|
-
devTools?: boolean;
|
|
11
|
-
/** Enable logger middleware in development */
|
|
12
|
-
logger?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function createStorePlugin(config?: StorePluginConfig): PluginModule;
|
|
15
|
-
//# sourceMappingURL=store-plugin-factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|