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/catalog.d.ts
CHANGED
|
@@ -32,13 +32,15 @@ export declare const TRASH = "trash";
|
|
|
32
32
|
export declare const DISK = "disk";
|
|
33
33
|
/** A folder's kind. */
|
|
34
34
|
export declare const FOLDER = "folder";
|
|
35
|
+
/** An application's icon: the kind the shell registers, whose data names the application it opens. */
|
|
36
|
+
export declare const APP_KIND = "app";
|
|
35
37
|
/** The name a new folder takes, counted up where it is taken. */
|
|
36
38
|
export declare const UNTITLED_FOLDER = "untitled folder";
|
|
37
39
|
/** One item of the catalog. */
|
|
38
40
|
export interface Item {
|
|
39
41
|
id: string;
|
|
40
42
|
name: string;
|
|
41
|
-
/** `folder`, a volume's (`trash`, `disk`), or a kind an application registers. */
|
|
43
|
+
/** `folder`, a volume's (`trash`, `disk`), the shell's `app`, or a kind an application registers. */
|
|
42
44
|
kind: string;
|
|
43
45
|
/** A folder's id, a volume's, or null for the desktop. */
|
|
44
46
|
parent: string | null;
|
|
@@ -107,6 +109,8 @@ export interface CatalogArchive {
|
|
|
107
109
|
export declare const isContainerKind: (kind: string) => boolean;
|
|
108
110
|
/** Whether `id` names a volume. */
|
|
109
111
|
export declare const isVolume: (id: string | null | undefined) => boolean;
|
|
112
|
+
/** The application an `app` item stands for: its `data.app`, or null. */
|
|
113
|
+
export declare function appIdOf(item: Item): string | null;
|
|
110
114
|
/** The item with `id`, or null. */
|
|
111
115
|
export declare function itemOf(state: CatalogState, id: string | null | undefined): Item | null;
|
|
112
116
|
/** The container `parent` resolves to: that container while it is listed, else the desktop (null). */
|
package/dist/shell/catalog.js
CHANGED
|
@@ -1,78 +1,82 @@
|
|
|
1
1
|
//#region src/shell/catalog.ts
|
|
2
|
-
var e = "trash", t = "disk", n = "folder", r = "untitled folder",
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function c(e, t) {
|
|
7
|
-
let n = s(e, t);
|
|
8
|
-
return n && a(n.kind) ? n.id : null;
|
|
2
|
+
var e = "trash", t = "disk", n = "folder", r = "app", i = "untitled folder", a = "#seeded", o = (e) => e === "folder" || e === "trash" || e === "disk", s = (e) => e === "trash" || e === "disk";
|
|
3
|
+
function c(e) {
|
|
4
|
+
let t = e.data;
|
|
5
|
+
return typeof t?.app == "string" ? t.app : null;
|
|
9
6
|
}
|
|
10
7
|
function l(e, t) {
|
|
11
|
-
|
|
12
|
-
return e.items.filter((t) => t.id !== n && c(e, t.parent) === n);
|
|
8
|
+
return t == null ? null : e.items.find((e) => e.id === t) ?? null;
|
|
13
9
|
}
|
|
14
10
|
function u(e, t) {
|
|
15
|
-
|
|
11
|
+
let n = l(e, t);
|
|
12
|
+
return n && o(n.kind) ? n.id : null;
|
|
13
|
+
}
|
|
14
|
+
function d(e, t) {
|
|
15
|
+
let n = u(e, t);
|
|
16
|
+
return e.items.filter((t) => t.id !== n && u(e, t.parent) === n);
|
|
17
|
+
}
|
|
18
|
+
function f(e, t) {
|
|
19
|
+
return d(e, t).length;
|
|
16
20
|
}
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let r = /* @__PURE__ */ new Set(), i =
|
|
21
|
+
var p = (e, t) => u(e, l(e, t)?.parent ?? null);
|
|
22
|
+
function m(e, t, n) {
|
|
23
|
+
let r = /* @__PURE__ */ new Set(), i = p(e, t);
|
|
20
24
|
for (; i != null && !r.has(i);) {
|
|
21
25
|
if (i === n) return !0;
|
|
22
|
-
r.add(i), i =
|
|
26
|
+
r.add(i), i = p(e, i);
|
|
23
27
|
}
|
|
24
28
|
return !1;
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
let n = [], r = /* @__PURE__ */ new Set(), i =
|
|
28
|
-
for (; i != null && !r.has(i);) n.push(i), r.add(i), i =
|
|
30
|
+
function h(e, t) {
|
|
31
|
+
let n = [], r = /* @__PURE__ */ new Set(), i = u(e, t ?? null);
|
|
32
|
+
for (; i != null && !r.has(i);) n.push(i), r.add(i), i = p(e, i);
|
|
29
33
|
return n;
|
|
30
34
|
}
|
|
31
|
-
function
|
|
32
|
-
return t == null ? !1 : t === "trash" ||
|
|
35
|
+
function g(e, t) {
|
|
36
|
+
return t == null ? !1 : t === "trash" || m(e, t, "trash");
|
|
33
37
|
}
|
|
34
|
-
function
|
|
38
|
+
function _(e, t) {
|
|
35
39
|
let n = [], r = /* @__PURE__ */ new Set(), i = (t) => {
|
|
36
|
-
for (let
|
|
40
|
+
for (let a of d(e, t)) r.has(a.id) || (r.add(a.id), n.push(a), o(a.kind) && i(a.id));
|
|
37
41
|
};
|
|
38
|
-
return i(
|
|
42
|
+
return i(u(e, t)), n;
|
|
39
43
|
}
|
|
40
|
-
function
|
|
41
|
-
let
|
|
42
|
-
if (!
|
|
44
|
+
function v(e, t) {
|
|
45
|
+
let r = new Set(d(e, t).filter((e) => e.kind === n).map((e) => e.name));
|
|
46
|
+
if (!r.has("untitled folder")) return i;
|
|
43
47
|
for (let e = 2;; e++) {
|
|
44
|
-
let t = `${
|
|
45
|
-
if (!
|
|
48
|
+
let t = `${i} ${e}`;
|
|
49
|
+
if (!r.has(t)) return t;
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
|
-
var
|
|
49
|
-
function
|
|
50
|
-
let i = new Set(
|
|
52
|
+
var y = (e) => e.replace(/ copy( \d+)?$/, "");
|
|
53
|
+
function b(e, t, n, r) {
|
|
54
|
+
let i = new Set(d(e, t).filter((e) => e.kind === r).map((e) => e.name));
|
|
51
55
|
if (!i.has(n)) return n;
|
|
52
|
-
let a =
|
|
56
|
+
let a = y(n);
|
|
53
57
|
if (!i.has(`${a} copy`)) return `${a} copy`;
|
|
54
58
|
for (let e = 2;; e++) {
|
|
55
59
|
let t = `${a} copy ${e}`;
|
|
56
60
|
if (!i.has(t)) return t;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
var
|
|
60
|
-
function
|
|
63
|
+
var x = (e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : 1);
|
|
64
|
+
function S(e, t) {
|
|
61
65
|
let n = { ...e };
|
|
62
66
|
return t ? (n.left = t.left, n.top = t.top) : (delete n.left, delete n.top), n;
|
|
63
67
|
}
|
|
64
|
-
function
|
|
65
|
-
let { storage: r, volumes:
|
|
66
|
-
|
|
68
|
+
function C(n) {
|
|
69
|
+
let { storage: r, volumes: i = {}, listed: c = () => !0, hooks: d = () => void 0, placeDelay: f = 400 } = n, p = () => (n.now ?? Date.now)(), h = () => n.newId ? n.newId() : crypto.randomUUID(), y = [];
|
|
70
|
+
i.disk && y.push({
|
|
67
71
|
id: t,
|
|
68
|
-
name:
|
|
72
|
+
name: i.disk,
|
|
69
73
|
kind: t,
|
|
70
74
|
parent: null,
|
|
71
75
|
createdAt: 0,
|
|
72
76
|
modifiedAt: 0
|
|
73
|
-
}),
|
|
77
|
+
}), i.trash !== !1 && y.push({
|
|
74
78
|
id: e,
|
|
75
|
-
name:
|
|
79
|
+
name: i.trash ?? "Trash",
|
|
76
80
|
kind: e,
|
|
77
81
|
parent: null,
|
|
78
82
|
createdAt: 0,
|
|
@@ -80,14 +84,14 @@ function x(n) {
|
|
|
80
84
|
});
|
|
81
85
|
let C = /* @__PURE__ */ new Map(), w = !1, T = !1, E = O(), D = /* @__PURE__ */ new Set();
|
|
82
86
|
function O() {
|
|
83
|
-
let e =
|
|
87
|
+
let e = y.map((e) => {
|
|
84
88
|
let t = C.get(e.id);
|
|
85
89
|
return t?.left != null && t.top != null ? {
|
|
86
90
|
...e,
|
|
87
91
|
left: t.left,
|
|
88
92
|
top: t.top
|
|
89
93
|
} : e;
|
|
90
|
-
}), t = [...C.values()].filter((e) => !
|
|
94
|
+
}), t = [...C.values()].filter((e) => !s(e.id) && (e.kind === "folder" || c(e.kind))).sort(x);
|
|
91
95
|
return {
|
|
92
96
|
available: w,
|
|
93
97
|
items: [...e, ...t]
|
|
@@ -114,7 +118,7 @@ function x(n) {
|
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
let F = (e) => {
|
|
117
|
-
let t =
|
|
121
|
+
let t = y.find((t) => t.id === e);
|
|
118
122
|
return C.get(e) ?? {
|
|
119
123
|
...t,
|
|
120
124
|
name: ""
|
|
@@ -122,7 +126,7 @@ function x(n) {
|
|
|
122
126
|
};
|
|
123
127
|
async function I() {
|
|
124
128
|
M.clear();
|
|
125
|
-
for (let e of await A().list()) e.id !==
|
|
129
|
+
for (let e of await A().list()) e.id !== a && (await A().remove(e.id), C.delete(e.id));
|
|
126
130
|
C = /* @__PURE__ */ new Map();
|
|
127
131
|
}
|
|
128
132
|
let L = {
|
|
@@ -132,7 +136,7 @@ function x(n) {
|
|
|
132
136
|
D.delete(e);
|
|
133
137
|
};
|
|
134
138
|
},
|
|
135
|
-
item: (e) =>
|
|
139
|
+
item: (e) => l(E, e),
|
|
136
140
|
async refresh() {
|
|
137
141
|
if (!r) {
|
|
138
142
|
C = /* @__PURE__ */ new Map(), w = !1, k();
|
|
@@ -141,7 +145,7 @@ function x(n) {
|
|
|
141
145
|
try {
|
|
142
146
|
let e = await r.list();
|
|
143
147
|
C = /* @__PURE__ */ new Map(), T = !1;
|
|
144
|
-
for (let t of e) t.id ===
|
|
148
|
+
for (let t of e) t.id === a ? T = !0 : C.set(t.id, t);
|
|
145
149
|
w = !0;
|
|
146
150
|
} catch (e) {
|
|
147
151
|
console.warn("vintage-frames/shell: the catalog could not be read —", e), C = /* @__PURE__ */ new Map(), w = !1;
|
|
@@ -150,51 +154,51 @@ function x(n) {
|
|
|
150
154
|
},
|
|
151
155
|
async seed(e) {
|
|
152
156
|
return !r || !w || T ? !1 : (await e(L), await r.put({
|
|
153
|
-
id:
|
|
157
|
+
id: a,
|
|
154
158
|
name: "",
|
|
155
|
-
kind:
|
|
159
|
+
kind: a,
|
|
156
160
|
parent: null,
|
|
157
|
-
createdAt:
|
|
158
|
-
modifiedAt:
|
|
161
|
+
createdAt: p(),
|
|
162
|
+
modifiedAt: p()
|
|
159
163
|
}), T = !0, !0);
|
|
160
164
|
},
|
|
161
165
|
async create(e = {}) {
|
|
162
|
-
let t =
|
|
163
|
-
if (
|
|
164
|
-
let n = e.kind ?? "folder", r = e.at ??
|
|
165
|
-
id:
|
|
166
|
-
name: e.name ?? (n === "folder" ?
|
|
166
|
+
let t = u(E, e.parent ?? null);
|
|
167
|
+
if (g(E, t)) return null;
|
|
168
|
+
let n = e.kind ?? "folder", r = e.at ?? p(), i = {
|
|
169
|
+
id: h(),
|
|
170
|
+
name: e.name ?? (n === "folder" ? v(E, t) : "untitled"),
|
|
167
171
|
kind: n,
|
|
168
172
|
parent: t,
|
|
169
173
|
createdAt: r,
|
|
170
174
|
modifiedAt: r
|
|
171
175
|
};
|
|
172
|
-
return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i =
|
|
176
|
+
return e.data !== void 0 && (i.data = e.data), e.left != null && e.top != null && (i = S(i, {
|
|
173
177
|
left: e.left,
|
|
174
178
|
top: e.top
|
|
175
179
|
})), await j(i), k(), i;
|
|
176
180
|
},
|
|
177
181
|
async rename(e, t) {
|
|
178
182
|
let n = C.get(e);
|
|
179
|
-
return !n ||
|
|
183
|
+
return !n || s(e) || n.name === t ? !1 : (await j({
|
|
180
184
|
...n,
|
|
181
185
|
name: t,
|
|
182
|
-
modifiedAt:
|
|
186
|
+
modifiedAt: p()
|
|
183
187
|
}), k(), !0);
|
|
184
188
|
},
|
|
185
189
|
async update(e, t) {
|
|
186
190
|
let n = C.get(e);
|
|
187
|
-
return !n ||
|
|
191
|
+
return !n || s(e) ? !1 : (await j({
|
|
188
192
|
...n,
|
|
189
193
|
data: t,
|
|
190
|
-
modifiedAt:
|
|
194
|
+
modifiedAt: p()
|
|
191
195
|
}), k(), !0);
|
|
192
196
|
},
|
|
193
197
|
async move(e, t, n) {
|
|
194
|
-
let r =
|
|
198
|
+
let r = u(E, t), i = [];
|
|
195
199
|
for (let t of e) {
|
|
196
200
|
let e = C.get(t);
|
|
197
|
-
!e ||
|
|
201
|
+
!e || s(t) || r === t || r != null && o(e.kind) && m(E, r, t) || u(E, e.parent) !== r && (M.delete(t), await j(S({
|
|
198
202
|
...e,
|
|
199
203
|
parent: r
|
|
200
204
|
}, n?.get(t) ?? null)), i.push(t));
|
|
@@ -204,43 +208,43 @@ function x(n) {
|
|
|
204
208
|
place(e) {
|
|
205
209
|
let t = !1;
|
|
206
210
|
for (let [n, r] of e) {
|
|
207
|
-
let e =
|
|
208
|
-
!e || e.left === r.left && e.top === r.top || (C.set(n,
|
|
211
|
+
let e = s(n) ? y.some((e) => e.id === n) ? F(n) : null : C.get(n);
|
|
212
|
+
!e || e.left === r.left && e.top === r.top || (C.set(n, S(e, r)), M.add(n), t = !0);
|
|
209
213
|
}
|
|
210
|
-
t && (k(), N && clearTimeout(N), N = setTimeout(() => void P(),
|
|
214
|
+
t && (k(), N && clearTimeout(N), N = setTimeout(() => void P(), f));
|
|
211
215
|
},
|
|
212
216
|
flush: P,
|
|
213
217
|
async copy(e, t) {
|
|
214
|
-
let n =
|
|
215
|
-
if (
|
|
218
|
+
let n = u(E, t);
|
|
219
|
+
if (g(E, n)) return [];
|
|
216
220
|
let r = [];
|
|
217
221
|
for (let t of e) {
|
|
218
|
-
let e =
|
|
219
|
-
if (!e ||
|
|
220
|
-
let i =
|
|
221
|
-
let r =
|
|
222
|
+
let e = l(E, t);
|
|
223
|
+
if (!e || s(t)) continue;
|
|
224
|
+
let i = o(e.kind) ? _(E, t) : [], a = /* @__PURE__ */ new Map(), c = async (e, t, n) => {
|
|
225
|
+
let r = p(), i = {
|
|
222
226
|
...e,
|
|
223
|
-
id:
|
|
224
|
-
name: n ?
|
|
227
|
+
id: h(),
|
|
228
|
+
name: n ? b(E, t, e.name, e.kind) : e.name,
|
|
225
229
|
parent: t,
|
|
226
230
|
createdAt: r,
|
|
227
231
|
modifiedAt: r
|
|
228
232
|
};
|
|
229
|
-
return n && (i =
|
|
233
|
+
return n && (i = S(i, null)), a.set(e.id, i.id), await j(i), await d(e.kind)?.copy?.(e, i), i;
|
|
230
234
|
};
|
|
231
|
-
r.push(await
|
|
232
|
-
for (let e of i) await
|
|
235
|
+
r.push(await c(e, n, !0));
|
|
236
|
+
for (let e of i) await c(e, a.get(u(E, e.parent) ?? "") ?? null, !1);
|
|
233
237
|
k();
|
|
234
238
|
}
|
|
235
239
|
return r;
|
|
236
240
|
},
|
|
237
241
|
async emptyTrash() {
|
|
238
|
-
let t =
|
|
242
|
+
let t = _(E, e);
|
|
239
243
|
for (let e of t) await A().remove(e.id), C.delete(e.id), M.delete(e.id), await d(e.kind)?.onRemove?.(e);
|
|
240
244
|
return t.length && k(), t;
|
|
241
245
|
},
|
|
242
246
|
trashSize() {
|
|
243
|
-
return
|
|
247
|
+
return _(E, e).reduce((e, t) => e + (d(t.kind)?.size?.(t) ?? 0), 0);
|
|
244
248
|
},
|
|
245
249
|
dump() {
|
|
246
250
|
return { items: [...C.values()] };
|
|
@@ -253,14 +257,14 @@ function x(n) {
|
|
|
253
257
|
}
|
|
254
258
|
},
|
|
255
259
|
async import(e, { mode: t = "merge" } = {}) {
|
|
256
|
-
let n = /* @__PURE__ */ new Map(),
|
|
257
|
-
if (!
|
|
258
|
-
let
|
|
259
|
-
for (let e of
|
|
260
|
-
let l = (e) => e == null ||
|
|
260
|
+
let n = /* @__PURE__ */ new Map(), i = e.items.filter((e) => e.id !== a && !s(e.id));
|
|
261
|
+
if (!i.length || !r) return n;
|
|
262
|
+
let o = t === "replace", c = /* @__PURE__ */ new Map();
|
|
263
|
+
for (let e of i) c.set(e.id, o ? e.id : h());
|
|
264
|
+
let l = (e) => e == null || s(e) ? e : c.get(e) ?? null;
|
|
261
265
|
try {
|
|
262
|
-
|
|
263
|
-
for (let e of
|
|
266
|
+
o && await I();
|
|
267
|
+
for (let e of i) {
|
|
264
268
|
let t = {
|
|
265
269
|
...e,
|
|
266
270
|
id: c.get(e.id),
|
|
@@ -279,7 +283,7 @@ function x(n) {
|
|
|
279
283
|
};
|
|
280
284
|
return L;
|
|
281
285
|
}
|
|
282
|
-
function
|
|
286
|
+
function w(e = []) {
|
|
283
287
|
let t = new Map(e.map((e) => [e.id, e]));
|
|
284
288
|
return {
|
|
285
289
|
records: t,
|
|
@@ -289,4 +293,4 @@ function S(e = []) {
|
|
|
289
293
|
};
|
|
290
294
|
}
|
|
291
295
|
//#endregion
|
|
292
|
-
export { t as DISK, n as FOLDER, e as TRASH,
|
|
296
|
+
export { r as APP_KIND, t as DISK, n as FOLDER, e as TRASH, i as UNTITLED_FOLDER, c as appIdOf, d as childrenOf, u as containerOf, b as copyName, C as createCatalog, _ as descendantsOf, h as enclosingFolders, o as isContainerKind, m as isInside, g as isTrashed, s as isVolume, f as itemCount, l as itemOf, w as memoryStorage, v as nextFolderName };
|