@hamak/ui-local-fs 0.6.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 (43) hide show
  1. package/dist/impl/autosave/index.d.ts +2 -0
  2. package/dist/impl/autosave/index.d.ts.map +1 -0
  3. package/dist/impl/autosave/index.js +1 -0
  4. package/dist/impl/autosave/local-fs-autosave-provider.d.ts +31 -0
  5. package/dist/impl/autosave/local-fs-autosave-provider.d.ts.map +1 -0
  6. package/dist/impl/autosave/local-fs-autosave-provider.js +57 -0
  7. package/dist/impl/client/index.d.ts +3 -0
  8. package/dist/impl/client/index.d.ts.map +1 -0
  9. package/dist/impl/client/index.js +2 -0
  10. package/dist/impl/client/key-path.d.ts +45 -0
  11. package/dist/impl/client/key-path.d.ts.map +1 -0
  12. package/dist/impl/client/key-path.js +85 -0
  13. package/dist/impl/client/local-store-workspace-client.d.ts +32 -0
  14. package/dist/impl/client/local-store-workspace-client.d.ts.map +1 -0
  15. package/dist/impl/client/local-store-workspace-client.js +74 -0
  16. package/dist/impl/index.d.ts +9 -0
  17. package/dist/impl/index.d.ts.map +1 -0
  18. package/dist/impl/index.js +9 -0
  19. package/dist/impl/plugin/index.d.ts +3 -0
  20. package/dist/impl/plugin/index.d.ts.map +1 -0
  21. package/dist/impl/plugin/index.js +2 -0
  22. package/dist/impl/plugin/local-fs-plugin-factory.d.ts +42 -0
  23. package/dist/impl/plugin/local-fs-plugin-factory.d.ts.map +1 -0
  24. package/dist/impl/plugin/local-fs-plugin-factory.js +120 -0
  25. package/dist/impl/plugin/tokens.d.ts +12 -0
  26. package/dist/impl/plugin/tokens.d.ts.map +1 -0
  27. package/dist/impl/plugin/tokens.js +11 -0
  28. package/dist/impl/store/index.d.ts +2 -0
  29. package/dist/impl/store/index.d.ts.map +1 -0
  30. package/dist/impl/store/index.js +1 -0
  31. package/dist/impl/store/web-local-store.d.ts +37 -0
  32. package/dist/impl/store/web-local-store.d.ts.map +1 -0
  33. package/dist/impl/store/web-local-store.js +128 -0
  34. package/dist/index.d.ts +22 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +21 -0
  37. package/dist/spi/index.d.ts +6 -0
  38. package/dist/spi/index.d.ts.map +1 -0
  39. package/dist/spi/index.js +5 -0
  40. package/dist/spi/local-store.d.ts +28 -0
  41. package/dist/spi/local-store.d.ts.map +1 -0
  42. package/dist/spi/local-store.js +1 -0
  43. package/package.json +59 -0
@@ -0,0 +1,2 @@
1
+ export * from './local-fs-autosave-provider.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/autosave/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './local-fs-autosave-provider.js';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * LocalFsAutosaveProvider
3
+ *
4
+ * Autosave provider for files under a local-storage mount. On a content
5
+ * change for a path inside the mount it dispatches a PUT request, which the
6
+ * reused remote-fs middleware turns into a `LocalStoreWorkspaceClient.putFile`.
7
+ *
8
+ * Mirrors `RemoteFsAutosaveProvider` (different `id` so both can coexist). The
9
+ * app registers this in its autosave registry — the registry is app-managed,
10
+ * exactly as for remote-fs. See amah/app-framework#31.
11
+ */
12
+ import type { Dispatch, AnyAction } from 'redux';
13
+ import type { FileSystemNode } from '@hamak/shared-utils';
14
+ import type { IAutosaveProvider, AutosaveResult } from '@hamak/ui-store-spi';
15
+ import { type IPathTranslator } from '@hamak/ui-remote-fs';
16
+ export interface LocalFsAutosaveProviderConfig {
17
+ /** Path translator used to test whether a path is under the mount point. */
18
+ pathTranslator: IPathTranslator;
19
+ /** Provider priority (default 10). */
20
+ priority?: number;
21
+ }
22
+ export declare class LocalFsAutosaveProvider implements IAutosaveProvider {
23
+ readonly id = "local-fs";
24
+ readonly priority: number;
25
+ private readonly pathTranslator;
26
+ constructor(config: LocalFsAutosaveProviderConfig);
27
+ supports(path: string[], _node: FileSystemNode): boolean;
28
+ save(path: string[], content: unknown, _node: FileSystemNode, dispatch: Dispatch<AnyAction>): Promise<AutosaveResult>;
29
+ cancel(_path: string[]): void;
30
+ }
31
+ //# sourceMappingURL=local-fs-autosave-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-fs-autosave-provider.d.ts","sourceRoot":"","sources":["../../../src/impl/autosave/local-fs-autosave-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,KAAK,eAAe,EAAc,MAAM,qBAAqB,CAAC;AAEvE,MAAM,WAAW,6BAA6B;IAC5C,4EAA4E;IAC5E,cAAc,EAAE,eAAe,CAAC;IAChC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,QAAQ,CAAC,EAAE,cAAc;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkB;gBAErC,MAAM,EAAE,6BAA6B;IAKjD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO;IAIlD,IAAI,CACR,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC5B,OAAO,CAAC,cAAc,CAAC;IAe1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;CAG9B"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * LocalFsAutosaveProvider
3
+ *
4
+ * Autosave provider for files under a local-storage mount. On a content
5
+ * change for a path inside the mount it dispatches a PUT request, which the
6
+ * reused remote-fs middleware turns into a `LocalStoreWorkspaceClient.putFile`.
7
+ *
8
+ * Mirrors `RemoteFsAutosaveProvider` (different `id` so both can coexist). The
9
+ * app registers this in its autosave registry — the registry is app-managed,
10
+ * exactly as for remote-fs. See amah/app-framework#31.
11
+ */
12
+ import { rfsActions } from '@hamak/ui-remote-fs';
13
+ export class LocalFsAutosaveProvider {
14
+ constructor(config) {
15
+ Object.defineProperty(this, "id", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: 'local-fs'
20
+ });
21
+ Object.defineProperty(this, "priority", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ Object.defineProperty(this, "pathTranslator", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: void 0
32
+ });
33
+ this.pathTranslator = config.pathTranslator;
34
+ this.priority = config.priority ?? 10;
35
+ }
36
+ supports(path, _node) {
37
+ return this.pathTranslator.toRemotePath(path) !== undefined;
38
+ }
39
+ async save(path, content, _node, dispatch) {
40
+ try {
41
+ dispatch(rfsActions.ofPutRequest(path, content));
42
+ return { success: true, timestamp: Date.now() };
43
+ }
44
+ catch (error) {
45
+ return {
46
+ success: false,
47
+ error: {
48
+ code: error?.code ?? 'SAVE_ERROR',
49
+ message: error?.message ?? 'Failed to dispatch save action',
50
+ },
51
+ };
52
+ }
53
+ }
54
+ cancel(_path) {
55
+ // No-op: the mount middleware owns the request lifecycle.
56
+ }
57
+ }
@@ -0,0 +1,3 @@
1
+ export * from './key-path.js';
2
+ export * from './local-store-workspace-client.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './key-path.js';
2
+ export * from './local-store-workspace-client.js';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Key ⇆ path encoding for the local filesystem mount.
3
+ *
4
+ * A store key belonging to the mount has the form `<namespace>:<rel>` where
5
+ * `<rel>` is the path relative to the mount point. In **hierarchical** mode the
6
+ * separator (`/`) inside `<rel>` synthesizes subdirectories; in **flat** mode
7
+ * every key is a single file directly under the mount. See amah/app-framework#31.
8
+ */
9
+ export interface KeyPathConfig {
10
+ /** Key prefix that scopes which store keys belong to this mount (e.g. `prism.fs`). */
11
+ namespace: string;
12
+ /** `/`-delimited keys become subdirectories when true (default). */
13
+ hierarchical: boolean;
14
+ /** Path separator within a key's rel part (default `/`). */
15
+ separator: string;
16
+ }
17
+ export interface ChildEntry {
18
+ name: string;
19
+ isDirectory: boolean;
20
+ }
21
+ export declare const DEFAULT_SEPARATOR = "/";
22
+ export declare function resolveKeyPathConfig(config: Partial<KeyPathConfig> & {
23
+ namespace: string;
24
+ }): KeyPathConfig;
25
+ /** The `<namespace>:` prefix every key for this mount starts with. */
26
+ export declare function keyPrefix(config: KeyPathConfig): string;
27
+ /** Build the full store key for a mount-relative path. */
28
+ export declare function toKey(config: KeyPathConfig, segments: string[]): string;
29
+ /** Whether a store key belongs to this mount's namespace. */
30
+ export declare function belongsToMount(config: KeyPathConfig, key: string): boolean;
31
+ /** Strip the namespace prefix, returning the rel part of a key. */
32
+ export declare function keyToRel(config: KeyPathConfig, key: string): string;
33
+ /**
34
+ * List the immediate children of the directory at `dirSegments` (empty = mount
35
+ * root) given the full set of store keys. Files and synthesized directories are
36
+ * deduped by name; when a name is both (a file key and a deeper prefix exist),
37
+ * the directory wins because it has navigable children.
38
+ */
39
+ export declare function listChildren(config: KeyPathConfig, allKeys: string[], dirSegments: string[]): ChildEntry[];
40
+ /**
41
+ * Keys strictly underneath a directory path (used for recursive delete).
42
+ * Returns full store keys, not rel parts.
43
+ */
44
+ export declare function keysUnder(config: KeyPathConfig, allKeys: string[], dirSegments: string[]): string[];
45
+ //# sourceMappingURL=key-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-path.d.ts","sourceRoot":"","sources":["../../../src/impl/client/key-path.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,YAAY,EAAE,OAAO,CAAC;IACtB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrD,aAAa,CAMf;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAIvD;AAED,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvE;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,mEAAmE;AACnE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,EAAE,GACpB,UAAU,EAAE,CA+Bd;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,EAAE,GACpB,MAAM,EAAE,CAQV"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Key ⇆ path encoding for the local filesystem mount.
3
+ *
4
+ * A store key belonging to the mount has the form `<namespace>:<rel>` where
5
+ * `<rel>` is the path relative to the mount point. In **hierarchical** mode the
6
+ * separator (`/`) inside `<rel>` synthesizes subdirectories; in **flat** mode
7
+ * every key is a single file directly under the mount. See amah/app-framework#31.
8
+ */
9
+ export const DEFAULT_SEPARATOR = '/';
10
+ export function resolveKeyPathConfig(config) {
11
+ return {
12
+ namespace: config.namespace,
13
+ hierarchical: config.hierarchical ?? true,
14
+ separator: config.separator ?? DEFAULT_SEPARATOR,
15
+ };
16
+ }
17
+ /** The `<namespace>:` prefix every key for this mount starts with. */
18
+ export function keyPrefix(config) {
19
+ const ns = config.namespace;
20
+ if (ns === '')
21
+ return '';
22
+ return ns.endsWith(':') ? ns : `${ns}:`;
23
+ }
24
+ /** Build the full store key for a mount-relative path. */
25
+ export function toKey(config, segments) {
26
+ return keyPrefix(config) + segments.join(config.separator);
27
+ }
28
+ /** Whether a store key belongs to this mount's namespace. */
29
+ export function belongsToMount(config, key) {
30
+ return key.startsWith(keyPrefix(config));
31
+ }
32
+ /** Strip the namespace prefix, returning the rel part of a key. */
33
+ export function keyToRel(config, key) {
34
+ return key.slice(keyPrefix(config).length);
35
+ }
36
+ /**
37
+ * List the immediate children of the directory at `dirSegments` (empty = mount
38
+ * root) given the full set of store keys. Files and synthesized directories are
39
+ * deduped by name; when a name is both (a file key and a deeper prefix exist),
40
+ * the directory wins because it has navigable children.
41
+ */
42
+ export function listChildren(config, allKeys, dirSegments) {
43
+ const sep = config.separator;
44
+ const dirRel = dirSegments.join(sep);
45
+ const dirPrefix = dirRel === '' ? '' : dirRel + sep;
46
+ const byName = new Map(); // name -> isDirectory
47
+ for (const key of allKeys) {
48
+ if (!belongsToMount(config, key))
49
+ continue;
50
+ const rel = keyToRel(config, key);
51
+ if (rel === '')
52
+ continue;
53
+ if (!config.hierarchical) {
54
+ // Flat: keys are files at the root only.
55
+ if (dirSegments.length === 0)
56
+ byName.set(rel, false);
57
+ continue;
58
+ }
59
+ if (dirPrefix !== '' && !rel.startsWith(dirPrefix))
60
+ continue;
61
+ const remainder = rel.slice(dirPrefix.length);
62
+ if (remainder === '')
63
+ continue;
64
+ const idx = remainder.indexOf(sep);
65
+ if (idx === -1) {
66
+ if (!byName.get(remainder))
67
+ byName.set(remainder, false);
68
+ }
69
+ else {
70
+ byName.set(remainder.slice(0, idx), true); // directory wins
71
+ }
72
+ }
73
+ return [...byName.entries()].map(([name, isDirectory]) => ({ name, isDirectory }));
74
+ }
75
+ /**
76
+ * Keys strictly underneath a directory path (used for recursive delete).
77
+ * Returns full store keys, not rel parts.
78
+ */
79
+ export function keysUnder(config, allKeys, dirSegments) {
80
+ if (!config.hierarchical)
81
+ return [];
82
+ const sep = config.separator;
83
+ const dirPrefix = dirSegments.join(sep) + sep;
84
+ return allKeys.filter((key) => belongsToMount(config, key) && keyToRel(config, key).startsWith(dirPrefix));
85
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * LocalStoreWorkspaceClient — an `IWorkspaceClient` backed by an `ILocalStore`.
3
+ *
4
+ * This is the adapter that lets the (backend-agnostic) ui-remote-fs mount
5
+ * pipeline drive a browser local-storage area: directory listings come from
6
+ * enumerating namespaced keys, files are read/written as those keys' values.
7
+ * Paths received here are already mount-relative (the PathTranslator strips the
8
+ * mount prefix upstream). See amah/app-framework#31.
9
+ */
10
+ import type { FileInfo } from '@hamak/shared-utils';
11
+ import type { IWorkspaceClient, RequestOptions } from '@hamak/ui-remote-fs';
12
+ import type { ILocalStore } from '../../spi/index.js';
13
+ export interface LocalStoreWorkspaceClientConfig {
14
+ /** Key prefix scoping which store keys belong to this mount. */
15
+ namespace: string;
16
+ /** Synthesize subdirectories from `/`-delimited keys (default true). */
17
+ hierarchical?: boolean;
18
+ /** Path separator within keys (default `/`). */
19
+ separator?: string;
20
+ }
21
+ export declare class LocalStoreWorkspaceClient implements IWorkspaceClient {
22
+ private readonly store;
23
+ private readonly config;
24
+ constructor(store: ILocalStore, config: LocalStoreWorkspaceClientConfig);
25
+ listFiles(path: string[], _options?: RequestOptions): Promise<FileInfo[]>;
26
+ readFile(path: string[], _options?: RequestOptions): Promise<FileInfo>;
27
+ putFile(path: string[], content: any, _options?: RequestOptions): Promise<FileInfo>;
28
+ createDirectory(path: string[], _options?: RequestOptions): Promise<FileInfo>;
29
+ deleteFile(path: string[], _options?: RequestOptions): Promise<FileInfo>;
30
+ private fileInfo;
31
+ }
32
+ //# sourceMappingURL=local-store-workspace-client.d.ts.map
@@ -0,0 +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;AAW7C,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;IAQd,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"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * LocalStoreWorkspaceClient — an `IWorkspaceClient` backed by an `ILocalStore`.
3
+ *
4
+ * This is the adapter that lets the (backend-agnostic) ui-remote-fs mount
5
+ * pipeline drive a browser local-storage area: directory listings come from
6
+ * enumerating namespaced keys, files are read/written as those keys' values.
7
+ * Paths received here are already mount-relative (the PathTranslator strips the
8
+ * mount prefix upstream). See amah/app-framework#31.
9
+ */
10
+ import { resolveKeyPathConfig, toKey, keysUnder, listChildren, } from './key-path.js';
11
+ const EPOCH = new Date(0);
12
+ export class LocalStoreWorkspaceClient {
13
+ constructor(store, config) {
14
+ Object.defineProperty(this, "store", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: store
19
+ });
20
+ Object.defineProperty(this, "config", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ this.config = resolveKeyPathConfig(config);
27
+ }
28
+ async listFiles(path, _options) {
29
+ const children = listChildren(this.config, this.store.keys(), path);
30
+ return children.map((c) => this.fileInfo([...path, c.name], c.isDirectory));
31
+ }
32
+ async readFile(path, _options) {
33
+ const raw = this.store.getItem(toKey(this.config, path));
34
+ if (raw === null) {
35
+ throw new Error(`[ui-local-fs] file not found: ${path.join(this.config.separator)}`);
36
+ }
37
+ return this.fileInfo(path, false, raw);
38
+ }
39
+ async putFile(path, content, _options) {
40
+ // Always store valid JSON: the store-sync middleware JSON.parses content on
41
+ // read, so a round-trip requires the persisted value to be JSON.
42
+ const serialized = JSON.stringify(content ?? null);
43
+ this.store.setItem(toKey(this.config, path), serialized);
44
+ return this.fileInfo(path, false, serialized);
45
+ }
46
+ async createDirectory(path, _options) {
47
+ // The store has no directory entities; directories are implied by key
48
+ // structure. Creating one is a no-op (an empty directory simply does not
49
+ // persist until it contains a file).
50
+ return this.fileInfo(path, true);
51
+ }
52
+ async deleteFile(path, _options) {
53
+ const key = toKey(this.config, path);
54
+ if (this.store.getItem(key) !== null) {
55
+ this.store.removeItem(key);
56
+ return this.fileInfo(path, false);
57
+ }
58
+ // Not a file — treat as a directory and remove everything beneath it.
59
+ const under = keysUnder(this.config, this.store.keys(), path);
60
+ under.forEach((k) => this.store.removeItem(k));
61
+ return this.fileInfo(path, true);
62
+ }
63
+ fileInfo(segments, isDirectory, content) {
64
+ return {
65
+ name: segments[segments.length - 1] ?? '',
66
+ path: segments.join(this.config.separator),
67
+ isDirectory,
68
+ size: content ? content.length : 0,
69
+ createdAt: EPOCH,
70
+ updatedAt: EPOCH,
71
+ ...(content !== undefined ? { content } : {}),
72
+ };
73
+ }
74
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @hamak/ui-local-fs implementation.
3
+ */
4
+ export * from '../spi/index.js';
5
+ export * from './store/index.js';
6
+ export * from './client/index.js';
7
+ export * from './autosave/index.js';
8
+ export * from './plugin/index.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/impl/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,QAAQ,CAAC;AAEvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @hamak/ui-local-fs implementation.
3
+ */
4
+ // Re-export SPI for convenience.
5
+ export * from '../spi/index.js';
6
+ export * from './store/index.js';
7
+ export * from './client/index.js';
8
+ export * from './autosave/index.js';
9
+ export * from './plugin/index.js';
@@ -0,0 +1,3 @@
1
+ export * from './tokens.js';
2
+ export * from './local-fs-plugin-factory.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './tokens.js';
2
+ export * from './local-fs-plugin-factory.js';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Local FS Plugin Factory
3
+ *
4
+ * Mounts a browser local-storage area as a folder inside store-fs. Reuses the
5
+ * backend-agnostic ui-remote-fs mount pipeline (request + store-sync
6
+ * middleware, PathTranslator), swapping the HTTP client for a
7
+ * `LocalStoreWorkspaceClient`. See amah/app-framework#31.
8
+ */
9
+ import type { PluginModule } from '@hamak/microkernel-spi';
10
+ import type { Pathway } from '@hamak/shared-utils';
11
+ import { type IPathTranslator, type IWorkspaceClient } from '@hamak/ui-remote-fs';
12
+ import type { ILocalStore } from '../../spi/index.js';
13
+ export interface LocalFsPluginConfig {
14
+ /**
15
+ * Mount point in store-fs where the local storage area appears.
16
+ * @example Pathway.ofRoot().resolve('local')
17
+ */
18
+ mountPoint: Pathway;
19
+ /** Key prefix scoping which store keys belong to this mount (e.g. `prism.fs`). */
20
+ namespace: string;
21
+ /** Custom backend store. Defaults to a localStorage-backed store. */
22
+ store?: ILocalStore;
23
+ /** Which web storage area to use when `store` is not provided (default `localStorage`). */
24
+ storageArea?: 'localStorage' | 'sessionStorage';
25
+ /** Synthesize subdirectories from `/`-delimited keys (default true). */
26
+ hierarchical?: boolean;
27
+ /** Path separator within keys (default `/`). */
28
+ separator?: string;
29
+ /** Reload file content after a write (passed to store-sync, default true). */
30
+ autoReload?: boolean;
31
+ /** Optional transform applied to content before it enters store-fs. */
32
+ transformContent?: (content: any) => any;
33
+ /** Enable verbose logging. */
34
+ debug?: boolean;
35
+ /** Custom path translator (advanced). */
36
+ customPathTranslator?: IPathTranslator;
37
+ /** Custom workspace client (advanced / testing). */
38
+ customClient?: IWorkspaceClient;
39
+ }
40
+ export declare function createLocalFsPlugin(config: LocalFsPluginConfig): PluginModule;
41
+ export default createLocalFsPlugin;
42
+ //# sourceMappingURL=local-fs-plugin-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-fs-plugin-factory.d.ts","sourceRoot":"","sources":["../../../src/impl/plugin/local-fs-plugin-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAmB7C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAElB,qEAAqE;IACrE,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB,2FAA2F;IAC3F,WAAW,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC;IAEhD,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;IAEzC,8BAA8B;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yCAAyC;IACzC,oBAAoB,CAAC,EAAE,eAAe,CAAC;IAEvC,oDAAoD;IACpD,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,YAAY,CAqH7E;AAED,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Local FS Plugin Factory
3
+ *
4
+ * Mounts a browser local-storage area as a folder inside store-fs. Reuses the
5
+ * backend-agnostic ui-remote-fs mount pipeline (request + store-sync
6
+ * middleware, PathTranslator), swapping the HTTP client for a
7
+ * `LocalStoreWorkspaceClient`. See amah/app-framework#31.
8
+ */
9
+ import { PathTranslator, createRemoteFsMiddleware, createStoreSyncMiddleware, } from '@hamak/ui-remote-fs';
10
+ // Decoupled sibling plugins resolve the store services via the global
11
+ // `Symbol.for(...)` aliases the ui-store plugin registers for exactly this
12
+ // purpose — NOT the unique tokens from @hamak/ui-store-api, which are a
13
+ // different symbol instance than the ones the canonical store plugin provides.
14
+ // Same approach as ui-navigation. See amah/app-framework#28 and #5.
15
+ const STORE_MANAGER_TOKEN = Symbol.for('StoreManager');
16
+ const STORE_EXTENSIONS_TOKEN = Symbol.for('@hamak/ui-store:StoreExtensionsRegistry');
17
+ import { createLocalStorageStore, createSessionStorageStore } from '../store/index.js';
18
+ import { LocalStoreWorkspaceClient } from '../client/index.js';
19
+ import { LOCAL_STORE_TOKEN, LOCAL_FS_WORKSPACE_CLIENT_TOKEN, LOCAL_FS_PATH_TRANSLATOR_TOKEN, } from './tokens.js';
20
+ export function createLocalFsPlugin(config) {
21
+ let store;
22
+ let client;
23
+ let pathTranslator;
24
+ let storeManager;
25
+ const log = (message, ...args) => {
26
+ if (config.debug)
27
+ console.log(`[ui-local-fs] ${message}`, ...args);
28
+ };
29
+ return {
30
+ async initialize(ctx) {
31
+ store =
32
+ config.store ??
33
+ (config.storageArea === 'sessionStorage'
34
+ ? createSessionStorageStore()
35
+ : createLocalStorageStore());
36
+ client =
37
+ config.customClient ??
38
+ new LocalStoreWorkspaceClient(store, {
39
+ namespace: config.namespace,
40
+ hierarchical: config.hierarchical,
41
+ separator: config.separator,
42
+ });
43
+ pathTranslator =
44
+ config.customPathTranslator ?? new PathTranslator(config.mountPoint);
45
+ ctx.provide({ provide: LOCAL_STORE_TOKEN, useValue: store });
46
+ ctx.provide({ provide: LOCAL_FS_WORKSPACE_CLIENT_TOKEN, useValue: client });
47
+ ctx.provide({
48
+ provide: LOCAL_FS_PATH_TRANSLATOR_TOKEN,
49
+ useValue: pathTranslator,
50
+ });
51
+ log('initialized', {
52
+ mountPoint: config.mountPoint.getSegments(),
53
+ namespace: config.namespace,
54
+ available: store.isAvailable(),
55
+ });
56
+ },
57
+ async activate(ctx) {
58
+ try {
59
+ storeManager = ctx.resolve(STORE_MANAGER_TOKEN);
60
+ }
61
+ catch {
62
+ throw new Error('[ui-local-fs] Store manager not found. Ensure @hamak/ui-store is loaded before ui-local-fs.');
63
+ }
64
+ const fileSystemAdapter = storeManager.getFileSystemAdapter();
65
+ if (!fileSystemAdapter) {
66
+ throw new Error('[ui-local-fs] File system adapter not found in store manager.');
67
+ }
68
+ const extensionsCollector = ctx.resolve(STORE_EXTENSIONS_TOKEN);
69
+ // Reuse the remote-fs request middleware with our local-storage client.
70
+ const requestMiddleware = createRemoteFsMiddleware({
71
+ client,
72
+ pathTranslator,
73
+ onError: (error, action) => {
74
+ log('error', error, action);
75
+ ctx.hooks.emit('ui-local-fs:error', { error, action });
76
+ },
77
+ onSuccess: (result, action) => {
78
+ log('success', action?.type);
79
+ ctx.hooks.emit('ui-local-fs:success', { result, action });
80
+ },
81
+ });
82
+ const storeSyncMiddleware = createStoreSyncMiddleware({
83
+ fileSystemAdapter,
84
+ pathTranslator,
85
+ autoReload: config.autoReload,
86
+ transformContent: config.transformContent,
87
+ });
88
+ const middlewareExtensions = [
89
+ {
90
+ id: 'local-fs',
91
+ middleware: requestMiddleware,
92
+ priority: 100,
93
+ plugin: 'ui-local-fs',
94
+ description: 'Handles local-storage filesystem operations',
95
+ },
96
+ {
97
+ id: 'local-fs-store-sync',
98
+ middleware: storeSyncMiddleware,
99
+ priority: 50,
100
+ plugin: 'ui-local-fs',
101
+ description: 'Synchronizes local FS to Redux Store FS',
102
+ },
103
+ ];
104
+ extensionsCollector.register('ui-local-fs:middleware', {
105
+ middleware: middlewareExtensions,
106
+ });
107
+ ctx.hooks.emit('ui-local-fs:ready', {
108
+ client,
109
+ pathTranslator,
110
+ store,
111
+ mountPoint: config.mountPoint,
112
+ });
113
+ log('activated');
114
+ },
115
+ async deactivate() {
116
+ log('deactivated');
117
+ },
118
+ };
119
+ }
120
+ export default createLocalFsPlugin;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * DI tokens for the local filesystem mount. Namespaced separately from
3
+ * ui-remote-fs so both can be mounted side by side without clobbering each
4
+ * other's container registrations. See amah/app-framework#31.
5
+ */
6
+ /** The active {@link ILocalStore} backend. */
7
+ export declare const LOCAL_STORE_TOKEN: unique symbol;
8
+ /** The {@link IWorkspaceClient} bridging the store into the mount pipeline. */
9
+ export declare const LOCAL_FS_WORKSPACE_CLIENT_TOKEN: unique symbol;
10
+ /** The {@link IPathTranslator} for this mount point. */
11
+ export declare const LOCAL_FS_PATH_TRANSLATOR_TOKEN: unique symbol;
12
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/impl/plugin/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,eAA+C,CAAC;AAE9E,+EAA+E;AAC/E,eAAO,MAAM,+BAA+B,eAE3C,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,8BAA8B,eAE1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * DI tokens for the local filesystem mount. Namespaced separately from
3
+ * ui-remote-fs so both can be mounted side by side without clobbering each
4
+ * other's container registrations. See amah/app-framework#31.
5
+ */
6
+ /** The active {@link ILocalStore} backend. */
7
+ export const LOCAL_STORE_TOKEN = Symbol.for('@hamak/ui-local-fs:local-store');
8
+ /** The {@link IWorkspaceClient} bridging the store into the mount pipeline. */
9
+ export const LOCAL_FS_WORKSPACE_CLIENT_TOKEN = Symbol.for('@hamak/ui-local-fs:workspace-client');
10
+ /** The {@link IPathTranslator} for this mount point. */
11
+ export const LOCAL_FS_PATH_TRANSLATOR_TOKEN = Symbol.for('@hamak/ui-local-fs:path-translator');
@@ -0,0 +1,2 @@
1
+ export * from './web-local-store.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './web-local-store.js';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Web Storage implementation of {@link ILocalStore}.
3
+ *
4
+ * Backed by `localStorage` / `sessionStorage`, degrading gracefully to an
5
+ * in-memory map when the area is unavailable (SSR, private-mode quota errors,
6
+ * disabled storage) so the mount never throws. See amah/app-framework#31.
7
+ */
8
+ import type { ILocalStore } from '../../spi/index.js';
9
+ /** Minimal structural subset of the Web Storage API we depend on. */
10
+ export interface WebStorageLike {
11
+ getItem(key: string): string | null;
12
+ setItem(key: string, value: string): void;
13
+ removeItem(key: string): void;
14
+ key(index: number): string | null;
15
+ readonly length: number;
16
+ }
17
+ export declare class WebLocalStore implements ILocalStore {
18
+ private readonly storage;
19
+ private readonly memory;
20
+ private readonly available;
21
+ constructor(storage: WebStorageLike | null);
22
+ isAvailable(): boolean;
23
+ getItem(key: string): string | null;
24
+ setItem(key: string, value: string): void;
25
+ removeItem(key: string): void;
26
+ keys(): string[];
27
+ /** Observe cross-tab changes via the window `storage` event, when available. */
28
+ subscribe(listener: (key: string | null) => void): () => void;
29
+ private static probe;
30
+ }
31
+ /** {@link ILocalStore} backed by `window.localStorage` (in-memory fallback when absent). */
32
+ export declare function createLocalStorageStore(): WebLocalStore;
33
+ /** {@link ILocalStore} backed by `window.sessionStorage` (in-memory fallback when absent). */
34
+ export declare function createSessionStorageStore(): WebLocalStore;
35
+ /** Purely in-memory {@link ILocalStore} (tests, SSR, ephemeral mounts). */
36
+ export declare function createMemoryStore(): WebLocalStore;
37
+ //# sourceMappingURL=web-local-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-local-store.d.ts","sourceRoot":"","sources":["../../../src/impl/store/web-local-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAID,qBAAa,aAAc,YAAW,WAAW;IAInC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;gBAEP,OAAO,EAAE,cAAc,GAAG,IAAI;IAI3D,WAAW,IAAI,OAAO;IAItB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAWnC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAYzC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAW7B,IAAI,IAAI,MAAM,EAAE;IAgBhB,gFAAgF;IAChF,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAW7D,OAAO,CAAC,MAAM,CAAC,KAAK;CAUrB;AAaD,4FAA4F;AAC5F,wBAAgB,uBAAuB,IAAI,aAAa,CAEvD;AAED,8FAA8F;AAC9F,wBAAgB,yBAAyB,IAAI,aAAa,CAEzD;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,IAAI,aAAa,CAEjD"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Web Storage implementation of {@link ILocalStore}.
3
+ *
4
+ * Backed by `localStorage` / `sessionStorage`, degrading gracefully to an
5
+ * in-memory map when the area is unavailable (SSR, private-mode quota errors,
6
+ * disabled storage) so the mount never throws. See amah/app-framework#31.
7
+ */
8
+ const PROBE_KEY = '@hamak/ui-local-fs:__probe__';
9
+ export class WebLocalStore {
10
+ constructor(storage) {
11
+ Object.defineProperty(this, "storage", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: storage
16
+ });
17
+ Object.defineProperty(this, "memory", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: new Map()
22
+ });
23
+ Object.defineProperty(this, "available", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ this.available = WebLocalStore.probe(storage);
30
+ }
31
+ isAvailable() {
32
+ return this.available;
33
+ }
34
+ getItem(key) {
35
+ if (this.available && this.storage) {
36
+ try {
37
+ return this.storage.getItem(key);
38
+ }
39
+ catch (e) {
40
+ console.warn('[ui-local-fs] getItem failed:', e);
41
+ }
42
+ }
43
+ return this.memory.get(key) ?? null;
44
+ }
45
+ setItem(key, value) {
46
+ if (this.available && this.storage) {
47
+ try {
48
+ this.storage.setItem(key, value);
49
+ return;
50
+ }
51
+ catch (e) {
52
+ console.warn('[ui-local-fs] setItem failed, using memory fallback:', e);
53
+ }
54
+ }
55
+ this.memory.set(key, value);
56
+ }
57
+ removeItem(key) {
58
+ this.memory.delete(key);
59
+ if (this.available && this.storage) {
60
+ try {
61
+ this.storage.removeItem(key);
62
+ }
63
+ catch (e) {
64
+ console.warn('[ui-local-fs] removeItem failed:', e);
65
+ }
66
+ }
67
+ }
68
+ keys() {
69
+ const out = new Set();
70
+ if (this.available && this.storage) {
71
+ try {
72
+ for (let i = 0; i < this.storage.length; i++) {
73
+ const k = this.storage.key(i);
74
+ if (k !== null)
75
+ out.add(k);
76
+ }
77
+ }
78
+ catch (e) {
79
+ console.warn('[ui-local-fs] keys() enumeration failed:', e);
80
+ }
81
+ }
82
+ for (const k of this.memory.keys())
83
+ out.add(k);
84
+ return [...out];
85
+ }
86
+ /** Observe cross-tab changes via the window `storage` event, when available. */
87
+ subscribe(listener) {
88
+ const w = globalThis;
89
+ if (!w.addEventListener || !w.removeEventListener)
90
+ return () => { };
91
+ const handler = (e) => listener(e?.key ?? null);
92
+ w.addEventListener('storage', handler);
93
+ return () => w.removeEventListener('storage', handler);
94
+ }
95
+ static probe(storage) {
96
+ if (!storage)
97
+ return false;
98
+ try {
99
+ storage.setItem(PROBE_KEY, '1');
100
+ storage.removeItem(PROBE_KEY);
101
+ return true;
102
+ }
103
+ catch {
104
+ return false;
105
+ }
106
+ }
107
+ }
108
+ function getWindowStorage(kind) {
109
+ try {
110
+ const g = globalThis;
111
+ return g[kind] ?? null;
112
+ }
113
+ catch {
114
+ return null;
115
+ }
116
+ }
117
+ /** {@link ILocalStore} backed by `window.localStorage` (in-memory fallback when absent). */
118
+ export function createLocalStorageStore() {
119
+ return new WebLocalStore(getWindowStorage('localStorage'));
120
+ }
121
+ /** {@link ILocalStore} backed by `window.sessionStorage` (in-memory fallback when absent). */
122
+ export function createSessionStorageStore() {
123
+ return new WebLocalStore(getWindowStorage('sessionStorage'));
124
+ }
125
+ /** Purely in-memory {@link ILocalStore} (tests, SSR, ephemeral mounts). */
126
+ export function createMemoryStore() {
127
+ return new WebLocalStore(null);
128
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @hamak/ui-local-fs
3
+ * Browser local-storage filesystem mount for microkernel-based applications.
4
+ *
5
+ * Mounts a localStorage (or any ILocalStore) area as a folder inside store-fs,
6
+ * parallel to @hamak/ui-remote-fs but offline and synchronous. Keys become
7
+ * files. See amah/app-framework#31.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Pathway } from '@hamak/shared-utils';
12
+ * import { createLocalFsPlugin } from '@hamak/ui-local-fs';
13
+ *
14
+ * const plugin = createLocalFsPlugin({
15
+ * mountPoint: Pathway.ofRoot().resolve('local'),
16
+ * namespace: 'prism.fs',
17
+ * hierarchical: true,
18
+ * });
19
+ * ```
20
+ */
21
+ export * from './impl/index.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @hamak/ui-local-fs
3
+ * Browser local-storage filesystem mount for microkernel-based applications.
4
+ *
5
+ * Mounts a localStorage (or any ILocalStore) area as a folder inside store-fs,
6
+ * parallel to @hamak/ui-remote-fs but offline and synchronous. Keys become
7
+ * files. See amah/app-framework#31.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Pathway } from '@hamak/shared-utils';
12
+ * import { createLocalFsPlugin } from '@hamak/ui-local-fs';
13
+ *
14
+ * const plugin = createLocalFsPlugin({
15
+ * mountPoint: Pathway.ofRoot().resolve('local'),
16
+ * namespace: 'prism.fs',
17
+ * hierarchical: true,
18
+ * });
19
+ * ```
20
+ */
21
+ export * from './impl/index.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @hamak/ui-local-fs SPI
3
+ * Service Provider Interfaces for the local filesystem mount.
4
+ */
5
+ export * from './local-store.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spi/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @hamak/ui-local-fs SPI
3
+ * Service Provider Interfaces for the local filesystem mount.
4
+ */
5
+ export * from './local-store.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * ILocalStore — backend SPI for a synchronous key/value store.
3
+ *
4
+ * This is the pluggable backend behind the local filesystem mount. The default
5
+ * implementation wraps `window.localStorage` / `sessionStorage`, but any local
6
+ * persistence (IndexedDB, OPFS, an in-memory map) can implement this interface.
7
+ * Keys are opaque strings; the workspace client owns the key⇆path encoding.
8
+ * See amah/app-framework#31.
9
+ */
10
+ export interface ILocalStore {
11
+ /** Read a raw value, or `null` if the key is absent. */
12
+ getItem(key: string): string | null;
13
+ /** Write a raw value. */
14
+ setItem(key: string, value: string): void;
15
+ /** Delete a key (no-op if absent). */
16
+ removeItem(key: string): void;
17
+ /** Enumerate every key currently held. */
18
+ keys(): string[];
19
+ /** Whether the backing storage is usable (false ⇒ in-memory fallback). */
20
+ isAvailable(): boolean;
21
+ /**
22
+ * Optionally observe external changes (e.g. cross-tab `storage` events).
23
+ * The listener receives the changed key, or `null` for a bulk change.
24
+ * Returns an unsubscribe function. Backends without change events may omit it.
25
+ */
26
+ subscribe?(listener: (key: string | null) => void): () => void;
27
+ }
28
+ //# sourceMappingURL=local-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-store.d.ts","sourceRoot":"","sources":["../../src/spi/local-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,yBAAyB;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,sCAAsC;IACtC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0CAA0C;IAC1C,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,0EAA0E;IAC1E,WAAW,IAAI,OAAO,CAAC;IACvB;;;;OAIG;IACH,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAChE"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@hamak/ui-local-fs",
3
+ "version": "0.6.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Browser local-storage filesystem mount for microkernel-based applications",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/amah/app-framework.git",
16
+ "directory": "packages/ui-local-fs"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "tsc -p tsconfig.lib.json && node ../../scripts/fix-esm-extensions.mjs ./dist",
23
+ "clean": "rm -rf dist",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./spi": {
34
+ "types": "./dist/spi/index.d.ts",
35
+ "import": "./dist/spi/index.js",
36
+ "default": "./dist/spi/index.js"
37
+ }
38
+ },
39
+ "typesVersions": {
40
+ "*": {
41
+ "spi": [
42
+ "./dist/spi/index.d.ts"
43
+ ]
44
+ }
45
+ },
46
+ "dependencies": {
47
+ "@hamak/shared-utils": "*",
48
+ "@hamak/ui-remote-fs": "*",
49
+ "@hamak/ui-store-api": "*",
50
+ "@hamak/ui-store-spi": "*",
51
+ "@hamak/microkernel-spi": "*",
52
+ "redux": "^5.0.1"
53
+ },
54
+ "devDependencies": {
55
+ "typescript": "~5.4.0",
56
+ "vitest": "^2.0.0",
57
+ "@types/node": "^20.0.0"
58
+ }
59
+ }