buckyos 0.7.200 → 0.7.204
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/cli/dist/cli.mjs +42 -1
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/pikg.ts +7 -0
- package/cli/modules/pikg_protocol.ts +37 -0
- package/cli/version.ts +1 -1
- package/dist/{aiws_write-2f0baa6f.mjs → aiws_write-0606e098.mjs} +707 -291
- package/dist/aiws_write-0606e098.mjs.map +1 -0
- package/dist/aiws_write-7a9d71d1.js +13 -0
- package/dist/aiws_write-7a9d71d1.js.map +1 -0
- package/dist/app-frame.cjs +1 -1
- package/dist/app-frame.cjs.map +1 -1
- package/dist/app-frame.d.ts +131 -24
- package/dist/app-frame.d.ts.map +1 -1
- package/dist/app-frame.mjs +235 -70
- package/dist/app-frame.mjs.map +1 -1
- package/dist/audio.d.ts +84 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs +249 -219
- package/dist/browser.mjs.map +1 -1
- package/dist/content.cjs +1 -1
- package/dist/content.cjs.map +1 -1
- package/dist/content.mjs +357 -34
- package/dist/content.mjs.map +1 -1
- package/dist/{content_objid-0e63f1ff.js → content_objid-c69251aa.js} +2 -2
- package/dist/{content_objid-0e63f1ff.js.map → content_objid-c69251aa.js.map} +1 -1
- package/dist/{content_objid-8ebeead4.mjs → content_objid-e3fc56dd.mjs} +2 -2
- package/dist/{content_objid-8ebeead4.mjs.map → content_objid-e3fc56dd.mjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +249 -219
- package/dist/index.mjs.map +1 -1
- package/dist/msg_center_client.d.ts +37 -0
- package/dist/msg_center_client.d.ts.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +5 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.mjs +246 -215
- package/dist/node.mjs.map +1 -1
- package/dist/open-app.cjs +2 -0
- package/dist/open-app.cjs.map +1 -0
- package/dist/open-app.mjs +160 -0
- package/dist/open-app.mjs.map +1 -0
- package/dist/open_app.d.ts +95 -0
- package/dist/open_app.d.ts.map +1 -0
- package/dist/provision.cjs +1 -1
- package/dist/provision.cjs.map +1 -1
- package/dist/provision.mjs +1 -3
- package/dist/provision.mjs.map +1 -1
- package/dist/provision_activate.d.ts.map +1 -1
- package/dist/runtime_env-39e4df98.mjs +44 -0
- package/dist/runtime_env-39e4df98.mjs.map +1 -0
- package/dist/runtime_env-6396e1eb.js +2 -0
- package/dist/runtime_env-6396e1eb.js.map +1 -0
- package/dist/runtime_env.d.ts +53 -0
- package/dist/runtime_env.d.ts.map +1 -0
- package/dist/sdk_core.d.ts +4 -2
- package/dist/sdk_core.d.ts.map +1 -1
- package/dist/zone_clients.d.ts +35 -0
- package/dist/zone_clients.d.ts.map +1 -0
- package/package.json +6 -1
- package/dist/aiws_write-2f0baa6f.mjs.map +0 -1
- package/dist/aiws_write-ad97b561.js +0 -13
- package/dist/aiws_write-ad97b561.js.map +0 -1
- package/dist/content_mime-dc80d960.js +0 -2
- package/dist/content_mime-dc80d960.js.map +0 -1
- package/dist/content_mime-e42d5f8d.mjs +0 -335
- package/dist/content_mime-e42d5f8d.mjs.map +0 -1
package/dist/content.mjs
CHANGED
|
@@ -1,13 +1,336 @@
|
|
|
1
|
-
import { e as extensionOf, m as mediaTypeFromExtension } from "./content_mime-e42d5f8d.mjs";
|
|
2
|
-
import { T, h, i, s, a } from "./content_mime-e42d5f8d.mjs";
|
|
3
1
|
import { f as encodeObjSegment } from "./object_url-20e94b67.mjs";
|
|
4
2
|
import "./ndn_types-0fac2499.mjs";
|
|
3
|
+
const TEXT_CODE_EXTENSIONS = [
|
|
4
|
+
"txt",
|
|
5
|
+
"text",
|
|
6
|
+
"log",
|
|
7
|
+
"ini",
|
|
8
|
+
"conf",
|
|
9
|
+
"cfg",
|
|
10
|
+
"env",
|
|
11
|
+
"csv",
|
|
12
|
+
"tsv",
|
|
13
|
+
"md",
|
|
14
|
+
"markdown",
|
|
15
|
+
"rst",
|
|
16
|
+
"adoc",
|
|
17
|
+
"json",
|
|
18
|
+
"jsonc",
|
|
19
|
+
"json5",
|
|
20
|
+
"xml",
|
|
21
|
+
"yaml",
|
|
22
|
+
"yml",
|
|
23
|
+
"toml",
|
|
24
|
+
"ts",
|
|
25
|
+
"tsx",
|
|
26
|
+
"js",
|
|
27
|
+
"jsx",
|
|
28
|
+
"mjs",
|
|
29
|
+
"cjs",
|
|
30
|
+
"rs",
|
|
31
|
+
"py",
|
|
32
|
+
"go",
|
|
33
|
+
"c",
|
|
34
|
+
"h",
|
|
35
|
+
"cc",
|
|
36
|
+
"cpp",
|
|
37
|
+
"hpp",
|
|
38
|
+
"java",
|
|
39
|
+
"kt",
|
|
40
|
+
"swift",
|
|
41
|
+
"rb",
|
|
42
|
+
"php",
|
|
43
|
+
"sql",
|
|
44
|
+
"sh",
|
|
45
|
+
"bash",
|
|
46
|
+
"zsh",
|
|
47
|
+
"ps1",
|
|
48
|
+
"bat",
|
|
49
|
+
"css",
|
|
50
|
+
"scss",
|
|
51
|
+
"less",
|
|
52
|
+
"vue",
|
|
53
|
+
"svelte",
|
|
54
|
+
"lua",
|
|
55
|
+
"dart",
|
|
56
|
+
"r",
|
|
57
|
+
"scala",
|
|
58
|
+
"ex",
|
|
59
|
+
"exs",
|
|
60
|
+
"dockerfile",
|
|
61
|
+
"makefile",
|
|
62
|
+
"gitignore",
|
|
63
|
+
"editorconfig",
|
|
64
|
+
"lock"
|
|
65
|
+
];
|
|
66
|
+
const MEDIA_TYPE_BY_EXTENSION = {
|
|
67
|
+
png: "image/png",
|
|
68
|
+
apng: "image/apng",
|
|
69
|
+
jpg: "image/jpeg",
|
|
70
|
+
jpeg: "image/jpeg",
|
|
71
|
+
jfif: "image/jpeg",
|
|
72
|
+
gif: "image/gif",
|
|
73
|
+
webp: "image/webp",
|
|
74
|
+
bmp: "image/bmp",
|
|
75
|
+
ico: "image/x-icon",
|
|
76
|
+
avif: "image/avif",
|
|
77
|
+
heic: "image/heic",
|
|
78
|
+
heif: "image/heif",
|
|
79
|
+
tif: "image/tiff",
|
|
80
|
+
tiff: "image/tiff",
|
|
81
|
+
psd: "image/vnd.adobe.photoshop",
|
|
82
|
+
svg: "image/svg+xml",
|
|
83
|
+
mp4: "video/mp4",
|
|
84
|
+
m4v: "video/mp4",
|
|
85
|
+
webm: "video/webm",
|
|
86
|
+
mov: "video/quicktime",
|
|
87
|
+
mkv: "video/x-matroska",
|
|
88
|
+
avi: "video/x-msvideo",
|
|
89
|
+
ogv: "video/ogg",
|
|
90
|
+
mp3: "audio/mpeg",
|
|
91
|
+
wav: "audio/wav",
|
|
92
|
+
flac: "audio/flac",
|
|
93
|
+
ogg: "audio/ogg",
|
|
94
|
+
oga: "audio/ogg",
|
|
95
|
+
opus: "audio/ogg",
|
|
96
|
+
m4a: "audio/mp4",
|
|
97
|
+
aac: "audio/aac",
|
|
98
|
+
pdf: "application/pdf",
|
|
99
|
+
html: "text/html",
|
|
100
|
+
htm: "text/html",
|
|
101
|
+
xhtml: "application/xhtml+xml",
|
|
102
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
103
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
104
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
105
|
+
doc: "application/msword",
|
|
106
|
+
xls: "application/vnd.ms-excel",
|
|
107
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
108
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
109
|
+
zip: "application/zip",
|
|
110
|
+
tar: "application/x-tar",
|
|
111
|
+
gz: "application/gzip",
|
|
112
|
+
"7z": "application/x-7z-compressed",
|
|
113
|
+
rar: "application/vnd.rar",
|
|
114
|
+
epub: "application/epub+zip",
|
|
115
|
+
md: "text/markdown",
|
|
116
|
+
markdown: "text/markdown",
|
|
117
|
+
json: "application/json",
|
|
118
|
+
xml: "application/xml",
|
|
119
|
+
csv: "text/csv",
|
|
120
|
+
yaml: "application/yaml",
|
|
121
|
+
yml: "application/yaml",
|
|
122
|
+
toml: "application/toml",
|
|
123
|
+
js: "text/javascript",
|
|
124
|
+
mjs: "text/javascript",
|
|
125
|
+
cjs: "text/javascript",
|
|
126
|
+
css: "text/css"
|
|
127
|
+
};
|
|
128
|
+
for (const ext of TEXT_CODE_EXTENSIONS) {
|
|
129
|
+
if (!MEDIA_TYPE_BY_EXTENSION[ext])
|
|
130
|
+
MEDIA_TYPE_BY_EXTENSION[ext] = `text/x-${ext}`;
|
|
131
|
+
}
|
|
132
|
+
function extensionOf(name) {
|
|
133
|
+
if (!name)
|
|
134
|
+
return "";
|
|
135
|
+
const base = name.split("/").pop() ?? name;
|
|
136
|
+
const dot = base.lastIndexOf(".");
|
|
137
|
+
if (dot <= 0)
|
|
138
|
+
return "";
|
|
139
|
+
return base.slice(dot + 1).toLowerCase();
|
|
140
|
+
}
|
|
141
|
+
function mediaTypeFromExtension(ext) {
|
|
142
|
+
return MEDIA_TYPE_BY_EXTENSION[ext.toLowerCase()];
|
|
143
|
+
}
|
|
144
|
+
function stripMediaTypeParams(value) {
|
|
145
|
+
return (value ?? "").split(";")[0].trim().toLowerCase();
|
|
146
|
+
}
|
|
147
|
+
function ascii(bytes, start, length) {
|
|
148
|
+
let out = "";
|
|
149
|
+
for (let i = start; i < Math.min(bytes.length, start + length); i += 1) {
|
|
150
|
+
out += String.fromCharCode(bytes[i]);
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function textHead(bytes, length = 512) {
|
|
155
|
+
let start = 0;
|
|
156
|
+
if (bytes.length >= 3 && bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191)
|
|
157
|
+
start = 3;
|
|
158
|
+
return ascii(bytes, start, length).replace(/^\s+/, "");
|
|
159
|
+
}
|
|
160
|
+
const HEIC_BRANDS = /* @__PURE__ */ new Set(["heic", "heix", "heim", "heis", "hevc", "hevx", "hevm", "hevs"]);
|
|
161
|
+
function compatibleBrands(b) {
|
|
162
|
+
const size = b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
|
|
163
|
+
const end = Math.min(b.length, size > 16 ? size : 16);
|
|
164
|
+
const brands = [];
|
|
165
|
+
for (let at = 16; at + 4 <= end; at += 4)
|
|
166
|
+
brands.push(ascii(b, at, 4));
|
|
167
|
+
return brands;
|
|
168
|
+
}
|
|
169
|
+
function sniffMagic(bytes) {
|
|
170
|
+
if (!bytes || bytes.length < 4)
|
|
171
|
+
return null;
|
|
172
|
+
const b = bytes;
|
|
173
|
+
if (b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71)
|
|
174
|
+
return "image/png";
|
|
175
|
+
if (b[0] === 255 && b[1] === 216 && b[2] === 255)
|
|
176
|
+
return "image/jpeg";
|
|
177
|
+
if (ascii(b, 0, 4) === "GIF8")
|
|
178
|
+
return "image/gif";
|
|
179
|
+
if (ascii(b, 0, 4) === "RIFF" && b.length >= 12) {
|
|
180
|
+
const form = ascii(b, 8, 4);
|
|
181
|
+
if (form === "WEBP")
|
|
182
|
+
return "image/webp";
|
|
183
|
+
if (form === "WAVE")
|
|
184
|
+
return "audio/wav";
|
|
185
|
+
if (form === "AVI ")
|
|
186
|
+
return "video/x-msvideo";
|
|
187
|
+
}
|
|
188
|
+
if (b[0] === 66 && b[1] === 77)
|
|
189
|
+
return "image/bmp";
|
|
190
|
+
if (b[0] === 0 && b[1] === 0 && b[2] === 1 && b[3] === 0)
|
|
191
|
+
return "image/x-icon";
|
|
192
|
+
if (ascii(b, 0, 4) === "II*\0" || ascii(b, 0, 4) === "MM\0*")
|
|
193
|
+
return "image/tiff";
|
|
194
|
+
if (ascii(b, 0, 4) === "8BPS")
|
|
195
|
+
return "image/vnd.adobe.photoshop";
|
|
196
|
+
if (ascii(b, 0, 5) === "%PDF-")
|
|
197
|
+
return "application/pdf";
|
|
198
|
+
if (b.length >= 12 && ascii(b, 4, 4) === "ftyp") {
|
|
199
|
+
const brand = ascii(b, 8, 4);
|
|
200
|
+
if (brand === "avif" || brand === "avis")
|
|
201
|
+
return "image/avif";
|
|
202
|
+
if (HEIC_BRANDS.has(brand))
|
|
203
|
+
return "image/heic";
|
|
204
|
+
if (brand === "mif1" || brand === "msf1") {
|
|
205
|
+
const compatible = compatibleBrands(b);
|
|
206
|
+
if (compatible.some((c) => c === "avif" || c === "avis"))
|
|
207
|
+
return "image/avif";
|
|
208
|
+
return compatible.some((c) => HEIC_BRANDS.has(c)) ? "image/heic" : "image/heif";
|
|
209
|
+
}
|
|
210
|
+
if (brand === "qt ")
|
|
211
|
+
return "video/quicktime";
|
|
212
|
+
if (brand === "M4A ")
|
|
213
|
+
return "audio/mp4";
|
|
214
|
+
return "video/mp4";
|
|
215
|
+
}
|
|
216
|
+
if (b[0] === 26 && b[1] === 69 && b[2] === 223 && b[3] === 163) {
|
|
217
|
+
return ascii(b, 0, 64).includes("webm") ? "video/webm" : "video/x-matroska";
|
|
218
|
+
}
|
|
219
|
+
if (ascii(b, 0, 4) === "OggS") {
|
|
220
|
+
const head2 = ascii(b, 0, 96);
|
|
221
|
+
return head2.includes("theora") ? "video/ogg" : "audio/ogg";
|
|
222
|
+
}
|
|
223
|
+
if (ascii(b, 0, 3) === "ID3")
|
|
224
|
+
return "audio/mpeg";
|
|
225
|
+
if (b[0] === 255 && (b[1] & 230) === 226 && (b[1] & 24) !== 8)
|
|
226
|
+
return "audio/mpeg";
|
|
227
|
+
if (ascii(b, 0, 4) === "fLaC")
|
|
228
|
+
return "audio/flac";
|
|
229
|
+
if (b[0] === 80 && b[1] === 75 && (b[2] === 3 || b[2] === 5 || b[2] === 7)) {
|
|
230
|
+
return "application/zip";
|
|
231
|
+
}
|
|
232
|
+
if (b[0] === 31 && b[1] === 139)
|
|
233
|
+
return "application/gzip";
|
|
234
|
+
if (ascii(b, 0, 6) === "7z¼¯'")
|
|
235
|
+
return "application/x-7z-compressed";
|
|
236
|
+
if (ascii(b, 0, 4) === "Rar!")
|
|
237
|
+
return "application/vnd.rar";
|
|
238
|
+
const head = textHead(b).toLowerCase();
|
|
239
|
+
if (head.startsWith("<?xml") || head.startsWith("<svg") || head.startsWith("<!doctype svg")) {
|
|
240
|
+
if (head.includes("<svg"))
|
|
241
|
+
return "image/svg+xml";
|
|
242
|
+
if (head.startsWith("<?xml"))
|
|
243
|
+
return "application/xml";
|
|
244
|
+
}
|
|
245
|
+
if (head.startsWith("<!doctype html") || head.startsWith("<html") || head.startsWith("<head") || head.startsWith("<body")) {
|
|
246
|
+
return "text/html";
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const MAX_ISO_BOXES = 4096;
|
|
251
|
+
function isoBoxes(view, start, end) {
|
|
252
|
+
const boxes = [];
|
|
253
|
+
let at = start;
|
|
254
|
+
while (boxes.length < MAX_ISO_BOXES && at + 8 <= end) {
|
|
255
|
+
let size = view.getUint32(at);
|
|
256
|
+
const type = String.fromCharCode(view.getUint8(at + 4), view.getUint8(at + 5), view.getUint8(at + 6), view.getUint8(at + 7));
|
|
257
|
+
let header = 8;
|
|
258
|
+
if (size === 1) {
|
|
259
|
+
if (at + 16 > end)
|
|
260
|
+
break;
|
|
261
|
+
size = Number(view.getBigUint64(at + 8));
|
|
262
|
+
if (!Number.isSafeInteger(size))
|
|
263
|
+
throw new RangeError("box size exceeds the safe integer range");
|
|
264
|
+
header = 16;
|
|
265
|
+
} else if (size === 0) {
|
|
266
|
+
size = end - at;
|
|
267
|
+
}
|
|
268
|
+
if (size < header)
|
|
269
|
+
break;
|
|
270
|
+
boxes.push({ type, start: at + header, end: Math.min(end, at + size) });
|
|
271
|
+
at += size;
|
|
272
|
+
}
|
|
273
|
+
return boxes;
|
|
274
|
+
}
|
|
275
|
+
function heifImageSize(bytes) {
|
|
276
|
+
try {
|
|
277
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
278
|
+
const meta = isoBoxes(view, 0, bytes.length).find((b) => b.type === "meta");
|
|
279
|
+
if (!meta)
|
|
280
|
+
return null;
|
|
281
|
+
const children = isoBoxes(view, meta.start + 4, meta.end);
|
|
282
|
+
const pitm = children.find((b) => b.type === "pitm");
|
|
283
|
+
const iprp = children.find((b) => b.type === "iprp");
|
|
284
|
+
if (!pitm || !iprp)
|
|
285
|
+
return null;
|
|
286
|
+
const primary = view.getUint8(pitm.start) === 0 ? view.getUint16(pitm.start + 4) : view.getUint32(pitm.start + 4);
|
|
287
|
+
const props = isoBoxes(view, iprp.start, iprp.end);
|
|
288
|
+
const ipco = props.find((b) => b.type === "ipco");
|
|
289
|
+
if (!ipco)
|
|
290
|
+
return null;
|
|
291
|
+
const properties = isoBoxes(view, ipco.start, ipco.end);
|
|
292
|
+
let width = 0;
|
|
293
|
+
let height = 0;
|
|
294
|
+
let quarterTurns = 0;
|
|
295
|
+
for (const ipma of props.filter((b) => b.type === "ipma")) {
|
|
296
|
+
const version = view.getUint8(ipma.start);
|
|
297
|
+
const wideIndex = (view.getUint8(ipma.start + 3) & 1) === 1;
|
|
298
|
+
let at = ipma.start + 4;
|
|
299
|
+
const count = view.getUint32(at);
|
|
300
|
+
at += 4;
|
|
301
|
+
for (let i = 0; i < count && at < ipma.end; i += 1) {
|
|
302
|
+
const item = version < 1 ? view.getUint16(at) : view.getUint32(at);
|
|
303
|
+
at += version < 1 ? 2 : 4;
|
|
304
|
+
const associations = view.getUint8(at);
|
|
305
|
+
at += 1;
|
|
306
|
+
for (let j = 0; j < associations; j += 1) {
|
|
307
|
+
const index = wideIndex ? view.getUint16(at) & 32767 : view.getUint8(at) & 127;
|
|
308
|
+
at += wideIndex ? 2 : 1;
|
|
309
|
+
if (item !== primary || index === 0)
|
|
310
|
+
continue;
|
|
311
|
+
const property = properties[index - 1];
|
|
312
|
+
if ((property == null ? void 0 : property.type) === "ispe") {
|
|
313
|
+
width = view.getUint32(property.start + 4);
|
|
314
|
+
height = view.getUint32(property.start + 8);
|
|
315
|
+
} else if ((property == null ? void 0 : property.type) === "irot") {
|
|
316
|
+
quarterTurns = view.getUint8(property.start) & 3;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (!width || !height)
|
|
322
|
+
return null;
|
|
323
|
+
return quarterTurns % 2 === 1 ? { width: height, height: width } : { width, height };
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
5
328
|
function isArchiveInnerPath(value) {
|
|
6
329
|
if (typeof value !== "string" || value !== "/archive" && !value.startsWith("/archive/"))
|
|
7
330
|
return false;
|
|
8
|
-
return value.split("/").slice(2).every((
|
|
331
|
+
return value.split("/").slice(2).every((s) => !!s && s !== "." && s !== ".." && s.length <= 255 && !/[\\\0]/.test(s));
|
|
9
332
|
}
|
|
10
|
-
const objRefString = (objectId, innerPath) => `obj://${objectId}${innerPath ? innerPath.split("/").slice(1).map((
|
|
333
|
+
const objRefString = (objectId, innerPath) => `obj://${objectId}${innerPath ? innerPath.split("/").slice(1).map((s) => `/${encodeObjSegment(s)}`).join("") : ""}`;
|
|
11
334
|
function parseObjRefString(value) {
|
|
12
335
|
if (!value.startsWith("obj://"))
|
|
13
336
|
return void 0;
|
|
@@ -62,7 +385,7 @@ function isTransferableSession(value) {
|
|
|
62
385
|
if (!value || typeof value !== "object")
|
|
63
386
|
return false;
|
|
64
387
|
const v = value;
|
|
65
|
-
return v.kind === "single" || v.kind === "container" && isTransferableRef(v.container) && isTransferableRef(v.current) || v.kind === "list" && Array.isArray(v.items) && v.items.every((
|
|
388
|
+
return v.kind === "single" || v.kind === "container" && isTransferableRef(v.container) && isTransferableRef(v.current) || v.kind === "list" && Array.isArray(v.items) && v.items.every((i) => i && isTransferableRef(i.source)) && Number.isInteger(v.currentIndex) && v.currentIndex >= 0 && v.currentIndex < v.items.length;
|
|
66
389
|
}
|
|
67
390
|
function contentDescriptor(source, hints = {}) {
|
|
68
391
|
const tail = source.kind === "cyfs-path" ? source.path : source.innerPath ?? "";
|
|
@@ -78,15 +401,15 @@ function contentDescriptor(source, hints = {}) {
|
|
|
78
401
|
};
|
|
79
402
|
}
|
|
80
403
|
const values = (v) => v === void 0 ? [] : Array.isArray(v) ? v : [v];
|
|
81
|
-
function matchSelector(
|
|
404
|
+
function matchSelector(s, d) {
|
|
82
405
|
var _a;
|
|
83
|
-
if (
|
|
406
|
+
if (s.maxSize !== void 0 && d.size !== void 0 && d.size > s.maxSize)
|
|
84
407
|
return 0;
|
|
85
|
-
if (
|
|
408
|
+
if (s.objType && !values(s.objType).includes(d.objType ?? ""))
|
|
86
409
|
return 0;
|
|
87
|
-
let score =
|
|
88
|
-
if (
|
|
89
|
-
const matches = values(
|
|
410
|
+
let score = s.objType ? 2 : 1;
|
|
411
|
+
if (s.schema) {
|
|
412
|
+
const matches = values(s.schema).filter((v) => {
|
|
90
413
|
var _a2;
|
|
91
414
|
return v.endsWith("*") ? (_a2 = d.schema) == null ? void 0 : _a2.startsWith(v.slice(0, -1)) : d.schema === v;
|
|
92
415
|
});
|
|
@@ -94,14 +417,14 @@ function matchSelector(s2, d) {
|
|
|
94
417
|
return 0;
|
|
95
418
|
score = matches.some((v) => v === d.schema) ? 7 : 6;
|
|
96
419
|
}
|
|
97
|
-
if (
|
|
420
|
+
if (s.mime) {
|
|
98
421
|
const mime = (d.mime ?? "").toLowerCase().split(";")[0].trim();
|
|
99
|
-
const scores = values(
|
|
422
|
+
const scores = values(s.mime).map((v) => {
|
|
100
423
|
v = v.toLowerCase();
|
|
101
424
|
if (v === "*/*")
|
|
102
425
|
return 1;
|
|
103
426
|
if (v.split(";")[0].trim() === mime)
|
|
104
|
-
return
|
|
427
|
+
return s.objType ? 6 : 5;
|
|
105
428
|
if (v.includes("/*+") && mime.startsWith(v.split("/")[0] + "/") && mime.endsWith(v.slice(v.indexOf("+"))))
|
|
106
429
|
return 4;
|
|
107
430
|
if (v.endsWith("/*") && mime.startsWith(v.slice(0, -1)))
|
|
@@ -113,16 +436,16 @@ function matchSelector(s2, d) {
|
|
|
113
436
|
return 0;
|
|
114
437
|
score = Math.max(score, best);
|
|
115
438
|
}
|
|
116
|
-
if (!
|
|
439
|
+
if (!s.mime && !s.objType && !s.schema && !((_a = s.ext) == null ? void 0 : _a.includes(d.ext ?? "")))
|
|
117
440
|
return 0;
|
|
118
441
|
return score;
|
|
119
442
|
}
|
|
120
443
|
function compactSelector(value) {
|
|
121
444
|
const out = {};
|
|
122
445
|
for (const part of value.split(";")) {
|
|
123
|
-
const
|
|
124
|
-
const key = part.slice(0,
|
|
125
|
-
const v = part.slice(
|
|
446
|
+
const i = part.indexOf(":");
|
|
447
|
+
const key = part.slice(0, i);
|
|
448
|
+
const v = part.slice(i + 1);
|
|
126
449
|
if (key === "obj")
|
|
127
450
|
out.objType = v;
|
|
128
451
|
else if (key === "mime")
|
|
@@ -140,20 +463,20 @@ function resolveContentHandlers(registry, defaults, descriptor, intent = "open",
|
|
|
140
463
|
var _a;
|
|
141
464
|
const visible = new Set(availableApps);
|
|
142
465
|
const handlers = { ...registry.handlers, "system#preview": previewHandler };
|
|
143
|
-
const preferred = Object.entries(defaults.defaults.open ?? {}).map(([
|
|
144
|
-
const matches = Object.entries(handlers).flatMap(([key,
|
|
145
|
-
const binding =
|
|
146
|
-
if (!binding || !
|
|
466
|
+
const preferred = Object.entries(defaults.defaults.open ?? {}).map(([s, key]) => ({ key, score: matchSelector(compactSelector(s), descriptor) })).filter((v) => v.score > 0).sort((a, b) => b.score - a.score || a.key.localeCompare(b.key));
|
|
467
|
+
const matches = Object.entries(handlers).flatMap(([key, h]) => {
|
|
468
|
+
const binding = h.intents[intent];
|
|
469
|
+
if (!binding || !h.enabled || key !== "system#preview" && defaults.disabled.includes(key))
|
|
147
470
|
return [];
|
|
148
|
-
if (
|
|
471
|
+
if (h.provider === "app" && (!h.app_instance_id || !visible.has(h.app_instance_id) || binding.entry.type !== "web"))
|
|
149
472
|
return [];
|
|
150
|
-
const selectors =
|
|
473
|
+
const selectors = h.selectors.map((selector) => ({ selector, specificity: matchSelector(selector, descriptor) })).filter((s) => s.specificity > 0).sort((a, b) => b.specificity - a.specificity);
|
|
151
474
|
if (!selectors.length)
|
|
152
475
|
return [];
|
|
153
|
-
return [{ key, h
|
|
476
|
+
return [{ key, h, binding, matched: selectors[0] }];
|
|
154
477
|
});
|
|
155
478
|
const preferredKey = (_a = preferred.find((p) => matches.some((m) => m.key === p.key))) == null ? void 0 : _a.key;
|
|
156
|
-
matches.sort((
|
|
479
|
+
matches.sort((a, b) => Number(b.key === preferredKey) - Number(a.key === preferredKey) || Number(b.matched.specificity > 1 || b.h.provider === "system") - Number(a.matched.specificity > 1 || a.h.provider === "system") || b.matched.specificity - a.matched.specificity || (b.binding.priority ?? 0) - (a.binding.priority ?? 0) || Number(b.h.provider === "system") - Number(a.h.provider === "system") || (a.h.registered_at ?? 0) - (b.h.registered_at ?? 0) || a.key.localeCompare(b.key));
|
|
157
480
|
return matches.map((m) => {
|
|
158
481
|
var _a2;
|
|
159
482
|
return {
|
|
@@ -175,8 +498,8 @@ function parentSource(source) {
|
|
|
175
498
|
return void 0;
|
|
176
499
|
return { kind: "object-id", objectId: source.objectId, innerPath: source.innerPath.slice(0, source.innerPath.lastIndexOf("/")) };
|
|
177
500
|
}
|
|
178
|
-
const
|
|
179
|
-
return
|
|
501
|
+
const i = source.path.lastIndexOf("/");
|
|
502
|
+
return i >= 7 ? { kind: "cyfs-path", path: source.path.slice(0, i) || "cyfs:///" } : void 0;
|
|
180
503
|
}
|
|
181
504
|
function encodeSession(session, source) {
|
|
182
505
|
if (!session)
|
|
@@ -186,7 +509,7 @@ function encodeSession(session, source) {
|
|
|
186
509
|
if (encoded.length <= 2048 || session.kind !== "list")
|
|
187
510
|
return encoded;
|
|
188
511
|
const parent = parentSource(source);
|
|
189
|
-
if (parent && session.items.every((
|
|
512
|
+
if (parent && session.items.every((i) => contentRefString(parentSource(i.source) ?? i.source) === contentRefString(parent))) {
|
|
190
513
|
return encode({ kind: "container", container: parent, current: source });
|
|
191
514
|
}
|
|
192
515
|
return "";
|
|
@@ -349,7 +672,7 @@ export {
|
|
|
349
672
|
SELECT_DIALOG_PATH,
|
|
350
673
|
SYSTEM_DIALOG_ERROR_CODES,
|
|
351
674
|
SystemDialogError,
|
|
352
|
-
|
|
675
|
+
TEXT_CODE_EXTENSIONS,
|
|
353
676
|
contentDescriptor,
|
|
354
677
|
contentRefString,
|
|
355
678
|
emptyDefaults,
|
|
@@ -357,12 +680,12 @@ export {
|
|
|
357
680
|
expandOpenPath,
|
|
358
681
|
extensionOf,
|
|
359
682
|
handlerOfApp,
|
|
360
|
-
|
|
683
|
+
heifImageSize,
|
|
361
684
|
isArchiveInnerPath,
|
|
362
685
|
isOpenRequest,
|
|
363
686
|
isTransferableRef,
|
|
364
687
|
isTransferableSession,
|
|
365
|
-
|
|
688
|
+
isoBoxes,
|
|
366
689
|
matchSelector,
|
|
367
690
|
mediaTypeFromExtension,
|
|
368
691
|
parentSource,
|
|
@@ -372,8 +695,8 @@ export {
|
|
|
372
695
|
readContentHints,
|
|
373
696
|
readSelectDialogResult,
|
|
374
697
|
resolveContentHandlers,
|
|
375
|
-
|
|
376
|
-
|
|
698
|
+
sniffMagic,
|
|
699
|
+
stripMediaTypeParams,
|
|
377
700
|
systemOpenUrl
|
|
378
701
|
};
|
|
379
702
|
//# sourceMappingURL=content.mjs.map
|