@pixeleye/puppeteer
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,59 @@ | ||
var n=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});import{loadConfig as l}from"@pixeleye/cli-config";import{snapshot as m}from"@pixeleye/cli-booth";async function v(r,e){if(!r)throw new Error("No Puppeteer page object provided");if(!e.name)throw new Error("No name provided");let s=await l(),i={endpoint:`http://localhost:${process.env.PIXELEYE_BOOTH_PORT}`},c=s.css||e.css?`${s.css??""} | ||
${e.css??""}`:void 0;await r.addScriptTag({path:n.resolve("rrweb-snapshot/dist/rrweb-snapshot.min.js")});let o=await r.evaluate(()=>rrwebSnapshot.snapshot(document));if(!o)throw new Error("No DOM snapshot available",o);let p={devices:e.devices??s.devices??[],name:e.name,variant:e.variant,serializedDom:o,fullPage:e.fullPage,selector:e.selector,maskSelectors:e.maskSelectors,maskColor:e.maskColor,css:c},a=await m(i,p).catch(t=>{throw console.log("Error uploading snapshot",t),t});if(a.status<200||a.status>=300){let t=await a.json();throw new Error("Error uploading snapshot, err: "+JSON.stringify(t))}}export{v as pixeleyeSnapshot}; | ||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] | ||
}) : x)(function(x) { | ||
if (typeof require !== "undefined") | ||
return require.apply(this, arguments); | ||
throw Error('Dynamic require of "' + x + '" is not supported'); | ||
}); | ||
// src/snapshot.ts | ||
import { loadConfig } from "@pixeleye/cli-config"; | ||
import { | ||
snapshot | ||
} from "@pixeleye/cli-booth"; | ||
async function pixeleyeSnapshot(page, options) { | ||
if (!page) { | ||
throw new Error("No Puppeteer page object provided"); | ||
} | ||
if (!options.name) { | ||
throw new Error("No name provided"); | ||
} | ||
const config = await loadConfig(); | ||
const opts = { | ||
endpoint: `http://localhost:${// eslint-disable-next-line turbo/no-undeclared-env-vars | ||
process.env.PIXELEYE_BOOTH_PORT}` | ||
}; | ||
const css = config.css || options.css ? `${config.css ?? ""} | ||
${options.css ?? ""}` : void 0; | ||
await page.addScriptTag({ | ||
path: __require.resolve("rrweb-snapshot/dist/rrweb-snapshot.min.js") | ||
}); | ||
const domSnapshot = await page.evaluate(() => { | ||
return rrwebSnapshot.snapshot(document); | ||
}); | ||
if (!domSnapshot) { | ||
throw new Error("No DOM snapshot available", domSnapshot); | ||
} | ||
const snap = { | ||
devices: options.devices ?? config.devices ?? [], | ||
name: options.name, | ||
variant: options.variant, | ||
serializedDom: domSnapshot, | ||
fullPage: options.fullPage, | ||
selector: options.selector, | ||
maskSelectors: options.maskSelectors, | ||
maskColor: options.maskColor, | ||
css | ||
}; | ||
const res = await snapshot(opts, snap).catch((err) => { | ||
console.log("Error uploading snapshot", err); | ||
throw err; | ||
}); | ||
if (res.status < 200 || res.status >= 300) { | ||
const data = await res.json(); | ||
throw new Error("Error uploading snapshot, err: " + JSON.stringify(data)); | ||
} | ||
} | ||
export { | ||
pixeleyeSnapshot | ||
}; |
{ | ||
"name": "@pixeleye/puppeteer", | ||
"private": false, | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"license": "AGPL-3.0", | ||
@@ -27,3 +27,3 @@ "exports": { | ||
"undici": "^6.6.2", | ||
"@pixeleye/cli-devices": "0.4.0" | ||
"@pixeleye/cli-devices": "0.4.1" | ||
}, | ||
@@ -39,7 +39,7 @@ "devDependencies": { | ||
"vitest": "^1.3.1", | ||
"@pixeleye/cli-booth": "0.4.0", | ||
"@pixeleye/cli-config": "0.4.0", | ||
"@pixeleye/cli-booth": "0.4.1", | ||
"@pixeleye/cli-config": "0.4.1", | ||
"@pixeleye/esbuild": "0.0.0", | ||
"@pixeleye/eslint-config": "0.0.0", | ||
"@pixeleye/tsconfig": "0.0.0" | ||
"@pixeleye/tsconfig": "0.0.0", | ||
"@pixeleye/eslint-config": "0.0.0" | ||
}, | ||
@@ -46,0 +46,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
42470
159
2
+ Added@pixeleye/cli-devices@0.4.1(transitive)
- Removed@pixeleye/cli-devices@0.4.0(transitive)
Updated@pixeleye/cli-devices@0.4.1