@floegence/floe-webapp-core 0.48.5 → 0.49.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.
@@ -0,0 +1,91 @@
1
+ import type { FileItem } from '../../file-browser/types';
2
+ export interface PickerRoot {
3
+ id: string;
4
+ label: string;
5
+ pathAbs: string;
6
+ permissions?: Readonly<{
7
+ read: boolean;
8
+ write: boolean;
9
+ }>;
10
+ hidden?: boolean;
11
+ }
12
+ export interface PickerPathContext {
13
+ homePathAbs: string;
14
+ defaultRootId: string;
15
+ roots: readonly PickerRoot[];
16
+ }
17
+ export type PickerDirectoryLoader = (path: string, options: {
18
+ showHidden: boolean;
19
+ }) => Promise<readonly FileItem[]>;
20
+ export interface PickerCopy {
21
+ path: string;
22
+ go: string;
23
+ roots: string;
24
+ root: string;
25
+ showHidden: string;
26
+ loading: string;
27
+ retry: string;
28
+ empty: string;
29
+ emptyFiles: string;
30
+ invalidPath: string;
31
+ missingPath: string;
32
+ unavailableContext: string;
33
+ loadFailed: string;
34
+ currentDirectory: string;
35
+ newFolder: string;
36
+ folderName: string;
37
+ create: string;
38
+ cancel: string;
39
+ fileName: string;
40
+ fileNameRequired: string;
41
+ noFilesSelected: string;
42
+ selectionLimit: string;
43
+ selectedCount: (count: number) => string;
44
+ }
45
+ export declare const defaultPickerCopy: PickerCopy;
46
+ export interface PickerDataProps {
47
+ /** Static trees contain absolute paths. Remote consumers provide loadDirectory instead. */
48
+ files?: readonly FileItem[];
49
+ pathContext?: PickerPathContext;
50
+ /** Refreshed on every open, scope change, and explicit context retry. */
51
+ loadPathContext?: () => Promise<PickerPathContext>;
52
+ loadDirectory?: PickerDirectoryLoader;
53
+ /** Changing environment/session identity invalidates all pending work. */
54
+ scopeKey?: string;
55
+ initialPath?: string;
56
+ /** Display-only Home hint for static pickers; never rebases a path. */
57
+ homePath?: string;
58
+ homeLabel?: string;
59
+ initialShowHidden?: boolean;
60
+ filter?: (item: FileItem) => boolean;
61
+ copy?: Partial<PickerCopy>;
62
+ formatError?: (error: unknown) => string;
63
+ onValidityChange?: (valid: boolean) => void;
64
+ }
65
+ export declare class PickerNavigationError extends Error {
66
+ readonly kind: 'invalidPath' | 'missingPath' | 'unavailableContext';
67
+ constructor(kind: 'invalidPath' | 'missingPath' | 'unavailableContext');
68
+ }
69
+ /** Absolute POSIX paths only. The runtime remains responsible for canonical/symlink resolution. */
70
+ export declare function parsePickerPath(rawPath: string, homePathAbs?: string): string;
71
+ export declare function pickerParentPath(path: string): string;
72
+ export declare function formatPickerPath(path: string, homePathAbs?: string): string;
73
+ /** Owns one committed directory and latest navigation. No cached tree can authorize a path. */
74
+ export declare function createFilesystemPickerDataSource(getProps: () => PickerDataProps, onValidated?: (path: string) => void): {
75
+ context: import("solid-js").Accessor<PickerPathContext | null>;
76
+ currentPath: import("solid-js").Accessor<string>;
77
+ entries: import("solid-js").Accessor<readonly FileItem[]>;
78
+ pathInput: import("solid-js").Accessor<string>;
79
+ pending: import("solid-js").Accessor<boolean>;
80
+ error: import("solid-js").Accessor<unknown>;
81
+ showHidden: import("solid-js").Accessor<boolean>;
82
+ active: import("solid-js").Accessor<boolean>;
83
+ valid: () => boolean;
84
+ open: (path?: string) => Promise<void>;
85
+ close: () => void;
86
+ navigate: (rawPath: string) => Promise<boolean>;
87
+ setPathInput(value: string): void;
88
+ setShowHidden(value: boolean): Promise<void>;
89
+ retry(): Promise<void>;
90
+ };
91
+ export type FilesystemPickerDataSource = ReturnType<typeof createFilesystemPickerDataSource>;
@@ -0,0 +1,160 @@
1
+ import { createSignal as l, onCleanup as z, batch as d } from "solid-js";
2
+ const J = {
3
+ path: "Directory path",
4
+ go: "Go",
5
+ roots: "Locations",
6
+ root: "Root",
7
+ showHidden: "Show hidden items",
8
+ loading: "Loading directory…",
9
+ retry: "Retry",
10
+ empty: "No directories here",
11
+ emptyFiles: "No matching files in this directory",
12
+ invalidPath: "Enter an absolute path or a path starting with ~/",
13
+ missingPath: "Directory not found",
14
+ unavailableContext: "Filesystem locations are unavailable",
15
+ loadFailed: "Could not load directory",
16
+ currentDirectory: "Current directory",
17
+ newFolder: "New folder",
18
+ folderName: "Folder name",
19
+ create: "Create",
20
+ cancel: "Cancel",
21
+ fileName: "File name",
22
+ fileNameRequired: "Filename is required",
23
+ noFilesSelected: "No files selected",
24
+ selectionLimit: "Selection limit reached",
25
+ selectedCount: (t) => `${t} selected`
26
+ };
27
+ class S extends Error {
28
+ constructor(n) {
29
+ super(n), this.kind = n;
30
+ }
31
+ }
32
+ function g(t, n = "") {
33
+ let e = String(t ?? "").trim();
34
+ if (e === "~" ? e = n : e.startsWith("~/") && (e = n ? `${n}/${e.slice(2)}` : ""), !e.startsWith("/") || e.includes("\0")) return "";
35
+ const u = [];
36
+ for (const o of e.split("/"))
37
+ !o || o === "." || (o === ".." ? u.pop() : u.push(o));
38
+ return `/${u.join("/")}`;
39
+ }
40
+ function Q(t) {
41
+ const n = g(t);
42
+ return n.slice(0, n.lastIndexOf("/")) || "/";
43
+ }
44
+ function U(t, n = "") {
45
+ const e = g(n);
46
+ return e && t === e ? "~" : e && e !== "/" && t.startsWith(`${e}/`) ? `~${t.slice(e.length)}` : t;
47
+ }
48
+ function j(t, n) {
49
+ if (n === "/") return t;
50
+ for (const e of t)
51
+ if (e.type === "folder") {
52
+ if (g(e.path) === n) return e.children ?? [];
53
+ if (e.children)
54
+ try {
55
+ return j(e.children, n);
56
+ } catch {
57
+ }
58
+ }
59
+ throw new S("missingPath");
60
+ }
61
+ function V(t, n) {
62
+ const [e, u] = l(null), [o, H] = l(""), [B, N] = l([]), [v, C] = l(""), [$, c] = l(!1), [k, f] = l(null), [I, q] = l(!1), [h, R] = l(!1);
63
+ let p = 0, b = 0, A, w = /* @__PURE__ */ new Map();
64
+ const G = () => h() && !$() && !k() && !!o() && g(v(), e()?.homePathAbs) === o(), L = () => {
65
+ p += 1, b += 1, w = /* @__PURE__ */ new Map();
66
+ }, W = () => {
67
+ L(), d(() => {
68
+ R(!1), c(!1);
69
+ });
70
+ };
71
+ z(W);
72
+ const x = async (i) => {
73
+ if (!h() || !e()) return !1;
74
+ const D = p, a = ++b, r = g(i, e()?.homePathAbs);
75
+ d(() => {
76
+ C(i), f(null), c(!0);
77
+ });
78
+ const y = () => h() && p === D && b === a;
79
+ try {
80
+ if (!r) throw new S("invalidPath");
81
+ const s = t(), m = { showHidden: I() }, F = `${r}\0${m.showHidden}`;
82
+ let P = w.get(F);
83
+ P || (P = Promise.resolve().then(() => s.loadDirectory ? s.loadDirectory(r, m) : j(s.files ?? [], r)), w.set(F, P));
84
+ let E;
85
+ try {
86
+ E = await P;
87
+ } finally {
88
+ w.get(F) === P && w.delete(F);
89
+ }
90
+ if (!y()) return !1;
91
+ const O = s.loadDirectory || m.showHidden ? E : E.filter((T) => !T.name.startsWith("."));
92
+ return d(() => {
93
+ H(r), N(O), C(r), c(!1), f(null);
94
+ }), n?.(r), !0;
95
+ } catch (s) {
96
+ return y() && d(() => {
97
+ f(s), c(!1);
98
+ }), !1;
99
+ }
100
+ }, M = async (i) => {
101
+ L();
102
+ const D = p;
103
+ A = i;
104
+ const a = t();
105
+ d(() => {
106
+ R(!0), u(null), H(""), N([]), C(i ?? ""), c(!0), f(null), q(a.initialShowHidden ?? !a.loadDirectory);
107
+ });
108
+ try {
109
+ const r = a.loadPathContext ? await a.loadPathContext() : a.pathContext;
110
+ if (!h() || p !== D) return;
111
+ if (!r && a.loadDirectory) throw new S("unavailableContext");
112
+ const y = r ?? {
113
+ homePathAbs: a.homePath ?? "",
114
+ defaultRootId: "root",
115
+ roots: [{ id: "root", label: a.homeLabel ?? J.root, pathAbs: "/" }]
116
+ };
117
+ u(y);
118
+ const s = i || y.roots.find((m) => m.id === y.defaultRootId)?.pathAbs;
119
+ if (!s) throw new S("unavailableContext");
120
+ await x(s);
121
+ } catch (r) {
122
+ h() && p === D && d(() => {
123
+ f(r), c(!1);
124
+ });
125
+ }
126
+ };
127
+ return {
128
+ context: e,
129
+ currentPath: o,
130
+ entries: B,
131
+ pathInput: v,
132
+ pending: $,
133
+ error: k,
134
+ showHidden: I,
135
+ active: h,
136
+ valid: G,
137
+ open: M,
138
+ close: W,
139
+ navigate: x,
140
+ setPathInput(i) {
141
+ b += 1, d(() => {
142
+ C(i), c(!1), f(null);
143
+ });
144
+ },
145
+ async setShowHidden(i) {
146
+ q(i), await x(v() || o());
147
+ },
148
+ async retry() {
149
+ e() ? await x(v() || o()) : await M(A);
150
+ }
151
+ };
152
+ }
153
+ export {
154
+ S as PickerNavigationError,
155
+ V as createFilesystemPickerDataSource,
156
+ J as defaultPickerCopy,
157
+ U as formatPickerPath,
158
+ g as parsePickerPath,
159
+ Q as pickerParentPath
160
+ };
@@ -130,8 +130,8 @@ function Qe(i) {
130
130
  widgetRoot: w ?? null,
131
131
  interactiveSelector: h().interactiveSelector,
132
132
  panSurfaceSelector: h().panSurfaceSelector
133
- }), ae = () => {
134
- F(), w?.focus({
133
+ }), ae = (t) => {
134
+ F(), t?.focus !== !1 && w?.focus({
135
135
  preventScroll: !0
136
136
  });
137
137
  }, _t = (t) => {
@@ -103,7 +103,10 @@ export interface WorkbenchWidgetBodyProps<TWidgetType extends string = Workbench
103
103
  motion?: WorkbenchWidgetMotionIntent | null;
104
104
  selected?: boolean;
105
105
  filtered?: boolean;
106
- requestActivate?: () => void;
106
+ /** Select and raise the widget. Set focus to false for local or embedded input observations. */
107
+ requestActivate?: (options?: {
108
+ focus?: boolean;
109
+ }) => void;
107
110
  }
108
111
  export interface WorkbenchWidgetDefinition<TWidgetType extends string = WorkbenchWidgetType> {
109
112
  type: TWidgetType;