vintage-frames 0.16.1 → 0.16.2
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.
- package/dist/shell/catalog.d.ts +5 -1
- package/dist/shell/catalog.js +90 -86
- package/dist/shell/finder.js +252 -252
- package/dist/shell/index.d.ts +2 -2
- package/dist/shell/index.js +7 -7
- package/dist/shell/pure.js +4 -4
- package/dist/shell/shell.d.ts +0 -4
- package/dist/shell/shell.js +40 -44
- package/editor/web-types.json +1 -1
- package/package.json +1 -1
package/dist/shell/finder.js
CHANGED
|
@@ -2,31 +2,31 @@ import { snapSys as e, systemPxQuantum as t } from "../scale.js";
|
|
|
2
2
|
import { prefersReducedMotion as n } from "../motion.js";
|
|
3
3
|
import { windowChrome as r } from "../window-chrome.js";
|
|
4
4
|
import "../index.js";
|
|
5
|
-
import { FOLDER as i, TRASH as a,
|
|
5
|
+
import { FOLDER as i, TRASH as a, appIdOf as o, childrenOf as s, enclosingFolders as c, isContainerKind as l, isInside as u, isTrashed as d, isVolume as f, itemCount as p } from "./catalog.js";
|
|
6
6
|
import { cleanUp as ee, collisions as te, desktopLattice as ne, fieldExtent as re, fillOrder as ie, folderLattice as ae, frameOf as oe, nextFreeCell as se, pinOf as ce, pinTo as le, trashCell as ue } from "./geometry.js";
|
|
7
7
|
import { desktopRendered as de } from "./windows.js";
|
|
8
|
-
import {
|
|
9
|
-
import { fileByDrag as
|
|
10
|
-
import { composeAlert as
|
|
8
|
+
import { defineApp as m } from "./shell.js";
|
|
9
|
+
import { fileByDrag as fe } from "./filing.js";
|
|
10
|
+
import { composeAlert as pe } from "./alert.js";
|
|
11
11
|
//#region src/shell/finder.ts
|
|
12
|
-
var
|
|
12
|
+
var h = "finder", me = 306, he = 300, ge = {
|
|
13
13
|
"new-folder": "New Folder",
|
|
14
14
|
"empty-trash": "Empty Trash",
|
|
15
15
|
paste: "Paste",
|
|
16
16
|
"add-file": "Adding the file"
|
|
17
|
-
},
|
|
17
|
+
}, _e = 20, ve = 18, g = {
|
|
18
18
|
left: 8,
|
|
19
19
|
top: 2
|
|
20
|
-
},
|
|
20
|
+
}, _ = {
|
|
21
21
|
width: 12,
|
|
22
22
|
height: 12
|
|
23
|
-
},
|
|
24
|
-
left:
|
|
25
|
-
top:
|
|
26
|
-
},
|
|
27
|
-
left:
|
|
28
|
-
top:
|
|
29
|
-
},
|
|
23
|
+
}, v = {
|
|
24
|
+
left: g.left - 1,
|
|
25
|
+
top: g.top
|
|
26
|
+
}, ye = {
|
|
27
|
+
left: v.left + _.width + 3,
|
|
28
|
+
top: g.top
|
|
29
|
+
}, y = [
|
|
30
30
|
{
|
|
31
31
|
menu: "file",
|
|
32
32
|
label: "File",
|
|
@@ -80,23 +80,23 @@ var m = "finder", he = 306, ge = 300, _e = {
|
|
|
80
80
|
items: [["clean-up", "Clean Up Desktop"], ["empty-trash", "Empty Trash…"]]
|
|
81
81
|
}
|
|
82
82
|
];
|
|
83
|
-
function
|
|
84
|
-
return
|
|
83
|
+
function b(e) {
|
|
84
|
+
return y.map(({ menu: t, label: n, items: r }) => {
|
|
85
85
|
let i = r.filter(([t]) => e(t)).map(([e, t, n], r) => `${e === "close" && r > 0 ? "<vf-separator></vf-separator>" : ""}<vf-menu-item value="${e}"${n ? ` shortcut="${n}"` : ""}>${t}</vf-menu-item>`);
|
|
86
86
|
return i.length ? `<vf-menu data-menu="${t}" label="${n}">${i.join("")}</vf-menu>` : "";
|
|
87
87
|
}).join("");
|
|
88
88
|
}
|
|
89
|
-
var
|
|
90
|
-
function
|
|
89
|
+
var be = (e) => e.localName === "vf-icon" && e.dataset.app != null || e instanceof HTMLTemplateElement && e.dataset.folder != null;
|
|
90
|
+
function xe(e) {
|
|
91
91
|
let t = (e, t) => e != null && t != null && Number.isFinite(+e) && Number.isFinite(+t) ? {
|
|
92
92
|
left: +e,
|
|
93
93
|
top: +t
|
|
94
94
|
} : void 0, n = [];
|
|
95
|
-
for (let r of [...e.children].filter(
|
|
95
|
+
for (let r of [...e.children].filter(be)) r instanceof HTMLTemplateElement ? n.push({
|
|
96
96
|
kind: i,
|
|
97
97
|
name: r.dataset.folder ?? null,
|
|
98
98
|
at: t(r.dataset.left, r.dataset.top),
|
|
99
|
-
children:
|
|
99
|
+
children: xe(r.content)
|
|
100
100
|
}) : n.push({
|
|
101
101
|
kind: "app",
|
|
102
102
|
name: r.getAttribute("label"),
|
|
@@ -106,13 +106,13 @@ function Se(e) {
|
|
|
106
106
|
});
|
|
107
107
|
return n;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
let
|
|
109
|
+
function x(i) {
|
|
110
|
+
let x = i.volumes?.trash !== !1, S = (e) => i.commands?.[e] !== !1 && (e !== "empty-trash" || x), Se = [], Ce = (e) => e, C = i.seed === "markup" ? async (e) => {
|
|
111
111
|
let t = Date.now(), n = async (r, i) => {
|
|
112
112
|
for (let a of r) {
|
|
113
113
|
let r = await e.create({
|
|
114
114
|
kind: a.kind,
|
|
115
|
-
name: a.name ?? (a.app == null ? void 0 :
|
|
115
|
+
name: a.name ?? (a.app == null ? void 0 : Ce(a.app)),
|
|
116
116
|
parent: i,
|
|
117
117
|
...a.at,
|
|
118
118
|
...a.app == null ? {} : { data: { app: a.app } },
|
|
@@ -121,90 +121,90 @@ function b(i) {
|
|
|
121
121
|
r && a.children.length && await n(a.children, r.id);
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
await n(
|
|
124
|
+
await n(Se, null);
|
|
125
125
|
} : i.seed;
|
|
126
|
-
return
|
|
127
|
-
id:
|
|
126
|
+
return m({
|
|
127
|
+
id: h,
|
|
128
128
|
name: "Finder",
|
|
129
|
-
menus:
|
|
129
|
+
menus: b(S),
|
|
130
130
|
dialogs: i.dialogs,
|
|
131
131
|
catalog: {
|
|
132
132
|
storage: i.storage,
|
|
133
133
|
volumes: i.volumes,
|
|
134
|
-
seed:
|
|
134
|
+
seed: C
|
|
135
135
|
},
|
|
136
|
-
init(
|
|
137
|
-
let { desktop:
|
|
138
|
-
|
|
139
|
-
let
|
|
136
|
+
init(m) {
|
|
137
|
+
let { desktop: b, windows: C } = m, w = m.catalog, T = i.art;
|
|
138
|
+
Ce = (e) => m.app(e)?.name ?? e;
|
|
139
|
+
let E = i.lattice?.desktop?.cell ?? 64, we = i.lattice?.folder?.cell ?? 64, Te = i.window ?? {
|
|
140
140
|
width: 320,
|
|
141
141
|
height: 223
|
|
142
|
-
},
|
|
142
|
+
}, D = r({
|
|
143
143
|
scrollbars: "both",
|
|
144
|
-
headerHeight:
|
|
145
|
-
}),
|
|
146
|
-
async function
|
|
147
|
-
let i =
|
|
144
|
+
headerHeight: _e
|
|
145
|
+
}), Ee = /* @__PURE__ */ new Map();
|
|
146
|
+
async function O(e, t, n, r = {}) {
|
|
147
|
+
let i = Ee.get(e);
|
|
148
148
|
if (i) return i(t);
|
|
149
|
-
let a =
|
|
150
|
-
art:
|
|
149
|
+
let a = pe(n, {
|
|
150
|
+
art: T.caution ?? null,
|
|
151
151
|
...r
|
|
152
152
|
});
|
|
153
|
-
|
|
153
|
+
m.hold(a.dialog);
|
|
154
154
|
try {
|
|
155
155
|
await a.rendered();
|
|
156
|
-
let e =
|
|
156
|
+
let e = m.ask(a.dialog);
|
|
157
157
|
return a.fit(), await e;
|
|
158
158
|
} finally {
|
|
159
|
-
|
|
159
|
+
m.release(a.dialog);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
let
|
|
162
|
+
let k = (e) => (t) => {
|
|
163
163
|
let n = t;
|
|
164
|
-
|
|
164
|
+
O("failed", {
|
|
165
165
|
action: e,
|
|
166
166
|
error: n
|
|
167
|
-
}, `${
|
|
168
|
-
},
|
|
169
|
-
if (!
|
|
170
|
-
|
|
171
|
-
let e =
|
|
172
|
-
e ? e.after(
|
|
167
|
+
}, `${ge[e]} failed: ${n.message}.`);
|
|
168
|
+
}, A = b.querySelector(":scope > vf-icon-field"), De = !A;
|
|
169
|
+
if (!A) {
|
|
170
|
+
A = document.createElement("vf-icon-field"), A.label = "Desktop", A.toggleAttribute("fill-width", !0), A.toggleAttribute("fill-height", !0);
|
|
171
|
+
let e = b.querySelector(":scope > vf-menu-bar");
|
|
172
|
+
e ? e.after(A) : b.prepend(A);
|
|
173
173
|
}
|
|
174
|
-
let
|
|
175
|
-
|
|
176
|
-
for (let e of
|
|
177
|
-
let
|
|
178
|
-
let n =
|
|
174
|
+
let j = A, Oe = [...j.children].filter(be);
|
|
175
|
+
Se = xe(j);
|
|
176
|
+
for (let e of Oe) e.remove();
|
|
177
|
+
let ke = () => C.windowsOf(h).map((e) => [C.itemOf(e), e]).filter((e) => e[0] != null), M = (e) => e.querySelector(":scope > vf-icon-field"), N = () => [[null, j], ...ke().flatMap(([e, t]) => {
|
|
178
|
+
let n = M(t);
|
|
179
179
|
return n ? [[e, n]] : [];
|
|
180
|
-
})],
|
|
180
|
+
})], Ae = (e) => N().find(([t]) => t === e)?.[1] ?? null, P = (e) => [...e.querySelectorAll(":scope > vf-icon[data-id]")], F = () => N().flatMap(([, e]) => P(e)), I = (e) => e.dataset.id, L = (e) => F().find((t) => I(t) === e) ?? null, R = (e) => ({
|
|
181
181
|
left: e.left ?? 0,
|
|
182
182
|
top: e.top ?? 0
|
|
183
|
-
}),
|
|
184
|
-
width: Math.max(0, (e.width ?? 0) -
|
|
185
|
-
height: Math.max(0, (e.height ?? 0) -
|
|
186
|
-
}),
|
|
187
|
-
if (e == null) return ne(
|
|
188
|
-
let t =
|
|
189
|
-
return ae(t ?
|
|
190
|
-
},
|
|
191
|
-
let t =
|
|
183
|
+
}), je = (e) => C.itemOf(e.closest("vf-window")), Me = (e) => ({
|
|
184
|
+
width: Math.max(0, (e.width ?? 0) - D.left - D.right),
|
|
185
|
+
height: Math.max(0, (e.height ?? 0) - D.top - D.bottom)
|
|
186
|
+
}), Ne = (e) => {
|
|
187
|
+
if (e == null) return ne(b.workArea, i.lattice?.desktop);
|
|
188
|
+
let t = C.windowFor(e);
|
|
189
|
+
return ae(t ? Me(t).width : 0, i.lattice?.folder);
|
|
190
|
+
}, Pe = (e) => {
|
|
191
|
+
let t = C.windowFor(e), n = t && M(t);
|
|
192
192
|
if (!t || !n) return;
|
|
193
|
-
let r = re(
|
|
193
|
+
let r = re(P(n).map(R), Me(t), { cell: we });
|
|
194
194
|
n.width !== r.width && (n.width = r.width), n.height !== r.height && (n.height = r.height);
|
|
195
|
-
},
|
|
195
|
+
}, Fe = (n, r, i) => {
|
|
196
196
|
if (r == null) {
|
|
197
|
-
let r =
|
|
197
|
+
let r = b.workArea, a = t(n), o = (e) => Math.floor(e / a) * a, s = Math.ceil(r.top / a) * a, c = Math.max(r.left, o(r.left + r.width - E)), l = Math.max(s, o(r.top + r.height - E));
|
|
198
198
|
n.left = Math.min(Math.max(e(i.left, n), r.left), c), n.top = Math.min(Math.max(e(i.top, n), s), l);
|
|
199
199
|
} else n.left = e(Math.max(0, i.left), n), n.top = e(Math.max(0, i.top), n);
|
|
200
|
-
},
|
|
201
|
-
if (e.kind === "folder") return
|
|
202
|
-
if (e.kind === "trash") return
|
|
203
|
-
if (e.kind === "disk") return
|
|
204
|
-
let t =
|
|
205
|
-
return (typeof t?.art == "function" ? t.art(e) : t?.art) ||
|
|
200
|
+
}, Ie = (e) => {
|
|
201
|
+
if (e.kind === "folder") return T.folder;
|
|
202
|
+
if (e.kind === "trash") return p(w.get(), "trash") ? T.trashFull : T.trash;
|
|
203
|
+
if (e.kind === "disk") return T.disk ?? T.folder;
|
|
204
|
+
let t = m.kind(e.kind);
|
|
205
|
+
return (typeof t?.art == "function" ? t.art(e) : t?.art) || T.document;
|
|
206
206
|
};
|
|
207
|
-
function
|
|
207
|
+
function Le(e, t) {
|
|
208
208
|
let n = e.querySelector(":scope > vf-img > img");
|
|
209
209
|
if (!n) {
|
|
210
210
|
let t = document.createElement("vf-img");
|
|
@@ -212,225 +212,225 @@ function b(i) {
|
|
|
212
212
|
}
|
|
213
213
|
n.getAttribute("src") !== t && (n.src = t);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function Re(e) {
|
|
216
216
|
let t = document.createElement("vf-icon");
|
|
217
|
-
return t.dataset.id = e.id, t.label = e.name, t.width =
|
|
217
|
+
return t.dataset.id = e.id, t.label = e.name, t.width = E, t.selectable = !0, t.movable = !0, l(e.kind) && (t.dataset.folder = e.id), t;
|
|
218
218
|
}
|
|
219
|
-
let
|
|
220
|
-
function
|
|
219
|
+
let z = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new WeakMap();
|
|
220
|
+
function ze(e, t, n, r) {
|
|
221
221
|
if (t.left != null && t.top != null) {
|
|
222
222
|
let r = `${t.left},${t.top}`;
|
|
223
|
-
if (
|
|
224
|
-
|
|
223
|
+
if (B.get(e) === r) return;
|
|
224
|
+
B.set(e, r), (e.left !== t.left || e.top !== t.top) && Fe(e, n, {
|
|
225
225
|
left: t.left,
|
|
226
226
|
top: t.top
|
|
227
227
|
});
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
let a =
|
|
231
|
-
|
|
230
|
+
let a = P(r).filter((t) => t !== e && t.left != null && t.top != null).map(R), o = n == null && t.id === "trash" ? ue(b.workArea, i.lattice?.desktop) : se(Ne(n), a, n == null ? E : we);
|
|
231
|
+
Fe(e, n, o), z.add(e);
|
|
232
232
|
}
|
|
233
|
-
let
|
|
234
|
-
function
|
|
235
|
-
if (!(
|
|
236
|
-
|
|
233
|
+
let Be = !1, V = !1;
|
|
234
|
+
function H() {
|
|
235
|
+
if (!(V || !Be)) {
|
|
236
|
+
V = !0;
|
|
237
237
|
try {
|
|
238
|
-
let e =
|
|
239
|
-
for (let [a,
|
|
240
|
-
let e = t.get(
|
|
241
|
-
e.parentElement !==
|
|
242
|
-
let
|
|
243
|
-
e.open !==
|
|
244
|
-
let
|
|
245
|
-
|
|
238
|
+
let e = w.get(), t = new Map(F().map((e) => [I(e), e])), n = /* @__PURE__ */ new Set(), r = [], i = [];
|
|
239
|
+
for (let [a, c] of N()) for (let l of s(e, a)) {
|
|
240
|
+
let e = t.get(l.id) ?? Re(l);
|
|
241
|
+
e.parentElement !== c && (c.append(e), e.left = void 0, e.top = void 0, B.delete(e)), n.add(e), e.label !== l.name && (e.label = l.name), e.editable = !f(l.id) && m.kind(l.kind)?.editable !== !1, Le(e, Ie(l));
|
|
242
|
+
let s = l.kind === "app" ? C.hasWindows(o(l) ?? "") : C.isOpen(l.id);
|
|
243
|
+
e.open !== s && (e.open = s);
|
|
244
|
+
let u = () => ze(e, l, a, c);
|
|
245
|
+
l.left != null && l.top != null ? r.push(u) : i.push(u);
|
|
246
246
|
}
|
|
247
247
|
for (let e of t.values()) n.has(e) || e.remove();
|
|
248
248
|
for (let e of [...r, ...i]) e();
|
|
249
|
-
for (let [e, t] of
|
|
250
|
-
let n =
|
|
251
|
-
n && r != null && n.label !== r && (n.label = r),
|
|
249
|
+
for (let [e, t] of ke()) {
|
|
250
|
+
let n = M(t), r = w.item(e)?.name;
|
|
251
|
+
n && r != null && n.label !== r && (n.label = r), Ue(e), Pe(e);
|
|
252
252
|
}
|
|
253
253
|
} finally {
|
|
254
|
-
|
|
254
|
+
V = !1;
|
|
255
255
|
}
|
|
256
|
-
|
|
256
|
+
Ve();
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
let
|
|
260
|
-
function
|
|
261
|
-
if (
|
|
259
|
+
let U = !1;
|
|
260
|
+
function Ve() {
|
|
261
|
+
if (U = !1, !z.size) return;
|
|
262
262
|
let e = /* @__PURE__ */ new Map();
|
|
263
|
-
for (let t of
|
|
264
|
-
|
|
263
|
+
for (let t of z) t.isConnected && t.left != null && t.top != null && e.set(I(t), R(t));
|
|
264
|
+
z.clear(), w.place(e);
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
m.on(b, "vf-placement-change", (e) => {
|
|
267
267
|
let t = e.target;
|
|
268
|
-
t.localName === "vf-icon" && t.dataset.id != null && (
|
|
269
|
-
}),
|
|
270
|
-
function
|
|
268
|
+
t.localName === "vf-icon" && t.dataset.id != null && (z.add(t), !U && (U = !0, queueMicrotask(Ve)));
|
|
269
|
+
}), m.onDispose(w.subscribe(H)), m.onDispose(C.onWindows(H));
|
|
270
|
+
function He() {
|
|
271
271
|
let e = document.createElement("vf-img");
|
|
272
|
-
e.dataset.trashMark = "", e.width =
|
|
272
|
+
e.dataset.trashMark = "", e.width = _.width, e.height = _.height, e.left = v.left, e.top = v.top;
|
|
273
273
|
let t = document.createElement("img");
|
|
274
|
-
return t.alt = "in the Trash", t.src =
|
|
274
|
+
return t.alt = "in the Trash", t.src = T.trashMark, e.append(t), e;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
let t =
|
|
276
|
+
function Ue(e) {
|
|
277
|
+
let t = C.windowFor(e)?.querySelector(":scope > [slot=\"header\"]"), n = t?.querySelector(":scope > vf-label[data-count]");
|
|
278
278
|
if (!t || !n) return;
|
|
279
|
-
let r =
|
|
279
|
+
let r = w.get(), i = p(r, e), a = `${i} item${i === 1 ? "" : "s"}`;
|
|
280
280
|
n.textContent !== a && (n.textContent = a);
|
|
281
|
-
let o = !!
|
|
282
|
-
o && !s ? t.prepend(
|
|
283
|
-
let c = o ?
|
|
281
|
+
let o = !!T.trashMark && d(r, e), s = t.querySelector(":scope > vf-img[data-trash-mark]");
|
|
282
|
+
o && !s ? t.prepend(He()) : !o && s && s.remove();
|
|
283
|
+
let c = o ? ye : g;
|
|
284
284
|
n.left !== c.left && (n.left = c.left);
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
let t =
|
|
288
|
-
n.heading = t, n.closable = !0, n.movable = !0, n.outlineDrag = !0, n.resizable = !0, n.scrollbars = "both", n.headerHeight =
|
|
286
|
+
function We(e) {
|
|
287
|
+
let t = w.item(e)?.name ?? "", n = document.createElement("vf-window");
|
|
288
|
+
n.heading = t, n.closable = !0, n.movable = !0, n.outlineDrag = !0, n.resizable = !0, n.scrollbars = "both", n.headerHeight = _e, n.width = Te.width, n.height = Te.height;
|
|
289
289
|
let r = document.createElement("vf-container");
|
|
290
|
-
r.slot = "header", r.toggleAttribute("fill-width", !0), r.height =
|
|
290
|
+
r.slot = "header", r.toggleAttribute("fill-width", !0), r.height = ve, r.rule = "bottom";
|
|
291
291
|
let i = document.createElement("vf-label");
|
|
292
|
-
i.face = "body", i.dataset.count = "", i.left =
|
|
292
|
+
i.face = "body", i.dataset.count = "", i.left = g.left, i.top = g.top, r.append(i);
|
|
293
293
|
let a = document.createElement("vf-icon-field");
|
|
294
294
|
return a.label = t, a.left = 0, a.top = 0, n.append(r, a), n;
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
if (!e.detail?.commit ||
|
|
298
|
-
let t =
|
|
299
|
-
t != null &&
|
|
296
|
+
m.on(b, "vf-resize", (e) => {
|
|
297
|
+
if (!e.detail?.commit || C.appOf(e.target) !== "finder") return;
|
|
298
|
+
let t = C.itemOf(e.target);
|
|
299
|
+
t != null && Pe(t);
|
|
300
300
|
});
|
|
301
|
-
function
|
|
302
|
-
let n =
|
|
303
|
-
n && (
|
|
304
|
-
app:
|
|
301
|
+
function W(e, t) {
|
|
302
|
+
let n = w.item(e);
|
|
303
|
+
n && (l(n.kind) ? C.open({
|
|
304
|
+
app: h,
|
|
305
305
|
item: e,
|
|
306
306
|
from: t,
|
|
307
|
-
create: () =>
|
|
308
|
-
}) :
|
|
307
|
+
create: () => We(e)
|
|
308
|
+
}) : m.kind(n.kind)?.open(n, t));
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
m.on(b, "vf-open", (e) => {
|
|
311
311
|
let t = e.target;
|
|
312
|
-
t.localName === "vf-icon" && t.dataset.id != null && (t.selected &&
|
|
312
|
+
t.localName === "vf-icon" && t.dataset.id != null && (t.selected && J().length > 1 ? Ye() : W(I(t), t.cellRect()));
|
|
313
313
|
});
|
|
314
|
-
let
|
|
315
|
-
let t =
|
|
316
|
-
return t.find((e) =>
|
|
317
|
-
},
|
|
318
|
-
|
|
319
|
-
let n =
|
|
314
|
+
let Ge = (e) => {
|
|
315
|
+
let t = w.get().items.filter((t) => t.kind === "app" && o(t) === e);
|
|
316
|
+
return t.find((e) => L(e.id)) ?? t[0] ?? null;
|
|
317
|
+
}, Ke = (e, t) => w.item(e) ?? (t == null ? null : Ge(t));
|
|
318
|
+
m.onDispose(C.setHome((e, t) => {
|
|
319
|
+
let n = Ke(e, t);
|
|
320
320
|
if (!n) return null;
|
|
321
|
-
let r =
|
|
321
|
+
let r = L(n.id)?.cellRect();
|
|
322
322
|
if (r) return r;
|
|
323
|
-
for (let e of
|
|
324
|
-
let t =
|
|
323
|
+
for (let e of c(w.get(), n.parent)) {
|
|
324
|
+
let t = L(e)?.cellRect();
|
|
325
325
|
if (t) return t;
|
|
326
326
|
}
|
|
327
327
|
return null;
|
|
328
328
|
}, (e, t) => {
|
|
329
|
-
let n = e == null && t == null ? null :
|
|
329
|
+
let n = e == null && t == null ? null : Ke(e, t), r = P(j), i = n ? L(n.id) : r.find((e) => e.selected) ?? r[0] ?? null;
|
|
330
330
|
return i?.checkVisibility() ? (i.focus({ preventScroll: !0 }), !0) : !1;
|
|
331
|
-
})),
|
|
332
|
-
let
|
|
331
|
+
})), m.on(j, "pointerdown", () => b.clearActive());
|
|
332
|
+
let G = (e) => {
|
|
333
333
|
let t = e.target;
|
|
334
334
|
return t.localName === "vf-icon" && t.dataset.id != null;
|
|
335
335
|
};
|
|
336
|
-
|
|
337
|
-
if (!
|
|
336
|
+
m.on(b, "vf-change", (e) => {
|
|
337
|
+
if (!G(e)) return;
|
|
338
338
|
let t = e.target, { label: n, previous: r } = e.detail;
|
|
339
|
-
|
|
339
|
+
w.rename(I(t), n).catch(() => {
|
|
340
340
|
t.label = r;
|
|
341
341
|
});
|
|
342
342
|
});
|
|
343
|
-
let
|
|
344
|
-
|
|
345
|
-
if (!
|
|
346
|
-
|
|
343
|
+
let K = !1;
|
|
344
|
+
m.on(b, "vf-name-too-long", (e) => {
|
|
345
|
+
if (!G(e) || K) return;
|
|
346
|
+
K = !0;
|
|
347
347
|
let { limit: t } = e.detail;
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
O("name-too-long", { limit: t }, `That name is too long. A name can have up to ${t} characters.`).finally(() => {
|
|
349
|
+
K = !1;
|
|
350
350
|
});
|
|
351
|
-
}),
|
|
352
|
-
|
|
353
|
-
}),
|
|
354
|
-
folderOfWindow: (e) =>
|
|
351
|
+
}), m.on(b, "vf-name-rejected", (e) => {
|
|
352
|
+
G(e) && O("name-rejected", {}, "An item needs a name.");
|
|
353
|
+
}), m.onDispose(fe(b, {
|
|
354
|
+
folderOfWindow: (e) => C.appOf(e) === "finder" ? C.itemOf(e) ?? void 0 : void 0,
|
|
355
355
|
folderOfIcon: (e) => e.dataset.folder,
|
|
356
|
-
containerOf: (e) => e.dataset.id == null ? void 0 :
|
|
356
|
+
containerOf: (e) => e.dataset.id == null ? void 0 : je(e),
|
|
357
357
|
canFile: (e, t) => {
|
|
358
|
-
let n =
|
|
358
|
+
let n = w.get();
|
|
359
359
|
return e.every((e) => {
|
|
360
360
|
let r = e.dataset.id;
|
|
361
|
-
return r == null ||
|
|
361
|
+
return r == null || f(r) ? !1 : t == null || e.dataset.folder == null || r !== t && !u(n, t, r);
|
|
362
362
|
});
|
|
363
363
|
},
|
|
364
364
|
file: (e, t, n) => {
|
|
365
|
-
let r = new Map([...n].map(([e, t]) => [
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
let r = new Map([...n].map(([e, t]) => [I(e), t]));
|
|
366
|
+
w.move(e.map(I), t, r).catch((e) => {
|
|
367
|
+
O("move-failed", { error: e }, `The items couldn’t be moved: ${e.message}.`);
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
370
|
}));
|
|
371
|
-
let
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
let qe = /* @__PURE__ */ new WeakMap(), q = 0;
|
|
372
|
+
m.onDispose(C.onRaster((t, n) => {
|
|
373
|
+
j.dragIcons([]);
|
|
374
374
|
let r = {
|
|
375
|
-
width:
|
|
376
|
-
height:
|
|
377
|
-
}, a = oe(
|
|
378
|
-
for (let i of
|
|
375
|
+
width: E,
|
|
376
|
+
height: E
|
|
377
|
+
}, a = oe(b.workArea.top);
|
|
378
|
+
for (let i of P(j)) {
|
|
379
379
|
let o = {
|
|
380
|
-
...
|
|
380
|
+
...R(i),
|
|
381
381
|
...r
|
|
382
|
-
}, s =
|
|
383
|
-
i.left = e(l.left, i), i.top = e(l.top, i),
|
|
382
|
+
}, s = qe.get(i), c = !s || s.left !== o.left || s.top !== o.top ? ce(o, t, a) : s.pin, l = le(c, n, a, { size: r });
|
|
383
|
+
i.left = e(l.left, i), i.top = e(l.top, i), qe.set(i, {
|
|
384
384
|
pin: c,
|
|
385
385
|
left: i.left,
|
|
386
386
|
top: i.top
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
|
-
i.cleanUpAfterResize && (window.clearTimeout(
|
|
390
|
-
|
|
391
|
-
...
|
|
389
|
+
i.cleanUpAfterResize && (window.clearTimeout(q), q = window.setTimeout(() => {
|
|
390
|
+
q = 0, te(P(j).map((e) => ({
|
|
391
|
+
...R(e),
|
|
392
392
|
...r
|
|
393
|
-
}))).size &&
|
|
394
|
-
},
|
|
395
|
-
})),
|
|
396
|
-
let
|
|
397
|
-
let e = new Set(
|
|
398
|
-
return
|
|
399
|
-
},
|
|
393
|
+
}))).size && Je(null);
|
|
394
|
+
}, he));
|
|
395
|
+
})), m.onDispose(() => window.clearTimeout(q));
|
|
396
|
+
let J = () => {
|
|
397
|
+
let e = new Set(F().filter((e) => e.selected).map(I));
|
|
398
|
+
return w.get().items.filter((t) => e.has(t.id));
|
|
399
|
+
}, Y = (e) => {
|
|
400
400
|
let t = new Set(e);
|
|
401
|
-
for (let e of
|
|
402
|
-
},
|
|
403
|
-
let e =
|
|
404
|
-
return e &&
|
|
401
|
+
for (let e of F()) e.setSelected(t.has(I(e)));
|
|
402
|
+
}, X = () => {
|
|
403
|
+
let e = b.activeWindow;
|
|
404
|
+
return e && C.appOf(e) === "finder" ? C.itemOf(e) : null;
|
|
405
405
|
};
|
|
406
|
-
async function
|
|
407
|
-
let t =
|
|
406
|
+
async function Je(e) {
|
|
407
|
+
let t = Ae(e);
|
|
408
408
|
if (!t) return;
|
|
409
|
-
let n =
|
|
409
|
+
let n = Ne(e), r = P(t), i = ee(n, r.map(R)), a = r.map((e, t) => ({
|
|
410
410
|
icon: e,
|
|
411
411
|
...i[t]
|
|
412
412
|
})).sort((e, t) => ie(n, e, t));
|
|
413
413
|
await t.dragIcons(a);
|
|
414
414
|
}
|
|
415
415
|
async function Ye() {
|
|
416
|
-
let e = n() ? 0 :
|
|
417
|
-
for (let [t, n] of
|
|
416
|
+
let e = n() ? 0 : me;
|
|
417
|
+
for (let [t, n] of J().entries()) t && e && await new Promise((t) => setTimeout(t, e)), W(n.id, L(n.id)?.cellRect() ?? null);
|
|
418
418
|
}
|
|
419
419
|
async function Xe(e) {
|
|
420
|
-
let t =
|
|
421
|
-
t && (
|
|
420
|
+
let t = L(e);
|
|
421
|
+
t && (Y([e]), await t.updateComplete, t.startEditing());
|
|
422
422
|
}
|
|
423
|
-
let Z = () =>
|
|
423
|
+
let Z = () => w.get().available ? !0 : (O("storage-unavailable", {}, "Files can’t be saved in this browser session. A private window, perhaps.", { label: "Storage Unavailable" }), !1);
|
|
424
424
|
async function Ze() {
|
|
425
425
|
if (!Z()) return;
|
|
426
|
-
let e = await
|
|
426
|
+
let e = await w.create({ parent: X() }).catch(k("new-folder"));
|
|
427
427
|
e && await Xe(e.id);
|
|
428
428
|
}
|
|
429
429
|
async function Qe() {
|
|
430
|
-
let e =
|
|
431
|
-
if (!
|
|
432
|
-
let t =
|
|
433
|
-
await
|
|
430
|
+
let e = p(w.get(), a);
|
|
431
|
+
if (!x || !e) return;
|
|
432
|
+
let t = w.trashSize(), n = Math.ceil(t / 1024), r = e === 1 ? `The Trash contains 1 item, which uses ${n}K of disk space. Are you sure you want to permanently remove it?` : `The Trash contains ${e} items, which use ${n}K of disk space. Are you sure you want to permanently remove these items?`;
|
|
433
|
+
await O("empty-trash", {
|
|
434
434
|
count: e,
|
|
435
435
|
bytes: t
|
|
436
436
|
}, r, {
|
|
@@ -443,23 +443,23 @@ function b(i) {
|
|
|
443
443
|
value: "ok",
|
|
444
444
|
default: !0
|
|
445
445
|
}]
|
|
446
|
-
}) === "ok" && await
|
|
446
|
+
}) === "ok" && await w.emptyTrash().catch(k("empty-trash"));
|
|
447
447
|
}
|
|
448
448
|
let Q = {
|
|
449
449
|
ids: [],
|
|
450
450
|
text: ""
|
|
451
451
|
}, $e = (e) => e.replace(/\r\n?/g, "\n").trimEnd();
|
|
452
452
|
async function et() {
|
|
453
|
-
let e =
|
|
453
|
+
let e = J().filter((e) => !f(e.id));
|
|
454
454
|
if (!e.length) return;
|
|
455
455
|
let t = e.map((e) => e.name).join("\n");
|
|
456
456
|
Q = {
|
|
457
457
|
ids: e.map((e) => e.id),
|
|
458
458
|
text: t
|
|
459
459
|
};
|
|
460
|
-
let n = e.find((e) =>
|
|
460
|
+
let n = e.find((e) => m.kind(e.kind)?.export);
|
|
461
461
|
try {
|
|
462
|
-
let e = n ? await
|
|
462
|
+
let e = n ? await m.kind(n.kind).export(n) : null;
|
|
463
463
|
if (e?.type && e.type !== "text/plain" && typeof ClipboardItem < "u") {
|
|
464
464
|
await navigator.clipboard.write([new ClipboardItem({
|
|
465
465
|
"text/plain": new Blob([t], { type: "text/plain" }),
|
|
@@ -473,10 +473,10 @@ function b(i) {
|
|
|
473
473
|
} catch {}
|
|
474
474
|
}
|
|
475
475
|
async function tt(e, t) {
|
|
476
|
-
for (let n of
|
|
476
|
+
for (let n of m.kinds.values()) if (n.claim && await n.claim(e, t)) return !0;
|
|
477
477
|
return !1;
|
|
478
478
|
}
|
|
479
|
-
let nt = () => [...
|
|
479
|
+
let nt = () => [...m.kinds.values()].some((e) => e.claim);
|
|
480
480
|
async function rt() {
|
|
481
481
|
try {
|
|
482
482
|
if (navigator.clipboard?.read) {
|
|
@@ -499,20 +499,20 @@ function b(i) {
|
|
|
499
499
|
}
|
|
500
500
|
async function it(e) {
|
|
501
501
|
if (!Z()) return;
|
|
502
|
-
let t =
|
|
503
|
-
if (
|
|
502
|
+
let t = X();
|
|
503
|
+
if (d(w.get(), t)) return;
|
|
504
504
|
let n = e === void 0 ? await rt() : e, r = Q.ids.length > 0 && (n == null || n.text != null && $e(n.text) === $e(Q.text));
|
|
505
505
|
try {
|
|
506
506
|
if (r) {
|
|
507
|
-
let e = await
|
|
508
|
-
e.length &&
|
|
507
|
+
let e = await w.copy(Q.ids, t);
|
|
508
|
+
e.length && Y(e.map((e) => e.id));
|
|
509
509
|
} else for (let e of n?.files ?? []) await tt(e, t);
|
|
510
510
|
} catch (e) {
|
|
511
|
-
|
|
511
|
+
k("paste")(e);
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
-
|
|
515
|
-
if (!
|
|
514
|
+
m.on(document, "paste", (e) => {
|
|
515
|
+
if (!S("paste") || C.front !== "finder" || m.modalOpen() || m.typing()) return;
|
|
516
516
|
let t = e.clipboardData;
|
|
517
517
|
t && (e.preventDefault(), it({
|
|
518
518
|
text: t.getData("text/plain") || null,
|
|
@@ -520,85 +520,85 @@ function b(i) {
|
|
|
520
520
|
}));
|
|
521
521
|
});
|
|
522
522
|
let at = (e) => [...e.dataTransfer?.types ?? []].includes("Files");
|
|
523
|
-
|
|
523
|
+
m.on(b, "dragover", (e) => {
|
|
524
524
|
at(e) && nt() && e.preventDefault();
|
|
525
|
-
}),
|
|
525
|
+
}), m.on(b, "drop", (e) => {
|
|
526
526
|
if (!at(e) || !nt()) return;
|
|
527
527
|
e.preventDefault();
|
|
528
528
|
let t = e, n = [...t.dataTransfer?.files ?? []], r = document.elementsFromPoint(t.clientX, t.clientY).find((e) => e.localName === "vf-window");
|
|
529
|
-
if (r &&
|
|
530
|
-
let i = r ?
|
|
531
|
-
|
|
529
|
+
if (r && C.appOf(r) !== "finder" || (r ? b.bringToFront(r) : b.clearActive(), !Z())) return;
|
|
530
|
+
let i = r ? C.itemOf(r) : null;
|
|
531
|
+
d(w.get(), i) || (async () => {
|
|
532
532
|
for (let e of n) await tt(e, i);
|
|
533
|
-
})().catch(
|
|
533
|
+
})().catch(k("add-file"));
|
|
534
534
|
});
|
|
535
535
|
let ot = {
|
|
536
536
|
open: () => void Ye(),
|
|
537
537
|
"new-folder": () => void Ze(),
|
|
538
538
|
close: () => {
|
|
539
|
-
let e =
|
|
540
|
-
t &&
|
|
539
|
+
let e = X(), t = e == null ? null : C.windowFor(e);
|
|
540
|
+
t && C.requestClose(t);
|
|
541
541
|
},
|
|
542
542
|
copy: () => void et(),
|
|
543
543
|
paste: () => void it(),
|
|
544
544
|
"select-all": () => {
|
|
545
|
-
let e =
|
|
546
|
-
e &&
|
|
545
|
+
let e = Ae(X());
|
|
546
|
+
e && Y(P(e).map(I));
|
|
547
547
|
},
|
|
548
|
-
arrange: () =>
|
|
549
|
-
"clean-up": () => void X(
|
|
548
|
+
arrange: () => C.arrange(),
|
|
549
|
+
"clean-up": () => void Je(X()),
|
|
550
550
|
"empty-trash": () => void Qe()
|
|
551
551
|
}, $ = (e, t) => {
|
|
552
|
-
|
|
552
|
+
S(e) && m.gate(m.item(e), t);
|
|
553
553
|
};
|
|
554
|
-
if ($("open", () => !
|
|
555
|
-
let e =
|
|
556
|
-
|
|
557
|
-
let t =
|
|
554
|
+
if ($("open", () => !m.typing() && J().length > 0), $("new-folder", () => !d(w.get(), X())), $("close", () => X() != null), $("copy", () => !m.typing() && J().some((e) => !f(e.id))), $("paste", () => !m.typing() && !d(w.get(), X())), $("select-all", () => !m.typing()), $("arrange", () => !C.arranged()), $("empty-trash", () => p(w.get(), a) > 0), S("clean-up")) {
|
|
555
|
+
let e = m.item("clean-up");
|
|
556
|
+
m.gate(e, () => {
|
|
557
|
+
let t = X() == null ? "Clean Up Desktop" : "Clean Up Window";
|
|
558
558
|
return e.textContent !== t && (e.textContent = t), !0;
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
561
|
let st = !0, ct = (e) => {
|
|
562
|
-
let t =
|
|
562
|
+
let t = m.menus.find((t) => t.dataset.menu === e);
|
|
563
563
|
if (t) return t;
|
|
564
564
|
if (!st) throw Error(`vintage-frames/shell (finder): no ${e} menu; add to it from extend`);
|
|
565
565
|
let n = document.createElement("vf-menu");
|
|
566
|
-
n.dataset.menu = e, n.label =
|
|
567
|
-
let r =
|
|
568
|
-
return
|
|
566
|
+
n.dataset.menu = e, n.label = y.find((t) => t.menu === e).label;
|
|
567
|
+
let r = y.map((e) => e.menu), i = m.menus.findIndex((t) => r.indexOf(t.dataset.menu) > r.indexOf(e));
|
|
568
|
+
return m.menus.splice(i < 0 ? m.menus.length : i, 0, n), n;
|
|
569
569
|
}, lt = {
|
|
570
|
-
catalog:
|
|
571
|
-
selection:
|
|
572
|
-
select:
|
|
573
|
-
activeFolder:
|
|
570
|
+
catalog: w,
|
|
571
|
+
selection: J,
|
|
572
|
+
select: Y,
|
|
573
|
+
activeFolder: X,
|
|
574
574
|
open: ({ item: e, from: t = null } = {}) => {
|
|
575
|
-
e != null &&
|
|
575
|
+
e != null && W(e, t);
|
|
576
576
|
},
|
|
577
577
|
rename: Xe,
|
|
578
|
-
cleanUp:
|
|
579
|
-
iconFor:
|
|
578
|
+
cleanUp: Je,
|
|
579
|
+
iconFor: L,
|
|
580
580
|
addCommand(e) {
|
|
581
581
|
let t = ct(e.menu);
|
|
582
582
|
e.separator && t.append(document.createElement("vf-separator"));
|
|
583
583
|
let n = document.createElement("vf-menu-item");
|
|
584
|
-
return n.setAttribute("value", e.value), e.shortcut && n.setAttribute("shortcut", e.shortcut), n.textContent = e.label, t.append(n), ot[e.value] = e.run, e.enabled &&
|
|
584
|
+
return n.setAttribute("value", e.value), e.shortcut && n.setAttribute("shortcut", e.shortcut), n.textContent = e.label, t.append(n), ot[e.value] = e.run, e.enabled && m.gate(n, e.enabled), n;
|
|
585
585
|
},
|
|
586
586
|
alertWith(e, t) {
|
|
587
|
-
|
|
587
|
+
Ee.set(e, t);
|
|
588
588
|
},
|
|
589
589
|
storageReady: Z
|
|
590
590
|
};
|
|
591
|
-
i.extend?.(lt,
|
|
591
|
+
i.extend?.(lt, m), st = !1, m.onMenu((e) => ot[e]?.());
|
|
592
592
|
let ut = !1;
|
|
593
|
-
return
|
|
593
|
+
return m.onDispose(() => {
|
|
594
594
|
ut = !0;
|
|
595
|
-
for (let e of
|
|
596
|
-
|
|
597
|
-
}), de(
|
|
598
|
-
ut || (
|
|
595
|
+
for (let e of P(j)) e.remove();
|
|
596
|
+
De ? j.remove() : j.append(...Oe);
|
|
597
|
+
}), de(b).then(() => {
|
|
598
|
+
ut || (Be = !0, H());
|
|
599
599
|
}), lt;
|
|
600
600
|
}
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
603
|
//#endregion
|
|
604
|
-
export {
|
|
604
|
+
export { h as FINDER, x as finder };
|