@floegence/floe-webapp-core 0.86.65 → 0.86.68

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