@hamak/ui-store 0.8.1 → 0.9.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/impl/fs/commands/fs-commands.d.ts +12 -2
- package/dist/impl/fs/commands/fs-commands.d.ts.map +1 -1
- package/dist/impl/fs/commands/fs-commands.js +21 -0
- package/dist/impl/fs/core/fs-adapter.d.ts +8 -0
- package/dist/impl/fs/core/fs-adapter.d.ts.map +1 -1
- package/dist/impl/fs/core/fs-adapter.js +23 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { DataUpdater } from '../utils/data-updater.js';
|
|
|
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' | 'set-extension-state';
|
|
8
|
+
name: 'mkdir' | 'set-file' | 'remove' | 'update-file-content' | 'set-file-content' | 'set-extension-state' | 'set-content-loading';
|
|
9
9
|
path: string | string[];
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -57,10 +57,19 @@ export interface SetExtensionStateCommand extends FsCommandBase {
|
|
|
57
57
|
key: string;
|
|
58
58
|
state: Record<string, unknown>;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Set the loading flag on a file node without touching its content.
|
|
62
|
+
* Used for stale-while-revalidate refreshes (keep previous content visible
|
|
63
|
+
* while a new fetch is in flight). Setting loading=true clears any prior error.
|
|
64
|
+
*/
|
|
65
|
+
export interface SetContentLoadingCommand extends FsCommandBase {
|
|
66
|
+
name: 'set-content-loading';
|
|
67
|
+
loading: boolean;
|
|
68
|
+
}
|
|
60
69
|
/**
|
|
61
70
|
* Union type for all filesystem commands
|
|
62
71
|
*/
|
|
63
|
-
export type FileSystemCommand = MkdirCommand | RemoveCommand | SetFileCommand | UpdateFileContentCommand | SetFileContentCommand | SetExtensionStateCommand;
|
|
72
|
+
export type FileSystemCommand = MkdirCommand | RemoveCommand | SetFileCommand | UpdateFileContentCommand | SetFileContentCommand | SetExtensionStateCommand | SetContentLoadingCommand;
|
|
64
73
|
export { pathSteps, parentPathSteps } from '@hamak/shared-utils';
|
|
65
74
|
/**
|
|
66
75
|
* Get filesystem node at path
|
|
@@ -79,6 +88,7 @@ export declare class FileSystemCommandHandler {
|
|
|
79
88
|
private contentMayChange;
|
|
80
89
|
private executeSetContentCommand;
|
|
81
90
|
private executeSetExtensionState;
|
|
91
|
+
private executeSetContentLoading;
|
|
82
92
|
protected current<T = any>(o: T): T;
|
|
83
93
|
protected original<T = any>(o: T): T | undefined;
|
|
84
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-commands.d.ts","sourceRoot":"","sources":["../../../../src/impl/fs/commands/fs-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAEtB,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,GAAG,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"fs-commands.d.ts","sourceRoot":"","sources":["../../../../src/impl/fs/commands/fs-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAEtB,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,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EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;CAKxD"}
|
|
@@ -69,6 +69,7 @@ export class FileSystemCommandHandler {
|
|
|
69
69
|
case 'set-file-content': return this.executeSetContentCommand(state, command);
|
|
70
70
|
case 'remove': return this.executeRemove(state, command);
|
|
71
71
|
case 'set-extension-state': return this.executeSetExtensionState(state, command);
|
|
72
|
+
case 'set-content-loading': return this.executeSetContentLoading(state, command);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
executeMkdir(state, command) {
|
|
@@ -245,6 +246,26 @@ export class FileSystemCommandHandler {
|
|
|
245
246
|
}
|
|
246
247
|
});
|
|
247
248
|
}
|
|
249
|
+
executeSetContentLoading(state, command) {
|
|
250
|
+
const { path, loading } = command;
|
|
251
|
+
return produce(state, draft => {
|
|
252
|
+
const { root } = draft;
|
|
253
|
+
const node = getFileSystemNode(root, path);
|
|
254
|
+
if (node === undefined) {
|
|
255
|
+
console.warn(`No node found at location`, path);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (node.state === undefined) {
|
|
259
|
+
node.state = fileSystemNodeInitialState();
|
|
260
|
+
}
|
|
261
|
+
// Flip the loading flag without touching content. Starting a load clears
|
|
262
|
+
// any previous error so a retry doesn't surface a stale failure.
|
|
263
|
+
node.state.contentLoading = loading;
|
|
264
|
+
if (loading) {
|
|
265
|
+
node.state.contentLoadError = undefined;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
248
269
|
current(o) {
|
|
249
270
|
if (o === null || o === undefined) {
|
|
250
271
|
return o;
|
|
@@ -35,6 +35,7 @@ export declare class FileSystemNodeActions {
|
|
|
35
35
|
private readonly _updateFileContentType;
|
|
36
36
|
private readonly _setFileContentType;
|
|
37
37
|
private readonly _setExtensionStateType;
|
|
38
|
+
private readonly _setContentLoadingType;
|
|
38
39
|
private actionTypeSet;
|
|
39
40
|
constructor(sliceName: string);
|
|
40
41
|
get mkdirType(): string;
|
|
@@ -43,6 +44,7 @@ export declare class FileSystemNodeActions {
|
|
|
43
44
|
get updateFileContentType(): string;
|
|
44
45
|
get setFileContentType(): string;
|
|
45
46
|
get setExtensionStateType(): string;
|
|
47
|
+
get setContentLoadingType(): string;
|
|
46
48
|
isFileSystemNodeAction(action: Action): action is FileSystemNodeAction;
|
|
47
49
|
mkdir(path: string | string[], parents?: boolean, extensionStates?: Record<string, unknown>): FileSystemNodeAction;
|
|
48
50
|
setFile(path: string | string[], content: any, schema: FileContentSchema, params?: FileSystemNodeActionParams): FileSystemNodeAction;
|
|
@@ -50,5 +52,11 @@ export declare class FileSystemNodeActions {
|
|
|
50
52
|
setFileContent(path: string | string[], content: any, fromRemote?: boolean): FileSystemNodeAction;
|
|
51
53
|
removeNode(path: string | string[], recursive?: boolean): FileSystemNodeAction;
|
|
52
54
|
setExtensionState(path: string | string[], key: string, state: Record<string, unknown>): FileSystemNodeAction;
|
|
55
|
+
/**
|
|
56
|
+
* Set a file node's loading flag without altering its content.
|
|
57
|
+
* Enables stale-while-revalidate: keep the previous content visible while a
|
|
58
|
+
* re-fetch is in flight. Passing `true` also clears any prior load error.
|
|
59
|
+
*/
|
|
60
|
+
setContentLoading(path: string | string[], loading: boolean): FileSystemNodeAction;
|
|
53
61
|
}
|
|
54
62
|
//# sourceMappingURL=fs-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-adapter.d.ts","sourceRoot":"","sources":["../../../../src/impl/fs/core/fs-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EAEd,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,QAAQ,EACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE;;GAEG;A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AM,CAElC;IAED,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,oBAAoB;IAI/D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAC,OAAO,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB;IAOjH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAG,iBAAiB,EAAE,MAAM,GAAG,0BAAoE,GAAG,oBAAoB;IAQ9K,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,cAAc,EAAG,oBAAoB,GAAI,oBAAoB;IAOxG,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAG,GAAG,EAAE,UAAU,UAAQ,GAAG,oBAAoB;IAQhG,UAAU,CAAC,IAAI,EAAG,MAAM,GAAG,MAAM,EAAE,EAAE,SAAS,CAAC,EAAG,OAAO,GAAG,oBAAoB;IAOhF,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB;IAOpH;;;;OAIG;IACI,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,oBAAoB;CAO1F"}
|
|
@@ -122,6 +122,12 @@ export class FileSystemNodeActions {
|
|
|
122
122
|
writable: true,
|
|
123
123
|
value: void 0
|
|
124
124
|
});
|
|
125
|
+
Object.defineProperty(this, "_setContentLoadingType", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
value: void 0
|
|
130
|
+
});
|
|
125
131
|
Object.defineProperty(this, "actionTypeSet", {
|
|
126
132
|
enumerable: true,
|
|
127
133
|
configurable: true,
|
|
@@ -134,13 +140,15 @@ export class FileSystemNodeActions {
|
|
|
134
140
|
this._updateFileContentType = `${this.sliceName}/updateFileContent`;
|
|
135
141
|
this._setFileContentType = `${this.sliceName}/setFileContent`;
|
|
136
142
|
this._setExtensionStateType = `${this.sliceName}/setExtensionState`;
|
|
143
|
+
this._setContentLoadingType = `${this.sliceName}/setContentLoading`;
|
|
137
144
|
this.actionTypeSet = new Set([
|
|
138
145
|
this._mkdirType,
|
|
139
146
|
this._setFileType,
|
|
140
147
|
this._removeType,
|
|
141
148
|
this._updateFileContentType,
|
|
142
149
|
this._setFileContentType,
|
|
143
|
-
this._setExtensionStateType
|
|
150
|
+
this._setExtensionStateType,
|
|
151
|
+
this._setContentLoadingType
|
|
144
152
|
]);
|
|
145
153
|
}
|
|
146
154
|
get mkdirType() {
|
|
@@ -161,6 +169,9 @@ export class FileSystemNodeActions {
|
|
|
161
169
|
get setExtensionStateType() {
|
|
162
170
|
return this._setExtensionStateType;
|
|
163
171
|
}
|
|
172
|
+
get setContentLoadingType() {
|
|
173
|
+
return this._setContentLoadingType;
|
|
174
|
+
}
|
|
164
175
|
isFileSystemNodeAction(action) {
|
|
165
176
|
return this.actionTypeSet.has(action.type);
|
|
166
177
|
}
|
|
@@ -201,4 +212,15 @@ export class FileSystemNodeActions {
|
|
|
201
212
|
command: { name: 'set-extension-state', path, key, state }
|
|
202
213
|
};
|
|
203
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Set a file node's loading flag without altering its content.
|
|
217
|
+
* Enables stale-while-revalidate: keep the previous content visible while a
|
|
218
|
+
* re-fetch is in flight. Passing `true` also clears any prior load error.
|
|
219
|
+
*/
|
|
220
|
+
setContentLoading(path, loading) {
|
|
221
|
+
return {
|
|
222
|
+
type: this.setContentLoadingType,
|
|
223
|
+
command: { name: 'set-content-loading', path, loading }
|
|
224
|
+
};
|
|
225
|
+
}
|
|
204
226
|
}
|