vintage-frames 0.16.1 → 0.17.0
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 +2 -0
- package/dist/build/app-file.d.ts +21 -0
- package/dist/build/app-file.js +41 -0
- package/dist/build/box.d.ts +55 -0
- package/dist/build/box.js +90 -0
- package/dist/build/client.d.ts +12 -0
- package/dist/build/frame-picture.d.ts +6 -0
- package/dist/build/frame-picture.js +4 -0
- package/dist/build/frame.d.ts +11 -0
- package/dist/build/frame.js +42 -0
- package/dist/build/index.d.ts +14 -0
- package/dist/build/index.js +4 -0
- package/dist/build/plugins.d.ts +40 -0
- package/dist/build/plugins.js +129 -0
- package/dist/build/png.d.ts +24 -0
- package/dist/build/png.js +116 -0
- package/dist/shell/app-file.d.ts +77 -0
- package/dist/shell/app-file.js +161 -0
- 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 +5 -2
- package/dist/shell/index.js +9 -7
- package/dist/shell/pure.d.ts +7 -4
- package/dist/shell/pure.js +6 -4
- package/dist/shell/shell.d.ts +0 -4
- package/dist/shell/shell.js +40 -44
- package/dist/shell/version.d.ts +2 -0
- package/dist/shell/version.js +4 -0
- package/dist/styles/body-strike.d.ts +12 -0
- package/dist/styles/body-strike.js +3961 -0
- package/dist/styles/display-strike.d.ts +12 -0
- package/dist/styles/display-strike.js +4343 -0
- package/dist/styles/strike.d.ts +30 -0
- package/editor/web-types.json +1 -1
- package/package.json +19 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App files: an application on the shell as one PNG. The picture is the
|
|
3
|
+
* application's box; two iTXt chunks before IEND carry its manifest, as
|
|
4
|
+
* JSON, and its code, one ES module compressed with zlib. Any PNG tool reads
|
|
5
|
+
* the chunks and any decoder skips them.
|
|
6
|
+
*
|
|
7
|
+
* This is the reading half, and checking a version against a range. It is
|
|
8
|
+
* pure and runs the same under Node and in a page, through the platform's
|
|
9
|
+
* compression streams. Writing an app file, and the box, are
|
|
10
|
+
* `vintage-frames/build`'s.
|
|
11
|
+
*/
|
|
12
|
+
/** The app file format this kit reads and writes. */
|
|
13
|
+
export declare const APP_FILE_FORMAT = 1;
|
|
14
|
+
/** The iTXt keywords of the manifest's chunk and the code's. */
|
|
15
|
+
export declare const MANIFEST_KEYWORD = "vintage-frames.app";
|
|
16
|
+
export declare const CODE_KEYWORD = "vintage-frames.code";
|
|
17
|
+
/** What an app file says about its application. */
|
|
18
|
+
export interface AppManifest {
|
|
19
|
+
/** The app file's own format, {@link APP_FILE_FORMAT}. */
|
|
20
|
+
format: number;
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
version: string;
|
|
24
|
+
/** The kit range the code was built and checked against: `^0.17.0`. */
|
|
25
|
+
requires: string;
|
|
26
|
+
author: string;
|
|
27
|
+
/** Its 32 × 32 icon: its PNG as a `data:` URL. */
|
|
28
|
+
icon: string;
|
|
29
|
+
}
|
|
30
|
+
/** An application, read from its app file. */
|
|
31
|
+
export interface AppFile {
|
|
32
|
+
manifest: AppManifest;
|
|
33
|
+
/** One ES module. Its default export is the application's factory. */
|
|
34
|
+
code: string;
|
|
35
|
+
}
|
|
36
|
+
/** The eight bytes every PNG starts with. */
|
|
37
|
+
export declare const PNG_SIGNATURE: Uint8Array<ArrayBuffer>;
|
|
38
|
+
/** The CRC-32 a PNG chunk ends with, over its type and data. */
|
|
39
|
+
export declare function crc32(bytes: Uint8Array): number;
|
|
40
|
+
/** One chunk of a PNG. */
|
|
41
|
+
export interface PngChunk {
|
|
42
|
+
type: string;
|
|
43
|
+
data: Uint8Array;
|
|
44
|
+
/** Where it sits in the file: its length's first byte, and the byte after its CRC. */
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A PNG's chunks, IEND last, or null when it isn't a whole PNG: the
|
|
50
|
+
* signature is wrong, a chunk runs past the end, a CRC doesn't match, or
|
|
51
|
+
* there is no IEND. Anything after IEND is left out.
|
|
52
|
+
*/
|
|
53
|
+
export declare function pngChunks(bytes: Uint8Array): PngChunk[] | null;
|
|
54
|
+
/** An iTXt chunk's keyword. */
|
|
55
|
+
export declare function itxtKeyword(data: Uint8Array): string;
|
|
56
|
+
/** zlib data, inflated. */
|
|
57
|
+
export declare function inflate(bytes: Uint8Array): Promise<Uint8Array>;
|
|
58
|
+
/** zlib data, deflated. */
|
|
59
|
+
export declare function deflate(bytes: Uint8Array): Promise<Uint8Array>;
|
|
60
|
+
/** A parsed manifest as one this kit reads, or what is wrong with it. */
|
|
61
|
+
export declare function manifestOf(json: unknown): AppManifest | string;
|
|
62
|
+
/**
|
|
63
|
+
* The manifest and code an app file carries, or why it isn't one: not a
|
|
64
|
+
* whole PNG, a chunk missing or doubled, a format this kit doesn't read, a
|
|
65
|
+
* field missing, or code that doesn't inflate.
|
|
66
|
+
*/
|
|
67
|
+
export declare function inspectAppFile(bytes: Uint8Array): Promise<AppFile | string>;
|
|
68
|
+
/** The manifest and code an app file carries, or null for any other PNG. */
|
|
69
|
+
export declare function readAppFile(bytes: Uint8Array): Promise<AppFile | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Whether `version` meets `range`: an exact version, or a caret range as
|
|
72
|
+
* npm reads it. `^1.2.3` takes 1.x from 1.2.3 on, `^0.2.3` takes 0.2.x from
|
|
73
|
+
* 0.2.3 on, and `^0.0.3` takes 0.0.3 alone. A prerelease meets a range only
|
|
74
|
+
* when the range names a prerelease of the same version. Anything else is
|
|
75
|
+
* false.
|
|
76
|
+
*/
|
|
77
|
+
export declare function satisfies(version: string, range: string): boolean;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
//#region src/shell/app-file.ts
|
|
2
|
+
var e = 1, t = "vintage-frames.app", n = "vintage-frames.code", r = [
|
|
3
|
+
"id",
|
|
4
|
+
"name",
|
|
5
|
+
"version",
|
|
6
|
+
"requires",
|
|
7
|
+
"author",
|
|
8
|
+
"icon"
|
|
9
|
+
], i = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10), a = Uint32Array.from({ length: 256 }, (e, t) => {
|
|
10
|
+
let n = t;
|
|
11
|
+
for (let e = 0; e < 8; e++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
|
|
12
|
+
return n >>> 0;
|
|
13
|
+
});
|
|
14
|
+
function o(e) {
|
|
15
|
+
let t = 4294967295;
|
|
16
|
+
for (let n of e) t = a[(t ^ n) & 255] ^ t >>> 8;
|
|
17
|
+
return (t ^ 4294967295) >>> 0;
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
if (e.length < 8 || i.some((t, n) => e[n] !== t)) return null;
|
|
21
|
+
let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = [], r = 8;
|
|
22
|
+
for (; r + 12 <= e.length;) {
|
|
23
|
+
let i = r + 12 + t.getUint32(r);
|
|
24
|
+
if (i > e.length || o(e.subarray(r + 4, i - 4)) !== t.getUint32(i - 4)) return null;
|
|
25
|
+
let a = String.fromCharCode(...e.subarray(r + 4, r + 8));
|
|
26
|
+
if (n.push({
|
|
27
|
+
type: a,
|
|
28
|
+
data: e.subarray(r + 8, i - 4),
|
|
29
|
+
start: r,
|
|
30
|
+
end: i
|
|
31
|
+
}), a === "IEND") return n;
|
|
32
|
+
r = i;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function c(e) {
|
|
37
|
+
let t = e.indexOf(0);
|
|
38
|
+
return t > 0 ? String.fromCharCode(...e.subarray(0, t)) : "";
|
|
39
|
+
}
|
|
40
|
+
var l = new TextDecoder("utf-8", { fatal: !0 });
|
|
41
|
+
async function u(e) {
|
|
42
|
+
let t = e.indexOf(0), n = e[t + 1], r = e[t + 2], i = e.indexOf(0, t + 3), a = i < 0 ? -1 : e.indexOf(0, i + 1);
|
|
43
|
+
if (t < 1 || a < 0 || n > 1 || r !== 0) throw Error("a broken iTXt chunk");
|
|
44
|
+
let o = e.subarray(a + 1);
|
|
45
|
+
return l.decode(n ? await d(o) : o);
|
|
46
|
+
}
|
|
47
|
+
async function d(e) {
|
|
48
|
+
let t = new Blob([e.slice()]).stream().pipeThrough(new DecompressionStream("deflate"));
|
|
49
|
+
return new Uint8Array(await new Response(t).arrayBuffer());
|
|
50
|
+
}
|
|
51
|
+
async function f(e) {
|
|
52
|
+
let t = new Blob([e.slice()]).stream().pipeThrough(new CompressionStream("deflate"));
|
|
53
|
+
return new Uint8Array(await new Response(t).arrayBuffer());
|
|
54
|
+
}
|
|
55
|
+
function p(e) {
|
|
56
|
+
if (!e || typeof e != "object") return "its manifest is not an object";
|
|
57
|
+
let t = e;
|
|
58
|
+
if (t.format !== 1) return typeof t.format == "number" ? `it is format ${t.format}, and this kit reads format 1` : "its manifest has no format";
|
|
59
|
+
let n = {
|
|
60
|
+
format: 1,
|
|
61
|
+
id: "",
|
|
62
|
+
name: "",
|
|
63
|
+
version: "",
|
|
64
|
+
requires: "",
|
|
65
|
+
author: "",
|
|
66
|
+
icon: ""
|
|
67
|
+
};
|
|
68
|
+
for (let e of r) {
|
|
69
|
+
let r = t[e];
|
|
70
|
+
if (typeof r != "string" || !r) return `its manifest has no ${e}`;
|
|
71
|
+
n[e] = r;
|
|
72
|
+
}
|
|
73
|
+
return n;
|
|
74
|
+
}
|
|
75
|
+
async function m(e) {
|
|
76
|
+
let r = s(e);
|
|
77
|
+
if (!r) return "it is not a whole PNG";
|
|
78
|
+
let i = /* @__PURE__ */ new Map();
|
|
79
|
+
for (let { type: e, data: t } of r) {
|
|
80
|
+
if (e !== "iTXt") continue;
|
|
81
|
+
let n = c(t);
|
|
82
|
+
if (n === "vintage-frames.app" || n === "vintage-frames.code") {
|
|
83
|
+
if (i.has(n)) return `it has two ${n} chunks`;
|
|
84
|
+
i.set(n, t);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let a = i.get(t), o = i.get(n);
|
|
88
|
+
if (!a && !o) return "it carries no application";
|
|
89
|
+
if (!a) return "its manifest is missing";
|
|
90
|
+
if (!o) return "its code is missing";
|
|
91
|
+
let l;
|
|
92
|
+
try {
|
|
93
|
+
l = JSON.parse(await u(a));
|
|
94
|
+
} catch {
|
|
95
|
+
return "its manifest does not read";
|
|
96
|
+
}
|
|
97
|
+
let d = p(l);
|
|
98
|
+
if (typeof d == "string") return d;
|
|
99
|
+
try {
|
|
100
|
+
return {
|
|
101
|
+
manifest: d,
|
|
102
|
+
code: await u(o)
|
|
103
|
+
};
|
|
104
|
+
} catch {
|
|
105
|
+
return "its code does not inflate";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function h(e) {
|
|
109
|
+
let t = await m(e);
|
|
110
|
+
return typeof t == "string" ? null : t;
|
|
111
|
+
}
|
|
112
|
+
var g = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
113
|
+
function _(e) {
|
|
114
|
+
let t = g.exec(e.trim());
|
|
115
|
+
return t ? {
|
|
116
|
+
core: [
|
|
117
|
+
Number(t[1]),
|
|
118
|
+
Number(t[2]),
|
|
119
|
+
Number(t[3])
|
|
120
|
+
],
|
|
121
|
+
pre: t[4] ? t[4].split(".") : []
|
|
122
|
+
} : null;
|
|
123
|
+
}
|
|
124
|
+
function v(e, t) {
|
|
125
|
+
for (let n = 0; n < 3; n++) if (e.core[n] !== t.core[n]) return e.core[n] - t.core[n];
|
|
126
|
+
if (!e.pre.length || !t.pre.length) return t.pre.length - e.pre.length;
|
|
127
|
+
for (let n = 0; n < Math.max(e.pre.length, t.pre.length); n++) {
|
|
128
|
+
let r = e.pre[n], i = t.pre[n];
|
|
129
|
+
if (r === void 0) return -1;
|
|
130
|
+
if (i === void 0) return 1;
|
|
131
|
+
if (r === i) continue;
|
|
132
|
+
let a = /^\d+$/.test(r), o = /^\d+$/.test(i);
|
|
133
|
+
return a && o ? Number(r) - Number(i) : a === o ? r < i ? -1 : 1 : a ? -1 : 1;
|
|
134
|
+
}
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
function y(e, t) {
|
|
138
|
+
let n = t.trim().startsWith("^"), r = _(e), i = _(n ? t.trim().slice(1) : t);
|
|
139
|
+
if (!r || !i) return !1;
|
|
140
|
+
if (!n) return v(r, i) === 0;
|
|
141
|
+
if (r.pre.length && !(i.pre.length && r.core.every((e, t) => e === i.core[t]))) return !1;
|
|
142
|
+
let [a, o, s] = i.core, c = {
|
|
143
|
+
core: a ? [
|
|
144
|
+
a + 1,
|
|
145
|
+
0,
|
|
146
|
+
0
|
|
147
|
+
] : o ? [
|
|
148
|
+
0,
|
|
149
|
+
o + 1,
|
|
150
|
+
0
|
|
151
|
+
] : [
|
|
152
|
+
0,
|
|
153
|
+
0,
|
|
154
|
+
s + 1
|
|
155
|
+
],
|
|
156
|
+
pre: []
|
|
157
|
+
};
|
|
158
|
+
return v(r, i) >= 0 && v(r, c) < 0;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { e as APP_FILE_FORMAT, n as CODE_KEYWORD, t as MANIFEST_KEYWORD, i as PNG_SIGNATURE, o as crc32, f as deflate, d as inflate, m as inspectAppFile, c as itxtKeyword, p as manifestOf, s as pngChunks, h as readAppFile, y as satisfies };
|
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 };
|