@openartifactsai/cli 0.23.0-rc.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/vendor/frame-host/frame-host.mjs +176 -52
- package/vendor/open-artifacts.mjs +5 -5
- package/vendor/runtime.json +1 -1
- package/vendor/type-server/cli.mjs +275 -171
|
@@ -1346,7 +1346,7 @@ function lineDecoder() {
|
|
|
1346
1346
|
}
|
|
1347
1347
|
async function* decode(body, decoder2, onChunk) {
|
|
1348
1348
|
const reader = body.getReader();
|
|
1349
|
-
let
|
|
1349
|
+
let ended2 = false;
|
|
1350
1350
|
try {
|
|
1351
1351
|
for (; ; ) {
|
|
1352
1352
|
const { value: value2, done: done2 } = await reader.read();
|
|
@@ -1354,10 +1354,10 @@ async function* decode(body, decoder2, onChunk) {
|
|
|
1354
1354
|
onChunk?.();
|
|
1355
1355
|
yield* decoder2.push(value2);
|
|
1356
1356
|
}
|
|
1357
|
-
|
|
1357
|
+
ended2 = true;
|
|
1358
1358
|
yield* decoder2.end();
|
|
1359
1359
|
} finally {
|
|
1360
|
-
if (!
|
|
1360
|
+
if (!ended2) await reader.cancel().catch(() => void 0);
|
|
1361
1361
|
reader.releaseLock();
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
@@ -9213,10 +9213,10 @@ var init_connectors2 = __esm({
|
|
|
9213
9213
|
}
|
|
9214
9214
|
}
|
|
9215
9215
|
this.entries = next;
|
|
9216
|
-
for (const [name,
|
|
9217
|
-
if (next.get(name)?.key ===
|
|
9216
|
+
for (const [name, running2] of [...this.clients]) {
|
|
9217
|
+
if (next.get(name)?.key === running2.key) continue;
|
|
9218
9218
|
this.clients.delete(name);
|
|
9219
|
-
void
|
|
9219
|
+
void running2.client.close();
|
|
9220
9220
|
}
|
|
9221
9221
|
}
|
|
9222
9222
|
/** The client of a usable, enabled server; throws `server_not_connected` otherwise. */
|
|
@@ -9229,8 +9229,8 @@ var init_connectors2 = __esm({
|
|
|
9229
9229
|
}
|
|
9230
9230
|
if (entry.error !== void 0) throw new McpError("server_not_connected", `${server}: ${entry.error}`);
|
|
9231
9231
|
if (entry.config.disabled) throw new McpError("server_not_connected", `${server} is turned off in ${this.file}.`);
|
|
9232
|
-
const
|
|
9233
|
-
if (
|
|
9232
|
+
const running2 = this.clients.get(server);
|
|
9233
|
+
if (running2?.key === entry.key) return running2.client;
|
|
9234
9234
|
const config = entry.config;
|
|
9235
9235
|
const client = "command" in config ? new StdioMcpClient(server, config, { log: this.log, ...this.clientInfo ? { clientInfo: this.clientInfo } : {} }) : new HttpMcpClient(server, config, this.clientInfo ? { clientInfo: this.clientInfo } : {});
|
|
9236
9236
|
this.clients.set(server, { key: entry.key, client });
|
|
@@ -9271,9 +9271,9 @@ var init_connectors2 = __esm({
|
|
|
9271
9271
|
/** Stops every server this host started. */
|
|
9272
9272
|
async close() {
|
|
9273
9273
|
process.off("exit", this.onExit);
|
|
9274
|
-
const
|
|
9274
|
+
const running2 = [...this.clients.values()];
|
|
9275
9275
|
this.clients.clear();
|
|
9276
|
-
await Promise.all(
|
|
9276
|
+
await Promise.all(running2.map(({ client }) => client.close()));
|
|
9277
9277
|
}
|
|
9278
9278
|
};
|
|
9279
9279
|
}
|
|
@@ -48835,11 +48835,156 @@ var init_history_host = __esm({
|
|
|
48835
48835
|
}
|
|
48836
48836
|
});
|
|
48837
48837
|
|
|
48838
|
+
// packages/server-sdk/src/chrome.ts
|
|
48839
|
+
import { readFileSync as readFileSync13, rmSync as rmSync6 } from "node:fs";
|
|
48840
|
+
import { join as join19 } from "node:path";
|
|
48841
|
+
function activePortEndpoint(profile) {
|
|
48842
|
+
let text;
|
|
48843
|
+
try {
|
|
48844
|
+
text = readFileSync13(join19(profile, DEVTOOLS_ACTIVE_PORT), "utf8");
|
|
48845
|
+
} catch {
|
|
48846
|
+
return null;
|
|
48847
|
+
}
|
|
48848
|
+
const [port, path20] = text.split(/\r?\n/);
|
|
48849
|
+
if (!port || !/^\d+$/.test(port) || !path20?.startsWith("/devtools/browser/")) return null;
|
|
48850
|
+
return `ws://127.0.0.1:${port}${path20}`;
|
|
48851
|
+
}
|
|
48852
|
+
function waitForDevTools(wait) {
|
|
48853
|
+
const { child: child2, profile, stderr, timeoutMs, relaunchMs = Infinity, name = "Chrome" } = wait;
|
|
48854
|
+
const started = Date.now();
|
|
48855
|
+
return new Promise((resolve19, reject2) => {
|
|
48856
|
+
let exitedAt = null;
|
|
48857
|
+
let poll;
|
|
48858
|
+
let settled = false;
|
|
48859
|
+
const settle = (then) => {
|
|
48860
|
+
if (settled) return;
|
|
48861
|
+
settled = true;
|
|
48862
|
+
clearInterval(poll);
|
|
48863
|
+
then();
|
|
48864
|
+
};
|
|
48865
|
+
child2.once("error", (error) => settle(() => reject2(error)));
|
|
48866
|
+
const check = () => {
|
|
48867
|
+
const said = stderr();
|
|
48868
|
+
const endpoint = /DevTools listening on (ws:\/\/\S+)/.exec(said)?.[1] ?? activePortEndpoint(profile);
|
|
48869
|
+
if (endpoint) return settle(() => resolve19(endpoint));
|
|
48870
|
+
const last = said.trim().slice(-400);
|
|
48871
|
+
const failed = (message) => settle(() => reject2(new Error(last ? `${message}: ${last}` : `${message}.`)));
|
|
48872
|
+
if (child2.signalCode !== null || child2.exitCode !== null && child2.exitCode !== 0) {
|
|
48873
|
+
return failed(`${name} exited (${child2.exitCode ?? child2.signalCode})`);
|
|
48874
|
+
}
|
|
48875
|
+
const relaunched = `${name} exited (0), and no browser it started serves its profile`;
|
|
48876
|
+
if (child2.exitCode === 0) {
|
|
48877
|
+
exitedAt ??= Date.now();
|
|
48878
|
+
if (Date.now() - exitedAt > relaunchMs) return failed(relaunched);
|
|
48879
|
+
}
|
|
48880
|
+
if (Date.now() - started > timeoutMs) failed(child2.exitCode === 0 ? relaunched : `${name} did not start in ${Math.round(timeoutMs / 1e3)} s`);
|
|
48881
|
+
};
|
|
48882
|
+
poll = setInterval(check, 50);
|
|
48883
|
+
});
|
|
48884
|
+
}
|
|
48885
|
+
function closeBrowserAt(endpoint, waitMs = 3e3, exitMs = 5e3) {
|
|
48886
|
+
return new Promise((resolve19) => {
|
|
48887
|
+
let socket;
|
|
48888
|
+
let pid = null;
|
|
48889
|
+
let closing = false;
|
|
48890
|
+
let hungUp = false;
|
|
48891
|
+
let unanswered;
|
|
48892
|
+
const timer = setTimeout(() => hangUp(), waitMs);
|
|
48893
|
+
const askToClose = () => {
|
|
48894
|
+
if (closing || hungUp) return;
|
|
48895
|
+
closing = true;
|
|
48896
|
+
socket.send(JSON.stringify({ id: 2, method: "Browser.close" }));
|
|
48897
|
+
};
|
|
48898
|
+
const hangUp = () => {
|
|
48899
|
+
if (hungUp) return;
|
|
48900
|
+
hungUp = true;
|
|
48901
|
+
clearTimeout(timer);
|
|
48902
|
+
clearTimeout(unanswered);
|
|
48903
|
+
try {
|
|
48904
|
+
socket?.close();
|
|
48905
|
+
} catch {
|
|
48906
|
+
}
|
|
48907
|
+
if (pid === null) resolve19();
|
|
48908
|
+
else void waitForExit(pid, exitMs).then(resolve19);
|
|
48909
|
+
};
|
|
48910
|
+
try {
|
|
48911
|
+
socket = new WebSocket(endpoint);
|
|
48912
|
+
} catch {
|
|
48913
|
+
return hangUp();
|
|
48914
|
+
}
|
|
48915
|
+
socket.addEventListener(
|
|
48916
|
+
"open",
|
|
48917
|
+
() => {
|
|
48918
|
+
socket.send(JSON.stringify({ id: 1, method: "SystemInfo.getProcessInfo" }));
|
|
48919
|
+
unanswered = setTimeout(askToClose, 1e3);
|
|
48920
|
+
},
|
|
48921
|
+
{ once: true }
|
|
48922
|
+
);
|
|
48923
|
+
socket.addEventListener("message", (event) => {
|
|
48924
|
+
let answer;
|
|
48925
|
+
try {
|
|
48926
|
+
answer = JSON.parse(String(event.data));
|
|
48927
|
+
} catch {
|
|
48928
|
+
return;
|
|
48929
|
+
}
|
|
48930
|
+
if (answer.id !== 1) return;
|
|
48931
|
+
const browser = answer.result?.processInfo?.find((info) => info.type === "browser")?.id;
|
|
48932
|
+
if (typeof browser === "number" && Number.isInteger(browser) && browser > 0 && browser !== process.pid) pid = browser;
|
|
48933
|
+
askToClose();
|
|
48934
|
+
});
|
|
48935
|
+
socket.addEventListener("close", () => hangUp(), { once: true });
|
|
48936
|
+
socket.addEventListener("error", () => hangUp(), { once: true });
|
|
48937
|
+
});
|
|
48938
|
+
}
|
|
48939
|
+
function running(pid) {
|
|
48940
|
+
try {
|
|
48941
|
+
process.kill(pid, 0);
|
|
48942
|
+
return true;
|
|
48943
|
+
} catch (error) {
|
|
48944
|
+
return error.code === "EPERM";
|
|
48945
|
+
}
|
|
48946
|
+
}
|
|
48947
|
+
async function ended(pid, ms) {
|
|
48948
|
+
const deadline = Date.now() + ms;
|
|
48949
|
+
while (running(pid)) {
|
|
48950
|
+
if (Date.now() >= deadline) return false;
|
|
48951
|
+
await new Promise((done2) => setTimeout(done2, 25));
|
|
48952
|
+
}
|
|
48953
|
+
return true;
|
|
48954
|
+
}
|
|
48955
|
+
async function waitForExit(pid, ms) {
|
|
48956
|
+
if (await ended(pid, ms)) return;
|
|
48957
|
+
try {
|
|
48958
|
+
process.kill(pid, "SIGKILL");
|
|
48959
|
+
} catch {
|
|
48960
|
+
return;
|
|
48961
|
+
}
|
|
48962
|
+
await ended(pid, 1e3);
|
|
48963
|
+
}
|
|
48964
|
+
function removeProfile(profile) {
|
|
48965
|
+
const remove = () => {
|
|
48966
|
+
try {
|
|
48967
|
+
rmSync6(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
48968
|
+
return true;
|
|
48969
|
+
} catch {
|
|
48970
|
+
return false;
|
|
48971
|
+
}
|
|
48972
|
+
};
|
|
48973
|
+
if (!remove()) setTimeout(remove, 2e3).unref();
|
|
48974
|
+
}
|
|
48975
|
+
var DEVTOOLS_ACTIVE_PORT;
|
|
48976
|
+
var init_chrome = __esm({
|
|
48977
|
+
"packages/server-sdk/src/chrome.ts"() {
|
|
48978
|
+
"use strict";
|
|
48979
|
+
DEVTOOLS_ACTIVE_PORT = "DevToolsActivePort";
|
|
48980
|
+
}
|
|
48981
|
+
});
|
|
48982
|
+
|
|
48838
48983
|
// packages/server-sdk/src/snapshot.ts
|
|
48839
48984
|
import { spawn as spawn2 } from "node:child_process";
|
|
48840
|
-
import { closeSync as closeSync2, existsSync as existsSync11, mkdtempSync, openSync as openSync2, readFileSync as
|
|
48985
|
+
import { closeSync as closeSync2, existsSync as existsSync11, mkdtempSync, openSync as openSync2, readFileSync as readFileSync14 } from "node:fs";
|
|
48841
48986
|
import { tmpdir } from "node:os";
|
|
48842
|
-
import { join as
|
|
48987
|
+
import { join as join20, win32 } from "node:path";
|
|
48843
48988
|
function windowsCandidates(env = process.env) {
|
|
48844
48989
|
const roots = [
|
|
48845
48990
|
env.ProgramW6432,
|
|
@@ -48867,8 +49012,8 @@ function findChrome() {
|
|
|
48867
49012
|
return CANDIDATES.find((path20) => existsSync11(path20)) ?? null;
|
|
48868
49013
|
}
|
|
48869
49014
|
async function snapshotPage(chrome, request) {
|
|
48870
|
-
const profile = mkdtempSync(
|
|
48871
|
-
const stderr =
|
|
49015
|
+
const profile = mkdtempSync(join20(tmpdir(), "open-artifacts-snapshot-"));
|
|
49016
|
+
const stderr = join20(profile, "chrome-stderr.log");
|
|
48872
49017
|
const fd = openSync2(stderr, "a");
|
|
48873
49018
|
const child2 = spawn2(
|
|
48874
49019
|
chrome,
|
|
@@ -48893,43 +49038,28 @@ async function snapshotPage(chrome, request) {
|
|
|
48893
49038
|
);
|
|
48894
49039
|
closeSync2(fd);
|
|
48895
49040
|
let ws = null;
|
|
49041
|
+
let endpoint = null;
|
|
48896
49042
|
let timer;
|
|
48897
|
-
const removeProfile = () => {
|
|
48898
|
-
try {
|
|
48899
|
-
rmSync6(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
48900
|
-
return true;
|
|
48901
|
-
} catch {
|
|
48902
|
-
return false;
|
|
48903
|
-
}
|
|
48904
|
-
};
|
|
48905
49043
|
const cleanup = async () => {
|
|
48906
49044
|
clearTimeout(timer);
|
|
48907
49045
|
try {
|
|
48908
49046
|
ws?.close();
|
|
48909
49047
|
} catch {
|
|
48910
49048
|
}
|
|
49049
|
+
const browser = endpoint ?? activePortEndpoint(profile);
|
|
49050
|
+
if (browser) await closeBrowserAt(browser);
|
|
48911
49051
|
await stopChild(child2, { graceMs: 0, settleMs: 3e3 });
|
|
48912
|
-
|
|
49052
|
+
removeProfile(profile);
|
|
48913
49053
|
};
|
|
48914
49054
|
const work = async () => {
|
|
48915
|
-
const
|
|
48916
|
-
|
|
48917
|
-
|
|
48918
|
-
|
|
48919
|
-
|
|
48920
|
-
|
|
48921
|
-
|
|
48922
|
-
|
|
48923
|
-
const found = /DevTools listening on (ws:\/\/\S+)/.exec(text);
|
|
48924
|
-
if (found) {
|
|
48925
|
-
clearInterval(poll);
|
|
48926
|
-
resolveEndpoint(found[1]);
|
|
48927
|
-
} else if (child2.exitCode !== null || Date.now() - started > CHROME_START_MS) {
|
|
48928
|
-
clearInterval(poll);
|
|
48929
|
-
reject2(new Error(`Chrome did not start: ${text.slice(-300)}`));
|
|
48930
|
-
}
|
|
48931
|
-
}, 50);
|
|
48932
|
-
});
|
|
49055
|
+
const readStderr = () => {
|
|
49056
|
+
try {
|
|
49057
|
+
return readFileSync14(stderr, "utf8");
|
|
49058
|
+
} catch {
|
|
49059
|
+
return "";
|
|
49060
|
+
}
|
|
49061
|
+
};
|
|
49062
|
+
endpoint = await waitForDevTools({ child: child2, profile, stderr: readStderr, timeoutMs: CHROME_START_MS });
|
|
48933
49063
|
const socket = new WebSocket(endpoint);
|
|
48934
49064
|
ws = socket;
|
|
48935
49065
|
await new Promise((opened, failed) => {
|
|
@@ -49001,6 +49131,7 @@ var init_snapshot = __esm({
|
|
|
49001
49131
|
"packages/server-sdk/src/snapshot.ts"() {
|
|
49002
49132
|
"use strict";
|
|
49003
49133
|
init_child();
|
|
49134
|
+
init_chrome();
|
|
49004
49135
|
WINDOWS_BROWSERS = [
|
|
49005
49136
|
["Google\\Chrome\\Application", "chrome.exe"],
|
|
49006
49137
|
["Microsoft\\Edge\\Application", "msedge.exe"]
|
|
@@ -49639,7 +49770,7 @@ var init_daemon_connectors = __esm({
|
|
|
49639
49770
|
});
|
|
49640
49771
|
|
|
49641
49772
|
// packages/type-server/src/connector-shares.ts
|
|
49642
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
49773
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, renameSync as renameSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
49643
49774
|
import { dirname as dirname8 } from "node:path";
|
|
49644
49775
|
function sharedCallKey(call) {
|
|
49645
49776
|
return canonicalJson({
|
|
@@ -49720,7 +49851,7 @@ var init_connector_shares = __esm({
|
|
|
49720
49851
|
if (this.#data !== null) return this.#data;
|
|
49721
49852
|
let data2 = { version: 1, artifacts: {} };
|
|
49722
49853
|
try {
|
|
49723
|
-
const parsed3 = JSON.parse(
|
|
49854
|
+
const parsed3 = JSON.parse(readFileSync15(this.#file, "utf8"));
|
|
49724
49855
|
if (isPlainObject(parsed3) && isPlainObject(parsed3.artifacts)) data2 = { version: 1, artifacts: parsed3.artifacts };
|
|
49725
49856
|
} catch {
|
|
49726
49857
|
}
|
|
@@ -49818,16 +49949,16 @@ ${canonicalJson([approved.tool, filled.args])}`;
|
|
|
49818
49949
|
let answer;
|
|
49819
49950
|
if (kept !== void 0 && (keptAge < SHARED_RESULT_FLOOR_MS || keptAge < reuse && options.refresh !== true)) answer = kept;
|
|
49820
49951
|
else {
|
|
49821
|
-
let
|
|
49822
|
-
if (
|
|
49952
|
+
let running2 = this.#running.get(runKey);
|
|
49953
|
+
if (running2 === void 0) {
|
|
49823
49954
|
const started = this.#call(approved.connector, approved.tool, filled.args, SHARED_CALL_TIMEOUT_MS).then((result) => ({ result, ranAt: this.#now() })).finally(() => {
|
|
49824
49955
|
if (this.#running.get(runKey) === started) this.#running.delete(runKey);
|
|
49825
49956
|
});
|
|
49826
|
-
|
|
49827
|
-
this.#running.set(runKey,
|
|
49957
|
+
running2 = started;
|
|
49958
|
+
this.#running.set(runKey, running2);
|
|
49828
49959
|
}
|
|
49829
49960
|
try {
|
|
49830
|
-
answer = await
|
|
49961
|
+
answer = await running2;
|
|
49831
49962
|
} catch (error) {
|
|
49832
49963
|
return { ok: false, code: failureCode(error), sharer: share.sharer };
|
|
49833
49964
|
}
|
|
@@ -49857,7 +49988,7 @@ var init_mcp_client2 = __esm({
|
|
|
49857
49988
|
// packages/type-server/src/upgrade-cli.ts
|
|
49858
49989
|
import { existsSync as existsSync12 } from "node:fs";
|
|
49859
49990
|
import { readdir as readdir5 } from "node:fs/promises";
|
|
49860
|
-
import { join as
|
|
49991
|
+
import { join as join21, resolve as resolve9 } from "node:path";
|
|
49861
49992
|
async function writeOnDisk(root, writes) {
|
|
49862
49993
|
const history = new History(root);
|
|
49863
49994
|
const tracks = historyTracksOf("motion");
|
|
@@ -49900,7 +50031,7 @@ async function upgradeFilm(root, { dryRun = false, write } = {}) {
|
|
|
49900
50031
|
}
|
|
49901
50032
|
async function filmsUnder(root) {
|
|
49902
50033
|
if (await detectType(root) === "motion") return [root];
|
|
49903
|
-
if (existsSync12(
|
|
50034
|
+
if (existsSync12(join21(root, "db"))) return [];
|
|
49904
50035
|
let entries;
|
|
49905
50036
|
try {
|
|
49906
50037
|
entries = (await readdir5(root, { withFileTypes: true })).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
|
|
@@ -49909,7 +50040,7 @@ async function filmsUnder(root) {
|
|
|
49909
50040
|
}
|
|
49910
50041
|
const films = [];
|
|
49911
50042
|
for (const name of entries.sort((a, b) => a.localeCompare(b, "en", { numeric: true }))) {
|
|
49912
|
-
const dir =
|
|
50043
|
+
const dir = join21(root, name);
|
|
49913
50044
|
if (await detectType(dir) === "motion") films.push(dir);
|
|
49914
50045
|
}
|
|
49915
50046
|
return films;
|
|
@@ -52442,39 +52573,26 @@ async function launchChrome(chrome, args = []) {
|
|
|
52442
52573
|
],
|
|
52443
52574
|
{ stdio: ["ignore", "ignore", "pipe"] }
|
|
52444
52575
|
);
|
|
52445
|
-
|
|
52446
|
-
|
|
52576
|
+
let said = "";
|
|
52577
|
+
child2.stderr.on("data", (chunk) => {
|
|
52578
|
+
said += chunk;
|
|
52579
|
+
});
|
|
52580
|
+
let endpoint = null;
|
|
52581
|
+
let ws;
|
|
52447
52582
|
try {
|
|
52448
|
-
endpoint = await
|
|
52449
|
-
|
|
52450
|
-
|
|
52451
|
-
|
|
52452
|
-
|
|
52453
|
-
const found = /DevTools listening on (ws:\/\/\S+)/.exec(text);
|
|
52454
|
-
if (found) {
|
|
52455
|
-
clearTimeout(timer);
|
|
52456
|
-
resolve19(found[1]);
|
|
52457
|
-
}
|
|
52458
|
-
});
|
|
52459
|
-
child2.on("error", (error) => {
|
|
52460
|
-
clearTimeout(timer);
|
|
52461
|
-
reject2(error);
|
|
52462
|
-
});
|
|
52463
|
-
child2.on("exit", (code) => {
|
|
52464
|
-
clearTimeout(timer);
|
|
52465
|
-
reject2(new Error(`Chrome exited (${code}): ${text.slice(-400)}`));
|
|
52466
|
-
});
|
|
52583
|
+
endpoint = await waitForDevTools({ child: child2, profile, stderr: () => said, timeoutMs: 3e4 });
|
|
52584
|
+
ws = new WebSocket(endpoint);
|
|
52585
|
+
await new Promise((resolve19, reject2) => {
|
|
52586
|
+
ws.addEventListener("open", () => resolve19(), { once: true });
|
|
52587
|
+
ws.addEventListener("error", () => reject2(new Error("could not connect to Chrome")), { once: true });
|
|
52467
52588
|
});
|
|
52468
52589
|
} catch (error) {
|
|
52590
|
+
if (endpoint) await closeBrowserAt(endpoint);
|
|
52469
52591
|
void stopChild(child2, { graceMs: 0 });
|
|
52470
|
-
removeProfile();
|
|
52592
|
+
removeProfile(profile);
|
|
52471
52593
|
throw error;
|
|
52472
52594
|
}
|
|
52473
|
-
const
|
|
52474
|
-
await new Promise((resolve19, reject2) => {
|
|
52475
|
-
ws.addEventListener("open", () => resolve19(), { once: true });
|
|
52476
|
-
ws.addEventListener("error", () => reject2(new Error("could not connect to Chrome")), { once: true });
|
|
52477
|
-
});
|
|
52595
|
+
const browserAt = endpoint;
|
|
52478
52596
|
let nextId = 1;
|
|
52479
52597
|
const pending2 = /* @__PURE__ */ new Map();
|
|
52480
52598
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -52540,24 +52658,22 @@ async function launchChrome(chrome, args = []) {
|
|
|
52540
52658
|
};
|
|
52541
52659
|
}
|
|
52542
52660
|
async function close() {
|
|
52543
|
-
try {
|
|
52544
|
-
await Promise.race([send2("Browser.close"), sleep2(3e3)]);
|
|
52545
|
-
} catch {
|
|
52546
|
-
}
|
|
52547
52661
|
try {
|
|
52548
52662
|
ws.close();
|
|
52549
52663
|
} catch {
|
|
52550
52664
|
}
|
|
52665
|
+
await closeBrowserAt(browserAt);
|
|
52551
52666
|
await stopChild(child2, { signal: null, graceMs: 3e3, settleMs: 0 });
|
|
52552
|
-
removeProfile();
|
|
52667
|
+
removeProfile(profile);
|
|
52553
52668
|
}
|
|
52554
52669
|
return { page: page2, close };
|
|
52555
52670
|
}
|
|
52556
52671
|
var sleep2, exceptionText;
|
|
52557
|
-
var
|
|
52672
|
+
var init_chrome2 = __esm({
|
|
52558
52673
|
"packages/type-server/src/docs/chrome.ts"() {
|
|
52559
52674
|
"use strict";
|
|
52560
52675
|
init_child();
|
|
52676
|
+
init_chrome();
|
|
52561
52677
|
init_snapshot2();
|
|
52562
52678
|
sleep2 = (ms) => new Promise((done2) => setTimeout(done2, ms));
|
|
52563
52679
|
exceptionText = (details) => String(details.exception?.description ?? details.text);
|
|
@@ -52838,7 +52954,7 @@ var init_print = __esm({
|
|
|
52838
52954
|
"packages/type-server/src/docs/print.ts"() {
|
|
52839
52955
|
"use strict";
|
|
52840
52956
|
init_src9();
|
|
52841
|
-
|
|
52957
|
+
init_chrome2();
|
|
52842
52958
|
MARGIN_MM = { y: 18, x: 16 };
|
|
52843
52959
|
PAPER_INCHES = { a4: { width: 210 / 25.4, height: 297 / 25.4 }, letter: { width: 8.5, height: 11 } };
|
|
52844
52960
|
PAGE_SIZE = { a4: "A4", letter: "letter" };
|
|
@@ -55652,7 +55768,7 @@ import { watch as watch2 } from "node:fs";
|
|
|
55652
55768
|
import { mkdir as mkdir5, readFile as readFile6, readdir as readdir6, rm as rm6, stat as stat5, writeFile as writeFile3 } from "node:fs/promises";
|
|
55653
55769
|
import { createServer as createServer2 } from "node:http";
|
|
55654
55770
|
import { homedir as homedir2 } from "node:os";
|
|
55655
|
-
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute5, join as
|
|
55771
|
+
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute5, join as join22, normalize, relative as relative2, resolve as resolve10, sep as sep5 } from "node:path";
|
|
55656
55772
|
function uploadLimitOf(type, hosted) {
|
|
55657
55773
|
return type === "design" && !hosted ? LOCAL_DESIGN_MAX_UPLOAD : MAX_UPLOAD;
|
|
55658
55774
|
}
|
|
@@ -55702,7 +55818,7 @@ function folderId(root) {
|
|
|
55702
55818
|
}
|
|
55703
55819
|
async function readArtifactMeta(root, files) {
|
|
55704
55820
|
try {
|
|
55705
|
-
const path20 =
|
|
55821
|
+
const path20 = join22(root, ".artifact.json");
|
|
55706
55822
|
const meta = JSON.parse(await readFile6(files?.resolve(path20) ?? path20, "utf8"));
|
|
55707
55823
|
return {
|
|
55708
55824
|
id: typeof meta.id === "string" ? meta.id : void 0,
|
|
@@ -55715,7 +55831,7 @@ async function readArtifactMeta(root, files) {
|
|
|
55715
55831
|
}
|
|
55716
55832
|
async function indexTitle(root, type, files) {
|
|
55717
55833
|
try {
|
|
55718
|
-
const path20 =
|
|
55834
|
+
const path20 = join22(root, contentDirOf(type), TYPES[type].marker);
|
|
55719
55835
|
const index = JSON.parse(await readFile6(files?.resolve(path20) ?? path20, "utf8"));
|
|
55720
55836
|
return typeof index.title === "string" && index.title.trim() ? index.title.trim() : void 0;
|
|
55721
55837
|
} catch {
|
|
@@ -55727,7 +55843,7 @@ async function detectType(root, files) {
|
|
|
55727
55843
|
if (isTypeName(meta.type)) return meta.type;
|
|
55728
55844
|
for (const type of Object.values(TYPES)) {
|
|
55729
55845
|
try {
|
|
55730
|
-
const path20 =
|
|
55846
|
+
const path20 = join22(root, contentDirOf(type.name), type.marker);
|
|
55731
55847
|
await stat5(files?.resolve(path20) ?? path20);
|
|
55732
55848
|
return type.name;
|
|
55733
55849
|
} catch {
|
|
@@ -55736,7 +55852,7 @@ async function detectType(root, files) {
|
|
|
55736
55852
|
for (const type of Object.values(TYPES)) {
|
|
55737
55853
|
if (type.store !== "db" || !type.marker.includes("/")) continue;
|
|
55738
55854
|
try {
|
|
55739
|
-
const path20 =
|
|
55855
|
+
const path20 = join22(root, contentDirOf(type.name), dirname9(type.marker));
|
|
55740
55856
|
if ((await stat5(files?.resolve(path20) ?? path20)).isDirectory()) return type.name;
|
|
55741
55857
|
} catch {
|
|
55742
55858
|
}
|
|
@@ -55774,7 +55890,7 @@ function createTypeServer(options) {
|
|
|
55774
55890
|
const connectors = () => options.connectors ?? viaDaemon ?? ownHost();
|
|
55775
55891
|
let ownShares = null;
|
|
55776
55892
|
const connectorShares = () => ownShares ??= new ConnectorShares({
|
|
55777
|
-
file:
|
|
55893
|
+
file: join22(dirname9(connectors().file), "connector-shares.json"),
|
|
55778
55894
|
call: async (server2, tool, callArgs, timeoutMs) => ({ ...await connectors().callTool(server2, tool, callArgs, { timeoutMs }) }),
|
|
55779
55895
|
log
|
|
55780
55896
|
});
|
|
@@ -56032,7 +56148,7 @@ function createTypeServer(options) {
|
|
|
56032
56148
|
return;
|
|
56033
56149
|
}
|
|
56034
56150
|
artifact.listing = await artifact.store.list();
|
|
56035
|
-
const project =
|
|
56151
|
+
const project = join22(artifact.root, PROJECT_DIR);
|
|
56036
56152
|
await mkdir5(project, { recursive: true });
|
|
56037
56153
|
if (artifact.watcher || artifact.statusTimer || artifact.watching || artifact.clients.size === 0) return;
|
|
56038
56154
|
try {
|
|
@@ -56097,14 +56213,14 @@ function createTypeServer(options) {
|
|
|
56097
56213
|
throw new HttpError(400, "invalid", "shell must be an origin.");
|
|
56098
56214
|
}
|
|
56099
56215
|
}
|
|
56100
|
-
const marker =
|
|
56216
|
+
const marker = join22(root, contentDirOf(type), TYPES[type].marker);
|
|
56101
56217
|
try {
|
|
56102
56218
|
await stat5(files?.resolve(marker) ?? marker);
|
|
56103
56219
|
} catch {
|
|
56104
56220
|
const title2 = request.title?.trim() || meta.title || basename6(root);
|
|
56105
|
-
const dir =
|
|
56221
|
+
const dir = join22(root, contentDirOf(type));
|
|
56106
56222
|
for (const [path20, content] of Object.entries(TYPES[type].scaffold(title2, dir))) {
|
|
56107
|
-
const target =
|
|
56223
|
+
const target = join22(dir, path20);
|
|
56108
56224
|
await writeAtomic(files?.resolve(target, false) ?? target, content);
|
|
56109
56225
|
}
|
|
56110
56226
|
}
|
|
@@ -56219,7 +56335,7 @@ function createTypeServer(options) {
|
|
|
56219
56335
|
else send(res, 200, bytes, mimeOf(file), headers);
|
|
56220
56336
|
};
|
|
56221
56337
|
const inside = (dir, rel) => {
|
|
56222
|
-
const target = normalize(
|
|
56338
|
+
const target = normalize(join22(dir, rel));
|
|
56223
56339
|
if (target !== dir && !target.startsWith(dir.endsWith(sep5) ? dir : dir + sep5)) throw new HttpError(404, "not_found", "Not found.");
|
|
56224
56340
|
return target;
|
|
56225
56341
|
};
|
|
@@ -56573,7 +56689,7 @@ data: ${JSON.stringify(payload)}
|
|
|
56573
56689
|
}
|
|
56574
56690
|
case API.downloads: {
|
|
56575
56691
|
if (method !== "POST") throw new HttpError(405, "invalid", "POST only.");
|
|
56576
|
-
const dir = options.downloadsDir ??
|
|
56692
|
+
const dir = options.downloadsDir ?? join22(homedir2(), "Downloads");
|
|
56577
56693
|
const savedTo = await saveDownload(req, dir, downloadName(url.searchParams.get("name")), options.maxDownloadBytes);
|
|
56578
56694
|
return sendJson(res, 200, { savedTo });
|
|
56579
56695
|
}
|
|
@@ -56724,11 +56840,11 @@ data: ${JSON.stringify(payload)}
|
|
|
56724
56840
|
const files = new WorkspaceDirectory(root);
|
|
56725
56841
|
const dir = files.resolve("_agent/snapshots");
|
|
56726
56842
|
await mkdir5(dir, { recursive: true });
|
|
56727
|
-
const image = files.resolve(
|
|
56843
|
+
const image = files.resolve(join22(dir, `snapshot-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.png`), false);
|
|
56728
56844
|
await writeFile3(image, png, { flag: "wx" });
|
|
56729
56845
|
const old = (await readdir6(dir)).filter((name) => /^snapshot-.*\.png$/.test(name)).sort();
|
|
56730
|
-
for (const name of old.slice(0, Math.max(0, old.length - SNAPSHOTS_KEPT))) await rm6(files.resolve(
|
|
56731
|
-
return { image:
|
|
56846
|
+
for (const name of old.slice(0, Math.max(0, old.length - SNAPSHOTS_KEPT))) await rm6(files.resolve(join22(dir, name), false), { force: true });
|
|
56847
|
+
return { image: join22(root, relative2(files.root, image)), width, height, bytes: png.length, note: SNAPSHOT_NOTE };
|
|
56732
56848
|
};
|
|
56733
56849
|
const callTargetOf = async (body) => {
|
|
56734
56850
|
const opened = typeof body.id === "string" ? byId.get(body.id) : void 0;
|
|
@@ -57680,7 +57796,7 @@ import { randomBytes as randomBytes16 } from "node:crypto";
|
|
|
57680
57796
|
import { existsSync as existsSync17, openSync as openSync3 } from "node:fs";
|
|
57681
57797
|
import { mkdir as mkdir6, readdir as readdir8, readFile as readFile9, rm as rm8, writeFile as writeFile5 } from "node:fs/promises";
|
|
57682
57798
|
import { homedir as homedir4 } from "node:os";
|
|
57683
|
-
import { basename as basename8, delimiter, dirname as dirname11, join as
|
|
57799
|
+
import { basename as basename8, delimiter, dirname as dirname11, join as join26, relative as relative4, resolve as resolve18 } from "node:path";
|
|
57684
57800
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
57685
57801
|
|
|
57686
57802
|
// packages/type-server/src/db-cli.ts
|
|
@@ -57689,7 +57805,7 @@ init_db();
|
|
|
57689
57805
|
init_agent();
|
|
57690
57806
|
init_server();
|
|
57691
57807
|
init_types2();
|
|
57692
|
-
import { existsSync as existsSync13, readFileSync as
|
|
57808
|
+
import { existsSync as existsSync13, readFileSync as readFileSync16 } from "node:fs";
|
|
57693
57809
|
import { isAbsolute as isAbsolute6, resolve as resolve11 } from "node:path";
|
|
57694
57810
|
function fail2(message) {
|
|
57695
57811
|
console.error(message);
|
|
@@ -57741,7 +57857,7 @@ async function cmdReadDb(positional, options = {}) {
|
|
|
57741
57857
|
}
|
|
57742
57858
|
}
|
|
57743
57859
|
function readWrites(source) {
|
|
57744
|
-
const text = source === "-" ?
|
|
57860
|
+
const text = source === "-" ? readFileSync16(0, "utf8") : /^\s*[[{]/.test(source) ? source : existsSync13(source) ? readFileSync16(source, "utf8") : null;
|
|
57745
57861
|
if (text === null) throw new Error(`${source}: no such file (pass inline JSON, a file, or - for stdin).`);
|
|
57746
57862
|
const value2 = JSON.parse(text);
|
|
57747
57863
|
if (Array.isArray(value2)) return value2;
|
|
@@ -57764,7 +57880,7 @@ function resolveFileRefs(value2, where) {
|
|
|
57764
57880
|
if (typeof value2.$file !== "string" || !value2.$file) throw new Refusal2("INVALID_FILE_REF", `${where}: {"$file": \u2026} names a file path.`);
|
|
57765
57881
|
const file = resolve11(value2.$file);
|
|
57766
57882
|
try {
|
|
57767
|
-
return
|
|
57883
|
+
return readFileSync16(file, "utf8");
|
|
57768
57884
|
} catch {
|
|
57769
57885
|
throw new Refusal2("FILE_NOT_FOUND", `${where}: {"$file": ${JSON.stringify(value2.$file)}}: cannot read ${file}. Nothing was written.`);
|
|
57770
57886
|
}
|
|
@@ -58022,7 +58138,7 @@ ${result.changed.map((p) => ` ${p}`).join("\n")}`);
|
|
|
58022
58138
|
|
|
58023
58139
|
// packages/type-server/src/comments-cli.ts
|
|
58024
58140
|
init_comments();
|
|
58025
|
-
import { readFileSync as
|
|
58141
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
58026
58142
|
import { resolve as resolve13 } from "node:path";
|
|
58027
58143
|
|
|
58028
58144
|
// packages/type-server/src/docs/comment-target.ts
|
|
@@ -58261,7 +58377,7 @@ async function cmdCommentReply(positional, flags) {
|
|
|
58261
58377
|
const id = positional[1];
|
|
58262
58378
|
if (!id) return fail4(`Pass the thread id: ${hint("comment-reply", positional[0], "<thread>", "<text>")}`);
|
|
58263
58379
|
const given = positional.slice(2).join(" ");
|
|
58264
|
-
const text = (given === "" || given === "-" ? process.stdin.isTTY ? "" :
|
|
58380
|
+
const text = (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync17(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
|
|
58265
58381
|
if (!text) return fail4("The reply is empty: pass it as an argument, or as - with the text on stdin.");
|
|
58266
58382
|
if (text.length > TEXT_MAX) return fail4(`A reply is at most ${TEXT_MAX} characters.`);
|
|
58267
58383
|
try {
|
|
@@ -58287,7 +58403,7 @@ async function cmdCommentResolve(positional, flags) {
|
|
|
58287
58403
|
}
|
|
58288
58404
|
var DOC_THREADS_MAX = 1e3;
|
|
58289
58405
|
function textOf4(given) {
|
|
58290
|
-
return (given === "" || given === "-" ? process.stdin.isTTY ? "" :
|
|
58406
|
+
return (given === "" || given === "-" ? process.stdin.isTTY ? "" : readFileSync17(0, "utf8") : given).replace(/\r\n?/g, "\n").trim();
|
|
58291
58407
|
}
|
|
58292
58408
|
var flagText = (flags, name) => {
|
|
58293
58409
|
const value2 = flags.get(name);
|
|
@@ -58332,7 +58448,7 @@ init_workspace_files();
|
|
|
58332
58448
|
init_store();
|
|
58333
58449
|
import { existsSync as existsSync14 } from "node:fs";
|
|
58334
58450
|
import { readdir as readdir7, readFile as readFile7, rm as rm7, stat as stat6, writeFile as writeFile4 } from "node:fs/promises";
|
|
58335
|
-
import { basename as basename7, join as
|
|
58451
|
+
import { basename as basename7, join as join23, relative as relative3, resolve as resolve14, sep as sep6 } from "node:path";
|
|
58336
58452
|
var MAX_SEARCHED_BYTES = 16 * 1024 * 1024;
|
|
58337
58453
|
var SEARCHED = ["project", "db"];
|
|
58338
58454
|
var SEARCHED_FILES = ["comments.json", ".artifact.json"];
|
|
@@ -58361,13 +58477,13 @@ async function referencesTo(root, id) {
|
|
|
58361
58477
|
}
|
|
58362
58478
|
for (const entry of entries) {
|
|
58363
58479
|
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
58364
|
-
const file =
|
|
58480
|
+
const file = join23(dir, entry.name);
|
|
58365
58481
|
if (entry.isDirectory()) await walk3(file);
|
|
58366
58482
|
else if (entry.isFile()) await visit(file);
|
|
58367
58483
|
}
|
|
58368
58484
|
};
|
|
58369
|
-
for (const dir of SEARCHED) await walk3(
|
|
58370
|
-
for (const name of SEARCHED_FILES) await visit(
|
|
58485
|
+
for (const dir of SEARCHED) await walk3(join23(root, dir));
|
|
58486
|
+
for (const name of SEARCHED_FILES) await visit(join23(root, name));
|
|
58371
58487
|
return users.sort();
|
|
58372
58488
|
}
|
|
58373
58489
|
var AssetError = class extends Error {
|
|
@@ -58381,7 +58497,7 @@ async function deleteAsset(root, given) {
|
|
|
58381
58497
|
const id = blobIdOf2(given);
|
|
58382
58498
|
if (!id) throw new AssetError("INVALID_ASSET", "Give the upload as its url (/_blob/<id>) or its id (32 hex digits).");
|
|
58383
58499
|
const blob = await new ArtifactStore(root).findBlob(id);
|
|
58384
|
-
if (!blob) throw new AssetError("NOT_FOUND", `No upload ${id} in ${
|
|
58500
|
+
if (!blob) throw new AssetError("NOT_FOUND", `No upload ${id} in ${join23(root, "_blobs")}.`);
|
|
58385
58501
|
const users = await referencesTo(root, id);
|
|
58386
58502
|
if (users.length) throw new AssetError("IN_USE", `/_blob/${id} is still named by ${users.join(", ")}; change or delete those first. Nothing was removed.`);
|
|
58387
58503
|
if (basename7(blob.file) === id) await rm7(blob.file + ".json", { force: true });
|
|
@@ -58488,15 +58604,17 @@ init_project_check();
|
|
|
58488
58604
|
init_src13();
|
|
58489
58605
|
import { existsSync as existsSync16 } from "node:fs";
|
|
58490
58606
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
58491
|
-
import { dirname as dirname10, join as
|
|
58607
|
+
import { dirname as dirname10, join as join25, resolve as resolve17 } from "node:path";
|
|
58492
58608
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
58493
58609
|
|
|
58494
58610
|
// packages/motion-stage/src/stills.ts
|
|
58611
|
+
init_child();
|
|
58612
|
+
init_chrome();
|
|
58495
58613
|
init_src13();
|
|
58496
58614
|
import { spawn as spawn4 } from "node:child_process";
|
|
58497
|
-
import { existsSync as existsSync15, lstatSync as lstatSync6, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, readFileSync as
|
|
58615
|
+
import { existsSync as existsSync15, lstatSync as lstatSync6, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync2, readFileSync as readFileSync18, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
58498
58616
|
import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
|
|
58499
|
-
import { join as
|
|
58617
|
+
import { join as join24, resolve as resolve16 } from "node:path";
|
|
58500
58618
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
58501
58619
|
var StillsError = class extends Error {
|
|
58502
58620
|
};
|
|
@@ -58514,24 +58632,24 @@ function parseStillScale(text) {
|
|
|
58514
58632
|
var stillFileName = (t) => "t_" + t.toFixed(3) + ".png";
|
|
58515
58633
|
var plainFile = (path20) => lstatSync6(path20, { throwIfNoEntry: false })?.isFile() === true;
|
|
58516
58634
|
function readStillsFilm(root, warn = () => void 0) {
|
|
58517
|
-
const db =
|
|
58518
|
-
if (!plainFile(
|
|
58635
|
+
const db = join24(root, "db");
|
|
58636
|
+
if (!plainFile(join24(db, "film", "meta.json"))) throw new StillsError(root + " is not a motion artifact: it has no db/film/meta.json.");
|
|
58519
58637
|
const documents = {};
|
|
58520
58638
|
for (const collection of [...FILM_COLLECTIONS, ...VERSION_COLLECTIONS]) {
|
|
58521
|
-
const folder =
|
|
58639
|
+
const folder = join24(db, collection);
|
|
58522
58640
|
if (!existsSync15(folder)) continue;
|
|
58523
58641
|
for (const name of readdirSync8(folder)) {
|
|
58524
58642
|
if (!name.endsWith(".json")) continue;
|
|
58525
|
-
const path20 =
|
|
58643
|
+
const path20 = join24(folder, name);
|
|
58526
58644
|
if (!plainFile(path20)) {
|
|
58527
58645
|
warn("skipped " + path20 + ": not a plain file");
|
|
58528
58646
|
continue;
|
|
58529
58647
|
}
|
|
58530
|
-
documents[collection + "/" + name.slice(0, -".json".length)] =
|
|
58648
|
+
documents[collection + "/" + name.slice(0, -".json".length)] = readFileSync18(path20, "utf8");
|
|
58531
58649
|
}
|
|
58532
58650
|
}
|
|
58533
58651
|
const blobs = {};
|
|
58534
|
-
const uploads =
|
|
58652
|
+
const uploads = join24(root, "_blobs");
|
|
58535
58653
|
const stored = existsSync15(uploads) ? readdirSync8(uploads) : [];
|
|
58536
58654
|
for (const [path20, text] of Object.entries(documents)) {
|
|
58537
58655
|
if (!path20.startsWith("assets/")) continue;
|
|
@@ -58544,7 +58662,7 @@ function readStillsFilm(root, warn = () => void 0) {
|
|
|
58544
58662
|
const id = /^\/?_blob\/([0-9a-f]{32})$/.exec(ref2)?.[1];
|
|
58545
58663
|
if (id === void 0 || id in blobs) continue;
|
|
58546
58664
|
const file = stored.find((name) => name === id || name.startsWith(id + "."));
|
|
58547
|
-
if (file !== void 0 && plainFile(
|
|
58665
|
+
if (file !== void 0 && plainFile(join24(uploads, file))) blobs[id] = readFileSync18(join24(uploads, file)).toString("base64");
|
|
58548
58666
|
}
|
|
58549
58667
|
return { documents, blobs };
|
|
58550
58668
|
}
|
|
@@ -58591,17 +58709,17 @@ function findChromium(env = process.env) {
|
|
|
58591
58709
|
if (existsSync15(env.CHROME_PATH)) return env.CHROME_PATH;
|
|
58592
58710
|
throw new StillsError("CHROME_PATH does not exist: " + env.CHROME_PATH);
|
|
58593
58711
|
}
|
|
58594
|
-
const caches = [env.PLAYWRIGHT_BROWSERS_PATH,
|
|
58712
|
+
const caches = [env.PLAYWRIGHT_BROWSERS_PATH, join24(homedir3(), "Library", "Caches", "ms-playwright"), join24(homedir3(), ".cache", "ms-playwright"), "/opt/pw-browsers"].filter(
|
|
58595
58713
|
(path20) => path20 !== void 0 && path20 !== "" && existsSync15(path20)
|
|
58596
58714
|
);
|
|
58597
58715
|
const found = [];
|
|
58598
58716
|
for (const cache of caches) {
|
|
58599
58717
|
for (const build of safeList(cache).sort().reverse()) {
|
|
58600
|
-
const home =
|
|
58601
|
-
if (build.startsWith("chromium_headless_shell-")) for (const sub of safeList(home)) found.push(
|
|
58718
|
+
const home = join24(cache, build);
|
|
58719
|
+
if (build.startsWith("chromium_headless_shell-")) for (const sub of safeList(home)) found.push(join24(home, sub, "chrome-headless-shell"));
|
|
58602
58720
|
else if (build.startsWith("chromium-")) {
|
|
58603
|
-
found.push(
|
|
58604
|
-
for (const sub of safeList(home)) found.push(
|
|
58721
|
+
found.push(join24(home, "chrome-linux", "chrome"), join24(home, "chrome-linux64", "chrome"));
|
|
58722
|
+
for (const sub of safeList(home)) found.push(join24(home, sub, "Chromium.app", "Contents", "MacOS", "Chromium"));
|
|
58605
58723
|
}
|
|
58606
58724
|
}
|
|
58607
58725
|
}
|
|
@@ -58638,22 +58756,11 @@ var CHROMIUM_ARGS = [
|
|
|
58638
58756
|
function launch(binary, profile) {
|
|
58639
58757
|
const keychain = process.platform === "darwin" ? ["--use-mock-keychain"] : [];
|
|
58640
58758
|
const child2 = spawn4(binary, [...CHROMIUM_ARGS, ...keychain, "--user-data-dir=" + profile, "about:blank"], { stdio: ["ignore", "ignore", "pipe"] });
|
|
58641
|
-
|
|
58642
|
-
|
|
58643
|
-
|
|
58644
|
-
child2.stderr?.on("data", (chunk) => {
|
|
58645
|
-
said += String(chunk);
|
|
58646
|
-
const url = /DevTools listening on (ws:\/\/\S+)/.exec(said)?.[1];
|
|
58647
|
-
if (url === void 0) return;
|
|
58648
|
-
clearTimeout(timer);
|
|
58649
|
-
done2({ child: child2, url });
|
|
58650
|
-
});
|
|
58651
|
-
child2.on("error", (error) => {
|
|
58652
|
-
clearTimeout(timer);
|
|
58653
|
-
fail6(error);
|
|
58654
|
-
});
|
|
58655
|
-
child2.on("exit", (code) => fail6(new Error("Chromium exited (" + String(code) + "):\n" + said.slice(-2e3))));
|
|
58759
|
+
let said = "";
|
|
58760
|
+
child2.stderr?.on("data", (chunk) => {
|
|
58761
|
+
said += String(chunk);
|
|
58656
58762
|
});
|
|
58763
|
+
return { child: child2, url: waitForDevTools({ child: child2, profile, stderr: () => said, timeoutMs: 3e4, name: "Chromium" }) };
|
|
58657
58764
|
}
|
|
58658
58765
|
async function connect2(url) {
|
|
58659
58766
|
const socket = new WebSocket(url);
|
|
@@ -58688,8 +58795,7 @@ async function connect2(url) {
|
|
|
58688
58795
|
if (exceptionDetails) throw new Error(exceptionDetails.exception?.description ?? exceptionDetails.text);
|
|
58689
58796
|
return result.value;
|
|
58690
58797
|
},
|
|
58691
|
-
|
|
58692
|
-
await send2("Browser.close").catch(() => void 0);
|
|
58798
|
+
close() {
|
|
58693
58799
|
socket.close();
|
|
58694
58800
|
}
|
|
58695
58801
|
};
|
|
@@ -58710,10 +58816,10 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
|
|
|
58710
58816
|
const view2 = { ...request.version !== void 0 ? { version: request.version } : {}, ...request.ratio !== void 0 ? { ratio: request.ratio } : {} };
|
|
58711
58817
|
const files = { documents: stillsDocumentsFor(film.documents, view2), blobs: film.blobs, mode: request.mode };
|
|
58712
58818
|
const binary = findChromium();
|
|
58713
|
-
const work = mkdtempSync2(
|
|
58714
|
-
const out = request.out === null ? mkdtempSync2(
|
|
58819
|
+
const work = mkdtempSync2(join24(tmpdir2(), "film-tools-"));
|
|
58820
|
+
const out = request.out === null ? mkdtempSync2(join24(tmpdir2(), "film-stills-")) : resolve16(request.out);
|
|
58715
58821
|
mkdirSync6(out, { recursive: true });
|
|
58716
|
-
const page2 =
|
|
58822
|
+
const page2 = join24(work, "tools.html");
|
|
58717
58823
|
writeFileSync8(page2, toolsPage2);
|
|
58718
58824
|
const json = request.json === true;
|
|
58719
58825
|
const report = { problems: [], film: null, view: { version: request.version ?? null, ratio: request.ratio ?? null }, stills: [], score: null, levels: null, log: [] };
|
|
@@ -58721,11 +58827,13 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
|
|
|
58721
58827
|
if (!json) say(text);
|
|
58722
58828
|
};
|
|
58723
58829
|
let child2 = null;
|
|
58830
|
+
let url = null;
|
|
58724
58831
|
let browser = null;
|
|
58725
58832
|
try {
|
|
58726
|
-
const launched =
|
|
58833
|
+
const launched = launch(binary, join24(work, "profile"));
|
|
58727
58834
|
child2 = launched.child;
|
|
58728
|
-
|
|
58835
|
+
url = await launched.url;
|
|
58836
|
+
browser = await connect2(url);
|
|
58729
58837
|
await browser.navigate(pathToFileURL2(page2).href);
|
|
58730
58838
|
for (let i = 0; i < 100 && await browser.evaluate("typeof window.filmTools") !== "object"; i++) await new Promise((next) => setTimeout(next, 100));
|
|
58731
58839
|
const loaded = await browser.evaluate("window.filmTools.load(" + JSON.stringify(files) + ")");
|
|
@@ -58738,7 +58846,7 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
|
|
|
58738
58846
|
for (const t of request.times) {
|
|
58739
58847
|
try {
|
|
58740
58848
|
const png = await browser.evaluate("window.filmTools.frame(" + String(t) + ", { scale: " + String(request.scale) + " })");
|
|
58741
|
-
const file =
|
|
58849
|
+
const file = join24(out, stillFileName(t));
|
|
58742
58850
|
writeFileSync8(file, Buffer.from(png.slice(png.indexOf(",") + 1), "base64"));
|
|
58743
58851
|
report.stills.push({ t, file });
|
|
58744
58852
|
line(file);
|
|
@@ -58760,14 +58868,10 @@ async function drawStills(request, toolsPage2, say = (line) => console.log(line)
|
|
|
58760
58868
|
if (json) say(JSON.stringify({ ...report, error: messageOf(error) }));
|
|
58761
58869
|
return 1;
|
|
58762
58870
|
} finally {
|
|
58763
|
-
|
|
58764
|
-
|
|
58765
|
-
if (
|
|
58766
|
-
|
|
58767
|
-
running.once("exit", () => done2());
|
|
58768
|
-
running.kill();
|
|
58769
|
-
});
|
|
58770
|
-
rmSync7(work, { recursive: true, force: true });
|
|
58871
|
+
browser?.close();
|
|
58872
|
+
if (url !== null) await closeBrowserAt(url);
|
|
58873
|
+
if (child2 !== null) await stopChild(child2, { graceMs: 3e3 });
|
|
58874
|
+
removeProfile(work);
|
|
58771
58875
|
}
|
|
58772
58876
|
}
|
|
58773
58877
|
|
|
@@ -58805,7 +58909,7 @@ function stillsRequest(positional, flags) {
|
|
|
58805
58909
|
};
|
|
58806
58910
|
}
|
|
58807
58911
|
async function toolsPage() {
|
|
58808
|
-
const beside =
|
|
58912
|
+
const beside = join25(dirname10(fileURLToPath3(import.meta.url)), STILLS_TOOLS_PAGE);
|
|
58809
58913
|
if (existsSync16(beside)) return readFile8(beside, "utf8");
|
|
58810
58914
|
const build = "@openartifactsai/motion-stage/build";
|
|
58811
58915
|
try {
|
|
@@ -59028,11 +59132,11 @@ var flag = (args, name) => {
|
|
|
59028
59132
|
var UsageError = class extends Error {
|
|
59029
59133
|
};
|
|
59030
59134
|
function stateDir() {
|
|
59031
|
-
return process.env.OPEN_ARTIFACTS_TYPE_SERVER_HOME ||
|
|
59135
|
+
return process.env.OPEN_ARTIFACTS_TYPE_SERVER_HOME || join26(homedir4(), ".open-artifacts");
|
|
59032
59136
|
}
|
|
59033
59137
|
async function readRecord() {
|
|
59034
59138
|
try {
|
|
59035
|
-
return JSON.parse(await readFile9(
|
|
59139
|
+
return JSON.parse(await readFile9(join26(stateDir(), "server.json"), "utf8"));
|
|
59036
59140
|
} catch {
|
|
59037
59141
|
return null;
|
|
59038
59142
|
}
|
|
@@ -59061,7 +59165,7 @@ async function liveServer() {
|
|
|
59061
59165
|
async function startServer(port) {
|
|
59062
59166
|
const dir = stateDir();
|
|
59063
59167
|
await mkdir6(dir, { recursive: true });
|
|
59064
|
-
const logFile = openSync3(
|
|
59168
|
+
const logFile = openSync3(join26(dir, "server.log"), "a");
|
|
59065
59169
|
const child2 = spawn5(process.execPath, [SELF, "serve", "--record", ...port ? ["--port", String(port)] : []], {
|
|
59066
59170
|
detached: true,
|
|
59067
59171
|
stdio: ["ignore", logFile, logFile],
|
|
@@ -59073,7 +59177,7 @@ async function startServer(port) {
|
|
|
59073
59177
|
const record = await liveServer();
|
|
59074
59178
|
if (record && record.pid === child2.pid) return record;
|
|
59075
59179
|
}
|
|
59076
|
-
throw new UsageError(`The server did not start; see ${
|
|
59180
|
+
throw new UsageError(`The server did not start; see ${join26(dir, "server.log")}.`);
|
|
59077
59181
|
}
|
|
59078
59182
|
function artifactRoot(args) {
|
|
59079
59183
|
const dir = args.positional[1];
|
|
@@ -59144,7 +59248,7 @@ async function cmdGenerate(args) {
|
|
|
59144
59248
|
let changed = 0;
|
|
59145
59249
|
for (const [path20, content] of Object.entries(out)) {
|
|
59146
59250
|
if (content === (files.get(path20) ?? null)) continue;
|
|
59147
|
-
const file =
|
|
59251
|
+
const file = join26(root, "project", ...path20.split("/"));
|
|
59148
59252
|
if (content === null) await rm8(file, { force: true });
|
|
59149
59253
|
else await writeAtomic(file, content);
|
|
59150
59254
|
console.log(`${content === null ? "removed" : "wrote "} project/${path20}`);
|
|
@@ -59206,13 +59310,13 @@ function installFolder(namespace) {
|
|
|
59206
59310
|
}
|
|
59207
59311
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", "_blobs", "_agent", "history"]);
|
|
59208
59312
|
async function findSystems(dir, depth, out) {
|
|
59209
|
-
const index =
|
|
59313
|
+
const index = join26(dir, "project", "design-system.json");
|
|
59210
59314
|
if (existsSync17(index)) {
|
|
59211
59315
|
try {
|
|
59212
59316
|
const raw = JSON.parse(await readFile9(index, "utf8"));
|
|
59213
59317
|
if (hasMarker(raw)) {
|
|
59214
59318
|
const system = normalizeSystemIndex(raw);
|
|
59215
|
-
const at2 = (path20) => existsSync17(
|
|
59319
|
+
const at2 = (path20) => existsSync17(join26(dir, "project", path20)) ? join26(dir, "project", path20) : null;
|
|
59216
59320
|
const shown = relative4(process.cwd(), dir);
|
|
59217
59321
|
out.set(dir, {
|
|
59218
59322
|
title: system.title,
|
|
@@ -59236,7 +59340,7 @@ async function findSystems(dir, depth, out) {
|
|
|
59236
59340
|
}
|
|
59237
59341
|
for (const entry of entries) {
|
|
59238
59342
|
if (!entry.isDirectory() || entry.name.startsWith(".") || SKIP_DIRS.has(entry.name)) continue;
|
|
59239
|
-
await findSystems(
|
|
59343
|
+
await findSystems(join26(dir, entry.name), depth - 1, out);
|
|
59240
59344
|
}
|
|
59241
59345
|
}
|
|
59242
59346
|
async function cmdList(args) {
|
|
@@ -59438,11 +59542,11 @@ async function cmdStop() {
|
|
|
59438
59542
|
} catch {
|
|
59439
59543
|
console.log("The recorded server was not running.");
|
|
59440
59544
|
}
|
|
59441
|
-
await rm8(
|
|
59545
|
+
await rm8(join26(stateDir(), "server.json"), { force: true });
|
|
59442
59546
|
}
|
|
59443
59547
|
function defaultAssets() {
|
|
59444
59548
|
const here = dirname11(SELF);
|
|
59445
|
-
if (existsSync17(
|
|
59549
|
+
if (existsSync17(join26(here, "editors"))) return here;
|
|
59446
59550
|
return resolve18(here, "../../../dist/server");
|
|
59447
59551
|
}
|
|
59448
59552
|
async function cmdServe(args) {
|
|
@@ -59457,7 +59561,7 @@ async function cmdServe(args) {
|
|
|
59457
59561
|
await server?.stop().catch(() => void 0);
|
|
59458
59562
|
if (record) {
|
|
59459
59563
|
const current2 = await readRecord();
|
|
59460
|
-
if (current2?.pid === process.pid) await rm8(
|
|
59564
|
+
if (current2?.pid === process.pid) await rm8(join26(stateDir(), "server.json"), { force: true });
|
|
59461
59565
|
}
|
|
59462
59566
|
process.exit(code);
|
|
59463
59567
|
};
|
|
@@ -59480,7 +59584,7 @@ async function cmdServe(args) {
|
|
|
59480
59584
|
if (record) {
|
|
59481
59585
|
await mkdir6(stateDir(), { recursive: true });
|
|
59482
59586
|
const value2 = { pid: process.pid, url, secret, version: 1 };
|
|
59483
|
-
await writeFile5(
|
|
59587
|
+
await writeFile5(join26(stateDir(), "server.json"), `${JSON.stringify(value2, null, 2)}
|
|
59484
59588
|
`, { mode: 384 });
|
|
59485
59589
|
}
|
|
59486
59590
|
const ready3 = { openArtifacts: "ready", url };
|