browxai 0.7.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/LICENSE +21 -0
- package/README.md +139 -0
- package/THIRD_PARTY_NOTICES.md +45 -0
- package/dist/cli/chrome.d.ts +1 -0
- package/dist/cli/chrome.js +130 -0
- package/dist/cli/command-registry.d.ts +15 -0
- package/dist/cli/command-registry.js +35 -0
- package/dist/cli/doctor-plugins.d.ts +18 -0
- package/dist/cli/doctor-plugins.js +338 -0
- package/dist/cli/doctor.d.ts +9 -0
- package/dist/cli/doctor.js +407 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.js +200 -0
- package/dist/cli/register-commands.d.ts +1 -0
- package/dist/cli/register-commands.js +22 -0
- package/dist/cli/serve.d.ts +14 -0
- package/dist/cli/serve.js +151 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +129 -0
- package/dist/engine/adapters/adb.d.ts +72 -0
- package/dist/engine/adapters/adb.js +200 -0
- package/dist/engine/adapters/android-cdp.d.ts +54 -0
- package/dist/engine/adapters/android-cdp.js +110 -0
- package/dist/engine/adapters/android.engine.d.ts +1 -0
- package/dist/engine/adapters/android.engine.js +31 -0
- package/dist/engine/adapters/chromium.engine.d.ts +1 -0
- package/dist/engine/adapters/chromium.engine.js +44 -0
- package/dist/engine/adapters/firefox.engine.d.ts +1 -0
- package/dist/engine/adapters/firefox.engine.js +43 -0
- package/dist/engine/adapters/playwright-chromium.d.ts +43 -0
- package/dist/engine/adapters/playwright-chromium.js +56 -0
- package/dist/engine/adapters/playwright-firefox.d.ts +52 -0
- package/dist/engine/adapters/playwright-firefox.js +97 -0
- package/dist/engine/adapters/playwright-webkit.d.ts +40 -0
- package/dist/engine/adapters/playwright-webkit.js +79 -0
- package/dist/engine/adapters/safari/bidi-client.d.ts +46 -0
- package/dist/engine/adapters/safari/bidi-client.js +130 -0
- package/dist/engine/adapters/safari/launch.d.ts +56 -0
- package/dist/engine/adapters/safari/launch.js +104 -0
- package/dist/engine/adapters/safari/webdriver-client.d.ts +102 -0
- package/dist/engine/adapters/safari/webdriver-client.js +175 -0
- package/dist/engine/adapters/safari.engine.d.ts +1 -0
- package/dist/engine/adapters/safari.engine.js +52 -0
- package/dist/engine/adapters/safaridriver-hybrid.d.ts +56 -0
- package/dist/engine/adapters/safaridriver-hybrid.js +127 -0
- package/dist/engine/adapters/webkit.engine.d.ts +1 -0
- package/dist/engine/adapters/webkit.engine.js +47 -0
- package/dist/engine/capabilities.d.ts +53 -0
- package/dist/engine/capabilities.js +122 -0
- package/dist/engine/capability-registry.d.ts +9 -0
- package/dist/engine/capability-registry.js +20 -0
- package/dist/engine/index.d.ts +18 -0
- package/dist/engine/index.js +14 -0
- package/dist/engine/register-engines.d.ts +5 -0
- package/dist/engine/register-engines.js +16 -0
- package/dist/engine/registry.d.ts +145 -0
- package/dist/engine/registry.js +67 -0
- package/dist/engine/select.d.ts +48 -0
- package/dist/engine/select.js +128 -0
- package/dist/engine/session-cdp.d.ts +13 -0
- package/dist/engine/session-cdp.js +22 -0
- package/dist/engine/tool-gate.d.ts +19 -0
- package/dist/engine/tool-gate.js +226 -0
- package/dist/engine/types.d.ts +71 -0
- package/dist/engine/types.js +16 -0
- package/dist/helper/bridge.d.ts +48 -0
- package/dist/helper/bridge.js +200 -0
- package/dist/helper/browx-page.d.ts +1 -0
- package/dist/helper/browx-page.js +47 -0
- package/dist/helper/overlay-hide.d.ts +9 -0
- package/dist/helper/overlay-hide.js +49 -0
- package/dist/helper/stealth.d.ts +10 -0
- package/dist/helper/stealth.js +88 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +15 -0
- package/dist/page/a11y.d.ts +81 -0
- package/dist/page/a11y.js +219 -0
- package/dist/page/action-substrate.d.ts +64 -0
- package/dist/page/action-substrate.js +118 -0
- package/dist/page/actionresult-blocks.d.ts +99 -0
- package/dist/page/actionresult-blocks.js +144 -0
- package/dist/page/actionresult-shape.d.ts +48 -0
- package/dist/page/actionresult-shape.js +155 -0
- package/dist/page/actionresult-types.d.ts +368 -0
- package/dist/page/actionresult-types.js +4 -0
- package/dist/page/actionresult.d.ts +4 -0
- package/dist/page/actionresult.js +299 -0
- package/dist/page/actions-probe.d.ts +32 -0
- package/dist/page/actions-probe.js +294 -0
- package/dist/page/actions-scroll.d.ts +40 -0
- package/dist/page/actions-scroll.js +53 -0
- package/dist/page/actions.d.ts +132 -0
- package/dist/page/actions.js +453 -0
- package/dist/page/archive-assets.d.ts +39 -0
- package/dist/page/archive-assets.js +187 -0
- package/dist/page/archive.d.ts +47 -0
- package/dist/page/archive.js +349 -0
- package/dist/page/asset-export.d.ts +122 -0
- package/dist/page/asset-export.js +376 -0
- package/dist/page/await_network.d.ts +16 -0
- package/dist/page/await_network.js +23 -0
- package/dist/page/bbox.d.ts +37 -0
- package/dist/page/bbox.js +115 -0
- package/dist/page/canvas-capture.d.ts +82 -0
- package/dist/page/canvas-capture.js +257 -0
- package/dist/page/canvas-diff.d.ts +51 -0
- package/dist/page/canvas-diff.js +131 -0
- package/dist/page/canvas-gesture.d.ts +53 -0
- package/dist/page/canvas-gesture.js +167 -0
- package/dist/page/canvas-transform.d.ts +96 -0
- package/dist/page/canvas-transform.js +150 -0
- package/dist/page/canvas.d.ts +8 -0
- package/dist/page/canvas.js +50 -0
- package/dist/page/capture-substrate.d.ts +111 -0
- package/dist/page/capture-substrate.js +139 -0
- package/dist/page/clipboard.d.ts +25 -0
- package/dist/page/clipboard.js +50 -0
- package/dist/page/clock.d.ts +36 -0
- package/dist/page/clock.js +167 -0
- package/dist/page/compose.d.ts +55 -0
- package/dist/page/compose.js +169 -0
- package/dist/page/console.d.ts +39 -0
- package/dist/page/console.js +73 -0
- package/dist/page/coverage.d.ts +97 -0
- package/dist/page/coverage.js +280 -0
- package/dist/page/dom-export.d.ts +41 -0
- package/dist/page/dom-export.js +193 -0
- package/dist/page/dom-walk.d.ts +91 -0
- package/dist/page/dom-walk.js +267 -0
- package/dist/page/dom_diff.d.ts +48 -0
- package/dist/page/dom_diff.js +121 -0
- package/dist/page/downloads.d.ts +80 -0
- package/dist/page/downloads.js +244 -0
- package/dist/page/drop-files.d.ts +78 -0
- package/dist/page/drop-files.js +310 -0
- package/dist/page/element-export-discovery.d.ts +64 -0
- package/dist/page/element-export-discovery.js +346 -0
- package/dist/page/element-export.d.ts +46 -0
- package/dist/page/element-export.js +251 -0
- package/dist/page/emulation-substrate.d.ts +53 -0
- package/dist/page/emulation-substrate.js +87 -0
- package/dist/page/emulation.d.ts +60 -0
- package/dist/page/emulation.js +162 -0
- package/dist/page/export-playwright-script.d.ts +47 -0
- package/dist/page/export-playwright-script.js +304 -0
- package/dist/page/extract-resolve.d.ts +22 -0
- package/dist/page/extract-resolve.js +341 -0
- package/dist/page/extract-schema.d.ts +20 -0
- package/dist/page/extract-schema.js +200 -0
- package/dist/page/extract-types.d.ts +127 -0
- package/dist/page/extract-types.js +8 -0
- package/dist/page/extract-warnings.d.ts +8 -0
- package/dist/page/extract-warnings.js +56 -0
- package/dist/page/extract.d.ts +9 -0
- package/dist/page/extract.js +174 -0
- package/dist/page/fill-form.d.ts +58 -0
- package/dist/page/fill-form.js +261 -0
- package/dist/page/find.d.ts +158 -0
- package/dist/page/find.js +470 -0
- package/dist/page/frames.d.ts +45 -0
- package/dist/page/frames.js +133 -0
- package/dist/page/generate-locator.d.ts +57 -0
- package/dist/page/generate-locator.js +136 -0
- package/dist/page/gestures.d.ts +128 -0
- package/dist/page/gestures.js +198 -0
- package/dist/page/har.d.ts +91 -0
- package/dist/page/har.js +174 -0
- package/dist/page/heap.d.ts +97 -0
- package/dist/page/heap.js +285 -0
- package/dist/page/inspect.d.ts +34 -0
- package/dist/page/inspect.js +75 -0
- package/dist/page/layout-thrash.d.ts +34 -0
- package/dist/page/layout-thrash.js +232 -0
- package/dist/page/learning.d.ts +21 -0
- package/dist/page/learning.js +84 -0
- package/dist/page/locator.d.ts +54 -0
- package/dist/page/locator.js +142 -0
- package/dist/page/memory-diff.d.ts +48 -0
- package/dist/page/memory-diff.js +105 -0
- package/dist/page/network-mask.d.ts +8 -0
- package/dist/page/network-mask.js +18 -0
- package/dist/page/network-playwright.d.ts +96 -0
- package/dist/page/network-playwright.js +353 -0
- package/dist/page/network-substrate-select.d.ts +18 -0
- package/dist/page/network-substrate-select.js +32 -0
- package/dist/page/network-substrate.d.ts +109 -0
- package/dist/page/network-substrate.js +161 -0
- package/dist/page/network-ws.d.ts +46 -0
- package/dist/page/network-ws.js +113 -0
- package/dist/page/network.d.ts +194 -0
- package/dist/page/network.js +415 -0
- package/dist/page/overflow-detect.d.ts +102 -0
- package/dist/page/overflow-detect.js +449 -0
- package/dist/page/pdf.d.ts +69 -0
- package/dist/page/pdf.js +109 -0
- package/dist/page/perf-audit-analysers.d.ts +40 -0
- package/dist/page/perf-audit-analysers.js +369 -0
- package/dist/page/perf-audit-runner.d.ts +20 -0
- package/dist/page/perf-audit-runner.js +195 -0
- package/dist/page/perf-audit-types.d.ts +41 -0
- package/dist/page/perf-audit-types.js +5 -0
- package/dist/page/perf-audit.d.ts +37 -0
- package/dist/page/perf-audit.js +377 -0
- package/dist/page/perf.d.ts +127 -0
- package/dist/page/perf.js +373 -0
- package/dist/page/plan.d.ts +192 -0
- package/dist/page/plan.js +308 -0
- package/dist/page/point_probe.d.ts +46 -0
- package/dist/page/point_probe.js +99 -0
- package/dist/page/recording.d.ts +67 -0
- package/dist/page/recording.js +172 -0
- package/dist/page/refs.d.ts +92 -0
- package/dist/page/refs.js +134 -0
- package/dist/page/regions.d.ts +23 -0
- package/dist/page/regions.js +32 -0
- package/dist/page/routes.d.ts +40 -0
- package/dist/page/routes.js +87 -0
- package/dist/page/safari-actions.d.ts +12 -0
- package/dist/page/safari-actions.js +144 -0
- package/dist/page/sample.d.ts +64 -0
- package/dist/page/sample.js +216 -0
- package/dist/page/screenshot-on.d.ts +51 -0
- package/dist/page/screenshot-on.js +150 -0
- package/dist/page/screenshot-save.d.ts +36 -0
- package/dist/page/screenshot-save.js +53 -0
- package/dist/page/screenshot-schedule.d.ts +50 -0
- package/dist/page/screenshot-schedule.js +155 -0
- package/dist/page/script-substrate.d.ts +32 -0
- package/dist/page/script-substrate.js +47 -0
- package/dist/page/seed-random.d.ts +45 -0
- package/dist/page/seed-random.js +144 -0
- package/dist/page/set-of-marks.d.ts +96 -0
- package/dist/page/set-of-marks.js +245 -0
- package/dist/page/shadow.d.ts +136 -0
- package/dist/page/shadow.js +400 -0
- package/dist/page/shortcut.d.ts +50 -0
- package/dist/page/shortcut.js +147 -0
- package/dist/page/snapshot-substrate-safari.d.ts +30 -0
- package/dist/page/snapshot-substrate-safari.js +84 -0
- package/dist/page/snapshot-substrate-select.d.ts +24 -0
- package/dist/page/snapshot-substrate-select.js +34 -0
- package/dist/page/snapshot-substrate.d.ts +58 -0
- package/dist/page/snapshot-substrate.js +135 -0
- package/dist/page/snapshot.d.ts +24 -0
- package/dist/page/snapshot.js +162 -0
- package/dist/page/solve-captcha.d.ts +76 -0
- package/dist/page/solve-captcha.js +286 -0
- package/dist/page/storage-substrate-types.d.ts +221 -0
- package/dist/page/storage-substrate-types.js +6 -0
- package/dist/page/storage-substrate.d.ts +215 -0
- package/dist/page/storage-substrate.js +280 -0
- package/dist/page/structural.d.ts +9 -0
- package/dist/page/structural.js +152 -0
- package/dist/page/substrate-bundle-safari.d.ts +8 -0
- package/dist/page/substrate-bundle-safari.js +42 -0
- package/dist/page/substrate-bundle.d.ts +6 -0
- package/dist/page/substrate-bundle.js +53 -0
- package/dist/page/text_search.d.ts +44 -0
- package/dist/page/text_search.js +90 -0
- package/dist/page/upload.d.ts +28 -0
- package/dist/page/upload.js +62 -0
- package/dist/page/verify.d.ts +63 -0
- package/dist/page/verify.js +451 -0
- package/dist/page/video.d.ts +115 -0
- package/dist/page/video.js +169 -0
- package/dist/page/visibility.d.ts +22 -0
- package/dist/page/visibility.js +94 -0
- package/dist/page/watch.d.ts +29 -0
- package/dist/page/watch.js +99 -0
- package/dist/page/workers.d.ts +126 -0
- package/dist/page/workers.js +490 -0
- package/dist/page/ws-interactive.d.ts +82 -0
- package/dist/page/ws-interactive.js +318 -0
- package/dist/plugin/cli.d.ts +45 -0
- package/dist/plugin/cli.js +496 -0
- package/dist/plugin/command-registry.d.ts +9 -0
- package/dist/plugin/command-registry.js +23 -0
- package/dist/plugin/depgraph.d.ts +37 -0
- package/dist/plugin/depgraph.js +186 -0
- package/dist/plugin/manifest.d.ts +182 -0
- package/dist/plugin/manifest.js +219 -0
- package/dist/plugin/package-manager.d.ts +22 -0
- package/dist/plugin/package-manager.js +40 -0
- package/dist/plugin/resolver.d.ts +85 -0
- package/dist/plugin/resolver.js +166 -0
- package/dist/plugin/runtime.d.ts +77 -0
- package/dist/plugin/runtime.js +402 -0
- package/dist/plugin/types.d.ts +113 -0
- package/dist/plugin/types.js +4 -0
- package/dist/policy/confirm.d.ts +76 -0
- package/dist/policy/confirm.js +162 -0
- package/dist/policy/origin.d.ts +17 -0
- package/dist/policy/origin.js +79 -0
- package/dist/sdk/client.d.ts +21 -0
- package/dist/sdk/client.js +174 -0
- package/dist/sdk/index.d.ts +32 -0
- package/dist/sdk/index.js +61 -0
- package/dist/sdk/plugin-types.d.ts +33 -0
- package/dist/sdk/plugin-types.js +22 -0
- package/dist/sdk/registry.d.ts +17 -0
- package/dist/sdk/registry.js +94 -0
- package/dist/sdk/socket-transport.d.ts +20 -0
- package/dist/sdk/socket-transport.js +90 -0
- package/dist/sdk/tool-types.d.ts +634 -0
- package/dist/sdk/tool-types.js +28 -0
- package/dist/sdk/transport-in-process.d.ts +21 -0
- package/dist/sdk/transport-in-process.js +44 -0
- package/dist/sdk/transport-registry.d.ts +19 -0
- package/dist/sdk/transport-registry.js +31 -0
- package/dist/sdk/transport-socket.d.ts +12 -0
- package/dist/sdk/transport-socket.js +77 -0
- package/dist/sdk/transport-stdio-child.d.ts +10 -0
- package/dist/sdk/transport-stdio-child.js +47 -0
- package/dist/sdk/transport.d.ts +10 -0
- package/dist/sdk/transport.js +35 -0
- package/dist/sdk/types.d.ts +176 -0
- package/dist/sdk/types.js +10 -0
- package/dist/server.d.ts +33 -0
- package/dist/server.js +327 -0
- package/dist/session/artifacts.d.ts +52 -0
- package/dist/session/artifacts.js +177 -0
- package/dist/session/byob-attach.d.ts +26 -0
- package/dist/session/byob-attach.js +187 -0
- package/dist/session/byob.d.ts +8 -0
- package/dist/session/byob.js +20 -0
- package/dist/session/cache-storage.d.ts +100 -0
- package/dist/session/cache-storage.js +166 -0
- package/dist/session/device-emu.d.ts +149 -0
- package/dist/session/device-emu.js +545 -0
- package/dist/session/device.d.ts +14 -0
- package/dist/session/device.js +44 -0
- package/dist/session/dialog.d.ts +62 -0
- package/dist/session/dialog.js +164 -0
- package/dist/session/emulation.d.ts +69 -0
- package/dist/session/emulation.js +168 -0
- package/dist/session/extensions.d.ts +113 -0
- package/dist/session/extensions.js +237 -0
- package/dist/session/fs-picker.d.ts +144 -0
- package/dist/session/fs-picker.js +666 -0
- package/dist/session/idb-storage.d.ts +86 -0
- package/dist/session/idb-storage.js +229 -0
- package/dist/session/incognito.d.ts +3 -0
- package/dist/session/incognito.js +20 -0
- package/dist/session/launch-options.d.ts +41 -0
- package/dist/session/launch-options.js +200 -0
- package/dist/session/managed.d.ts +3 -0
- package/dist/session/managed.js +16 -0
- package/dist/session/metrics.d.ts +45 -0
- package/dist/session/metrics.js +75 -0
- package/dist/session/notification.d.ts +122 -0
- package/dist/session/notification.js +426 -0
- package/dist/session/permission.d.ts +144 -0
- package/dist/session/permission.js +600 -0
- package/dist/session/playwright-post-wire.d.ts +8 -0
- package/dist/session/playwright-post-wire.js +148 -0
- package/dist/session/policy-buffer.d.ts +21 -0
- package/dist/session/policy-buffer.js +47 -0
- package/dist/session/profile-snapshot.d.ts +11 -0
- package/dist/session/profile-snapshot.js +53 -0
- package/dist/session/registry.d.ts +365 -0
- package/dist/session/registry.js +98 -0
- package/dist/session/safari-post-wire.d.ts +8 -0
- package/dist/session/safari-post-wire.js +28 -0
- package/dist/session/safari-session.d.ts +10 -0
- package/dist/session/safari-session.js +39 -0
- package/dist/session/storage.d.ts +148 -0
- package/dist/session/storage.js +350 -0
- package/dist/session/types.d.ts +113 -0
- package/dist/session/types.js +5 -0
- package/dist/session/wedge.d.ts +15 -0
- package/dist/session/wedge.js +41 -0
- package/dist/tools/action-core-tools.d.ts +13 -0
- package/dist/tools/action-core-tools.js +156 -0
- package/dist/tools/action-form-tools.d.ts +12 -0
- package/dist/tools/action-form-tools.js +179 -0
- package/dist/tools/action-gesture-tools.d.ts +9 -0
- package/dist/tools/action-gesture-tools.js +115 -0
- package/dist/tools/action-history-tools.d.ts +8 -0
- package/dist/tools/action-history-tools.js +67 -0
- package/dist/tools/action-tool.d.ts +42 -0
- package/dist/tools/action-tool.js +58 -0
- package/dist/tools/action-tools.d.ts +20 -0
- package/dist/tools/action-tools.js +28 -0
- package/dist/tools/batch-act-tools.d.ts +10 -0
- package/dist/tools/batch-act-tools.js +276 -0
- package/dist/tools/batch-human-tools.d.ts +8 -0
- package/dist/tools/batch-human-tools.js +148 -0
- package/dist/tools/canvas-tools.d.ts +40 -0
- package/dist/tools/canvas-tools.js +368 -0
- package/dist/tools/capture-report-diagnostics-tools.d.ts +7 -0
- package/dist/tools/capture-report-diagnostics-tools.js +318 -0
- package/dist/tools/capture-report-element-export-tools.d.ts +8 -0
- package/dist/tools/capture-report-element-export-tools.js +197 -0
- package/dist/tools/capture-report-export-tools.d.ts +8 -0
- package/dist/tools/capture-report-export-tools.js +246 -0
- package/dist/tools/capture-report-marks-tools.d.ts +9 -0
- package/dist/tools/capture-report-marks-tools.js +221 -0
- package/dist/tools/capture-report-upload-tools.d.ts +8 -0
- package/dist/tools/capture-report-upload-tools.js +277 -0
- package/dist/tools/config-approval-tools.d.ts +8 -0
- package/dist/tools/config-approval-tools.js +166 -0
- package/dist/tools/deep-coverage-tools.d.ts +8 -0
- package/dist/tools/deep-coverage-tools.js +325 -0
- package/dist/tools/deep-determinism-tools.d.ts +8 -0
- package/dist/tools/deep-determinism-tools.js +276 -0
- package/dist/tools/deep-perf-tools.d.ts +19 -0
- package/dist/tools/deep-perf-tools.js +324 -0
- package/dist/tools/device-emulation-tools.d.ts +9 -0
- package/dist/tools/device-emulation-tools.js +137 -0
- package/dist/tools/extensions-batch-tools.d.ts +18 -0
- package/dist/tools/extensions-batch-tools.js +24 -0
- package/dist/tools/extensions-rebuild.d.ts +22 -0
- package/dist/tools/extensions-rebuild.js +208 -0
- package/dist/tools/extensions-tools.d.ts +2 -0
- package/dist/tools/extensions-tools.js +331 -0
- package/dist/tools/forms-fill-tools.d.ts +8 -0
- package/dist/tools/forms-fill-tools.js +109 -0
- package/dist/tools/forms-plan-tools.d.ts +7 -0
- package/dist/tools/forms-plan-tools.js +159 -0
- package/dist/tools/forms-recording-mode-tools.d.ts +8 -0
- package/dist/tools/forms-recording-mode-tools.js +71 -0
- package/dist/tools/forms-recording-tools.d.ts +14 -0
- package/dist/tools/forms-recording-tools.js +22 -0
- package/dist/tools/forms-refs-tools.d.ts +8 -0
- package/dist/tools/forms-refs-tools.js +90 -0
- package/dist/tools/gesture-coord-tools.d.ts +8 -0
- package/dist/tools/gesture-coord-tools.js +168 -0
- package/dist/tools/gesture-emulation-tools.d.ts +8 -0
- package/dist/tools/gesture-emulation-tools.js +135 -0
- package/dist/tools/gesture-network-tools.d.ts +17 -0
- package/dist/tools/gesture-network-tools.js +27 -0
- package/dist/tools/gesture-route-tools.d.ts +8 -0
- package/dist/tools/gesture-route-tools.js +142 -0
- package/dist/tools/gesture-websocket-tools.d.ts +8 -0
- package/dist/tools/gesture-websocket-tools.js +122 -0
- package/dist/tools/gesture-worker-tools.d.ts +9 -0
- package/dist/tools/gesture-worker-tools.js +200 -0
- package/dist/tools/host-build.d.ts +76 -0
- package/dist/tools/host-build.js +516 -0
- package/dist/tools/host.d.ts +287 -0
- package/dist/tools/host.js +1 -0
- package/dist/tools/input-tools.d.ts +10 -0
- package/dist/tools/input-tools.js +176 -0
- package/dist/tools/live-emulation-tools.d.ts +9 -0
- package/dist/tools/live-emulation-tools.js +353 -0
- package/dist/tools/plugin-runtime.d.ts +36 -0
- package/dist/tools/plugin-runtime.js +274 -0
- package/dist/tools/read-observe-buffer-tools.d.ts +9 -0
- package/dist/tools/read-observe-buffer-tools.js +385 -0
- package/dist/tools/read-observe-capture-tools.d.ts +12 -0
- package/dist/tools/read-observe-capture-tools.js +376 -0
- package/dist/tools/read-observe-dom-tools.d.ts +8 -0
- package/dist/tools/read-observe-dom-tools.js +308 -0
- package/dist/tools/read-observe-extract-tools.d.ts +8 -0
- package/dist/tools/read-observe-extract-tools.js +232 -0
- package/dist/tools/read-observe-verify-tools.d.ts +8 -0
- package/dist/tools/read-observe-verify-tools.js +316 -0
- package/dist/tools/schemas.d.ts +29 -0
- package/dist/tools/schemas.js +58 -0
- package/dist/tools/secrets-captcha-tools.d.ts +9 -0
- package/dist/tools/secrets-captcha-tools.js +231 -0
- package/dist/tools/session-dialog-permission-tools.d.ts +9 -0
- package/dist/tools/session-dialog-permission-tools.js +287 -0
- package/dist/tools/session-lifecycle-tools.d.ts +8 -0
- package/dist/tools/session-lifecycle-tools.js +314 -0
- package/dist/tools/session-notification-device-tools.d.ts +9 -0
- package/dist/tools/session-notification-device-tools.js +156 -0
- package/dist/tools/session-policy-tools.d.ts +16 -0
- package/dist/tools/session-policy-tools.js +22 -0
- package/dist/tools/session-registry.d.ts +28 -0
- package/dist/tools/session-registry.js +427 -0
- package/dist/tools/storage-artifact-har-video-tools.d.ts +8 -0
- package/dist/tools/storage-artifact-har-video-tools.js +311 -0
- package/dist/tools/storage-cache-idb-tools.d.ts +8 -0
- package/dist/tools/storage-cache-idb-tools.js +347 -0
- package/dist/tools/storage-state-cookies-tools.d.ts +8 -0
- package/dist/tools/storage-state-cookies-tools.js +223 -0
- package/dist/tools/storage-tools.d.ts +17 -0
- package/dist/tools/storage-tools.js +25 -0
- package/dist/tools/storage-web-auth-tools.d.ts +10 -0
- package/dist/tools/storage-web-auth-tools.js +230 -0
- package/dist/tools/tool-metadata.d.ts +8 -0
- package/dist/tools/tool-metadata.js +185 -0
- package/dist/util/batch.d.ts +83 -0
- package/dist/util/batch.js +191 -0
- package/dist/util/capabilities.d.ts +504 -0
- package/dist/util/capabilities.js +254 -0
- package/dist/util/config-store.d.ts +103 -0
- package/dist/util/config-store.js +206 -0
- package/dist/util/config.d.ts +11 -0
- package/dist/util/config.js +28 -0
- package/dist/util/credentials.d.ts +136 -0
- package/dist/util/credentials.js +622 -0
- package/dist/util/deadline.d.ts +22 -0
- package/dist/util/deadline.js +62 -0
- package/dist/util/diagnostics.d.ts +161 -0
- package/dist/util/diagnostics.js +579 -0
- package/dist/util/egress-sanitiser.d.ts +29 -0
- package/dist/util/egress-sanitiser.js +52 -0
- package/dist/util/failure.d.ts +8 -0
- package/dist/util/failure.js +50 -0
- package/dist/util/flake-check.d.ts +109 -0
- package/dist/util/flake-check.js +342 -0
- package/dist/util/invariant.d.ts +25 -0
- package/dist/util/invariant.js +66 -0
- package/dist/util/logging.d.ts +6 -0
- package/dist/util/logging.js +12 -0
- package/dist/util/predicates.d.ts +62 -0
- package/dist/util/predicates.js +340 -0
- package/dist/util/secrets.d.ts +104 -0
- package/dist/util/secrets.js +219 -0
- package/dist/util/tokens.d.ts +6 -0
- package/dist/util/tokens.js +24 -0
- package/dist/util/url-sanitizer.d.ts +19 -0
- package/dist/util/url-sanitizer.js +70 -0
- package/dist/util/version.d.ts +2 -0
- package/dist/util/version.js +21 -0
- package/dist/util/workspace.d.ts +7 -0
- package/dist/util/workspace.js +22 -0
- package/package.json +120 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** One resource the element subtree references. Same shape as
|
|
2
|
+
* `archive.ts`'s `DiscoveredResource`. */
|
|
3
|
+
export interface DiscoveredResource {
|
|
4
|
+
url: string;
|
|
5
|
+
kind: "image" | "font" | "script" | "stylesheet" | "media" | "other";
|
|
6
|
+
rawRef: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SubtreeDiscovery {
|
|
9
|
+
/** outerHTML of the resolved element subtree. */
|
|
10
|
+
html: string;
|
|
11
|
+
/** Concatenated CSS — page-level stylesheets + inline <style> contents. */
|
|
12
|
+
css: string;
|
|
13
|
+
/** Stylesheets unreadable due to cross-origin `cssRules` restrictions. */
|
|
14
|
+
unreadableStylesheets: number;
|
|
15
|
+
resources: DiscoveredResource[];
|
|
16
|
+
}
|
|
17
|
+
/** Thin Locator-shaped adapter for `locator.evaluate(SUBTREE_DISCOVERY_FN)`. */
|
|
18
|
+
export interface ElementExportLocator {
|
|
19
|
+
count(): Promise<number>;
|
|
20
|
+
evaluate<T>(fn: (element: Element) => T | Promise<T>): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
/** Thin Page-shaped adapter — used for `page.evaluate(buildFetchScript)`. */
|
|
23
|
+
export interface ElementExportPage {
|
|
24
|
+
evaluate(expression: string): Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** Page-side discovery function. Receives `el` as the element handle the
|
|
27
|
+
* Playwright locator resolved to. Passed as a real function literal (NOT
|
|
28
|
+
* a stringified expression) — `locator.evaluate(stringExpr)` evaluates
|
|
29
|
+
* the string in page context but returns the function value uncalled,
|
|
30
|
+
* which CDP can't serialize → undefined. The function literal is
|
|
31
|
+
* serialized by Playwright and invoked in-page with the element.
|
|
32
|
+
*
|
|
33
|
+
* Body uses only DOM types the page context provides (Element + standard
|
|
34
|
+
* globals); no TS-only constructs survive serialization. */
|
|
35
|
+
export declare const SUBTREE_DISCOVERY_FN: (el: Element) => SubtreeDiscovery;
|
|
36
|
+
/** Build the page-side fetch script — identical posture to
|
|
37
|
+
* `archive.ts::buildFetchScript`. We import it here rather than the
|
|
38
|
+
* archive's version so future tweaks (e.g. CSP heuristic) can diverge
|
|
39
|
+
* per consumer. */
|
|
40
|
+
export declare function buildFetchScript(url: string): string;
|
|
41
|
+
export interface FetchedResource {
|
|
42
|
+
ok: boolean;
|
|
43
|
+
base64?: string;
|
|
44
|
+
contentType?: string;
|
|
45
|
+
bytes?: number;
|
|
46
|
+
status?: number;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function assetFilename(url: string, kind: DiscoveredResource["kind"], contentType: string): string;
|
|
50
|
+
export declare function subdirForKind(kind: DiscoveredResource["kind"]): string;
|
|
51
|
+
export declare function mimeFromKind(kind: DiscoveredResource["kind"]): string;
|
|
52
|
+
/** Rewrite raw HTML — replace every recorded `rawRef` with the relative
|
|
53
|
+
* asset path the file has been written to. Same logic as
|
|
54
|
+
* `archive.ts::rewriteHtml`. */
|
|
55
|
+
export declare function rewriteHtml(html: string, replacements: Array<{
|
|
56
|
+
rawRef: string;
|
|
57
|
+
replacement: string;
|
|
58
|
+
}>): string;
|
|
59
|
+
export declare function directorySize(dir: string): number;
|
|
60
|
+
/** Compose the standalone HTML document wrapper around an element snippet
|
|
61
|
+
* + its CSS. The wrapper is minimal so the snippet renders the way it
|
|
62
|
+
* did on the source page (UTF-8, default base, the captured stylesheet
|
|
63
|
+
* text). */
|
|
64
|
+
export declare function wrapStandalone(elementHtml: string, css: string, baseUri: string): string;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// Element-export subtree discovery + asset emission helpers — the page-side
|
|
2
|
+
// `SUBTREE_DISCOVERY_FN` (outerHTML + CSS + linked resources), the per-URL fetch
|
|
3
|
+
// script, and the filename/mime/ext/subdir naming + HTML-rewrite + standalone-
|
|
4
|
+
// wrap utilities. Split out of element-export.ts so the orchestrator stays under
|
|
5
|
+
// the size budget; behavior-identical.
|
|
6
|
+
import { extname, sep } from "node:path";
|
|
7
|
+
import { statSync, readdirSync } from "node:fs";
|
|
8
|
+
/** Page-side discovery function. Receives `el` as the element handle the
|
|
9
|
+
* Playwright locator resolved to. Passed as a real function literal (NOT
|
|
10
|
+
* a stringified expression) — `locator.evaluate(stringExpr)` evaluates
|
|
11
|
+
* the string in page context but returns the function value uncalled,
|
|
12
|
+
* which CDP can't serialize → undefined. The function literal is
|
|
13
|
+
* serialized by Playwright and invoked in-page with the element.
|
|
14
|
+
*
|
|
15
|
+
* Body uses only DOM types the page context provides (Element + standard
|
|
16
|
+
* globals); no TS-only constructs survive serialization. */
|
|
17
|
+
export const SUBTREE_DISCOVERY_FN = (el) => {
|
|
18
|
+
function abs(u) {
|
|
19
|
+
try {
|
|
20
|
+
return new URL(u, document.baseURI).href;
|
|
21
|
+
}
|
|
22
|
+
catch (_) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function bgUrls(node) {
|
|
27
|
+
const out = [];
|
|
28
|
+
try {
|
|
29
|
+
const cs = getComputedStyle(node);
|
|
30
|
+
const bg = cs && cs.backgroundImage;
|
|
31
|
+
if (bg && bg !== "none") {
|
|
32
|
+
const re = /url\((['"]?)([^'")]+)\1\)/g;
|
|
33
|
+
let m;
|
|
34
|
+
while ((m = re.exec(bg)) !== null)
|
|
35
|
+
out.push(m[2]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// best-effort: getComputedStyle may throw on detached / cross-origin nodes
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
const resources = [];
|
|
44
|
+
const seen = Object.create(null);
|
|
45
|
+
function push(raw, kind) {
|
|
46
|
+
if (!raw)
|
|
47
|
+
return;
|
|
48
|
+
const a = abs(raw);
|
|
49
|
+
if (!a)
|
|
50
|
+
return;
|
|
51
|
+
if (!/^https?:|^ftp:|^file:/i.test(a))
|
|
52
|
+
return;
|
|
53
|
+
const key = a + "|" + kind;
|
|
54
|
+
if (seen[key])
|
|
55
|
+
return;
|
|
56
|
+
seen[key] = true;
|
|
57
|
+
resources.push({ url: a, kind, rawRef: raw });
|
|
58
|
+
}
|
|
59
|
+
function srcKind(tag) {
|
|
60
|
+
if (tag === "img" || tag === "source")
|
|
61
|
+
return "image";
|
|
62
|
+
if (tag === "script")
|
|
63
|
+
return "script";
|
|
64
|
+
if (tag === "video" || tag === "audio" || tag === "track")
|
|
65
|
+
return "media";
|
|
66
|
+
return "other";
|
|
67
|
+
}
|
|
68
|
+
function linkRelKind(rel, asAttr) {
|
|
69
|
+
if (rel.indexOf("stylesheet") !== -1)
|
|
70
|
+
return "stylesheet";
|
|
71
|
+
if (rel.indexOf("icon") !== -1)
|
|
72
|
+
return "image";
|
|
73
|
+
if (asAttr === "font")
|
|
74
|
+
return "font";
|
|
75
|
+
if (asAttr === "script")
|
|
76
|
+
return "script";
|
|
77
|
+
if (asAttr === "image")
|
|
78
|
+
return "image";
|
|
79
|
+
if (asAttr === "style")
|
|
80
|
+
return "stylesheet";
|
|
81
|
+
return "other";
|
|
82
|
+
}
|
|
83
|
+
function pushHref(n, tag, href) {
|
|
84
|
+
if (tag === "link") {
|
|
85
|
+
const rel = (n.getAttribute("rel") || "").toLowerCase();
|
|
86
|
+
const asAttr = (n.getAttribute("as") || "").toLowerCase();
|
|
87
|
+
push(href, linkRelKind(rel, asAttr));
|
|
88
|
+
}
|
|
89
|
+
else if (tag === "image" || tag === "use") {
|
|
90
|
+
push(href, "image");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function scanNode(n) {
|
|
94
|
+
if (n.nodeType !== 1)
|
|
95
|
+
return;
|
|
96
|
+
const tag = (n.tagName || "").toLowerCase();
|
|
97
|
+
const s = n.getAttribute("src");
|
|
98
|
+
if (s)
|
|
99
|
+
push(s, srcKind(tag));
|
|
100
|
+
const href = n.getAttribute("href");
|
|
101
|
+
if (href && (tag === "link" || tag === "a" || tag === "use" || tag === "image")) {
|
|
102
|
+
pushHref(n, tag, href);
|
|
103
|
+
}
|
|
104
|
+
const ss = n.getAttribute("srcset");
|
|
105
|
+
if (ss) {
|
|
106
|
+
const first = ss.split(",")[0].trim().split(/\s+/)[0];
|
|
107
|
+
if (first)
|
|
108
|
+
push(first, "image");
|
|
109
|
+
}
|
|
110
|
+
const poster = n.getAttribute("poster");
|
|
111
|
+
if (poster)
|
|
112
|
+
push(poster, "image");
|
|
113
|
+
for (const b of bgUrls(n))
|
|
114
|
+
push(b, "image");
|
|
115
|
+
}
|
|
116
|
+
function scan(root) {
|
|
117
|
+
const nodes = [root, ...Array.from(root.querySelectorAll("*"))];
|
|
118
|
+
for (let i = 0; i < nodes.length && i < 5000; i++)
|
|
119
|
+
scanNode(nodes[i]);
|
|
120
|
+
}
|
|
121
|
+
scan(el);
|
|
122
|
+
const cssParts = [];
|
|
123
|
+
let unreadable = 0;
|
|
124
|
+
try {
|
|
125
|
+
const sheets = document.styleSheets;
|
|
126
|
+
for (let si = 0; si < sheets.length; si++) {
|
|
127
|
+
try {
|
|
128
|
+
const rules = sheets[si].cssRules;
|
|
129
|
+
if (!rules) {
|
|
130
|
+
unreadable++;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
let part = "";
|
|
134
|
+
for (let ri = 0; ri < rules.length; ri++) {
|
|
135
|
+
part += rules[ri].cssText + "\n";
|
|
136
|
+
}
|
|
137
|
+
cssParts.push(part);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
unreadable++;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// best-effort: document.styleSheets enumeration can throw on hostile docs
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
html: el.outerHTML || "",
|
|
149
|
+
css: cssParts.join("\n"),
|
|
150
|
+
unreadableStylesheets: unreadable,
|
|
151
|
+
resources,
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/** Build the page-side fetch script — identical posture to
|
|
155
|
+
* `archive.ts::buildFetchScript`. We import it here rather than the
|
|
156
|
+
* archive's version so future tweaks (e.g. CSP heuristic) can diverge
|
|
157
|
+
* per consumer. */
|
|
158
|
+
export function buildFetchScript(url) {
|
|
159
|
+
const literal = JSON.stringify(url);
|
|
160
|
+
return `(async () => {
|
|
161
|
+
try {
|
|
162
|
+
var r = await fetch(${literal}, { credentials: 'include', cache: 'no-store' });
|
|
163
|
+
if (!r.ok) return { ok: false, status: r.status, contentType: r.headers.get('content-type') || '' };
|
|
164
|
+
var ct = r.headers.get('content-type') || '';
|
|
165
|
+
var buf = await r.arrayBuffer();
|
|
166
|
+
var bytes = new Uint8Array(buf);
|
|
167
|
+
var CHUNK = 0x8000, parts = [];
|
|
168
|
+
for (var i = 0; i < bytes.length; i += CHUNK) {
|
|
169
|
+
parts.push(String.fromCharCode.apply(null, bytes.subarray(i, i + CHUNK)));
|
|
170
|
+
}
|
|
171
|
+
return { ok: true, base64: btoa(parts.join('')), contentType: ct, bytes: bytes.length };
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return { ok: false, error: (e && e.message) ? String(e.message) : String(e) };
|
|
174
|
+
}
|
|
175
|
+
})()`;
|
|
176
|
+
}
|
|
177
|
+
export function assetFilename(url, kind, contentType) {
|
|
178
|
+
let stem;
|
|
179
|
+
let urlExt = "";
|
|
180
|
+
try {
|
|
181
|
+
const u = new URL(url);
|
|
182
|
+
const last = u.pathname.split("/").filter(Boolean).pop() ?? "asset";
|
|
183
|
+
urlExt = extname(last);
|
|
184
|
+
stem = last.replace(/[^A-Za-z0-9._-]/g, "_") || "asset";
|
|
185
|
+
if (urlExt)
|
|
186
|
+
stem = stem.slice(0, -urlExt.length);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
stem = "asset";
|
|
190
|
+
}
|
|
191
|
+
const hash = simpleHash(url);
|
|
192
|
+
const ext = urlExt || guessExtFromContentType(contentType) || guessExtFromKind(kind);
|
|
193
|
+
return `${stem}-${hash}${ext}`;
|
|
194
|
+
}
|
|
195
|
+
function simpleHash(s) {
|
|
196
|
+
let h = 0x811c9dc5;
|
|
197
|
+
for (let i = 0; i < s.length; i++) {
|
|
198
|
+
h = (h ^ s.charCodeAt(i)) >>> 0;
|
|
199
|
+
h = (h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24))) >>> 0;
|
|
200
|
+
}
|
|
201
|
+
return h.toString(16).padStart(8, "0");
|
|
202
|
+
}
|
|
203
|
+
function guessExtFromContentType(ct) {
|
|
204
|
+
const c = ct.split(";")[0].trim().toLowerCase();
|
|
205
|
+
const map = {
|
|
206
|
+
"text/html": ".html",
|
|
207
|
+
"text/css": ".css",
|
|
208
|
+
"text/javascript": ".js",
|
|
209
|
+
"application/javascript": ".js",
|
|
210
|
+
"application/json": ".json",
|
|
211
|
+
"image/png": ".png",
|
|
212
|
+
"image/jpeg": ".jpg",
|
|
213
|
+
"image/gif": ".gif",
|
|
214
|
+
"image/svg+xml": ".svg",
|
|
215
|
+
"image/webp": ".webp",
|
|
216
|
+
"image/x-icon": ".ico",
|
|
217
|
+
"font/woff": ".woff",
|
|
218
|
+
"font/woff2": ".woff2",
|
|
219
|
+
"font/ttf": ".ttf",
|
|
220
|
+
"font/otf": ".otf",
|
|
221
|
+
"application/font-woff": ".woff",
|
|
222
|
+
"application/font-woff2": ".woff2",
|
|
223
|
+
"video/mp4": ".mp4",
|
|
224
|
+
"audio/mpeg": ".mp3",
|
|
225
|
+
};
|
|
226
|
+
return map[c] ?? "";
|
|
227
|
+
}
|
|
228
|
+
function guessExtFromKind(kind) {
|
|
229
|
+
switch (kind) {
|
|
230
|
+
case "image":
|
|
231
|
+
return ".bin";
|
|
232
|
+
case "font":
|
|
233
|
+
return ".font";
|
|
234
|
+
case "script":
|
|
235
|
+
return ".js";
|
|
236
|
+
case "stylesheet":
|
|
237
|
+
return ".css";
|
|
238
|
+
case "media":
|
|
239
|
+
return ".media";
|
|
240
|
+
default:
|
|
241
|
+
return ".bin";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export function subdirForKind(kind) {
|
|
245
|
+
switch (kind) {
|
|
246
|
+
case "image":
|
|
247
|
+
return "images";
|
|
248
|
+
case "font":
|
|
249
|
+
return "fonts";
|
|
250
|
+
case "script":
|
|
251
|
+
return "scripts";
|
|
252
|
+
case "stylesheet":
|
|
253
|
+
return "styles";
|
|
254
|
+
case "media":
|
|
255
|
+
return "media";
|
|
256
|
+
default:
|
|
257
|
+
return "other";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export function mimeFromKind(kind) {
|
|
261
|
+
switch (kind) {
|
|
262
|
+
case "image":
|
|
263
|
+
return "image/png";
|
|
264
|
+
case "font":
|
|
265
|
+
return "font/woff2";
|
|
266
|
+
case "script":
|
|
267
|
+
return "application/javascript";
|
|
268
|
+
case "stylesheet":
|
|
269
|
+
return "text/css";
|
|
270
|
+
case "media":
|
|
271
|
+
return "video/mp4";
|
|
272
|
+
default:
|
|
273
|
+
return "application/octet-stream";
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** Rewrite raw HTML — replace every recorded `rawRef` with the relative
|
|
277
|
+
* asset path the file has been written to. Same logic as
|
|
278
|
+
* `archive.ts::rewriteHtml`. */
|
|
279
|
+
export function rewriteHtml(html, replacements) {
|
|
280
|
+
const sorted = [...replacements].sort((a, b) => b.rawRef.length - a.rawRef.length);
|
|
281
|
+
let out = html;
|
|
282
|
+
for (const { rawRef, replacement } of sorted) {
|
|
283
|
+
if (!rawRef)
|
|
284
|
+
continue;
|
|
285
|
+
const quoted = [`"${rawRef}"`, `'${rawRef}'`];
|
|
286
|
+
for (const q of quoted) {
|
|
287
|
+
const replWith = q[0] + replacement + q[0];
|
|
288
|
+
out = out.split(q).join(replWith);
|
|
289
|
+
}
|
|
290
|
+
if (rawRef.length >= 4)
|
|
291
|
+
out = out.split(rawRef).join(replacement);
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
295
|
+
export function directorySize(dir) {
|
|
296
|
+
let total = 0;
|
|
297
|
+
const walk = (d) => {
|
|
298
|
+
for (const entry of readdirSync(d, { withFileTypes: true })) {
|
|
299
|
+
const p = d + sep + entry.name;
|
|
300
|
+
if (entry.isDirectory())
|
|
301
|
+
walk(p);
|
|
302
|
+
else if (entry.isFile()) {
|
|
303
|
+
try {
|
|
304
|
+
total += statSync(p).size;
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
/* best-effort */
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
walk(dir);
|
|
313
|
+
return total;
|
|
314
|
+
}
|
|
315
|
+
/** Compose the standalone HTML document wrapper around an element snippet
|
|
316
|
+
* + its CSS. The wrapper is minimal so the snippet renders the way it
|
|
317
|
+
* did on the source page (UTF-8, default base, the captured stylesheet
|
|
318
|
+
* text). */
|
|
319
|
+
export function wrapStandalone(elementHtml, css, baseUri) {
|
|
320
|
+
// Embedding the CSS inline rather than as an external file matches the
|
|
321
|
+
// "self-contained" promise. `baseUri` gives the rendered snippet a sane
|
|
322
|
+
// base for any reference we *didn't* manage to rewrite (left as a remote
|
|
323
|
+
// URL — the browser will follow it).
|
|
324
|
+
const safeBase = baseUri ? `<base href="${escapeAttr(baseUri)}">` : "";
|
|
325
|
+
return `<!doctype html>
|
|
326
|
+
<html>
|
|
327
|
+
<head>
|
|
328
|
+
<meta charset="utf-8">
|
|
329
|
+
${safeBase}
|
|
330
|
+
<style>
|
|
331
|
+
${css}
|
|
332
|
+
</style>
|
|
333
|
+
</head>
|
|
334
|
+
<body>
|
|
335
|
+
${elementHtml}
|
|
336
|
+
</body>
|
|
337
|
+
</html>
|
|
338
|
+
`;
|
|
339
|
+
}
|
|
340
|
+
function escapeAttr(s) {
|
|
341
|
+
return s
|
|
342
|
+
.replace(/&/g, "&")
|
|
343
|
+
.replace(/"/g, """)
|
|
344
|
+
.replace(/</g, "<")
|
|
345
|
+
.replace(/>/g, ">");
|
|
346
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { RefRegistry } from "./refs.js";
|
|
3
|
+
import { type ElementExportLocator, type ElementExportPage } from "./element-export-discovery.js";
|
|
4
|
+
export type { DiscoveredResource, SubtreeDiscovery, ElementExportLocator, ElementExportPage, } from "./element-export-discovery.js";
|
|
5
|
+
/** Export format — mirrors `ArchiveFormat`. */
|
|
6
|
+
export type ElementExportFormat = "directory" | "single-file";
|
|
7
|
+
export interface ElementExportArgs {
|
|
8
|
+
/** Ref minted by a prior `snapshot()` / `find()` call. */
|
|
9
|
+
ref: string;
|
|
10
|
+
/** Format. Default `"directory"`. */
|
|
11
|
+
format?: ElementExportFormat;
|
|
12
|
+
/** Workspace-rooted output target. For `directory` format it's a
|
|
13
|
+
* directory path; for `single-file` it's a `.html` file. When omitted,
|
|
14
|
+
* defaults to `elements/<sessionId>-<ISO>-<ref>/` (directory) or
|
|
15
|
+
* `elements/<sessionId>-<ISO>-<ref>.html` (single-file). */
|
|
16
|
+
intoDir?: string;
|
|
17
|
+
/** Total export size cap (MB). Default 50 (smaller than `page_archive`'s
|
|
18
|
+
* 200 — an element snippet is meant to be a slice, not a meal). */
|
|
19
|
+
maxSizeMb?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ElementExportResult {
|
|
22
|
+
ok: true;
|
|
23
|
+
format: ElementExportFormat;
|
|
24
|
+
/** The ref that was exported (echoed for audit). */
|
|
25
|
+
ref: string;
|
|
26
|
+
/** Absolute, workspace-rooted output path (directory or file). */
|
|
27
|
+
path: string;
|
|
28
|
+
/** Total export size on disk, in bytes. */
|
|
29
|
+
sizeBytes: number;
|
|
30
|
+
/** Resources successfully fetched + included. */
|
|
31
|
+
resourceCount: number;
|
|
32
|
+
/** Resources skipped — drop reasons match `page_archive`. */
|
|
33
|
+
droppedCount: number;
|
|
34
|
+
/** Non-fatal advisories. Always carries the secrets-masking caveat. */
|
|
35
|
+
warnings: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Default output target when `intoDir` is omitted. Workspace-relative,
|
|
38
|
+
* namespaced under `elements/<sessionId>-<ISO>-<ref>` to match the
|
|
39
|
+
* archive subdir-per-artefact convention. */
|
|
40
|
+
export declare function defaultElementExportPath(sessionId: string, ref: string, format: ElementExportFormat): string;
|
|
41
|
+
export declare function elementExport(page: ElementExportPage, locator: ElementExportLocator, workspaceRoot: string, sessionId: string, args: ElementExportArgs): Promise<ElementExportResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Server-facing helper: resolve a ref through the registry, then call
|
|
44
|
+
* `elementExport`. Lives here so the server.ts call site is a one-liner.
|
|
45
|
+
*/
|
|
46
|
+
export declare function elementExportFromRef(page: Page, refs: RefRegistry, workspaceRoot: string, sessionId: string, args: ElementExportArgs): Promise<ElementExportResult>;
|