@floegence/floe-webapp-core 0.86.49 → 0.86.51

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.
@@ -18,6 +18,13 @@ export type PickerDirectoryLoader = (path: string, options: {
18
18
  showHidden: boolean;
19
19
  }) => Promise<readonly FileItem[]>;
20
20
  export interface PickerCopy {
21
+ favorites: string;
22
+ favoriteDirectory: string;
23
+ unfavoriteDirectory: string;
24
+ favoritesEmpty: string;
25
+ favoritesFilter: string;
26
+ favoritesNoMatches: string;
27
+ favoritesLoadFailed: string;
21
28
  path: string;
22
29
  go: string;
23
30
  roots: string;
@@ -1,5 +1,12 @@
1
1
  import { createSignal as l, onCleanup as z, batch as d } from "solid-js";
2
2
  const J = {
3
+ favorites: "Favorites",
4
+ favoriteDirectory: "Add directory to favorites",
5
+ unfavoriteDirectory: "Remove directory from favorites",
6
+ favoritesEmpty: "Star a directory to keep it here.",
7
+ favoritesFilter: "Filter favorites by name or path",
8
+ favoritesNoMatches: "No matching favorites",
9
+ favoritesLoadFailed: "Could not load favorites",
3
10
  path: "Directory path",
4
11
  go: "Go",
5
12
  roots: "Locations",
@@ -24,138 +31,138 @@ const J = {
24
31
  selectionLimit: "Selection limit reached",
25
32
  selectedCount: (t) => `${t} selected`
26
33
  };
27
- class S extends Error {
28
- constructor(n) {
29
- super(n), this.kind = n;
34
+ class N extends Error {
35
+ constructor(r) {
36
+ super(r), this.kind = r;
30
37
  }
31
38
  kind;
32
39
  }
33
- function g(t, n = "") {
40
+ function P(t, r = "") {
34
41
  let e = String(t ?? "").trim();
35
- if (e === "~" ? e = n : e.startsWith("~/") && (e = n ? `${n}/${e.slice(2)}` : ""), !e.startsWith("/") || e.includes("\0")) return "";
36
- const u = [];
37
- for (const o of e.split("/"))
38
- !o || o === "." || (o === ".." ? u.pop() : u.push(o));
39
- return `/${u.join("/")}`;
42
+ if (e === "~" ? e = r : e.startsWith("~/") && (e = r ? `${r}/${e.slice(2)}` : ""), !e.startsWith("/") || e.includes("\0")) return "";
43
+ const f = [];
44
+ for (const i of e.split("/"))
45
+ !i || i === "." || (i === ".." ? f.pop() : f.push(i));
46
+ return `/${f.join("/")}`;
40
47
  }
41
48
  function Q(t) {
42
- const n = g(t);
43
- return n.slice(0, n.lastIndexOf("/")) || "/";
49
+ const r = P(t);
50
+ return r.slice(0, r.lastIndexOf("/")) || "/";
44
51
  }
45
- function U(t, n = "") {
46
- const e = g(n);
52
+ function U(t, r = "") {
53
+ const e = P(r);
47
54
  return e && t === e ? "~" : e && e !== "/" && t.startsWith(`${e}/`) ? `~${t.slice(e.length)}` : t;
48
55
  }
49
- function j(t, n) {
50
- if (n === "/") return t;
56
+ function j(t, r) {
57
+ if (r === "/") return t;
51
58
  for (const e of t)
52
59
  if (e.type === "folder") {
53
- if (g(e.path) === n) return e.children ?? [];
60
+ if (P(e.path) === r) return e.children ?? [];
54
61
  if (e.children)
55
62
  try {
56
- return j(e.children, n);
63
+ return j(e.children, r);
57
64
  } catch {
58
65
  }
59
66
  }
60
- throw new S("missingPath");
67
+ throw new N("missingPath");
61
68
  }
62
- function V(t, n) {
63
- const [e, u] = l(null), [o, E] = l(""), [B, H] = l([]), [v, C] = l(""), [N, c] = l(!1), [$, f] = l(null), [I, q] = l(!1), [h, R] = l(!1);
64
- let p = 0, b = 0, A, w = /* @__PURE__ */ new Map();
65
- const G = () => h() && !N() && !$() && !!o() && g(v(), e()?.homePathAbs) === o(), L = () => {
66
- p += 1, b += 1, w = /* @__PURE__ */ new Map();
69
+ function V(t, r) {
70
+ const [e, f] = l(null), [i, k] = l(""), [B, E] = l([]), [g, C] = l(""), [H, c] = l(!1), [$, u] = l(null), [I, q] = l(!1), [h, R] = l(!1);
71
+ let y = 0, b = 0, A, m = /* @__PURE__ */ new Map();
72
+ const G = () => h() && !H() && !$() && !!i() && P(g(), e()?.homePathAbs) === i(), L = () => {
73
+ y += 1, b += 1, m = /* @__PURE__ */ new Map();
67
74
  }, W = () => {
68
75
  L(), d(() => {
69
76
  R(!1), c(!1);
70
77
  });
71
78
  };
72
79
  z(W);
73
- const x = async (i) => {
80
+ const F = async (n) => {
74
81
  if (!h() || !e()) return !1;
75
- const D = p, a = ++b, r = g(i, e()?.homePathAbs);
82
+ const x = y, a = ++b, o = P(n, e()?.homePathAbs);
76
83
  d(() => {
77
- C(i), f(null), c(!0);
84
+ C(n), u(null), c(!0);
78
85
  });
79
- const y = () => h() && p === D && b === a;
86
+ const p = () => h() && y === x && b === a;
80
87
  try {
81
- if (!r) throw new S("invalidPath");
82
- const s = t(), m = { showHidden: I() }, F = `${r}\0${m.showHidden}`;
83
- let P = w.get(F);
84
- P || (P = Promise.resolve().then(() => s.loadDirectory ? s.loadDirectory(r, m) : j(s.files ?? [], r)), w.set(F, P));
85
- let k;
88
+ if (!o) throw new N("invalidPath");
89
+ const s = t(), v = { showHidden: I() }, D = `${o}\0${v.showHidden}`;
90
+ let w = m.get(D);
91
+ w || (w = Promise.resolve().then(() => s.loadDirectory ? s.loadDirectory(o, v) : j(s.files ?? [], o)), m.set(D, w));
92
+ let S;
86
93
  try {
87
- k = await P;
94
+ S = await w;
88
95
  } finally {
89
- w.get(F) === P && w.delete(F);
96
+ m.get(D) === w && m.delete(D);
90
97
  }
91
- if (!y()) return !1;
92
- const O = s.loadDirectory || m.showHidden ? k : k.filter((T) => !T.name.startsWith("."));
98
+ if (!p()) return !1;
99
+ const O = s.loadDirectory || v.showHidden ? S : S.filter((T) => !T.name.startsWith("."));
93
100
  return d(() => {
94
- E(r), H(O), C(r), c(!1), f(null);
95
- }), n?.(r), !0;
101
+ k(o), E(O), C(o), c(!1), u(null);
102
+ }), r?.(o), !0;
96
103
  } catch (s) {
97
- return y() && d(() => {
98
- f(s), c(!1);
104
+ return p() && d(() => {
105
+ u(s), c(!1);
99
106
  }), !1;
100
107
  }
101
- }, M = async (i) => {
108
+ }, M = async (n) => {
102
109
  L();
103
- const D = p;
104
- A = i;
110
+ const x = y;
111
+ A = n;
105
112
  const a = t();
106
113
  d(() => {
107
- R(!0), u(null), E(""), H([]), C(i ?? ""), c(!0), f(null), q(a.initialShowHidden ?? !a.loadDirectory);
114
+ R(!0), f(null), k(""), E([]), C(n ?? ""), c(!0), u(null), q(a.initialShowHidden ?? !a.loadDirectory);
108
115
  });
109
116
  try {
110
- const r = a.loadPathContext ? await a.loadPathContext() : a.pathContext;
111
- if (!h() || p !== D) return;
112
- if (!r && a.loadDirectory) throw new S("unavailableContext");
113
- const y = r ?? {
117
+ const o = a.loadPathContext ? await a.loadPathContext() : a.pathContext;
118
+ if (!h() || y !== x) return;
119
+ if (!o && a.loadDirectory) throw new N("unavailableContext");
120
+ const p = o ?? {
114
121
  homePathAbs: a.homePath ?? "",
115
122
  defaultRootId: "root",
116
123
  roots: [{ id: "root", label: a.homeLabel ?? J.root, pathAbs: "/" }]
117
124
  };
118
- u(y);
119
- const s = i || y.roots.find((m) => m.id === y.defaultRootId)?.pathAbs;
120
- if (!s) throw new S("unavailableContext");
121
- await x(s);
122
- } catch (r) {
123
- h() && p === D && d(() => {
124
- f(r), c(!1);
125
+ f(p);
126
+ const s = n || p.roots.find((v) => v.id === p.defaultRootId)?.pathAbs;
127
+ if (!s) throw new N("unavailableContext");
128
+ await F(s);
129
+ } catch (o) {
130
+ h() && y === x && d(() => {
131
+ u(o), c(!1);
125
132
  });
126
133
  }
127
134
  };
128
135
  return {
129
136
  context: e,
130
- currentPath: o,
137
+ currentPath: i,
131
138
  entries: B,
132
- pathInput: v,
133
- pending: N,
139
+ pathInput: g,
140
+ pending: H,
134
141
  error: $,
135
142
  showHidden: I,
136
143
  active: h,
137
144
  valid: G,
138
145
  open: M,
139
146
  close: W,
140
- navigate: x,
141
- setPathInput(i) {
147
+ navigate: F,
148
+ setPathInput(n) {
142
149
  b += 1, d(() => {
143
- C(i), c(!1), f(null);
150
+ C(n), c(!1), u(null);
144
151
  });
145
152
  },
146
- async setShowHidden(i) {
147
- q(i), await x(v() || o());
153
+ async setShowHidden(n) {
154
+ q(n), await F(g() || i());
148
155
  },
149
156
  async retry() {
150
- e() ? await x(v() || o()) : await M(A);
157
+ e() ? await F(g() || i()) : await M(A);
151
158
  }
152
159
  };
153
160
  }
154
161
  export {
155
- S as PickerNavigationError,
162
+ N as PickerNavigationError,
156
163
  V as createFilesystemPickerDataSource,
157
164
  J as defaultPickerCopy,
158
165
  U as formatPickerPath,
159
- g as parsePickerPath,
166
+ P as parsePickerPath,
160
167
  Q as pickerParentPath
161
168
  };