screw-bugs 0.1.9 → 0.1.10
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 +49 -34
- package/dist/browser-playwright/capture.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli/app.js +6 -2
- package/dist/cli/commands.js +4 -3
- package/dist/cli/doctor.d.ts +17 -2
- package/dist/cli/doctor.js +62 -4
- package/dist/cli/mcp.js +2 -2
- package/dist/cli/report-server.d.ts +19 -10
- package/dist/cli/report-server.js +43 -18
- package/dist/cli/share.js +2 -2
- package/dist/cli/sign-in.d.ts +9 -3
- package/dist/cli/sign-in.js +12 -9
- package/dist/cli/tailnet.d.ts +57 -0
- package/dist/cli/tailnet.js +82 -0
- package/dist/core/index.d.ts +1 -14
- package/dist/core/index.js +3 -14
- package/dist/report/index.d.ts +1 -10
- package/dist/report/index.js +3 -10
- package/dist/schema/index.d.ts +1 -9
- package/dist/schema/index.js +3 -9
- package/package.json +14 -14
- package/dist/core/accounts.d.ts +0 -40
- package/dist/core/accounts.js +0 -95
- package/dist/core/css.d.ts +0 -95
- package/dist/core/css.js +0 -436
- package/dist/core/engine.d.ts +0 -75
- package/dist/core/engine.js +0 -560
- package/dist/core/errors.d.ts +0 -85
- package/dist/core/errors.js +0 -36
- package/dist/core/evidence.d.ts +0 -14
- package/dist/core/evidence.js +0 -131
- package/dist/core/labels.d.ts +0 -47
- package/dist/core/labels.js +0 -199
- package/dist/core/liveness.d.ts +0 -45
- package/dist/core/liveness.js +0 -66
- package/dist/core/marks.d.ts +0 -63
- package/dist/core/marks.js +0 -410
- package/dist/core/services.d.ts +0 -579
- package/dist/core/services.js +0 -25
- package/dist/core/share.d.ts +0 -68
- package/dist/core/share.js +0 -318
- package/dist/core/steps.d.ts +0 -106
- package/dist/core/steps.js +0 -722
- package/dist/core/uploads.d.ts +0 -49
- package/dist/core/uploads.js +0 -133
- package/dist/core/video.d.ts +0 -53
- package/dist/core/video.js +0 -241
- package/dist/core/viewport.d.ts +0 -28
- package/dist/core/viewport.js +0 -50
- package/dist/report/assets.d.ts +0 -34
- package/dist/report/assets.js +0 -105
- package/dist/report/bug.d.ts +0 -11
- package/dist/report/bug.js +0 -20
- package/dist/report/html.d.ts +0 -47
- package/dist/report/html.js +0 -923
- package/dist/report/icons.d.ts +0 -51
- package/dist/report/icons.js +0 -93
- package/dist/report/live.d.ts +0 -7
- package/dist/report/live.js +0 -135
- package/dist/report/logos.d.ts +0 -4
- package/dist/report/logos.js +0 -19
- package/dist/report/markup.d.ts +0 -50
- package/dist/report/markup.js +0 -156
- package/dist/report/menu-bar.d.ts +0 -60
- package/dist/report/menu-bar.js +0 -157
- package/dist/report/player.d.ts +0 -102
- package/dist/report/player.js +0 -315
- package/dist/report/pr-summary.d.ts +0 -11
- package/dist/report/pr-summary.js +0 -119
- package/dist/report/sha256.d.ts +0 -9
- package/dist/report/sha256.js +0 -97
- package/dist/report/share-page.d.ts +0 -48
- package/dist/report/share-page.js +0 -291
- package/dist/report/shots.d.ts +0 -59
- package/dist/report/shots.js +0 -280
- package/dist/report/sign-in.d.ts +0 -41
- package/dist/report/sign-in.js +0 -568
- package/dist/report/styles.d.ts +0 -3
- package/dist/report/styles.js +0 -274
- package/dist/report/view.d.ts +0 -296
- package/dist/report/view.js +0 -702
- package/dist/report/walkthrough.d.ts +0 -93
- package/dist/report/walkthrough.js +0 -716
- package/dist/schema/accounts.d.ts +0 -137
- package/dist/schema/accounts.js +0 -121
- package/dist/schema/config.d.ts +0 -7
- package/dist/schema/config.js +0 -6
- package/dist/schema/doctor.d.ts +0 -46
- package/dist/schema/doctor.js +0 -30
- package/dist/schema/evidence.d.ts +0 -1115
- package/dist/schema/evidence.js +0 -565
- package/dist/schema/findings.d.ts +0 -161
- package/dist/schema/findings.js +0 -82
- package/dist/schema/job.d.ts +0 -1905
- package/dist/schema/job.js +0 -577
- package/dist/schema/ledger.d.ts +0 -1124
- package/dist/schema/ledger.js +0 -285
- package/dist/schema/share.d.ts +0 -55
- package/dist/schema/share.js +0 -64
- package/dist/schema/status.d.ts +0 -7
- package/dist/schema/status.js +0 -11
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Context, Duration, Effect, Layer, Schema } from 'effect';
|
|
2
|
+
import { ChildProcessSpawner } from 'effect/process';
|
|
3
|
+
/**
|
|
4
|
+
* Tailscale, for the host settings (`SCREW_BUGS_REPORT_HOST`) when unset or `tailnet`: this
|
|
5
|
+
* machine's MagicDNS name (its tailnet IPv4 when MagicDNS is off), read from `tailscale status
|
|
6
|
+
* --json` once per process. Unset, reports and sign-ins go there whenever Tailscale is running
|
|
7
|
+
* (not in CI); `SCREW_BUGS_REPORT_HOST=127.0.0.1` keeps them on this machine, and doctor says so
|
|
8
|
+
* (see `checkTailnet`).
|
|
9
|
+
*/
|
|
10
|
+
/** The value of a host setting that means "this machine's name on the tailnet". */
|
|
11
|
+
export declare const TAILNET = "tailnet";
|
|
12
|
+
/** The few fields of `tailscale status --json` screw-bugs reads; the rest is ignored. */
|
|
13
|
+
export declare const TailscaleStatus: Schema.Struct<{
|
|
14
|
+
readonly BackendState: Schema.String;
|
|
15
|
+
readonly Self: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
16
|
+
readonly DNSName: Schema.optionalKey<Schema.String>;
|
|
17
|
+
readonly TailscaleIPs: Schema.optionalKey<Schema.NullOr<Schema.$Array<Schema.String>>>;
|
|
18
|
+
}>>>;
|
|
19
|
+
readonly CurrentTailnet: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
20
|
+
readonly MagicDNSEnabled: Schema.optionalKey<Schema.Boolean>;
|
|
21
|
+
}>>>;
|
|
22
|
+
}>;
|
|
23
|
+
export type TailscaleStatus = typeof TailscaleStatus.Type;
|
|
24
|
+
/** What the lookup found: this machine's host on the tailnet, or why there is none. */
|
|
25
|
+
export type TailnetStatus = {
|
|
26
|
+
readonly running: true;
|
|
27
|
+
readonly host: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly running: false;
|
|
30
|
+
readonly why: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* This machine's host on a running tailnet: its MagicDNS name without the trailing dot, lowercase,
|
|
34
|
+
* unless the tailnet has MagicDNS off; otherwise its first tailnet IPv4.
|
|
35
|
+
*/
|
|
36
|
+
export declare const tailnetStatusOf: (status: TailscaleStatus) => TailnetStatus;
|
|
37
|
+
/** How long `tailscale status` may take. */
|
|
38
|
+
export declare const LOOKUP_TIMEOUT: Duration.Duration;
|
|
39
|
+
/** Asks the Tailscale CLI for this machine's status; never fails. */
|
|
40
|
+
export declare const lookupTailnet: Effect.Effect<TailnetStatus, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
41
|
+
export interface TailnetLookup {
|
|
42
|
+
/** What Tailscale said, the first time anything asked. */
|
|
43
|
+
readonly status: Effect.Effect<TailnetStatus>;
|
|
44
|
+
/**
|
|
45
|
+
* The host for a setting of `tailnet`: Tailscale's, or undefined when it is not running. The
|
|
46
|
+
* first time it is undefined, one line on stderr says the servers use 127.0.0.1 instead.
|
|
47
|
+
*/
|
|
48
|
+
readonly host: Effect.Effect<string | undefined>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* This machine's tailnet, looked up once per process (on first need) so every link a process gives
|
|
52
|
+
* names the address its servers bound. Without `TailnetLive` (tests, and code with no process
|
|
53
|
+
* around it), there is none.
|
|
54
|
+
*/
|
|
55
|
+
export declare const Tailnet: Context.Reference<TailnetLookup>;
|
|
56
|
+
/** The lookup through the Tailscale CLI, cached for the process. */
|
|
57
|
+
export declare const TailnetLive: Layer.Layer<never, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Console, Context, Duration, Effect, Layer, Schema } from 'effect';
|
|
2
|
+
import { ChildProcess, ChildProcessSpawner } from 'effect/process';
|
|
3
|
+
/**
|
|
4
|
+
* Tailscale, for the host settings (`SCREW_BUGS_REPORT_HOST`) when unset or `tailnet`: this
|
|
5
|
+
* machine's MagicDNS name (its tailnet IPv4 when MagicDNS is off), read from `tailscale status
|
|
6
|
+
* --json` once per process. Unset, reports and sign-ins go there whenever Tailscale is running
|
|
7
|
+
* (not in CI); `SCREW_BUGS_REPORT_HOST=127.0.0.1` keeps them on this machine, and doctor says so
|
|
8
|
+
* (see `checkTailnet`).
|
|
9
|
+
*/
|
|
10
|
+
/** The value of a host setting that means "this machine's name on the tailnet". */
|
|
11
|
+
export const TAILNET = 'tailnet';
|
|
12
|
+
/** The few fields of `tailscale status --json` screw-bugs reads; the rest is ignored. */
|
|
13
|
+
export const TailscaleStatus = Schema.Struct({
|
|
14
|
+
BackendState: Schema.String,
|
|
15
|
+
Self: Schema.optionalKey(Schema.NullOr(Schema.Struct({
|
|
16
|
+
DNSName: Schema.optionalKey(Schema.String),
|
|
17
|
+
TailscaleIPs: Schema.optionalKey(Schema.NullOr(Schema.Array(Schema.String))),
|
|
18
|
+
}))),
|
|
19
|
+
CurrentTailnet: Schema.optionalKey(Schema.NullOr(Schema.Struct({ MagicDNSEnabled: Schema.optionalKey(Schema.Boolean) }))),
|
|
20
|
+
});
|
|
21
|
+
const IPV4 = /^\d{1,3}(\.\d{1,3}){3}$/;
|
|
22
|
+
/**
|
|
23
|
+
* This machine's host on a running tailnet: its MagicDNS name without the trailing dot, lowercase,
|
|
24
|
+
* unless the tailnet has MagicDNS off; otherwise its first tailnet IPv4.
|
|
25
|
+
*/
|
|
26
|
+
export const tailnetStatusOf = (status) => {
|
|
27
|
+
if (status.BackendState !== 'Running')
|
|
28
|
+
return { running: false, why: `Tailscale is ${status.BackendState.toLowerCase()}` };
|
|
29
|
+
const name = status.Self?.DNSName?.trim().replace(/\.$/, '').toLowerCase() ?? '';
|
|
30
|
+
const magicDns = status.CurrentTailnet?.MagicDNSEnabled !== false;
|
|
31
|
+
if (magicDns && name !== '')
|
|
32
|
+
return { running: true, host: name };
|
|
33
|
+
const ipv4 = (status.Self?.TailscaleIPs ?? []).find((ip) => IPV4.test(ip));
|
|
34
|
+
return ipv4 === undefined
|
|
35
|
+
? { running: false, why: 'Tailscale gave this machine no name or IPv4 address' }
|
|
36
|
+
: { running: true, host: ipv4 };
|
|
37
|
+
};
|
|
38
|
+
/** How long `tailscale status` may take. */
|
|
39
|
+
export const LOOKUP_TIMEOUT = Duration.seconds(3);
|
|
40
|
+
/**
|
|
41
|
+
* Where the Tailscale CLI may be: on the PATH, else the macOS app's own (the Mac App Store and
|
|
42
|
+
* standalone apps do not put one on the PATH).
|
|
43
|
+
*/
|
|
44
|
+
const TAILSCALE_COMMANDS = ['tailscale', '/Applications/Tailscale.app/Contents/MacOS/Tailscale'];
|
|
45
|
+
const decodeStatus = Schema.decodeUnknownEffect(Schema.fromJsonString(TailscaleStatus));
|
|
46
|
+
/** Asks the Tailscale CLI for this machine's status; never fails. */
|
|
47
|
+
export const lookupTailnet = Effect.gen(function* () {
|
|
48
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
49
|
+
for (const command of TAILSCALE_COMMANDS) {
|
|
50
|
+
const out = yield* spawner
|
|
51
|
+
.string(ChildProcess.make(command, ['status', '--json'], { stdin: 'ignore' }))
|
|
52
|
+
.pipe(Effect.timeout(LOOKUP_TIMEOUT), Effect.option);
|
|
53
|
+
if (out._tag === 'None')
|
|
54
|
+
continue;
|
|
55
|
+
return yield* decodeStatus(out.value).pipe(Effect.map(tailnetStatusOf), Effect.orElseSucceed(() => ({
|
|
56
|
+
running: false,
|
|
57
|
+
why: 'Tailscale gave a status screw-bugs cannot read',
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
return { running: false, why: 'Tailscale is not installed or did not answer' };
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* This machine's tailnet, looked up once per process (on first need) so every link a process gives
|
|
64
|
+
* names the address its servers bound. Without `TailnetLive` (tests, and code with no process
|
|
65
|
+
* around it), there is none.
|
|
66
|
+
*/
|
|
67
|
+
export const Tailnet = Context.Reference('screw-bugs/Tailnet', {
|
|
68
|
+
defaultValue: () => ({
|
|
69
|
+
status: Effect.succeed({ running: false, why: 'Tailscale was not looked up' }),
|
|
70
|
+
host: Effect.succeed(undefined),
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
/** The lookup through the Tailscale CLI, cached for the process. */
|
|
74
|
+
export const TailnetLive = Layer.effect(Tailnet, Effect.gen(function* () {
|
|
75
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
76
|
+
const status = yield* Effect.cached(lookupTailnet.pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner)));
|
|
77
|
+
const host = yield* Effect.cached(status.pipe(Effect.flatMap((found) => found.running
|
|
78
|
+
? Effect.succeed(found.host)
|
|
79
|
+
: Console.error(`screw-bugs: a host setting is "${TAILNET}", but ${found.why}; ` +
|
|
80
|
+
'serving on 127.0.0.1 until screw-bugs restarts.').pipe(Effect.as(undefined)))));
|
|
81
|
+
return { status, host };
|
|
82
|
+
}));
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './engine.js';
|
|
3
|
-
export * from './errors.js';
|
|
4
|
-
export * from './evidence.js';
|
|
5
|
-
export * from './labels.js';
|
|
6
|
-
export * from './css.js';
|
|
7
|
-
export * from './marks.js';
|
|
8
|
-
export * from './services.js';
|
|
9
|
-
export * from './steps.js';
|
|
10
|
-
export * from './liveness.js';
|
|
11
|
-
export * from './video.js';
|
|
12
|
-
export * from './uploads.js';
|
|
13
|
-
export * from './viewport.js';
|
|
14
|
-
export * from './share.js';
|
|
1
|
+
export * from '@screw-bugs/core/core';
|
package/dist/core/index.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from '
|
|
4
|
-
export * from './evidence.js';
|
|
5
|
-
export * from './labels.js';
|
|
6
|
-
export * from './css.js';
|
|
7
|
-
export * from './marks.js';
|
|
8
|
-
export * from './services.js';
|
|
9
|
-
export * from './steps.js';
|
|
10
|
-
export * from './liveness.js';
|
|
11
|
-
export * from './video.js';
|
|
12
|
-
export * from './uploads.js';
|
|
13
|
-
export * from './viewport.js';
|
|
14
|
-
export * from './share.js';
|
|
1
|
+
// screw-bugs' `core` module lives in @screw-bugs/core, the platform-free package that screw-bugs
|
|
2
|
+
// Cloud shares; this keeps `screw-bugs/core` and the module boundaries working.
|
|
3
|
+
export * from '@screw-bugs/core/core';
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './pr-summary.js';
|
|
3
|
-
export { SHARE_START_PATH } from './menu-bar.js';
|
|
4
|
-
export { stepText } from './view.js';
|
|
5
|
-
export { base64, cspHash, hex, hmacSha256, sha256 } from './sha256.js';
|
|
6
|
-
export { renderWalkthrough, WALKTHROUGH_CSP, WALKTHROUGH_SCRIPT, walkthroughCsp, } from './walkthrough.js';
|
|
7
|
-
export { AssetBaseUrl, type RenderOptions } from './assets.js';
|
|
8
|
-
export { renderSignInPage, SIGN_IN_CSP, SIGN_IN_SCRIPT } from './sign-in.js';
|
|
9
|
-
export { LIVE_CSP, LIVE_REFRESH_S, renderLivePage } from './live.js';
|
|
10
|
-
export { renderSharePage, SHARE_PAGE_SCRIPT, SHARE_POLL_MS, SHARE_WEBP_QUALITY, type SharePage, sharePageCsp, } from './share-page.js';
|
|
1
|
+
export * from '@screw-bugs/core/report';
|
package/dist/report/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export { stepText } from './view.js';
|
|
5
|
-
export { base64, cspHash, hex, hmacSha256, sha256 } from './sha256.js';
|
|
6
|
-
export { renderWalkthrough, WALKTHROUGH_CSP, WALKTHROUGH_SCRIPT, walkthroughCsp, } from './walkthrough.js';
|
|
7
|
-
export { AssetBaseUrl } from './assets.js';
|
|
8
|
-
export { renderSignInPage, SIGN_IN_CSP, SIGN_IN_SCRIPT } from './sign-in.js';
|
|
9
|
-
export { LIVE_CSP, LIVE_REFRESH_S, renderLivePage } from './live.js';
|
|
10
|
-
export { renderSharePage, SHARE_PAGE_SCRIPT, SHARE_POLL_MS, SHARE_WEBP_QUALITY, sharePageCsp, } from './share-page.js';
|
|
1
|
+
// screw-bugs' `report` module lives in @screw-bugs/core, the platform-free package that screw-bugs
|
|
2
|
+
// Cloud shares; this keeps `screw-bugs/report` and the module boundaries working.
|
|
3
|
+
export * from '@screw-bugs/core/report';
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './config.js';
|
|
3
|
-
export * from './doctor.js';
|
|
4
|
-
export * from './evidence.js';
|
|
5
|
-
export * from './findings.js';
|
|
6
|
-
export * from './job.js';
|
|
7
|
-
export * from './ledger.js';
|
|
8
|
-
export * from './status.js';
|
|
9
|
-
export * from './share.js';
|
|
1
|
+
export * from '@screw-bugs/core/schema';
|
package/dist/schema/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from '
|
|
4
|
-
export * from './evidence.js';
|
|
5
|
-
export * from './findings.js';
|
|
6
|
-
export * from './job.js';
|
|
7
|
-
export * from './ledger.js';
|
|
8
|
-
export * from './status.js';
|
|
9
|
-
export * from './share.js';
|
|
1
|
+
// screw-bugs' `schema` module lives in @screw-bugs/core, the platform-free package that screw-bugs
|
|
2
|
+
// Cloud shares; this keeps `screw-bugs/schema` and the module boundaries working.
|
|
3
|
+
export * from '@screw-bugs/core/schema';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screw-bugs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Local browser QA for coding agents (MCP), people and CI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -43,20 +43,10 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"build": "tsc -p tsconfig.build.json && node dist/cli/stamp-build.js",
|
|
48
|
-
"typecheck": "tsc -p tsconfig.json",
|
|
49
|
-
"lint": "oxlint --deny-warnings",
|
|
50
|
-
"format": "oxfmt",
|
|
51
|
-
"format:check": "oxfmt --check",
|
|
52
|
-
"test": "vitest run",
|
|
53
|
-
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test",
|
|
54
|
-
"e2e": "tsc -p e2e && node e2e/run.ts",
|
|
55
|
-
"prepack": "node -e \"process.getBuiltinModule('fs').rmSync('dist',{recursive:true,force:true})\" && pnpm build"
|
|
56
|
-
},
|
|
57
46
|
"dependencies": {
|
|
58
47
|
"@effect/platform-node": "^4.1.0",
|
|
59
48
|
"@modelcontextprotocol/server": "2.4.0",
|
|
49
|
+
"@screw-bugs/core": "0.1.10",
|
|
60
50
|
"effect": "^4.1.0",
|
|
61
51
|
"playwright-core": "1.64.1"
|
|
62
52
|
},
|
|
@@ -71,5 +61,15 @@
|
|
|
71
61
|
"engines": {
|
|
72
62
|
"node": ">=22.19.0"
|
|
73
63
|
},
|
|
74
|
-
"
|
|
75
|
-
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "pnpm --filter @screw-bugs/core build && tsc -p tsconfig.build.json && node dist/cli/stamp-build.js",
|
|
66
|
+
"typecheck": "pnpm --filter @screw-bugs/core typecheck && tsc -p tsconfig.json",
|
|
67
|
+
"lint": "oxlint --deny-warnings",
|
|
68
|
+
"format": "oxfmt",
|
|
69
|
+
"format:check": "oxfmt --check",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"check:workers": "pnpm --filter @screw-bugs/core check:workers",
|
|
72
|
+
"check": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm check:workers",
|
|
73
|
+
"e2e": "tsc -p e2e && node e2e/run.ts"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/core/accounts.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { SavedAccount } from './services.js';
|
|
2
|
-
import { type JobAccount, type SavedSession, type SignInWhy } from '../schema/index.js';
|
|
3
|
-
/** How recent a session counts as just signed in, so `renew` does not ask for it again. */
|
|
4
|
-
export declare const RENEW_GRACE_MS: number;
|
|
5
|
-
/**
|
|
6
|
-
* Whether the browser sends a cookie of `domain` (as Playwright gives it) to `origin`'s host. A
|
|
7
|
-
* host-only cookie (no leading dot) goes to its own host alone; a domain cookie (`.acme.dev`) to
|
|
8
|
-
* that host and every name under it (RFC 6265 domain matching). Browsers never keep a cookie for
|
|
9
|
-
* a public suffix (`co.uk`, `github.io`), so this never takes in another site that shares one;
|
|
10
|
-
* a sibling's cookie (`api.acme.dev` for `app.acme.dev`), or the parent's own host-only one, is
|
|
11
|
-
* not kept either.
|
|
12
|
-
*/
|
|
13
|
-
export declare const sentTo: (origin: string, domain: string) => boolean;
|
|
14
|
-
/** The origin of a job URL, such as `http://localhost:3000`; undefined for one that is not a URL. */
|
|
15
|
-
export declare const originOf: (url: string) => string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Whether every cookie of the session has an expiry and it has passed: then the browser would
|
|
18
|
-
* start with none of them, and the session cannot work. A session with no cookies at all may
|
|
19
|
-
* live in storage, so it counts as working.
|
|
20
|
-
*/
|
|
21
|
-
export declare const sessionExpired: (session: Pick<SavedSession, 'cookies'>, nowMs: number) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Why a run of a job with `account` at `url` cannot start from its saved session yet (a person has
|
|
24
|
-
* to sign in to it first), or undefined when it can.
|
|
25
|
-
*/
|
|
26
|
-
export declare const needsSignIn: (account: JobAccount, url: string, saved: SavedAccount | undefined, nowMs: number) => SignInWhy | undefined;
|
|
27
|
-
/** What kind of user the account is: what the job says, else what was saved. */
|
|
28
|
-
export declare const aboutOf: (account: JobAccount, saved: SavedAccount | undefined) => string | undefined;
|
|
29
|
-
/** Why the account needs signing in, as the end of a sentence about it. */
|
|
30
|
-
export declare const describeSignInWhy: (why: SignInWhy) => string;
|
|
31
|
-
/** At most this long, the app's title as the live view shows it. */
|
|
32
|
-
export declare const SITE_TITLE_MAX = 120;
|
|
33
|
-
/** A page title on one line, cut to `SITE_TITLE_MAX`; undefined when blank. */
|
|
34
|
-
export declare const siteTitle: (raw: string) => string | undefined;
|
|
35
|
-
/** At most this many icon addresses are tried, best first. */
|
|
36
|
-
export declare const SITE_ICONS_MAX = 4;
|
|
37
|
-
/** The largest icon the live view shows, in bytes. */
|
|
38
|
-
export declare const SITE_ICON_BYTES_MAX: number;
|
|
39
|
-
/** The image type of an icon from its `Content-Type`, or undefined when it is not one shown. */
|
|
40
|
-
export declare const siteIconType: (contentType: string | undefined) => string | undefined;
|
package/dist/core/accounts.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { DateTime, Option } from 'effect';
|
|
2
|
-
import { accountAboutOf, } from '../schema/index.js';
|
|
3
|
-
/** How recent a session counts as just signed in, so `renew` does not ask for it again. */
|
|
4
|
-
export const RENEW_GRACE_MS = 10 * 60_000;
|
|
5
|
-
/**
|
|
6
|
-
* Whether the browser sends a cookie of `domain` (as Playwright gives it) to `origin`'s host. A
|
|
7
|
-
* host-only cookie (no leading dot) goes to its own host alone; a domain cookie (`.acme.dev`) to
|
|
8
|
-
* that host and every name under it (RFC 6265 domain matching). Browsers never keep a cookie for
|
|
9
|
-
* a public suffix (`co.uk`, `github.io`), so this never takes in another site that shares one;
|
|
10
|
-
* a sibling's cookie (`api.acme.dev` for `app.acme.dev`), or the parent's own host-only one, is
|
|
11
|
-
* not kept either.
|
|
12
|
-
*/
|
|
13
|
-
export const sentTo = (origin, domain) => {
|
|
14
|
-
const host = URL.parse(origin)
|
|
15
|
-
?.hostname.toLowerCase()
|
|
16
|
-
.replace(/^\[|\]$/g, '');
|
|
17
|
-
const lower = domain.toLowerCase().replace(/\.$/, '');
|
|
18
|
-
const bare = lower.replace(/^\./, '');
|
|
19
|
-
if (host === undefined || bare === '')
|
|
20
|
-
return false;
|
|
21
|
-
return host === bare || (lower.startsWith('.') && host.endsWith(`.${bare}`));
|
|
22
|
-
};
|
|
23
|
-
/** The origin of a job URL, such as `http://localhost:3000`; undefined for one that is not a URL. */
|
|
24
|
-
export const originOf = (url) => {
|
|
25
|
-
const parsed = URL.parse(url);
|
|
26
|
-
return parsed === null ? undefined : parsed.origin;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Whether every cookie of the session has an expiry and it has passed: then the browser would
|
|
30
|
-
* start with none of them, and the session cannot work. A session with no cookies at all may
|
|
31
|
-
* live in storage, so it counts as working.
|
|
32
|
-
*/
|
|
33
|
-
export const sessionExpired = (session, nowMs) => session.cookies.length > 0 &&
|
|
34
|
-
session.cookies.every((c) => c.expires > 0 && c.expires * 1000 <= nowMs);
|
|
35
|
-
/**
|
|
36
|
-
* Why a run of a job with `account` at `url` cannot start from its saved session yet (a person has
|
|
37
|
-
* to sign in to it first), or undefined when it can.
|
|
38
|
-
*/
|
|
39
|
-
export const needsSignIn = (account, url, saved, nowMs) => {
|
|
40
|
-
if (saved === undefined || saved.session === undefined)
|
|
41
|
-
return { _tag: 'none' };
|
|
42
|
-
if (saved.entry.origin !== originOf(url))
|
|
43
|
-
return { _tag: 'origin', saved: saved.entry.origin };
|
|
44
|
-
if (sessionExpired(saved.session, nowMs))
|
|
45
|
-
return { _tag: 'expired' };
|
|
46
|
-
const savedAt = Option.map(DateTime.make(saved.entry.savedAt), DateTime.toEpochMillis);
|
|
47
|
-
const renew = typeof account !== 'string' && account.renew === true;
|
|
48
|
-
const justSaved = Option.exists(savedAt, (at) => nowMs - at < RENEW_GRACE_MS);
|
|
49
|
-
if (renew && !justSaved)
|
|
50
|
-
return { _tag: 'renew' };
|
|
51
|
-
return undefined;
|
|
52
|
-
};
|
|
53
|
-
/** What kind of user the account is: what the job says, else what was saved. */
|
|
54
|
-
export const aboutOf = (account, saved) => accountAboutOf(account) ?? saved?.entry.about;
|
|
55
|
-
/** Why the account needs signing in, as the end of a sentence about it. */
|
|
56
|
-
export const describeSignInWhy = (why) => {
|
|
57
|
-
switch (why._tag) {
|
|
58
|
-
case 'none':
|
|
59
|
-
return 'has no saved sign-in yet';
|
|
60
|
-
case 'origin':
|
|
61
|
-
return `is signed in on ${why.saved}, not here`;
|
|
62
|
-
case 'expired':
|
|
63
|
-
return 'has a saved sign-in whose cookies have all expired';
|
|
64
|
-
case 'renew':
|
|
65
|
-
return 'was asked to sign in again';
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
/** At most this long, the app's title as the live view shows it. */
|
|
69
|
-
export const SITE_TITLE_MAX = 120;
|
|
70
|
-
/** A page title on one line, cut to `SITE_TITLE_MAX`; undefined when blank. */
|
|
71
|
-
export const siteTitle = (raw) => {
|
|
72
|
-
const line = raw.replace(/\s+/g, ' ').trim();
|
|
73
|
-
if (line === '')
|
|
74
|
-
return undefined;
|
|
75
|
-
return line.length > SITE_TITLE_MAX ? `${line.slice(0, SITE_TITLE_MAX - 1)}…` : line;
|
|
76
|
-
};
|
|
77
|
-
/** At most this many icon addresses are tried, best first. */
|
|
78
|
-
export const SITE_ICONS_MAX = 4;
|
|
79
|
-
/** The largest icon the live view shows, in bytes. */
|
|
80
|
-
export const SITE_ICON_BYTES_MAX = 64 * 1024;
|
|
81
|
-
/** Image types an icon is shown as. It goes in an `<img>`, where even an SVG runs no script. */
|
|
82
|
-
const SITE_ICON_TYPES = new Set([
|
|
83
|
-
'image/png',
|
|
84
|
-
'image/x-icon',
|
|
85
|
-
'image/vnd.microsoft.icon',
|
|
86
|
-
'image/svg+xml',
|
|
87
|
-
'image/gif',
|
|
88
|
-
'image/jpeg',
|
|
89
|
-
'image/webp',
|
|
90
|
-
]);
|
|
91
|
-
/** The image type of an icon from its `Content-Type`, or undefined when it is not one shown. */
|
|
92
|
-
export const siteIconType = (contentType) => {
|
|
93
|
-
const type = contentType?.split(';')[0]?.trim().toLowerCase();
|
|
94
|
-
return type !== undefined && SITE_ICON_TYPES.has(type) ? type : undefined;
|
|
95
|
-
};
|
package/dist/core/css.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/** An attribute selector, such as `[data-test="preview"]` or `[href*=linkedin i]`. */
|
|
2
|
-
export interface AttributeTest {
|
|
3
|
-
readonly name: string;
|
|
4
|
-
/** Undefined for `[name]`: the attribute is there, whatever its value. */
|
|
5
|
-
readonly op?: '=' | '~=' | '|=' | '^=' | '$=' | '*=';
|
|
6
|
-
readonly value?: string;
|
|
7
|
-
/** `i` compares ignoring ASCII case, `s` with it; without one, as HTML says for the attribute. */
|
|
8
|
-
readonly flag?: 'i' | 's';
|
|
9
|
-
}
|
|
10
|
-
/** One compound selector: everything about one element, such as `iframe.preview[title=Hi]`. */
|
|
11
|
-
export interface Compound {
|
|
12
|
-
/** Lower case; undefined for `*` or none. */
|
|
13
|
-
readonly tag?: string;
|
|
14
|
-
readonly ids: ReadonlyArray<string>;
|
|
15
|
-
readonly classes: ReadonlyArray<string>;
|
|
16
|
-
readonly attributes: ReadonlyArray<AttributeTest>;
|
|
17
|
-
readonly not: ReadonlyArray<Compound>;
|
|
18
|
-
}
|
|
19
|
-
/** A compound and how it relates to the one before it: inside it anywhere, or right inside it. */
|
|
20
|
-
export interface Part {
|
|
21
|
-
readonly compound: Compound;
|
|
22
|
-
/** How this part relates to the one before it; undefined for the first. */
|
|
23
|
-
readonly combinator?: 'descendant' | 'child';
|
|
24
|
-
}
|
|
25
|
-
/** A selector list: an element matches when it matches any of them, judged by its last part. */
|
|
26
|
-
export type Selector = ReadonlyArray<ReadonlyArray<Part>>;
|
|
27
|
-
/** A selector, or why it cannot be matched against saved page state, in words. */
|
|
28
|
-
export type Parsed = {
|
|
29
|
-
readonly _tag: 'selector';
|
|
30
|
-
readonly selector: Selector;
|
|
31
|
-
} | {
|
|
32
|
-
readonly _tag: 'unsupported';
|
|
33
|
-
readonly reason: string;
|
|
34
|
-
};
|
|
35
|
-
/** What a highlight's CSS can check, besides the element itself and the frame it is in. */
|
|
36
|
-
export declare const SUPPORTED_CSS: string;
|
|
37
|
-
/**
|
|
38
|
-
* Parses `css` into the selectors `matches` takes, or says in words what of it cannot be matched
|
|
39
|
-
* against saved page state (see `SUPPORTED_CSS`).
|
|
40
|
-
*/
|
|
41
|
-
export declare const parseSelector: (css: string) => Parsed;
|
|
42
|
-
/**
|
|
43
|
-
* An attribute's value as saved: `cut` when only its start was kept, so it is longer than `value`.
|
|
44
|
-
*/
|
|
45
|
-
export interface AttributeValue {
|
|
46
|
-
readonly value: string;
|
|
47
|
-
readonly cut?: boolean | undefined;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* An element as a selector sees it: its own attributes, and the element it is in. What was not
|
|
51
|
-
* saved whole is said, so a selector that depends on it is not taken as matching or not.
|
|
52
|
-
*/
|
|
53
|
-
export interface CssElement {
|
|
54
|
-
readonly tag: string;
|
|
55
|
-
readonly id?: string | undefined;
|
|
56
|
-
readonly classes?: ReadonlyArray<string> | undefined;
|
|
57
|
-
/** More classes than `classes` holds. */
|
|
58
|
-
readonly classesCut?: boolean | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* An attribute's value, undefined when it does not have it (as far as was saved), or `unsaved`
|
|
61
|
-
* when it has it but its value was not saved.
|
|
62
|
-
*/
|
|
63
|
-
readonly attribute: (name: string) => AttributeValue | 'unsaved' | undefined;
|
|
64
|
-
/** More attributes than were saved, so one `attribute` does not give may still be there. */
|
|
65
|
-
readonly attributesCut?: boolean | undefined;
|
|
66
|
-
/** Not an HTML element (such as an `<svg>`), whose attribute values HTML never folds. */
|
|
67
|
-
readonly foreign?: boolean | undefined;
|
|
68
|
-
/** The element it is in; undefined at the top of its document, or when that was not saved. */
|
|
69
|
-
readonly parent: () => CssElement | undefined;
|
|
70
|
-
/** It is in an element that was not saved, so `parent` stops short of the top. */
|
|
71
|
-
readonly parentCut?: boolean | undefined;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Whether something holds: true, false, or undefined when it depends on what was not saved (an
|
|
75
|
-
* attribute value cut short, attributes, classes or ancestors left out).
|
|
76
|
-
*/
|
|
77
|
-
export type Maybe = boolean | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Attributes whose values HTML compares ignoring ASCII case in selectors, on HTML elements, unless
|
|
80
|
-
* the selector says `s` (HTML's list of case-insensitive attribute values).
|
|
81
|
-
*/
|
|
82
|
-
export declare const CASE_INSENSITIVE_ATTRIBUTES: ReadonlySet<string>;
|
|
83
|
-
/** Whether `el` matches any selector of the list; undefined when that depends on what was not saved. */
|
|
84
|
-
export declare const selectorMatches: (selector: Selector, el: CssElement) => Maybe;
|
|
85
|
-
/** Whether the selector looks at an element's ancestors at all. */
|
|
86
|
-
export declare const usesAncestors: (selector: Selector) => boolean;
|
|
87
|
-
/**
|
|
88
|
-
* The ID or test ID that every element matching `selector` exactly has, when it is one compound
|
|
89
|
-
* with one: what `Truncated.unsaved` can count.
|
|
90
|
-
*/
|
|
91
|
-
export declare const selectorKey: (selector: Selector) => {
|
|
92
|
-
readonly id: string;
|
|
93
|
-
} | {
|
|
94
|
-
readonly testId: string;
|
|
95
|
-
} | undefined;
|