@hamak/ui-store-spi 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.
- package/dist/autosave/i-autosave-provider.d.ts +98 -0
- package/dist/autosave/i-autosave-provider.d.ts.map +1 -0
- package/dist/autosave/i-autosave-provider.js +8 -0
- package/dist/autosave/i-autosave-registry.d.ts +59 -0
- package/dist/autosave/i-autosave-registry.d.ts.map +1 -0
- package/dist/autosave/i-autosave-registry.js +8 -0
- package/dist/autosave/index.d.ts +8 -0
- package/dist/autosave/index.d.ts.map +1 -0
- package/dist/autosave/index.js +7 -0
- package/dist/es2015/autosave/i-autosave-provider.js +8 -0
- package/dist/es2015/autosave/i-autosave-registry.js +8 -0
- package/dist/es2015/autosave/index.js +7 -0
- package/dist/es2015/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Interface
|
|
3
|
+
*
|
|
4
|
+
* Each filesystem plugin (remote-fs, remote-resource, git) implements this interface
|
|
5
|
+
* to handle actual save operations. The core autosave middleware handles debouncing
|
|
6
|
+
* and orchestration, then delegates to the appropriate provider for execution.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileSystemNode } from '@hamak/shared-utils';
|
|
9
|
+
import type { Dispatch, AnyAction } from 'redux';
|
|
10
|
+
/**
|
|
11
|
+
* Result of a save operation
|
|
12
|
+
*/
|
|
13
|
+
export interface AutosaveResult {
|
|
14
|
+
/** Whether the save succeeded */
|
|
15
|
+
success: boolean;
|
|
16
|
+
/** Error information if failed */
|
|
17
|
+
error?: {
|
|
18
|
+
code: string;
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
/** Timestamp of the save */
|
|
22
|
+
timestamp?: number;
|
|
23
|
+
/** Additional metadata from the save operation */
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Autosave provider interface
|
|
28
|
+
*
|
|
29
|
+
* Implement this interface to add autosave support for a filesystem plugin.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* class RemoteFsAutosaveProvider implements IAutosaveProvider {
|
|
34
|
+
* readonly id = 'remote-fs';
|
|
35
|
+
* readonly priority = 10;
|
|
36
|
+
*
|
|
37
|
+
* supports(path: string[], node: FileSystemNode): boolean {
|
|
38
|
+
* return node.state?.extensionStates?.['remoteFs'] !== undefined;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* async save(path, content, node, dispatch): Promise<AutosaveResult> {
|
|
42
|
+
* dispatch(rfsActions.ofPutRequest(path, content));
|
|
43
|
+
* return { success: true, timestamp: Date.now() };
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export interface IAutosaveProvider {
|
|
49
|
+
/**
|
|
50
|
+
* Unique provider identifier
|
|
51
|
+
* Examples: 'remote-fs', 'remote-resource', 'git'
|
|
52
|
+
*/
|
|
53
|
+
readonly id: string;
|
|
54
|
+
/**
|
|
55
|
+
* Priority for provider selection when multiple providers support a path.
|
|
56
|
+
* Higher priority = preferred. Default: 0
|
|
57
|
+
*/
|
|
58
|
+
readonly priority?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Check if this provider can handle autosave for a given path.
|
|
61
|
+
*
|
|
62
|
+
* Provider should check if the node has the required extension state.
|
|
63
|
+
* For example, remote-fs checks for 'remoteFs' extension state,
|
|
64
|
+
* remote-resource checks for 'ui-remote-resource' extension state.
|
|
65
|
+
*
|
|
66
|
+
* @param path - File path segments
|
|
67
|
+
* @param node - The filesystem node
|
|
68
|
+
* @returns true if this provider can handle the path
|
|
69
|
+
*/
|
|
70
|
+
supports(path: string[], node: FileSystemNode): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Execute the save operation.
|
|
73
|
+
*
|
|
74
|
+
* Provider should dispatch its own save actions (e.g., PUT_REQUEST, UPDATE_ENTITY)
|
|
75
|
+
* and return the result. The autosave middleware will track the save status.
|
|
76
|
+
*
|
|
77
|
+
* @param path - File path segments
|
|
78
|
+
* @param content - File content to save
|
|
79
|
+
* @param node - The filesystem node
|
|
80
|
+
* @param dispatch - Redux dispatch function
|
|
81
|
+
* @returns Promise resolving to the save result
|
|
82
|
+
*/
|
|
83
|
+
save(path: string[], content: unknown, node: FileSystemNode, dispatch: Dispatch<AnyAction>): Promise<AutosaveResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Cancel any in-progress save for a path (optional).
|
|
86
|
+
*
|
|
87
|
+
* @param path - File path segments
|
|
88
|
+
*/
|
|
89
|
+
cancel?(path: string[]): void;
|
|
90
|
+
/**
|
|
91
|
+
* Clean up resources for a path (optional).
|
|
92
|
+
* Called when autosave is disabled or node is removed.
|
|
93
|
+
*
|
|
94
|
+
* @param path - File path segments
|
|
95
|
+
*/
|
|
96
|
+
cleanup?(path: string[]): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=i-autosave-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i-autosave-provider.d.ts","sourceRoot":"","sources":["../../src/autosave/i-autosave-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IAEjB,kCAAkC;IAClC,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC;IAExD;;;;;;;;;;;OAWG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE9B;;;;;OAKG;IACH,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Interface
|
|
3
|
+
*
|
|
4
|
+
* Each filesystem plugin (remote-fs, remote-resource, git) implements this interface
|
|
5
|
+
* to handle actual save operations. The core autosave middleware handles debouncing
|
|
6
|
+
* and orchestration, then delegates to the appropriate provider for execution.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Registry Interface
|
|
3
|
+
*
|
|
4
|
+
* Registry for managing autosave providers. Plugins register their providers
|
|
5
|
+
* during activation, and the autosave middleware uses the registry to find
|
|
6
|
+
* the appropriate provider for each file.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileSystemNode } from '@hamak/shared-utils';
|
|
9
|
+
import type { IAutosaveProvider } from './i-autosave-provider';
|
|
10
|
+
/**
|
|
11
|
+
* Registry for autosave providers
|
|
12
|
+
*/
|
|
13
|
+
export interface IAutosaveProviderRegistry {
|
|
14
|
+
/**
|
|
15
|
+
* Register an autosave provider
|
|
16
|
+
*
|
|
17
|
+
* @param provider - The provider to register
|
|
18
|
+
* @throws Error if a provider with the same ID is already registered
|
|
19
|
+
*/
|
|
20
|
+
register(provider: IAutosaveProvider): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregister an autosave provider
|
|
23
|
+
*
|
|
24
|
+
* @param providerId - The ID of the provider to unregister
|
|
25
|
+
*/
|
|
26
|
+
unregister(providerId: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Get a provider by ID
|
|
29
|
+
*
|
|
30
|
+
* @param providerId - The provider ID
|
|
31
|
+
* @returns The provider or undefined if not found
|
|
32
|
+
*/
|
|
33
|
+
get(providerId: string): IAutosaveProvider | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Find the best provider for a path
|
|
36
|
+
*
|
|
37
|
+
* Checks all registered providers and returns the one with the highest
|
|
38
|
+
* priority that supports the given path.
|
|
39
|
+
*
|
|
40
|
+
* @param path - File path segments
|
|
41
|
+
* @param node - The filesystem node
|
|
42
|
+
* @returns The best matching provider or undefined if none found
|
|
43
|
+
*/
|
|
44
|
+
findProvider(path: string[], node: FileSystemNode): IAutosaveProvider | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get all registered providers
|
|
47
|
+
*
|
|
48
|
+
* @returns Array of all registered providers
|
|
49
|
+
*/
|
|
50
|
+
getAll(): IAutosaveProvider[];
|
|
51
|
+
/**
|
|
52
|
+
* Check if a provider is registered
|
|
53
|
+
*
|
|
54
|
+
* @param providerId - The provider ID
|
|
55
|
+
* @returns true if the provider is registered
|
|
56
|
+
*/
|
|
57
|
+
has(providerId: string): boolean;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=i-autosave-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i-autosave-registry.d.ts","sourceRoot":"","sources":["../../src/autosave/i-autosave-registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE5C;;;;OAIG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAEvD;;;;;;;;;OASG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,GAAG,iBAAiB,GAAG,SAAS,CAAC;IAElF;;;;OAIG;IACH,MAAM,IAAI,iBAAiB,EAAE,CAAC;IAE9B;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Registry Interface
|
|
3
|
+
*
|
|
4
|
+
* Registry for managing autosave providers. Plugins register their providers
|
|
5
|
+
* during activation, and the autosave middleware uses the registry to find
|
|
6
|
+
* the appropriate provider for each file.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/autosave/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Interface
|
|
3
|
+
*
|
|
4
|
+
* Each filesystem plugin (remote-fs, remote-resource, git) implements this interface
|
|
5
|
+
* to handle actual save operations. The core autosave middleware handles debouncing
|
|
6
|
+
* and orchestration, then delegates to the appropriate provider for execution.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autosave Provider Registry Interface
|
|
3
|
+
*
|
|
4
|
+
* Registry for managing autosave providers. Plugins register their providers
|
|
5
|
+
* during activation, and the autosave middleware uses the registry to find
|
|
6
|
+
* the appropriate provider for each file.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
package/dist/es2015/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED