Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return !leafFolderName.startsWith('.')
})
.map(entry => {
// If this is a scope (folder starts with @), return all
// folders inside it (scoped packages)
if (/@.*$/.test(entry)) {
return getDirectories(entry)
} else {
return entry
}
})
// Remove path from all strings
// e.g. turn bla/bla/node_modules/@babel/core
// into @babel/core
nodeModules = flatten(nodeModules).map((entry: string) =>
getLeafFolderName(entry)
)
return nodeModules
}
console.error(`Failed to find node_modules at ${this.dir}`)
return null
}
}
export function getPropertiesOfObjectAssignOrExtendHelper(
node,
blockScopeNode
) {
// Check all the args and recursively try to get props of identifiers (although they may be imported)
return flatten(
node.arguments.map(arg => {
if (t.isObjectExpression(arg)) {
return arg.properties;
} else if (t.isIdentifier(arg)) {
// Recursive, although props will be empty if arg is an imported object
return getOtherPropertiesOfIdentifier(blockScopeNode, arg.name);
}
})
);
}
export function getOtherPropertiesOfIdentifier(blockScopeNode, idName) {
return flatten(
blockScopeNode.body
.map(node => {
if (t.isExpressionStatement(node)) {
// ID = value | ID.key = value | ID.key.nested = value
const { left, right } = node.expression;
if (t.isAssignmentExpression(node.expression)) {
if (t.isIdentifier(left) && left.name === idName) {
// ID = value
if (t.isObjectExpression(right)) {
// ID = {}
return right.properties; // Array
}
} else {
const { object, property: key } = left;
if (t.isIdentifier(object) && object.name === idName) {
// ID.key = value
query.questions.forEach(function (question) {
var type = question.type
var name = question.name
// generate the answers section
var answers = type === 'ANY'
? flatten.depth(Object.keys(self.registry).map(self._recordsFor.bind(self, name)), 1)
: self._recordsFor(name, type)
if (answers.length === 0) return
// generate the additionals section
var additionals = []
if (type !== 'ANY') {
answers.forEach(function (answer) {
if (answer.type !== 'PTR') return
additionals = additionals
.concat(self._recordsFor(answer.data, 'SRV'))
.concat(self._recordsFor(answer.data, 'TXT'))
})
// to populate the A and AAAA records, we need to get a set of unique
// targets from the SRV record
function teardown (server, services, cb) {
if (!Array.isArray(services)) services = [services]
services = services.filter(function (service) {
return service._activated // ignore services not currently starting or started
})
var records = flatten.depth(services.map(function (service) {
service._activated = false
var records = service._records()
records.forEach(function (record) {
record.ttl = 0 // prepare goodbye message
})
return records
}), 1)
if (records.length === 0) return cb && cb()
server.unregister(records)
// send goodbye message
server.mdns.respond(records, function () {
services.forEach(function (service) {
service.published = false
query.questions.forEach(function (question) {
var type = question.type
var name = question.name
// generate the answers section
var answers = type === 'ANY'
? flatten.depth(Object.keys(self.registry).map(self._recordsFor.bind(self, name)), 1)
: self._recordsFor(name, type)
if (answers.length === 0) return
// generate the additionals section
var additionals = []
if (type !== 'ANY') {
answers.forEach(function (answer) {
if (answer.type !== 'PTR') return
additionals = additionals
.concat(self._recordsFor(answer.data, 'SRV'))
.concat(self._recordsFor(answer.data, 'TXT'))
})
}
self.mdns.respond({ answers: answers, additionals: additionals }, function (err) {
function teardown (server, services, cb) {
if (!Array.isArray(services)) services = [services]
services = services.filter(function (service) {
return service._activated // ignore services not currently starting or started
})
var records = flatten.depth(services.map(function (service) {
service._activated = false
var records = service._records()
records.forEach(function (record) {
record.ttl = 0 // prepare goodbye message
})
return records
}), 1)
if (records.length === 0) return cb && cb()
server.unregister(records)
// send goodbye message
server.mdns.respond(records, function () {
services.forEach(function (service) {
service.published = false
query.questions.forEach(function (question) {
var type = question.type
var name = question.name
// generate the answers section
var answers = type === 'ANY'
? flatten.depth(Object.keys(self.registry).map(self._recordsFor.bind(self, name)), 1)
: self._recordsFor(name, type)
if (answers.length === 0) return
// generate the additionals section
var additionals = []
if (type !== 'ANY') {
answers.forEach(function (answer) {
if (answer.type !== 'PTR') return
additionals = additionals
.concat(self._recordsFor(answer.data, 'SRV'))
.concat(self._recordsFor(answer.data, 'TXT'))
})
// to populate the A and AAAA records, we need to get a set of unique
// targets from the SRV record
}
const parentClump = this.clumpById[layoutNodeLeaf.parent ? layoutNodeLeaf.parent.id : 0]
// TODO: find out why at aggregateNode level sometimes there's a node on its own like this
if (!parentClump) continue
if (parentClump.orientation !== 'center') {
insertAtSide = this.orientationToInsertionSide[parentClump.orientation]
}
parentClump[insertAtSide](leaf.id)
const updateSide = leaf === this.leadingLeaf ? 'center' : this.insertionSideToOrientation[insertAtSide]
this.leavesOnSide[updateSide]++
}
this.order = arrayFlatten(roots.map(rootId => arrayFlatten(this.clumpById[rootId])))
}
}
export default function resolveWithRTL(css, styles) {
const flattenedStyles = flatten(styles);
const {
aphroditeStyles,
hasInlineStyles,
inlineStyles,
} = separateStyles(flattenedStyles);
aphroditeStyles.forEach((stylesObj) => {
// The _definition key is an implementation detail of aphrodite. If aphrodite
// changes it in the future, this code will need to be updated.
const definition = stylesObj._definition;
const directionalStyles = generateDirectionalStyles(definition);
if (!directionalStyles) return;
stylesObj._definition = directionalStyles; // eslint-disable-line no-param-reassign