@hamak/ui-local-fs 0.14.1 → 0.15.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.
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { Dispatch, AnyAction } from 'redux';
|
|
13
13
|
import type { FileSystemNode } from '@hamak/shared-utils';
|
|
14
|
-
import type { IAutosaveProvider, AutosaveResult } from '@hamak/ui-store
|
|
14
|
+
import type { IAutosaveProvider, AutosaveResult } from '@hamak/ui-store/spi';
|
|
15
15
|
import { type IPathTranslator } from '@hamak/ui-remote-fs';
|
|
16
16
|
export interface LocalFsAutosaveProviderConfig {
|
|
17
17
|
/** Path translator used to test whether a path is under the mount point. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-store-workspace-client.d.ts","sourceRoot":"","sources":["../../../src/impl/client/local-store-workspace-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"local-store-workspace-client.d.ts","sourceRoot":"","sources":["../../../src/impl/client/local-store-workspace-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AA+B7C,MAAM,WAAW,+BAA+B;IAC9C,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,yBAA0B,YAAW,gBAAgB;IAI9D,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAGpB,KAAK,EAAE,WAAW,EACnC,MAAM,EAAE,+BAA+B;IAKnC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOzE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUtE,OAAO,CACX,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,GAAG,EACZ,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC;IAkBd,eAAe,CACnB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC;IAOd,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY9E,OAAO,CAAC,QAAQ;CAejB"}
|
|
@@ -9,6 +9,25 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { resolveKeyPathConfig, toKey, keysUnder, listChildren, } from './key-path.js';
|
|
11
11
|
const EPOCH = new Date(0);
|
|
12
|
+
/**
|
|
13
|
+
* Serialize content to the string a mount key stores.
|
|
14
|
+
*
|
|
15
|
+
* Mirrors `HttpWorkspaceClient.serializeContent`
|
|
16
|
+
* (packages/ui-remote-fs/src/impl/providers/http-workspace-client.ts) exactly:
|
|
17
|
+
* a string is stored verbatim (this store also carries non-JSON files),
|
|
18
|
+
* `undefined` becomes an empty file, and anything else is pretty-printed JSON.
|
|
19
|
+
* `serializeContent` is a private method there, not an exported helper, so it
|
|
20
|
+
* is mirrored here rather than imported — keep the two in sync by hand.
|
|
21
|
+
*/
|
|
22
|
+
function serializeContent(content) {
|
|
23
|
+
if (typeof content === 'string') {
|
|
24
|
+
return content;
|
|
25
|
+
}
|
|
26
|
+
if (content === undefined) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
return JSON.stringify(content, null, 2);
|
|
30
|
+
}
|
|
12
31
|
export class LocalStoreWorkspaceClient {
|
|
13
32
|
constructor(store, config) {
|
|
14
33
|
Object.defineProperty(this, "store", {
|
|
@@ -37,9 +56,19 @@ export class LocalStoreWorkspaceClient {
|
|
|
37
56
|
return this.fileInfo(path, false, raw);
|
|
38
57
|
}
|
|
39
58
|
async putFile(path, content, _options) {
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
59
|
+
// The store-sync middleware's decodeFileContent only JSON.parses a file
|
|
60
|
+
// whose *suffix* says JSON (see @hamak/shared-utils/file-content-type);
|
|
61
|
+
// everything else is read back verbatim. So this serialization must match
|
|
62
|
+
// that contract, not always produce JSON — otherwise a non-JSON file
|
|
63
|
+
// (.xqm, .txt, .css, …) gains a quote layer on every save that never
|
|
64
|
+
// comes off on read (amah/app-framework#49).
|
|
65
|
+
//
|
|
66
|
+
// Mirrors HttpWorkspaceClient.serializeContent
|
|
67
|
+
// (packages/ui-remote-fs/src/impl/providers/http-workspace-client.ts) so
|
|
68
|
+
// the two IWorkspaceClient implementations share identical file
|
|
69
|
+
// semantics: a string is stored verbatim, undefined becomes an empty
|
|
70
|
+
// file, and anything else is pretty-printed JSON.
|
|
71
|
+
const serialized = serializeContent(content);
|
|
43
72
|
this.store.setItem(toKey(this.config, path), serialized);
|
|
44
73
|
return this.fileInfo(path, false, serialized);
|
|
45
74
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { PathTranslator, createRemoteFsMiddleware, createStoreSyncMiddleware, } from '@hamak/ui-remote-fs';
|
|
10
10
|
// Decoupled sibling plugins resolve the store services via the global
|
|
11
11
|
// `Symbol.for(...)` aliases the ui-store plugin registers for exactly this
|
|
12
|
-
// purpose — NOT the unique tokens from @hamak/ui-store
|
|
12
|
+
// purpose — NOT the unique tokens from @hamak/ui-store/api, which are a
|
|
13
13
|
// different symbol instance than the ones the canonical store plugin provides.
|
|
14
14
|
// Same approach as ui-navigation. See amah/app-framework#28 and #5.
|
|
15
15
|
const STORE_MANAGER_TOKEN = Symbol.for('StoreManager');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamak/ui-local-fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Browser local-storage filesystem mount for microkernel-based applications",
|
|
@@ -44,11 +44,10 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@hamak/shared-utils": "^0.
|
|
48
|
-
"@hamak/ui-remote-fs": "^0.
|
|
49
|
-
"@hamak/ui-store
|
|
50
|
-
"@hamak/
|
|
51
|
-
"@hamak/microkernel-spi": "^0.14.1",
|
|
47
|
+
"@hamak/shared-utils": "^0.15.0",
|
|
48
|
+
"@hamak/ui-remote-fs": "^0.15.0",
|
|
49
|
+
"@hamak/ui-store": "^0.15.0",
|
|
50
|
+
"@hamak/microkernel-spi": "^0.15.0",
|
|
52
51
|
"redux": "^5.0.1"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|