vintage-frames 0.18.0 → 0.19.1
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/README.md +1 -1
- package/custom-elements.json +278 -51
- package/dist/build/app-file.d.ts +2 -2
- package/dist/build/app-file.js +1 -0
- package/dist/build/plugins.d.ts +2 -2
- package/dist/build/plugins.js +62 -59
- package/dist/components/vf-icon.d.ts +7 -0
- package/dist/components/vf-icon.js +101 -81
- package/dist/components/vf-menu-bar.d.ts +6 -4
- package/dist/components/vf-menu-bar.js +26 -56
- package/dist/components/vf-menu-item.d.ts +33 -5
- package/dist/components/vf-menu-item.js +128 -61
- package/dist/components/vf-menu.d.ts +35 -0
- package/dist/components/vf-menu.js +171 -111
- package/dist/glyphs.d.ts +6 -0
- package/dist/glyphs.js +18 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -14
- package/dist/menu-navigation.d.ts +34 -0
- package/dist/menu-navigation.js +53 -0
- package/dist/menu-press.d.ts +25 -7
- package/dist/menu-press.js +78 -44
- package/dist/motion.d.ts +10 -0
- package/dist/shell/app-file.d.ts +20 -4
- package/dist/shell/app-file.js +65 -53
- package/dist/shell/catalog.d.ts +79 -1
- package/dist/shell/catalog.js +206 -153
- package/dist/shell/finder.d.ts +28 -9
- package/dist/shell/finder.js +339 -267
- package/dist/shell/geometry.d.ts +7 -0
- package/dist/shell/geometry.js +19 -3
- package/dist/shell/index.d.ts +4 -4
- package/dist/shell/index.js +12 -12
- package/dist/shell/pure.d.ts +1 -1
- package/dist/shell/pure.js +6 -6
- package/dist/shell/shell.d.ts +14 -10
- package/dist/shell/shell.js +148 -116
- package/dist/shell/version.d.ts +1 -1
- package/dist/shell/version.js +1 -1
- package/dist/styles/body-italic-font.d.ts +2 -0
- package/dist/styles/body-italic-font.js +10 -0
- package/dist/styles/register-embedded-font.d.ts +5 -4
- package/dist/styles/register-embedded-font.js +11 -10
- package/docs/SPEC.md +11 -7
- package/editor/vscode.html-custom-data.json +15 -5
- package/editor/web-types.json +55 -9
- package/package.json +7 -3
package/dist/shell/catalog.js
CHANGED
|
@@ -1,289 +1,342 @@
|
|
|
1
1
|
//#region src/shell/catalog.ts
|
|
2
|
-
var e = "trash", t = "disk", n = "folder", r = "
|
|
3
|
-
function
|
|
2
|
+
var e = "trash", t = "disk", n = "system-folder", r = "apple-menu-items", i = "startup-items", a = "folder", o = "app", s = "alias", c = "untitled folder", l = "#seeded", u = (e) => e === "folder" || e === "trash" || e === "disk", d = (e) => e === "trash" || e === "disk", f = (e) => d(e) || e === "system-folder" || e === "apple-menu-items" || e === "startup-items";
|
|
3
|
+
function p(e) {
|
|
4
4
|
let t = e.data;
|
|
5
5
|
return typeof t?.app == "string" ? t.app : null;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function m(e) {
|
|
8
|
+
if (e.kind !== "alias") return null;
|
|
9
|
+
let t = e.data;
|
|
10
|
+
return typeof t?.original == "string" ? t.original : null;
|
|
11
|
+
}
|
|
12
|
+
function h(e) {
|
|
13
|
+
if (e.kind !== "alias") return null;
|
|
14
|
+
let t = e.data;
|
|
15
|
+
return typeof t?.kind == "string" ? t.kind : null;
|
|
16
|
+
}
|
|
17
|
+
function g(e, t) {
|
|
8
18
|
return t == null ? null : e.items.find((e) => e.id === t) ?? null;
|
|
9
19
|
}
|
|
10
|
-
function
|
|
11
|
-
let n =
|
|
12
|
-
|
|
20
|
+
function _(e, t) {
|
|
21
|
+
let n = /* @__PURE__ */ new Set(), r = g(e, t);
|
|
22
|
+
for (; r?.kind === s;) {
|
|
23
|
+
if (n.has(r.id)) return null;
|
|
24
|
+
n.add(r.id), r = g(e, m(r));
|
|
25
|
+
}
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
function v(e, t) {
|
|
29
|
+
let n = g(e, t);
|
|
30
|
+
return n && u(n.kind) ? n.id : null;
|
|
13
31
|
}
|
|
14
|
-
function
|
|
15
|
-
let n =
|
|
16
|
-
return e.items.filter((t) => t.id !== n &&
|
|
32
|
+
function y(e, t) {
|
|
33
|
+
let n = v(e, t);
|
|
34
|
+
return e.items.filter((t) => t.id !== n && v(e, t.parent) === n);
|
|
17
35
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
36
|
+
function b(e, t) {
|
|
37
|
+
return y(e, t).length;
|
|
20
38
|
}
|
|
21
|
-
var
|
|
22
|
-
function
|
|
23
|
-
let r = /* @__PURE__ */ new Set(), i =
|
|
39
|
+
var x = (e, t) => v(e, g(e, t)?.parent ?? null);
|
|
40
|
+
function S(e, t, n) {
|
|
41
|
+
let r = /* @__PURE__ */ new Set(), i = x(e, t);
|
|
24
42
|
for (; i != null && !r.has(i);) {
|
|
25
43
|
if (i === n) return !0;
|
|
26
|
-
r.add(i), i =
|
|
44
|
+
r.add(i), i = x(e, i);
|
|
27
45
|
}
|
|
28
46
|
return !1;
|
|
29
47
|
}
|
|
30
|
-
function
|
|
31
|
-
let n = [], r = /* @__PURE__ */ new Set(), i =
|
|
32
|
-
for (; i != null && !r.has(i);) n.push(i), r.add(i), i =
|
|
48
|
+
function C(e, t) {
|
|
49
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = v(e, t ?? null);
|
|
50
|
+
for (; i != null && !r.has(i);) n.push(i), r.add(i), i = x(e, i);
|
|
33
51
|
return n;
|
|
34
52
|
}
|
|
35
|
-
function
|
|
36
|
-
return t == null ? !1 : t === "trash" ||
|
|
53
|
+
function w(e, t) {
|
|
54
|
+
return t == null ? !1 : t === "trash" || S(e, t, "trash");
|
|
37
55
|
}
|
|
38
|
-
function
|
|
56
|
+
function T(e, t) {
|
|
57
|
+
let n = g(e, t);
|
|
58
|
+
if (!n || w(e, n.id)) return !1;
|
|
59
|
+
let r = _(e, n.id);
|
|
60
|
+
return r != null && r.id !== "trash";
|
|
61
|
+
}
|
|
62
|
+
function E(e, t) {
|
|
63
|
+
let n = g(e, t);
|
|
64
|
+
if (!n) return null;
|
|
65
|
+
let r = _(e, n.id);
|
|
66
|
+
if (r) return u(r.kind) ? { folder: r.id } : null;
|
|
67
|
+
let i = h(n);
|
|
68
|
+
return i != null && u(i) ? { missing: n } : null;
|
|
69
|
+
}
|
|
70
|
+
function D(e, t) {
|
|
39
71
|
let n = [], r = /* @__PURE__ */ new Set(), i = (t) => {
|
|
40
|
-
for (let a of
|
|
72
|
+
for (let a of y(e, t)) r.has(a.id) || (r.add(a.id), n.push(a), u(a.kind) && i(a.id));
|
|
41
73
|
};
|
|
42
|
-
return i(
|
|
74
|
+
return i(v(e, t)), n;
|
|
43
75
|
}
|
|
44
|
-
function
|
|
45
|
-
let
|
|
46
|
-
if (!
|
|
76
|
+
function O(e, t) {
|
|
77
|
+
let n = new Set(y(e, t).filter((e) => e.kind === a).map((e) => e.name));
|
|
78
|
+
if (!n.has("untitled folder")) return c;
|
|
47
79
|
for (let e = 2;; e++) {
|
|
48
|
-
let t = `${
|
|
49
|
-
if (!
|
|
80
|
+
let t = `${c} ${e}`;
|
|
81
|
+
if (!n.has(t)) return t;
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
|
-
var
|
|
53
|
-
function
|
|
54
|
-
let i = new Set(
|
|
84
|
+
var k = (e) => e.replace(/ copy( \d+)?$/, "");
|
|
85
|
+
function A(e, t, n, r) {
|
|
86
|
+
let i = new Set(y(e, t).filter((e) => e.kind === r).map((e) => e.name));
|
|
55
87
|
if (!i.has(n)) return n;
|
|
56
|
-
let a =
|
|
88
|
+
let a = k(n);
|
|
57
89
|
if (!i.has(`${a} copy`)) return `${a} copy`;
|
|
58
90
|
for (let e = 2;; e++) {
|
|
59
91
|
let t = `${a} copy ${e}`;
|
|
60
92
|
if (!i.has(t)) return t;
|
|
61
93
|
}
|
|
62
94
|
}
|
|
63
|
-
|
|
64
|
-
|
|
95
|
+
function j(e, t, n) {
|
|
96
|
+
let r = new Set(y(e, t).filter((e) => e.kind === s).map((e) => e.name)), i = `${n} alias`;
|
|
97
|
+
if (!r.has(i)) return i;
|
|
98
|
+
for (let e = 2;; e++) {
|
|
99
|
+
let t = `${i} ${e}`;
|
|
100
|
+
if (!r.has(t)) return t;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
var M = new Intl.Collator("en"), N = (e, t) => y(e, t).sort((e, t) => M.compare(e.name, t.name) || z(e, t));
|
|
104
|
+
function P(e, t) {
|
|
105
|
+
return g(e, t) ? N(e, t) : [];
|
|
106
|
+
}
|
|
107
|
+
var F = (e) => P(e, r), I = (e) => P(e, i), L = 5;
|
|
108
|
+
function R(e) {
|
|
109
|
+
let t = (n, r, i) => N(e, n).map((n) => {
|
|
110
|
+
let a = _(e, n.id);
|
|
111
|
+
if (!a || !u(a.kind) || r.has(a.id) || i >= L) return { item: n };
|
|
112
|
+
let o = t(a.id, /* @__PURE__ */ new Set([...r, a.id]), i + 1);
|
|
113
|
+
return o.length ? {
|
|
114
|
+
item: n,
|
|
115
|
+
entries: o
|
|
116
|
+
} : { item: n };
|
|
117
|
+
});
|
|
118
|
+
return g(e, "apple-menu-items") ? t(r, /* @__PURE__ */ new Set([r]), 0) : [];
|
|
119
|
+
}
|
|
120
|
+
var z = (e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : 1);
|
|
121
|
+
function B(e, t) {
|
|
65
122
|
let n = { ...e };
|
|
66
123
|
return t ? (n.left = t.left, n.top = t.top) : (delete n.left, delete n.top), n;
|
|
67
124
|
}
|
|
68
|
-
function
|
|
69
|
-
let { storage:
|
|
70
|
-
i.disk && y.push({
|
|
71
|
-
id: t,
|
|
72
|
-
name: i.disk,
|
|
73
|
-
kind: t,
|
|
74
|
-
parent: null,
|
|
75
|
-
createdAt: 0,
|
|
76
|
-
modifiedAt: 0
|
|
77
|
-
}), i.trash !== !1 && y.push({
|
|
125
|
+
function V(o) {
|
|
126
|
+
let { storage: s, volumes: c = {}, system: d, listed: p = () => !0, hooks: h = () => void 0, placeDelay: _ = 400 } = o, y = () => (o.now ?? Date.now)(), b = () => o.newId ? o.newId() : crypto.randomUUID(), x = [], C = (e, t, n, r) => x.push({
|
|
78
127
|
id: e,
|
|
79
|
-
name:
|
|
80
|
-
kind:
|
|
81
|
-
parent:
|
|
128
|
+
name: t,
|
|
129
|
+
kind: n,
|
|
130
|
+
parent: r,
|
|
82
131
|
createdAt: 0,
|
|
83
132
|
modifiedAt: 0
|
|
84
133
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
134
|
+
c.disk && C(t, c.disk, t, null), c.trash !== !1 && C(e, c.trash ?? "Trash", e, null), d && (C(n, d.folder, a, c.disk ? t : null), C(r, d.appleMenu, a, n), C(i, d.startup, a, n));
|
|
135
|
+
let T = /* @__PURE__ */ new Map(), E = !1, k = !1, j = N(), M = /* @__PURE__ */ new Set();
|
|
136
|
+
function N() {
|
|
137
|
+
let e = x.map((e) => {
|
|
138
|
+
let t = T.get(e.id);
|
|
89
139
|
return t?.left != null && t.top != null ? {
|
|
90
140
|
...e,
|
|
91
141
|
left: t.left,
|
|
92
142
|
top: t.top
|
|
93
143
|
} : e;
|
|
94
|
-
}), t = [...
|
|
144
|
+
}), t = [...T.values()].filter((e) => !f(e.id) && (e.kind === "folder" || p(e.kind))).sort(z);
|
|
95
145
|
return {
|
|
96
|
-
available:
|
|
146
|
+
available: E,
|
|
97
147
|
items: [...e, ...t]
|
|
98
148
|
};
|
|
99
149
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
for (let e of [...
|
|
150
|
+
function P() {
|
|
151
|
+
j = N();
|
|
152
|
+
for (let e of [...M]) e(j);
|
|
103
153
|
}
|
|
104
|
-
let
|
|
105
|
-
if (!
|
|
106
|
-
return
|
|
154
|
+
let F = () => {
|
|
155
|
+
if (!s) throw Error("storage is unavailable");
|
|
156
|
+
return s;
|
|
107
157
|
};
|
|
108
|
-
async function
|
|
109
|
-
await
|
|
158
|
+
async function I(e) {
|
|
159
|
+
await F().put(e), T.set(e.id, e);
|
|
110
160
|
}
|
|
111
|
-
let
|
|
112
|
-
async function
|
|
113
|
-
|
|
114
|
-
let e = [...
|
|
115
|
-
if (
|
|
116
|
-
let e =
|
|
117
|
-
e && await
|
|
161
|
+
let L = /* @__PURE__ */ new Set(), R = null;
|
|
162
|
+
async function V() {
|
|
163
|
+
R && clearTimeout(R), R = null;
|
|
164
|
+
let e = [...L];
|
|
165
|
+
if (L.clear(), !(!s || !E)) for (let t of e) {
|
|
166
|
+
let e = T.get(t);
|
|
167
|
+
e && await s.put(e).catch(() => {});
|
|
118
168
|
}
|
|
119
169
|
}
|
|
120
|
-
let
|
|
121
|
-
let t =
|
|
122
|
-
return
|
|
170
|
+
let H = (e) => {
|
|
171
|
+
let t = x.find((t) => t.id === e);
|
|
172
|
+
return T.get(e) ?? {
|
|
123
173
|
...t,
|
|
124
174
|
name: ""
|
|
125
175
|
};
|
|
126
176
|
};
|
|
127
|
-
async function
|
|
128
|
-
|
|
129
|
-
for (let e of await
|
|
130
|
-
|
|
177
|
+
async function U() {
|
|
178
|
+
L.clear();
|
|
179
|
+
for (let e of await F().list()) e.id !== l && (await F().remove(e.id), T.delete(e.id));
|
|
180
|
+
T = /* @__PURE__ */ new Map();
|
|
131
181
|
}
|
|
132
|
-
let
|
|
133
|
-
get: () =>
|
|
182
|
+
let W = {
|
|
183
|
+
get: () => j,
|
|
134
184
|
subscribe(e) {
|
|
135
|
-
return
|
|
136
|
-
|
|
185
|
+
return M.add(e), () => {
|
|
186
|
+
M.delete(e);
|
|
137
187
|
};
|
|
138
188
|
},
|
|
139
|
-
item: (e) =>
|
|
189
|
+
item: (e) => g(j, e),
|
|
140
190
|
async refresh() {
|
|
141
|
-
if (!
|
|
142
|
-
|
|
191
|
+
if (!s) {
|
|
192
|
+
T = /* @__PURE__ */ new Map(), E = !1, P();
|
|
143
193
|
return;
|
|
144
194
|
}
|
|
145
195
|
try {
|
|
146
|
-
let e = await
|
|
147
|
-
|
|
148
|
-
for (let t of e) t.id ===
|
|
149
|
-
|
|
196
|
+
let e = await s.list();
|
|
197
|
+
T = /* @__PURE__ */ new Map(), k = !1;
|
|
198
|
+
for (let t of e) t.id === l ? k = !0 : T.set(t.id, t);
|
|
199
|
+
E = !0;
|
|
150
200
|
} catch (e) {
|
|
151
|
-
console.warn("vintage-frames/shell: the catalog could not be read —", e),
|
|
201
|
+
console.warn("vintage-frames/shell: the catalog could not be read —", e), T = /* @__PURE__ */ new Map(), E = !1;
|
|
152
202
|
}
|
|
153
|
-
|
|
203
|
+
P();
|
|
154
204
|
},
|
|
155
205
|
async seed(e) {
|
|
156
|
-
return !
|
|
157
|
-
id:
|
|
206
|
+
return !s || !E || k ? !1 : (await e(W), await s.put({
|
|
207
|
+
id: l,
|
|
158
208
|
name: "",
|
|
159
|
-
kind:
|
|
209
|
+
kind: l,
|
|
160
210
|
parent: null,
|
|
161
|
-
createdAt:
|
|
162
|
-
modifiedAt:
|
|
163
|
-
}),
|
|
211
|
+
createdAt: y(),
|
|
212
|
+
modifiedAt: y()
|
|
213
|
+
}), k = !0, !0);
|
|
164
214
|
},
|
|
165
215
|
async create(e = {}) {
|
|
166
|
-
let t =
|
|
167
|
-
if (
|
|
168
|
-
let n = e.kind ?? "folder", r = e.at ??
|
|
169
|
-
id:
|
|
170
|
-
name: e.name ?? (n === "folder" ?
|
|
216
|
+
let t = v(j, e.parent ?? null);
|
|
217
|
+
if (w(j, t)) return null;
|
|
218
|
+
let n = e.kind ?? "folder", r = e.at ?? y(), i = {
|
|
219
|
+
id: b(),
|
|
220
|
+
name: e.name ?? (n === "folder" ? O(j, t) : "untitled"),
|
|
171
221
|
kind: n,
|
|
172
222
|
parent: t,
|
|
173
223
|
createdAt: r,
|
|
174
224
|
modifiedAt: r
|
|
175
225
|
};
|
|
176
|
-
return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i =
|
|
226
|
+
return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i = B(i, {
|
|
177
227
|
left: e.left,
|
|
178
228
|
top: e.top
|
|
179
|
-
})), await
|
|
229
|
+
})), await I(i), P(), i;
|
|
180
230
|
},
|
|
181
231
|
async rename(e, t) {
|
|
182
|
-
let n =
|
|
183
|
-
return !n ||
|
|
232
|
+
let n = T.get(e);
|
|
233
|
+
return !n || f(e) || n.name === t ? !1 : (await I({
|
|
184
234
|
...n,
|
|
185
235
|
name: t,
|
|
186
|
-
modifiedAt:
|
|
187
|
-
}),
|
|
236
|
+
modifiedAt: y()
|
|
237
|
+
}), P(), !0);
|
|
188
238
|
},
|
|
189
239
|
async update(e, t) {
|
|
190
|
-
let n =
|
|
191
|
-
return !n ||
|
|
240
|
+
let n = T.get(e);
|
|
241
|
+
return !n || f(e) ? !1 : (await I({
|
|
192
242
|
...n,
|
|
193
243
|
data: t,
|
|
194
|
-
modifiedAt:
|
|
195
|
-
}),
|
|
244
|
+
modifiedAt: y()
|
|
245
|
+
}), P(), !0);
|
|
196
246
|
},
|
|
197
247
|
async move(e, t, n) {
|
|
198
|
-
let r =
|
|
248
|
+
let r = v(j, t), i = [];
|
|
199
249
|
for (let t of e) {
|
|
200
|
-
let e =
|
|
201
|
-
!e ||
|
|
250
|
+
let e = T.get(t);
|
|
251
|
+
!e || f(t) || r === t || r != null && u(e.kind) && S(j, r, t) || v(j, e.parent) !== r && (L.delete(t), await I(B({
|
|
202
252
|
...e,
|
|
203
253
|
parent: r
|
|
204
254
|
}, n?.get(t) ?? null)), i.push(t));
|
|
205
255
|
}
|
|
206
|
-
return i.length &&
|
|
256
|
+
return i.length && P(), i;
|
|
207
257
|
},
|
|
208
258
|
place(e) {
|
|
209
259
|
let t = !1;
|
|
210
260
|
for (let [n, r] of e) {
|
|
211
|
-
let e =
|
|
212
|
-
!e || e.left === r.left && e.top === r.top || (
|
|
261
|
+
let e = f(n) ? x.some((e) => e.id === n) ? H(n) : null : T.get(n);
|
|
262
|
+
!e || e.left === r.left && e.top === r.top || (T.set(n, B(e, r)), L.add(n), t = !0);
|
|
213
263
|
}
|
|
214
|
-
t && (
|
|
264
|
+
t && (P(), R && clearTimeout(R), R = setTimeout(() => void V(), _));
|
|
215
265
|
},
|
|
216
|
-
flush:
|
|
266
|
+
flush: V,
|
|
217
267
|
async copy(e, t) {
|
|
218
|
-
let n =
|
|
219
|
-
if (
|
|
268
|
+
let n = v(j, t);
|
|
269
|
+
if (w(j, n)) return [];
|
|
220
270
|
let r = [];
|
|
221
271
|
for (let t of e) {
|
|
222
|
-
let e =
|
|
223
|
-
if (!e ||
|
|
224
|
-
let i =
|
|
225
|
-
let r =
|
|
272
|
+
let e = g(j, t);
|
|
273
|
+
if (!e || f(t)) continue;
|
|
274
|
+
let i = u(e.kind) ? D(j, t) : [], a = /* @__PURE__ */ new Map(), o = async (e, t, n) => {
|
|
275
|
+
let r = y(), i = {
|
|
226
276
|
...e,
|
|
227
|
-
id:
|
|
228
|
-
name: n ?
|
|
277
|
+
id: b(),
|
|
278
|
+
name: n ? A(j, t, e.name, e.kind) : e.name,
|
|
229
279
|
parent: t,
|
|
230
280
|
createdAt: r,
|
|
231
281
|
modifiedAt: r
|
|
232
282
|
};
|
|
233
|
-
return n && (i =
|
|
283
|
+
return n && (i = B(i, null)), a.set(e.id, i.id), await I(i), await h(e.kind)?.copy?.(e, i), i;
|
|
234
284
|
};
|
|
235
|
-
r.push(await
|
|
236
|
-
for (let e of i) await
|
|
237
|
-
|
|
285
|
+
r.push(await o(e, n, !0));
|
|
286
|
+
for (let e of i) await o(e, a.get(v(j, e.parent) ?? "") ?? null, !1);
|
|
287
|
+
P();
|
|
238
288
|
}
|
|
239
289
|
return r;
|
|
240
290
|
},
|
|
241
291
|
async emptyTrash() {
|
|
242
|
-
let t =
|
|
243
|
-
for (let e of t) await
|
|
244
|
-
return t.length &&
|
|
292
|
+
let t = D(j, e);
|
|
293
|
+
for (let e of t) await F().remove(e.id), T.delete(e.id), L.delete(e.id), await h(e.kind)?.onRemove?.(e);
|
|
294
|
+
return t.length && P(), t;
|
|
245
295
|
},
|
|
246
296
|
trashSize() {
|
|
247
|
-
return
|
|
297
|
+
return D(j, e).reduce((e, t) => e + (h(t.kind)?.size?.(t) ?? 0), 0);
|
|
248
298
|
},
|
|
249
299
|
dump() {
|
|
250
|
-
return { items: [...
|
|
300
|
+
return { items: [...T.values()] };
|
|
251
301
|
},
|
|
252
302
|
async clear() {
|
|
253
|
-
if (
|
|
254
|
-
await
|
|
303
|
+
if (s) try {
|
|
304
|
+
await U();
|
|
255
305
|
} finally {
|
|
256
|
-
|
|
306
|
+
P();
|
|
257
307
|
}
|
|
258
308
|
},
|
|
259
309
|
async import(e, { mode: t = "merge" } = {}) {
|
|
260
|
-
let n = /* @__PURE__ */ new Map(),
|
|
261
|
-
if (!
|
|
262
|
-
let
|
|
263
|
-
for (let e of
|
|
264
|
-
let
|
|
310
|
+
let n = /* @__PURE__ */ new Map(), r = e.items.filter((e) => e.id !== l && !f(e.id));
|
|
311
|
+
if (!r.length || !s) return n;
|
|
312
|
+
let i = t === "replace", a = /* @__PURE__ */ new Map();
|
|
313
|
+
for (let e of r) a.set(e.id, i ? e.id : b());
|
|
314
|
+
let o = (e) => e == null || f(e) ? e : a.get(e) ?? null;
|
|
265
315
|
try {
|
|
266
|
-
|
|
267
|
-
for (let e of
|
|
316
|
+
i && await U();
|
|
317
|
+
for (let e of r) {
|
|
268
318
|
let t = {
|
|
269
319
|
...e,
|
|
270
|
-
id:
|
|
271
|
-
parent:
|
|
272
|
-
};
|
|
273
|
-
|
|
320
|
+
id: a.get(e.id),
|
|
321
|
+
parent: o(e.parent)
|
|
322
|
+
}, r = m(e);
|
|
323
|
+
r != null && a.has(r) && (t.data = {
|
|
324
|
+
...e.data,
|
|
325
|
+
original: a.get(r)
|
|
326
|
+
}), await I(t), n.set(e.id, t);
|
|
274
327
|
}
|
|
275
328
|
} finally {
|
|
276
|
-
|
|
329
|
+
P();
|
|
277
330
|
}
|
|
278
331
|
return n;
|
|
279
332
|
},
|
|
280
333
|
async dispose() {
|
|
281
|
-
await
|
|
334
|
+
await V(), M.clear();
|
|
282
335
|
}
|
|
283
336
|
};
|
|
284
|
-
return
|
|
337
|
+
return W;
|
|
285
338
|
}
|
|
286
|
-
function
|
|
339
|
+
function H(e = []) {
|
|
287
340
|
let t = new Map(e.map((e) => [e.id, e]));
|
|
288
341
|
return {
|
|
289
342
|
records: t,
|
|
@@ -293,4 +346,4 @@ function w(e = []) {
|
|
|
293
346
|
};
|
|
294
347
|
}
|
|
295
348
|
//#endregion
|
|
296
|
-
export { r as APP_KIND, t as DISK,
|
|
349
|
+
export { s as ALIAS_KIND, r as APPLE_MENU_ITEMS, o as APP_KIND, t as DISK, a as FOLDER, i as STARTUP_ITEMS, n as SYSTEM_FOLDER, e as TRASH, c as UNTITLED_FOLDER, j as aliasName, p as appIdOf, F as appleMenuItemsOf, R as appleMenuOf, T as canAlias, y as childrenOf, v as containerOf, A as copyName, V as createCatalog, D as descendantsOf, E as dropTargetOf, C as enclosingFolders, u as isContainerKind, S as isInside, f as isKept, w as isTrashed, d as isVolume, b as itemCount, g as itemOf, H as memoryStorage, O as nextFolderName, m as originalOf, _ as resolve, I as startupItemsOf };
|
package/dist/shell/finder.d.ts
CHANGED
|
@@ -19,16 +19,20 @@
|
|
|
19
19
|
* around it. An application's icon stands for the application: it is drawn
|
|
20
20
|
* open while the application has a window open, and the application's own
|
|
21
21
|
* windows close into it.
|
|
22
|
-
* -
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* - An alias wears its original's art with its name in italics, and opens
|
|
23
|
+
* its original; an alias of a folder or the disk also files a drop into
|
|
24
|
+
* it. With the original gone, an alert says so. Make Alias makes one
|
|
25
|
+
* beside each selected application, document, folder or disk.
|
|
26
|
+
* - Menus: File (Open, New Folder, Close, Make Alias), Edit (Copy, Paste,
|
|
27
|
+
* Select All), View (Arrange Windows), Special (Clean Up, Empty Trash…),
|
|
28
|
+
* each disabled while it has nothing to act on. A site switches commands
|
|
29
|
+
* off and adds its own.
|
|
26
30
|
* - Alerts are the Finder's own, composed with the site's caution art and
|
|
27
31
|
* held by it while they are up. A site answers any of them with its own
|
|
28
32
|
* dialog through `alertWith`.
|
|
29
33
|
*/
|
|
30
34
|
import type { VfIcon, VfMenuItem, VfViewportBox } from '../index.js';
|
|
31
|
-
import type { Catalog, CatalogStorage, Item, Volumes } from './catalog.js';
|
|
35
|
+
import type { Catalog, CatalogStorage, Item, SystemFolders, Volumes } from './catalog.js';
|
|
32
36
|
import type { LatticeOptions, Size } from './geometry.js';
|
|
33
37
|
import type { AppContext, AppDefinition } from './shell.js';
|
|
34
38
|
/** The Finder's application id. */
|
|
@@ -44,13 +48,17 @@ export interface FinderArt {
|
|
|
44
48
|
document: string;
|
|
45
49
|
/** The startup disk; the folder's art without it. */
|
|
46
50
|
disk?: string;
|
|
51
|
+
/** The System Folder and its two folders; the folder's art without them. */
|
|
52
|
+
systemFolder?: string;
|
|
53
|
+
appleMenuItems?: string;
|
|
54
|
+
startupItems?: string;
|
|
47
55
|
/** 12×12: the mark before the item count in the Trash's window and trashed folders. */
|
|
48
56
|
trashMark?: string;
|
|
49
57
|
/** 32×32: beside the message in the Finder's alerts. Without it they have no art. */
|
|
50
58
|
caution?: string;
|
|
51
59
|
}
|
|
52
60
|
/** What a failed command was, in the `failed` alert. */
|
|
53
|
-
export type FinderFailedAction = 'new-folder' | 'empty-trash' | 'paste' | 'add-file';
|
|
61
|
+
export type FinderFailedAction = 'new-folder' | 'empty-trash' | 'paste' | 'add-file' | 'make-alias';
|
|
54
62
|
/** The Finder's alerts, by id, with the details each one's handler gets. */
|
|
55
63
|
export interface FinderAlerts {
|
|
56
64
|
/** Special → Empty Trash…: an answer of `'ok'` empties the Trash. */
|
|
@@ -70,7 +78,11 @@ export interface FinderAlerts {
|
|
|
70
78
|
'move-failed': {
|
|
71
79
|
error: Error;
|
|
72
80
|
};
|
|
73
|
-
/**
|
|
81
|
+
/** Opening an alias whose original is gone, or a drop onto an alias of a folder whose original is gone. */
|
|
82
|
+
'original-missing': {
|
|
83
|
+
alias: Item;
|
|
84
|
+
};
|
|
85
|
+
/** New Folder, Empty Trash, Paste, Make Alias or a dropped file failed. */
|
|
74
86
|
failed: {
|
|
75
87
|
action: FinderFailedAction;
|
|
76
88
|
error: Error;
|
|
@@ -81,7 +93,7 @@ export type FinderAlert = keyof FinderAlerts;
|
|
|
81
93
|
/** Answers one of the Finder's alerts: resolves the answer, or null. */
|
|
82
94
|
export type FinderAlertHandler<K extends FinderAlert> = (details: FinderAlerts[K]) => string | null | Promise<string | null>;
|
|
83
95
|
/** The Finder's own commands, each of which a site can switch off. */
|
|
84
|
-
export type FinderCommand = 'open' | 'new-folder' | 'close' | 'copy' | 'paste' | 'select-all' | 'arrange' | 'clean-up' | 'empty-trash';
|
|
96
|
+
export type FinderCommand = 'open' | 'new-folder' | 'close' | 'make-alias' | 'copy' | 'paste' | 'select-all' | 'arrange' | 'clean-up' | 'empty-trash';
|
|
85
97
|
/** The Finder's menus, by `data-menu`. */
|
|
86
98
|
export type FinderMenu = 'file' | 'edit' | 'view' | 'special';
|
|
87
99
|
/** A command a site adds to the Finder's menus. */
|
|
@@ -135,10 +147,17 @@ export interface FinderOptions {
|
|
|
135
147
|
art: FinderArt;
|
|
136
148
|
/** The volumes: the Trash by default, and a startup disk when named. */
|
|
137
149
|
volumes?: Volumes;
|
|
150
|
+
/**
|
|
151
|
+
* The System Folder and its folders, named: what Apple Menu Items holds is
|
|
152
|
+
* the Apple menu, and what Startup Items holds opens at startup. Unset, none.
|
|
153
|
+
*/
|
|
154
|
+
system?: SystemFolders;
|
|
138
155
|
/**
|
|
139
156
|
* What the catalog starts with, stored once per storage: `'markup'` reads
|
|
140
157
|
* the `<vf-icon data-app>` and `<template data-folder="Name">` the page
|
|
141
|
-
* put in the desktop's field
|
|
158
|
+
* put in the desktop's field, and a `<template data-system="apple-menu-items">`
|
|
159
|
+
* files what it holds in that folder of the System Folder; a function
|
|
160
|
+
* stores the site's defaults.
|
|
142
161
|
*/
|
|
143
162
|
seed?: 'markup' | ((catalog: Catalog) => void | Promise<void>);
|
|
144
163
|
/** The lattices' cells, pitches and insets (default: 64px cells, 80px columns, 72px rows, 16px insets). */
|