vintage-frames 0.19.1 → 0.20.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 -18
- package/custom-elements.json +72 -13
- package/dist/components/vf-desktop.d.ts +36 -6
- package/dist/components/vf-desktop.js +41 -23
- package/dist/components/vf-window.d.ts +19 -0
- package/dist/components/vf-window.js +33 -3
- package/dist/text-control.d.ts +3 -3
- package/docs/SPEC.md +8 -6
- package/editor/vscode.html-custom-data.json +10 -5
- package/editor/web-types.json +25 -10
- package/package.json +4 -34
- package/dist/build/app-file.d.ts +0 -21
- package/dist/build/app-file.js +0 -42
- package/dist/build/box.d.ts +0 -57
- package/dist/build/box.js +0 -93
- package/dist/build/client.d.ts +0 -12
- package/dist/build/frame-picture.d.ts +0 -6
- package/dist/build/frame-picture.js +0 -4
- package/dist/build/frame.d.ts +0 -11
- package/dist/build/frame.js +0 -44
- package/dist/build/index.d.ts +0 -14
- package/dist/build/index.js +0 -4
- package/dist/build/plugins.d.ts +0 -41
- package/dist/build/plugins.js +0 -134
- package/dist/build/png.d.ts +0 -24
- package/dist/build/png.js +0 -116
- package/dist/shell/alert.d.ts +0 -40
- package/dist/shell/alert.js +0 -41
- package/dist/shell/app-file.d.ts +0 -115
- package/dist/shell/app-file.js +0 -189
- package/dist/shell/catalog.d.ts +0 -250
- package/dist/shell/catalog.js +0 -349
- package/dist/shell/clock.d.ts +0 -16
- package/dist/shell/clock.js +0 -36
- package/dist/shell/filing.d.ts +0 -39
- package/dist/shell/filing.js +0 -68
- package/dist/shell/finder.d.ts +0 -180
- package/dist/shell/finder.js +0 -676
- package/dist/shell/geometry.d.ts +0 -203
- package/dist/shell/geometry.js +0 -257
- package/dist/shell/index.d.ts +0 -30
- package/dist/shell/index.js +0 -12
- package/dist/shell/pure.d.ts +0 -13
- package/dist/shell/pure.js +0 -6
- package/dist/shell/shell.d.ts +0 -177
- package/dist/shell/shell.js +0 -277
- package/dist/shell/state.d.ts +0 -88
- package/dist/shell/state.js +0 -103
- package/dist/shell/storage.d.ts +0 -14
- package/dist/shell/storage.js +0 -41
- package/dist/shell/version.d.ts +0 -2
- package/dist/shell/version.js +0 -4
- package/dist/shell/windows.d.ts +0 -278
- package/dist/shell/windows.js +0 -447
- package/dist/styles/body-strike.d.ts +0 -12
- package/dist/styles/body-strike.js +0 -3961
- package/dist/styles/display-strike.d.ts +0 -12
- package/dist/styles/display-strike.js +0 -4343
- package/dist/styles/strike.d.ts +0 -30
package/dist/shell/alert.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { effectiveScale as e } from "../scale.js";
|
|
2
|
-
import "../index.js";
|
|
3
|
-
//#region src/shell/alert.ts
|
|
4
|
-
var t = 10, n = 16, r = 32, i = 28;
|
|
5
|
-
function a(a, o = {}) {
|
|
6
|
-
let { buttons: s = [{
|
|
7
|
-
label: "OK",
|
|
8
|
-
value: "ok",
|
|
9
|
-
default: !0
|
|
10
|
-
}], width: c = 400, art: l = null, label: u = "Alert" } = o, d = document.createElement("vf-dialog");
|
|
11
|
-
d.frame = "plain", d.label = u, d.width = c, d.height = 120;
|
|
12
|
-
let f = document.createElement("form");
|
|
13
|
-
f.method = "dialog", f.noValidate = !0;
|
|
14
|
-
let p = l ? 64 : n;
|
|
15
|
-
if (l) {
|
|
16
|
-
let e = document.createElement("vf-img");
|
|
17
|
-
e.width = r, e.height = r, e.left = n, e.top = n;
|
|
18
|
-
let t = document.createElement("img");
|
|
19
|
-
t.src = l, t.alt = "", e.append(t), f.append(e);
|
|
20
|
-
}
|
|
21
|
-
let m = document.createElement("vf-paragraph");
|
|
22
|
-
m.face = "display", m.width = c - t - p - n, m.left = p, m.top = n, m.textContent = a, f.append(m);
|
|
23
|
-
let h = document.createElement("vf-button-group");
|
|
24
|
-
return h.origin = "bottom right", h.append(...s.map((e) => {
|
|
25
|
-
let t = document.createElement("vf-button");
|
|
26
|
-
return t.textContent = e.label, t.type = "submit", t.value = e.value, e.default && (t.variant = "default"), t;
|
|
27
|
-
})), f.append(h), d.append(f), {
|
|
28
|
-
dialog: d,
|
|
29
|
-
rendered: () => Promise.all([
|
|
30
|
-
d.updateComplete,
|
|
31
|
-
m.updateComplete,
|
|
32
|
-
h.updateComplete
|
|
33
|
-
]),
|
|
34
|
-
fit() {
|
|
35
|
-
let r = Math.ceil(m.getBoundingClientRect().height / e(m)), a = Math.max(l ? 48 : 0, n + r) + n + i + n;
|
|
36
|
-
d.height = a + t, h.left = c - t - n, h.top = a - n;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
export { a as composeAlert };
|
package/dist/shell/app-file.d.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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: the reader, checking a version against a range,
|
|
8
|
-
* putting versions in order, the app API levels and whether this kit runs an
|
|
9
|
-
* application, and the scale every box is drawn at. It is pure and runs the
|
|
10
|
-
* same under Node and in a page, through the platform's compression streams.
|
|
11
|
-
* Writing an app file, and the box, are `vintage-frames/build`'s.
|
|
12
|
-
*/
|
|
13
|
-
/** The app file format this kit reads and writes. */
|
|
14
|
-
export declare const APP_FILE_FORMAT = 1;
|
|
15
|
-
/**
|
|
16
|
-
* The app API this kit provides: the level of what a built application can
|
|
17
|
-
* use of it. It goes up when something in it changes or goes away, and never
|
|
18
|
-
* for an addition. app-api.json lists what it covers.
|
|
19
|
-
*/
|
|
20
|
-
export declare const APP_API = 2;
|
|
21
|
-
/** The oldest app API this kit still runs. */
|
|
22
|
-
export declare const APP_API_OLDEST = 2;
|
|
23
|
-
/**
|
|
24
|
-
* One system px of an app file's box, in its picture's px: every box of
|
|
25
|
-
* this format is drawn at 3×, each system px a 3 × 3 block.
|
|
26
|
-
*/
|
|
27
|
-
export declare const BOX_SCALE = 3;
|
|
28
|
-
/** The iTXt keywords of the manifest's chunk and the code's. */
|
|
29
|
-
export declare const MANIFEST_KEYWORD = "vintage-frames.app";
|
|
30
|
-
export declare const CODE_KEYWORD = "vintage-frames.code";
|
|
31
|
-
/** What an app file says about its application. */
|
|
32
|
-
export interface AppManifest {
|
|
33
|
-
/** The app file's own format, {@link APP_FILE_FORMAT}. */
|
|
34
|
-
format: number;
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
version: string;
|
|
38
|
-
/** The kit range the code was built and checked against: `^0.17.0`. */
|
|
39
|
-
requires: string;
|
|
40
|
-
/** The app API the code was built against, {@link APP_API}. A file from before levels has none. */
|
|
41
|
-
api?: number;
|
|
42
|
-
author: string;
|
|
43
|
-
/** What the application is, in a sentence or two of plain text. */
|
|
44
|
-
description?: string;
|
|
45
|
-
/** Its 32 × 32 icon: its PNG as a `data:` URL. */
|
|
46
|
-
icon: string;
|
|
47
|
-
}
|
|
48
|
-
/** An application, read from its app file. */
|
|
49
|
-
export interface AppFile {
|
|
50
|
-
manifest: AppManifest;
|
|
51
|
-
/** One ES module. Its default export is the application's factory. */
|
|
52
|
-
code: string;
|
|
53
|
-
}
|
|
54
|
-
/** The eight bytes every PNG starts with. */
|
|
55
|
-
export declare const PNG_SIGNATURE: Uint8Array<ArrayBuffer>;
|
|
56
|
-
/** The CRC-32 a PNG chunk ends with, over its type and data. */
|
|
57
|
-
export declare function crc32(bytes: Uint8Array): number;
|
|
58
|
-
/** One chunk of a PNG. */
|
|
59
|
-
export interface PngChunk {
|
|
60
|
-
type: string;
|
|
61
|
-
data: Uint8Array;
|
|
62
|
-
/** Where it sits in the file: its length's first byte, and the byte after its CRC. */
|
|
63
|
-
start: number;
|
|
64
|
-
end: number;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A PNG's chunks, IEND last, or null when it isn't a whole PNG: the
|
|
68
|
-
* signature is wrong, a chunk runs past the end, a CRC doesn't match, or
|
|
69
|
-
* there is no IEND. Anything after IEND is left out.
|
|
70
|
-
*/
|
|
71
|
-
export declare function pngChunks(bytes: Uint8Array): PngChunk[] | null;
|
|
72
|
-
/** An iTXt chunk's keyword. */
|
|
73
|
-
export declare function itxtKeyword(data: Uint8Array): string;
|
|
74
|
-
/** zlib data, inflated. */
|
|
75
|
-
export declare function inflate(bytes: Uint8Array): Promise<Uint8Array>;
|
|
76
|
-
/** zlib data, deflated. */
|
|
77
|
-
export declare function deflate(bytes: Uint8Array): Promise<Uint8Array>;
|
|
78
|
-
/** A parsed manifest as one this kit reads, or what is wrong with it. */
|
|
79
|
-
export declare function manifestOf(json: unknown): AppManifest | string;
|
|
80
|
-
/**
|
|
81
|
-
* The manifest and code an app file carries, or why it isn't one: not a
|
|
82
|
-
* whole PNG, a chunk missing or doubled, a format this kit doesn't read, a
|
|
83
|
-
* field missing or unreadable, or code that doesn't inflate. The reason ends
|
|
84
|
-
* a sentence such as "Meteors.png is not an app file: …", and is for people:
|
|
85
|
-
* its wording can change in any release, so match on nothing in it.
|
|
86
|
-
*/
|
|
87
|
-
export declare function inspectAppFile(bytes: Uint8Array): Promise<AppFile | string>;
|
|
88
|
-
/** The manifest and code an app file carries, or null for any other PNG. */
|
|
89
|
-
export declare function readAppFile(bytes: Uint8Array): Promise<AppFile | null>;
|
|
90
|
-
/**
|
|
91
|
-
* Whether `text` is a version exactly as semver writes one: `0.1.0`,
|
|
92
|
-
* `1.0.0-rc.1`, but not `v0.1.0`, ` 0.1.0` or `01.2.3`.
|
|
93
|
-
*/
|
|
94
|
-
export declare function isVersion(text: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Below zero, zero or above as version `a` comes before, with or after `b`,
|
|
97
|
-
* in semver's order: a release after its prereleases, build metadata
|
|
98
|
-
* ignored. Anything that isn't a version, a string or not, comes before
|
|
99
|
-
* every version, so a sort never throws.
|
|
100
|
-
*/
|
|
101
|
-
export declare function compareVersions(a: string, b: string): number;
|
|
102
|
-
/**
|
|
103
|
-
* Whether `version` meets `range`: an exact version, or a caret range as
|
|
104
|
-
* npm reads it. `^1.2.3` takes 1.x from 1.2.3 on, `^0.2.3` takes 0.2.x from
|
|
105
|
-
* 0.2.3 on, and `^0.0.3` takes 0.0.3 alone. A prerelease meets a range only
|
|
106
|
-
* when the range names a prerelease of the same version. Anything else is
|
|
107
|
-
* false.
|
|
108
|
-
*/
|
|
109
|
-
export declare function satisfies(version: string, range: string): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Whether this kit runs the application a manifest describes: one built at
|
|
112
|
-
* an app API from {@link APP_API_OLDEST} to {@link APP_API}, or, for a file
|
|
113
|
-
* from before levels, one whose `requires` this kit's version meets.
|
|
114
|
-
*/
|
|
115
|
-
export declare function appRuns(manifest: Pick<AppManifest, 'requires' | 'api'>): boolean;
|
package/dist/shell/app-file.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { VERSION as e } from "./version.js";
|
|
2
|
-
//#region src/shell/app-file.ts
|
|
3
|
-
var t = 1, n = 2, r = 2, i = 3, a = "vintage-frames.app", o = "vintage-frames.code", s = [
|
|
4
|
-
"id",
|
|
5
|
-
"name",
|
|
6
|
-
"version",
|
|
7
|
-
"requires",
|
|
8
|
-
"api",
|
|
9
|
-
"author",
|
|
10
|
-
"description",
|
|
11
|
-
"icon"
|
|
12
|
-
], c = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10), l = Uint32Array.from({ length: 256 }, (e, t) => {
|
|
13
|
-
let n = t;
|
|
14
|
-
for (let e = 0; e < 8; e++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
|
|
15
|
-
return n >>> 0;
|
|
16
|
-
});
|
|
17
|
-
function u(e) {
|
|
18
|
-
let t = 4294967295;
|
|
19
|
-
for (let n of e) t = l[(t ^ n) & 255] ^ t >>> 8;
|
|
20
|
-
return (t ^ 4294967295) >>> 0;
|
|
21
|
-
}
|
|
22
|
-
function d(e) {
|
|
23
|
-
if (e.length < 8 || c.some((t, n) => e[n] !== t)) return null;
|
|
24
|
-
let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = [], r = 8;
|
|
25
|
-
for (; r + 12 <= e.length;) {
|
|
26
|
-
let i = r + 12 + t.getUint32(r);
|
|
27
|
-
if (i > e.length || u(e.subarray(r + 4, i - 4)) !== t.getUint32(i - 4)) return null;
|
|
28
|
-
let a = String.fromCharCode(...e.subarray(r + 4, r + 8));
|
|
29
|
-
if (n.push({
|
|
30
|
-
type: a,
|
|
31
|
-
data: e.subarray(r + 8, i - 4),
|
|
32
|
-
start: r,
|
|
33
|
-
end: i
|
|
34
|
-
}), a === "IEND") return n;
|
|
35
|
-
r = i;
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
function f(e) {
|
|
40
|
-
let t = e.indexOf(0);
|
|
41
|
-
return t > 0 ? String.fromCharCode(...e.subarray(0, t)) : "";
|
|
42
|
-
}
|
|
43
|
-
var p = new TextDecoder("utf-8", { fatal: !0 });
|
|
44
|
-
async function m(e) {
|
|
45
|
-
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);
|
|
46
|
-
if (t < 1 || a < 0 || n > 1 || r !== 0) throw Error("a broken iTXt chunk");
|
|
47
|
-
let o = e.subarray(a + 1);
|
|
48
|
-
return p.decode(n ? await h(o) : o);
|
|
49
|
-
}
|
|
50
|
-
async function h(e) {
|
|
51
|
-
let t = new Blob([e.slice()]).stream().pipeThrough(new DecompressionStream("deflate"));
|
|
52
|
-
return new Uint8Array(await new Response(t).arrayBuffer());
|
|
53
|
-
}
|
|
54
|
-
async function g(e) {
|
|
55
|
-
let t = new Blob([e.slice()]).stream().pipeThrough(new CompressionStream("deflate"));
|
|
56
|
-
return new Uint8Array(await new Response(t).arrayBuffer());
|
|
57
|
-
}
|
|
58
|
-
function _(e) {
|
|
59
|
-
if (!e || typeof e != "object") return "its manifest is not an object";
|
|
60
|
-
let t = e;
|
|
61
|
-
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";
|
|
62
|
-
let n = { format: 1 };
|
|
63
|
-
for (let e of s) {
|
|
64
|
-
let r = t[e];
|
|
65
|
-
if (e === "api") {
|
|
66
|
-
if (r === void 0) continue;
|
|
67
|
-
if (!Number.isInteger(r) || r < 1) return `its api, ${JSON.stringify(r)}, is not a level`;
|
|
68
|
-
n.api = r;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (e === "description") {
|
|
72
|
-
if (r !== void 0 && typeof r != "string") return "its description is not text";
|
|
73
|
-
typeof r == "string" && r.trim() && (n.description = r);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (typeof r != "string" || !r) return `its manifest has no ${e}`;
|
|
77
|
-
if (e === "version" && !S(r)) return `its version, ${r}, is not a version`;
|
|
78
|
-
if (e === "requires" && !C(r)) return `its requires, ${r}, is not a range`;
|
|
79
|
-
n[e] = r;
|
|
80
|
-
}
|
|
81
|
-
return n;
|
|
82
|
-
}
|
|
83
|
-
async function v(e) {
|
|
84
|
-
let t = d(e);
|
|
85
|
-
if (!t) return "it is not a whole PNG";
|
|
86
|
-
let n = /* @__PURE__ */ new Map();
|
|
87
|
-
for (let { type: e, data: r } of t) {
|
|
88
|
-
if (e !== "iTXt") continue;
|
|
89
|
-
let t = f(r);
|
|
90
|
-
if (t === "vintage-frames.app" || t === "vintage-frames.code") {
|
|
91
|
-
if (n.has(t)) return `it has two ${t} chunks`;
|
|
92
|
-
n.set(t, r);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
let r = n.get(a), i = n.get(o);
|
|
96
|
-
if (!r && !i) return "it carries no application";
|
|
97
|
-
if (!r) return "its manifest is missing";
|
|
98
|
-
if (!i) return "its code is missing";
|
|
99
|
-
let s;
|
|
100
|
-
try {
|
|
101
|
-
s = JSON.parse(await m(r));
|
|
102
|
-
} catch {
|
|
103
|
-
return "its manifest does not read";
|
|
104
|
-
}
|
|
105
|
-
let c = _(s);
|
|
106
|
-
if (typeof c == "string") return c;
|
|
107
|
-
try {
|
|
108
|
-
return {
|
|
109
|
-
manifest: c,
|
|
110
|
-
code: await m(i)
|
|
111
|
-
};
|
|
112
|
-
} catch {
|
|
113
|
-
return "its code does not inflate";
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function y(e) {
|
|
117
|
-
let t = await v(e);
|
|
118
|
-
return typeof t == "string" ? null : t;
|
|
119
|
-
}
|
|
120
|
-
var b = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
121
|
-
function x(e) {
|
|
122
|
-
if (typeof e != "string") return null;
|
|
123
|
-
let t = b.exec(e.trim().replace(/^v/, ""));
|
|
124
|
-
return t ? {
|
|
125
|
-
core: [
|
|
126
|
-
Number(t[1]),
|
|
127
|
-
Number(t[2]),
|
|
128
|
-
Number(t[3])
|
|
129
|
-
],
|
|
130
|
-
pre: t[4] ? t[4].split(".") : []
|
|
131
|
-
} : null;
|
|
132
|
-
}
|
|
133
|
-
function S(e) {
|
|
134
|
-
return b.test(e);
|
|
135
|
-
}
|
|
136
|
-
function C(e) {
|
|
137
|
-
return S(e.startsWith("^") ? e.slice(1) : e);
|
|
138
|
-
}
|
|
139
|
-
function w(e) {
|
|
140
|
-
if (typeof e != "string") return null;
|
|
141
|
-
let t = e.trim();
|
|
142
|
-
return x(t.startsWith("^") ? t.slice(1) : t);
|
|
143
|
-
}
|
|
144
|
-
function T(e, t) {
|
|
145
|
-
for (let n = 0; n < 3; n++) if (e.core[n] !== t.core[n]) return e.core[n] - t.core[n];
|
|
146
|
-
if (!e.pre.length || !t.pre.length) return t.pre.length - e.pre.length;
|
|
147
|
-
for (let n = 0; n < Math.max(e.pre.length, t.pre.length); n++) {
|
|
148
|
-
let r = e.pre[n], i = t.pre[n];
|
|
149
|
-
if (r === void 0) return -1;
|
|
150
|
-
if (i === void 0) return 1;
|
|
151
|
-
if (r === i) continue;
|
|
152
|
-
let a = /^\d+$/.test(r), o = /^\d+$/.test(i);
|
|
153
|
-
return a && o ? Number(r) - Number(i) : a === o ? r < i ? -1 : 1 : a ? -1 : 1;
|
|
154
|
-
}
|
|
155
|
-
return 0;
|
|
156
|
-
}
|
|
157
|
-
function E(e, t) {
|
|
158
|
-
let n = x(e), r = x(t);
|
|
159
|
-
return n && r ? T(n, r) : !!n - +!!r;
|
|
160
|
-
}
|
|
161
|
-
function D(e, t) {
|
|
162
|
-
let n = x(e), r = w(t);
|
|
163
|
-
if (!n || !r) return !1;
|
|
164
|
-
if (!t.trim().startsWith("^")) return T(n, r) === 0;
|
|
165
|
-
if (n.pre.length && !(r.pre.length && n.core.every((e, t) => e === r.core[t]))) return !1;
|
|
166
|
-
let [i, a, o] = r.core, s = {
|
|
167
|
-
core: i ? [
|
|
168
|
-
i + 1,
|
|
169
|
-
0,
|
|
170
|
-
0
|
|
171
|
-
] : a ? [
|
|
172
|
-
0,
|
|
173
|
-
a + 1,
|
|
174
|
-
0
|
|
175
|
-
] : [
|
|
176
|
-
0,
|
|
177
|
-
0,
|
|
178
|
-
o + 1
|
|
179
|
-
],
|
|
180
|
-
pre: []
|
|
181
|
-
};
|
|
182
|
-
return T(n, r) >= 0 && T(n, s) < 0;
|
|
183
|
-
}
|
|
184
|
-
function O(t) {
|
|
185
|
-
let { api: n } = t;
|
|
186
|
-
return n === void 0 ? D(e, t.requires) : Number.isInteger(n) && n >= 2 && n <= 2;
|
|
187
|
-
}
|
|
188
|
-
//#endregion
|
|
189
|
-
export { n as APP_API, r as APP_API_OLDEST, t as APP_FILE_FORMAT, i as BOX_SCALE, o as CODE_KEYWORD, a as MANIFEST_KEYWORD, c as PNG_SIGNATURE, O as appRuns, E as compareVersions, u as crc32, g as deflate, h as inflate, v as inspectAppFile, S as isVersion, f as itxtKeyword, _ as manifestOf, d as pngChunks, y as readAppFile, D as satisfies };
|
package/dist/shell/catalog.d.ts
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The catalog: what is where. Pure and DOM-free — it runs under Node — and
|
|
3
|
-
* the source of truth for what a folder holds; the Finder renders it.
|
|
4
|
-
*
|
|
5
|
-
* - An item is a small record: a name, a kind, the container it sits in
|
|
6
|
-
* (`parent`, a folder's id, or null for the desktop) and, once placed, its
|
|
7
|
-
* position there in whole system px. A kind keeps small data of its own in
|
|
8
|
-
* `data`; a large payload stays in its application's own store, keyed by
|
|
9
|
-
* the item's id, and the kind's `copy` and `onRemove` keep that store in
|
|
10
|
-
* step.
|
|
11
|
-
* - Volumes are containers no one made: the Trash and a startup disk, each
|
|
12
|
-
* if the page wants one. They lead the listing, keep their names, and are
|
|
13
|
-
* never renamed, moved, copied or removed; nothing is made in the Trash.
|
|
14
|
-
* Deleting is a move into the Trash, and only Empty Trash removes. A
|
|
15
|
-
* volume's position is stored on a record of its own id.
|
|
16
|
-
* - The System Folder is kept the same way when the site names it: a folder
|
|
17
|
-
* on the startup disk (the desktop without one) holding Apple Menu Items
|
|
18
|
-
* and Startup Items, listed after the volumes. What they hold is anyone's,
|
|
19
|
-
* and the shell reads it: the Apple menu, and what opens at startup.
|
|
20
|
-
* - An alias stands for another item: its data names the original's id and
|
|
21
|
-
* kind, and `resolve` finds the original wherever it moved, until it is
|
|
22
|
-
* removed. An alias of a container takes a drop for its original, and
|
|
23
|
-
* keeps taking one, to say so, once the original is gone.
|
|
24
|
-
* - A folder never goes into itself or a folder inside it. A parent with no
|
|
25
|
-
* record reads as the desktop.
|
|
26
|
-
* - An item whose kind no application registers is left out of the listing
|
|
27
|
-
* and kept in storage.
|
|
28
|
-
* - Storage is three calls over item records (list, put, remove). The
|
|
29
|
-
* catalog holds every record in memory, writes through to storage, and
|
|
30
|
-
* lists from memory; a position change writes after a short delay, since
|
|
31
|
-
* the resize rule moves every desktop icon on each resize event.
|
|
32
|
-
* - A seed runs once per storage: a persistent one stores a marker record
|
|
33
|
-
* (`#seeded`), so a site that starts in memory and switches its storage
|
|
34
|
-
* seeds once there.
|
|
35
|
-
*/
|
|
36
|
-
import type { Point } from './geometry.js';
|
|
37
|
-
/** The Trash's id. */
|
|
38
|
-
export declare const TRASH = "trash";
|
|
39
|
-
/** The startup disk's id. */
|
|
40
|
-
export declare const DISK = "disk";
|
|
41
|
-
/** The System Folder's id: kept on the startup disk when the site names it. */
|
|
42
|
-
export declare const SYSTEM_FOLDER = "system-folder";
|
|
43
|
-
/** Apple Menu Items' id, in the System Folder: what it holds is the Apple menu. */
|
|
44
|
-
export declare const APPLE_MENU_ITEMS = "apple-menu-items";
|
|
45
|
-
/** Startup Items' id, in the System Folder: what it holds opens at startup. */
|
|
46
|
-
export declare const STARTUP_ITEMS = "startup-items";
|
|
47
|
-
/** A folder's kind. */
|
|
48
|
-
export declare const FOLDER = "folder";
|
|
49
|
-
/** An application's icon: the kind the shell registers, whose data names the application it opens. */
|
|
50
|
-
export declare const APP_KIND = "app";
|
|
51
|
-
/** An alias: the kind the shell registers, whose data names the item it stands for. */
|
|
52
|
-
export declare const ALIAS_KIND = "alias";
|
|
53
|
-
/** The name a new folder takes, counted up where it is taken. */
|
|
54
|
-
export declare const UNTITLED_FOLDER = "untitled folder";
|
|
55
|
-
/** One item of the catalog. */
|
|
56
|
-
export interface Item {
|
|
57
|
-
id: string;
|
|
58
|
-
name: string;
|
|
59
|
-
/** `folder`, a volume's (`trash`, `disk`), the shell's `app` or `alias`, or a kind an application registers. */
|
|
60
|
-
kind: string;
|
|
61
|
-
/** A folder's id, a volume's, or null for the desktop. */
|
|
62
|
-
parent: string | null;
|
|
63
|
-
/** Its place in its container, whole system px; unset, the next free cell. */
|
|
64
|
-
left?: number;
|
|
65
|
-
top?: number;
|
|
66
|
-
createdAt: number;
|
|
67
|
-
modifiedAt: number;
|
|
68
|
-
/** The kind's own, small and serializable. */
|
|
69
|
-
data?: unknown;
|
|
70
|
-
}
|
|
71
|
-
/** The listing: volumes first, then every listed item by creation. */
|
|
72
|
-
export interface CatalogState {
|
|
73
|
-
/** Whether storage answers. Without it the catalog lists the volumes alone. */
|
|
74
|
-
available: boolean;
|
|
75
|
-
items: readonly Item[];
|
|
76
|
-
}
|
|
77
|
-
/** Where item records live. Any object with these three calls will do. */
|
|
78
|
-
export interface CatalogStorage {
|
|
79
|
-
list(): Promise<Item[]>;
|
|
80
|
-
put(item: Item): Promise<unknown>;
|
|
81
|
-
remove(id: string): Promise<unknown>;
|
|
82
|
-
}
|
|
83
|
-
/** What a kind tells the catalog about its items' payloads. */
|
|
84
|
-
export interface KindHooks {
|
|
85
|
-
/** Bytes, for Empty Trash's alert. */
|
|
86
|
-
size?(item: Item): number;
|
|
87
|
-
/** Copy `from`'s payload to `to`, a fresh copy of it. */
|
|
88
|
-
copy?(from: Item, to: Item): void | Promise<void>;
|
|
89
|
-
/** Empty Trash removed the item: drop its payload. */
|
|
90
|
-
onRemove?(item: Item): void | Promise<void>;
|
|
91
|
-
}
|
|
92
|
-
/** The volumes a page wants, by name; `false` or unset is none (the Trash defaults on). */
|
|
93
|
-
export interface Volumes {
|
|
94
|
-
trash?: string | false;
|
|
95
|
-
disk?: string | false;
|
|
96
|
-
}
|
|
97
|
-
/** The System Folder and its two folders, by name. A site that names them has them. */
|
|
98
|
-
export interface SystemFolders {
|
|
99
|
-
folder: string;
|
|
100
|
-
appleMenu: string;
|
|
101
|
-
startup: string;
|
|
102
|
-
}
|
|
103
|
-
export interface CatalogOptions {
|
|
104
|
-
storage: CatalogStorage | null;
|
|
105
|
-
volumes?: Volumes;
|
|
106
|
-
/** The System Folder, on the startup disk. Unset, none. */
|
|
107
|
-
system?: SystemFolders;
|
|
108
|
-
/** Whether an application registers `kind`. Folders are always listed. Default: every kind. */
|
|
109
|
-
listed?(kind: string): boolean;
|
|
110
|
-
/** A kind's payload hooks. */
|
|
111
|
-
hooks?(kind: string): KindHooks | undefined;
|
|
112
|
-
now?(): number;
|
|
113
|
-
newId?(): string;
|
|
114
|
-
/** How long a position change waits before it is written, ms. Default 400. */
|
|
115
|
-
placeDelay?: number;
|
|
116
|
-
}
|
|
117
|
-
/** What an operation makes: the new item, or null where it was refused. */
|
|
118
|
-
export interface NewItem {
|
|
119
|
-
name?: string;
|
|
120
|
-
kind?: string;
|
|
121
|
-
parent?: string | null;
|
|
122
|
-
left?: number;
|
|
123
|
-
top?: number;
|
|
124
|
-
data?: unknown;
|
|
125
|
-
/** The creation time, for a batch made in order. Default now. */
|
|
126
|
-
at?: number;
|
|
127
|
-
}
|
|
128
|
-
/** A catalog dumped or restored: its item records. */
|
|
129
|
-
export interface CatalogArchive {
|
|
130
|
-
items: Item[];
|
|
131
|
-
}
|
|
132
|
-
/** Whether `kind` holds other items: a folder or a volume. */
|
|
133
|
-
export declare const isContainerKind: (kind: string) => boolean;
|
|
134
|
-
/** Whether `id` names a volume. */
|
|
135
|
-
export declare const isVolume: (id: string | null | undefined) => boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Whether `id` names a container the catalog keeps, never renamed, moved,
|
|
138
|
-
* copied or removed: a volume, the System Folder or a folder in it.
|
|
139
|
-
*/
|
|
140
|
-
export declare const isKept: (id: string | null | undefined) => boolean;
|
|
141
|
-
/** The application an `app` item stands for: its `data.app`, or null. */
|
|
142
|
-
export declare function appIdOf(item: Item): string | null;
|
|
143
|
-
/** The id of the item an alias stands for: its `data.original`, or null for anything but an alias. */
|
|
144
|
-
export declare function originalOf(item: Item): string | null;
|
|
145
|
-
/** The item with `id`, or null. */
|
|
146
|
-
export declare function itemOf(state: CatalogState, id: string | null | undefined): Item | null;
|
|
147
|
-
/**
|
|
148
|
-
* The item `id` names, or the original an alias stands for, through an alias
|
|
149
|
-
* of an alias too. Null once the original is gone, and for a chain that loops.
|
|
150
|
-
*/
|
|
151
|
-
export declare function resolve(state: CatalogState, id: string | null | undefined): Item | null;
|
|
152
|
-
/** The container `parent` resolves to: that container while it is listed, else the desktop (null). */
|
|
153
|
-
export declare function containerOf(state: CatalogState, parent: string | null | undefined): string | null;
|
|
154
|
-
/** The items directly in a container (null: the desktop), in listing order. */
|
|
155
|
-
export declare function childrenOf(state: CatalogState, parent: string | null): Item[];
|
|
156
|
-
/** How many items a container holds directly. */
|
|
157
|
-
export declare function itemCount(state: CatalogState, parent: string | null): number;
|
|
158
|
-
/**
|
|
159
|
-
* Whether `ancestor` is on `id`'s chain of containers. An item is not inside
|
|
160
|
-
* itself; a looping chain stops at its first repeat.
|
|
161
|
-
*/
|
|
162
|
-
export declare function isInside(state: CatalogState, id: string, ancestor: string): boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Container `id` and the containers around it, innermost first. The desktop
|
|
165
|
-
* ends the chain, and so does an id with no container; a loop stops at its
|
|
166
|
-
* first repeat.
|
|
167
|
-
*/
|
|
168
|
-
export declare function enclosingFolders(state: CatalogState, id: string | null | undefined): string[];
|
|
169
|
-
/** Whether `id` is the Trash or anything inside it. */
|
|
170
|
-
export declare function isTrashed(state: CatalogState, id: string | null | undefined): boolean;
|
|
171
|
-
/**
|
|
172
|
-
* Whether Make Alias takes item `id`: an application, a document, a folder
|
|
173
|
-
* or the startup disk, or an alias of one, outside the Trash. Never the
|
|
174
|
-
* Trash itself, and never an alias whose original is gone.
|
|
175
|
-
*/
|
|
176
|
-
export declare function canAlias(state: CatalogState, id: string | null | undefined): boolean;
|
|
177
|
-
/** What a drop onto an item files into: a container's id, or the alias of a container whose original is gone. */
|
|
178
|
-
export type DropTarget = {
|
|
179
|
-
folder: string;
|
|
180
|
-
} | {
|
|
181
|
-
missing: Item;
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* What a drop onto item `id` files into. A container takes it itself, and
|
|
185
|
-
* an alias of one passes it to the original, so filing judges the original:
|
|
186
|
-
* a folder never goes into itself through an alias either. An alias of a
|
|
187
|
-
* container whose original is gone still takes the drop and files nothing:
|
|
188
|
-
* `missing`, the alias. Anything else takes none: null.
|
|
189
|
-
*/
|
|
190
|
-
export declare function dropTargetOf(state: CatalogState, id: string | null | undefined): DropTarget | null;
|
|
191
|
-
/** Everything under a container, each container before what it holds; a loop is walked once. */
|
|
192
|
-
export declare function descendantsOf(state: CatalogState, parent: string | null): Item[];
|
|
193
|
-
/** The first free folder name in a container: "untitled folder", "untitled folder 2", … */
|
|
194
|
-
export declare function nextFolderName(state: CatalogState, parent: string | null): string;
|
|
195
|
-
/**
|
|
196
|
-
* The name for a copy in a container: `name` itself while no item of its
|
|
197
|
-
* kind there has it, else its base (less " copy" and " copy N") plus " copy",
|
|
198
|
-
* then " copy 2", " copy 3", …
|
|
199
|
-
*/
|
|
200
|
-
export declare function copyName(state: CatalogState, parent: string | null, name: string, kind: string): string;
|
|
201
|
-
/** The name for an alias of `name` in a container: "name alias", then "name alias 2", … while an alias there has it. */
|
|
202
|
-
export declare function aliasName(state: CatalogState, parent: string | null, name: string): string;
|
|
203
|
-
/** What Apple Menu Items holds, by name: the Apple menu's entries. None without the System Folder. */
|
|
204
|
-
export declare const appleMenuItemsOf: (state: CatalogState) => Item[];
|
|
205
|
-
/** What Startup Items holds, by name: what opens at startup. None without the System Folder. */
|
|
206
|
-
export declare const startupItemsOf: (state: CatalogState) => Item[];
|
|
207
|
-
/** One entry of the Apple menu, and what it holds when it is a folder's. */
|
|
208
|
-
export interface AppleMenuEntry {
|
|
209
|
-
/** The entry's own item: an alias stays the alias. */
|
|
210
|
-
item: Item;
|
|
211
|
-
/** What the folder holds, or the folder an alias stands for, by name. */
|
|
212
|
-
entries?: AppleMenuEntry[];
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* The Apple menu as a tree: what Apple Menu Items holds, by name, and for a
|
|
216
|
-
* folder in it, or an alias of one, what that folder holds, the same way,
|
|
217
|
-
* down to five levels below the menu. A folder already on the way down
|
|
218
|
-
* (Apple Menu Items starts it), an empty folder and a folder past the fifth
|
|
219
|
-
* level have no entries, so the tree never loops. None without the System
|
|
220
|
-
* Folder.
|
|
221
|
-
*/
|
|
222
|
-
export declare function appleMenuOf(state: CatalogState): AppleMenuEntry[];
|
|
223
|
-
/** The catalog's operations, over its listing. */
|
|
224
|
-
export interface Catalog {
|
|
225
|
-
get(): CatalogState;
|
|
226
|
-
subscribe(fn: (state: CatalogState) => void): () => void;
|
|
227
|
-
item(id: string | null | undefined): Item | null;
|
|
228
|
-
refresh(): Promise<void>;
|
|
229
|
-
seed(fn: (catalog: Catalog) => void | Promise<void>): Promise<boolean>;
|
|
230
|
-
create(input?: NewItem): Promise<Item | null>;
|
|
231
|
-
rename(id: string, name: string): Promise<boolean>;
|
|
232
|
-
update(id: string, data: unknown): Promise<boolean>;
|
|
233
|
-
move(ids: readonly string[], parent: string | null, landings?: ReadonlyMap<string, Point | null>): Promise<string[]>;
|
|
234
|
-
place(positions: ReadonlyMap<string, Point>): void;
|
|
235
|
-
flush(): Promise<void>;
|
|
236
|
-
copy(ids: readonly string[], parent: string | null): Promise<Item[]>;
|
|
237
|
-
emptyTrash(): Promise<Item[]>;
|
|
238
|
-
trashSize(): number;
|
|
239
|
-
dump(): CatalogArchive;
|
|
240
|
-
clear(): Promise<void>;
|
|
241
|
-
import(archive: CatalogArchive, options?: {
|
|
242
|
-
mode?: 'merge' | 'replace';
|
|
243
|
-
}): Promise<Map<string, Item>>;
|
|
244
|
-
dispose(): Promise<void>;
|
|
245
|
-
}
|
|
246
|
-
export declare function createCatalog(options: CatalogOptions): Catalog;
|
|
247
|
-
/** Storage that forgets everything on a reload. Its map is exposed for tests. */
|
|
248
|
-
export declare function memoryStorage(initial?: readonly Item[]): CatalogStorage & {
|
|
249
|
-
records: Map<string, Item>;
|
|
250
|
-
};
|