@plurnk/plurnk-schemes-http 1.3.12 → 1.5.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/.env.defaults +18 -46
- package/README.md +74 -23
- package/SPEC.md +487 -124
- package/dist/Config.d.ts +3 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +18 -0
- package/dist/Config.js.map +1 -0
- package/dist/ContentType.d.ts +2 -0
- package/dist/ContentType.d.ts.map +1 -0
- package/dist/ContentType.js +15 -0
- package/dist/ContentType.js.map +1 -0
- package/dist/ErrorDetail.d.ts +6 -0
- package/dist/ErrorDetail.d.ts.map +1 -0
- package/dist/ErrorDetail.js +19 -0
- package/dist/ErrorDetail.js.map +1 -0
- package/dist/Guard.d.ts +1 -1
- package/dist/Guard.d.ts.map +1 -1
- package/dist/Guard.js +95 -55
- package/dist/Guard.js.map +1 -1
- package/dist/Http.d.ts +3 -16
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +817 -331
- package/dist/Http.js.map +1 -1
- package/dist/TavilyExtract.d.ts +35 -0
- package/dist/TavilyExtract.d.ts.map +1 -0
- package/dist/TavilyExtract.js +204 -0
- package/dist/TavilyExtract.js.map +1 -0
- package/dist/WebFetcher.d.ts +88 -18
- package/dist/WebFetcher.d.ts.map +1 -1
- package/dist/WebFetcher.js +588 -70
- package/dist/WebFetcher.js.map +1 -1
- package/dist/Ws.d.ts +7 -3
- package/dist/Ws.d.ts.map +1 -1
- package/dist/Ws.js +432 -96
- package/dist/Ws.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -10
- package/dist/index.js.map +1 -1
- package/docs/http.md +108 -53
- package/docs/wss.md +39 -43
- package/package.json +14 -13
- package/dist/Browser.d.ts +0 -84
- package/dist/Browser.d.ts.map +0 -1
- package/dist/Browser.js +0 -273
- package/dist/Browser.js.map +0 -1
- package/scripts/install-browser.mjs +0 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { default } from "./Http.ts";
|
|
2
2
|
export { default as Http } from "./Http.ts";
|
|
3
3
|
export { default as Ws } from "./Ws.ts";
|
|
4
|
-
export { default as Browser } from "./Browser.ts";
|
|
5
|
-
export type { ChromiumEngine, ChromiumFactory, RenderResult } from "./Browser.ts";
|
|
6
4
|
export { default as WebFetcher } from "./WebFetcher.ts";
|
|
7
|
-
export
|
|
5
|
+
export { PROJECTION_ID_HEADER, WebMaterializationError } from "./WebFetcher.ts";
|
|
6
|
+
export type { WebFetchResult, WebMaterializedResult } from "./WebFetcher.ts";
|
|
8
7
|
export { default as Guard, GuardBlockedError } from "./Guard.ts";
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
// Public
|
|
2
|
-
// The default export is the scheme class plurnk-service registers at boot
|
|
3
|
-
// (plugin discovery scans node_modules/@plurnk/* for `plurnk.kind === "scheme"`).
|
|
1
|
+
// Public package surface. package.json owns plugin registration {§http-manifest}.
|
|
4
2
|
export { default } from "./Http.js";
|
|
5
3
|
export { default as Http } from "./Http.js";
|
|
6
|
-
// The WebSocket
|
|
7
|
-
// registered `wss` via package.json plurnk.schemes ({ export: "Ws" }); the `ws`
|
|
8
|
-
// prefix rides it (core's schemeNameOf, mirroring https → http).
|
|
4
|
+
// The registered WebSocket handler {§ws}.
|
|
9
5
|
export { default as Ws } from "./Ws.js";
|
|
10
|
-
//
|
|
11
|
-
// troubleshooting MCP package can sit on the same warm-Chromium pool.
|
|
12
|
-
export { default as Browser } from "./Browser.js";
|
|
13
|
-
// The guarded prefetch acquisition seam core's entrySink calls (#454).
|
|
6
|
+
// Automatic entry-acquisition primitive {§prefetch} and its URL check.
|
|
14
7
|
export { default as WebFetcher } from "./WebFetcher.js";
|
|
8
|
+
export { PROJECTION_ID_HEADER, WebMaterializationError } from "./WebFetcher.js";
|
|
15
9
|
export { default as Guard, GuardBlockedError } from "./Guard.js";
|
|
16
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,0CAA0C;AAC1C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAExC,uEAAuE;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
package/docs/http.md
CHANGED
|
@@ -1,60 +1,115 @@
|
|
|
1
1
|
# http(s)://
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
A
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
3
|
+
Use a web URL as an addressable entry. Every exact READ acquires or refreshes a
|
|
4
|
+
complete representation when needed, then core selects the channel and applies
|
|
5
|
+
the requested text scope. HTML becomes a readable model-facing body (normally
|
|
6
|
+
Markdown); original server source is retained separately. Auxiliary channels
|
|
7
|
+
are never presented by default.
|
|
8
|
+
|
|
9
|
+
| Operation | Remote action | Effect |
|
|
10
|
+
| --------------------------------- | ------------- | -------------------------------------------------------------------------- |
|
|
11
|
+
| `READ(http(s)://…)<scope?>` | GET if needed | Acquire/reuse the complete response, then return the selected scoped text |
|
|
12
|
+
| `FIND(http(s)://…):matcher` | GET if needed | Prepare an exact URL, then return flat match locations |
|
|
13
|
+
| `SEND[200](http(s)://…):body:` | POST | Submit the body and stream the response |
|
|
14
|
+
| `EDIT(http(s)://…):body:` | PUT | Replace the whole remote resource; do not use a line scope |
|
|
15
|
+
| `KILL(http(s)://…)` | DELETE | Delete the remote resource and stream the response |
|
|
16
|
+
|
|
17
|
+
A path-pattern FIND searches only web entries already materialized in the
|
|
18
|
+
workspace; a pattern cannot discover the remote web. FIND returns navigation
|
|
19
|
+
metadata, not the selected page body. Use READ for content.
|
|
20
|
+
|
|
21
|
+
Caller cancellation of an exact acquisition returns `499 cancelled`.
|
|
22
|
+
|
|
23
|
+
| Response | `body` | Other channel |
|
|
24
|
+
| ------------------------------------ | --------------------------------------------------- | ---------------------------------------------- |
|
|
25
|
+
| Negotiated origin Markdown | Exact origin Markdown | Independently requested server HTML in `#html` |
|
|
26
|
+
| GET HTML | Tavily Markdown or local HTML-reader projection | Original server HTML in `#html` |
|
|
27
|
+
| GET `text/event-stream` | Event `data` chunks after READ `102` | Initial response in `#header` |
|
|
28
|
+
| Configured textual response | Complete Fetch-decoded text under its declared type | Status and headers in `#header` |
|
|
29
|
+
| Origin HTTP `4xx`/`5xx` | Preserve available origin or independently produced text | Exact status on each origin-backed channel |
|
|
30
|
+
| Binary with a readable projection | Derived Unicode under the projection output type | Origin type and projection ID in `#header` |
|
|
31
|
+
| Binary without a readable projection | No fabricated text representation | Exact `415` Problem |
|
|
32
|
+
|
|
33
|
+
Generic public HTML uses configured Tavily as its body producer. A recoverable
|
|
34
|
+
timeout, transport error, `429`, `5xx`, or per-URL extraction failure uses the
|
|
35
|
+
local HTML reader and records terminal body status `203`. Authentication,
|
|
36
|
+
provider rejection, and malformed provider responses are hard failures and do
|
|
37
|
+
not silently switch producers. Any authored target metadata makes HTML use the
|
|
38
|
+
local reader directly. Origin Markdown always wins without Tavily.
|
|
39
|
+
|
|
40
|
+
Projection presence is structural: a returned projection is accepted even
|
|
41
|
+
when its content is empty. `422 no-readable-projection` means the local route
|
|
42
|
+
produced no model-facing body. An internal projection exception returns
|
|
43
|
+
non-retryable `500 projection-failed`.
|
|
44
|
+
|
|
45
|
+
A binary response uses the installed mimetype reader when one supplies a
|
|
46
|
+
bounded Unicode projection; raw bytes never enter a durable channel. Without a
|
|
47
|
+
reader, finite GET preparation returns `415 binary-response-unsupported`
|
|
48
|
+
without fabricating an entry. Input above the configured byte ceiling returns
|
|
49
|
+
`413 projection-input-limit`. A streamed POST, PUT, or DELETE response already
|
|
50
|
+
owns lifecycle evidence in `#header`; do not retry a mutation solely to
|
|
51
|
+
retrieve its binary body.
|
|
52
|
+
|
|
53
|
+
`#header` contains origin and package acquisition evidence. A Tavily attempt
|
|
54
|
+
adds its route, status, timing, any reported request ID and credits, and bounded
|
|
55
|
+
failure evidence. `body`, `header`, and `html` carry independent durable
|
|
56
|
+
producer outcomes; the selected channel determines success. Thus `#html` or
|
|
57
|
+
`#header` can remain readable after a body failure, while a Tavily body can
|
|
58
|
+
succeed without fabricating unavailable server HTML. `SEND[code]` is never the
|
|
59
|
+
remote HTTP status. A direct non-success origin response is still materialized:
|
|
60
|
+
origin-backed channels carry its exact durable `http-response-status` Problem,
|
|
61
|
+
while independently produced Tavily content and acquisition headers retain
|
|
62
|
+
their own outcomes.
|
|
63
|
+
|
|
64
|
+
For SSE, the response and persisted `#header` establish acquisition. READ then
|
|
65
|
+
returns `102` while events continue. Origin close settles the subscription at
|
|
66
|
+
`200`; later cancellation or transfer failure settles it at `499` or `502`
|
|
67
|
+
without rewriting the initial READ.
|
|
68
|
+
|
|
69
|
+
Re-reading an exact URL can reuse only a complete GET acquired without
|
|
70
|
+
explicit request metadata whose response had no `Vary` field. Plurnk keeps one
|
|
71
|
+
representation per URL, so any target metadata or `Vary` response bypasses both
|
|
72
|
+
the freshness shortcut and old validators instead of creating a variant store.
|
|
73
|
+
Eligible content is served directly only while both the operator TTL and any
|
|
74
|
+
origin `max-age` or `Expires` lifetime remain live. `no-cache` requires origin
|
|
75
|
+
validation; `no-store` evidence remains in the log but supplies neither content
|
|
76
|
+
nor validators to a later request. Only singular, syntactically valid stored
|
|
77
|
+
validators are sent. A 304 restores a non-page representation only when its
|
|
78
|
+
ETag or Last-Modified value identifies the nominated representation; otherwise
|
|
79
|
+
acquisition fails without serving the stored body. Responses to POST, PUT, and
|
|
80
|
+
DELETE are not reused as later GET representations. A projected GET is reused
|
|
81
|
+
only while the installed reader has the same projection identity. Page bodies
|
|
82
|
+
likewise require the same origin-Markdown, local, Tavily depth/version, or
|
|
83
|
+
local-fallback route. Once stale, a page composite is fully reacquired without
|
|
84
|
+
old validators; an origin 304 cannot certify provider or auxiliary material.
|
|
85
|
+
|
|
86
|
+
Scope never suppresses acquisition or refresh. The HTTP producer cannot see the
|
|
87
|
+
fragment or text coordinates; after preparation, the fragment (or `body` by
|
|
88
|
+
default) selects a durable channel and core applies the range. Cold and warm
|
|
89
|
+
forms therefore have identical selection and scope semantics.
|
|
90
|
+
|
|
91
|
+
Request headers ride inside the target as ordered trailing `{Key: value}`
|
|
92
|
+
blocks, one header per block:
|
|
93
|
+
|
|
94
|
+
```plurnk
|
|
95
|
+
<<READ(https://api.example.com/v1/me{Authorization: Bearer TOKEN}{Accept: application/json})::READ
|
|
96
|
+
<<EDIT(https://api.example.com/v1/thing/42{Authorization: Bearer TOKEN}{Content-Type: application/json}):{"done":true}:EDIT
|
|
40
97
|
```
|
|
41
98
|
|
|
42
|
-
Percent-encode `)`, `<`, and `}` inside a header value
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Cancel / cache:
|
|
49
|
-
|
|
50
|
-
- `SEND[499](http(s)://…)` — cancel an in-flight request (abort the fetch).
|
|
51
|
-
- `SEND[410](http(s)://…)` — drop the locally cached copy, forcing the next READ
|
|
52
|
-
to full-fetch instead of revalidate. A local cache drop, **not** an HTTP
|
|
53
|
-
DELETE — use `KILL` to DELETE the remote resource.
|
|
99
|
+
Percent-encode `)`, `<`, and `}` inside a header value.
|
|
100
|
+
An exact FIND forwards these headers when it must acquire the URL, but the
|
|
101
|
+
result remains intentionally ineligible for later cache reuse. Target headers
|
|
102
|
+
are never forwarded to Tavily, so HTML requests carrying any explicit metadata
|
|
103
|
+
use the local HTML-reader projection. Executor-supplied HTML also stays local;
|
|
104
|
+
only generic web acquisition grants Tavily spending authority.
|
|
54
105
|
|
|
55
|
-
|
|
56
|
-
|
|
106
|
+
GET acquisition of a GitHub `…/blob/…` URL uses its
|
|
107
|
+
`raw.githubusercontent.com` source. The addressed GitHub URL remains entry
|
|
108
|
+
identity. POST, PUT, and DELETE never use that rewrite.
|
|
57
109
|
|
|
58
|
-
|
|
110
|
+
| Control | Effect |
|
|
111
|
+
| ------------------------ | --------------------------------------------------------------------- |
|
|
112
|
+
| `SEND[499](http(s)://…)` | Cancel the routed in-flight acquisition |
|
|
113
|
+
| `SEND[410](http(s)://…)` | Delete the local stored response; the next READ must acquire it again |
|
|
59
114
|
|
|
60
|
-
For a persistent
|
|
115
|
+
For a persistent bidirectional connection, use `wss://`.
|
package/docs/wss.md
CHANGED
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
# wss:// — WebSocket
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
| `
|
|
13
|
-
| `SEND[
|
|
14
|
-
| `
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
handshake aren't wired yet (the standard `WebSocket` constructor has no header
|
|
43
|
-
slot); pending, tracked on #468.
|
|
44
|
-
|
|
45
|
-
Runtime: Node ≥22 (global `WebSocket`).
|
|
3
|
+
Use WebSocket for a persistent, bidirectional connection. `wss` is a
|
|
4
|
+
stateful scheme, not an HTTP content type: READ claims a workspace address and
|
|
5
|
+
owns its socket until terminal settlement, while concurrent SEND and KILL
|
|
6
|
+
operations address that owner.
|
|
7
|
+
|
|
8
|
+
| Operation | Effect |
|
|
9
|
+
| ------------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
10
|
+
| `READ(wss://host/path)` | Claim the address, connect, mark `messages` active on `open`, and stream inbound frames |
|
|
11
|
+
| A second `READ` of the same address | Return `409` until the existing owner's terminal cleanup releases the claim |
|
|
12
|
+
| `SEND[200](wss://host/path):message:` | Send only through an open socket; claimed, connecting, or settling owners return `409` |
|
|
13
|
+
| `SEND[499](wss://host/path)` | Cancel the owning READ through its routed subscription handle |
|
|
14
|
+
| `KILL(wss://host/path)` | Close or cancel the claimed owner; an address with no owner is `404` |
|
|
15
|
+
|
|
16
|
+
| Owner state | Meaning | `SEND[200]` |
|
|
17
|
+
| ------------ | ---------------------------------------------------- | ------------------------------------------------ |
|
|
18
|
+
| `claimed` | Address reserved while entry/subscription setup runs | `409`; no second ownership path is created |
|
|
19
|
+
| `connecting` | Native socket exists but has not emitted `open` | `409`; wait for the active stream event |
|
|
20
|
+
| `open` | `open` was observed and the native state is open | Sends the message |
|
|
21
|
+
| `settling` | A terminal transition owns cleanup | `409`; wait for cleanup before another READ |
|
|
22
|
+
|
|
23
|
+
The native `open` event plus durable `messages` activation is the acquisition
|
|
24
|
+
boundary. It emits the ordinary metadata-only stream event and returns the READ
|
|
25
|
+
at `102`; later operations from the same worker or client may then SEND or KILL
|
|
26
|
+
the live owner. A close before acquisition is a direct `502` connection
|
|
27
|
+
failure. After acquisition, close, cancellation, and failure settle the retained
|
|
28
|
+
subscription without rewriting the initial READ.
|
|
29
|
+
|
|
30
|
+
Connection identity includes the workspace, exact `ws`/`wss` protocol, host,
|
|
31
|
+
non-default port, path, and ordered query. A fragment does not change socket
|
|
32
|
+
identity; `messages` is the only current channel.
|
|
33
|
+
|
|
34
|
+
| Current transport boundary | Behavior |
|
|
35
|
+
| -------------------------- | ----------------------------------------------------------------------- |
|
|
36
|
+
| Inbound payload | String event data only; no coercion or binary projection |
|
|
37
|
+
| Inbound order | Native event order; one durable write completes before the next begins |
|
|
38
|
+
| Binary inbound payload | Keep the text prefix, prune the suffix, settle `415`, and close with private-use code `4003` |
|
|
39
|
+
| Persistence failure | Keep the successful prefix; prune queued and later frames; settle `500` |
|
|
40
|
+
| Reconnection | None; READ again after terminal cleanup |
|
|
41
|
+
| Handshake headers | Target header metadata is not applied |
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-schemes-http",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "HTTP(S) request/response and WebSocket scheme handlers for the plurnk agent runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurnk",
|
|
7
7
|
"scheme",
|
|
8
8
|
"uri",
|
|
9
9
|
"http",
|
|
10
|
-
"https"
|
|
10
|
+
"https",
|
|
11
|
+
"websocket",
|
|
12
|
+
"ws",
|
|
13
|
+
"wss"
|
|
11
14
|
],
|
|
12
|
-
"homepage": "https://github.com/plurnk/plurnk-schemes-http#readme",
|
|
15
|
+
"homepage": "https://github.com/plurnk/plurnk-service/tree/main/plurnk-schemes-http#readme",
|
|
13
16
|
"bugs": {
|
|
14
|
-
"url": "https://
|
|
17
|
+
"url": "https://repo.possumtech.com/plurnk/plurnk-service/issues"
|
|
15
18
|
},
|
|
16
19
|
"repository": {
|
|
17
20
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/plurnk/plurnk-
|
|
21
|
+
"url": "git+https://github.com/plurnk/plurnk-service.git",
|
|
22
|
+
"directory": "plurnk-schemes-http"
|
|
19
23
|
},
|
|
20
24
|
"engines": {
|
|
21
25
|
"node": ">=26"
|
|
@@ -49,7 +53,6 @@
|
|
|
49
53
|
},
|
|
50
54
|
"files": [
|
|
51
55
|
"dist/**/*",
|
|
52
|
-
"scripts/**/*",
|
|
53
56
|
".env.defaults",
|
|
54
57
|
"docs/**/*",
|
|
55
58
|
"README.md",
|
|
@@ -58,19 +61,17 @@
|
|
|
58
61
|
"scripts": {
|
|
59
62
|
"test:lint": "tsc --noEmit",
|
|
60
63
|
"test:unit": "node --conditions=plurnk-dev --test --env-file=.env.defaults src/**/*.test.ts",
|
|
61
|
-
"test:intg": "node --conditions=plurnk-dev --test --env-file=.env.defaults test/integration/**/*.test.ts",
|
|
62
64
|
"test": "npm run test:lint && npm run test:unit",
|
|
65
|
+
"build:clean": "rm -rf dist",
|
|
63
66
|
"build:dist": "tsc -p tsconfig.build.json",
|
|
64
|
-
"build": "npm run build:dist",
|
|
65
|
-
"postinstall": "node scripts/install-browser.mjs",
|
|
67
|
+
"build": "npm run build:clean && npm run build:dist",
|
|
66
68
|
"prepublishOnly": "npm audit --audit-level=moderate && npm test",
|
|
67
69
|
"prepack": "npm run build"
|
|
68
70
|
},
|
|
69
71
|
"peerDependencies": {
|
|
70
|
-
"@plurnk/plurnk-schemes": "^1.
|
|
72
|
+
"@plurnk/plurnk-schemes": "^1.5.0"
|
|
71
73
|
},
|
|
72
74
|
"dependencies": {
|
|
73
|
-
"eventsource-parser": "^
|
|
74
|
-
"playwright": "1.62.0"
|
|
75
|
+
"eventsource-parser": "^4.0.0"
|
|
75
76
|
}
|
|
76
77
|
}
|
package/dist/Browser.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
interface PwResponse {
|
|
2
|
-
status(): number;
|
|
3
|
-
statusText(): string;
|
|
4
|
-
headers(): Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
interface PwRoute {
|
|
7
|
-
request(): {
|
|
8
|
-
url(): string;
|
|
9
|
-
};
|
|
10
|
-
continue(): Promise<void>;
|
|
11
|
-
abort(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
interface PwPage {
|
|
14
|
-
route(pattern: string, handler: (route: PwRoute) => Promise<void>): Promise<void>;
|
|
15
|
-
goto(url: string, opts: {
|
|
16
|
-
waitUntil: "networkidle";
|
|
17
|
-
timeout: number;
|
|
18
|
-
}): Promise<PwResponse | null>;
|
|
19
|
-
setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
|
|
20
|
-
content(): Promise<string>;
|
|
21
|
-
evaluate<T>(fn: () => T): Promise<T>;
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
interface PwContext {
|
|
25
|
-
newPage(): Promise<PwPage>;
|
|
26
|
-
close(): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
interface PwContextOptions {
|
|
29
|
-
userAgent: string;
|
|
30
|
-
viewport: {
|
|
31
|
-
width: number;
|
|
32
|
-
height: number;
|
|
33
|
-
};
|
|
34
|
-
deviceScaleFactor: number;
|
|
35
|
-
isMobile: boolean;
|
|
36
|
-
hasTouch: boolean;
|
|
37
|
-
}
|
|
38
|
-
interface PwBrowser {
|
|
39
|
-
newContext(options?: PwContextOptions): Promise<PwContext>;
|
|
40
|
-
on(event: "disconnected", cb: () => void): void;
|
|
41
|
-
close(): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
interface PwLaunchOptions {
|
|
44
|
-
headless: boolean;
|
|
45
|
-
chromiumSandbox: boolean;
|
|
46
|
-
timeout: number;
|
|
47
|
-
args: ReadonlyArray<string>;
|
|
48
|
-
channel?: string;
|
|
49
|
-
executablePath?: string;
|
|
50
|
-
}
|
|
51
|
-
interface PwConnectOptions {
|
|
52
|
-
timeout: number;
|
|
53
|
-
}
|
|
54
|
-
export interface ChromiumEngine {
|
|
55
|
-
launch(opts: PwLaunchOptions): Promise<PwBrowser>;
|
|
56
|
-
connect(endpoint: string, opts: PwConnectOptions): Promise<PwBrowser>;
|
|
57
|
-
connectOverCDP(endpoint: string, opts: PwConnectOptions): Promise<PwBrowser>;
|
|
58
|
-
}
|
|
59
|
-
export type ChromiumFactory = () => Promise<ChromiumEngine>;
|
|
60
|
-
export type PlaywrightMethod = "launch" | "connect" | "connectOverCDP" | "disabled";
|
|
61
|
-
export interface RenderResult {
|
|
62
|
-
readonly status: number;
|
|
63
|
-
readonly statusText: string;
|
|
64
|
-
readonly headers: ReadonlyArray<readonly [string, string]>;
|
|
65
|
-
readonly html: string;
|
|
66
|
-
}
|
|
67
|
-
export declare const BROWSER_UA = "Mozilla/5.0 (Linux; Android 13; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
|
|
68
|
-
export declare const requireNumEnv: (key: string) => number;
|
|
69
|
-
export default class Browser {
|
|
70
|
-
#private;
|
|
71
|
-
constructor(factory?: ChromiumFactory);
|
|
72
|
-
ready(): Promise<PlaywrightMethod>;
|
|
73
|
-
render(url: string, { workerId, signal, headers, guard, timeout }: {
|
|
74
|
-
workerId: number;
|
|
75
|
-
signal?: AbortSignal;
|
|
76
|
-
headers?: ReadonlyArray<readonly [string, string]>;
|
|
77
|
-
guard?: (url: string) => Promise<boolean>;
|
|
78
|
-
timeout?: number;
|
|
79
|
-
}): Promise<RenderResult>;
|
|
80
|
-
closeContext(workerId: number): void;
|
|
81
|
-
close(): Promise<void>;
|
|
82
|
-
}
|
|
83
|
-
export {};
|
|
84
|
-
//# sourceMappingURL=Browser.d.ts.map
|
package/dist/Browser.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../src/Browser.ts"],"names":[],"mappings":"AAmBA,UAAU,UAAU;IAChB,MAAM,IAAI,MAAM,CAAC;IACjB,UAAU,IAAI,MAAM,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AACD,UAAU,OAAO;IACb,OAAO,IAAI;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE,CAAC;IAC7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AACD,UAAU,MAAM;IACZ,KAAK,CAAC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