@percy/core
Advanced tools
Comparing version 1.27.5-alpha.0 to 1.27.5-beta.0
@@ -6,3 +6,3 @@ import fs from 'fs'; | ||
import { normalize } from '@percy/config/utils'; | ||
import { getPackageJSON, Server, percyAutomateRequestHandler } from './utils.js'; | ||
import { getPackageJSON, Server, percyAutomateRequestHandler, percyBuildEventHandler } from './utils.js'; | ||
import WebdriverUtils from '@percy/webdriver-utils'; | ||
@@ -148,2 +148,11 @@ // need require.resolve until import.meta.resolve can be transpiled | ||
}) | ||
// Recieves events from sdk's. | ||
.route('post', '/percy/events', async (req, res) => { | ||
var _percy$build2; | ||
const body = percyBuildEventHandler(req, pkg.version); | ||
await percy.client.sendBuildEvents((_percy$build2 = percy.build) === null || _percy$build2 === void 0 ? void 0 : _percy$build2.id, body); | ||
res.json(200, { | ||
success: true | ||
}); | ||
}) | ||
// stops percy at the end of the current event loop | ||
@@ -150,0 +159,0 @@ .route('/percy/stop', (req, res) => { |
@@ -50,5 +50,11 @@ // Common config options used in Percy commands | ||
}, | ||
enableLayout: { | ||
type: 'boolean' | ||
}, | ||
domTransformation: { | ||
type: 'string' | ||
}, | ||
reshuffleInvalidTags: { | ||
type: 'boolean' | ||
}, | ||
scope: { | ||
@@ -284,2 +290,8 @@ type: 'string' | ||
}, | ||
enableLayout: { | ||
$ref: '/config/snapshot#/properties/enableLayout' | ||
}, | ||
reshuffleInvalidTags: { | ||
$ref: '/config/snapshot#/properties/reshuffleInvalidTags' | ||
}, | ||
discovery: { | ||
@@ -529,2 +541,8 @@ type: 'object', | ||
} | ||
}, | ||
hints: { | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
} | ||
} | ||
@@ -531,0 +549,0 @@ } |
@@ -29,2 +29,5 @@ import logger from '@percy/logger'; | ||
debugProp(snapshot, 'disableShadowDOM'); | ||
debugProp(snapshot, 'enableLayout'); | ||
debugProp(snapshot, 'domTransformation'); | ||
debugProp(snapshot, 'reshuffleInvalidTags'); | ||
debugProp(snapshot, 'deviceScaleFactor'); | ||
@@ -105,2 +108,3 @@ debugProp(snapshot, 'waitForTimeout'); | ||
var _resources; | ||
let log = logger('core:snapshot'); | ||
resources = [...(((_resources = resources) === null || _resources === void 0 ? void 0 : _resources.values()) ?? [])]; | ||
@@ -124,2 +128,7 @@ | ||
if (snapshot.percyCSS) { | ||
// check @percy/dom/serialize-dom.js | ||
let domSnapshotHints = (domSnapshot === null || domSnapshot === void 0 ? void 0 : domSnapshot.hints) ?? []; | ||
if (domSnapshotHints.includes('DOM elements found outside </body>')) { | ||
log.warn('DOM elements found outside </body>, percyCSS might not work'); | ||
} | ||
let css = createPercyCSSResource(root.url, snapshot.percyCSS); | ||
@@ -126,0 +135,0 @@ resources.push(css); |
@@ -149,3 +149,4 @@ import fs from 'fs'; | ||
disableShadowDOM, | ||
domTransformation | ||
domTransformation, | ||
reshuffleInvalidTags | ||
} = snapshot; | ||
@@ -195,3 +196,4 @@ this.log.debug(`Taking snapshot: ${name}${width ? ` @${width}px` : ''}`, this.meta); | ||
disableShadowDOM, | ||
domTransformation | ||
domTransformation, | ||
reshuffleInvalidTags | ||
}); | ||
@@ -198,0 +200,0 @@ return { |
@@ -58,2 +58,36 @@ import EventEmitter from 'events'; | ||
// Returns the body for sendEvent structure | ||
export function percyBuildEventHandler(req, cliVersion) { | ||
if (Array.isArray(req.body)) { | ||
return req.body.map(item => processSendEventData(item, cliVersion)); | ||
} else { | ||
// Treat the input as an object and perform instructions | ||
return processSendEventData(req.body, cliVersion); | ||
} | ||
} | ||
// Process sendEvent object | ||
function processSendEventData(input, cliVersion) { | ||
// Add Properties here to send to eventData | ||
const allowedEventProperties = ['message', 'cliVersion', 'clientInfo', 'errorKind', 'extra']; | ||
const extractedData = {}; | ||
for (const property of allowedEventProperties) { | ||
if (Object.prototype.hasOwnProperty.call(input, property)) { | ||
extractedData[property] = input[property]; | ||
} | ||
} | ||
if (extractedData.clientInfo) { | ||
const [client, clientVersion] = extractedData.clientInfo.split('/'); | ||
// Add the client and clientVersion fields to the object | ||
extractedData.client = client; | ||
extractedData.clientVersion = clientVersion; | ||
delete extractedData.clientInfo; | ||
} | ||
if (!input.cliVersion) { | ||
extractedData.cliVersion = cliVersion; | ||
} | ||
return extractedData; | ||
} | ||
// Creates a local resource object containing the resource URL, mimetype, content, sha, and any | ||
@@ -60,0 +94,0 @@ // other additional resources attributes. |
{ | ||
"name": "@percy/core", | ||
"version": "1.27.5-alpha.0", | ||
"version": "1.27.5-beta.0", | ||
"license": "MIT", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"access": "public", | ||
"tag": "alpha" | ||
"tag": "latest" | ||
}, | ||
@@ -47,7 +47,7 @@ "engines": { | ||
"dependencies": { | ||
"@percy/client": "1.27.5-alpha.0", | ||
"@percy/config": "1.27.5-alpha.0", | ||
"@percy/dom": "1.27.5-alpha.0", | ||
"@percy/logger": "1.27.5-alpha.0", | ||
"@percy/webdriver-utils": "1.27.5-alpha.0", | ||
"@percy/client": "1.27.5-beta.0", | ||
"@percy/config": "1.27.5-beta.0", | ||
"@percy/dom": "1.27.5-beta.0", | ||
"@percy/logger": "1.27.5-beta.0", | ||
"@percy/webdriver-utils": "1.27.5-beta.0", | ||
"content-disposition": "^0.5.4", | ||
@@ -63,3 +63,3 @@ "cross-spawn": "^7.0.3", | ||
}, | ||
"gitHead": "8ecc32db25f708a01192b8454d0fdf9c051f48a0" | ||
"gitHead": "5fed59aa21112e7854a414306504ce7243df7365" | ||
} |
@@ -42,2 +42,5 @@ // utility types | ||
disableShadowDOM?: boolean; | ||
enableLayout?: boolean; | ||
domTransformation?: string; | ||
reshuffleInvalidTags?: boolean; | ||
devicePixelRatio?: number; | ||
@@ -44,0 +47,0 @@ scope?: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187470
4530
+ Added@percy/client@1.27.5-beta.0(transitive)
+ Added@percy/config@1.27.5-beta.0(transitive)
+ Added@percy/dom@1.27.5-beta.0(transitive)
+ Added@percy/env@1.27.5-beta.0(transitive)
+ Added@percy/logger@1.27.5-beta.0(transitive)
+ Added@percy/sdk-utils@1.27.5-beta.0(transitive)
+ Added@percy/webdriver-utils@1.27.5-beta.0(transitive)
- Removed@percy/client@1.27.5-alpha.0(transitive)
- Removed@percy/config@1.27.5-alpha.0(transitive)
- Removed@percy/dom@1.27.5-alpha.0(transitive)
- Removed@percy/env@1.27.5-alpha.0(transitive)
- Removed@percy/logger@1.27.5-alpha.0(transitive)
- Removed@percy/sdk-utils@1.27.5-alpha.0(transitive)
- Removed@percy/webdriver-utils@1.27.5-alpha.0(transitive)
Updated@percy/client@1.27.5-beta.0
Updated@percy/config@1.27.5-beta.0
Updated@percy/dom@1.27.5-beta.0
Updated@percy/logger@1.27.5-beta.0