How to use snack-sdk - 10 common examples

To help you get started, we’ve selected a few snack-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / snack-web / src / client / components / DependencyManager.tsx View on Github external
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,
      };
    }, {});
github expo / snack-web / snack / components / DependencyManager.js View on Github external
({ 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)
                  )
              )
github expo / snack-web / src / client / components / DependencyManager.tsx View on Github external
({ 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)
                  )
              )
github expo / snack-web / snack / workers / snack-session.worker.js View on Github external
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
github expo / snack-web / src / client / components / Editor / MonacoEditor.tsx View on Github external
_getAllDependencies = (dependencies: DependencyList, sdkVersion: SDKVersion): DependencyList => ({
    // @ts-ignore
    ...mapValues(preloadedModules.dependencies[sdkVersion], version => ({ version })),
    ...dependencies,
  });
github expo / snack-web / src / client / utils / lintPackageJson.tsx View on Github external
.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')
github expo / snack-web / snack / utils / lintPackageJson.js View on Github external
.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')
        ) {
github expo / snack-web / src / client / components / DependencyManager.tsx View on Github external
      pickBy(deps, (_, name) => !isModulePreloaded(name, this.props.sdkVersion))
    );
github expo / snack-web / src / client / components / FileList / FileList.tsx View on Github external
(acc: { [key: string]: string }, name) => {
                          if (!isModulePreloaded(name, this.props.sdkVersion)) {
                            acc[name] = next.dependencies[name];
                          }

                          return acc;
                        },
                        {}
github expo / snack-web / src / client / workers / snack-session.worker.js View on Github external
create(options) {
    session = new SnackSession(options);
  },

snack-sdk

The Expo Snack SDK

MIT
Latest version published 18 days ago

Package Health Score

73 / 100
Full package analysis

Similar packages