uiport 0.1.4 → 0.1.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/CHANGELOG.md +9 -0
- package/README.md +10 -6
- package/README.pt-BR.md +10 -6
- package/bin/cli.mjs +2 -1
- package/docs/support.md +5 -3
- package/package.json +1 -1
- package/scripts/capture.mjs +7 -0
- package/scripts/options.mjs +48 -2
- package/scripts/validate.mjs +6 -1
- package/skills/uiport/SKILL.md +7 -6
- package/uiport.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ Notable changes are documented here. Versions follow Semantic Versioning.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.1.5] — 2026-11-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- `capture` and `validate` accept `--storage-state FILE`, the session state file the browser itself produces, so a section that sits behind a login can be captured. The file belongs to the user: it is read, used on the source page only, never copied into the output, and its path is not written anywhere. The export opens without it.
|
|
11
|
+
- `docs/analysis.md` records the engineering review: what was examined, what was found, what was measured, what the independent reviews found, and what was deliberately left alone.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- The support matrix states two boundaries the tool always had. The export is the DOM of the first viewport, so a section that changes the class of an element across viewports can bind a contextual property to the rule of another viewport; the validation reports the consequence. The redaction covers credentials, queries and fragments and keeps the path of a URL.
|
|
15
|
+
|
|
7
16
|
## [0.1.4] — 2026-11-29
|
|
8
17
|
|
|
9
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
UIport captures a rendered section as editable HTML, original CSS and local assets. Inspect it, compare it with the source, and make it a starting point for your own work. Runs locally, from your terminal or coding agent. No account, API key or hosted service.
|
|
6
6
|
|
|
7
|
-
[Português brasileiro](README.pt-BR.md) · [Support matrix](docs/support.md) · [Contributing](CONTRIBUTING.md)
|
|
7
|
+
[Português brasileiro](README.pt-BR.md) · [Support matrix](docs/support.md) · [Engineering review](docs/analysis.md) · [Contributing](CONTRIBUTING.md)
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -25,10 +25,10 @@ Requires **Node.js 22.14+**; Node 24 LTS recommended. Chromium is installed expl
|
|
|
25
25
|
Run these commands in any directory, including an empty one. `npx` fetches UIport automatically; you do not need a `package.json` or `npm install` in that directory. `browser install` prepares Chromium in Playwright's shared browser cache.
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
npx uiport@0.1.
|
|
29
|
-
npx uiport@0.1.
|
|
30
|
-
npx uiport@0.1.
|
|
31
|
-
npx uiport@0.1.
|
|
28
|
+
npx uiport@0.1.5 browser install
|
|
29
|
+
npx uiport@0.1.5 capture --url "https://your-site.example" --selector "#hero" --out ./my-section
|
|
30
|
+
npx uiport@0.1.5 serve --dir ./my-section
|
|
31
|
+
npx uiport@0.1.5 validate --url "https://your-site.example" --selector "#hero" --dir ./my-section
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Choose the selector using your browser's **Inspect element** tool. It must match exactly one container, such as `main`, `section` or a `div`, and that container must render something at the captured viewport: a root that displays nothing is reported as a partial result. Use `body` to capture the whole visible page, or `html` to include original head scripts as well. This captures one page, not a multi-page crawl.
|
|
@@ -68,7 +68,9 @@ Open `http://127.0.0.1:4174`. You can move that output directory and serve it ag
|
|
|
68
68
|
| `browser install` | Install Chromium matched to the bundled Playwright version |
|
|
69
69
|
| `--help` / `--version` | Inspect the CLI without starting a browser |
|
|
70
70
|
|
|
71
|
-
`capture` and `validate` share `--viewports`, `--wait`, `--timeout`, `--max-scroll-steps`, `--locale`, `--color-scheme` and `--json`. `capture --dry-run` checks the selector against the page and writes nothing.
|
|
71
|
+
`capture` and `validate` share `--viewports`, `--wait`, `--timeout`, `--max-scroll-steps`, `--locale`, `--color-scheme` and `--json`. `capture --dry-run` checks the selector against the page and writes nothing.
|
|
72
|
+
|
|
73
|
+
A section that sits behind a login can be captured with `--storage-state FILE`, the session state file the browser itself produces. The file is yours: UIport reads it, uses it on the source page only, and never copies it into the output or writes its path anywhere. The exported section opens without it, exactly as the person who receives it would open it. Defaults: four viewports (`1440x900,1024x768,768x1024,375x812`), 1200 ms settle time, 120 s whole-operation deadline and 80 scroll steps. The default locale is `pt-BR`; use the same `--locale` and `--color-scheme` in capture and validation.
|
|
72
74
|
|
|
73
75
|
Capture limits copied resources to 20 MiB each and 100 MiB in total. Override with `--max-resource-mb` and `--max-total-mb`. The capture reuses responses received by its fresh browser context (including resources requiring Referer), then uses HTTP fetch as fallback. Budgets limit retained response bytes and exported downloads, not the browser's complete memory or the temporary buffer materialized by Playwright. Fallback fetching has a 15 s request deadline.
|
|
74
76
|
|
|
@@ -87,6 +89,8 @@ Validation disables animations for screenshots. It compares pixels with a defaul
|
|
|
87
89
|
|
|
88
90
|
Migration compatibility and intentional command/default changes: [migration notes](docs/migration.md).
|
|
89
91
|
|
|
92
|
+
What the engineering review found, what was changed, what was measured and what was deliberately left alone: [engineering review](docs/analysis.md).
|
|
93
|
+
|
|
90
94
|
## Use with a coding agent
|
|
91
95
|
|
|
92
96
|
Start with [uiport.md](uiport.md). Read [skills/uiport/SKILL.md](skills/uiport/SKILL.md), or copy it into your agent's skill directory. The same file ships with the npm package. The agent should capture, read limitations, inspect supported interactions and validate, without inventing replacement effects. No LLM API is called by UIport itself.
|
package/README.pt-BR.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
O UIport captura uma seção renderizada como HTML editável, CSS original e assets locais. Inspecione a implementação, compare com a origem e use como base para continuar seu projeto. Executa localmente, pelo terminal ou pelo seu agente de código, sem conta, chave de IA ou serviço hospedado.
|
|
6
6
|
|
|
7
|
-
[English](README.md) · [Matriz de suporte](docs/support.md) · [Contribuição](CONTRIBUTING.md)
|
|
7
|
+
[English](README.md) · [Matriz de suporte](docs/support.md) · [Revisão de engenharia](docs/analysis.md) · [Contribuição](CONTRIBUTING.md)
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -25,10 +25,10 @@ Requer **Node.js 22.14+**; recomendamos Node 24 LTS. O Chromium é instalado exp
|
|
|
25
25
|
Execute os comandos em uma pasta de sua escolha, que pode estar vazia. O `npx` obtém o UIport automaticamente; não é necessário criar um `package.json` nem rodar `npm install` nessa pasta. `browser install` prepara o Chromium no cache compartilhado do Playwright.
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
npx uiport@0.1.
|
|
29
|
-
npx uiport@0.1.
|
|
30
|
-
npx uiport@0.1.
|
|
31
|
-
npx uiport@0.1.
|
|
28
|
+
npx uiport@0.1.5 browser install
|
|
29
|
+
npx uiport@0.1.5 capture --url "https://seu-site.example" --selector "#hero" --out ./minha-secao
|
|
30
|
+
npx uiport@0.1.5 serve --dir ./minha-secao
|
|
31
|
+
npx uiport@0.1.5 validate --url "https://seu-site.example" --selector "#hero" --dir ./minha-secao
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Para escolher o seletor, use **Inspecionar elemento** no navegador. Ele precisa encontrar exatamente um container, como `main`, `section` ou `div`, e esse container precisa renderizar algo no tamanho de tela capturado: uma raiz que não exibe nada é relatada como resultado parcial. Use `body` para capturar a página visível completa ou `html` para incluir também scripts originais do head. Isso captura uma página, sem percorrer automaticamente outras URLs do site.
|
|
@@ -68,7 +68,9 @@ Abra `http://127.0.0.1:4174`. A pasta de saída pode ser movida e servida novame
|
|
|
68
68
|
| `browser install` | Instala Chromium compatível com a versão de Playwright do pacote |
|
|
69
69
|
| `--help` / `--version` | Mostra ajuda ou versão sem abrir navegador |
|
|
70
70
|
|
|
71
|
-
Capture e validate aceitam `--viewports`, `--wait`, `--timeout`, `--max-scroll-steps`, `--locale`, `--color-scheme` e `--json`. `capture --dry-run` confere o seletor na página sem escrever nada.
|
|
71
|
+
Capture e validate aceitam `--viewports`, `--wait`, `--timeout`, `--max-scroll-steps`, `--locale`, `--color-scheme` e `--json`. `capture --dry-run` confere o seletor na página sem escrever nada.
|
|
72
|
+
|
|
73
|
+
Uma seção que fica atrás de um login pode ser capturada com `--storage-state FILE`, o arquivo de estado de sessão que o próprio browser produz. O arquivo é seu: o UIport o lê, usa apenas na página de origem e nunca o copia para a saída nem grava o caminho dele em lugar algum. A seção exportada abre sem ele, exatamente como abriria para quem a recebe. Padrões: `1440x900,1024x768,768x1024,375x812`, espera de 1200 ms, prazo total de 120 s, 80 passos de rolagem, idioma `pt-BR` e tema `light`. Use o mesmo `--locale` nos dois comandos quando precisar de outro idioma.
|
|
72
74
|
|
|
73
75
|
A captura limita recursos copiados a 20 MiB por arquivo e 100 MiB no total, configuráveis por `--max-resource-mb` e `--max-total-mb`. A captura reaproveita respostas recebidas pelo navegador, incluindo recursos que exigem Referer, e usa fetch HTTP como fallback. Os orçamentos limitam bytes retidos e baixados pela exportação, não a memória completa do navegador nem o buffer temporário materializado pelo Playwright. O fetch de fallback tem prazo de até 15 s.
|
|
74
76
|
|
|
@@ -87,6 +89,8 @@ A comparação visual desativa animações, aceita por padrão 2% de diferença
|
|
|
87
89
|
|
|
88
90
|
Compatibilidade com o protótipo e mudanças intencionais de comandos/limites: [notas de migração](docs/migration.md).
|
|
89
91
|
|
|
92
|
+
O que a revisão de engenharia encontrou, o que mudou, o que foi medido e o que foi deixado de fora de propósito: [revisão de engenharia](docs/analysis.md).
|
|
93
|
+
|
|
90
94
|
## Usar com agentes e contribuir
|
|
91
95
|
|
|
92
96
|
Comece por [uiport.md](uiport.md). Leia [skills/uiport/SKILL.md](skills/uiport/SKILL.md) ou copie para a pasta de skills do seu agente. A skill também acompanha o pacote npm. O agente deve capturar, ler limitações, inspecionar interações suportadas e validar, sem inventar efeitos substitutos. O UIport não chama uma API de LLM.
|
package/bin/cli.mjs
CHANGED
|
@@ -32,6 +32,7 @@ Capture / validate / diff:
|
|
|
32
32
|
--json One JSON result on stdout; progress on stderr
|
|
33
33
|
Capture / validate:
|
|
34
34
|
--max-scroll-steps 80 Bounded lazy-loading scroll (1–1000)
|
|
35
|
+
--storage-state FILE Session state you prepared; used on the source only
|
|
35
36
|
Capture:
|
|
36
37
|
--omit-scripts Omit source scripts and inline event handlers
|
|
37
38
|
--dry-run Check the selector against the page and stop
|
|
@@ -110,7 +111,7 @@ try {
|
|
|
110
111
|
);
|
|
111
112
|
process.exitCode = Number(code);
|
|
112
113
|
} else {
|
|
113
|
-
const options = optionsFor(command, args);
|
|
114
|
+
const options = await optionsFor(command, args);
|
|
114
115
|
// A capture or a validation writes exactly one JSON document to stdout.
|
|
115
116
|
// The guard is installed before the command module is loaded, so that
|
|
116
117
|
// anything printed while loading also goes to the diagnostics channel.
|
package/docs/support.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# UIport support matrix
|
|
2
2
|
|
|
3
|
-
This matrix describes the 0.1.x CLI line and was last verified against 0.1.
|
|
3
|
+
This matrix describes the 0.1.x CLI line and was last verified against 0.1.5. It applies to every 0.1.x release unless a row says otherwise.
|
|
4
4
|
|
|
5
5
|
UIport exports a rendered section or a selected whole page. It does not reconstruct a complete application backend or crawl a site. A successful capture is not a general proof of fidelity.
|
|
6
6
|
|
|
@@ -49,9 +49,11 @@ A failure carries a stable code and a hint: `USAGE_INVALID`, `BROWSER_NOT_FOUND`
|
|
|
49
49
|
- The selected root must render something at the captured viewport. A root that displays nothing — hidden, without a box of its own, or fully transparent — is reported as a partial result instead of failing the capture, and validation refuses it with an actionable message instead of waiting for a screenshot that can never succeed.
|
|
50
50
|
- Export resource budget: default 20 MiB/file, 100 MiB total; controls downloaded copies, not source browser memory. Successful responses from the fresh capture context are reused, including Referer-dependent resources. Retention has the same per-file/aggregate budgets, but Playwright materializes response bodies before actual-size validation; peak memory is not bounded by these budgets. All referenced CSS resources may be retained, including resources unused by the selected DOM, because CSS is conservative.
|
|
51
51
|
- Resources are downloaded concurrently, with at most eight transfers at a time. The per-file and total budgets are shared by those transfers, so a section that references many assets does not exceed the total budget. The same URL is downloaded once even when several declarations reference it. The result reports `downloadedBytes`, the bytes read from the network, and `budgetBytes`, the bytes charged against the total budget; the charged amount never exceeds the limit, while the read amount can exceed it by the chunk that the limit refused.
|
|
52
|
-
- Public HTTP(S) only; no session
|
|
52
|
+
- Public HTTP(S) only; the tool imports no session of its own. A section that sits behind a login can be captured with `--storage-state FILE`, the session state file the browser itself produces. The file is read, used on the source page only, and never copied into the output; the export opens without it. The path of the file is not written to the artifact either.
|
|
53
|
+
- Local development URLs are supported. The capture reuses its own navigation responses; fallback fetch does not import browser cookies.
|
|
53
54
|
- Source JavaScript executes in the capture browser. The optional --omit-scripts mode is not a general-purpose sanitizer or sandbox for hostile websites.
|
|
54
|
-
- Source style values and content remain in the HTML. Review artifacts before redistribution. The CLI redacts URL credentials, queries and fragments in resource diagnostics and operational errors and does not print source page content or form values.
|
|
55
|
+
- Source style values and content remain in the HTML. Review artifacts before redistribution. The CLI redacts URL credentials, queries and fragments in resource diagnostics and operational errors and does not print source page content or form values. The path of a URL is kept, because it identifies the resource; a secret carried in a path segment is not masked, so avoid capturing an address that carries one.
|
|
56
|
+
- The exported DOM is the one captured at the first viewport. When the source changes the class or another attribute of an element across viewports without changing the element structure, the contextual custom property is expected to follow the export, but an observation that lands between the extraction and the measurement can bind it to the rule of another viewport. `validate` reports the consequence as a visual difference; when a section behaves this way, capture it at the viewport you intend to deliver.
|
|
55
57
|
- Network/rendering differences, DOM changed by runtime, special CSS/HTML features and states not observed can still require manual work. No invented replacement effects.
|
|
56
58
|
|
|
57
59
|
Common partial-result codes: `SOURCE_RUNTIME_UNVERIFIED`, `SOURCE_RUNTIME_OMITTED`, `RESOURCE_UNAVAILABLE`, `INVALID_RESOURCE_URL`, `STYLESHEET_UNAVAILABLE`, `SRCSET_INVALID`, `SCROLL_LIMIT`, `RESPONSIVE_DOM_CHANGED`, `SECTION_NOT_VISIBLE`, `SECTION_EMPTY_AREA`, `CANVAS_STATIC`, `CANVAS_UNREADABLE`, `EMBED_OMITTED`, `ANIMATION_UNSUPPORTED`, `SOURCE_REQUEST_FAILED`, `SOURCE_SCRIPT_ERROR`, `CSS_IMPORT_CYCLE`, `CSS_IMPORT_UNSUPPORTED`.
|
package/package.json
CHANGED
package/scripts/capture.mjs
CHANGED
|
@@ -43,6 +43,8 @@ async function dryRun(options) {
|
|
|
43
43
|
locale: options.locale,
|
|
44
44
|
colorScheme: options.colorScheme,
|
|
45
45
|
serviceWorkers: "block",
|
|
46
|
+
// The session the user prepared, and only on the page of the source.
|
|
47
|
+
...(options.storageState ? { storageState: options.storageState } : {}),
|
|
46
48
|
});
|
|
47
49
|
const page = await context.newPage();
|
|
48
50
|
await page.goto(options.sourceUrl, {
|
|
@@ -109,6 +111,8 @@ export async function capture(options) {
|
|
|
109
111
|
locale,
|
|
110
112
|
colorScheme,
|
|
111
113
|
serviceWorkers: "block",
|
|
114
|
+
// The session the user prepared, and only on the page of the source.
|
|
115
|
+
...(options.storageState ? { storageState: options.storageState } : {}),
|
|
112
116
|
});
|
|
113
117
|
const page = await context.newPage();
|
|
114
118
|
const cache = browserResources(page, options, life.signal);
|
|
@@ -403,6 +407,9 @@ export async function capture(options) {
|
|
|
403
407
|
limitations,
|
|
404
408
|
behavior: BEHAVIOR,
|
|
405
409
|
source: redactedUrl(sourceUrl),
|
|
410
|
+
// The fact that a session was used is worth recording; the file that
|
|
411
|
+
// carries it is not, and it never leaves the machine of the user.
|
|
412
|
+
...(options.storageState ? { authenticated: true } : {}),
|
|
406
413
|
};
|
|
407
414
|
const html = `<!doctype html>
|
|
408
415
|
<html lang="${escapeHtml(locale)}"${serializeAttributes(primary.htmlAttributes)}>
|
package/scripts/options.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
import fs from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { UiportError } from "./errors.mjs";
|
|
4
5
|
|
|
@@ -22,6 +23,7 @@ export const allowed = {
|
|
|
22
23
|
"omit-scripts",
|
|
23
24
|
"max-scroll-steps",
|
|
24
25
|
"dry-run",
|
|
26
|
+
"storage-state",
|
|
25
27
|
],
|
|
26
28
|
validate: [
|
|
27
29
|
...common,
|
|
@@ -30,6 +32,7 @@ export const allowed = {
|
|
|
30
32
|
"max-diff-ratio",
|
|
31
33
|
"allow-external",
|
|
32
34
|
"max-scroll-steps",
|
|
35
|
+
"storage-state",
|
|
33
36
|
],
|
|
34
37
|
serve: [...common, "dir", "port"],
|
|
35
38
|
inspect: [...common, "dir"],
|
|
@@ -93,6 +96,46 @@ export function required(args, key) {
|
|
|
93
96
|
return value.trim();
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Reads the session state the user prepared, when one is given. The file
|
|
101
|
+
* belongs to the user and stays on their machine: it is read by the browser
|
|
102
|
+
* and never copied into the output.
|
|
103
|
+
* @param {string | boolean | undefined} value
|
|
104
|
+
*/
|
|
105
|
+
export async function storageState(value) {
|
|
106
|
+
if (typeof value !== "string" || !value) return undefined;
|
|
107
|
+
const file = path.resolve(value);
|
|
108
|
+
let content;
|
|
109
|
+
try {
|
|
110
|
+
content = await fs.readFile(file, "utf8");
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw new UiportError(
|
|
113
|
+
"USAGE_INVALID",
|
|
114
|
+
`The session state file could not be read: ${file}`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
let parsed;
|
|
118
|
+
try {
|
|
119
|
+
parsed = JSON.parse(content);
|
|
120
|
+
} catch {
|
|
121
|
+
throw new UiportError(
|
|
122
|
+
"USAGE_INVALID",
|
|
123
|
+
`The session state file is not valid JSON: ${file}`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
127
|
+
throw new UiportError(
|
|
128
|
+
"USAGE_INVALID",
|
|
129
|
+
`The session state file is not a session state: ${file}`,
|
|
130
|
+
);
|
|
131
|
+
if (!Array.isArray(parsed.cookies) && !parsed.origins)
|
|
132
|
+
throw new UiportError(
|
|
133
|
+
"USAGE_INVALID",
|
|
134
|
+
`The session state file has neither cookies nor origins: ${file}`,
|
|
135
|
+
);
|
|
136
|
+
return file;
|
|
137
|
+
}
|
|
138
|
+
|
|
96
139
|
/** @param {unknown} value @param {string} key @param {number} fallback @param {number} min @param {number} max */
|
|
97
140
|
export function numeric(value, key, fallback, min, max) {
|
|
98
141
|
const n = value === undefined ? fallback : Number(value);
|
|
@@ -157,6 +200,7 @@ export function httpUrl(value) {
|
|
|
157
200
|
* @property {string} before
|
|
158
201
|
* @property {string} after
|
|
159
202
|
* @property {string} directory
|
|
203
|
+
* @property {string | undefined} storageState
|
|
160
204
|
* @property {{width:number,height:number,name:string}[]} viewports
|
|
161
205
|
* @property {number} settleMs
|
|
162
206
|
* @property {number} timeoutMs
|
|
@@ -170,8 +214,8 @@ export function httpUrl(value) {
|
|
|
170
214
|
* @property {number} port
|
|
171
215
|
*/
|
|
172
216
|
|
|
173
|
-
/** @param {string} command @param {Record<string, string | boolean>} args @returns {Options} */
|
|
174
|
-
export function optionsFor(command, args) {
|
|
217
|
+
/** @param {string} command @param {Record<string, string | boolean>} args @returns {Promise<Options>} */
|
|
218
|
+
export async function optionsFor(command, args) {
|
|
175
219
|
/** @type {Options} */
|
|
176
220
|
const options = {
|
|
177
221
|
json: args.json === true,
|
|
@@ -182,6 +226,7 @@ export function optionsFor(command, args) {
|
|
|
182
226
|
before: "",
|
|
183
227
|
after: "",
|
|
184
228
|
directory: "",
|
|
229
|
+
storageState: undefined,
|
|
185
230
|
viewports: parseViewports(
|
|
186
231
|
typeof args.viewports === "string" ? args.viewports : undefined,
|
|
187
232
|
),
|
|
@@ -232,6 +277,7 @@ export function optionsFor(command, args) {
|
|
|
232
277
|
if (command === "capture" || command === "validate") {
|
|
233
278
|
options.sourceUrl = httpUrl(required(args, "url"));
|
|
234
279
|
options.selector = required(args, "selector");
|
|
280
|
+
options.storageState = await storageState(args["storage-state"]);
|
|
235
281
|
}
|
|
236
282
|
if (command === "diff") {
|
|
237
283
|
options.before = path.resolve(required(args, "before"));
|
package/scripts/validate.mjs
CHANGED
|
@@ -70,7 +70,12 @@ export async function validate(options) {
|
|
|
70
70
|
serviceWorkers: "block",
|
|
71
71
|
};
|
|
72
72
|
// Separate contexts ensure the exported page cannot inherit source cookies/storage.
|
|
73
|
-
|
|
73
|
+
// The session is used on the source only: the exported page must open
|
|
74
|
+
// without it, exactly as a reader would receive it.
|
|
75
|
+
const sourceContext = await browser.newContext({
|
|
76
|
+
...settings,
|
|
77
|
+
...(options.storageState ? { storageState: options.storageState } : {}),
|
|
78
|
+
});
|
|
74
79
|
const localContext = await browser.newContext(settings);
|
|
75
80
|
try {
|
|
76
81
|
const source = await sourceContext.newPage();
|
package/skills/uiport/SKILL.md
CHANGED
|
@@ -8,15 +8,16 @@ description: Capture a rendered web section as editable HTML, original CSS and l
|
|
|
8
8
|
Use for a request to extract an existing web section into local files. Use pages the user owns or has permission to reuse. Do not redesign or invent replacement effects.
|
|
9
9
|
|
|
10
10
|
1. Inspect the requested URL and choose one CSS selector matching a section container, or body/html for a full page. Include wrappers/decorations that belong to it; html also includes original head scripts. The selected root must render something at the captured viewport: a root that displays nothing is reported as a partial result.
|
|
11
|
-
2. Use the installed CLI or source checkout. `npx uiport@0.1.
|
|
11
|
+
2. Use the installed CLI or source checkout. `npx uiport@0.1.5` is the pinned form. When testing an unpublished version, use `node bin/cli.mjs` from its checkout.
|
|
12
12
|
3. If needed, install the matching browser with `uiport browser install`. No browser download is hidden inside capture.
|
|
13
13
|
4. Check the selector first with `uiport capture --url "URL" --selector "SELECTOR" --dry-run`. It reports whether the selector resolves to one visible element and writes nothing.
|
|
14
14
|
5. Run `uiport capture --url "URL" --selector "SELECTOR" --out "NEW_DIRECTORY" --json`. The default locale is pt-BR. Match locale/color scheme/viewports to the requested source. Never overwrite an existing nonempty directory.
|
|
15
|
-
6.
|
|
16
|
-
7.
|
|
17
|
-
8.
|
|
18
|
-
9.
|
|
19
|
-
10.
|
|
15
|
+
6. When the section sits behind a login, add `--storage-state "FILE"`, the session state file the browser itself produces. Use it only when the user owns the session and asked for it: the file is read, used on the source page only, never copied into the output, and its path is not written anywhere. The export opens without it.
|
|
16
|
+
7. Read the result. Exit 0 means no known reported limitations, not universal fidelity. Exit 2 means a partial artifact exists; inspect every limitation. Exit 1 means failure. With `--json` stdout carries one JSON document; without it, stdout carries a readable summary and progress goes to stderr.
|
|
17
|
+
8. Preview with `uiport serve --dir "DIRECTORY"` and compare with `uiport validate --url "URL" --selector "SELECTOR" --dir "DIRECTORY" --json`, using the same viewport/locale/color-scheme options. `uiport inspect --dir "DIRECTORY" --json` reads the limitations of an artifact without opening a browser.
|
|
18
|
+
9. Inspect hover/focus, animation and relevant interactions separately. Validation disables animation for screenshots and reports behavior as not tested. Source scripts inside the selection, inline handlers and recognized visual library scripts are retained by default. Use capture --omit-scripts to omit them explicitly. Outside initialization, listeners and framework dependencies are not generically recovered; inspect SOURCE_RUNTIME_UNVERIFIED.
|
|
19
|
+
10. If an effect cannot be isolated from original source, explain the limitation. Do not create a visually similar substitute and call it an extraction. Manual integration of necessary original runtime code is separate work requiring inspection and validation.
|
|
20
|
+
11. Deliver `index.html` and `assets/` only in the extraction folder. Put reports/screenshots outside it. State the path, verified behavior and remaining limitations.
|
|
20
21
|
|
|
21
22
|
## When the command fails
|
|
22
23
|
|
package/uiport.md
CHANGED
|
@@ -90,7 +90,7 @@ node bin/cli.mjs capture --url "<URL>" --selector "<SELETOR>" --out "./extractio
|
|
|
90
90
|
|
|
91
91
|
Ajuste `--locale`, `--color-scheme` e `--viewports` conforme a origem e use os mesmos valores na validação. A captura não sobrescreve uma pasta existente com conteúdo. `UIPORT_BROWSER_PATH` permite escolher o executável do navegador; a instalação do Chromium é explícita.
|
|
92
92
|
|
|
93
|
-
Os mesmos subcomandos podem ser executados com `npx uiport@0.1.
|
|
93
|
+
Os mesmos subcomandos podem ser executados com `npx uiport@0.1.5` no lugar de `node bin/cli.mjs`. Ao testar uma versão ainda não publicada, use o checkout local. Consulte os [comandos e opções](README.pt-BR.md) ou execute `node bin/cli.mjs --help`.
|
|
94
94
|
|
|
95
95
|
Confira o seletor antes de capturar, sem escrever nada:
|
|
96
96
|
|