vintage-frames 0.19.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.
@@ -9,89 +9,121 @@ function m(e) {
9
9
  let t = e.data;
10
10
  return typeof t?.original == "string" ? t.original : null;
11
11
  }
12
- function h(e, t) {
13
- return t == null ? null : e.items.find((e) => e.id === t) ?? null;
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;
14
16
  }
15
17
  function g(e, t) {
16
- let n = /* @__PURE__ */ new Set(), r = h(e, t);
18
+ return t == null ? null : e.items.find((e) => e.id === t) ?? null;
19
+ }
20
+ function _(e, t) {
21
+ let n = /* @__PURE__ */ new Set(), r = g(e, t);
17
22
  for (; r?.kind === s;) {
18
23
  if (n.has(r.id)) return null;
19
- n.add(r.id), r = h(e, m(r));
24
+ n.add(r.id), r = g(e, m(r));
20
25
  }
21
26
  return r;
22
27
  }
23
- function _(e, t) {
24
- let n = h(e, t);
25
- return n && u(n.kind) ? n.id : null;
26
- }
27
28
  function v(e, t) {
28
- let n = _(e, t);
29
- return e.items.filter((t) => t.id !== n && _(e, t.parent) === n);
29
+ let n = g(e, t);
30
+ return n && u(n.kind) ? n.id : null;
30
31
  }
31
32
  function y(e, t) {
32
- return v(e, t).length;
33
+ let n = v(e, t);
34
+ return e.items.filter((t) => t.id !== n && v(e, t.parent) === n);
35
+ }
36
+ function b(e, t) {
37
+ return y(e, t).length;
33
38
  }
34
- var b = (e, t) => _(e, h(e, t)?.parent ?? null);
35
- function x(e, t, n) {
36
- let r = /* @__PURE__ */ new Set(), i = b(e, t);
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);
37
42
  for (; i != null && !r.has(i);) {
38
43
  if (i === n) return !0;
39
- r.add(i), i = b(e, i);
44
+ r.add(i), i = x(e, i);
40
45
  }
41
46
  return !1;
42
47
  }
43
- function S(e, t) {
44
- let n = [], r = /* @__PURE__ */ new Set(), i = _(e, t ?? null);
45
- for (; i != null && !r.has(i);) n.push(i), r.add(i), i = b(e, i);
46
- return n;
47
- }
48
48
  function C(e, t) {
49
- return t == null ? !1 : t === "trash" || x(e, t, "trash");
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);
51
+ return n;
50
52
  }
51
53
  function w(e, t) {
54
+ return t == null ? !1 : t === "trash" || S(e, t, "trash");
55
+ }
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) {
52
71
  let n = [], r = /* @__PURE__ */ new Set(), i = (t) => {
53
- for (let a of v(e, t)) r.has(a.id) || (r.add(a.id), n.push(a), u(a.kind) && i(a.id));
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));
54
73
  };
55
- return i(_(e, t)), n;
74
+ return i(v(e, t)), n;
56
75
  }
57
- function T(e, t) {
58
- let n = new Set(v(e, t).filter((e) => e.kind === a).map((e) => e.name));
76
+ function O(e, t) {
77
+ let n = new Set(y(e, t).filter((e) => e.kind === a).map((e) => e.name));
59
78
  if (!n.has("untitled folder")) return c;
60
79
  for (let e = 2;; e++) {
61
80
  let t = `${c} ${e}`;
62
81
  if (!n.has(t)) return t;
63
82
  }
64
83
  }
65
- var E = (e) => e.replace(/ copy( \d+)?$/, "");
66
- function D(e, t, n, r) {
67
- let i = new Set(v(e, t).filter((e) => e.kind === r).map((e) => e.name));
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));
68
87
  if (!i.has(n)) return n;
69
- let a = E(n);
88
+ let a = k(n);
70
89
  if (!i.has(`${a} copy`)) return `${a} copy`;
71
90
  for (let e = 2;; e++) {
72
91
  let t = `${a} copy ${e}`;
73
92
  if (!i.has(t)) return t;
74
93
  }
75
94
  }
76
- function O(e, t, n) {
77
- let r = new Set(v(e, t).filter((e) => e.kind === s).map((e) => e.name)), i = `${n} alias`;
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`;
78
97
  if (!r.has(i)) return i;
79
98
  for (let e = 2;; e++) {
80
99
  let t = `${i} ${e}`;
81
100
  if (!r.has(t)) return t;
82
101
  }
83
102
  }
84
- var k = new Intl.Collator("en");
85
- function A(e, t) {
86
- return h(e, t) ? v(e, t).sort((e, t) => k.compare(e.name, t.name) || N(e, t)) : [];
87
- }
88
- var j = (e) => A(e, r), M = (e) => A(e, i), N = (e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : 1);
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));
89
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) {
90
122
  let n = { ...e };
91
123
  return t ? (n.left = t.left, n.top = t.top) : (delete n.left, delete n.top), n;
92
124
  }
93
- function F(o) {
94
- let { storage: s, volumes: c = {}, system: d, listed: p = () => !0, hooks: g = () => void 0, placeDelay: v = 400 } = o, y = () => (o.now ?? Date.now)(), b = () => o.newId ? o.newId() : crypto.randomUUID(), S = [], E = (e, t, n, r) => S.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({
95
127
  id: e,
96
128
  name: t,
97
129
  kind: n,
@@ -99,53 +131,53 @@ function F(o) {
99
131
  createdAt: 0,
100
132
  modifiedAt: 0
101
133
  });
102
- c.disk && E(t, c.disk, t, null), c.trash !== !1 && E(e, c.trash ?? "Trash", e, null), d && (E(n, d.folder, a, c.disk ? t : null), E(r, d.appleMenu, a, n), E(i, d.startup, a, n));
103
- let O = /* @__PURE__ */ new Map(), k = !1, A = !1, j = F(), M = /* @__PURE__ */ new Set();
104
- function F() {
105
- let e = S.map((e) => {
106
- let t = O.get(e.id);
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);
107
139
  return t?.left != null && t.top != null ? {
108
140
  ...e,
109
141
  left: t.left,
110
142
  top: t.top
111
143
  } : e;
112
- }), t = [...O.values()].filter((e) => !f(e.id) && (e.kind === "folder" || p(e.kind))).sort(N);
144
+ }), t = [...T.values()].filter((e) => !f(e.id) && (e.kind === "folder" || p(e.kind))).sort(z);
113
145
  return {
114
- available: k,
146
+ available: E,
115
147
  items: [...e, ...t]
116
148
  };
117
149
  }
118
- function I() {
119
- j = F();
150
+ function P() {
151
+ j = N();
120
152
  for (let e of [...M]) e(j);
121
153
  }
122
- let L = () => {
154
+ let F = () => {
123
155
  if (!s) throw Error("storage is unavailable");
124
156
  return s;
125
157
  };
126
- async function R(e) {
127
- await L().put(e), O.set(e.id, e);
158
+ async function I(e) {
159
+ await F().put(e), T.set(e.id, e);
128
160
  }
129
- let z = /* @__PURE__ */ new Set(), B = null;
161
+ let L = /* @__PURE__ */ new Set(), R = null;
130
162
  async function V() {
131
- B && clearTimeout(B), B = null;
132
- let e = [...z];
133
- if (z.clear(), !(!s || !k)) for (let t of e) {
134
- let e = O.get(t);
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);
135
167
  e && await s.put(e).catch(() => {});
136
168
  }
137
169
  }
138
170
  let H = (e) => {
139
- let t = S.find((t) => t.id === e);
140
- return O.get(e) ?? {
171
+ let t = x.find((t) => t.id === e);
172
+ return T.get(e) ?? {
141
173
  ...t,
142
174
  name: ""
143
175
  };
144
176
  };
145
177
  async function U() {
146
- z.clear();
147
- for (let e of await L().list()) e.id !== l && (await L().remove(e.id), O.delete(e.id));
148
- O = /* @__PURE__ */ new Map();
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();
149
181
  }
150
182
  let W = {
151
183
  get: () => j,
@@ -154,124 +186,124 @@ function F(o) {
154
186
  M.delete(e);
155
187
  };
156
188
  },
157
- item: (e) => h(j, e),
189
+ item: (e) => g(j, e),
158
190
  async refresh() {
159
191
  if (!s) {
160
- O = /* @__PURE__ */ new Map(), k = !1, I();
192
+ T = /* @__PURE__ */ new Map(), E = !1, P();
161
193
  return;
162
194
  }
163
195
  try {
164
196
  let e = await s.list();
165
- O = /* @__PURE__ */ new Map(), A = !1;
166
- for (let t of e) t.id === l ? A = !0 : O.set(t.id, t);
167
- k = !0;
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;
168
200
  } catch (e) {
169
- console.warn("vintage-frames/shell: the catalog could not be read —", e), O = /* @__PURE__ */ new Map(), k = !1;
201
+ console.warn("vintage-frames/shell: the catalog could not be read —", e), T = /* @__PURE__ */ new Map(), E = !1;
170
202
  }
171
- I();
203
+ P();
172
204
  },
173
205
  async seed(e) {
174
- return !s || !k || A ? !1 : (await e(W), await s.put({
206
+ return !s || !E || k ? !1 : (await e(W), await s.put({
175
207
  id: l,
176
208
  name: "",
177
209
  kind: l,
178
210
  parent: null,
179
211
  createdAt: y(),
180
212
  modifiedAt: y()
181
- }), A = !0, !0);
213
+ }), k = !0, !0);
182
214
  },
183
215
  async create(e = {}) {
184
- let t = _(j, e.parent ?? null);
185
- if (C(j, t)) return null;
216
+ let t = v(j, e.parent ?? null);
217
+ if (w(j, t)) return null;
186
218
  let n = e.kind ?? "folder", r = e.at ?? y(), i = {
187
219
  id: b(),
188
- name: e.name ?? (n === "folder" ? T(j, t) : "untitled"),
220
+ name: e.name ?? (n === "folder" ? O(j, t) : "untitled"),
189
221
  kind: n,
190
222
  parent: t,
191
223
  createdAt: r,
192
224
  modifiedAt: r
193
225
  };
194
- return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i = P(i, {
226
+ return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i = B(i, {
195
227
  left: e.left,
196
228
  top: e.top
197
- })), await R(i), I(), i;
229
+ })), await I(i), P(), i;
198
230
  },
199
231
  async rename(e, t) {
200
- let n = O.get(e);
201
- return !n || f(e) || n.name === t ? !1 : (await R({
232
+ let n = T.get(e);
233
+ return !n || f(e) || n.name === t ? !1 : (await I({
202
234
  ...n,
203
235
  name: t,
204
236
  modifiedAt: y()
205
- }), I(), !0);
237
+ }), P(), !0);
206
238
  },
207
239
  async update(e, t) {
208
- let n = O.get(e);
209
- return !n || f(e) ? !1 : (await R({
240
+ let n = T.get(e);
241
+ return !n || f(e) ? !1 : (await I({
210
242
  ...n,
211
243
  data: t,
212
244
  modifiedAt: y()
213
- }), I(), !0);
245
+ }), P(), !0);
214
246
  },
215
247
  async move(e, t, n) {
216
- let r = _(j, t), i = [];
248
+ let r = v(j, t), i = [];
217
249
  for (let t of e) {
218
- let e = O.get(t);
219
- !e || f(t) || r === t || r != null && u(e.kind) && x(j, r, t) || _(j, e.parent) !== r && (z.delete(t), await R(P({
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({
220
252
  ...e,
221
253
  parent: r
222
254
  }, n?.get(t) ?? null)), i.push(t));
223
255
  }
224
- return i.length && I(), i;
256
+ return i.length && P(), i;
225
257
  },
226
258
  place(e) {
227
259
  let t = !1;
228
260
  for (let [n, r] of e) {
229
- let e = f(n) ? S.some((e) => e.id === n) ? H(n) : null : O.get(n);
230
- !e || e.left === r.left && e.top === r.top || (O.set(n, P(e, r)), z.add(n), t = !0);
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);
231
263
  }
232
- t && (I(), B && clearTimeout(B), B = setTimeout(() => void V(), v));
264
+ t && (P(), R && clearTimeout(R), R = setTimeout(() => void V(), _));
233
265
  },
234
266
  flush: V,
235
267
  async copy(e, t) {
236
- let n = _(j, t);
237
- if (C(j, n)) return [];
268
+ let n = v(j, t);
269
+ if (w(j, n)) return [];
238
270
  let r = [];
239
271
  for (let t of e) {
240
- let e = h(j, t);
272
+ let e = g(j, t);
241
273
  if (!e || f(t)) continue;
242
- let i = u(e.kind) ? w(j, t) : [], a = /* @__PURE__ */ new Map(), o = async (e, t, n) => {
274
+ let i = u(e.kind) ? D(j, t) : [], a = /* @__PURE__ */ new Map(), o = async (e, t, n) => {
243
275
  let r = y(), i = {
244
276
  ...e,
245
277
  id: b(),
246
- name: n ? D(j, t, e.name, e.kind) : e.name,
278
+ name: n ? A(j, t, e.name, e.kind) : e.name,
247
279
  parent: t,
248
280
  createdAt: r,
249
281
  modifiedAt: r
250
282
  };
251
- return n && (i = P(i, null)), a.set(e.id, i.id), await R(i), await g(e.kind)?.copy?.(e, i), 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;
252
284
  };
253
285
  r.push(await o(e, n, !0));
254
- for (let e of i) await o(e, a.get(_(j, e.parent) ?? "") ?? null, !1);
255
- I();
286
+ for (let e of i) await o(e, a.get(v(j, e.parent) ?? "") ?? null, !1);
287
+ P();
256
288
  }
257
289
  return r;
258
290
  },
259
291
  async emptyTrash() {
260
- let t = w(j, e);
261
- for (let e of t) await L().remove(e.id), O.delete(e.id), z.delete(e.id), await g(e.kind)?.onRemove?.(e);
262
- return t.length && I(), t;
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;
263
295
  },
264
296
  trashSize() {
265
- return w(j, e).reduce((e, t) => e + (g(t.kind)?.size?.(t) ?? 0), 0);
297
+ return D(j, e).reduce((e, t) => e + (h(t.kind)?.size?.(t) ?? 0), 0);
266
298
  },
267
299
  dump() {
268
- return { items: [...O.values()] };
300
+ return { items: [...T.values()] };
269
301
  },
270
302
  async clear() {
271
303
  if (s) try {
272
304
  await U();
273
305
  } finally {
274
- I();
306
+ P();
275
307
  }
276
308
  },
277
309
  async import(e, { mode: t = "merge" } = {}) {
@@ -291,10 +323,10 @@ function F(o) {
291
323
  r != null && a.has(r) && (t.data = {
292
324
  ...e.data,
293
325
  original: a.get(r)
294
- }), await R(t), n.set(e.id, t);
326
+ }), await I(t), n.set(e.id, t);
295
327
  }
296
328
  } finally {
297
- I();
329
+ P();
298
330
  }
299
331
  return n;
300
332
  },
@@ -304,7 +336,7 @@ function F(o) {
304
336
  };
305
337
  return W;
306
338
  }
307
- function I(e = []) {
339
+ function H(e = []) {
308
340
  let t = new Map(e.map((e) => [e.id, e]));
309
341
  return {
310
342
  records: t,
@@ -314,4 +346,4 @@ function I(e = []) {
314
346
  };
315
347
  }
316
348
  //#endregion
317
- 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, O as aliasName, p as appIdOf, j as appleMenuItemsOf, v as childrenOf, _ as containerOf, D as copyName, F as createCatalog, w as descendantsOf, S as enclosingFolders, u as isContainerKind, x as isInside, f as isKept, C as isTrashed, d as isVolume, y as itemCount, h as itemOf, I as memoryStorage, T as nextFolderName, m as originalOf, g as resolve, M as startupItemsOf };
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 };
@@ -20,8 +20,9 @@
20
20
  * open while the application has a window open, and the application's own
21
21
  * windows close into it.
22
22
  * - An alias wears its original's art with its name in italics, and opens
23
- * its original; with the original gone, an alert says so. Make Alias makes
24
- * one beside each selected application or document.
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.
25
26
  * - Menus: File (Open, New Folder, Close, Make Alias), Edit (Copy, Paste,
26
27
  * Select All), View (Arrange Windows), Special (Clean Up, Empty Trash…),
27
28
  * each disabled while it has nothing to act on. A site switches commands
@@ -77,7 +78,7 @@ export interface FinderAlerts {
77
78
  'move-failed': {
78
79
  error: Error;
79
80
  };
80
- /** Opening an alias whose original is gone. */
81
+ /** Opening an alias whose original is gone, or a drop onto an alias of a folder whose original is gone. */
81
82
  'original-missing': {
82
83
  alias: Item;
83
84
  };