@streamapp/stream 0.0.3 → 0.0.5
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/bin/stream.mjs +1 -1
- package/package.json +1 -1
- package/resources/app/dist-panel/panel-detail.css +1 -1
- package/resources/app/dist-panel/panel-manage.css +1 -1
- package/resources/app/dist-panel/panel-movie.css +1 -1
- package/resources/app/dist-panel/panel-research.css +1 -1
- package/resources/app/dist-panel/panel.css +1 -1
- package/resources/app/dist-panel/panel.js +1 -1
- package/resources/server.mjs +72 -49
package/resources/server.mjs
CHANGED
|
@@ -174283,6 +174283,8 @@ async function typeInto(driver, step, params, foreground, find2) {
|
|
|
174283
174283
|
await driver.type(text3);
|
|
174284
174284
|
return "keyboard";
|
|
174285
174285
|
}
|
|
174286
|
+
var ForegroundRefused = class extends Error {
|
|
174287
|
+
};
|
|
174286
174288
|
var WINDOW_POLL_MS = 500;
|
|
174287
174289
|
async function waitForWindow(driver, match2, timeoutMs) {
|
|
174288
174290
|
const titles = match2.titleAnyOf ?? (match2.title == null ? [] : [match2.title]);
|
|
@@ -174326,7 +174328,13 @@ async function runDesktopRecipeLocked(recipe, params, driver) {
|
|
|
174326
174328
|
const stepFailed = (step, machine) => blocked("drift", step.label ? `${step.label}\uFF1A${machine}` : machine);
|
|
174327
174329
|
if (recipe.steps[0]?.kind !== "window") await driver.scopeWindow(recipe.app);
|
|
174328
174330
|
let scoped = recipe.app;
|
|
174329
|
-
const foreground = () =>
|
|
174331
|
+
const foreground = async () => {
|
|
174332
|
+
if (!await driver.focusApp(scoped)) {
|
|
174333
|
+
throw new ForegroundRefused(
|
|
174334
|
+
`\u6CA1\u80FD\u628A\u300C${scoped.title ?? scoped.process}\u300D\u62AC\u5230\u524D\u53F0\u2014\u2014\u5C4F\u5E55\u9501\u7740\u3001\u4F1A\u8BDD\u6CA1\u4EBA\u8FDE\u7740\u3001\u6216\u8005\u522B\u7684\u7A97\u53E3\u538B\u7740\u4E0D\u653E\u3002\u8FD9\u4E00\u6B65\u8981\u53D1\u7684\u662F\u952E\u76D8/\u9F20\u6807\u8F93\u5165\uFF0C\u6CA1\u6709\u524D\u53F0\u5C31\u6CA1\u6709\u6536\u4EF6\u4EBA\uFF0C\u6240\u4EE5\u505C\u624B\u3002`
|
|
174335
|
+
);
|
|
174336
|
+
}
|
|
174337
|
+
};
|
|
174330
174338
|
if (recipe.loginCheck) {
|
|
174331
174339
|
if ((await find2(subQuery(recipe.loginCheck.wall, params))).length > 0) return blocked("needsLogin");
|
|
174332
174340
|
}
|
|
@@ -174335,55 +174343,60 @@ async function runDesktopRecipeLocked(recipe, params, driver) {
|
|
|
174335
174343
|
for (const [i, step] of recipe.steps.entries()) {
|
|
174336
174344
|
probe2(`#${i} ${step.kind}${step.label ? ` (${step.label.slice(0, 24)}\u2026)` : ""}`);
|
|
174337
174345
|
if (step.skipIf && (await find2(subQuery(step.skipIf, params))).length > 0) continue;
|
|
174338
|
-
|
|
174339
|
-
|
|
174340
|
-
|
|
174341
|
-
|
|
174342
|
-
|
|
174343
|
-
|
|
174344
|
-
|
|
174345
|
-
|
|
174346
|
-
|
|
174347
|
-
|
|
174348
|
-
|
|
174349
|
-
|
|
174350
|
-
|
|
174351
|
-
|
|
174352
|
-
|
|
174353
|
-
|
|
174354
|
-
|
|
174355
|
-
|
|
174356
|
-
|
|
174357
|
-
|
|
174358
|
-
|
|
174359
|
-
|
|
174360
|
-
|
|
174361
|
-
|
|
174362
|
-
|
|
174363
|
-
|
|
174364
|
-
|
|
174365
|
-
|
|
174366
|
-
|
|
174367
|
-
|
|
174368
|
-
|
|
174369
|
-
|
|
174370
|
-
|
|
174371
|
-
|
|
174372
|
-
|
|
174346
|
+
try {
|
|
174347
|
+
if (step.kind === "window") {
|
|
174348
|
+
const win = await waitForWindow(driver, step.match, step.timeoutMs ?? 12e3);
|
|
174349
|
+
if (!win && step.optional) continue;
|
|
174350
|
+
if (!win) return stepFailed(step, `window not found: ${JSON.stringify(step.match)}`);
|
|
174351
|
+
probe2(`#${i} window hit \u300C${win.title}\u300D (${win.process})`);
|
|
174352
|
+
scoped = { process: win.process, title: win.title };
|
|
174353
|
+
try {
|
|
174354
|
+
await driver.scopeWindow(scoped);
|
|
174355
|
+
} catch (e) {
|
|
174356
|
+
if (step.optional) continue;
|
|
174357
|
+
const now = (await driver.windows()).map((w) => w.title).join("\u3001");
|
|
174358
|
+
return stepFailed(step, `\u7A97\u53E3\u300C${win.title}\u300D\u5728\u88AB scope \u4E4B\u524D\u5C31\u6D88\u5931\u4E86\uFF08${e.message}\uFF09\uFF1B\u6B64\u523B\u8FD8\u5728\u7684\u7A97\u53E3\uFF1A${now}`);
|
|
174359
|
+
}
|
|
174360
|
+
if (step.focus) await foreground();
|
|
174361
|
+
if (step.waitFor) {
|
|
174362
|
+
const q = subQuery(step.waitFor, params);
|
|
174363
|
+
const rounds = Math.max(1, Math.ceil((step.timeoutMs ?? 12e3) / WINDOW_POLL_MS));
|
|
174364
|
+
let seen2 = false;
|
|
174365
|
+
for (let i2 = 0; i2 < rounds; i2++) {
|
|
174366
|
+
if ((await find2(q)).length > 0) {
|
|
174367
|
+
seen2 = true;
|
|
174368
|
+
break;
|
|
174369
|
+
}
|
|
174370
|
+
await driver.sleep(WINDOW_POLL_MS);
|
|
174371
|
+
}
|
|
174372
|
+
if (!seen2 && !step.optional) return stepFailed(step, `window is up but its UI never appeared: ${JSON.stringify(q)}`);
|
|
174373
|
+
}
|
|
174374
|
+
} else if (step.kind === "focus") {
|
|
174375
|
+
await foreground();
|
|
174376
|
+
} else if (step.kind === "invoke") {
|
|
174377
|
+
const q = subQuery(step.query, params);
|
|
174378
|
+
const els = await find2(q);
|
|
174379
|
+
if (els.length === 0 && step.optional) continue;
|
|
174380
|
+
if (els.length === 0) return stepFailed(step, `invoke target not found: ${JSON.stringify(q)}`);
|
|
174381
|
+
if (step.fallbackClick) {
|
|
174382
|
+
await foreground();
|
|
174383
|
+
await driver.click(els[0].rect);
|
|
174384
|
+
} else await driver.invoke(els[0].ref);
|
|
174385
|
+
} else if (step.kind === "type") {
|
|
174386
|
+
const via = await typeInto(driver, step, params, foreground, find2);
|
|
174387
|
+
if (via === "no-target") {
|
|
174388
|
+
return stepFailed(step, `type target not found: ${JSON.stringify(subQuery(step.query, params))}`);
|
|
174389
|
+
}
|
|
174390
|
+
typedVia = via;
|
|
174391
|
+
} else if (step.kind === "scroll") {
|
|
174373
174392
|
await foreground();
|
|
174374
|
-
await driver.
|
|
174375
|
-
} else
|
|
174376
|
-
|
|
174377
|
-
const via = await typeInto(driver, step, params, foreground, find2);
|
|
174378
|
-
if (via === "no-target") {
|
|
174379
|
-
return stepFailed(step, `type target not found: ${JSON.stringify(subQuery(step.query, params))}`);
|
|
174393
|
+
await driver.scroll(step.dir, step.amount);
|
|
174394
|
+
} else if (step.kind === "wait") {
|
|
174395
|
+
await driver.sleep(step.ms);
|
|
174380
174396
|
}
|
|
174381
|
-
|
|
174382
|
-
|
|
174383
|
-
|
|
174384
|
-
await driver.scroll(step.dir, step.amount);
|
|
174385
|
-
} else if (step.kind === "wait") {
|
|
174386
|
-
await driver.sleep(step.ms);
|
|
174397
|
+
} catch (e) {
|
|
174398
|
+
if (e instanceof ForegroundRefused) return stepFailed(step, e.message);
|
|
174399
|
+
throw e;
|
|
174387
174400
|
}
|
|
174388
174401
|
}
|
|
174389
174402
|
if (!recipe.observer || !recipe.read) {
|
|
@@ -218711,9 +218724,15 @@ function envWithBundledNode(env = process.env, execPath = process.execPath, sep4
|
|
|
218711
218724
|
const current = env.PATH ?? env.Path ?? "";
|
|
218712
218725
|
return { ...env, PATH: current ? `${dir}${sep4}${current}` : dir };
|
|
218713
218726
|
}
|
|
218714
|
-
function resolveNpmCommand(baseDir = dirname28(fileURLToPath2(import.meta.url)), exists = existsSync18, execPath = process.execPath) {
|
|
218727
|
+
function resolveNpmCommand(baseDir = dirname28(fileURLToPath2(import.meta.url)), exists = existsSync18, execPath = process.execPath, platform = process.platform) {
|
|
218715
218728
|
const cli = join36(baseDir, "npm", "bin", "npm-cli.js");
|
|
218716
218729
|
if (exists(cli)) return { cmd: execPath, prefixArgs: [cli], bundled: true };
|
|
218730
|
+
if (platform === "win32") {
|
|
218731
|
+
const cut = Math.max(execPath.lastIndexOf("/"), execPath.lastIndexOf("\\"));
|
|
218732
|
+
const nodeDir = cut > 0 ? execPath.slice(0, cut) : dirname28(execPath);
|
|
218733
|
+
const cli2 = join36(nodeDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
218734
|
+
if (exists(cli2)) return { cmd: execPath, prefixArgs: [cli2], bundled: false };
|
|
218735
|
+
}
|
|
218717
218736
|
return { cmd: "npm", prefixArgs: [], bundled: false };
|
|
218718
218737
|
}
|
|
218719
218738
|
|
|
@@ -219173,6 +219192,10 @@ var DshWorkbench = class {
|
|
|
219173
219192
|
child.stdout?.on("data", (chunk) => {
|
|
219174
219193
|
tail2 = `${tail2}${String(chunk)}`.slice(-4e3);
|
|
219175
219194
|
});
|
|
219195
|
+
child.on("error", (e) => {
|
|
219196
|
+
const msg2 = e instanceof Error ? e.message : String(e);
|
|
219197
|
+
reject2(new Error(`\u8D77\u4E0D\u6765 ${cmd}\uFF08${msg2}\uFF09\u2014\u2014\u8FD9\u53F0\u673A\u5668\u4E0A\u627E\u4E0D\u5230\u5B83\u3002${tail2.trim()}`));
|
|
219198
|
+
});
|
|
219176
219199
|
child.on("exit", (code) => {
|
|
219177
219200
|
if (code === 0) resolve9();
|
|
219178
219201
|
else reject2(new Error(`${cmd} ${args.join(" ")} exited with ${code}
|