anyfile-cli 0.2.0 → 0.2.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 -2
- package/chunks/{chunk-5OI4NQH7.mjs → chunk-HI7TURZM.mjs} +27 -3
- package/chunks/{chunk-UUN2DVDC.mjs → chunk-IGEGIF35.mjs} +178 -37
- package/cli-main.mjs +24 -5
- package/index.mjs +2 -2
- package/package.json +2 -2
- package/renderer-host/assets/{amf-CLBaywBr.js → amf-BkE--DNX.js} +1 -1
- package/renderer-host/assets/{animation-DnPo99To.js → animation-Dt0WW2cB.js} +1 -1
- package/renderer-host/assets/{archive-client-CyhEmSF7.js → archive-client-CL5yOgwH.js} +1 -1
- package/renderer-host/assets/{book-worker-DrtzCzPo.js → book-worker-DUt14LJO.js} +1 -1
- package/renderer-host/assets/{client-Dp-p4unY.js → client-CU2ERPtk.js} +1 -1
- package/renderer-host/assets/container-inspection-ekEPWWcy.js +1 -0
- package/renderer-host/assets/decode-hBroL8C1.js +1 -0
- package/renderer-host/assets/{decode-tiff-BuYdKp6p.js → decode-tiff-CP1xdrF_.js} +3 -3
- package/renderer-host/assets/{dual-track-playback-lNQyU1GR.js → dual-track-playback-CxjGms-W.js} +1 -1
- package/renderer-host/assets/{ffmpeg-playback-QcT_NwlK.js → ffmpeg-playback-DzCJz9Ny.js} +1 -1
- package/renderer-host/assets/{gltf-Cqq-xStc.js → gltf-PozNLKNg.js} +1 -1
- package/renderer-host/assets/{image-load-B1fNI3iO.js → image-load-SK3ULGWm.js} +1 -1
- package/renderer-host/assets/index-DtiyOy_J.js +2 -0
- package/renderer-host/assets/{lerc-CRhfhhOS.js → lerc-Cuor-Zm2.js} +1 -1
- package/renderer-host/assets/{mediabunny-viewer-BnJM6Yo0.js → mediabunny-viewer-BniHVEWJ.js} +1 -1
- package/renderer-host/assets/{model-D2YSoRt5.js → model-Drd3vqcF.js} +1 -1
- package/renderer-host/assets/{obj-DbUZkDna.js → obj-B3p81LL2.js} +1 -1
- package/renderer-host/assets/{off-CzR_R_Tf.js → off-QQbiKPTX.js} +1 -1
- package/renderer-host/assets/{ogg-viewer-CT31JEhG.js → ogg-viewer-Dc8K-tas.js} +1 -1
- package/renderer-host/assets/{paged-CX-N_Pzy.js → paged-C8AQD7sX.js} +1 -1
- package/renderer-host/assets/{ply-C-xrhUaO.js → ply-C3_RRA7n.js} +1 -1
- package/renderer-host/assets/{probe-asf-CvcaYQaR.js → probe-asf-C_UpCBly.js} +1 -1
- package/renderer-host/assets/{range-reader-9PeAh1Hv.js → range-reader-BMfLhWcp.js} +1 -1
- package/renderer-host/assets/{resources-WcZvn3-C.js → resources-6AmS6O5e.js} +1 -1
- package/renderer-host/assets/{safe-content-B61Ktgzp.js → safe-content-CWHf8jex.js} +1 -1
- package/renderer-host/assets/{scene-adapter-CmaaVwsM.js → scene-adapter-CaCLr1am.js} +1 -1
- package/renderer-host/assets/{skp-adapter-ByI1iX8S.js → skp-adapter-jl6q24fW.js} +1 -1
- package/renderer-host/assets/{src-DZE9IoBl.js → src-1Won7FxU.js} +1 -1
- package/renderer-host/assets/{src-CXRrmfb0.js → src-3RoHqOkA.js} +1 -1
- package/renderer-host/assets/{src-vPHMg1Fp.js → src-4zBOL6Jt.js} +1 -1
- package/renderer-host/assets/{src-CGx0nUS5.js → src-6v8-hoR3.js} +1 -1
- package/renderer-host/assets/{src-D3OyeoQs.js → src-8Jx9gbII.js} +1 -1
- package/renderer-host/assets/{src-Bu1cTJNz.js → src-B1WA0dRu.js} +1 -1
- package/renderer-host/assets/{src-j_mEQ9Os.js → src-B5ijbemo.js} +2 -2
- package/renderer-host/assets/{src-efHN2oAJ.js → src-B8DH2GJe.js} +3 -3
- package/renderer-host/assets/{src-B_o7QilB.js → src-B9t_iEO3.js} +1 -1
- package/renderer-host/assets/{src-CIDWSV97.js → src-BCC58C0X.js} +1 -1
- package/renderer-host/assets/{src-lYIAi6Hw.js → src-BCwENs26.js} +1 -1
- package/renderer-host/assets/{src-ClIHDiJ4.js → src-BEirBh4c.js} +1 -1
- package/renderer-host/assets/{src-CeGmxOTi.js → src-BHR6n7Fj.js} +1 -1
- package/renderer-host/assets/{src-BMrLVJyB.js → src-BIlLq0QT.js} +3 -3
- package/renderer-host/assets/{src-C5k8Ydia.js → src-BKlK1jcN.js} +1 -1
- package/renderer-host/assets/{src-C_1M1IDo.js → src-BN0FUJhs.js} +1 -1
- package/renderer-host/assets/{src-BEn15PBT.js → src-BWElAdlq.js} +1 -1
- package/renderer-host/assets/{src-QXdjrTaw.js → src-BXg11IjY.js} +1 -1
- package/renderer-host/assets/{src-BwZAUudm.js → src-BbBdnTjJ.js} +2 -2
- package/renderer-host/assets/{src-Bw-O8ujJ.js → src-BbFZbZsL.js} +2 -2
- package/renderer-host/assets/{src-DPm7_lsi.js → src-BdPbFRd-.js} +1 -1
- package/renderer-host/assets/{src-C2LKqLBA.js → src-BpbGaBrT.js} +1 -1
- package/renderer-host/assets/{src-DmzigsPg.js → src-BwIl76_H.js} +1 -1
- package/renderer-host/assets/{src-CHNgoDf9.js → src-C2e6QJIj.js} +1 -1
- package/renderer-host/assets/{src-Cyw_3X-L.js → src-C2gNidHF.js} +1 -1
- package/renderer-host/assets/{src-CBE5sqjl.js → src-CBUhG6W5.js} +1 -1
- package/renderer-host/assets/{src-Cvb3aCDG.js → src-CQDGi3Qa.js} +1 -1
- package/renderer-host/assets/{src-CBo2yHRk.js → src-CRLCRg0N.js} +1 -1
- package/renderer-host/assets/{src-Q-oKL3Dw.js → src-CS5rqxBy.js} +1 -1
- package/renderer-host/assets/{src-DrYYfoQO.js → src-CWZdSJQw.js} +1 -1
- package/renderer-host/assets/{src-B0zJlB0C.js → src-CXnpsVpU.js} +1 -1
- package/renderer-host/assets/{src-C4t_UvT8.js → src-CnhXvqQY.js} +1 -1
- package/renderer-host/assets/{src-CPUYqpHZ.js → src-CpExg0ZA.js} +1 -1
- package/renderer-host/assets/{src-C_HAB_bn.js → src-CrLmL3wU.js} +1 -1
- package/renderer-host/assets/{src-2X3Gt6Lk.js → src-CrYEJ5uz.js} +2 -2
- package/renderer-host/assets/{src-CifsQr3m.js → src-D-iIkSqZ.js} +1 -1
- package/renderer-host/assets/{src-p14e1hma.js → src-D6sH9uTT.js} +1 -1
- package/renderer-host/assets/{src-BPG8SYXq.js → src-D8zHDJh_.js} +1 -1
- package/renderer-host/assets/{src-D4cv_-u0.js → src-D9OFaPNV.js} +1 -1
- package/renderer-host/assets/{src-9k3CCYnZ.js → src-DCI_ff7c.js} +1 -1
- package/renderer-host/assets/{src-BB6xj1UK.js → src-DCrbiTpH.js} +1 -1
- package/renderer-host/assets/{src-TbSq3WSr.js → src-DK8DvtMd.js} +1 -1
- package/renderer-host/assets/{src-eVKtGm4Q.js → src-DWGlOVjt.js} +1 -1
- package/renderer-host/assets/{src-DpEmkhrn.js → src-DbvEX_Ct.js} +1 -1
- package/renderer-host/assets/{src-Ck1ekdEN.js → src-Dezc2dj1.js} +1 -1
- package/renderer-host/assets/{src-TuTvYAR6.js → src-Dh5VD1lL.js} +1 -1
- package/renderer-host/assets/{src-BydeR01n.js → src-DlwABqw5.js} +1 -1
- package/renderer-host/assets/{src-0QHjkpy0.js → src-DlxETlTh.js} +1 -1
- package/renderer-host/assets/{src-R4bKlaNn.js → src-Dmd6BvBh.js} +1 -1
- package/renderer-host/assets/{src-BuN3y1yE.js → src-DpgvaJNJ.js} +1 -1
- package/renderer-host/assets/{src-C6w9FGSB.js → src-DpjRB2sv.js} +1 -1
- package/renderer-host/assets/{src-Blx9jp9x.js → src-Dvn41FR7.js} +1 -1
- package/renderer-host/assets/{src-CVc67mQv.js → src-DwcPYp7X.js} +1 -1
- package/renderer-host/assets/{src-BZrNtUNO.js → src-HUxhcDlO.js} +1 -1
- package/renderer-host/assets/{src-ORHZWeVF.js → src-Jhqg3J8L.js} +2 -2
- package/renderer-host/assets/{src-DsVDi0pr.js → src-MO5bLsLj.js} +1 -1
- package/renderer-host/assets/{src-n2gsf381.js → src-N8XBQaK4.js} +1 -1
- package/renderer-host/assets/{src-BgUXah8O.js → src-XZ_0U972.js} +1 -1
- package/renderer-host/assets/{src-5ZJshveh.js → src-Y6mXl4vh.js} +3 -3
- package/renderer-host/assets/{src-B4jorJ2U.js → src-b9aXVJde.js} +1 -1
- package/renderer-host/assets/{src-CAdKRH5C.js → src-d2U6neq8.js} +1 -1
- package/renderer-host/assets/{src-Bl5Lv4-d.js → src-jUGjKzOV.js} +1 -1
- package/renderer-host/assets/{src-BgM1jpe4.js → src-vOBd-1zk.js} +1 -1
- package/renderer-host/assets/{src-0DTp6SF8.js → src-yCrAObB-.js} +1 -1
- package/renderer-host/assets/{src-BLndk63N.js → src-zrBiCtay.js} +1 -1
- package/renderer-host/assets/{stl-adapter-D1eozFH9.js → stl-adapter-CLkWHoOn.js} +1 -1
- package/renderer-host/assets/{three-mf-CbcWWdM8.js → three-mf-BSrcsdQD.js} +1 -1
- package/renderer-host/assets/{webm-_wYh_V7u.js → webm-14HHwfWy.js} +1 -1
- package/renderer-host/assets/{zip-core-base-CDv8KjIR.js → zip-core-base-DD8akpjq.js} +1 -1
- package/renderer-host/assets/zip-core-custom-CfPFs1lw.js +1 -0
- package/renderer-host/assets/{zip-source-C5dFTDt7.js → zip-source-CLF3Hfcg.js} +1 -1
- package/renderer-host/index.html +1 -1
- package/worker.mjs +3 -2
- package/renderer-host/assets/container-inspection-DZoaDYQR.js +0 -1
- package/renderer-host/assets/decode-D5vB6JN8.js +0 -1
- package/renderer-host/assets/index-BCxD9rBl.js +0 -2
- package/renderer-host/assets/src-2tfD0huT.js +0 -16
- package/renderer-host/assets/zip-core-custom-D3VVVj-J.js +0 -1
package/README.md
CHANGED
|
@@ -45,13 +45,12 @@ Some formats download a WASM decoder on first use into `~/.cache/anyfile/vendor/
|
|
|
45
45
|
|
|
46
46
|
## Develop and release
|
|
47
47
|
|
|
48
|
-
This directory is the private workspace package `@anyfile/agent`. Its build output `dist/` is the published npm package `anyfile-cli`, generated by `scripts/build.mjs
|
|
48
|
+
This directory is the private workspace package `@anyfile/agent`. Its build output `dist/` is the published npm package `anyfile-cli`, generated by `scripts/build.mjs`. For versioning rules, release criteria, and automated publishing via `agent-v*` tags, see [`docs/release.md`](../../docs/release.md).
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
pnpm prepare:assets # once: generates public/vendor/manifest.json
|
|
52
52
|
pnpm --filter @anyfile/agent build # -> viewer/agent/dist
|
|
53
53
|
pnpm test viewer/agent # includes the dist smoke test
|
|
54
|
-
npm publish viewer/agent/dist # after bumping "version" in viewer/agent/package.json
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
The skill source is [`skills/anyfile/SKILL.md`](https://github.com/tianzhipeng-git/anyfile-viewer/blob/main/skills/anyfile/SKILL.md). After changing it, run `pnpm sync:skills` (which defaults to `../anyfile-skills`), then commit and push in [anyfile-skills](https://github.com/tianzhipeng-git/anyfile-skills), the install source for `npx skills add` and the Claude Code marketplace.
|
|
@@ -602,7 +602,24 @@ function parseVendorManifestMap(raw) {
|
|
|
602
602
|
}
|
|
603
603
|
return map;
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function parseVendorManifestSizes(raw) {
|
|
606
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
607
|
+
const obj = raw;
|
|
608
|
+
if (obj.schemaVersion !== 1 || !obj.assets || typeof obj.assets !== "object" || Array.isArray(obj.assets)) {
|
|
609
|
+
return {};
|
|
610
|
+
}
|
|
611
|
+
const map = {};
|
|
612
|
+
for (const [assetPath, entry] of Object.entries(obj.assets)) {
|
|
613
|
+
if (entry && typeof entry === "object") {
|
|
614
|
+
const bytes = entry.bytes;
|
|
615
|
+
if (typeof bytes === "number" && Number.isFinite(bytes) && bytes >= 0) {
|
|
616
|
+
map[assetPath] = bytes;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return map;
|
|
621
|
+
}
|
|
622
|
+
function readDefaultVendorManifestRaw() {
|
|
606
623
|
const here = dirname(fileURLToPath2(import.meta.url));
|
|
607
624
|
const candidates = [
|
|
608
625
|
join3(here, "vendor-manifest.json"),
|
|
@@ -613,11 +630,17 @@ function loadDefaultVendorManifest() {
|
|
|
613
630
|
for (const candidate of candidates) {
|
|
614
631
|
if (!existsSync(candidate)) continue;
|
|
615
632
|
try {
|
|
616
|
-
return
|
|
633
|
+
return JSON.parse(readFileSync(candidate, "utf8"));
|
|
617
634
|
} catch {
|
|
618
635
|
}
|
|
619
636
|
}
|
|
620
|
-
return
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
function loadDefaultVendorManifest() {
|
|
640
|
+
return parseVendorManifestMap(readDefaultVendorManifestRaw());
|
|
641
|
+
}
|
|
642
|
+
function loadDefaultVendorManifestSizes() {
|
|
643
|
+
return parseVendorManifestSizes(readDefaultVendorManifestRaw());
|
|
621
644
|
}
|
|
622
645
|
|
|
623
646
|
// ../plugins/hex/src/manifest.ts
|
|
@@ -2228,5 +2251,6 @@ export {
|
|
|
2228
2251
|
createDiskWorkspaceReader,
|
|
2229
2252
|
parseVendorManifestMap,
|
|
2230
2253
|
loadDefaultVendorManifest,
|
|
2254
|
+
loadDefaultVendorManifestSizes,
|
|
2231
2255
|
viewerRegistryEntries
|
|
2232
2256
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getVendorCacheRoot,
|
|
7
7
|
isWithinAllowedRoots,
|
|
8
8
|
loadDefaultVendorManifest,
|
|
9
|
+
loadDefaultVendorManifestSizes,
|
|
9
10
|
normalizeMaxBytes,
|
|
10
11
|
normalizeMaxDimension,
|
|
11
12
|
readPngDimensions,
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
toAgentFileError,
|
|
15
16
|
trimInspectPayload,
|
|
16
17
|
viewerRegistryEntries
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HI7TURZM.mjs";
|
|
18
19
|
import {
|
|
19
20
|
AgentError,
|
|
20
21
|
DEFAULT_INSPECT_MAX_BYTES
|
|
@@ -380,18 +381,26 @@ import { statSync as statSync2 } from "node:fs";
|
|
|
380
381
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
381
382
|
import { dirname, join as join3 } from "node:path";
|
|
382
383
|
var DEFAULT_VENDOR_UPSTREAM_URL = "https://assets.anyfile.top/vendor";
|
|
384
|
+
var DEFAULT_VENDOR_FETCH_TIMEOUT_MS = 6e4;
|
|
385
|
+
var DEFAULT_MAX_VENDOR_BYTES = 128 * 1024 * 1024;
|
|
383
386
|
var VendorAssetStore = class {
|
|
384
387
|
constructor(options = {}) {
|
|
385
388
|
this.inflightDownloads = /* @__PURE__ */ new Map();
|
|
386
389
|
this.vendorCacheRoot = options.vendorCacheRoot ?? getVendorCacheRoot();
|
|
387
390
|
this.vendorRoots = options.vendorRoots ?? (options.vendorCacheRoot ? [this.vendorCacheRoot] : defaultVendorRoots());
|
|
388
391
|
this.vendorManifest = options.vendorManifest ?? loadDefaultVendorManifest();
|
|
392
|
+
this.vendorManifestSizes = options.vendorManifestSizes ?? (options.vendorManifest ? {} : loadDefaultVendorManifestSizes());
|
|
389
393
|
const rawUpstream = options.vendorUpstreamBaseUrl ?? process.env.ANYFILE_VENDOR_UPSTREAM_URL ?? DEFAULT_VENDOR_UPSTREAM_URL;
|
|
390
394
|
this.vendorUpstreamBaseUrl = rawUpstream.replace(/\/+$/, "");
|
|
395
|
+
this.fetchTimeoutMs = options.fetchTimeoutMs ?? DEFAULT_VENDOR_FETCH_TIMEOUT_MS;
|
|
391
396
|
}
|
|
392
397
|
expectedSha(vendorPath) {
|
|
393
398
|
return this.vendorManifest[vendorPath]?.toLowerCase();
|
|
394
399
|
}
|
|
400
|
+
expectedBytes(vendorPath) {
|
|
401
|
+
const size = this.vendorManifestSizes[vendorPath];
|
|
402
|
+
return typeof size === "number" && Number.isFinite(size) && size >= 0 ? size : void 0;
|
|
403
|
+
}
|
|
395
404
|
locateLocal(vendorPath, roots = this.vendorRoots) {
|
|
396
405
|
const segments = assertVendorPath(vendorPath);
|
|
397
406
|
for (const root of roots) {
|
|
@@ -455,27 +464,104 @@ var VendorAssetStore = class {
|
|
|
455
464
|
const bytes = await this.fetchAndCache(vendorPath, segments, expectedSha);
|
|
456
465
|
return { path: vendorPath, bytes: bytes.byteLength, downloaded: true };
|
|
457
466
|
}
|
|
467
|
+
async readBoundedResponse(response, vendorPath, maxBytes, signal) {
|
|
468
|
+
const contentLengthHeader = response.headers.get("content-length");
|
|
469
|
+
if (contentLengthHeader !== null) {
|
|
470
|
+
const contentLength = Number(contentLengthHeader);
|
|
471
|
+
if (Number.isFinite(contentLength) && contentLength > maxBytes) {
|
|
472
|
+
await response.body?.cancel().catch(() => void 0);
|
|
473
|
+
throw new AgentError(
|
|
474
|
+
"runtime-unavailable",
|
|
475
|
+
`Upstream vendor asset /vendor/${vendorPath} exceeds expected size (${contentLength} > ${maxBytes} bytes).`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (!response.body) {
|
|
480
|
+
let buf;
|
|
481
|
+
try {
|
|
482
|
+
buf = await response.arrayBuffer();
|
|
483
|
+
} catch (error) {
|
|
484
|
+
if (signal.aborted) {
|
|
485
|
+
throw new AgentError("timeout", `Timed out fetching /vendor/${vendorPath} after ${this.fetchTimeoutMs}ms.`);
|
|
486
|
+
}
|
|
487
|
+
throw new AgentError(
|
|
488
|
+
"runtime-unavailable",
|
|
489
|
+
`Failed to read /vendor/${vendorPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
if (buf.byteLength > maxBytes) {
|
|
493
|
+
throw new AgentError(
|
|
494
|
+
"runtime-unavailable",
|
|
495
|
+
`Upstream vendor asset /vendor/${vendorPath} exceeds expected size (${buf.byteLength} > ${maxBytes} bytes).`
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
return new Uint8Array(buf);
|
|
499
|
+
}
|
|
500
|
+
const reader = response.body.getReader();
|
|
501
|
+
const chunks = [];
|
|
502
|
+
let totalBytes = 0;
|
|
503
|
+
try {
|
|
504
|
+
while (true) {
|
|
505
|
+
const { done, value } = await reader.read();
|
|
506
|
+
if (done) break;
|
|
507
|
+
if (!value || value.byteLength === 0) continue;
|
|
508
|
+
totalBytes += value.byteLength;
|
|
509
|
+
if (totalBytes > maxBytes) {
|
|
510
|
+
await reader.cancel().catch(() => void 0);
|
|
511
|
+
throw new AgentError(
|
|
512
|
+
"runtime-unavailable",
|
|
513
|
+
`Upstream vendor asset /vendor/${vendorPath} exceeds expected size (>${maxBytes} bytes).`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
chunks.push(value);
|
|
517
|
+
}
|
|
518
|
+
} catch (error) {
|
|
519
|
+
if (error instanceof AgentError) throw error;
|
|
520
|
+
if (signal.aborted) {
|
|
521
|
+
throw new AgentError("timeout", `Timed out fetching /vendor/${vendorPath} after ${this.fetchTimeoutMs}ms.`);
|
|
522
|
+
}
|
|
523
|
+
throw new AgentError(
|
|
524
|
+
"runtime-unavailable",
|
|
525
|
+
`Failed to read /vendor/${vendorPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
526
|
+
);
|
|
527
|
+
} finally {
|
|
528
|
+
reader.releaseLock();
|
|
529
|
+
}
|
|
530
|
+
const result = new Uint8Array(totalBytes);
|
|
531
|
+
let offset = 0;
|
|
532
|
+
for (const chunk of chunks) {
|
|
533
|
+
result.set(chunk, offset);
|
|
534
|
+
offset += chunk.byteLength;
|
|
535
|
+
}
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
458
538
|
fetchAndCache(vendorPath, segments, expectedSha) {
|
|
459
539
|
const existing = this.inflightDownloads.get(vendorPath);
|
|
460
540
|
if (existing) return existing;
|
|
461
541
|
const promise = (async () => {
|
|
462
542
|
const upstreamUrl = `${this.vendorUpstreamBaseUrl}/${vendorPath}`;
|
|
543
|
+
const maxBytes = this.expectedBytes(vendorPath) ?? DEFAULT_MAX_VENDOR_BYTES;
|
|
544
|
+
const signal = AbortSignal.timeout(this.fetchTimeoutMs);
|
|
463
545
|
let response;
|
|
464
546
|
try {
|
|
465
|
-
response = await fetch(upstreamUrl);
|
|
547
|
+
response = await fetch(upstreamUrl, { signal });
|
|
466
548
|
} catch (error) {
|
|
549
|
+
if (signal.aborted) {
|
|
550
|
+
throw new AgentError("timeout", `Timed out fetching /vendor/${vendorPath} after ${this.fetchTimeoutMs}ms.`);
|
|
551
|
+
}
|
|
467
552
|
throw new AgentError(
|
|
468
553
|
"runtime-unavailable",
|
|
469
554
|
`Failed to fetch /vendor/${vendorPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
470
555
|
);
|
|
471
556
|
}
|
|
472
557
|
if (!response.ok) {
|
|
558
|
+
await response.body?.cancel().catch(() => void 0);
|
|
473
559
|
throw new AgentError(
|
|
474
560
|
"runtime-unavailable",
|
|
475
561
|
`Upstream vendor fetch failed (${response.status}) for ${vendorPath}`
|
|
476
562
|
);
|
|
477
563
|
}
|
|
478
|
-
const bytes =
|
|
564
|
+
const bytes = await this.readBoundedResponse(response, vendorPath, maxBytes, signal);
|
|
479
565
|
if (sha256Hex(bytes) !== expectedSha) {
|
|
480
566
|
throw new AgentError(
|
|
481
567
|
"runtime-unavailable",
|
|
@@ -885,6 +971,8 @@ var ChromiumRenderer = class {
|
|
|
885
971
|
this.initPromise = null;
|
|
886
972
|
this.idleTimer = null;
|
|
887
973
|
this.activeRenders = 0;
|
|
974
|
+
this.disposed = false;
|
|
975
|
+
this.disposePromise = null;
|
|
888
976
|
this.persistent = options.persistent ?? false;
|
|
889
977
|
this.idleTimeoutMs = options.idleTimeoutMs ?? 5 * 60 * 1e3;
|
|
890
978
|
this.rendererHostDir = options.rendererHostDir ?? defaultRendererHostDir();
|
|
@@ -897,13 +985,16 @@ var ChromiumRenderer = class {
|
|
|
897
985
|
}
|
|
898
986
|
scheduleIdleShutdown() {
|
|
899
987
|
this.clearIdleTimer();
|
|
900
|
-
if (!this.persistent || this.activeRenders > 0) return;
|
|
988
|
+
if (this.disposed || !this.persistent || this.activeRenders > 0) return;
|
|
901
989
|
this.idleTimer = setTimeout(() => {
|
|
902
|
-
void this.
|
|
990
|
+
void this.closeRuntime();
|
|
903
991
|
}, this.idleTimeoutMs);
|
|
904
992
|
this.idleTimer.unref();
|
|
905
993
|
}
|
|
906
994
|
async ensureRuntime() {
|
|
995
|
+
if (this.disposed) {
|
|
996
|
+
throw new AgentError("runtime-unavailable", "ChromiumRenderer has been disposed.");
|
|
997
|
+
}
|
|
907
998
|
if (this.server && this.browser?.isAlive()) {
|
|
908
999
|
return { server: this.server, browser: this.browser };
|
|
909
1000
|
}
|
|
@@ -918,11 +1009,23 @@ var ChromiumRenderer = class {
|
|
|
918
1009
|
if (!this.server) {
|
|
919
1010
|
const server = new RenderAssetServer({ rendererHostDir: this.rendererHostDir });
|
|
920
1011
|
await server.start();
|
|
1012
|
+
if (this.disposed) {
|
|
1013
|
+
await server.close();
|
|
1014
|
+
throw new AgentError("runtime-unavailable", "ChromiumRenderer has been disposed.");
|
|
1015
|
+
}
|
|
921
1016
|
this.server = server;
|
|
922
1017
|
}
|
|
923
1018
|
if (!this.browser || !this.browser.isAlive()) {
|
|
924
1019
|
await this.browser?.close();
|
|
925
|
-
|
|
1020
|
+
const browser = await launchHeadlessBrowser();
|
|
1021
|
+
if (this.disposed) {
|
|
1022
|
+
await browser.close();
|
|
1023
|
+
const server = this.server;
|
|
1024
|
+
this.server = null;
|
|
1025
|
+
await server?.close();
|
|
1026
|
+
throw new AgentError("runtime-unavailable", "ChromiumRenderer has been disposed.");
|
|
1027
|
+
}
|
|
1028
|
+
this.browser = browser;
|
|
926
1029
|
}
|
|
927
1030
|
return { server: this.server, browser: this.browser };
|
|
928
1031
|
})().finally(() => {
|
|
@@ -996,31 +1099,36 @@ var ChromiumRenderer = class {
|
|
|
996
1099
|
});
|
|
997
1100
|
const hostUrl = `${server.origin}/renderer-host/index.html`;
|
|
998
1101
|
let navigatedToHost = false;
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1102
|
+
let loadTimer;
|
|
1103
|
+
let offNav;
|
|
1104
|
+
let offLoad;
|
|
1105
|
+
try {
|
|
1106
|
+
const loadDone = new Promise((resolveLoad, rejectLoad) => {
|
|
1107
|
+
loadTimer = setTimeout(() => {
|
|
1108
|
+
rejectLoad(new AgentError("timeout", "Timed out waiting for renderer-host to load."));
|
|
1109
|
+
}, timeoutMs);
|
|
1110
|
+
offNav = cdp.on("Page.frameNavigated", (params, eventSessionId) => {
|
|
1111
|
+
if (eventSessionId !== sessionId) return;
|
|
1112
|
+
const frame = params.frame;
|
|
1113
|
+
if (!frame?.parentId && frame?.url?.startsWith(server.origin)) {
|
|
1114
|
+
navigatedToHost = true;
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
offLoad = cdp.on("Page.loadEventFired", (_params, eventSessionId) => {
|
|
1118
|
+
if (eventSessionId === sessionId && navigatedToHost) {
|
|
1119
|
+
resolveLoad();
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1019
1122
|
});
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1123
|
+
loadDone.catch(() => void 0);
|
|
1124
|
+
await cdp.send("Page.navigate", { url: hostUrl }, sessionId, timeoutMs);
|
|
1125
|
+
await loadDone;
|
|
1126
|
+
} finally {
|
|
1127
|
+
if (loadTimer !== void 0) clearTimeout(loadTimer);
|
|
1128
|
+
offNav?.();
|
|
1129
|
+
offLoad?.();
|
|
1130
|
+
offException();
|
|
1131
|
+
}
|
|
1024
1132
|
const openPayload = {
|
|
1025
1133
|
pluginId: req.pluginId,
|
|
1026
1134
|
fileUrl: `${server.origin}${grant.filePathUrl}`,
|
|
@@ -1123,15 +1231,21 @@ var ChromiumRenderer = class {
|
|
|
1123
1231
|
}
|
|
1124
1232
|
grant?.revoke();
|
|
1125
1233
|
this.activeRenders -= 1;
|
|
1126
|
-
if (!this.
|
|
1127
|
-
if (this.
|
|
1128
|
-
|
|
1129
|
-
|
|
1234
|
+
if (!this.disposed) {
|
|
1235
|
+
if (!this.persistent) {
|
|
1236
|
+
if (this.activeRenders === 0) await this.closeRuntime();
|
|
1237
|
+
} else {
|
|
1238
|
+
this.scheduleIdleShutdown();
|
|
1239
|
+
}
|
|
1130
1240
|
}
|
|
1131
1241
|
}
|
|
1132
1242
|
}
|
|
1133
|
-
async
|
|
1243
|
+
async closeRuntime() {
|
|
1134
1244
|
this.clearIdleTimer();
|
|
1245
|
+
const inflight = this.initPromise;
|
|
1246
|
+
if (inflight) {
|
|
1247
|
+
await inflight.catch(() => void 0);
|
|
1248
|
+
}
|
|
1135
1249
|
const browser = this.browser;
|
|
1136
1250
|
const server = this.server;
|
|
1137
1251
|
this.browser = null;
|
|
@@ -1139,6 +1253,11 @@ var ChromiumRenderer = class {
|
|
|
1139
1253
|
await browser?.close();
|
|
1140
1254
|
await server?.close();
|
|
1141
1255
|
}
|
|
1256
|
+
async dispose() {
|
|
1257
|
+
this.disposed = true;
|
|
1258
|
+
this.disposePromise ??= this.closeRuntime();
|
|
1259
|
+
await this.disposePromise;
|
|
1260
|
+
}
|
|
1142
1261
|
};
|
|
1143
1262
|
|
|
1144
1263
|
// src/worker-pool.ts
|
|
@@ -1629,7 +1748,7 @@ async function clearVendorCache(cacheDir) {
|
|
|
1629
1748
|
// package.json
|
|
1630
1749
|
var package_default = {
|
|
1631
1750
|
name: "@anyfile/agent",
|
|
1632
|
-
version: "0.2.
|
|
1751
|
+
version: "0.2.1",
|
|
1633
1752
|
private: true,
|
|
1634
1753
|
type: "module",
|
|
1635
1754
|
bin: {
|
|
@@ -1822,8 +1941,25 @@ ${JSON.stringify(meta)}` }
|
|
|
1822
1941
|
}
|
|
1823
1942
|
}
|
|
1824
1943
|
const rl = createInterface({ input, crlfDelay: Infinity });
|
|
1944
|
+
let receivedSignal = null;
|
|
1945
|
+
let disposePromise = null;
|
|
1946
|
+
const disposeOnce = () => {
|
|
1947
|
+
disposePromise ??= service.dispose().catch(() => void 0);
|
|
1948
|
+
return disposePromise;
|
|
1949
|
+
};
|
|
1950
|
+
const onSignal = (signal) => {
|
|
1951
|
+
if (receivedSignal) return;
|
|
1952
|
+
receivedSignal = signal;
|
|
1953
|
+
rl.close();
|
|
1954
|
+
void disposeOnce();
|
|
1955
|
+
};
|
|
1956
|
+
const onSigint = () => onSignal("SIGINT");
|
|
1957
|
+
const onSigterm = () => onSignal("SIGTERM");
|
|
1958
|
+
process.once("SIGINT", onSigint);
|
|
1959
|
+
process.once("SIGTERM", onSigterm);
|
|
1825
1960
|
try {
|
|
1826
1961
|
for await (const rawLine of rl) {
|
|
1962
|
+
if (receivedSignal) break;
|
|
1827
1963
|
const line = rawLine.trim();
|
|
1828
1964
|
if (!line) continue;
|
|
1829
1965
|
let parsed;
|
|
@@ -1859,6 +1995,7 @@ ${JSON.stringify(meta)}` }
|
|
|
1859
1995
|
const name = typeof params.name === "string" ? params.name : "";
|
|
1860
1996
|
const args = params.arguments && typeof params.arguments === "object" && !Array.isArray(params.arguments) ? params.arguments : {};
|
|
1861
1997
|
const result = await handleToolCall(name, args);
|
|
1998
|
+
if (receivedSignal) break;
|
|
1862
1999
|
send({ id: req.id, result });
|
|
1863
2000
|
} else {
|
|
1864
2001
|
send({
|
|
@@ -1867,8 +2004,12 @@ ${JSON.stringify(meta)}` }
|
|
|
1867
2004
|
});
|
|
1868
2005
|
}
|
|
1869
2006
|
}
|
|
2007
|
+
return receivedSignal === "SIGINT" ? 130 : receivedSignal === "SIGTERM" ? 143 : 0;
|
|
1870
2008
|
} finally {
|
|
1871
|
-
|
|
2009
|
+
process.off("SIGINT", onSigint);
|
|
2010
|
+
process.off("SIGTERM", onSigterm);
|
|
2011
|
+
rl.close();
|
|
2012
|
+
await disposeOnce();
|
|
1872
2013
|
}
|
|
1873
2014
|
}
|
|
1874
2015
|
|
package/cli-main.mjs
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
clearVendorCache,
|
|
7
7
|
listVendorCache,
|
|
8
8
|
runMcpServer
|
|
9
|
-
} from "./chunks/chunk-
|
|
9
|
+
} from "./chunks/chunk-IGEGIF35.mjs";
|
|
10
10
|
import {
|
|
11
11
|
toAgentFileError
|
|
12
|
-
} from "./chunks/chunk-
|
|
12
|
+
} from "./chunks/chunk-HI7TURZM.mjs";
|
|
13
13
|
import "./chunks/chunk-HUSX3ZU3.mjs";
|
|
14
14
|
import "./chunks/chunk-5ZHDYRGV.mjs";
|
|
15
15
|
import {
|
|
@@ -115,8 +115,7 @@ async function runCli(argv) {
|
|
|
115
115
|
if (command === "mcp") {
|
|
116
116
|
const allowDirs = flags.get("allow-dir") ?? [];
|
|
117
117
|
const allowedRoots = [process.cwd(), ...allowDirs];
|
|
118
|
-
await runMcpServer({ allowedRoots });
|
|
119
|
-
return 0;
|
|
118
|
+
return await runMcpServer({ allowedRoots });
|
|
120
119
|
}
|
|
121
120
|
if (command === "cache") {
|
|
122
121
|
const sub = positionals[0] ?? "list";
|
|
@@ -162,6 +161,21 @@ async function runCli(argv) {
|
|
|
162
161
|
allowedRoots: [resolvedParent],
|
|
163
162
|
persistent: false
|
|
164
163
|
});
|
|
164
|
+
let receivedSignal = null;
|
|
165
|
+
let disposePromise = null;
|
|
166
|
+
const disposeOnce = () => {
|
|
167
|
+
disposePromise ??= service.dispose().catch(() => void 0);
|
|
168
|
+
return disposePromise;
|
|
169
|
+
};
|
|
170
|
+
const onSignal = (signal) => {
|
|
171
|
+
if (receivedSignal) return;
|
|
172
|
+
receivedSignal = signal;
|
|
173
|
+
void disposeOnce();
|
|
174
|
+
};
|
|
175
|
+
const onSigint = () => onSignal("SIGINT");
|
|
176
|
+
const onSigterm = () => onSignal("SIGTERM");
|
|
177
|
+
process.once("SIGINT", onSigint);
|
|
178
|
+
process.once("SIGTERM", onSigterm);
|
|
165
179
|
try {
|
|
166
180
|
if (command === "inspect") {
|
|
167
181
|
const result = await service.inspectFile(targetPath);
|
|
@@ -265,11 +279,16 @@ async function runCli(argv) {
|
|
|
265
279
|
}
|
|
266
280
|
throw new AgentError("invalid-argument", `Unknown command: ${command}`);
|
|
267
281
|
} catch (error) {
|
|
282
|
+
if (receivedSignal) {
|
|
283
|
+
return receivedSignal === "SIGINT" ? 130 : 143;
|
|
284
|
+
}
|
|
268
285
|
process.stderr.write(`${JSON.stringify(toAgentFileError(error))}
|
|
269
286
|
`);
|
|
270
287
|
return 1;
|
|
271
288
|
} finally {
|
|
272
|
-
|
|
289
|
+
process.off("SIGINT", onSigint);
|
|
290
|
+
process.off("SIGTERM", onSigterm);
|
|
291
|
+
await disposeOnce();
|
|
273
292
|
}
|
|
274
293
|
}
|
|
275
294
|
export {
|
package/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
listVendorCache,
|
|
17
17
|
resolveVendorAssetsForPlugins,
|
|
18
18
|
runMcpServer
|
|
19
|
-
} from "./chunks/chunk-
|
|
19
|
+
} from "./chunks/chunk-IGEGIF35.mjs";
|
|
20
20
|
import {
|
|
21
21
|
extractorLoaders,
|
|
22
22
|
hasExtractor
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
toAgentFileError,
|
|
40
40
|
trimInspectPayload,
|
|
41
41
|
trimReadResult
|
|
42
|
-
} from "./chunks/chunk-
|
|
42
|
+
} from "./chunks/chunk-HI7TURZM.mjs";
|
|
43
43
|
import "./chunks/chunk-HUSX3ZU3.mjs";
|
|
44
44
|
import "./chunks/chunk-5ZHDYRGV.mjs";
|
|
45
45
|
import "./chunks/chunk-IC3G2XE2.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyfile-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Read-only CLI and MCP server that lets AI agents inspect, extract, SQL-query, and render a wide range of local file formats without uploading them.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agent",
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"happy-dom": "20.11.6"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,n as t,u as n}from"./src-
|
|
1
|
+
import{g as e,n as t,u as n}from"./src-MO5bLsLj.js";import{a as r,i,n as a,r as o,t as s}from"./model-Drd3vqcF.js";function c(c){let l=r(c);if(l.localName!==`amf`)throw Error(`Invalid AMF`);if(o(l,`constellation`).length)throw Error(`AMF constellations are not implemented`);let u=new e,d=0,f=0,p=0,m=e=>{let t=e&&o(e,`color`)[0];if(!t)return;let r=[`r`,`g`,`b`].map(e=>i(a(t,e).textContent));if(r.some(e=>e<0||e>1))throw Error(`Invalid AMF color`);return`#${new n(...r).getHexString()}`},h=new Map(o(l,`material`).map(e=>[e.getAttribute(`id`),m(e)])),g=l.getAttribute(`unit`)||`millimeter`;if(![`millimeter`,`meter`,`micron`,`inch`,`feet`].includes(g))throw Error(`Invalid AMF unit`);try{for(let t of o(l,`object`)){if(u.children.length>4096)throw RangeError();let n=a(t,`mesh`),r=o(a(n,`vertices`),`vertex`).flatMap(e=>{let t=a(e,`coordinates`);return[`x`,`y`,`z`].map(e=>i(a(t,e).textContent))}),c=new e;c.name=t.getAttribute(`id`)||`AMF`,u.add(c);for(let e of o(n,`volume`)){let n=o(e,`triangle`).flatMap(e=>[`v1`,`v2`,`v3`].map(t=>i(a(e,t).textContent)));if(d+=r.length/3,f+=n.length,++p>4096||d>2e6||f>6e6)throw RangeError(`AMF total geometry budget`);c.add(s(r,n,m(e)||h.get(e.getAttribute(`materialid`))||m(t)))}}return{root:u,up:`z`,units:g}}catch(e){throw t(u),e}}export{c as loadAmf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t}from"./index-
|
|
1
|
+
import{a as e,o as t}from"./index-DtiyOy_J.js";import{r as n}from"./src-hCrza_Lf.js";import{a as r,i,n as a,r as o}from"./src-Y6mXl4vh.js";var s=class{constructor(e,t,n,r,i,a){this.decoder=e,this.frameCount=t,this.repetitionCount=n,this.draw=r,this.changed=i,this.failed=a,this.state={index:0,duration:null,playing:!1,busy:!1,ended:!1,rate:1},this.generation=0,this.disposed=!1,this.repeats=0,this.deadline=0,this.fail=e=>{this.disposed||(this.pause(),this.failed(e))}}async initialize(){await this.show(0)}pause(){this.generation++,clearTimeout(this.timer),this.state.playing=!1,this.notify()}play(){this.disposed||this.state.busy||this.state.playing||this.frameCount<2||this.state.duration===null||(this.state.playing=!0,this.state.ended?(this.state.ended=!1,this.repeats=0,this.show(0).then(()=>this.schedule(!0)).catch(this.fail)):this.schedule(!0),this.notify())}setRate(e){if(this.disposed)return;let t=this.state.rate;if(this.state.rate=e,this.state.playing&&!this.state.busy){let n=performance.now();this.deadline=n+Math.max(0,this.deadline-n)*t/e,clearTimeout(this.timer),this.queue()}this.notify()}step(e){if(this.disposed||this.state.busy)return;this.pause(),this.state.ended=!1,this.repeats=0;let t=Math.max(0,Math.min(this.frameCount-1,this.state.index+e));t!==this.state.index&&this.show(t).catch(this.fail)}dispose(){this.disposed||(this.disposed=!0,this.pause())}notify(){this.disposed||this.changed({...this.state})}async show(e){let t=this.generation;this.state.busy=!0,this.notify();try{let{image:n}=await this.decoder.decode({frameIndex:e,completeFramesOnly:!0});try{if(this.disposed||t!==this.generation)return;this.draw(n),this.state.index=e,this.state.duration=n.duration===null?null:n.duration/1e3}finally{n.close()}}finally{this.state.busy=!1,this.notify()}}schedule(e){if(this.disposed||!this.state.playing)return;if(this.state.duration===null){this.pause();return}let t=Math.max(1,this.state.duration/this.state.rate);this.deadline=e?performance.now()+t:Math.max(this.deadline+t,performance.now()),this.queue()}queue(){this.timer=setTimeout(()=>{this.advance().catch(this.fail)},Math.max(0,this.deadline-performance.now()))}async advance(){if(!this.state.playing||this.disposed)return;let e=this.state.index+1;if(e===this.frameCount){if(!Number.isNaN(this.repetitionCount)&&this.repeats<this.repetitionCount)this.repeats++,e=0;else{this.state.ended=!0,this.pause();return}}await this.show(e),this.schedule(!1)}};async function c(c,l){let u=new n,d=!1,f=()=>{d||(d=!0,u.dispose())};u.listen(c.signal,`abort`,f);let p=r(c.locale);try{let n=await i(c.file,l,c.signal,c.locale);if(u.add(n.close),c.signal.aborted)throw t();if(!n.track.animated)return f(),null;let r=document.createElement(`canvas`);r.width=n.info.width,r.height=n.info.height,u.add(()=>{r.width=0,r.height=0});let d=r.getContext(`2d`);if(!d)throw new e(`unsupported-environment`,p.copy.unavailable);let m=o(c.file.name,{...n.info,animated:!0,frameCount:n.track.frameCount},r.width,r.height,c.locale,r);u.add(()=>m.root.remove()),m.root.insertBefore(p.root,m.viewport);let{copy:h}=p,g=!1,_=new s(n.decoder,n.track.frameCount,n.track.repetitionCount,t=>{if(t.displayWidth!==r.width||t.displayHeight!==r.height)throw new e(`invalid-file`,h.invalid);d.clearRect(0,0,r.width,r.height),d.drawImage(t,0,0)},e=>{p.speed.value=String(e.rate),p.speed.disabled=g||e.duration===null,p.play.textContent=e.playing?h.pause:h.play,p.play.disabled=g||!e.playing&&(e.busy||e.duration===null||n.track.frameCount<2),p.previous.disabled=g||e.busy||e.index===0,p.next.disabled=g||e.busy||e.index===n.track.frameCount-1;let t=n.track.repetitionCount,r=t===1/0?h.forever:Number.isFinite(t)&&t>=0?String(t+1):h.unknown,i=e.duration===null?h.unknown:`${new Intl.NumberFormat(c.locale,{maximumFractionDigits:3}).format(e.duration)} ms`;p.status.textContent=`${h.frame} ${e.index+1} / ${n.track.frameCount} · ${h.duration}: ${i} · ${h.loops}: ${r}`},()=>{g=!0,n.close(),p.error.textContent=h.invalid,p.error.hidden=!1,p.play.disabled=p.previous.disabled=p.next.disabled=p.speed.disabled=!0,c.reportPreview?.({outcome:`failure`,reason:`invalid-file`})});if(u.add(()=>_.dispose()),await _.initialize(),c.signal.aborted)throw t();c.container.append(m.root);let v=new a(m,r.width,r.height);u.add(()=>v.dispose()),u.listen(p.play,`click`,()=>{let e=_.state.playing?`pause`:`play`;_.state.playing?_.pause():_.play(),c.reportInteraction?.({kind:`animation_control`,action:e})});for(let[e,t,n]of[[p.previous,-1,`previous_frame`],[p.next,1,`next_frame`]])u.listen(e,`click`,()=>{_.step(t),c.reportInteraction?.({kind:`animation_control`,action:n})});u.listen(p.speed,`change`,()=>{_.setRate(Number(p.speed.value)),c.reportInteraction?.({kind:`animation_control`,action:`speed_change`})});let y=window.matchMedia(`(prefers-reduced-motion: reduce)`);return u.listen(y,`change`,()=>{y.matches&&_.pause()}),u.listen(document,`visibilitychange`,()=>{document.hidden&&_.pause()}),!y.matches&&!document.hidden&&_.play(),_.state.duration===null&&(p.error.textContent=h.timing,p.error.hidden=!1),c.reportPreview?.({outcome:`success`,kind:`animation`}),{dispose:f}}catch(n){throw f(),c.signal.aborted?t():n instanceof e?n:new e(`invalid-file`,p.copy.invalid,{cause:n})}}export{c as openAnimation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./index-
|
|
1
|
+
import{a as e}from"./index-DtiyOy_J.js";import{t}from"./book-worker-DUt14LJO.js";async function n(n,r){if(r.throwIfAborted(),n.size>128*1024**2)throw new e(`resource-limit`,`Compressed comic size limit.`);if(typeof Worker>`u`||typeof WebAssembly>`u`)throw new e(`unsupported-environment`,`Comic decoder unavailable.`);let i=t(new Worker(new URL(`/renderer-host/assets/archive.worker-CcLnJ9FC.js`,``+import.meta.url),{type:`module`}),r);try{let e=await i.request({type:`open`,file:n,runtime:new URL(`/vendor/comic-archive/3.8.9-anyfile.1/comic-archive.js`,location.origin).href});r.throwIfAborted();let t=new Map(e.entries.map(e=>[e.filename,e]));return{entries:t,read(e,t,n=r){return i.request({type:`read`,path:e,limit:t},n)},async dispose(){i.dispose(),t.clear()}}}catch(e){throw i.dispose(),e}}export{n as openCompressedComic};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./index-
|
|
1
|
+
import{a as e}from"./index-DtiyOy_J.js";import{t}from"./book-source-28BQcBKR.js";function n(n,r){let i=0,a=!1,o=new Map;function s(e=new DOMException(`Aborted`,`AbortError`)){if(!a){a=!0,r.removeEventListener(`abort`,c),n.terminate();for(let t of o.values())t.cleanup(),t.reject(e);o.clear()}}let c=()=>s();return r.addEventListener(`abort`,c,{once:!0}),n.onerror=()=>s(new e(`open-failed`,`Book worker failed.`)),n.onmessage=({data:n})=>{let r=o.get(n.id);r&&(o.delete(n.id),r.cleanup(),n.error?r.reject(n.error===`protected`?new t:new e(n.error,`Book decoder failed.`)):r.resolve(n.result))},{dispose:s,request(t,c=r){if(a||r.aborted||c.aborted)return Promise.reject(new DOMException(`Aborted`,`AbortError`));let l=++i;return new Promise((r,i)=>{let a=()=>{o.delete(l),d(),i(new DOMException(`Aborted`,`AbortError`))},u=setTimeout(()=>s(new e(`resource-limit`,`Book decode time limit exceeded.`)),6e4),d=()=>{clearTimeout(u),c.removeEventListener(`abort`,a)};o.set(l,{resolve:e=>r(e),reject:i,cleanup:d}),c.addEventListener(`abort`,a,{once:!0});try{n.postMessage({...t,id:l})}catch{s(new e(`open-failed`,`Book worker failed.`))}})}}}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./index-
|
|
1
|
+
import{a as e}from"./index-DtiyOy_J.js";var t=`9.0.1-anyfile.4`,n=`/vendor/ffmpeg-playback/${t}/`,r=[`https://assets.anyfile.top/vendor/ffmpeg-playback/${t}/`,n],i=class{#e;#t;#n=0;#r=!1;#i;constructor(t){t.throwIfAborted(),this.#e=new Worker(`${n}ffmpeg-playback.worker.js`,{type:`module`});let r=()=>this.dispose();t.addEventListener(`abort`,r,{once:!0}),this.#i=()=>t.removeEventListener(`abort`,r),this.#e.onmessage=({data:t})=>{let n=this.#t;if(!(!n||t.id!==n.id)){if(this.#t=void 0,clearTimeout(n.timer),t.error){let r=[`invalid-file`,`resource-limit`,`unsupported-environment`].includes(t.error.code)?t.error.code:t.error.code===`unsupported-media`?`invalid-file`:`open-failed`;n.reject(new e(r,`FFmpeg operation failed`)),this.dispose()}else n.resolve(t.result)}},this.#e.onerror=()=>this.dispose(new e(`unsupported-environment`,`FFmpeg Worker failed`)),this.#e.onmessageerror=()=>this.dispose(new e(`open-failed`,`FFmpeg message failed`))}request(t,n={}){if(this.#r)return Promise.reject(new DOMException(`Disposed`,`AbortError`));if(this.#t)return Promise.reject(Error(`Concurrent FFmpeg command`));let r=++this.#n;return new Promise((i,a)=>{let o=setTimeout(()=>this.dispose(new e(t===`init`?`unsupported-environment`:`resource-limit`,`FFmpeg operation timed out`)),t===`init`?1e4:15e3);this.#t={id:r,resolve:e=>i(e),reject:a,timer:o};try{this.#e.postMessage({...n,type:t,id:r,generation:0})}catch(e){this.dispose(e)}})}open(e,t){return this.request(`open`,{file:e,video:t})}openPanorama(e){return this.request(`open`,{file:e,panorama:!0})}next(){return this.request(`next`)}seek(e){return this.request(`seek`,{time:e})}dispose(e=new DOMException(`Disposed`,`AbortError`)){this.#r||(this.#r=!0,this.#i(),this.#e.terminate(),this.#e.onmessage=this.#e.onerror=this.#e.onmessageerror=null,this.#t&&=(clearTimeout(this.#t.timer),this.#t.reject(e),void 0))}};async function a(t){for(let e of r){t.throwIfAborted();let n=new i(t);try{return await n.request(`init`,{assetBase:new URL(e,location.href).href}),n}catch{n.dispose(),t.throwIfAborted()}}throw new e(`unsupported-environment`,`Unable to initialize FFmpeg`)}export{a as n,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./webm-14HHwfWy.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./image-load-SK3ULGWm.js";
|