Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const dependencies = dependencyQueryParam.split(',').reduce((acc, curr) => {
const first = curr.slice(0, 1);
// remove the first letter so we don't match stuff like `@expo/` when splitting
const [dep, version] = curr.slice(1).split('@');
const name = first + dep;
if (isModulePreloaded(name, this.props.sdkVersion)) {
return acc;
}
return {
...acc,
[name]: version || null,
};
}, {});
({ name }) =>
// If the dependency is already in props, or is in progress, don't add them
!(
dependencies[name] ||
this.props.dependencies[name] ||
isModulePreloaded(name, this.props.sdkVersion)
)
)
({ name }) =>
// If the dependency is already in props, or is in progress, don't add them
!(
dependencies[name] ||
this.props.dependencies[name] ||
isModulePreloaded(name, this.props.sdkVersion)
)
)
self.addEventListener('message', event => {
const { type, payload } = event.data;
switch (type) {
case 'INIT': {
// Initialize the snack session
snackSession = new SnackSession(payload);
snackSession.expoApiUrl = nullthrows(process.env.API_SERVER_URL);
snackSession.addStateListener(state => self.postMessage({ type: 'STATE', payload: state }));
snackSession.addPresenceListener(event =>
self.postMessage({ type: 'PRESENCE', payload: event })
);
snackSession.addErrorListener(errors => self.postMessage({ type: 'ERROR', payload: errors }));
snackSession.addLogListener(log => self.postMessage({ type: 'LOG', payload: log }));
snackSession.dependencyErrorListener = error =>
self.postMessage({ type: 'DEPENDENCY_ERROR', payload: error });
// Send the initial details
_getAllDependencies = (dependencies: DependencyList, sdkVersion: SDKVersion): DependencyList => ({
// @ts-ignore
...mapValues(preloadedModules.dependencies[sdkVersion], version => ({ version })),
...dependencies,
});
.map((it: any) => {
if (isModulePreloaded(it.key.value, sdkVersion)) {
return {
startLineNumber: it.key.loc.start.line,
endLineNumber: it.key.loc.end.line,
startColumn: it.key.loc.start.column,
endColumn: it.key.loc.end.column,
message: `The package "${
it.key.value
}" can be imported without adding to "dependencies"`,
severity: 3,
source,
};
}
if (
it.value.type !== 'Literal' ||
!(semver.validRange(it.value.value) || it.value.value === 'latest')
.map(it => {
if (isModulePreloaded(it.key.value, sdkVersion)) {
return {
startLineNumber: it.key.loc.start.line,
endLineNumber: it.key.loc.end.line,
startColumn: it.key.loc.start.column,
endColumn: it.key.loc.end.column,
message: `The package "${it.key
.value}" can be imported without adding to "dependencies"`,
severity: 3,
source,
};
}
if (
it.value.type !== 'Literal' ||
!(semver.validRange(it.value.value) || it.value.value === 'latest')
) {
pickBy(deps, (_, name) => !isModulePreloaded(name, this.props.sdkVersion))
);
(acc: { [key: string]: string }, name) => {
if (!isModulePreloaded(name, this.props.sdkVersion)) {
acc[name] = next.dependencies[name];
}
return acc;
},
{}
create(options) {
session = new SnackSession(options);
},